OGS
ProcessLib::Reflection Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  ReflectionData
 

Functions

template<typename Class , typename Accessor >
auto makeReflectionData (Accessor &&accessor)
 
template<typename Class , typename Accessor >
auto makeReflectionData (std::string name, Accessor &&accessor)
 
template<typename Class , typename Member >
auto makeReflectionData (Member Class::*member)
 
template<typename Class , typename Member >
auto makeReflectionData (std::string name, Member Class::*member)
 
template<typename Class , typename Member >
auto reflectWithName (std::string name, Member Class::*member)
 
template<typename Class , typename... Accessors>
auto reflectWithoutName (Accessors &&... accessors)
 
template<typename Class , typename... Members>
auto reflectWithoutName (Members Class::*... members)
 
template<int Dim, typename LocAsmIF , typename ReflData >
void addReflectedSecondaryVariables (ReflData const &reflection_data, SecondaryVariableCollection &secondary_variables, NumLib::Extrapolator &extrapolator, std::vector< std::unique_ptr< LocAsmIF > > const &local_assemblers)
 
template<int Dim, typename LocAsmIF , typename ReflData >
void addReflectedIntegrationPointWriters (ReflData const &reflection_data, std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > &integration_point_writers, unsigned const integration_order, std::vector< std::unique_ptr< LocAsmIF > > const &local_assemblers)
 
template<int Dim, typename LocAsmIF , typename Callback , typename ReflData >
void forEachReflectedFlattenedIPDataAccessor (ReflData const &reflection_data, Callback const &callback)
 
template<int dim, typename IPData >
std::size_t reflectSetIPData (std::string_view const name, double const *values, std::vector< IPData > &ip_data_vector)
 

Function Documentation

◆ addReflectedIntegrationPointWriters()

template<int Dim, typename LocAsmIF , typename ReflData >
void ProcessLib::Reflection::addReflectedIntegrationPointWriters ( ReflData const & reflection_data,
std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > & integration_point_writers,
unsigned const integration_order,
std::vector< std::unique_ptr< LocAsmIF > > const & local_assemblers )

Adds IP data writers for all IP data obtained recursively from the given reflection_data to the given IP writer vector.

Definition at line 21 of file ReflectionForIPWriters.h.

27{
28 forEachReflectedFlattenedIPDataAccessor<Dim, LocAsmIF>(
29 reflection_data,
30 [&integration_point_writers, integration_order, &local_assemblers](
31 std::string const& name,
32 unsigned const num_comp,
33 auto&& flattened_ip_data_accessor)
34 {
35 // TODO check if writer with such a name already exists.
36 integration_point_writers.emplace_back(
37 std::make_unique<MeshLib::IntegrationPointWriter>(
38 name + "_ip", num_comp, integration_order, local_assemblers,
39 flattened_ip_data_accessor));
40 });
41}

Referenced by ProcessLib::LargeDeformation::LargeDeformationProcess< DisplacementDim >::LargeDeformationProcess(), ProcessLib::RichardsMechanics::RichardsMechanicsProcess< DisplacementDim >::RichardsMechanicsProcess(), and ProcessLib::SmallDeformation::SmallDeformationProcess< DisplacementDim >::SmallDeformationProcess().

◆ addReflectedSecondaryVariables()

template<int Dim, typename LocAsmIF , typename ReflData >
void ProcessLib::Reflection::addReflectedSecondaryVariables ( ReflData const & reflection_data,
SecondaryVariableCollection & secondary_variables,
NumLib::Extrapolator & extrapolator,
std::vector< std::unique_ptr< LocAsmIF > > const & local_assemblers )

Adds secondary variables for all IP data obtained recursively from the given reflection_data to the given secondary variable collection.

Definition at line 21 of file ReflectionForExtrapolation.h.

