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_boundary_hydrostatic_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 "includes/kratos_flags.h"
17 #include "processes/process.h"
18 
20 
21 namespace Kratos
22 {
23 
25 {
26 
27 public:
28 
30 
32  Parameters rParameters
34  {
36 
37  //only include validation with c++11 since raw_literals do not exist in c++03
38  Parameters default_parameters( R"(
39  {
40  "model_part_name":"PLEASE_CHOOSE_MODEL_PART_NAME",
41  "variable_name": "PLEASE_PRESCRIBE_VARIABLE_NAME",
42  "is_fixed": false,
43  "gravity_direction" : 2,
44  "reference_coordinate" : 0.0,
45  "specific_weight" : 10000.0,
46  "table" : 1
47  } )" );
48 
49  // Some values need to be mandatorily prescribed since no meaningful default value exist. For this reason try accessing to them
50  // So that an error is thrown if they don't exist
51  rParameters["reference_coordinate"];
52  rParameters["variable_name"];
53  rParameters["model_part_name"];
54 
55  mIsFixedProvided = rParameters.Has("is_fixed");
56 
57  // Now validate against defaults -- this also ensures no type mismatch
58  rParameters.ValidateAndAssignDefaults(default_parameters);
59 
60  mVariableName = rParameters["variable_name"].GetString();
61  mIsFixed = rParameters["is_fixed"].GetBool();
62  mGravityDirection = rParameters["gravity_direction"].GetInt();
63  mReferenceCoordinate = rParameters["reference_coordinate"].GetDouble();
64  mSpecificWeight = rParameters["specific_weight"].GetDouble();
65 
66  KRATOS_CATCH("")
67  }
68 
69 
73 
76  void ExecuteInitialize() override
77  {
79 
81 
82  block_for_each(mrModelPart.Nodes(), [&var, this](Node& rNode) {
83  if (mIsFixed) rNode.Fix(var);
84  else if (mIsFixedProvided) rNode.Free(var);
85 
86  const double pressure = mSpecificWeight * (mReferenceCoordinate - rNode.Coordinates()[mGravityDirection]);
87  rNode.FastGetSolutionStepValue(var) = std::max(pressure, 0.);
88  });
89 
90  KRATOS_CATCH("")
91  }
92 
94  std::string Info() const override
95  {
96  return "ApplyConstantBoundaryHydrostaticPressureProcess";
97  }
98 
99 protected:
102  std::string mVariableName;
103  bool mIsFixed;
105  unsigned int mGravityDirection;
108 };
109 
110 }
Definition: apply_constant_boundary_hydrostatic_pressure_process.hpp:25
double mReferenceCoordinate
Definition: apply_constant_boundary_hydrostatic_pressure_process.hpp:106
ApplyConstantBoundaryHydrostaticPressureProcess(ModelPart &model_part, Parameters rParameters)
Definition: apply_constant_boundary_hydrostatic_pressure_process.hpp:31
ApplyConstantBoundaryHydrostaticPressureProcess(const ApplyConstantBoundaryHydrostaticPressureProcess &)=delete
double mSpecificWeight
Definition: apply_constant_boundary_hydrostatic_pressure_process.hpp:107
KRATOS_CLASS_POINTER_DEFINITION(ApplyConstantBoundaryHydrostaticPressureProcess)
std::string mVariableName
Definition: apply_constant_boundary_hydrostatic_pressure_process.hpp:102
unsigned int mGravityDirection
Definition: apply_constant_boundary_hydrostatic_pressure_process.hpp:105
bool mIsFixed
Definition: apply_constant_boundary_hydrostatic_pressure_process.hpp:103
ModelPart & mrModelPart
Member Variables.
Definition: apply_constant_boundary_hydrostatic_pressure_process.hpp:101
bool mIsFixedProvided
Definition: apply_constant_boundary_hydrostatic_pressure_process.hpp:104
void ExecuteInitialize() override
Definition: apply_constant_boundary_hydrostatic_pressure_process.hpp:76
std::string Info() const override
Turn back information as a string.
Definition: apply_constant_boundary_hydrostatic_pressure_process.hpp:94
ApplyConstantBoundaryHydrostaticPressureProcess & operator=(const ApplyConstantBoundaryHydrostaticPressureProcess &)=delete
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
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
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
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