Skip to content

Commit

Permalink
[Core] Adding possibility to customize the skin variable in `Calculat…
Browse files Browse the repository at this point in the history
…eNodalDistanceToSkinProcess` when considered
  • Loading branch information
loumalouomega committed Apr 18, 2024
1 parent bb1a337 commit a7d0604
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ The selected lambda function is then applied to calculate the distances for all
"skin_model_part" : "",
"distance_database" : "nodal_historical",
"save_max_distance_in_skin" : false,
"distance_variable" : "DISTANCE"
"distance_variable" : "DISTANCE",
"skin_distance_variable" : "DISTANCE"
}
```

Expand All @@ -89,4 +90,7 @@ This flag indicating whether historical variable is enabled or otherwise non-his
This flag indicates if the distance is going to be saved in the skin. By default is false, if activated will save the maximum distance in the found skin geometry and set the flag `VISITED`. This also deactivate shared memory parallelization.

##### `distance_variable`
Denotes the variable for applying the process, with `DISTANCE` set as the default value.
Denotes the variable for applying the process, with `DISTANCE` set as the default value.

##### `skin_distance_variable`
Denotes the variable sved into the skin if `save_max_distance_in_skin` is active, with `DISTANCE` set as the default value.
9 changes: 6 additions & 3 deletions kratos/processes/calculate_nodal_distance_to_skin_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ CalculateNodalDistanceToSkinProcess::CalculateNodalDistanceToSkinProcess(

// Assign distance variable
mpDistanceVariable = &KratosComponents<Variable<double>>::Get(ThisParameters["distance_variable"].GetString());
mpSkinDistanceVariable = &KratosComponents<Variable<double>>::Get(ThisParameters["skin_distance_variable"].GetString());

// Check it is serial
KRATOS_ERROR_IF(mrVolumeModelPart.IsDistributed()) << "Distributed computation still not supported. Please update implementation as soon as MPI search is merged. See https://github.com/KratosMultiphysics/Kratos/pull/11719" << std::endl;
Expand Down Expand Up @@ -108,12 +109,13 @@ void CalculateNodalDistanceToSkinProcess::Execute()

const std::function<void(ModelPart::NodesContainerType& rNodes, GeometricalObjectsBins& rBins)> distance_lambda_historical_save_skin = [this, &p_variable_retriever](ModelPart::NodesContainerType& rNodes, GeometricalObjectsBins& rBins) {
const auto& r_variable = *mpDistanceVariable;
const auto& r_skin_variable = *mpSkinDistanceVariable;
for (Node& rNode: rNodes) {
auto result = rBins.SearchNearest(rNode);
const double value = result.GetDistance();
auto p_result = result.Get().get();
if (p_result->GetValue(r_variable) < value) {
p_result->SetValue(r_variable, value);
if (p_result->GetValue(r_skin_variable) < value) {
p_result->SetValue(r_skin_variable, value);
p_result->Set(VISITED);
}
p_variable_retriever->GetValue(rNode, r_variable) = value;
Expand Down Expand Up @@ -160,7 +162,8 @@ const Parameters CalculateNodalDistanceToSkinProcess::GetDefaultParameters() con
"skin_model_part" : "",
"distance_database" : "nodal_historical",
"save_max_distance_in_skin" : false,
"distance_variable" : "DISTANCE"
"distance_variable" : "DISTANCE",
"skin_distance_variable" : "DISTANCE"
})");
return default_parameters;
}
Expand Down
3 changes: 3 additions & 0 deletions kratos/processes/calculate_nodal_distance_to_skin_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ class KRATOS_API(KRATOS_CORE) CalculateNodalDistanceToSkinProcess
/// Pointer to the distance variable.
const Variable<double>* mpDistanceVariable = &DISTANCE;

/// Pointer to the skin saved distance variable.
const Variable<double>* mpSkinDistanceVariable = &DISTANCE;

/// This flag is used in order to check if the values are historical
bool mHistoricalValue = true;

Expand Down

0 comments on commit a7d0604

Please sign in to comment.