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(), 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 401 of file ReflectionIPData.h.

403{
404 boost::mp11::tuple_for_each(
405 reflection_data,
406 [&callback]<typename Class, typename Accessor>(
407 ReflectionData<Class, Accessor> const& refl_data)
408 {
409 static_assert(std::is_same_v<Class, LocAsmIF>,
410 "The currently processed reflection data is not for "
411 "the given LocAsmIF but for a different class.");
412
413 using AccessorResultRef =
414 std::invoke_result_t<Accessor, Class const&>;
415 using AccessorResult = std::remove_cvref_t<AccessorResultRef>;
416
417 // AccessorResult must be a std::vector<SomeType, SomeAllocator>. We
418 // check that, now.
419 static_assert(boost::mp11::mp_is_list<AccessorResult>::
420 value); // std::vector<SomeType, SomeAllocator>
421 // is a list in the Boost MP11 sense
422 static_assert(
423 std::is_same_v<
424 AccessorResult,
425 boost::mp11::mp_rename<AccessorResult, std::vector>>,
426 "We expect a std::vector, here.");
427 // Now, we know that AccessorResult is std::vector<Member>. To be
428 // more specific, AccessorResult is a std::vector<IPData> and Member
429 // is IPData.
430 using Member = typename AccessorResult::value_type;
431
432 auto accessor_ip_data_vec_in_loc_asm =
433 [ip_data_vector_accessor =
434 refl_data.accessor](LocAsmIF const& loc_asm) -> auto const&
435 { return ip_data_vector_accessor(loc_asm); };
436
437 if constexpr (detail::is_reflectable<Member>)
438 {
439 detail::forEachReflectedFlattenedIPDataAccessor<Dim>(
440 callback,
441 detail::reflect(std::type_identity<Member>{}),
442 accessor_ip_data_vec_in_loc_asm);
443 }
444 else
445 {
446 static_assert(detail::is_raw_data<Member>::value,
447 "The current member is not reflectable, so we "
448 "expect it to be raw data.");
449
450 constexpr unsigned num_comp =
451 detail::NumberOfComponents<Member>::value;
452
453 callback(refl_data.name, num_comp,
454 detail::getFlattenedIPDataFromLocAsm<Dim>(
455 accessor_ip_data_vec_in_loc_asm));
456 }
457 });
458}

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

◆ 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::DarcyLawData< DisplacementDim >::reflect(), ProcessLib::ThermoRichardsMechanics::LiquidDensityData::reflect(), ProcessLib::ThermoRichardsMechanics::LiquidViscosityData::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}