Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
solid_material_input.cpp
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other Serac Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
8 
9 #include <string>
10 
13 
14 namespace serac {
15 
16 void SolidMaterialInputOptions::defineInputFileSchema(axom::inlet::Container& container)
17 {
18  // Define schema with each solid material parameter
19  container.addString("model", "The model of material (e.g. NeoHookean)").required(true);
20  container.addDouble("density", "Initial mass density");
21 
22  // Solid mechanics (neo-hookean, linear isotropic)
23  container.addDouble("mu", "The shear modulus");
24  container.addDouble("K", "The bulk modulus");
25 
26  // Solid mechanics (j2, j2nonlinear)
27  container.addDouble("E", "Young's modulus");
28  container.addDouble("nu", "Poisson's ratio");
29  container.addDouble("Hk", "Kinematic hardening constant");
30  auto& hardening_container = container.addStruct("hardening", "Hardening law");
32 
33  // Verify
34  container.registerVerifier([](const axom::inlet::Container& c) -> bool {
35  axom::inlet::InletType double_type = axom::inlet::InletType::Double;
36  axom::inlet::InletType obj_type = axom::inlet::InletType::Object;
37  bool density_present = c.contains("density") && (c["density"].type() == double_type);
38  bool mu_present = c.contains("mu") && (c["mu"].type() == double_type);
39  bool K_present = c.contains("K") && (c["K"].type() == double_type);
40  bool E_present = c.contains("E") && (c["E"].type() == double_type);
41  bool nu_present = c.contains("nu") && (c["nu"].type() == double_type);
42  bool Hk_present = c.contains("Hk") && (c["Hk"].type() == double_type);
43  bool hardening_present = c.contains("hardening") && (c["hardening"].type() == obj_type);
44 
45  std::string model = c["model"];
46  if (model == "NeoHookean" || model == "LinearIsotropic") {
47  return density_present && mu_present && K_present && !E_present && !nu_present && !hardening_present;
48  } else if (model == "J2SmallStrain") {
49  return density_present && !mu_present && !K_present && E_present && nu_present && Hk_present && hardening_present;
50  }
51 
52  return false;
53  });
54 }
55 
56 } // namespace serac
57 
59 {
61  std::string model = base["model"];
62 
63  if (model == "NeoHookean") {
64  result = serac::solid_mechanics::NeoHookean{.density = base["density"], .K = base["K"], .G = base["mu"]};
65  } else if (model == "LinearIsotropic") {
66  result = serac::solid_mechanics::LinearIsotropic{.density = base["density"], .K = base["K"], .G = base["mu"]};
67  } else if (model == "J2SmallStrain") {
68  serac::var_hardening_t hardening = base["hardening"].get<serac::var_hardening_t>();
69 
70  if (std::holds_alternative<serac::solid_mechanics::LinearHardening>(hardening)) {
72  .E = base["E"],
73  .nu = base["nu"],
74  .hardening = std::get<serac::solid_mechanics::LinearHardening>(hardening),
75  .Hk = base["Hk"],
76  .density = base["density"]};
77  } else if (std::holds_alternative<serac::solid_mechanics::PowerLawHardening>(hardening)) {
79  .E = base["E"],
80  .nu = base["nu"],
81  .hardening = std::get<serac::solid_mechanics::PowerLawHardening>(hardening),
82  .Hk = base["Hk"],
83  .density = base["density"]};
84  } else if (std::holds_alternative<serac::solid_mechanics::VoceHardening>(hardening)) {
86  .E = base["E"],
87  .nu = base["nu"],
88  .hardening = std::get<serac::solid_mechanics::VoceHardening>(hardening),
89  .Hk = base["Hk"],
90  .density = base["density"]};
91  }
92  }
93 
94  return result;
95 }
This file contains functions for reading a material from input files.
Accelerator functionality.
Definition: serac.cpp:36
std::variant< solid_mechanics::NeoHookean, solid_mechanics::LinearIsotropic, solid_mechanics::J2SmallStrain< solid_mechanics::LinearHardening >, solid_mechanics::J2SmallStrain< solid_mechanics::PowerLawHardening >, solid_mechanics::J2SmallStrain< solid_mechanics::VoceHardening > > var_solid_material_t
All possible solid mechanics materials that can be utilized in our input file.
constexpr SERAC_HOST_DEVICE auto type(const tuple< T... > &values)
a function intended to be used for extracting the ith type from a tuple.
Definition: tuple.hpp:379
std::variant< solid_mechanics::LinearHardening, solid_mechanics::PowerLawHardening, solid_mechanics::VoceHardening > var_hardening_t
Holds all possible isotropic hardening laws that can be utilized in our input file.
The material and load types for the solid functional physics module.
This file contains functions for reading a material from input files.
serac::var_solid_material_t operator()(const axom::inlet::Container &base)
Returns created object from Inlet container.
static void defineInputFileSchema(axom::inlet::Container &container)
Input file parameters specific to this class.
static void defineInputFileSchema(axom::inlet::Container &container)
Input file parameters specific to this class.
J2 material with nonlinear isotropic hardening and linear kinematic hardening.
Linear isotropic elasticity material model.
Neo-Hookean material model.