GEOS-DEV / GEOS

GEOS Simulation Framework
GNU Lesser General Public License v2.1
210 stars 84 forks source link

refactor: Add component selector for fluid models #3213

Closed dkachuma closed 2 months ago

dkachuma commented 3 months ago

In IsothermalCompositionalMultiphaseFVMKernels.hpp:2127-2157 and ThermalCompositionalMultiphaseFVMKernels.hpp:1397-1432, we have calls of the form

constitutive::constitutiveUpdatePassThru( fluidBase, [&]( auto & fluid )
{
  using FluidType = TYPEOFREF( fluid );
  // ...
  isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComps, [&]( auto NC )
  {
    integer constexpr NUM_COMP = NC();

    // ...
    using kernelType = DirichletFaceBasedAssemblyKernel< NUM_COMP, NUM_DOF, typename FluidType::KernelWrapper >;

    // ...
  } );
} );

This expands over all available fluid types and within each expansion, we further expand over all possible numbers of components. The possible number of components is currently set to be from 1 to 5. However, not all fluid types support all these component numbers. For example the CO2BrineFluid models support only 2 components. As such we end up here with unnecessary expansions. The end result of all these expansions is to make the CompositionalMultiphaseFVM class extremely large to compile especially for CUDA builds. This is so bad that some of the fluid models have been commented out in MultiFluidSelector.hpp:39-58 just to be able to compile on GHA.

This PR tries to reduce the number of combinations by explicitly listing, for each fluid type, the number of components that it allows. The expansion is a combination of the fluid model type and number of components. Furthermore, not all fluid models support thermal simulations. So the thermal kernels are expanded only over those models that support thermal simulations.

Some other changes

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 71.68142% with 32 lines in your changes missing coverage. Please review.

Project coverage is 55.83%. Comparing base (18db014) to head (cb97a03).

Files Patch % Lines
...dFlow/ThermalCompositionalMultiphaseFVMKernels.hpp 0.00% 17 Missing :warning:
...ow/IsothermalCompositionalMultiphaseFVMKernels.hpp 0.00% 14 Missing :warning:
...uid/compositional/CompositionalMultiphaseFluid.hpp 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #3213 +/- ## =========================================== + Coverage 55.71% 55.83% +0.11% =========================================== Files 1041 1042 +1 Lines 88575 88652 +77 =========================================== + Hits 49353 49501 +148 + Misses 39222 39151 -71 ```

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