-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding new hydraulic utilities #12280
base: master
Are you sure you want to change the base?
Conversation
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
}); | ||
} | ||
|
||
void HydraulicFluidAuxiliaryUtilities::TurnOffGravityOnAirElements(ModelPart &rModelPart){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you turn it on when an element changes back from air to water?
} | ||
if (FluidAuxiliaryUtilities::IsPositive(distances)){ | ||
for (unsigned int i_nodes = 0; i_nodes < r_geom.PointsNumber(); i_nodes++) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be consistent in the formatting, you either put the { in the same line or in a new one.
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
void HydraulicFluidAuxiliaryUtilities::FixCornerNodeVelocity(ModelPart &rModelPart, double MaximumAngle) | ||
{ | ||
// Obtain for each condition each neighbor condition | ||
block_for_each(rModelPart.Nodes(), [&](NodeType &rNode){ rNode.SetValue(AUX_INDEX, 0); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a method in the variable utils for doing this.
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
double acceptable_cos = cos(angle_corner_rad); | ||
double max_height = block_for_each<MaxReduction<double>>(rModelPart.Nodes(), [&](NodeType &rNode){return rNode.Z();}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think both can be const.
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
array_1d<double, 2> ids_neig; | ||
array_1d<double, 2> ids_cond; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array_1d<double, 2> ids_neig; | |
array_1d<double, 2> ids_cond; | |
array_1d<double, 2> ids_neig; | |
array_1d<double, 2> ids_cond; |
Allocate these two outside the loop.
double repeated = edgelist[edge][i].GetValue(AUX_INDEX); | ||
repeated += 1; | ||
edgelist[edge][i].SetValue(AUX_INDEX, repeated); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can avoid the get/set by directly using the get with += 1.
} | ||
} | ||
block_for_each(rModelPart.Nodes(),[&](NodeType &rNode){ | ||
if (rNode.GetValue(AUX_INDEX)*0.5>=3 && rNode.Is(MARKER)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (rNode.GetValue(AUX_INDEX)*0.5>=3 && rNode.Is(MARKER)){ | |
if (rNode.GetValue(AUX_INDEX)*0.5>=3 && rNode.Is(MARKER)){ |
Why this?
} | ||
block_for_each(rModelPart.Nodes(),[&](NodeType &rNode){ | ||
if (rNode.GetValue(AUX_INDEX)*0.5>=3 && rNode.Is(MARKER)){ | ||
Vector veloctiy = ZeroVector(3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allocate the vector outside the loop.
double value= rNode.GetValue(AUX_INDEX); | ||
rNode.SetValue(AUX_INDEX,value*0.5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment, you can avoid the get/set.
|
||
bool HydraulicFluidAuxiliaryUtilities::MaximumWaterDepthChange(const ModelPart &rModelPart){ | ||
// make sure the Ids of the Nodes start with one | ||
const double &min_Z = block_for_each<MinReduction<double>>(rModelPart.Nodes(), [&](const auto &rNode){ return rNode.Z(); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why taking a reference in here?
if (std::abs(rNode.Z() - min_Z) < 1.0e-10 && !maximum_water_depth_change){ | ||
const double inlet_phi = rNode.GetValue(AUX_DISTANCE); | ||
const double domain_phi = rNode.FastGetSolutionStepValue(DISTANCE); | ||
if (std::abs(domain_phi) > std::abs(inlet_phi)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you want to check this? Shouldn't you check that the absolute value of the difference is below a threshold?
return maximum_water_depth_change; | ||
} | ||
|
||
void HydraulicFluidAuxiliaryUtilities::CalculateArtificialViscosity(ModelPart &rModelPart, double LimiterCoefficient) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the style guide for the arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides, I just realized that MaximumArtificialViscosity
would be a much convenient variable name for this magnitude. As far as I understand, this is not a limiting coefficient but a viscosity.
void HydraulicFluidAuxiliaryUtilities::CalculateArtificialViscosity(ModelPart &rModelPart, double LimiterCoefficient) | ||
{ | ||
const auto &r_process_info = rModelPart.GetProcessInfo(); | ||
block_for_each(rModelPart.Elements(), [&](Element &rElement){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please respect indentation in this loop? It would ease quite a lot going through the code inside the block_for_each
...
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
.../FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.cpp
Outdated
Show resolved
Hide resolved
struct NodeConditionDataStruct | ||
{ | ||
NodeType Node; // Condition normal | ||
double CornerNode; // Gauss point shape functions values | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is used nowhere...
...ns/FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.h
Outdated
Show resolved
Hide resolved
...ns/FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.h
Outdated
Show resolved
Hide resolved
...ns/FluidDynamicsHydraulicsApplication/custom_utilities/hydraulic_fluid_auxiliary_utilities.h
Show resolved
Hide resolved
@@ -26,12 +26,26 @@ void AddCustomUtilitiesToPython(pybind11::module& m) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, avoid all the non-necessary changes in the format as these complicate very much differentiating the new additions.
...cations/FluidDynamicsHydraulicsApplication/tests/test_hydraulic_fluid_auxiliary_utilities.py
Outdated
Show resolved
Hide resolved
Kratos.VariableUtils().AddDof(Kratos.VELOCITY_Z,self.model_part) | ||
KratosFluidHydraulics.HydraulicFluidAuxiliaryUtilities.FixCornerNodeVelocity(self.model_part , corner_angle) | ||
tested_node = self.model_part.GetNode(33) | ||
self.assertAlmostEqual(tested_node.GetSolutionStepValue(Kratos.BODY_FORCE_Z),0.0,12) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are you checking in here? Shouldn't you check the fixity status?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides some things that I consider tiny errors, there is still room for improvement.
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.h Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…raulic_fluid_auxiliary_utilities.py Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.h Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
…es/hydraulic_fluid_auxiliary_utilities.cpp Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
@uxuech any advance in this regard? |
📝 Description
In this PR, new hydraulic utilities have been added, each thoroughly tested with corresponding tests. Below are the main changes:
🆕 Changelog