LCOV - code coverage report
Current view: top level - src/IC - IC.H (source / functions) Coverage Total Hit
Test: coverage_merged.info Lines: 76.5 % 17 13
Test Date: 2025-02-27 04:17:48 Functions: 50.0 % 16 8

            Line data    Source code
       1              : //
       2              : // Initial condition (IC) objects are used to set fields to specified values,
       3              : // through mathematical expressions, images, etc.
       4              : // They are often used as initial conditions, but may be used generally to
       5              : // incorporate static or time-dependent values.
       6              : // All IC methods inherit from the base IC class, and are implemented by
       7              : // overriding the "Add" method.
       8              : // (Initialize uses Add after setting the field to zero.)
       9              : //
      10              : #ifndef IC_IC_H_
      11              : #define IC_IC_H_
      12              : 
      13              : #include <AMReX.H>
      14              : #include <AMReX_MultiFab.H>
      15              : #include "Util/Util.H"
      16              : #include "Set/Set.H"
      17              : 
      18              : namespace IC
      19              : {
      20              : /// Pure abstract IC object from which all other IC objects inherit.
      21              : template<class T = Set::Scalar>
      22              : class IC
      23              : {
      24              : public:
      25          136 :     IC (amrex::Vector<amrex::Geometry> &_geom)
      26          136 :         : geom(_geom) {} ;
      27           80 :     virtual ~IC() {}
      28              : 
      29              :     virtual void Add(const int &lev, Set::Field<T> &field, Set::Scalar time) = 0;
      30            0 :     void Add(const int &lev, Set::Field<T> &field)
      31              :     {
      32            0 :         Add(lev,field,0.0);
      33            0 :     }
      34              : 
      35              : 
      36              :     // SFINAE solution: this is how we initialize if the type is arithmetic and has a  
      37              :     // "0" value
      38              :     template <typename U = T, typename std::enable_if_t<std::is_arithmetic_v<U>, int> = 0>
      39         1410 :     void Initialize(const int &a_lev,
      40              :                     Set::Field<T> &a_field,
      41              :                     Set::Scalar a_time = 0.0)
      42              :     {
      43         9870 :         Util::Assert(INFO,TEST(a_lev < a_field.size())," a_lev=",a_lev," size=",a_field.size());
      44         1410 :         a_field[a_lev]->setVal(0.0);
      45         1410 :         Add(a_lev,a_field,a_time);
      46         1409 :     }
      47              : 
      48              :     // SFINAE solution: we initialize using "Zero" if it is a class type.
      49              :     template <typename U = T, typename std::enable_if_t<!std::is_arithmetic_v<U>, int> = 0>
      50           22 :     void Initialize(const int &a_lev,
      51              :                     Set::Field<T> &a_field,
      52              :                     Set::Scalar a_time = 0.0)
      53              :     {
      54          154 :         Util::Assert(INFO,TEST(a_lev < a_field.size())," a_lev=",a_lev," size=",a_field.size());
      55           22 :         a_field[a_lev]->setVal(T::Zero());
      56           22 :         Add(a_lev,a_field,a_time);
      57           22 :     }
      58              : 
      59            0 :     virtual void SetComp(int a_comp) final {comp = a_comp;}
      60              : protected:
      61              :     amrex::Vector<amrex::Geometry> &geom;
      62              :     int comp = 0;
      63              : };
      64              : }
      65              : #endif
        

Generated by: LCOV version 2.0-1