Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
solid_material_input.cpp
1 // Copyright (c) 2019-2024, 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 namespace serac {
10 
11 void SolidMaterialInputOptions::defineInputFileSchema(axom::inlet::Container& container)
12 {
13  // Define schema with each solid material parameter
14  container.addString("model", "The model of material (e.g. NeoHookean)").required(true);
15  container.addDouble("density", "Initial mass density");
16 
17  // Solid mechanics (neo-hookean, linear isotropic)
18  container.addDouble("mu", "The shear modulus");
19  container.addDouble("K", "The bulk modulus");
20 
21  // Solid mechanics (j2, j2nonlinear)
22  container.addDouble("E", "Young's modulus");
23  container.addDouble("nu", "Poisson's ratio");
24  container.addDouble("Hi", "Isotropic hardening constant");
25  container.addDouble("Hk", "Kinematic hardening constant");
26  container.addDouble("sigma_y", "Yield stress");
27  auto& hardening_container = container.addStruct("hardening", "Hardening law");
29 
30  // Verify
31  container.registerVerifier([](const axom::inlet::Container& c) -> bool {
32  axom::inlet::InletType double_type = axom::inlet::InletType::Double;
33  axom::inlet::InletType obj_type = axom::inlet::InletType::Object;
34  bool density_present = c.contains("density") && (c["density"].type() == double_type);
35  bool mu_present = c.contains("mu") && (c["mu"].type() == double_type);
36  bool K_present = c.contains("K") && (c["K"].type() == double_type);
37  bool E_present = c.contains("E") && (c["E"].type() == double_type);
38  bool nu_present = c.contains("nu") && (c["nu"].type() == double_type);
39  bool Hi_present = c.contains("Hi") && (c["Hi"].type() == double_type);
40  bool sigma_y_present = c.contains("sigma_y") && (c["sigma_y"].type() == double_type);
41  bool hardening_present = c.contains("hardening") && (c["hardening"].type() == obj_type);
42 
43  std::string model = c["model"];
44  if (model == "NeoHookean" || model == "LinearIsotropic") {
45  return density_present && mu_present && K_present && !E_present && !nu_present && !Hi_present &&
46  !sigma_y_present && !hardening_present;
47  } else if (model == "J2") {
48  return density_present && !mu_present && !K_present && E_present && nu_present && Hi_present && sigma_y_present &&
49  !hardening_present;
50  } else if (model == "J2Nonlinear") {
51  return density_present && !mu_present && !K_present && E_present && nu_present && !Hi_present &&
52  !sigma_y_present && hardening_present;
53  }
54 
55  return false;
56  });
57 }
58 
59 } // namespace serac
60 
62 {
64  std::string model = base["model"];
65 
66  if (model == "NeoHookean") {
67  result = serac::solid_mechanics::NeoHookean{.density = base["density"], .K = base["K"], .G = base["mu"]};
68  } else if (model == "LinearIsotropic") {
69  result = serac::solid_mechanics::LinearIsotropic{.density = base["density"], .K = base["K"], .G = base["mu"]};
70  } else if (model == "J2") {
71  result = serac::solid_mechanics::J2{.E = base["E"],
72  .nu = base["nu"],
73  .Hi = base["Hi"],
74  .Hk = base["Hk"],
75  .sigma_y = base["sigma_y"],
76  .density = base["density"]};
77  } else if (model == "J2Nonlinear") {
78  serac::var_hardening_t hardening = base["hardening"].get<serac::var_hardening_t>();
79 
80  if (std::holds_alternative<serac::solid_mechanics::PowerLawHardening>(hardening)) {
82  .E = base["E"],
83  .nu = base["nu"],
84  .hardening = std::get<serac::solid_mechanics::PowerLawHardening>(hardening),
85  .density = base["density"]};
86  } else if (std::holds_alternative<serac::solid_mechanics::VoceHardening>(hardening)) {
88  .E = base["E"],
89  .nu = base["nu"],
90  .hardening = std::get<serac::solid_mechanics::VoceHardening>(hardening),
91  .density = base["density"]};
92  }
93  }
94 
95  return result;
96 }
Accelerator functionality.
Definition: serac.cpp:38
std::variant< solid_mechanics::NeoHookean, solid_mechanics::LinearIsotropic, solid_mechanics::J2, solid_mechanics::J2Nonlinear< solid_mechanics::PowerLawHardening >, solid_mechanics::J2Nonlinear< 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:274
std::variant< solid_mechanics::PowerLawHardening, solid_mechanics::VoceHardening > var_hardening_t
Holds all possible isotropic hardening laws that can be utilized in our input file.
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.
a 3D constitutive model for a J2 material with linear isotropic and kinematic hardening.
double E
Young's modulus.
Linear isotropic elasticity material model.
Neo-Hookean material model.