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.
structural_meshmoving_strategy.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license:
9 // kratos/license.txt
10 //
11 // Main authors: Andreas Winterstein (a.winterstein@tum.de)
12 //
13 
14 #if !defined(KRATOS_NEW_STRUCTURAL_MESHMOVING_STRATEGY)
15 #define KRATOS_NEW_STRUCTURAL_MESHMOVING_STRATEGY
16 
17 /* System includes */
18 
19 /* External includes */
20 
21 /* Project includes */
24 #include "containers/model.h"
29 
31 
32 namespace Kratos {
33 
55 
57 template <class TSparseSpace, class TDenseSpace, class TLinearSolver>
59  : public ImplicitSolvingStrategy<TSparseSpace, TDenseSpace, TLinearSolver> {
60 public:
66 
70 
79  typename TLinearSolver::Pointer pNewLinearSolver,
80  int TimeOrder = 2,
81  bool ReformDofSetAtEachStep = false,
82  bool ComputeReactions = false,
83  bool CalculateMeshVelocities = true,
84  int EchoLevel = 0,
85  const double PoissonRatio = 0.3,
86  const bool ReInitializeModelPartEachStep = false)
87  : ImplicitSolvingStrategy<TSparseSpace, TDenseSpace, TLinearSolver>(model_part) {
89 
90  mreform_dof_set_at_each_step = ReformDofSetAtEachStep || ReInitializeModelPartEachStep;
91  mcompute_reactions = ComputeReactions;
92  mcalculate_mesh_velocities = CalculateMeshVelocities;
93  mecho_level = EchoLevel;
94  mtime_order = TimeOrder;
95  mreinitialize_model_part_at_each_step = ReInitializeModelPartEachStep;
96  bool calculate_norm_dx_flag = false;
97 
98  typename SchemeType::Pointer pscheme = typename SchemeType::Pointer(
100  TDenseSpace>());
101 
102  const std::string element_type = "StructuralMeshMovingElement";
103  mpmesh_model_part = MoveMeshUtilities::GenerateMeshPart(
105 
106  mpmesh_model_part->pGetProperties(0)->GetValue(MESH_POISSON_RATIO) = PoissonRatio;
107 
108  mpbulider_and_solver = typename TBuilderAndSolverType::Pointer(
109  new ResidualBasedBlockBuilderAndSolver<TSparseSpace, TDenseSpace,
110  TLinearSolver>(
111  pNewLinearSolver));
112 
113  mstrategy = typename BaseType::Pointer(new ResidualBasedLinearStrategy<TSparseSpace, TDenseSpace,TLinearSolver>(
114  *mpmesh_model_part,
115  pscheme,
116  mpbulider_and_solver,
117  mcompute_reactions,
118  mreform_dof_set_at_each_step,
119  calculate_norm_dx_flag));
120 
121  mstrategy->SetEchoLevel(mecho_level);
122 
123  KRATOS_CATCH("")
124  }
125 
127  {
128  Model& owner_model = mpmesh_model_part->GetModel();
129  std::string name = mpmesh_model_part->Name();
130  owner_model.DeleteModelPart(name);
131  }
132 
133  void Initialize() override {}
134 
135  double Solve() override {
136  KRATOS_TRY;
137 
138  if (mreinitialize_model_part_at_each_step) {
140  *mpmesh_model_part, BaseType::GetModelPart(),
141  mpmesh_model_part->pGetProperties(0), "StructuralMeshMovingElement");
142  }
143 
145  mpmesh_model_part->GetCommunicator().LocalMesh().Nodes());
146 
147  // Solve for the mesh movement
148  mstrategy->Solve();
149 
150  // Clearing the system if needed
151  if (mreform_dof_set_at_each_step == true)
152  mstrategy->Clear();
153 
154  return 0.0;
155 
156  KRATOS_CATCH("");
157  }
158 
182 protected:
212 private:
219  ModelPart* mpmesh_model_part;
220 
221  typename BaseType::Pointer mstrategy;
222  typename TBuilderAndSolverType::Pointer mpbulider_and_solver;
223 
224  int mecho_level;
225  int mtime_order;
226  bool mreform_dof_set_at_each_step;
227  bool mcompute_reactions;
228  bool mcalculate_mesh_velocities;
229  bool mreinitialize_model_part_at_each_step;
230 
253 
256 }; /* Class StructuralMeshMovingStrategy */
257 
264 }
265 /* namespace Kratos.*/
266 
267 #endif /* KRATOS_NEW_STRUCTURAL_MESHMOVING_STRATEGY defined */
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
Implicit solving strategy base class This is the base class from which we will derive all the implici...
Definition: implicit_solving_strategy.h:61
BuilderAndSolver< TSparseSpace, TDenseSpace, TLinearSolver > TBuilderAndSolverType
Definition: implicit_solving_strategy.h:84
NodesContainerType & Nodes()
Definition: mesh.h:346
This class aims to manage different model parts across multi-physics simulations.
Definition: model.h:60
void DeleteModelPart(const std::string &ModelPartName)
This method deletes a modelpart with a given name.
Definition: model.cpp:64
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
PropertiesType::Pointer pGetProperties(IndexType PropertiesId, IndexType MeshIndex=0)
Returns the Properties::Pointer corresponding to it's identifier.
Definition: model_part.cpp:664
Communicator & GetCommunicator()
Definition: model_part.h:1821
std::string & Name()
Definition: model_part.h:1811
Model & GetModel()
Definition: model_part.h:323
Current class provides an implementation for standard builder and solving operations.
Definition: residualbased_block_builder_and_solver.h:82
This class provides the implementation of a static scheme.
Definition: residualbased_incrementalupdate_static_scheme.h:57
This is a very simple strategy to solve linearly the problem.
Definition: residualbased_linear_strategy.h:64
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
ModelPart & GetModelPart()
Operations to get the pointer to the model.
Definition: solving_strategy.h:350
Short class definition.
Definition: structural_meshmoving_strategy.h:59
double Solve() override
The problem of interest is solved.
Definition: structural_meshmoving_strategy.h:135
BaseType::TBuilderAndSolverType TBuilderAndSolverType
Definition: structural_meshmoving_strategy.h:68
ImplicitSolvingStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: structural_meshmoving_strategy.h:67
Scheme< TSparseSpace, TDenseSpace > SchemeType
Definition: structural_meshmoving_strategy.h:69
virtual ~StructuralMeshMovingStrategy()
Definition: structural_meshmoving_strategy.h:126
StructuralMeshMovingStrategy(ModelPart &model_part, typename TLinearSolver::Pointer pNewLinearSolver, int TimeOrder=2, bool ReformDofSetAtEachStep=false, bool ComputeReactions=false, bool CalculateMeshVelocities=true, int EchoLevel=0, const double PoissonRatio=0.3, const bool ReInitializeModelPartEachStep=false)
Definition: structural_meshmoving_strategy.h:78
void Initialize() override
Initialization of member variables and prior operations.
Definition: structural_meshmoving_strategy.h:133
KRATOS_CLASS_POINTER_DEFINITION(StructuralMeshMovingStrategy)
This class implements a set of auxiliar, already parallelized, methods to perform some common tasks r...
Definition: variable_utils.h:63
void UpdateCurrentToInitialConfiguration(const ModelPart::NodesContainerType &rNodes)
This method updates the current nodal coordinates back to the initial coordinates.
Definition: variable_utils.cpp:245
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
void CalculateMeshVelocities(ModelPart &rModelPart, const TimeDiscretization::BDF1 &rBDF)
Definition: mesh_velocity_calculation.cpp:56
void InitializeMeshPartWithElements(ModelPart &rDestinationModelPart, ModelPart &rOriginModelPart, Properties::Pointer pProperties, const std::string &rElementName)
Definition: move_mesh_utilities.cpp:176
ModelPart * GenerateMeshPart(ModelPart &rModelPart, const std::string &rElementName)
Definition: move_mesh_utilities.cpp:143
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
model_part
Definition: face_heat.py:14
element_type
Choosing element type for lagrangian_model_part.
Definition: lagrangian_droplet_test.py:56