SPHinXsys  alpha version
base_material.h
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------*
2  * SPHinXsys *
3  * --------------------------------------------------------------------------*
4  * SPHinXsys (pronunciation: s'finksis) is an acronym from Smoothed Particle *
5  * Hydrodynamics for industrial compleX systems. It provides C++ APIs for *
6  * physical accurate simulation and aims to model coupled industrial dynamic *
7  * systems including fluid, solid, multi-body dynamics and beyond with SPH *
8  * (smoothed particle hydrodynamics), a meshless computational method using *
9  * particle discretization. *
10  * *
11  * SPHinXsys is partially funded by German Research Foundation *
12  * (Deutsche Forschungsgemeinschaft) DFG HU1527/6-1, HU1527/10-1 *
13  * and HU1527/12-1. *
14  * *
15  * Portions copyright (c) 2017-2020 Technical University of Munich and *
16  * the authors' affiliations. *
17  * *
18  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
19  * not use this file except in compliance with the License. You may obtain a *
20  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
21  * *
22  * --------------------------------------------------------------------------*/
35 #ifndef BASE_MATERIAL_H
36 #define BASE_MATERIAL_H
37 
38 #include "base_data_package.h"
39 #include "xml_engine.h"
40 
41 #include <string>
42 
43 namespace SPH
44 {
45  class BaseParticles;
46 
53  {
54  protected:
55  std::string material_type_name_;
56  std::string parameters_name_;
57  Real rho0_;
58  BaseParticles *base_particles_;
59  XmlEngine reload_material_xml_engine_;
60  ParticleVariableList reload_local_parameters_;
61 
62  public:
63  explicit BaseMaterial(Real rho0)
64  : material_type_name_("BaseMaterial"),
65  parameters_name_("LocalMaterialParameters"),
66  rho0_(rho0), base_particles_(nullptr),
67  reload_material_xml_engine_("xml_material", "local_material_paramaters"){};
68  BaseMaterial() : BaseMaterial(1.0){};
69  virtual ~BaseMaterial(){};
70 
75  virtual void assignBaseParticles(BaseParticles *base_particles);
76  std::string MaterialType() { return material_type_name_; }
77  std::string LocalParametersName() { return parameters_name_; }
78  Real ReferenceDensity() { return rho0_; };
79 
80  virtual void writeToXmlForReloadLocalParameters(const std::string &filefullpath);
81  virtual void readFromXmlForLocalParameters(const std::string &filefullpath);
82 
83  virtual BaseMaterial *ThisObjectPtr() { return this; };
84  };
85 
89  class Fluid : public BaseMaterial
90  {
91  protected:
92  Real mu_;
94  public:
95  explicit Fluid(Real rho0, Real mu)
96  : BaseMaterial(rho0), mu_(mu)
97  {
98  material_type_name_ = "Fluid";
99  };
100  virtual ~Fluid(){};
101 
102  Real ReferenceViscosity() { return mu_; };
103  virtual Real getPressure(Real rho) = 0;
104  virtual Real getPressure(Real rho, Real rho_e) { return getPressure(rho); };
105  virtual Real DensityFromPressure(Real p) = 0;
106  virtual Real getSoundSpeed(Real p = 0.0, Real rho = 1.0) = 0;
107  virtual Fluid *ThisObjectPtr() override { return this; };
108  };
109 
113  class Solid : public BaseMaterial
114  {
115  public:
116  Solid(Real rho0, Real contact_stiffness, Real contact_friction = 0.0)
117  : BaseMaterial(rho0), contact_stiffness_(contact_stiffness),
118  contact_friction_(contact_friction)
119  {
120  material_type_name_ = "Solid";
121  };
122  explicit Solid(Real rho0) : Solid(rho0, 1.0){};
123  Solid() : Solid(1.0){};
124  virtual ~Solid(){};
125 
126  Real ContactFriction() { return contact_friction_; };
127  Real ContactStiffness() { return contact_stiffness_; };
128  virtual Solid *ThisObjectPtr() override { return this; };
129 
130  protected:
131  Real contact_stiffness_;
134  void setContactStiffness(Real c0) { contact_stiffness_ = c0 * c0; };
135  };
136 }
137 #endif // BASE_MATERIAL_H
Particles with essential (geometric and kinematic) data. There are three types of particles, all par...
Definition: base_particles.h:81
Real contact_stiffness_
Definition: base_material.h:128
std::array< StdVec< std::pair< std::string, size_t > >, 4 > ParticleVariableList
Definition: sph_data_containers.h:63
Real contact_friction_
Definition: base_material.h:132
Base of all materials.
Definition: base_material.h:52
Base class of all solid materials.
Definition: base_material.h:113
XML class for xml input and output, this is GUI of simbody xml parser.
Base class of all fluids.
Definition: base_material.h:89
virtual void assignBaseParticles(BaseParticles *base_particles)
Definition: base_material.cpp:13
Definition: xml_engine.h:56
Real mu_
Definition: base_material.h:92
Definition: solid_body_supplementary.cpp:9
Real rho0_
Definition: base_material.h:57