26{
27 forEachReflectedFlattenedIPDataAccessor<Dim, LocAsmIF>(
28 reflection_data,
29 [&secondary_variables, &local_assemblers, &extrapolator](
30 std::string const& name,
31 unsigned const num_comp,
32 auto&& flattened_ip_data_accessor)
33 {
34 secondary_variables.addSecondaryVariable(
35 name,
36 makeExtrapolator2(num_comp, extrapolator, local_assemblers,
37 flattened_ip_data_accessor));
38 });
39}
void addSecondaryVariable(std::string const &internal_name, SecondaryVariableFunctions &&fcts)
SecondaryVariableFunctions makeExtrapolator2(const unsigned num_components, NumLib::Extrapolator &extrapolator, LocalAssemblerCollection const &local_assemblers, IPDataAccessor &&accessor)

References ProcessLib::SecondaryVariableCollection::addSecondaryVariable(), and ProcessLib::makeExtrapolator2().

◆ forEachReflectedFlattenedIPDataAccessor()

template<int Dim, typename LocAsmIF , typename Callback , typename ReflData >
void ProcessLib::Reflection::forEachReflectedFlattenedIPDataAccessor ( ReflData const & reflection_data,
Callback const & callback )

Calls the passed callback for each IP data accessor for the given LocAsmIF class.

The IP data accessors are obtained via reflection (i.e., via the static reflect() method.

The IP data accessors provide IP data as a flat std::vector<double>.

The callback must accept name, number of components and a function object with signature LocAsmIF const& -> std::vector<double> as its arguments.

Definition at line 456 of file ReflectionIPData.h.

458{
459 using namespace boost::mp11;
460
461 static_assert(mp_is_list_v<ReflData>,
462 "The passed reflection data is not a std::tuple.");
463 static_assert(std::is_same_v<ReflData, mp_rename<ReflData, std::tuple>>,
464 "The passed reflection data is not a std::tuple.");
465
466 tuple_for_each(
467 reflection_data,
468 [&callback]<typename Class, typename Accessor>(
469 ReflectionData<Class, Accessor> const& refl_data)
470 {
471 static_assert(std::is_same_v<Class, LocAsmIF>,
472 "The currently processed reflection data is not for "
473 "the given LocAsmIF but for a different class.");
474
475 using AccessorResultRef =
476 std::invoke_result_t<Accessor, Class const&>;
477 using AccessorResult = std::remove_cvref_t<AccessorResultRef>;
478
479 // AccessorResult must be a std::vector<SomeType, SomeAllocator>. We
480 // check that, now.
481 static_assert(
482 mp_is_list_v<AccessorResult>); // std::vector<SomeType,
483 // SomeAllocator> is a list in
484 // the Boost MP11 sense
485 static_assert(
486 std::is_same_v<AccessorResult,
487 mp_rename<AccessorResult, std::vector>>,
488 "We expect a std::vector, here.");
489 // Now, we know that AccessorResult is std::vector<Member>. To be
490 // more specific, AccessorResult is a std::vector<IPData> and Member
491 // is IPData.
492 using Member = typename AccessorResult::value_type;
493
494 auto accessor_ip_data_vec_in_loc_asm =
495 [ip_data_vector_accessor =
496 refl_data.accessor](LocAsmIF const& loc_asm) -> auto const&
497 {
498 return ip_data_vector_accessor(loc_asm);
499 };
500
501 if constexpr (detail::is_reflectable<Member>)
502 {
503 detail::forEachReflectedFlattenedIPDataAccessor<Dim>(
504 callback,
505 detail::reflect(std::type_identity<Member>{}),
506 accessor_ip_data_vec_in_loc_asm);
507 }
508 else
509 {
510 static_assert(detail::is_raw_data_v<Member>,
511 "The current member is not reflectable, so we "
512 "expect it to be raw data.");
513
514 constexpr unsigned num_comp =
515 detail::NumberOfComponents<Member>::value;
516
517 assert(!refl_data.name.empty());
518 callback(refl_data.name, num_comp,
519 detail::getFlattenedIPDataFromLocAsm<Dim>(
520 accessor_ip_data_vec_in_loc_asm));
521 }
522 });
523}

References ProcessLib::Reflection::ReflectionData< Class, Accessor >::accessor, ProcessLib::Reflection::ReflectionData< Class, Accessor >::name, and ProcessLib::Reflection::detail::reflect().

Referenced by ProcessLib::computeCellAverages().

◆ makeReflectionData() [1/4]

template<typename Class , typename Accessor >
auto ProcessLib::Reflection::makeReflectionData ( Accessor && accessor)

◆ makeReflectionData() [2/4]

template<typename Class , typename Member >
auto ProcessLib::Reflection::makeReflectionData ( Member Class::* member)

Definition at line 65 of file ReflectionData.h.

66{
67 return makeReflectionData<Class>([member](auto& obj) -> auto&
68 { return obj.*member; });
69}

◆ makeReflectionData() [3/4]

template<typename Class , typename Accessor >
auto ProcessLib::Reflection::makeReflectionData ( std::string name,
Accessor && accessor )

Definition at line 58 of file ReflectionData.h.

59{
61 std::move(name), std::forward<Accessor>(accessor)};
62}

