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.
empirical_spring_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 
24 #ifndef EMPIRICAL_SPRING_ELEMENT_PROCESS_H
25 #define EMPIRICAL_SPRING_ELEMENT_PROCESS_H
26 
27 // System includes
28 #include <string>
29 #include <iostream>
30 
31 // External includes
32 
33 // Project includes
34 #include "includes/node.h"
35 #include "includes/define.h"
36 #include "processes/process.h"
37 #include "utilities/math_utils.h"
39 #include "geometries/line_3d_2.h"
40 #include "includes/model_part.h"
42 
43 namespace Kratos
44 {
45 
46 
48  : public Process
49 {
50  public:
51 
52  typedef Node NodeType;
53  typedef Node ::Pointer NodeTypePointer;
54  typedef std::vector<NodeTypePointer> NodeVector;
56  typedef std::vector<NodeTypePointer>::iterator NodeIterator;
57  typedef std::vector<double> DoubleVector;
58  typedef DoubleVector::iterator DoubleVectorIterator;
59  typedef std::size_t SizeType;
60 
61 
64 
67  Parameters InputParameters, const DoubleVector FittedPolynomial):mrModelPart(rModelPart),mParameters(InputParameters),mrFittedPoly(FittedPolynomial)
68  {
69  KRATOS_TRY;
70  Parameters default_parameters = Parameters(R"(
71  {
72  "model_part_name" : "example_part",
73  "computing_model_part_name" : "computing_domain",
74  "node_ids" : [1,2],
75  "element_id" : 1,
76  "property_id" : 1,
77  "displacement_data" : [0.0,1.0,2.0,3.0],
78  "force_data" : [0.0,1.0,2.0,3.0],
79  "polynomial_order" : 3
80  })" );
81  default_parameters.ValidateAndAssignDefaults(InputParameters);
82 
83  KRATOS_ERROR_IF(mParameters["node_ids"].size()!=2) << "exactly two nodes for each spring needed !" << std::endl;
84  KRATOS_ERROR_IF(mParameters["displacement_data"].size()!=mParameters["force_data"].size()) << "only two nodes for each spring allowed !" << std::endl;
85 
86 
87  KRATOS_CATCH("")
88  }
89 
92  void ExecuteInitialize() override
93  {
94  KRATOS_TRY;
96  KRATOS_CATCH("");
97  }
98 
100 
102  {
103  KRATOS_TRY;
104  Vector polynomial_order = ZeroVector(mrFittedPoly.size());
105  for (SizeType i=0;i<mrFittedPoly.size();++i) polynomial_order[i] = mrFittedPoly[i];
106  const int number_nodes = 2;
107 
108  // get new element id
109  const std::size_t new_element_id = mParameters["element_id"].GetInt();
110 
111  // create geometric entitity
112  std::vector<NodeType::Pointer> element_nodes (number_nodes);
113  for (SizeType i=0; i<number_nodes; ++i)
114  {
115  element_nodes[i] = mrModelPart.pGetNode(mParameters["node_ids"][i].GetInt());
116  }
117  Line3D2 <NodeType> line_t ( PointerVector<NodeType>{element_nodes} );
118 
119  // get properties
120  Properties::Pointer p_elem_prop = mrModelPart.pGetProperties(mParameters["property_id"].GetInt());
121 
122 
123  p_elem_prop->SetValue(SPRING_DEFORMATION_EMPIRICAL_POLYNOMIAL, polynomial_order);
124 
125 
126  const Element& rElem = KratosComponents<Element>::Get("EmpiricalSpringElement3D2N");
127  Element::Pointer pElem = rElem.Create(new_element_id, line_t, p_elem_prop);
128  mrModelPart.AddElement(pElem);
129 
130 
131  KRATOS_CATCH("");
132  }
133 
134  protected:
135 
136 
137  private:
138 
139  ModelPart& mrModelPart;
140  Parameters mParameters;
141  const DoubleVector mrFittedPoly;
142 
143 }; // Class
144 
145 }; // namespace
146 
147 #endif
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
Definition: empirical_spring_element_process.h:49
void CreateEmpiricalSpringElement() const
this function will be executed at every time step BEFORE performing the solve phase
Definition: empirical_spring_element_process.h:101
std::size_t SizeType
Definition: empirical_spring_element_process.h:59
KRATOS_CLASS_POINTER_DEFINITION(EmpiricalSpringElementProcess)
Pointer definition of ApplyMultipointConstraintsProcess.
Node ::Pointer NodeTypePointer
Definition: empirical_spring_element_process.h:53
Node NodeType
Definition: empirical_spring_element_process.h:52
std::vector< double > DoubleVector
Definition: empirical_spring_element_process.h:57
DoubleVector::iterator DoubleVectorIterator
Definition: empirical_spring_element_process.h:58
std::vector< NodeTypePointer > NodeVector
Definition: empirical_spring_element_process.h:54
std::vector< NodeTypePointer >::iterator NodeIterator
Definition: empirical_spring_element_process.h:56
void ExecuteInitialize() override
Definition: empirical_spring_element_process.h:92
EmpiricalSpringElementProcess(ModelPart &rModelPart, Parameters InputParameters, const DoubleVector FittedPolynomial)
Constructor.
Definition: empirical_spring_element_process.h:66
ModelPart::NodesContainerType NodesArrayType
Definition: empirical_spring_element_process.h:55
void SetValue(const TVariableType &rThisVariable, typename TVariableType::Type const &rValue)
Definition: geometry.h:617
static const TComponentType & Get(const std::string &rName)
Retrieves a component with the specified name.
Definition: kratos_components.h:114
An two node 3D line geometry with linear shape functions.
Definition: line_3d_2.h: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
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
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
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_IF(conditional)
Definition: exception.h:162
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
integer i
Definition: TensorModule.f:17