ikarus-project / ikarus

Ikarus is a C++-based library that uses DUNE modules to solve partial differential equations with the finite element method and more.
https://ikarus-project.github.io/
Other
5 stars 3 forks source link

Proof of Concept: Add FE Settings using Reflection #255

Closed henrij22 closed 2 months ago

henrij22 commented 6 months ago

Note: Merge #253 first and rebase before taking a look at this

Using https://github.com/veselink1/refl-cpp to add reflection

The general idea is to be able to reflect about the members of a SettingsContainer struct, so that we don't have to keep track of settings keys.

The only thing that has to be kept in sync are the names of the settings with the member names of the struct. Reading the settings into code can be done as follows:

  auto loadSettings() {
    for_each(settingsReflection.members, [&](auto member) {
      if (member.is_writable)
        parseParameter(static_cast<std::string>(member.name), member.get(settings_));
    });
  }

The settingsReflection is a reflection about the type of a SettingsContainer and is defined

  static constexpr auto settingsReflection = refl::reflect<Container>();

So this is now highly generalized and can be used with different containers containing different settings or parameters (e.g. material parameters for different material laws)

codecov[bot] commented 6 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (f5a7c79) 92.55% compared to head (3127203) 92.73%.

Files Patch % Lines
...finiteelements/mechanics/enhancedassumedstrains.hh 95.65% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #255 +/- ## ========================================== + Coverage 92.55% 92.73% +0.17% ========================================== Files 56 59 +3 Lines 1975 2023 +48 ========================================== + Hits 1828 1876 +48 Misses 147 147 ``` | [Flag](https://app.codecov.io/gh/ikarus-project/ikarus/pull/255/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ikarus-project) | Coverage Δ | | |---|---|---| | [tests](https://app.codecov.io/gh/ikarus-project/ikarus/pull/255/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ikarus-project) | `92.73% <98.63%> (+0.17%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ikarus-project#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

henrij22 commented 2 months ago

closed as not viable