Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
input.hpp
Go to the documentation of this file.
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other Smith Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
13 #pragma once
14 
15 #include <string>
16 #include <variant>
17 #include <optional>
18 #include <functional>
19 #include <memory>
20 #include <set>
21 #include <unordered_map>
22 
23 #include "mfem.hpp"
24 #include "axom/inlet.hpp"
25 #include "axom/sidre.hpp"
26 
31 namespace smith::input {
32 
36 enum class Language
37 {
38  Lua,
39  JSON,
40  YAML
41 };
42 
52 axom::inlet::Inlet initialize(axom::sidre::DataStore& datastore, const std::string& input_file_path,
53  const Language language = Language::Lua, const std::string& sidre_path = "input_file");
54 
63 std::string findMeshFilePath(const std::string& mesh_path, const std::string& input_file_path);
64 
71 std::string fullDirectoryFromPath(const std::string& file_path);
72 
81 std::string getInputFileName(const std::string& file_path);
82 
87 void defineVectorInputFileSchema(axom::inlet::Container& container);
88 
97  using VecFunc = std::function<void(const mfem::Vector&, double, mfem::Vector&)>;
98 
103  using ScalarFunc = std::function<double(const mfem::Vector&, double)>;
108 
113 
117  std::optional<double> scalar_constant;
118 
122  std::optional<mfem::Vector> vector_constant;
123 
127  std::unordered_map<int, double> scalar_pw_const;
128 
132  std::unordered_map<int, mfem::Vector> vector_pw_const;
133 
137  std::optional<int> component;
141  bool isVector() const;
145  std::unique_ptr<mfem::VectorCoefficient> constructVector(const int dim = 3) const;
149  std::unique_ptr<mfem::Coefficient> constructScalar() const;
153  static void defineInputFileSchema(axom::inlet::Container& container);
154 };
155 
163  std::set<int> attrs{};
173  static void defineInputFileSchema(axom::inlet::Container& container);
174 };
175 
176 } // namespace smith::input
177 
183 template <>
184 struct FromInlet<mfem::Vector> {
186  mfem::Vector operator()(const axom::inlet::Container& base);
187 };
188 
194 template <>
195 struct FromInlet<smith::input::CoefficientInputOptions> {
197  smith::input::CoefficientInputOptions operator()(const axom::inlet::Container& base);
198 };
199 
205 template <>
206 struct FromInlet<smith::input::BoundaryConditionInputOptions> {
208  smith::input::BoundaryConditionInputOptions operator()(const axom::inlet::Container& base);
209 };
The input related helper functions and objects.
Definition: input.cpp:20
Language
The input file languages supported by Inlet.
Definition: input.hpp:37
std::string fullDirectoryFromPath(const std::string &path)
Returns the absolute directory of the given file path.
Definition: input.cpp:70
axom::inlet::Inlet initialize(axom::sidre::DataStore &datastore, const std::string &input_file_path, const Language language, const std::string &sidre_path)
Initializes Inlet with the given datastore and input file.
Definition: input.cpp:22
void defineVectorInputFileSchema(axom::inlet::Container &container)
Defines the schema for a vector in R^{1,2,3} space.
Definition: input.cpp:98
std::string getInputFileName(const std::string &file_path)
Returns the name of the input file (base name with file extension removed).
Definition: input.cpp:82
std::string findMeshFilePath(const std::string &mesh_path, const std::string &input_file_path)
Returns the absolute path of the given mesh either relative to CWD or the input file.
Definition: input.cpp:48
Accelerator functionality.
Definition: smith.cpp:36
The information required from the input file for a boundary condition.
Definition: input.hpp:159
static void defineInputFileSchema(axom::inlet::Container &container)
Input file parameters specific to this class.
Definition: input.cpp:107
std::set< int > attrs
The mesh attributes on which to apply the boundary condition.
Definition: input.hpp:163
CoefficientInputOptions coef_opts
The information from the input file on the BC coefficient.
Definition: input.hpp:167
The information required from the input file for an mfem::(Vector)(Function)Coefficient.
Definition: input.hpp:92
static void defineInputFileSchema(axom::inlet::Container &container)
Defines the input file schema on the provided inlet container.
Definition: input.cpp:192
std::unordered_map< int, double > scalar_pw_const
Scalar piecewise constant definition map.
Definition: input.hpp:127
VecFunc vector_function
The vector std::function corresponding to a function coefficient.
Definition: input.hpp:112
std::function< void(const mfem::Vector &, double, mfem::Vector &)> VecFunc
The type for coefficient functions that are vector-valued.
Definition: input.hpp:97
std::function< double(const mfem::Vector &, double)> ScalarFunc
The type for coefficient functions that are scalar-valued.
Definition: input.hpp:103
std::unordered_map< int, mfem::Vector > vector_pw_const
Vector piecewise constant definition map.
Definition: input.hpp:132
std::optional< int > component
The component to which a scalar coefficient should be applied.
Definition: input.hpp:137
std::unique_ptr< mfem::VectorCoefficient > constructVector(const int dim=3) const
Constructs a vector coefficient with the requested dimension.
Definition: input.cpp:118
ScalarFunc scalar_function
The scalar std::function corresponding to a function coefficient.
Definition: input.hpp:107
std::optional< double > scalar_constant
The scalar constant associated with the coefficient.
Definition: input.hpp:117
std::unique_ptr< mfem::Coefficient > constructScalar() const
Constructs a scalar coefficient.
Definition: input.cpp:158
bool isVector() const
Returns whether the contained function corresponds to a vector coefficient.
Definition: input.cpp:113
std::optional< mfem::Vector > vector_constant
The vector constant associated with the coefficient.
Definition: input.hpp:122