17template <
typename Sol
idMaterial>
19 std::vector<std::pair<int, typename SolidMaterial::InternalVariable>>>
21 std::map<
int, std::shared_ptr<SolidMaterial>>
const& solid_materials)
23 assert(!solid_materials.empty());
29 std::vector<std::pair<int, typename SolidMaterial::InternalVariable>>>
30 internal_variables_by_name;
31 for (
auto const& [material_id, solid_material] : solid_materials)
33 auto const& internal_variables = solid_material->getInternalVariables();
34 for (
auto const& iv : internal_variables)
36 internal_variables_by_name[iv.name].push_back({material_id, iv});
42 for (
auto const& [name, mat_iv_collection] : internal_variables_by_name)
44 if (mat_iv_collection.empty())
48 auto const num_components =
49 mat_iv_collection.front().second.num_components;
52 begin(mat_iv_collection), end(mat_iv_collection),
53 [num_components](
auto const& mat_iv)
54 {
return mat_iv.second.num_components == num_components; }))
57 "Not for all material ids the secondary variable '{:s}' has "
59 name, num_components);
63 return internal_variables_by_name;
66template <
typename InternalVariable>
69 template <
typename LocalAssemblerInterface>
73 int const material_id =
76 auto const mat_iv_it = std::find_if(
78 [material_id](
auto const& x) {
return x.first == material_id; });
89 return &mat_iv_it->second;
97template <
typename Pair>
101template <
typename Sol
idMaterial>
103 std::map<
int, std::shared_ptr<SolidMaterial>>
const& solid_materials,
104 auto const& function)
112 bool const material_id_independent = solid_materials.size() == 1;
117 for (
auto&& [name, mat_iv_collection] : internal_variables_by_name)
119 auto const num_components =
120 mat_iv_collection.front().second.num_components;
125 material_id_independent});
129template <
typename InternalVariable>
135 internal_variables_collection)
137 std::move(internal_variables_collection))
141 template <
typename LocalAssemblerInterface>
145 std::vector<GlobalVector*>
const& ,
146 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& ,
147 std::vector<double>& cache)
const
151 auto const*
const iv =
162 auto const& fct = iv->getter;
164 const unsigned num_int_pts = loc_asm.getNumberOfIntegrationPoints();
165 assert(num_int_pts > 0);
168 double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(
172 std::vector<double> cache_column(num_int_pts);
174 for (
unsigned i = 0; i < num_int_pts; ++i)
176 auto const& state = loc_asm.getMaterialStateVariablesAt(i);
178 auto const& int_pt_values = fct(state, cache_column);
179 assert(int_pt_values.size() ==
180 static_cast<std::size_t
>(
184 cache_mat.col(i).noalias() = int_pt_values_vec;
196 typename AddSecondaryVariableCallback>
198 std::map<
int, std::shared_ptr<SolidMaterial>>
const& solid_materials,
199 AddSecondaryVariableCallback
const& add_secondary_variable)
201 auto register_secondary_variable =
202 [&add_secondary_variable](
203 std::string
const& name,
205 typename SolidMaterial::InternalVariable>&&
206 internal_variables_collection)
208 DBUG(
"Registering internal variable {:s}.", name);
210 add_secondary_variable(name,
211 internal_variables_collection.num_components,
213 std::move(internal_variables_collection)});
217 register_secondary_variable);
220template <
typename InternalVariable>
226 internal_variables_collection)
231 template <
typename LocalAssemblerInterface>
244 auto const& fct = iv->reference;
246 return loc_asm.getMaterialStateVariableInternalState(
255template <
typename LocalAssemblerInterface,
typename Sol
idMaterial>
257 std::map<
int, std::shared_ptr<SolidMaterial>>
const& solid_materials,
258 std::vector<std::unique_ptr<LocalAssemblerInterface>>
const&
260 std::vector<std::unique_ptr<MeshLib::IntegrationPointWriter>>&
261 integration_point_writer,
262 int const integration_order)
264 auto add_integration_point_writer =
265 [&local_assemblers, &integration_point_writer, integration_order](
266 std::string
const& name,
268 typename SolidMaterial::InternalVariable>&&
269 internal_variables_collection)
271 DBUG(
"Creating integration point writer for internal variable {:s}.",
274 integration_point_writer.emplace_back(
275 std::make_unique<MeshLib::IntegrationPointWriter>(
276 "material_state_variable_" + name +
"_ip",
277 internal_variables_collection.num_components, integration_order,
280 std::move(internal_variables_collection)}));
284 add_integration_point_writer);
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
Eigen::Map< Matrix > createZeroedMatrix(std::vector< double > &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)