KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
apply_constant_phreatic_line_pressure_process.hpp
Go to the documentation of this file.
1 // KRATOS___
2 // // ) )
3 // // ___ ___
4 // // ____ //___) ) // ) )
5 // // / / // // / /
6 // ((____/ / ((____ ((___/ / MECHANICS
7 //
8 // License: geo_mechanics_application/license.txt
9 //
10 // Main authors: Vahid Galavi
11 //
12 
13 #pragma once
14 
15 #include <algorithm>
16 #include "includes/kratos_flags.h"
18 #include "processes/process.h"
19 
21 
22 namespace Kratos
23 {
24 
26 {
27 
28 public:
29 
31 
33  Parameters rParameters
35  {
37 
38  //only include validation with c++11 since raw_literals do not exist in c++03
39  Parameters default_parameters( R"(
40  {
41  "model_part_name":"PLEASE_CHOOSE_MODEL_PART_NAME",
42  "variable_name": "PLEASE_PRESCRIBE_VARIABLE_NAME",
43  "is_fixed": false,
44  "is_seepage": false,
45  "gravity_direction": 1,
46  "out_of_plane_direction": 2,
47  "first_reference_coordinate": [0.0,1.0,0.0],
48  "second_reference_coordinate": [1.0,0.5,0.0],
49  "specific_weight" : 10000.0,
50  "pressure_tension_cut_off" : 0.0,
51  "table" : [0,1]
52  } )" );
53 
54  // Some values need to be mandatorily prescribed since no meaningful default value exist. For this reason try accessing to them
55  // So that an error is thrown if they don't exist
56  rParameters["first_reference_coordinate"];
57  rParameters["second_reference_coordinate"];
58  rParameters["variable_name"];
59  rParameters["model_part_name"];
60 
61  mIsFixedProvided = rParameters.Has("is_fixed");
62 
63  // Now validate agains defaults -- this also ensures no type mismatch
64  rParameters.ValidateAndAssignDefaults(default_parameters);
65 
66  mVariableName = rParameters["variable_name"].GetString();
67  mIsFixed = rParameters["is_fixed"].GetBool();
68  mIsSeepage = rParameters["is_seepage"].GetBool();
69  mGravityDirection = rParameters["gravity_direction"].GetInt();
70  mOutOfPlaneDirection = rParameters["out_of_plane_direction"].GetInt();
72  KRATOS_ERROR << "Gravity direction cannot be the same as Out-of-Plane directions"
73  << rParameters
74  << std::endl;
75 
77  for (unsigned int i=0; i<N_DIM_3D; ++i)
79 
80  mFirstReferenceCoordinate = rParameters["first_reference_coordinate"].GetVector();
81  mSecondReferenceCoordinate = rParameters["second_reference_coordinate"].GetVector();
82 
85 
87  {
88  KRATOS_ERROR << "First and second point on the phreatic line have the same horizontal coordinate"
89  << rParameters
90  << std::endl;
91  }
92 
95 
96  mSpecificWeight = rParameters["specific_weight"].GetDouble();
97  mPressureTensionCutOff = rParameters["pressure_tension_cut_off"].GetDouble();
98 
99  KRATOS_CATCH("")
100  }
101 
105 
108  void ExecuteInitialize() override
109  {
110  KRATOS_TRY
111 
113  block_for_each(mrModelPart.Nodes(), [&var, this](Node& rNode) {
114  const double pressure = PORE_PRESSURE_SIGN_FACTOR * CalculatePressure(rNode);
115 
116  if (mIsSeepage) {
117  if (pressure < PORE_PRESSURE_SIGN_FACTOR * mPressureTensionCutOff) { // Before 0. was used i.s.o. the tension cut off value -> no effect in any test.
118  rNode.FastGetSolutionStepValue(var) = pressure;
119  if (mIsFixed) rNode.Fix(var);
120  } else {
121  if (mIsFixedProvided) rNode.Free(var);
122  }
123  } else {
124  rNode.FastGetSolutionStepValue(var) = std::min(pressure, PORE_PRESSURE_SIGN_FACTOR * mPressureTensionCutOff);
125  if (mIsFixed) rNode.Fix(var);
126  else if (mIsFixedProvided) rNode.Free(var);
127  }
128  });
129 
130  KRATOS_CATCH("")
131  }
132 
134  std::string Info() const override
135  {
136  return "ApplyConstantPhreaticLinePressureProcess";
137  }
138 
139 protected:
142  std::string mVariableName;
143  bool mIsFixed;
146  unsigned int mGravityDirection;
148  unsigned int mOutOfPlaneDirection;
149  unsigned int mHorizontalDirection;
152  double mSlope;
156 
157  double CalculatePressure(const Node &rNode) const
158  {
159  double x = rNode.Coordinates()[mHorizontalDirection];
160  x = std::max(x, mMinHorizontalCoordinate);
161  x = std::min(x, mMaxHorizontalCoordinate);
162  const double height = mSlope * (x - mFirstReferenceCoordinate[mHorizontalDirection]) + mFirstReferenceCoordinate[mGravityDirection];
163  const double distance = height - rNode.Coordinates()[mGravityDirection];
164  return - mSpecificWeight * distance;
165  }
166 
167 };
168 
169 }
Definition: apply_constant_phreatic_line_pressure_process.hpp:26
double CalculatePressure(const Node &rNode) const
Definition: apply_constant_phreatic_line_pressure_process.hpp:157
double mSlope
Definition: apply_constant_phreatic_line_pressure_process.hpp:152
std::string Info() const override
Turn back information as a string.
Definition: apply_constant_phreatic_line_pressure_process.hpp:134
unsigned int mHorizontalDirection
Definition: apply_constant_phreatic_line_pressure_process.hpp:149
bool mIsFixedProvided
Definition: apply_constant_phreatic_line_pressure_process.hpp:144
double mPressureTensionCutOff
Definition: apply_constant_phreatic_line_pressure_process.hpp:155
double mMinHorizontalCoordinate
Definition: apply_constant_phreatic_line_pressure_process.hpp:153
std::string mVariableName
Definition: apply_constant_phreatic_line_pressure_process.hpp:142
unsigned int mGravityDirection
Definition: apply_constant_phreatic_line_pressure_process.hpp:146
ApplyConstantPhreaticLinePressureProcess(ModelPart &model_part, Parameters rParameters)
Definition: apply_constant_phreatic_line_pressure_process.hpp:32
Vector3 mFirstReferenceCoordinate
Definition: apply_constant_phreatic_line_pressure_process.hpp:150
ApplyConstantPhreaticLinePressureProcess(const ApplyConstantPhreaticLinePressureProcess &)=delete
KRATOS_CLASS_POINTER_DEFINITION(ApplyConstantPhreaticLinePressureProcess)
bool mIsFixed
Definition: apply_constant_phreatic_line_pressure_process.hpp:143
bool mIsSeepage
Definition: apply_constant_phreatic_line_pressure_process.hpp:145
ApplyConstantPhreaticLinePressureProcess & operator=(const ApplyConstantPhreaticLinePressureProcess &)=delete
unsigned int mOutOfPlaneDirection
Definition: apply_constant_phreatic_line_pressure_process.hpp:148
double mMaxHorizontalCoordinate
Definition: apply_constant_phreatic_line_pressure_process.hpp:154
Vector3 mSecondReferenceCoordinate
Definition: apply_constant_phreatic_line_pressure_process.hpp:151
ModelPart & mrModelPart
Member Variables.
Definition: apply_constant_phreatic_line_pressure_process.hpp:141
void ExecuteInitialize() override
Definition: apply_constant_phreatic_line_pressure_process.hpp:108
double mSpecificWeight
Definition: apply_constant_phreatic_line_pressure_process.hpp:147
Definition: flags.h:58
KratosComponents class encapsulates a lookup table for a family of classes in a generic way.
Definition: kratos_components.h:49
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
Vector GetVector() const
This method returns the vector contained in the current Parameter.
Definition: kratos_parameters.cpp:707
int GetInt() const
This method returns the integer contained in the current Parameter.
Definition: kratos_parameters.cpp:666
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
std::string GetString() const
This method returns the string contained in the current Parameter.
Definition: kratos_parameters.cpp:684
bool Has(const std::string &rEntry) const
This method checks if the Parameter contains a certain entry.
Definition: kratos_parameters.cpp:520
bool GetBool() const
This method returns the boolean contained in the current Parameter.
Definition: kratos_parameters.cpp:675
CoordinatesArrayType const & Coordinates() const
Definition: point.h:215
The base class for all processes in Kratos.
Definition: process.h:49
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
constexpr SizeType N_DIM_3D
Definition: geo_mechanics_application_constants.h:25
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
model_part
Definition: face_heat.py:14
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17