Redesign create_materials
In input/src/include/input/userinput.h:
-
For each material appearing in solver/initialize_material.h, create a corresponding material property struct holding userinput values (e.g. KimFccProperties
forKimFcc
). Leave them empty initially, move values fromUserinput
into such structs later. Note: each field of such a struct should have a default value (as inuserinput
). -
A new field material
of typestd::variant<KimFccProperties, ...>
(replace...
by the remaining property structs you created).
In solver/initialize_material.h:
-
Rewrite the create_material
function, so it creates the correct material appearing in the newly createdmaterial
field ofUserinput
. Usestd::visit
. At this point move everything specific to a certain material fromUserinput
into the property structs from the above steps (there are already some structs which could be converted into material property structs:MeamPotentialParameters
,NNParameters
).
In input/src/userinput_json.cc
-
Make the material
field inUserinput
serializable (first need to make the property structs serializable). An equivalent change was recently done in lattice/latticeGenerators/lattice_generator_parameters/src/lattice_parameters_json.h by @stefazim for LatticeGeneratorParameters::method:
std::variant<SymmetricGrainboundaries<Dimension>, NanoIndentation<Dimension>,
ReadCoordinates>
method = NanoIndentation<Dimension>{};
To make a struct serializable, use: NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT
as in lattice/latticeGenerators/lattice_generator_parameters/src/lattice_parameters_json.h.
To make a variant serializable do something similar as:
// std::stringview <-> Variant type mapping
template <>
struct utils::json::VariantName<lattice::SymmetricGrainboundaries<3>> {
static constexpr std::string_view name =
std::string_view{"SymmetricGrainboundaries"};
};
template <> struct utils::json::VariantName<lattice::ReadCoordinates> {
static constexpr std::string_view name = std::string_view{"ReadCoordinates"};
};
template <> struct utils::json::VariantName<lattice::NanoIndentation<3>> {
static constexpr std::string_view name = std::string_view{"NanoIndentation"};
};