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.
edge_cable_element_process.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: Klaus B. Sautter
11 //
12 //
13 
14 
15 
16 #ifndef EDGE_CABLE_ELEMENT_PROCESS_H
17 #define EDGE_CABLE_ELEMENT_PROCESS_H
18 
19 // System includes
20 #include <string>
21 #include <iostream>
22 
23 // External includes
24 
25 // Project includes
26 #include "includes/node.h"
27 #include "includes/define.h"
28 #include "processes/process.h"
29 #include "utilities/math_utils.h"
31 #include "geometries/line_3d_3.h"
33 #include "includes/model_part.h"
34 
35 namespace Kratos
36 {
37 
38 
40  : public Process
41 {
42  public:
43 
44  typedef Node NodeType;
45  typedef Node ::Pointer NodeTypePointer;
46  typedef std::vector<NodeTypePointer> NodeVector;
48  typedef std::vector<NodeTypePointer>::iterator NodeIterator;
49  typedef std::vector<double> DoubleVector;
50  typedef DoubleVector::iterator DoubleVectorIterator;
51  typedef std::size_t SizeType;
52 
53 
56 
59  Parameters InputParameters):mrModelPart(rModelPart),mParameters(InputParameters)
60  {
61  KRATOS_TRY;
62  Parameters default_parameters = Parameters(R"(
63  {
64  "edge_sub_model_part_name" : "Structure.example_part",
65  "element_type" : "cable",
66  "node_id_order" : [1,2,3],
67  "element_id" : 1,
68  "property_id" : 1
69  })" );
70  default_parameters.ValidateAndAssignDefaults(InputParameters);
71  KRATOS_CATCH("")
72  }
73 
76  void ExecuteInitialize() override
77  {
78  KRATOS_TRY;
79  this->CreateEdgeCableElement();
80  KRATOS_CATCH("");
81  }
82 
85  {
86  KRATOS_TRY;
87  KRATOS_CATCH("");
88  }
89 
92  {
93  KRATOS_TRY;
94 
95  KRATOS_CATCH("");
96  }
97 
98 
99 
101  {
102  KRATOS_TRY;
103  // !!
104  // probably better to create the line equation and calculate the ordering here
105  // !!
106 
107  const SizeType number_nodes = mParameters["node_id_order"].size();
108  KRATOS_ERROR_IF_NOT(mrModelPart.Nodes().size()==number_nodes)
109  << "numbers of nodes in submodel part not consistent with numbers of nodes in process properties"
110  << std::endl;
111 
112 
113  // get new element id
114  const std::size_t new_element_id = mParameters["element_id"].GetInt();
115 
116  // create geometric entitity
117  std::vector<NodeType::Pointer> element_nodes (number_nodes);
118  for (SizeType i=0; i<number_nodes; ++i)
119  {
120  element_nodes[i] = mrModelPart.pGetNode(mParameters["node_id_order"][i].GetInt());
121  }
122  Line3DN <NodeType> line_t ( PointerVector<NodeType>{element_nodes} );
123 
124  // get properties
125  Properties::Pointer p_elem_prop = mrModelPart.pGetProperties(mParameters["property_id"].GetInt());
126 
127  // create element
128  if (mParameters["element_type"].GetString() == "cable")
129  {
130  const Element& rElem = KratosComponents<Element>::Get("SlidingCableElement3D3N");
131  Element::Pointer pElem = rElem.Create(new_element_id, line_t, p_elem_prop);
132  mrModelPart.AddElement(pElem);
133  }
134  else if (mParameters["element_type"].GetString() == "ring")
135  {
136  const Element& rElem = KratosComponents<Element>::Get("RingElement3D4N");
137  Element::Pointer pElem = rElem.Create(new_element_id, line_t, p_elem_prop);
138  mrModelPart.AddElement(pElem);
139  }
140  else KRATOS_ERROR << "element type :" << mParameters["element_type"].GetString() << " not available for sliding process" << std::endl;
141 
142 
143 
144 
145  KRATOS_CATCH("");
146  }
147 
148  protected:
149 
150 
151  private:
152 
153  ModelPart& mrModelPart;
154  Parameters mParameters;
155 
156 }; // Class
157 
158 }; // namespace
159 
160 #endif
Definition: edge_cable_element_process.h:41
void ExecuteInitializeSolutionStep() override
this function will be executed at every time step BEFORE performing the solve phase
Definition: edge_cable_element_process.h:84
void ExecuteInitialize() override
Definition: edge_cable_element_process.h:76
std::vector< NodeTypePointer > NodeVector
Definition: edge_cable_element_process.h:46
KRATOS_CLASS_POINTER_DEFINITION(EdgeCableElementProcess)
Pointer definition of ApplyMultipointConstraintsProcess.
Node ::Pointer NodeTypePointer
Definition: edge_cable_element_process.h:45
std::vector< double > DoubleVector
Definition: edge_cable_element_process.h:49
std::vector< NodeTypePointer >::iterator NodeIterator
Definition: edge_cable_element_process.h:48
void ExecuteFinalizeSolutionStep() override
this function will be executed at every time step AFTER performing the solve phase
Definition: edge_cable_element_process.h:91
ModelPart::NodesContainerType NodesArrayType
Definition: edge_cable_element_process.h:47
DoubleVector::iterator DoubleVectorIterator
Definition: edge_cable_element_process.h:50
std::size_t SizeType
Definition: edge_cable_element_process.h:51
Node NodeType
Definition: edge_cable_element_process.h:44
void CreateEdgeCableElement() const
Definition: edge_cable_element_process.h:100
EdgeCableElementProcess(ModelPart &rModelPart, Parameters InputParameters)
Constructor.
Definition: edge_cable_element_process.h:58
Base class for all Elements.
Definition: element.h:60
virtual Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const
It creates a new element pointer.
Definition: element.h:202
static const TComponentType & Get(const std::string &rName)
Retrieves a component with the specified name.
Definition: kratos_components.h:114
A arbitrary node 3D line geometry with quadratic shape functions.
Definition: line_3d_n.h:55
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
NodeType::Pointer pGetNode(IndexType NodeId, IndexType ThisIndex=0)
Definition: model_part.h:421
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
void AddElement(ElementType::Pointer pNewElement, IndexType ThisIndex=0)
Definition: model_part.cpp:917
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
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
SizeType size() const
This method returns the total size of the current array parameter.
Definition: kratos_parameters.cpp:993
std::string GetString() const
This method returns the string contained in the current Parameter.
Definition: kratos_parameters.cpp:684
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
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
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
integer i
Definition: TensorModule.f:17