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.
python_outfitted_constitutive_law.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosConstitutiveModelsApplication $
3 // Created by: $Author: JMCarbonell $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: April 2017 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined (KRATOS_PYTHON_OUTFITTED_CONSTITUTIVE_LAW_H_INCLUDED)
11 #define KRATOS_PYTHON_OUTFITTED_CONSTITUTIVE_LAW_H_INCLUDED
12 
13 // System includes
14 #include <iostream>
15 
16 // External includes
17 #include <cmath>
18 #include <boost/python.h>
19 
20 // Project includes
22 
24 
25 namespace Kratos
26 {
31 class KRATOS_API(CONSTITUTIVE_MODELS_APPLICATION) PythonOutfittedConstitutiveLaw : public ConstitutiveLaw
32 {
33 public:
39  typedef std::size_t SizeType;
40 
46 
55 
59  PythonOutfittedConstitutiveLaw(PyObject* pPyConstitutiveLaw);
60 
61 
66  ConstitutiveLaw::Pointer Clone() const;
67 
72 
73 
78  //PythonOutfittedConstitutiveLaw& operator=(const PythonOutfittedConstitutiveLaw& rOther);
79 
80 
85 
98  {
99  return boost::python::call_method<int>(mpPyConstitutiveLaw->ptr(),"WorkingSpaceDimension");
100  };
101 
106  {
107  return boost::python::call_method<int>(mpPyConstitutiveLaw->ptr(),"GetStrainSize");
108  };
109 
110 
111  bool Has( const Variable<double>& rThisVariable );
112  bool Has( const Variable<Vector>& rThisVariable );
113  bool Has( const Variable<Matrix>& rThisVariable );
114 
115  double& GetValue( const Variable<double>& rThisVariable, double& rValue );
116  Vector& GetValue( const Variable<Vector>& rThisVariable, Vector& rValue );
117  Matrix& GetValue( const Variable<Matrix>& rThisVariable, Matrix& rValue );
118 
119 
120  void SetValue( const Variable<double>& rVariable,
121  const double& rValue,
122  const ProcessInfo& rCurrentProcessInfo );
123  void SetValue( const Variable<Vector>& rThisVariable,
124  const Vector& rValue,
125  const ProcessInfo& rCurrentProcessInfo );
126  void SetValue( const Variable<Matrix>& rThisVariable,
127  const Matrix& rValue,
128  const ProcessInfo& rCurrentProcessInfo );
132  void InitializeMaterial( const Properties& rProperties,
133  const GeometryType& rElementGeometry,
134  const Vector& rShapeFunctionsValues );
135 
142  virtual void CalculateMaterialResponsePK1 (Parameters & rValues);
143 
150  virtual void CalculateMaterialResponsePK2 (Parameters & rValues);
151 
158  virtual void CalculateMaterialResponseKirchhoff (Parameters & rValues);
159 
160 
167  virtual void CalculateMaterialResponseCauchy (Parameters & rValues);
168 
169 
176  virtual void FinalizeMaterialResponsePK1 (Parameters & rValues);
177 
184  virtual void FinalizeMaterialResponsePK2 (Parameters & rValues);
185 
192  virtual void FinalizeMaterialResponseKirchhoff (Parameters & rValues);
193 
200  virtual void FinalizeMaterialResponseCauchy (Parameters & rValues);
201 
202 
207  void GetLawFeatures(Features& rFeatures);
208 
218  int Check(const Properties& rProperties, const GeometryType& rElementGeometry, const ProcessInfo& rCurrentProcessInfo);
219 
226  //virtual String Info() const;
230  //virtual void PrintInfo(std::ostream& rOStream) const;
234  //virtual void PrintData(std::ostream& rOStream) const;
235 
236 protected:
237 
243 
245 
246  double mTotalDeformationDet; //detF0
247 
249 
256 
263  virtual void UpdateInternalVariables (Parameters & rValues);
264 
266 
267 private:
268 
274 
275  //PyObject* mpPyConstitutiveLaw;
276  boost::shared_ptr<boost::python::object> mpPyConstitutiveLaw;
277 
281 
282 
286 
293  Matrix& Transform2DTo3D (Matrix& rMatrix);
294 
299 
300 
304  friend class Serializer;
305 
306  virtual void save(Serializer& rSerializer) const
307  {
309  rSerializer.save("mInverseTotalDeformationMatrix",mInverseTotalDeformationMatrix);
310  rSerializer.save("mTotalDeformationDet",mTotalDeformationDet);
311  rSerializer.save("mStrainEnergy",mStrainEnergy);
312  }
313 
314  virtual void load(Serializer& rSerializer)
315  {
317  rSerializer.load("mInverseTotalDeformationMatrix",mInverseTotalDeformationMatrix);
318  rSerializer.load("mTotalDeformationDet",mTotalDeformationDet);
319  rSerializer.load("mStrainEnergy",mStrainEnergy);
320  }
321 
322 
324 
325 }; // Class PythonOutfittedConstitutiveLaw
326 } // namespace Kratos.
327 #endif // KRATOS_PYTHON_OUTFITTED_CONSTITUTIVE_LAW_H_INCLUDED defined
Definition: constitutive_law.h:47
std::size_t SizeType
Definition: constitutive_law.h:82
Geometry base class.
Definition: geometry.h:71
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
Definition: python_outfitted_constitutive_law.hpp:32
double mTotalDeformationDet
Definition: python_outfitted_constitutive_law.hpp:246
KRATOS_CLASS_POINTER_DEFINITION(PythonOutfittedConstitutiveLaw)
ProcessInfo ProcessInfoType
Definition: python_outfitted_constitutive_law.hpp:37
Matrix mInverseTotalDeformationMatrix
Definition: python_outfitted_constitutive_law.hpp:244
std::size_t SizeType
Definition: python_outfitted_constitutive_law.hpp:39
SizeType GetStrainSize()
Definition: python_outfitted_constitutive_law.hpp:105
double mStrainEnergy
Definition: python_outfitted_constitutive_law.hpp:248
SizeType WorkingSpaceDimension()
Definition: python_outfitted_constitutive_law.hpp:97
ConstitutiveLaw BaseType
Definition: python_outfitted_constitutive_law.hpp:38
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void load(std::string const &rTag, TDataType &rObject)
Definition: serializer.h:207
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
bool Has(const std::string &ModelerName)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:24
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
def SetValue(entity, variable, value)
Definition: coupling_interface_data.py:256
def load(f)
Definition: ode_solve.py:307
Definition: constitutive_law.h:189