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.
model_part_wrapper.h
Go to the documentation of this file.
1 // _____ _____ _ __ __ _ _ _ _
2 // / ____|/ ____| | \ \ / / /\ | (_) | | (_)
3 // | | | (___ | |__ __ _ _ __ _ _\ \ /\ / / __ __ _ _ __ _ __ ___ _ __ / \ _ __ _ __ | |_ ___ __ _| |_ _ ___ _ __
4 // | | \___ \| '_ \ / _` | '__| '_ \ \/ \/ / '__/ _` | '_ \| '_ \ / _ \ '__/ /\ \ | '_ \| '_ \| | |/ __/ _` | __| |/ _ \| '_ |
5 // | |____ ____) | | | | (_| | | | |_) \ /\ /| | | (_| | |_) | |_) | __/ | / ____ \| |_) | |_) | | | (_| (_| | |_| | (_) | | | |
6 // \_____|_____/|_| |_|\__,_|_| | .__/ \/ \/ |_| \__,_| .__/| .__/ \___|_|/_/ \_\ .__/| .__/|_|_|\___\__,_|\__|_|\___/|_| |_|
7 // | | | | | | | | | |
8 // |_| |_| |_| |_| |_|
9 //
10 //
11 // License: BSD License
12 // license: CSharpWrapperApplication/license.txt
13 //
14 // Main authors: Hubert Balcerzak
15 
16 #ifndef KRATOSMULTIPHYSICS_MODEL_PART_WRAPPER_H
17 #define KRATOSMULTIPHYSICS_MODEL_PART_WRAPPER_H
18 
19 // System includes
20 #include <vector>
21 
22 // External includes
23 
24 // Project includes
25 #include "includes/model_part.h"
26 #include "id_translator.h"
27 #include "mesh_converter.h"
28 #include "includes/variables.h"
29 
30 
31 namespace CSharpKratosWrapper {
32 
33  using NodeType = Kratos::Node;
37 
39 
40  public:
41 
42  ModelPartWrapper(Kratos::ModelPart &mModelPart, std::vector<NodeType::Pointer> &fixedNodes)
43  : mModelPart(mModelPart), mFixedNodes(fixedNodes), pmParentModelPart(NULL) {
44  initialize();
45  }
46 
47  ModelPartWrapper(Kratos::ModelPart &mModelPart, std::vector<NodeType::Pointer> &fixedNodes,
48  ModelPartWrapper *parent)
49  : mModelPart(mModelPart), mFixedNodes(fixedNodes), pmParentModelPart(parent) {
50  initialize();
51  }
52 
54 
55 
56  ModelPartWrapper *getSubmodelPart(char *name);
57 
58  bool hasSubmodelPart(char *name);
59 
60  float *getXCoordinates();
61 
62  float *getYCoordinates();
63 
64  float *getZCoordinates();
65 
66  int getNodesCount();
67 
68  int *getTriangles();
69 
70  int getTrianglesCount();
71 
79  void updateNodePos(const int nodeId, const float x, const float y, const float z);
80 
84  void retrieveResults();
85 
90 
91  float *getSurfaceStress();
92 
94 
98  void recreateProcessedMesh();
99 
101 
102  NodeType *createNewNode(int id, double x, double y, double z);
103 
104  ElementType *createNewElement(char *name, int id, int *nodeIds);
105 
106  ConditionType *createNew2dCondition(char *name, int id, int *nodeIds);
107 
108  void removeNode(int id);
109 
110  void removeElement(int id);
111 
112  void removeCondition(int id);
113 
114  void addNodes(int *nodeIds, int nodeCount);
115 
116  void addElements(int *elementIds, int elementCount);
117 
118  void addConditions(int *conditionIds, int elementCount);
119 
120  int getMaxElementId();
121 
122  int getMaxNodeId();
123 
124  NodeType *getNode(int id);
125 
126  NodeType **getNodes();
127 
128  int getNumberOfNodes();
129 
130  ElementType *getElement(int id);
131 
133 
134  int getNumberOfElements();
135 
136  ConditionType *getCondition(int id);
137 
139 
140  int getNumberOfConditions();
141 
143 
144  double *getNodalVariable1d(Kratos::Variable<double> &variable);
145 
147 
149 
151 
152  protected:
153 
154  void updateMaxElementId(int maxId);
155 
156  void updateMaxNodeId(int maxId);
157 
158  private:
159  Kratos::ModelPart &mModelPart;
160  std::vector<NodeType::Pointer> &mFixedNodes;
161  ModelPartWrapper *pmParentModelPart;
162  IdTranslator idTranslator;
163 
164  float *pmXCoordinates;
165  float *pmYCoordinates;
166  float *pmZCoordinates;
167  int *pmTriangles;
168  int mNodesCount;
169  int mTrianglesCount;
170  float *pmSurfaceStress;
171  bool mStressResultsEnabled;
172  int mMaxElementId;
173  int mMaxNodeId;
174  bool mInitialized;
175 
176  void initialize();
177 
178  void saveNodes(MeshConverter &meshConverter);
179 
180  void saveTriangles(MeshConverter &meshConverter);
181 
182  void deleteSkin();
183  };
184 };
185 
186 
187 #endif //KRATOSMULTIPHYSICS_MODEL_PART_WRAPPER_H
Definition: id_translator.h:30
Definition: mesh_converter.h:35
Definition: model_part_wrapper.h:38
ConditionType * getCondition(int id)
Definition: model_part_wrapper.cpp:364
ElementType ** getElements()
Definition: model_part_wrapper.cpp:350
bool hasNodalVariable1d(Kratos::Variable< double > &variable)
Definition: model_part_wrapper.cpp:416
int getTrianglesCount()
Definition: model_part_wrapper.cpp:65
int getNumberOfElements()
Definition: model_part_wrapper.cpp:360
double * getNodalVariable1d(Kratos::Variable< double > &variable)
Definition: model_part_wrapper.cpp:385
ModelPartWrapper(Kratos::ModelPart &mModelPart, std::vector< NodeType::Pointer > &fixedNodes)
Definition: model_part_wrapper.h:42
void removeElement(int id)
Definition: model_part_wrapper.cpp:282
ModelPart & getKratosModelPart()
Definition: model_part_wrapper.cpp:214
void enableSurfaceStressResults()
Definition: model_part_wrapper.cpp:190
float * getYCoordinates()
Definition: model_part_wrapper.cpp:38
ModelPartWrapper(Kratos::ModelPart &mModelPart, std::vector< NodeType::Pointer > &fixedNodes, ModelPartWrapper *parent)
Definition: model_part_wrapper.h:47
NodeType ** getNodes()
Definition: model_part_wrapper.cpp:331
void recreateProcessedMesh()
Definition: model_part_wrapper.cpp:238
int getNumberOfNodes()
Definition: model_part_wrapper.cpp:342
int getNodesCount()
Definition: model_part_wrapper.cpp:46
NodeType * createNewNode(int id, double x, double y, double z)
Definition: model_part_wrapper.cpp:255
~ModelPartWrapper()
Definition: model_part_wrapper.cpp:204
bool hasSubmodelPart(char *name)
Definition: model_part_wrapper.cpp:30
void updateMaxElementId(int maxId)
Definition: model_part_wrapper.cpp:228
ElementType * createNewElement(char *name, int id, int *nodeIds)
Definition: model_part_wrapper.cpp:260
ModelPartWrapper * getSubmodelPart(char *name)
Definition: model_part_wrapper.cpp:210
void updateMaxNodeId(int maxId)
Definition: model_part_wrapper.cpp:233
NodeType * getNode(int id)
Definition: model_part_wrapper.cpp:327
int getMaxNodeId()
Definition: model_part_wrapper.cpp:223
void retrieveResults()
Definition: model_part_wrapper.cpp:160
ElementType * getElement(int id)
Definition: model_part_wrapper.cpp:346
void removeCondition(int id)
Definition: model_part_wrapper.cpp:286
float * getZCoordinates()
Definition: model_part_wrapper.cpp:42
int getNumberOfConditions()
Definition: model_part_wrapper.cpp:377
void updateNodePos(const int nodeId, const float x, const float y, const float z)
Definition: model_part_wrapper.cpp:69
ConditionType ** getConditions()
Definition: model_part_wrapper.cpp:368
ConditionType * createNew2dCondition(char *name, int id, int *nodeIds)
Definition: model_part_wrapper.cpp:269
bool hasNodalVariable3d(Kratos::Variable< Kratos::array_1d< double, 3 >> &variable)
Definition: model_part_wrapper.cpp:421
ModelPartWrapper * createSubmodelPart(char *name)
Definition: model_part_wrapper.cpp:250
int * getTriangles()
Definition: model_part_wrapper.cpp:50
int getMaxElementId()
Definition: model_part_wrapper.cpp:218
void removeNode(int id)
Definition: model_part_wrapper.cpp:278
void addConditions(int *conditionIds, int elementCount)
Definition: model_part_wrapper.cpp:304
float * getXCoordinates()
Definition: model_part_wrapper.cpp:34
void addElements(int *elementIds, int elementCount)
Definition: model_part_wrapper.cpp:297
double * getNodalVariable3d(Kratos::Variable< Kratos::array_1d< double, 3 >> &variable)
Definition: model_part_wrapper.cpp:400
float * getSurfaceStress()
Definition: model_part_wrapper.cpp:200
void addNodes(int *nodeIds, int nodeCount)
Definition: model_part_wrapper.cpp:290
IdTranslator * getIdTranslator()
Definition: model_part_wrapper.cpp:381
Base class for all Conditions.
Definition: condition.h:59
Base class for all Elements.
Definition: element.h:60
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
This class defines the node.
Definition: node.h:65
Definition: id_translator.h:28
z
Definition: GenerateWind.py:163
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
x
Definition: sensitivityMatrix.py:49