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.
modeler.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Riccardo Rossi
11 //
12 //
13 
14 
15 #if !defined(KRATOS_MODELER_H_INCLUDED )
16 #define KRATOS_MODELER_H_INCLUDED
17 
18 
19 // System includes
20 
21 // External includes
22 
23 // Project includes
24 #include "includes/define.h"
25 #include "containers/model.h"
27 
28 namespace Kratos
29 {
30 
33 
35 /* The modeler is designed to interact, create and update
36  the ModelPart of the analyses after and at certain steps.
37 */
38 class Modeler
39 {
40 public:
43 
46 
47  typedef std::size_t SizeType;
48  typedef std::size_t IndexType;
49 
53 
56  Parameters ModelerParameters = Parameters())
57  : mParameters(ModelerParameters)
58  , mEchoLevel(
59  ModelerParameters.Has("echo_level")
60  ? ModelerParameters["echo_level"].GetInt()
61  : 0)
62  {}
63 
66  Model& rModel,
67  Parameters ModelerParameters = Parameters())
68  : mParameters(ModelerParameters)
69  , mEchoLevel(
70  ModelerParameters.Has("echo_level")
71  ? ModelerParameters["echo_level"].GetInt()
72  : 0)
73  {}
74 
76  virtual ~Modeler() = default;
77 
79  virtual Modeler::Pointer Create(
80  Model& rModel, const Parameters ModelParameters) const
81  {
82  KRATOS_ERROR << "Trying to Create Modeler. Please check derived class 'Create' definition." << std::endl;
83  }
84 
88 
90  virtual void SetupGeometryModel()
91  {}
92 
94  virtual void PrepareGeometryModel()
95  {}
96 
98  virtual void SetupModelPart()
99  {}
100 
102  virtual const Parameters GetDefaultParameters() const
103  {
104  KRATOS_ERROR << "Calling the base Modeler class GetDefaultParameters. Please implement the GetDefaultParameters in your derived model class." << std::endl;
105  const Parameters default_parameters = Parameters(R"({})");
106  return default_parameters;
107  }
108 
112 
113  virtual void GenerateModelPart(ModelPart& rOriginModelPart, ModelPart& rDestinationModelPart, Element const& rReferenceElement, Condition const& rReferenceBoundaryCondition)
114  {
115  KRATOS_ERROR << "This modeler CAN NOT be used for mesh generation." << std::endl;
116  }
117 
118  virtual void GenerateMesh(ModelPart& ThisModelPart, Element const& rReferenceElement, Condition const& rReferenceBoundaryCondition)
119  {
120  KRATOS_ERROR << "This modeler CAN NOT be used for mesh generation." << std::endl;
121  }
122 
123  virtual void GenerateNodes(ModelPart& ThisModelPart)
124  {
125  KRATOS_ERROR << "This modeler CAN NOT be used for node generation." << std::endl;
126  }
127 
131 
133  virtual std::string Info() const
134  {
135  return "Modeler";
136  }
137 
139  virtual void PrintInfo(std::ostream& rOStream) const
140  {
141  rOStream << Info();
142  }
143 
145  virtual void PrintData(std::ostream& rOStream) const
146  {
147  }
148 
150 
151 protected:
154 
156 
158 
160 
161 }; // Class Modeler
162 
166 
168 inline std::istream& operator >> (std::istream& rIStream,
169  Modeler& rThis);
170 
172 inline std::ostream& operator << (std::ostream& rOStream,
173  const Modeler& rThis)
174 {
175  rThis.PrintInfo(rOStream);
176  rOStream << std::endl;
177  rThis.PrintData(rOStream);
178 
179  return rOStream;
180 }
182 
184 
185 void KRATOS_API(KRATOS_CORE) AddKratosComponent(std::string const& Name, Modeler const& ThisComponent);
186 
187 } // namespace Kratos.
188 
189 #endif // KRATOS_MODELER_H_INCLUDED defined
190 
191 
Base class for all Conditions.
Definition: condition.h:59
Base class for all Elements.
Definition: element.h:60
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 different model parts across multi-physics simulations.
Definition: model.h:60
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Modeler to interact with ModelParts.
Definition: modeler.h:39
virtual void SetupModelPart()
Convert the geometry model or import analysis suitable models.
Definition: modeler.h:98
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: modeler.h:145
virtual void GenerateNodes(ModelPart &ThisModelPart)
Definition: modeler.h:123
Modeler(Parameters ModelerParameters=Parameters())
Default constructor.
Definition: modeler.h:55
KRATOS_CLASS_POINTER_DEFINITION(Modeler)
Pointer definition of Modeler.
std::size_t IndexType
Definition: modeler.h:48
virtual void GenerateModelPart(ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, Element const &rReferenceElement, Condition const &rReferenceBoundaryCondition)
Definition: modeler.h:113
virtual Modeler::Pointer Create(Model &rModel, const Parameters ModelParameters) const
Creates the Modeler Pointer.
Definition: modeler.h:79
virtual ~Modeler()=default
Destructor.
virtual const Parameters GetDefaultParameters() const
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: modeler.h:102
Parameters mParameters
Definition: modeler.h:155
virtual void PrepareGeometryModel()
Prepare or update the geometry model_part.
Definition: modeler.h:94
Modeler(Model &rModel, Parameters ModelerParameters=Parameters())
Constructor with Model.
Definition: modeler.h:65
virtual std::string Info() const
Turn back information as a string.
Definition: modeler.h:133
virtual void GenerateMesh(ModelPart &ThisModelPart, Element const &rReferenceElement, Condition const &rReferenceBoundaryCondition)
Definition: modeler.h:118
std::size_t SizeType
Definition: modeler.h:47
virtual void SetupGeometryModel()
Import or generate geometry models from external input.
Definition: modeler.h:90
SizeType mEchoLevel
Definition: modeler.h:157
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: modeler.h:139
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_API_EXTERN
Definition: kratos_export_api.h:57
#define KRATOS_API(...)
Definition: kratos_export_api.h:40
bool Has(const std::string &ModelerName)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:24
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
void AddKratosComponent(std::string const &Name, ExplicitBuilderType const &ThisComponent)
Definition: register_factories.cpp:23
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432