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_surface_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: Ignasi de Pouplana,
11 // Vahid Galavi
12 //
13 
14 #pragma once
15 
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  "first_reference_coordinate": [0.0,1.0,0.0],
47  "second_reference_coordinate": [1.0,0.5,0.0],
48  "third_reference_coordinate": [1.0,0.5,0.0],
49  "specific_weight" : 10000.0,
50  "pressure_tension_cut_off" : 0.0,
51  "table" : [0,1,2]
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["third_reference_coordinate"];
59 
60  rParameters["variable_name"];
61  rParameters["model_part_name"];
62 
63  mIsFixedProvided = rParameters.Has("is_fixed");
64 
65  // Now validate against defaults -- this also ensures no type mismatch
66  rParameters.ValidateAndAssignDefaults(default_parameters);
67 
68  mVariableName = rParameters["variable_name"].GetString();
69  mIsFixed = rParameters["is_fixed"].GetBool();
70  mIsSeepage = rParameters["is_seepage"].GetBool();
71  mGravityDirection = rParameters["gravity_direction"].GetInt();
72  mFirstReferenceCoordinate = rParameters["first_reference_coordinate"].GetVector();
73  mSecondReferenceCoordinate = rParameters["second_reference_coordinate"].GetVector();
74  mThirdReferenceCoordinate = rParameters["third_reference_coordinate"].GetVector();
75 
76  calculateEquationParameters();
77 
78  mSpecificWeight = rParameters["specific_weight"].GetDouble();
79  mPressureTensionCutOff = rParameters["pressure_tension_cut_off"].GetDouble();
80 
81  KRATOS_CATCH("")
82  }
83 
87 
90  void ExecuteInitialize() override
91  {
93 
95  Vector3 direction = ZeroVector(3);
96  direction[mGravityDirection] = 1.0;
97 
98  block_for_each(mrModelPart.Nodes(), [&var, &direction, this](Node& rNode) {
99  double distance = inner_prod(mNormalVector, rNode.Coordinates());
100  const double d = inner_prod(mNormalVector, direction);
101  distance = -(distance - mEqRHS) / d;
102  const double pressure = - PORE_PRESSURE_SIGN_FACTOR * mSpecificWeight * distance;
103  if (mIsSeepage) {
104  if (pressure < PORE_PRESSURE_SIGN_FACTOR * mPressureTensionCutOff) {
105  rNode.FastGetSolutionStepValue(var) = pressure;
106  if (mIsFixed) rNode.Fix(var);
107  } else {
108  if (mIsFixedProvided) rNode.Free(var);
109  }
110  } else {
111  if (mIsFixed) rNode.Fix(var);
112  else if (mIsFixedProvided) rNode.Free(var);
113  rNode.FastGetSolutionStepValue(var) = std::min(pressure, PORE_PRESSURE_SIGN_FACTOR * mPressureTensionCutOff);
114  }
115  });
116 
117  KRATOS_CATCH("")
118  }
119 
121  std::string Info() const override
122  {
123  return "ApplyConstantPhreaticSurfacePressureProcess";
124  }
125 
126 protected:
129  std::string mVariableName;
130  bool mIsFixed;
133  unsigned int mGravityDirection;
139  double mEqRHS;
141 
142 private:
143 
144  void calculateEquationParameters()
145  {
146  const Vector3 v1 = mSecondReferenceCoordinate - mFirstReferenceCoordinate;
147  const Vector3 v2 = mThirdReferenceCoordinate - mFirstReferenceCoordinate;
148  mNormalVector = MathUtils<double>::CrossProduct(v1, v2);
149  if (norm_2(mNormalVector) == 0.0)
150  KRATOS_ERROR << "Normal vector to phreatic surface has zero size!"
151  << std::endl;
152 
153  mEqRHS = inner_prod(mNormalVector, mFirstReferenceCoordinate);
154  }
155 
156 };
157 
158 }
Definition: apply_constant_phreatic_surface_pressure_process.hpp:26
std::string mVariableName
Definition: apply_constant_phreatic_surface_pressure_process.hpp:129
Vector3 mThirdReferenceCoordinate
Definition: apply_constant_phreatic_surface_pressure_process.hpp:137
Vector3 mFirstReferenceCoordinate
Definition: apply_constant_phreatic_surface_pressure_process.hpp:135
ApplyConstantPhreaticSurfacePressureProcess(const ApplyConstantPhreaticSurfacePressureProcess &)=delete
KRATOS_CLASS_POINTER_DEFINITION(ApplyConstantPhreaticSurfacePressureProcess)
bool mIsFixedProvided
Definition: apply_constant_phreatic_surface_pressure_process.hpp:131
double mPressureTensionCutOff
Definition: apply_constant_phreatic_surface_pressure_process.hpp:140
void ExecuteInitialize() override
Definition: apply_constant_phreatic_surface_pressure_process.hpp:90
unsigned int mGravityDirection
Definition: apply_constant_phreatic_surface_pressure_process.hpp:133
ModelPart & mrModelPart
Member Variables.
Definition: apply_constant_phreatic_surface_pressure_process.hpp:128
Vector3 mSecondReferenceCoordinate
Definition: apply_constant_phreatic_surface_pressure_process.hpp:136
ApplyConstantPhreaticSurfacePressureProcess & operator=(const ApplyConstantPhreaticSurfacePressureProcess &)=delete
bool mIsSeepage
Definition: apply_constant_phreatic_surface_pressure_process.hpp:132
Vector3 mNormalVector
Definition: apply_constant_phreatic_surface_pressure_process.hpp:138
double mEqRHS
Definition: apply_constant_phreatic_surface_pressure_process.hpp:139
bool mIsFixed
Definition: apply_constant_phreatic_surface_pressure_process.hpp:130
ApplyConstantPhreaticSurfacePressureProcess(ModelPart &model_part, Parameters rParameters)
Definition: apply_constant_phreatic_surface_pressure_process.hpp:32
double mSpecificWeight
Definition: apply_constant_phreatic_surface_pressure_process.hpp:134
std::string Info() const override
Turn back information as a string.
Definition: apply_constant_phreatic_surface_pressure_process.hpp:121
Definition: flags.h:58
KratosComponents class encapsulates a lookup table for a family of classes in a generic way.
Definition: kratos_components.h:49
static T CrossProduct(const T &a, const T &b)
Performs the vector product of the two input vectors a,b.
Definition: math_utils.h:762
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
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
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
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
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
model_part
Definition: face_heat.py:14