◆ makeReflectionData() [4/4]

template<typename Class , typename Member >
auto ProcessLib::Reflection::makeReflectionData ( std::string name,
Member Class::* member )

Definition at line 72 of file ReflectionData.h.

73{
74 return makeReflectionData<Class>(
75 std::move(name), [member](auto& obj) -> auto& { return obj.*member; });
76}

◆ reflectSetIPData()

template<int dim, typename IPData >
std::size_t ProcessLib::Reflection::reflectSetIPData ( std::string_view const name,
double const * values,
std::vector< IPData > & ip_data_vector )

Sets integration point data for the property with the given name to the passed values.

Possible candidate properties are obtained from IPData via some sort of reflection.

Returns
The number of integration points.

Definition at line 170 of file ReflectionSetIPData.h.

172{
173 detail::reflectSetIPData<dim>(
174 name, values, ip_data_vector, std::identity{},
175 detail::reflect(std::type_identity<IPData>{}));
176
177 return ip_data_vector.size();
178}

References ProcessLib::Reflection::detail::reflect().

◆ reflectWithName()

template<typename Class , typename Member >
auto ProcessLib::Reflection::reflectWithName ( std::string name,
Member Class::* member )

Definition at line 79 of file ReflectionData.h.

80{
81 return std::tuple{makeReflectionData(std::move(name), member)};
82}
auto makeReflectionData(Accessor &&accessor)

References makeReflectionData().

Referenced by ProcessLib::ConstitutiveRelations::StrainData< DisplacementDim >::reflect(), ProcessLib::ConstitutiveRelations::StressData< DisplacementDim >::reflect(), ProcessLib::SmallDeformation::FreeEnergyDensityData::reflect(), ProcessLib::TH2M::ConstitutiveRelations::SaturationData::reflect(), ProcessLib::TH2M::ConstitutiveRelations::SwellingDataStateful< DisplacementDim >::reflect(), ProcessLib::TH2M::ConstitutiveRelations::TotalStressData< DisplacementDim >::reflect(), ProcessLib::ThermoRichardsMechanics::LiquidDensityData::reflect(), ProcessLib::ThermoRichardsMechanics::PorosityData::reflect(), ProcessLib::ThermoRichardsMechanics::SaturationData::reflect(), ProcessLib::ThermoRichardsMechanics::SolidDensityData::reflect(), ProcessLib::ThermoRichardsMechanics::TotalStressData< DisplacementDim >::reflect(), ProcessLib::ThermoRichardsMechanics::TransportPorosityData::reflect(), ProcessLib::ThermoRichardsMechanics::ConstitutiveStress_StrainTemperature::MechanicalStrainData< DisplacementDim >::reflect(), ProcessLib::ThermoRichardsMechanics::ConstitutiveStress_StrainTemperature::EffectiveStressData< DisplacementDim >::reflect(), and ProcessLib::ThermoRichardsMechanics::ConstitutiveStress_StrainTemperature::SwellingDataStateful< DisplacementDim >::reflect().

◆ reflectWithoutName() [1/2]

◆ reflectWithoutName() [2/2]

template<typename Class , typename... Members>
auto ProcessLib::Reflection::reflectWithoutName ( Members Class::*... members)

Definition at line 92 of file ReflectionData.h.

93{
94 return std::tuple{makeReflectionData<Class>(members)...};
95}