From 358979aaeb2b2d82bf7dd63992f48e984f6a04fb Mon Sep 17 00:00:00 2001 From: Anne van de Graaf Date: Fri, 15 Mar 2024 19:01:13 +0100 Subject: [PATCH] Addressed several code smells related to custom processes Changes include: - Made several `protected` data members `private`. Added getter functions to access them when needed. - Replaced some explicit type names by `auto`. - Declared some member functions `const`. - Changed a parameter type to a reference-to-const. - Removed an overridden member function since its body was identical to the base class implementation. - Use a range-based for loop rather than an index to iterate a vector. - Added a `static_cast` to avoid a difference in signedness. - Initialized a pointer when it is declared. Also moved the declaration closer to its first usage. - Reformatted most changes using Clang-format. - Rephrased a comment. - Renamed several variables/function parameters. These were not compliant with the Kratos Style Guide. --- ...ary_hydrostatic_pressure_table_process.hpp | 16 +- ...y_phreatic_line_pressure_table_process.hpp | 26 +-- ..._boundary_hydrostatic_pressure_process.hpp | 44 +++-- ...oundary_phreatic_line_pressure_process.hpp | 46 +++-- ...tant_interpolate_line_pressure_process.hpp | 186 +++++++++--------- 5 files changed, 181 insertions(+), 137 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_boundary_hydrostatic_pressure_table_process.hpp b/applications/GeoMechanicsApplication/custom_processes/apply_boundary_hydrostatic_pressure_table_process.hpp index 3d2979694b50..d3b7b717fbab 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_boundary_hydrostatic_pressure_table_process.hpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_boundary_hydrostatic_pressure_table_process.hpp @@ -53,14 +53,14 @@ class ApplyBoundaryHydrostaticPressureTableProcess : public ApplyConstantBoundar { KRATOS_TRY - const Variable &var = KratosComponents< Variable >::Get(mVariableName); - const double Time = mrModelPart.GetProcessInfo()[TIME]/mTimeUnitConverter; - const double deltaH = mpTable->GetValue(Time); - - block_for_each(mrModelPart.Nodes(), [&deltaH, &var, this](Node& rNode){ - const double distance = mReferenceCoordinate - rNode.Coordinates()[mGravityDirection]; - const double pressure = mSpecificWeight * (distance + deltaH); - rNode.FastGetSolutionStepValue(var) = std::max(pressure,0.0); + const auto& r_variable = KratosComponents>::Get(GetVariableName()); + const auto time = GetModelPart().GetProcessInfo()[TIME] / mTimeUnitConverter; + const auto delta_h = mpTable->GetValue(time); + + block_for_each(GetModelPart().Nodes(), [&delta_h, &r_variable, this](Node& rNode) { + const auto distance = GetReferenceCoordinate() - rNode.Coordinates()[GetGravityDirection()]; + const auto pressure = GetSpecificWeight() * (distance + delta_h); + rNode.FastGetSolutionStepValue(r_variable) = std::max(pressure, 0.0); }); KRATOS_CATCH("") } diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_boundary_phreatic_line_pressure_table_process.hpp b/applications/GeoMechanicsApplication/custom_processes/apply_boundary_phreatic_line_pressure_table_process.hpp index a5f559ff6c23..385bab01202e 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_boundary_phreatic_line_pressure_table_process.hpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_boundary_phreatic_line_pressure_table_process.hpp @@ -52,18 +52,20 @@ class ApplyBoundaryPhreaticLinePressureTableProcess : public ApplyConstantBounda { KRATOS_TRY - const Variable &var = KratosComponents< Variable >::Get(mVariableName); - const double Time = mrModelPart.GetProcessInfo()[TIME]/mTimeUnitConverter; - const double deltaH = mpTable->GetValue(Time); - - block_for_each(mrModelPart.Nodes(), [&deltaH, &var, this](Node& rNode){ - double xcoord = rNode.Coordinates()[mHorizontalDirection]; - xcoord = std::max(xcoord,mMinHorizontalCoordinate); - xcoord = std::min(xcoord,mMaxHorizontalCoordinate); - double height = mSlope * ( xcoord - mFirstReferenceCoordinate[mHorizontalDirection]) + mFirstReferenceCoordinate[mGravityDirection]; - const double distance = height - rNode.Coordinates()[mGravityDirection]; - const double pressure = mSpecificWeight * (distance + deltaH); - rNode.FastGetSolutionStepValue(var) = std::max(pressure,0.0); + const auto& r_variable = KratosComponents>::Get(GetVariableName()); + const auto time = GetModelPart().GetProcessInfo()[TIME] / mTimeUnitConverter; + const auto delta_h = mpTable->GetValue(time); + + block_for_each(GetModelPart().Nodes(), [&delta_h, &r_variable, this](Node& rNode) { + auto xcoord = rNode.Coordinates()[GetHorizontalDirection()]; + xcoord = std::max(xcoord, GetMinHorizontalCoordinate()); + xcoord = std::min(xcoord, GetMaxHorizontalCoordinate()); + const auto height = + GetSlope() * (xcoord - GetFirstReferenceCoordinate()[GetHorizontalDirection()]) + + GetFirstReferenceCoordinate()[GetGravityDirection()]; + const auto distance = height - rNode.Coordinates()[GetGravityDirection()]; + const auto pressure = GetSpecificWeight() * (distance + delta_h); + rNode.FastGetSolutionStepValue(r_variable) = std::max(pressure, 0.0); }); KRATOS_CATCH("") diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_constant_boundary_hydrostatic_pressure_process.hpp b/applications/GeoMechanicsApplication/custom_processes/apply_constant_boundary_hydrostatic_pressure_process.hpp index 74da66467b95..275a826c2af2 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_constant_boundary_hydrostatic_pressure_process.hpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_constant_boundary_hydrostatic_pressure_process.hpp @@ -46,8 +46,8 @@ class ApplyConstantBoundaryHydrostaticPressureProcess : public Process "table" : 1 } )" ); - // Some values need to be mandatorily prescribed since no meaningful default value exist. For this reason try accessing to them - // So that an error is thrown if they don't exist + // Some values have to be input by the user since no meaningful default value exist. For + // this reason, we try to access them, so that an error is thrown if they don't exist. rParameters["reference_coordinate"]; rParameters["variable_name"]; rParameters["model_part_name"]; @@ -59,7 +59,7 @@ class ApplyConstantBoundaryHydrostaticPressureProcess : public Process mVariableName = rParameters["variable_name"].GetString(); mIsFixed = rParameters["is_fixed"].GetBool(); - mGravityDirection = rParameters["gravity_direction"].GetInt(); + mGravityDirection = static_cast(rParameters["gravity_direction"].GetInt()); mReferenceCoordinate = rParameters["reference_coordinate"].GetDouble(); mSpecificWeight = rParameters["specific_weight"].GetDouble(); @@ -77,14 +77,15 @@ class ApplyConstantBoundaryHydrostaticPressureProcess : public Process { KRATOS_TRY - const Variable &var = KratosComponents< Variable >::Get(mVariableName); + const auto& r_variable = KratosComponents>::Get(GetVariableName()); - block_for_each(mrModelPart.Nodes(), [&var, this](Node& rNode) { - if (mIsFixed) rNode.Fix(var); - else if (mIsFixedProvided) rNode.Free(var); + block_for_each(GetModelPart().Nodes(), [&r_variable, this](Node& rNode) { + if (mIsFixed) rNode.Fix(r_variable); + else if (mIsFixedProvided) rNode.Free(r_variable); - const double pressure = mSpecificWeight * (mReferenceCoordinate - rNode.Coordinates()[mGravityDirection]); - rNode.FastGetSolutionStepValue(var) = std::max(pressure, 0.); + const auto pressure = GetSpecificWeight() * (GetReferenceCoordinate() - + rNode.Coordinates()[GetGravityDirection()]); + rNode.FastGetSolutionStepValue(r_variable) = std::max(pressure, 0.); }); KRATOS_CATCH("") @@ -96,15 +97,24 @@ class ApplyConstantBoundaryHydrostaticPressureProcess : public Process return "ApplyConstantBoundaryHydrostaticPressureProcess"; } -protected: - /// Member Variables - ModelPart& mrModelPart; - std::string mVariableName; - bool mIsFixed; - bool mIsFixedProvided; + ModelPart& GetModelPart() { return mrModelPart; } + + [[nodiscard]] const std::string& GetVariableName() const { return mVariableName; } + + [[nodiscard]] unsigned int GetGravityDirection() const { return mGravityDirection; } + + [[nodiscard]] double GetReferenceCoordinate() const { return mReferenceCoordinate; } + + [[nodiscard]] double GetSpecificWeight() const { return mSpecificWeight; } + +private: + ModelPart& mrModelPart; + std::string mVariableName; + bool mIsFixed; + bool mIsFixedProvided; unsigned int mGravityDirection; - double mReferenceCoordinate; - double mSpecificWeight; + double mReferenceCoordinate; + double mSpecificWeight; }; } \ No newline at end of file diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_constant_boundary_phreatic_line_pressure_process.hpp b/applications/GeoMechanicsApplication/custom_processes/apply_constant_boundary_phreatic_line_pressure_process.hpp index 35740842723e..763d4c54e5d3 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_constant_boundary_phreatic_line_pressure_process.hpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_constant_boundary_phreatic_line_pressure_process.hpp @@ -129,21 +129,43 @@ class ApplyConstantBoundaryPhreaticLinePressureProcess : public Process } protected: - /// Member Variables - ModelPart& mrModelPart; - std::string mVariableName; - bool mIsFixed; - bool mIsFixedProvided; + [[nodiscard]] const ModelPart& GetModelPart() const { return mrModelPart; } + + [[nodiscard]] ModelPart& GetModelPart() { return mrModelPart; } + + [[nodiscard]] const std::string& GetVariableName() const { return mVariableName; } + + [[nodiscard]] unsigned int GetGravityDirection() const { return mGravityDirection; } + + [[nodiscard]] unsigned int GetHorizontalDirection() const { return mHorizontalDirection; } + + [[nodiscard]] double GetSpecificWeight() const { return mSpecificWeight; } + + [[nodiscard]] const Vector3& GetFirstReferenceCoordinate() const + { + return mFirstReferenceCoordinate; + } + + [[nodiscard]] double GetSlope() const { return mSlope; } + + [[nodiscard]] double GetMinHorizontalCoordinate() const { return mMinHorizontalCoordinate; } + + [[nodiscard]] double GetMaxHorizontalCoordinate() const { return mMaxHorizontalCoordinate; } + +private: + ModelPart& mrModelPart; + std::string mVariableName; + bool mIsFixed; + bool mIsFixedProvided; unsigned int mGravityDirection; unsigned int mHorizontalDirection; - double mSpecificWeight; + double mSpecificWeight; unsigned int mOutOfPlaneDirection; - Vector3 mFirstReferenceCoordinate; - Vector3 mSecondReferenceCoordinate; - double mSlope; - double mMinHorizontalCoordinate; - double mMaxHorizontalCoordinate; - + Vector3 mFirstReferenceCoordinate; + Vector3 mSecondReferenceCoordinate; + double mSlope; + double mMinHorizontalCoordinate; + double mMaxHorizontalCoordinate; }; } \ No newline at end of file diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_constant_interpolate_line_pressure_process.hpp b/applications/GeoMechanicsApplication/custom_processes/apply_constant_interpolate_line_pressure_process.hpp index 85d01621db7d..d9f57ec23279 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_constant_interpolate_line_pressure_process.hpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_constant_interpolate_line_pressure_process.hpp @@ -86,11 +86,6 @@ class ApplyConstantInterpolateLinePressureProcess : public Process ApplyConstantInterpolateLinePressureProcess(ApplyConstantInterpolateLinePressureProcess&&) = delete; ApplyConstantInterpolateLinePressureProcess& operator=(ApplyConstantInterpolateLinePressureProcess&&) = delete; - /// Execute method is used to execute the ApplyConstantInterpolateLinePressureProcess algorithms. - void Execute() override - { - } - /// this function is designed for being called at the beginning of the computations /// right after reading the model and the groups void ExecuteInitialize() override @@ -196,13 +191,13 @@ class ApplyConstantInterpolateLinePressureProcess : public Process } - void InterpolateBoundaryPressureWithOneContainer(const Node &rNode, - const std::vector< Node*> &BoundaryNodes, - double &pressure, - double &coordinate ) + void InterpolateBoundaryPressureWithOneContainer(const Node& rNode, + const std::vector& rBoundaryNodes, + double& rPressure, + double& rCoordinate) const { std::vector< Node*> FoundNodes; - FindTwoClosestNodeOnBoundaryNodes(rNode, BoundaryNodes, FoundNodes); + FindTwoClosestNodeOnBoundaryNodes(rNode, rBoundaryNodes, FoundNodes); const Variable &var = KratosComponents< Variable >::Get(mVariableName); @@ -216,75 +211,90 @@ class ApplyConstantInterpolateLinePressureProcess : public Process // calculate pressure if (std::abs(CoordinatesRight[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]) > TINY) { - const double slopeP = (pressureRight - pressureLeft) / (CoordinatesRight[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]); - pressure = slopeP * (rNode.Coordinates()[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]) + pressureLeft; - - const double slopeY = (CoordinatesRight[mGravityDirection] - CoordinatesLeft[mGravityDirection]) / (CoordinatesRight[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]); - coordinate = slopeY * (rNode.Coordinates()[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]) + CoordinatesLeft[mGravityDirection]; + const auto slope_p = + (pressureRight - pressureLeft) / + (CoordinatesRight[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]); + rPressure = slope_p * (rNode.Coordinates()[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]) + + pressureLeft; + + const auto slope_y = + (CoordinatesRight[mGravityDirection] - CoordinatesLeft[mGravityDirection]) / + (CoordinatesRight[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]); + rCoordinate = slope_y * (rNode.Coordinates()[mHorizontalDirection] - + CoordinatesLeft[mHorizontalDirection]) + + CoordinatesLeft[mGravityDirection]; } else { - pressure = pressureLeft; - coordinate = CoordinatesLeft[mGravityDirection]; + rPressure = pressureLeft; + rCoordinate = CoordinatesLeft[mGravityDirection]; } } - void InterpolateBoundaryPressure(const Node &rNode, - const Node *LeftNode, - const Node *RightNode, - double &pressure, - double &coordinate ) + void InterpolateBoundaryPressure(const Node& rNode, + const Node* pLeftNode, + const Node* pRightNode, + double& rPressure, + double& rCoordinate) const { - const Variable &var = KratosComponents< Variable >::Get(mVariableName); + const auto& r_variable = KratosComponents>::Get(mVariableName); - const double &pressureLeft = LeftNode->FastGetSolutionStepValue(var); - Vector3 CoordinatesLeft; - noalias(CoordinatesLeft) = LeftNode->Coordinates(); + const auto pressure_left = pLeftNode->FastGetSolutionStepValue(r_variable); + Vector3 coordinates_left; + noalias(coordinates_left) = pLeftNode->Coordinates(); - const double &pressureRight = RightNode->FastGetSolutionStepValue(var); - Vector3 CoordinatesRight; - noalias(CoordinatesRight) = RightNode->Coordinates(); + const auto pressure_right = pRightNode->FastGetSolutionStepValue(r_variable); + Vector3 coordinates_right; + noalias(coordinates_right) = pRightNode->Coordinates(); // calculate pressure - if (std::abs(CoordinatesRight[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]) > TINY) { - const double slopeP = (pressureRight - pressureLeft) / (CoordinatesRight[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]); - pressure = slopeP * (rNode.Coordinates()[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]) + pressureLeft; - - const double slopeY = (CoordinatesRight[mGravityDirection] - CoordinatesLeft[mGravityDirection]) / (CoordinatesRight[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]); - coordinate = slopeY * (rNode.Coordinates()[mHorizontalDirection] - CoordinatesLeft[mHorizontalDirection]) + CoordinatesLeft[mGravityDirection]; + if (std::abs(coordinates_right[mHorizontalDirection] - coordinates_left[mHorizontalDirection]) > TINY) { + const auto slope_p = + (pressure_right - pressure_left) / + (coordinates_right[mHorizontalDirection] - coordinates_left[mHorizontalDirection]); + rPressure = slope_p * (rNode.Coordinates()[mHorizontalDirection] - + coordinates_left[mHorizontalDirection]) + + pressure_left; + + const auto slope_y = + (coordinates_right[mGravityDirection] - coordinates_left[mGravityDirection]) / + (coordinates_right[mHorizontalDirection] - coordinates_left[mHorizontalDirection]); + rCoordinate = slope_y * (rNode.Coordinates()[mHorizontalDirection] - + coordinates_left[mHorizontalDirection]) + + coordinates_left[mGravityDirection]; } else { - pressure = pressureLeft; - coordinate = CoordinatesLeft[mGravityDirection]; + rPressure = pressure_left; + rCoordinate = coordinates_left[mGravityDirection]; } } - void FindTwoClosestNodeOnBoundaryNodes(const Node &rNode, - const std::vector< Node*> &BoundaryNodes, - std::vector< Node*> &FoundNodes) + void FindTwoClosestNodeOnBoundaryNodes(const Node& rNode, + const std::vector& rBoundaryNodes, + std::vector& rFoundNodes) const { const double HorizontalCoordinate = rNode.Coordinates()[mHorizontalDirection]; - FoundNodes.resize(2); + rFoundNodes.resize(2); unsigned int nFound = 0; double horizontalDistanceClosest_1 = LARGE; - for (unsigned int i = 0; i < BoundaryNodes.size(); ++i) { + for (auto boundary_node : rBoundaryNodes) { Vector3 CoordinatesBoundary; - noalias(CoordinatesBoundary) = BoundaryNodes[i]->Coordinates(); + noalias(CoordinatesBoundary) = boundary_node->Coordinates(); if (std::abs(CoordinatesBoundary[mHorizontalDirection] - HorizontalCoordinate) <= horizontalDistanceClosest_1) { horizontalDistanceClosest_1 = std::abs(CoordinatesBoundary[mHorizontalDirection] - HorizontalCoordinate); - FoundNodes[0] = BoundaryNodes[i]; + rFoundNodes[0] = boundary_node; nFound++; } } double horizontalDistanceClosest_2 = LARGE; - for (unsigned int i = 0; i < BoundaryNodes.size(); ++i) { + for (auto boundary_node : rBoundaryNodes) { Vector3 CoordinatesBoundary; - noalias(CoordinatesBoundary) = BoundaryNodes[i]->Coordinates(); + noalias(CoordinatesBoundary) = boundary_node->Coordinates(); if (std::abs(CoordinatesBoundary[mHorizontalDirection] - HorizontalCoordinate) <= horizontalDistanceClosest_2 && std::abs(CoordinatesBoundary[mHorizontalDirection] - HorizontalCoordinate) > horizontalDistanceClosest_1) { horizontalDistanceClosest_2 = std::abs(CoordinatesBoundary[mHorizontalDirection] - HorizontalCoordinate); - FoundNodes[1] = BoundaryNodes[i]; + rFoundNodes[1] = boundary_node; nFound++; } } @@ -298,36 +308,36 @@ class ApplyConstantInterpolateLinePressureProcess : public Process const bool isBottom) { const double HorizontalCoordinate = rNode.Coordinates()[mHorizontalDirection]; - Node *pNode; std::vector< Node*> FoundNodes; double horizontalDistance = LARGE; - for (unsigned int i = 0; i < BoundaryNodes.size(); ++i) { - if (std::abs(BoundaryNodes[i]->Coordinates()[mHorizontalDirection] - HorizontalCoordinate) <= horizontalDistance) { - horizontalDistance = std::abs(BoundaryNodes[i]->Coordinates()[mHorizontalDirection] - HorizontalCoordinate); - FoundNodes.push_back(BoundaryNodes[i]); + for (auto boundary_node : BoundaryNodes) { + if (std::abs(boundary_node->Coordinates()[mHorizontalDirection] - HorizontalCoordinate) <= horizontalDistance) { + horizontalDistance = std::abs(boundary_node->Coordinates()[mHorizontalDirection] - HorizontalCoordinate); + FoundNodes.push_back(boundary_node); } } + Node* p_result = nullptr; if (isBottom) { double height = LARGE; - for (unsigned int i = 0; i < FoundNodes.size(); ++i) { - if (FoundNodes[i]->Coordinates()[mGravityDirection] < height) { - pNode = FoundNodes[i]; - height = FoundNodes[i]->Coordinates()[mGravityDirection]; + for (auto found_node : FoundNodes) { + if (found_node->Coordinates()[mGravityDirection] < height) { + p_result = found_node; + height = found_node->Coordinates()[mGravityDirection]; } } } else { double height = -LARGE; - for (unsigned int i = 0; i < FoundNodes.size(); ++i) { - if (FoundNodes[i]->Coordinates()[mGravityDirection] > height) { - pNode = FoundNodes[i]; - height = FoundNodes[i]->Coordinates()[mGravityDirection]; + for (auto found_node : FoundNodes) { + if (found_node->Coordinates()[mGravityDirection] > height) { + p_result = found_node; + height = found_node->Coordinates()[mGravityDirection]; } } } - return pNode; + return p_result; } void FindTopBoundaryNodes(const Node &rNode, @@ -352,26 +362,26 @@ class ApplyConstantInterpolateLinePressureProcess : public Process } } - void FindLeftBoundaryNodes(const Node &rNode, - const std::vector< Node*> &BoundaryNodes, - std::vector< Node*> &LeftBoundaryNodes) + void FindLeftBoundaryNodes(const Node& rNode, + const std::vector& rBoundaryNodes, + std::vector& rLeftBoundaryNodes) const { - for (unsigned int i = 0; i < BoundaryNodes.size(); ++i) { - if (BoundaryNodes[i]->Coordinates()[mHorizontalDirection] <= rNode.Coordinates()[mHorizontalDirection]) { + for (unsigned int i = 0; i < rBoundaryNodes.size(); ++i) { + if (rBoundaryNodes[i]->Coordinates()[mHorizontalDirection] <= rNode.Coordinates()[mHorizontalDirection]) { // node is on top boundary - LeftBoundaryNodes.push_back(BoundaryNodes[i]); + rLeftBoundaryNodes.push_back(rBoundaryNodes[i]); } } } - void FindRightBoundaryNodes(const Node &rNode, - const std::vector< Node*> &BoundaryNodes, - std::vector< Node*> &RightBoundaryNodes) + void FindRightBoundaryNodes(const Node& rNode, + const std::vector& rBoundaryNodes, + std::vector& rRightBoundaryNodes) const { - for (unsigned int i = 0; i < BoundaryNodes.size(); ++i) { - if (BoundaryNodes[i]->Coordinates()[mHorizontalDirection] >= rNode.Coordinates()[mHorizontalDirection]) { + for (unsigned int i = 0; i < rBoundaryNodes.size(); ++i) { + if (rBoundaryNodes[i]->Coordinates()[mHorizontalDirection] >= rNode.Coordinates()[mHorizontalDirection]) { // node is on top boundary - RightBoundaryNodes.push_back(BoundaryNodes[i]); + rRightBoundaryNodes.push_back(rBoundaryNodes[i]); } } } @@ -381,7 +391,7 @@ class ApplyConstantInterpolateLinePressureProcess : public Process KRATOS_TRY int MaxNodeID = -1; - block_for_each(mrModelPart.Nodes(), [&MaxNodeID](Node& rNode) { + block_for_each(mrModelPart.Nodes(), [&MaxNodeID](const Node& rNode) { #pragma omp critical MaxNodeID = std::max(MaxNodeID, rNode.Id()); }); @@ -479,43 +489,43 @@ class ApplyConstantInterpolateLinePressureProcess : public Process } - bool IsMoreThanOneElementWithThisEdgeFast(const std::vector &FaceID, - const std::vector> &ELementsOfNodes, - const std::vector &ELementsOfNodesSize) + bool IsMoreThanOneElementWithThisEdgeFast(const std::vector& rFaceIDs, + const std::vector>& rELementsOfNodes, + const std::vector& rELementsOfNodesSize) const { const int ID_UNDEFINED = -1; int nMaxElements = 0; - for (unsigned int iPoint = 0; iPoint < FaceID.size(); ++iPoint) { - int NodeID = FaceID[iPoint]; + for (unsigned int iPoint = 0; iPoint < rFaceIDs.size(); ++iPoint) { + int NodeID = rFaceIDs[iPoint]; int index = NodeID-1; - nMaxElements += ELementsOfNodesSize[index]; + nMaxElements += rELementsOfNodesSize[index]; } if (nMaxElements > 0) { std::vector> ElementIDs; - ElementIDs.resize(FaceID.size()); + ElementIDs.resize(rFaceIDs.size()); for (unsigned int i=0; i SharedElementIDs; - for (unsigned int iPoint = 0; iPoint < FaceID.size(); ++iPoint) { + for (unsigned int iPoint = 0; iPoint < rFaceIDs.size(); ++iPoint) { for (unsigned int i=0; i < ElementIDs[iPoint].size(); ++i) { int iElementID = ElementIDs[iPoint][i]; bool found = false; if (iElementID !=ID_UNDEFINED) { - for (unsigned int iPointInner = 0; iPointInner < FaceID.size(); ++iPointInner) { + for (unsigned int iPointInner = 0; iPointInner < rFaceIDs.size(); ++iPointInner) { if (iPointInner != iPoint) { //std::any_of followed by breaking out of 2 for loops for (unsigned int j = 0; j < ElementIDs[iPointInner].size(); ++j) { @@ -526,7 +536,7 @@ class ApplyConstantInterpolateLinePressureProcess : public Process } if (found) { - std::vector::iterator it = std::find(SharedElementIDs.begin(), SharedElementIDs.end(), iElementID); + auto it = std::find(SharedElementIDs.begin(), SharedElementIDs.end(), iElementID); if (it == SharedElementIDs.end()) { SharedElementIDs.push_back(iElementID); }