SPH
MaterialJobs.cpp
Go to the documentation of this file.
2 #include "sph/Materials.h"
3 #include "system/Factory.h"
4 
6 
7 // ----------------------------------------------------------------------------------------------------------
8 // MaterialProvider
9 // ----------------------------------------------------------------------------------------------------------
10 
20 
21  body.addEntries(overrides);
22 }
23 
25  auto enablerDp = [this, enabler] {
27  return (!enabler || enabler()) && id == YieldingEnum::DRUCKER_PRAGER;
28  };
29  auto enablerAf = [this, enabler] {
31  const bool use = body.get<bool>(BodySettingsId::USE_ACOUSTIC_FLUDIZATION);
32  return (!enabler || enabler()) && use && id == YieldingEnum::DRUCKER_PRAGER;
33  };
34  auto enablerRheo = [this, enabler] {
36  return (!enabler || enabler()) && id != YieldingEnum::NONE;
37  };
38  auto enablerFrag = [this, enablerRheo] {
40  return enablerRheo() && id != FractureEnum::NONE;
41  };
42 
43  category.connect<EnumWrapper>("EoS", body, BodySettingsId::EOS).setEnabler(enabler);
44  category.connect<Float>("Density [kg/m^3]", body, BodySettingsId::DENSITY).setEnabler(enabler);
45  category.connect<Float>("Specific energy [J/kg]", body, BodySettingsId::ENERGY).setEnabler(enabler);
46  category.connect<Float>("Damage []", body, BodySettingsId::DAMAGE).setEnabler(enabler);
47  category.connect<EnumWrapper>("Rheology", body, BodySettingsId::RHEOLOGY_YIELDING).setEnabler(enabler);
48  category.connect<Float>("Bulk modulus [Pa]", body, BodySettingsId::BULK_MODULUS)
49  .setEnabler([this, enabler] {
52  return (!enabler || enabler()) &&
53  ((eos != EosEnum::NONE && eos != EosEnum::IDEAL_GAS) || (yield != YieldingEnum::NONE));
54  });
55  category.connect<Float>("Shear modulus [Pa]", body, BodySettingsId::SHEAR_MODULUS)
56  .setEnabler(enablerRheo);
57  category.connect<Float>("Elastic modulus [Pa]", body, BodySettingsId::ELASTIC_MODULUS)
58  .setEnabler(enablerRheo);
59  category.connect<Float>("von Mises limit [Pa]", body, BodySettingsId::ELASTICITY_LIMIT)
60  .setEnabler([this, enabler] {
62  return (!enabler || enabler()) &&
64  });
65  category.connect<Float>("Melting energy [J/kg]", body, BodySettingsId::MELT_ENERGY)
66  .setEnabler(enablerRheo);
67  category.connect<Float>("Internal friction []", body, BodySettingsId::INTERNAL_FRICTION)
68  .setEnabler(enablerDp);
69  category.connect<Float>("Cohesion [Pa]", body, BodySettingsId::COHESION).setEnabler(enablerDp);
70  category.connect<Float>("Dry friction []", body, BodySettingsId::DRY_FRICTION).setEnabler(enablerDp);
71  category.connect<bool>("Use acoustic fludization", body, BodySettingsId::USE_ACOUSTIC_FLUDIZATION)
72  .setEnabler(enablerDp);
73  category.connect<Float>("Oscillation decay time [s]", body, BodySettingsId::OSCILLATION_DECAY_TIME)
74  .setEnabler(enablerAf);
75  category.connect<Float>("Oscillation regeneration []", body, BodySettingsId::OSCILLATION_REGENERATION)
76  .setEnabler(enablerAf);
77  category.connect<Float>("Fludization viscosity", body, BodySettingsId::FLUIDIZATION_VISCOSITY)
78  .setEnabler(enablerAf);
79  category.connect<EnumWrapper>("Fragmentation", body, BodySettingsId::RHEOLOGY_DAMAGE)
80  .setEnabler(enablerRheo);
81  category.connect<Float>("Weibull exponent", body, BodySettingsId::WEIBULL_EXPONENT)
82  .setEnabler(enablerFrag);
83  category.connect<Float>("Weibull coefficient", body, BodySettingsId::WEIBULL_COEFFICIENT)
84  .setEnabler(enablerFrag);
85  category.connect<bool>("Sample distributions", body, BodySettingsId::WEIBULL_SAMPLE_DISTRIBUTIONS)
86  .setEnabler(enablerFrag);
87 }
88 
89 // ----------------------------------------------------------------------------------------------------------
90 // MaterialJob
91 // ----------------------------------------------------------------------------------------------------------
92 
93 MaterialJob::MaterialJob(const std::string& name, const BodySettings& overrides)
94  : IMaterialJob(name)
95  , MaterialProvider(overrides) {}
96 
98  VirtualSettings connector;
99  addGenericCategory(connector, instName);
100 
101  VirtualSettings::Category& materialCat = connector.addCategory("Material");
102  this->addMaterialEntries(materialCat, nullptr);
103 
104  auto tillotsonEnabler = [this] { return body.get<EosEnum>(BodySettingsId::EOS) == EosEnum::TILLOTSON; };
105 
106  VirtualSettings::Category& tillotsonCat = connector.addCategory("Tillotson's parameters");
107  tillotsonCat.connect<Float>("Tillotson's a", body, BodySettingsId::TILLOTSON_SMALL_A)
108  .setEnabler(tillotsonEnabler);
109  tillotsonCat.connect<Float>("Tillotson's b", body, BodySettingsId::TILLOTSON_SMALL_B)
110  .setEnabler(tillotsonEnabler);
111  tillotsonCat.connect<Float>("Tillotson's B", body, BodySettingsId::TILLOTSON_NONLINEAR_B)
112  .setEnabler(tillotsonEnabler);
113  tillotsonCat.connect<Float>("Tillotson's alpha", body, BodySettingsId::TILLOTSON_ALPHA)
114  .setEnabler(tillotsonEnabler);
115  tillotsonCat.connect<Float>("Tillotson's beta", body, BodySettingsId::TILLOTSON_BETA)
116  .setEnabler(tillotsonEnabler);
117  tillotsonCat.connect<Float>("Incipient vaporization energy", body, BodySettingsId::TILLOTSON_ENERGY_IV)
118  .setEnabler(tillotsonEnabler);
119  tillotsonCat.connect<Float>("Complete vaporization energy", body, BodySettingsId::TILLOTSON_ENERGY_CV)
120  .setEnabler(tillotsonEnabler);
121  tillotsonCat.connect<Float>("Sublimation energy", body, BodySettingsId::TILLOTSON_SUBLIMATION)
122  .setEnabler(tillotsonEnabler);
123 
124  VirtualSettings::Category& integratorCat = connector.addCategory("Time step control");
125  integratorCat.connect<Float>("Density coeff. [kg/m^3]", body, BodySettingsId::DENSITY_MIN);
126  integratorCat.connect<Float>("Energy coeff. [J/kg]", body, BodySettingsId::ENERGY_MIN);
127  integratorCat.connect<Float>("Stress coeff. [Pa]", body, BodySettingsId::STRESS_TENSOR_MIN);
128  integratorCat.connect<Float>("Damage coeff. []", body, BodySettingsId::DAMAGE_MIN);
129 
130  return connector;
131 }
132 
133 
134 void MaterialJob::evaluate(const RunSettings& UNUSED(global), IRunCallbacks& UNUSED(callbacks)) {
136 }
137 
138 static JobRegistrar sRegisterMaterial(
139  "material",
140  "materials",
141  [](const std::string& name) { return makeAuto<MaterialJob>(name); },
142  "Generic material");
143 
144 // these presets only differ in initial parameters, so it's ok if they have different class names
145 static JobRegistrar sRegisterBasalt(
146  "basalt",
147  "materials",
148  [](const std::string& name) {
149  return makeAuto<MaterialJob>(name, getMaterial(MaterialEnum::BASALT)->getParams());
150  },
151  "Basalt");
152 static JobRegistrar sRegisterIce(
153  "ice",
154  "materials",
155  [](const std::string& name) {
156  return makeAuto<MaterialJob>(name, getMaterial(MaterialEnum::ICE)->getParams());
157  },
158  "Ice");
159 static JobRegistrar sRegisterOlivine(
160  "olivine",
161  "materials",
162  [](const std::string& name) {
163  return makeAuto<MaterialJob>(name, getMaterial(MaterialEnum::OLIVINE)->getParams());
164  },
165  "Olivine");
166 static JobRegistrar sRegisterIron(
167  "iron",
168  "materials",
169  [](const std::string& name) {
170  return makeAuto<MaterialJob>(name, getMaterial(MaterialEnum::IRON)->getParams());
171  },
172  "Iron");
173 
174 
175 // ----------------------------------------------------------------------------------------------------------
176 // DisableDerivativeCriterionJob
177 // ----------------------------------------------------------------------------------------------------------
178 
180  VirtualSettings connector;
181  addGenericCategory(connector, instName);
182  return connector;
183 }
184 
186  IRunCallbacks& UNUSED(callbacks)) {
187  SharedPtr<IMaterial> input = this->getInput<IMaterial>("material");
188 
189  // basically should clone the material, needs to be generalized if more complex material setups are used
193 }
194 
195 static JobRegistrar sRegisterDisabler(
196  "optimize timestepping",
197  "optimizer",
198  "materials",
199  [](const std::string& name) { return makeAuto<DisableDerivativeCriterionJob>(name); },
200  "Helper material modifier that turns off the time step limitation for damage and stress "
201  "tensor. Useful to avoid very low time steps due to particles that are deemed not important to "
202  "the solution (such as impactor particles). If the time step is not limited by the derivative "
203  "criterion, this material modifier simply forwards the material parameters unchanged.");
204 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
VirtualSettings::Category & addGenericCategory(VirtualSettings &connector, std::string &instanceName)
Adds a common settings category, used by all jobs.
Definition: Job.cpp:43
AutoPtr< IMaterial > getMaterial(const MaterialEnum type)
Definition: Materials.cpp:91
SPH-specific implementation of particle materials.
constexpr Float INFTY
Definition: MathUtils.h:38
constexpr Float LARGE
Definition: MathUtils.h:34
#define UNUSED(x)
Definition: Object.h:37
#define NAMESPACE_SPH_END
Definition: Object.h:12
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
std::string instName
Definition: Job.h:100
Base class for jobs providing a material.
Definition: Job.h:303
SharedPtr< IMaterial > result
Data filled by the job when it finishes.
Definition: Job.h:306
INLINE const BodySettings & getParams() const
Returns settings containing material parameters.
Definition: IMaterial.h:142
INLINE IMaterial & setParam(const BodySettingsId paramIdx, TValue &&value)
Definition: IMaterial.h:130
Callbacks executed by the simulation to provide feedback to the user.
Definition: IRun.h:27
Object representing a 1D interval of real numbers.
Definition: Interval.h:17
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
MaterialJob(const std::string &name, const BodySettings &overrides=EMPTY_SETTINGS)
void addMaterialEntries(VirtualSettings::Category &category, Function< bool()> enabler)
MaterialProvider(const BodySettings &overrides=EMPTY_SETTINGS)
BodySettings body
Definition: MaterialJobs.h:9
TValue get(const TEnum idx, std::enable_if_t<!std::is_enum< std::decay_t< TValue >>::value, int >=0) const
Returns a value of given type from the settings.
Definition: Settings.h:326
Settings & set(const TEnum idx, TValue &&value, std::enable_if_t<!std::is_enum< std::decay_t< TValue >>::value, int >=0)
Saves a value into the settings.
Definition: Settings.h:226
void addEntries(const Settings &settings)
Adds entries from different Settings object into this one, overriding current entries.
Definition: Settings.h:297
EntryControl & connect(const std::string &name, const std::string &key, TValue &value)
Connects to given reference.
Holds a map of virtual entries, associated with a unique name.
Category & addCategory(const std::string &name)
Creates a new category of entries.
Creating code components based on values from settings.
YieldingEnum
Definition: Settings.h:743
@ NONE
Gass or material with no stress tensor.
@ VON_MISES
Von Mises criterion.
@ DRUCKER_PRAGER
Drucker-Prager pressure dependent yielding stress.
FractureEnum
Definition: Settings.h:757
@ SCALAR_GRADY_KIPP
Grady-Kipp model of fragmentation using scalar damage.
@ NONE
No fragmentation.
EosEnum
Definition: Settings.h:1363
@ IDEAL_GAS
Equation of state for ideal gas.
@ NONE
No equation of state.
@ TILLOTSON
Tillotson (1962) equation of state.
@ INTERNAL_FRICTION
Coefficient of friction for undamaged material.
@ TILLOTSON_NONLINEAR_B
Coefficient B of the nonlinear compressive term in Tillotson equation.
@ ELASTICITY_LIMIT
Elasticity limit of the von Mises yielding criterion.
@ TILLOTSON_ALPHA
Alpha coefficient in expanded phase of Tillotson equation.
@ FLUIDIZATION_VISCOSITY
Effective viscosity of acoustic fludizations.
@ DRY_FRICTION
Coefficient of friction for fully damaged material.
@ WEIBULL_EXPONENT
Exponent of the Weibull distribution of flaws.
@ TILLOTSON_ENERGY_CV
Specific energy of complete vaporization.
@ TILLOTSON_SMALL_B
"Small b" coefficient in Tillotson equation
@ OSCILLATION_REGENERATION
Regeneration efficiency of acoustric oscillations.
@ MELT_ENERGY
Melting energy, used for temperature-dependence of the stress tensor.
@ ENERGY_MIN
Estimated minimal value of energy used to determine timestepping error.
@ USE_ACOUSTIC_FLUDIZATION
Whether to use the acoustic fludization model.
@ DAMAGE_MIN
Estimate minimal value of damage used to determine timestepping error.
@ ELASTIC_MODULUS
Elastic modulus lambda (a.k.a Lame's first parameter) of the material.
@ RHEOLOGY_DAMAGE
Model of fragmentation used within the rheological model.
@ COHESION
Cohesion, yield strength at zero pressure.
@ TILLOTSON_BETA
Beta coefficient in expanded phase of Tillotson equation.
@ DAMAGE
Initial damage of the body.
@ ENERGY
Initial specific internal energy.
@ SHEAR_MODULUS
Shear modulus mu (a.k.a Lame's second parameter) of the material.
@ BULK_MODULUS
Bulk modulus of the material.
@ DENSITY
Density at zero pressure.
@ WEIBULL_COEFFICIENT
Coefficient (multiplier) of the Weibull distribution of flaws.
@ OSCILLATION_DECAY_TIME
Characteristic decay time of acoustic oscillations in the material.
@ TILLOTSON_ENERGY_IV
Specific energy of incipient vaporization.
@ STRESS_TENSOR_MIN
Estimated minial value of stress tensor components used to determined timestepping error.
@ EOS
Equation of state for this material, see EosEnum for options.
@ ENERGY_RANGE
Allowed range of specific internal energy.
@ RHEOLOGY_YIELDING
Model of stress reducing used within the rheological model.
@ TILLOTSON_SMALL_A
"Small a" coefficient in Tillotson equation
@ TILLOTSON_SUBLIMATION
Specific sublimation energy.
@ WEIBULL_SAMPLE_DISTRIBUTIONS
AutoPtr< IMaterial > getMaterial(const BodySettings &settings)
Definition: Factory.cpp:508
Wrapper of an enum.
Definition: Settings.h:37
Helper class, allowing to register job into the global list of jobs.
Definition: Job.h:203