From eb20a06077e0b3c6e154a1a3a7e90fb1aa2d48a2 Mon Sep 17 00:00:00 2001 From: Vicente Mataix Ferrandiz Date: Mon, 4 Mar 2024 10:50:03 +0100 Subject: [PATCH] Revert local flags --- ...alculate_nodal_distance_to_skin_process.md | 8 ++--- ...lculate_nodal_distance_to_skin_process.cpp | 29 +++++++------------ ...calculate_nodal_distance_to_skin_process.h | 10 ++++--- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/docs/pages/Kratos/Processes/Calculation/calculate_nodal_distance_to_skin_process.md b/docs/pages/Kratos/Processes/Calculation/calculate_nodal_distance_to_skin_process.md index 661dabc5b1eb..b01e6c03be22 100644 --- a/docs/pages/Kratos/Processes/Calculation/calculate_nodal_distance_to_skin_process.md +++ b/docs/pages/Kratos/Processes/Calculation/calculate_nodal_distance_to_skin_process.md @@ -44,9 +44,9 @@ This algorithm defines 4 lambda functions for calculating the distance of nodes - **`distance_lambda_non_historica_save_skin`**: Performs the same operations as `distance_lambda_historical_save_skin` but for non-historical variables. -These lambdas functions will be chosen depending on the flags `HISTORICAL_VALUE` and `SAVE_DISTANCE_IN_SKIN`, one of the four lambda functions is selected for execution. This decision dictates whether historical or non-historical variables are used and whether distances are saved in the skin model part. +These lambdas functions will be chosen depending on the flags `mHistoricalValue` and `mSaveDistanceInSkin`, one of the four lambda functions is selected for execution. This decision dictates whether historical or non-historical variables are used and whether distances are saved in the skin model part. -If the `SAVE_DISTANCE_IN_SKIN` flag is set, initializes the distance variable to zero for all elements or conditions in the skin model part. +If the `mSaveDistanceInSkin` flag is set, initializes the distance variable to zero for all elements or conditions in the skin model part. Both lambda functions take the following parameters: - `Nodes`: A reference to the container holding the nodes for which distances will be calculated. @@ -61,8 +61,8 @@ The selected lambda function is then applied to calculate the distances for all > A warning is issued if both elements and conditions are found in the skin model part, indicating that elements will be considered for the distance calculation. #### Flags -- `HISTORICAL_VALUE`: Determines whether historical or non-historical variables are used for distance calculations. -- `SAVE_DISTANCE_IN_SKIN`: Indicates whether the calculated distances should be saved back to the skin model part, updating the values if the new distance is greater than the existing one. +- `mHistoricalValue`: Determines whether historical or non-historical variables are used for distance calculations. +- `mSaveDistanceInSkin`: Indicates whether the calculated distances should be saved back to the skin model part, updating the values if the new distance is greater than the existing one. ## Parameters & Defaults diff --git a/kratos/processes/calculate_nodal_distance_to_skin_process.cpp b/kratos/processes/calculate_nodal_distance_to_skin_process.cpp index a2e4e344bd01..d1a80c34d471 100644 --- a/kratos/processes/calculate_nodal_distance_to_skin_process.cpp +++ b/kratos/processes/calculate_nodal_distance_to_skin_process.cpp @@ -24,13 +24,6 @@ namespace Kratos { -/// Local Flags -KRATOS_CREATE_LOCAL_FLAG( CalculateNodalDistanceToSkinProcess, HISTORICAL_VALUE, 0 ); -KRATOS_CREATE_LOCAL_FLAG( CalculateNodalDistanceToSkinProcess, SAVE_DISTANCE_IN_SKIN, 1 ); - -/***********************************************************************************/ -/***********************************************************************************/ - CalculateNodalDistanceToSkinProcess::CalculateNodalDistanceToSkinProcess( ModelPart& rVolumeModelPart, ModelPart& rSkinModelPart, @@ -38,7 +31,9 @@ CalculateNodalDistanceToSkinProcess::CalculateNodalDistanceToSkinProcess( const std::string& rDistanceVariableName, const bool SaveDistanceInSkin ) : mrVolumeModelPart(rVolumeModelPart), - mrSkinModelPart(rSkinModelPart) + mrSkinModelPart(rSkinModelPart), + mHistoricalValue(HistoricalVariable), + mSaveDistanceInSkin(SaveDistanceInSkin) { // Assign distance variable if (rDistanceVariableName != "") { @@ -46,10 +41,8 @@ CalculateNodalDistanceToSkinProcess::CalculateNodalDistanceToSkinProcess( } // Setting flags - this->Set(HISTORICAL_VALUE, HistoricalVariable); // If SaveDistanceInSkin is true we can not use parallel algorithms and therefore a warning will be raised - KRATOS_WARNING_IF("CalculateNodalDistanceToSkinProcess", SaveDistanceInSkin) << "SaveDistanceInSkin is true, therefore the parallel algorithms will not be used." << std::endl; - this->Set(SAVE_DISTANCE_IN_SKIN, SaveDistanceInSkin); + KRATOS_WARNING_IF("CalculateNodalDistanceToSkinProcess", mSaveDistanceInSkin) << "SaveDistanceInSkin is true, therefore the parallel algorithms will not be used." << std::endl; // 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; @@ -70,15 +63,15 @@ CalculateNodalDistanceToSkinProcess::CalculateNodalDistanceToSkinProcess( // If historical or non-historical variables const std::string database = ThisParameters["distance_database"].GetString(); if (database == "nodal_historical") { - this->Set(HISTORICAL_VALUE, true); + mHistoricalValue = true; } else if (database == "nodal_non_historical") { - this->Set(HISTORICAL_VALUE, false); + mHistoricalValue = false; } else { KRATOS_ERROR << "Only options are nodal_historical and nodal_non_historical, provided is: " << database << std::endl; } // Save distance in skin flag - this->Set(SAVE_DISTANCE_IN_SKIN, ThisParameters["save_distance_in_skin"].GetBool()); + mSaveDistanceInSkin = ThisParameters["save_distance_in_skin"].GetBool(); // Assign distance variable mpDistanceVariable = &KratosComponents>::Get(ThisParameters["distance_variable"].GetString()); @@ -136,7 +129,7 @@ void CalculateNodalDistanceToSkinProcess::Execute() }; // Call lambda depending on the flags - const auto* p_distance_lambda = this->Is(HISTORICAL_VALUE) ? (this->Is(SAVE_DISTANCE_IN_SKIN) ? &distance_lambda_historical_save_skin : &distance_lambda_historical) : (this->Is(SAVE_DISTANCE_IN_SKIN) ? &distance_lambda_non_historica_save_skin : &distance_lambda_non_historical); + const auto* p_distance_lambda = mHistoricalValue ? (mSaveDistanceInSkin ? &distance_lambda_historical_save_skin : &distance_lambda_historical) : (mSaveDistanceInSkin ? &distance_lambda_non_historica_save_skin : &distance_lambda_non_historical); // First try to detect if elements or conditions const std::size_t number_of_elements_skin = mrSkinModelPart.NumberOfElements(); @@ -146,7 +139,7 @@ void CalculateNodalDistanceToSkinProcess::Execute() GeometricalObjectsBins bins(mrSkinModelPart.ElementsBegin(), mrSkinModelPart.ElementsEnd()); // Set to zero in skin if required - if (this->Is(SAVE_DISTANCE_IN_SKIN)) { + if (mSaveDistanceInSkin) { VariableUtils().SetNonHistoricalVariableToZero(*mpDistanceVariable, mrSkinModelPart.Elements()); } @@ -156,7 +149,7 @@ void CalculateNodalDistanceToSkinProcess::Execute() GeometricalObjectsBins bins(mrSkinModelPart.ConditionsBegin(), mrSkinModelPart.ConditionsEnd()); // Set to zero in skin if required - if (this->Is(SAVE_DISTANCE_IN_SKIN)) { + if (mSaveDistanceInSkin) { VariableUtils().SetNonHistoricalVariableToZero(*mpDistanceVariable, mrSkinModelPart.Conditions()); } @@ -203,7 +196,7 @@ void CalculateNodalDistanceToSkinProcess::PrintInfo(std::ostream& rOStream) cons void CalculateNodalDistanceToSkinProcess::PrintData(std::ostream& rOStream) const { - rOStream << "Volume model part:\n" << mrVolumeModelPart << "\nSkin model part:\n" << mrSkinModelPart << "\nHistorical variable: " << std::boolalpha << this->Is(HISTORICAL_VALUE) << "\nSave distance in skin: " << std::boolalpha << this->Is(SAVE_DISTANCE_IN_SKIN) << "\nDistance variable: " << mpDistanceVariable->Name() << std::endl; + rOStream << "Volume model part:\n" << mrVolumeModelPart << "\nSkin model part:\n" << mrSkinModelPart << "\nHistorical variable: " << std::boolalpha << mHistoricalValue << "\nSave distance in skin: " << std::boolalpha << mSaveDistanceInSkin << "\nDistance variable: " << mpDistanceVariable->Name() << std::endl; } } // namespace Kratos. \ No newline at end of file diff --git a/kratos/processes/calculate_nodal_distance_to_skin_process.h b/kratos/processes/calculate_nodal_distance_to_skin_process.h index 1b8faa2181a3..d6c025fe9d60 100644 --- a/kratos/processes/calculate_nodal_distance_to_skin_process.h +++ b/kratos/processes/calculate_nodal_distance_to_skin_process.h @@ -42,10 +42,6 @@ class KRATOS_API(KRATOS_CORE) CalculateNodalDistanceToSkinProcess ///@name Type Definitions ///@{ - /// Local Flags - KRATOS_DEFINE_LOCAL_FLAG( HISTORICAL_VALUE ); /// This flag is used in order to check if the values are historical - KRATOS_DEFINE_LOCAL_FLAG( SAVE_DISTANCE_IN_SKIN ); /// This flag is used in order to save the highest distance in the found geometries of the skin - /// Pointer definition of CalculateNodalDistanceToSkinProcess KRATOS_CLASS_POINTER_DEFINITION(CalculateNodalDistanceToSkinProcess); @@ -149,6 +145,12 @@ class KRATOS_API(KRATOS_CORE) CalculateNodalDistanceToSkinProcess /// Pointer to the distance variable. const Variable* mpDistanceVariable = &DISTANCE; + /// This flag is used in order to check if the values are historical + bool mHistoricalValue = true; + + /// This flag is used in order to save the highest distance in the found geometries of the skin + bool mSaveDistanceInSkin = false; + ///@} ///@name Private Operators ///@{