24template <
typename Sol
idMaterial>
 
   26         std::vector<std::pair<int, typename SolidMaterial::InternalVariable>>>
 
   28    std::map<
int, std::shared_ptr<SolidMaterial>> 
const& solid_materials)
 
   30    assert(!solid_materials.empty());
 
   36        std::vector<std::pair<int, typename SolidMaterial::InternalVariable>>>
 
   37        internal_variables_by_name;
 
   38    for (
auto const& [material_id, solid_material] : solid_materials)
 
   40        auto const& internal_variables = solid_material->getInternalVariables();
 
   41        for (
auto const& iv : internal_variables)
 
   43            internal_variables_by_name[iv.name].push_back({material_id, iv});
 
   49    for (
auto const& [name, mat_iv_collection] : internal_variables_by_name)
 
   51        if (mat_iv_collection.empty())
 
   55        auto const num_components =
 
   56            mat_iv_collection.front().second.num_components;
 
   59                begin(mat_iv_collection), end(mat_iv_collection),
 
   60                [num_components](
auto const& mat_iv)
 
   61                { 
return mat_iv.second.num_components == num_components; }))
 
   64                "Not for all material ids the secondary variable '{:s}' has " 
   66                name, num_components);
 
   70    return internal_variables_by_name;
 
 
   73template <
typename InternalVariable>
 
   76    template <
typename LocalAssemblerInterface>
 
   80        int const material_id =
 
   83        auto const mat_iv_it = std::find_if(
 
   85            [material_id](
auto const& x) { 
return x.first == material_id; });
 
   96        return &mat_iv_it->second;
 
 
 
  104template <
typename Pair>
 
  108template <
typename Sol
idMaterial>
 
  110    std::map<
int, std::shared_ptr<SolidMaterial>> 
const& solid_materials,
 
  111    auto const& function)
 
  119    bool const material_id_independent = solid_materials.size() == 1;
 
  124    for (
auto&& [name, mat_iv_collection] : internal_variables_by_name)
 
  126        auto const num_components =
 
  127            mat_iv_collection.front().second.num_components;
 
  132                                             material_id_independent});
 
 
  136template <
typename InternalVariable>
 
  142            internal_variables_collection)
 
  144              std::move(internal_variables_collection))
 
 
  148    template <
typename LocalAssemblerInterface>
 
  152        std::vector<GlobalVector*> 
const& ,
 
  153        std::vector<NumLib::LocalToGlobalIndexMap const*> 
const& ,
 
  154        std::vector<double>& cache)
 const 
  158        auto const* 
const iv =
 
  169        auto const& fct = iv->getter;
 
  171        const unsigned num_int_pts = loc_asm.getNumberOfIntegrationPoints();
 
  172        assert(num_int_pts > 0);
 
  175            double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(
 
  179        std::vector<double> cache_column(num_int_pts);
 
  181        for (
unsigned i = 0; i < num_int_pts; ++i)
 
  183            auto const& state = loc_asm.getMaterialStateVariablesAt(i);
 
  185            auto const& int_pt_values = fct(state, cache_column);
 
  186            assert(int_pt_values.size() ==
 
  187                   static_cast<std::size_t
>(
 
  191            cache_mat.col(i).noalias() = int_pt_values_vec;
 
 
 
  203          typename AddSecondaryVariableCallback>
 
  205    std::map<
int, std::shared_ptr<SolidMaterial>> 
const& solid_materials,
 
  206    AddSecondaryVariableCallback 
const& add_secondary_variable)
 
  208    auto register_secondary_variable =
 
  209        [&add_secondary_variable](
 
  210            std::string 
const& name,
 
  212                typename SolidMaterial::InternalVariable>&&
 
  213                internal_variables_collection)
 
  215        DBUG(
"Registering internal variable {:s}.", name);
 
  217        add_secondary_variable(name,
 
  218                               internal_variables_collection.num_components,
 
  220                                   std::move(internal_variables_collection)});
 
  224                                         register_secondary_variable);
 
 
  227template <
typename InternalVariable>
 
  233            internal_variables_collection)
 
 
  238    template <
typename LocalAssemblerInterface>
 
  251        auto const& fct = iv->reference;
 
  253        return loc_asm.getMaterialStateVariableInternalState(
 
 
 
  262template <
typename LocalAssemblerInterface, 
typename Sol
idMaterial>
 
  264    std::map<
int, std::shared_ptr<SolidMaterial>> 
const& solid_materials,
 
  265    std::vector<std::unique_ptr<LocalAssemblerInterface>> 
const&
 
  267    std::vector<std::unique_ptr<MeshLib::IntegrationPointWriter>>&
 
  268        integration_point_writer,
 
  269    int const integration_order)
 
  271    auto add_integration_point_writer =
 
  272        [&local_assemblers, &integration_point_writer, integration_order](
 
  273            std::string 
const& name,
 
  275                typename SolidMaterial::InternalVariable>&&
 
  276                internal_variables_collection)
 
  278        DBUG(
"Creating integration point writer for  internal variable {:s}.",
 
  281        integration_point_writer.emplace_back(
 
  282            std::make_unique<MeshLib::IntegrationPointWriter>(
 
  283                "material_state_variable_" + name + 
"_ip",
 
  284                internal_variables_collection.num_components, integration_order,
 
  287                    std::move(internal_variables_collection)}));
 
  291                                         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)