Skip to content

Commit

Permalink
Merge pull request #12291 from KratosMultiphysics/core/customize-skin…
Browse files Browse the repository at this point in the history
…-variable-CalculateNodalDistanceToSkinProcess

[Core] Adding possibility to customize the skin variable in `CalculateNodalDistanceToSkinProcess` when considered
  • Loading branch information
loumalouomega authored Apr 24, 2024
2 parents 66d7a8b + 1c5179d commit d4a91c0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ 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",
"visited_skin_flag" : "VISITED"
}
```

Expand All @@ -89,4 +91,10 @@ 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 saved into the skin if `save_max_distance_in_skin` is active, with `DISTANCE` set as the default value.

##### `visited_skin_flag`
Denotes the flag to set when saving a value into the skin. Default is `VISITED`.
13 changes: 9 additions & 4 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,8 @@ CalculateNodalDistanceToSkinProcess::CalculateNodalDistanceToSkinProcess(

// Assign distance variable
mpDistanceVariable = &KratosComponents<Variable<double>>::Get(ThisParameters["distance_variable"].GetString());
mpSkinDistanceVariable = &KratosComponents<Variable<double>>::Get(ThisParameters["skin_distance_variable"].GetString());
mIdVisitedFlag = KratosComponents<Flags>::Get(ThisParameters["visited_skin_flag"].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,13 +110,14 @@ 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);
p_result->Set(VISITED);
if (p_result->GetValue(r_skin_variable) < value) {
p_result->SetValue(r_skin_variable, value);
p_result->Set(mIdVisitedFlag);
}
p_variable_retriever->GetValue(rNode, r_variable) = value;
}
Expand Down Expand Up @@ -160,7 +163,9 @@ 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",
"visited_skin_flag" : "VISITED"
})");
return default_parameters;
}
Expand Down
6 changes: 6 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,12 @@ 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;

/// The flag to check if the distance is saved in the skin
Flags mIdVisitedFlag = VISITED;

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

Expand Down

0 comments on commit d4a91c0

Please sign in to comment.