LCOV - code coverage report
Current view: top level - src/Model/Solid/Finite - NeoHookeanPredeformed.H (source / functions) Coverage Total Hit
Test: coverage_merged.info Lines: 74.6 % 71 53
Test Date: 2025-02-27 04:17:48 Functions: 88.9 % 18 16

            Line data    Source code
       1              : #ifndef MODEL_SOLID_FINITE_NEOHOOKEANPREDEFORMED_H_
       2              : #define MODEL_SOLID_FINITE_NEOHOOKEANPREDEFORMED_H_
       3              : 
       4              : #include "IO/ParmParse.H"
       5              : #include "Model/Solid/Finite/NeoHookean.H"
       6              : 
       7              : namespace Model
       8              : {
       9              : namespace Solid
      10              : {
      11              : namespace Finite
      12              : {
      13              : class NeoHookeanPredeformed : public NeoHookean
      14              : {
      15              : public:
      16       280902 :     NeoHookeanPredeformed() {};
      17        31467 :     NeoHookeanPredeformed(NeoHookean base) : NeoHookean(base) {};
      18       384760 :     virtual ~NeoHookeanPredeformed() {};
      19              : 
      20          480 :     Set::Scalar W(const Set::Matrix& F) const override
      21              :     {
      22          480 :         return NeoHookean::W(F * F0.inverse());
      23              :     }
      24        71355 :     Set::Matrix DW(const Set::Matrix& F) const override
      25              :     {
      26       142710 :         return NeoHookean::DW(F * F0.inverse());
      27              :     }
      28        69415 :     Set::Matrix4<AMREX_SPACEDIM, Set::Sym::Major> DDW(const Set::Matrix& F) const override
      29              :     {
      30        69415 :         return NeoHookean::DDW(F * F0.inverse());
      31              :     }
      32            0 :     virtual void Print(std::ostream& out) const override
      33              :     {
      34            0 :         out << "mu = " << mu << " kappa = " << kappa << " F0 = " << F0;
      35            0 :     }
      36              : 
      37              : public:
      38              :     Set::Matrix F0 = Set::Matrix::Identity();
      39              : 
      40              : public:
      41        31339 :     static NeoHookeanPredeformed Zero()
      42              :     {
      43        31339 :         NeoHookeanPredeformed ret = NeoHookean::Zero();
      44        31339 :         ret.F0 = Set::Matrix::Zero();
      45        31339 :         return ret;
      46            0 :     }
      47           64 :     static NeoHookean Random()
      48              :     {
      49           64 :         NeoHookeanPredeformed ret = NeoHookean::Random();
      50           64 :         ret.F0 = Set::Matrix::Random();
      51          128 :         return ret;
      52           64 :     }
      53            4 :     static void Parse(NeoHookeanPredeformed& value, IO::ParmParse& pp)
      54              :     {
      55           12 :         pp.queryclass<NeoHookean>(value);
      56              :         
      57           20 :         if (pp.contains("eps0") && pp.contains("F0"))
      58              :         {
      59            0 :             Util::Abort("Cannot specify both F0 and eps0");
      60              :         }
      61            8 :         else if (pp.contains("F0")) 
      62              :         {
      63            0 :             Set::Matrix F0;
      64            0 :             pp_queryarr("F0", F0); // Large-deformation eigendeformation (Identity = no deformation)
      65            0 :             value.F0 = F0;
      66              :         }
      67            8 :         else if (pp.contains("eps0"))
      68              :         {
      69            4 :             Set::Matrix eps0;
      70           20 :             pp_queryarr("eps0",eps0); // Small-deformation eigendeformation (Zero = no deformation)
      71            4 :             value.F0 = eps0 + Set::Matrix::Identity(); 
      72              :         }
      73              :         else
      74              :         {
      75            0 :             value.F0 = Set::Matrix::Identity();
      76              :         }
      77           28 :         Util::Assert(INFO,TEST(fabs(value.F0.determinant()) > 1E-8 ),"F0 must be non-singular");
      78            4 :     }
      79              : 
      80              : #define OP_CLASS NeoHookeanPredeformed
      81              : #define OP_VARS X(kappa) X(mu) X(F0)
      82              : #include "Model/Solid/InClassOperators.H"
      83              : };
      84              : #include "Model/Solid/ExtClassOperators.H"
      85              : 
      86              : }
      87              : }
      88              : }
      89              : 
      90              : 
      91              : 
      92              : template<>
      93              : ALAMO_SINGLE_DEFINITION
      94           38 : int Set::Field<Model::Solid::Finite::NeoHookeanPredeformed>::NComp() const
      95              : {
      96           38 :     return 2 + AMREX_SPACEDIM * AMREX_SPACEDIM;
      97              : }
      98              : 
      99              : template<>
     100              : ALAMO_SINGLE_DEFINITION
     101           12 : std::string Set::Field<Model::Solid::Finite::NeoHookeanPredeformed>::Name(int i) const
     102              : {
     103           12 :     if (i == 0) return name + "_mu";
     104           10 :     if (i == 1) return name + "_kappa";
     105              : #if AMREX_SPACEDIM==2
     106            8 :     if (i == 2) return name + "_F0xx";
     107            6 :     if (i == 3) return name + "_F0xy";
     108            4 :     if (i == 4) return name + "_F0yx";
     109            2 :     if (i == 5) return name + "_F0yy";
     110              : #elif AMREX_SPACEDIM==3
     111              :     //Util::Abort(INFO, "Not implemented yet");
     112            0 :     if (i == 2) return name + "_F0xx";
     113            0 :     if (i == 3) return name + "_F0xy";
     114            0 :     if (i == 4) return name + "_F0yx";
     115            0 :     if (i == 5) return name + "_F0yy";
     116              : #endif
     117            0 :     return name;
     118              : }
     119              : 
     120              : template<>
     121              : ALAMO_SINGLE_DEFINITION
     122           22 : void Set::Field<Model::Solid::Finite::NeoHookeanPredeformed>::Copy(int a_lev, amrex::MultiFab& a_dst, int a_dstcomp, int a_nghost) const
     123              : {
     124          258 :     for (amrex::MFIter mfi(a_dst, amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
     125              :     {
     126          236 :         const amrex::Box& bx = mfi.growntilebox(amrex::IntVect(a_nghost));
     127          236 :         if (bx.ok())
     128              :         {
     129          236 :             amrex::Array4<const Model::Solid::Finite::NeoHookeanPredeformed> const& src = ((*this)[a_lev])->array(mfi);
     130          236 :             amrex::Array4<Set::Scalar> const& dst = a_dst.array(mfi);
     131          236 :             amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
     132              :             {
     133       124936 :                 dst(i, j, k, a_dstcomp + 0) = src(i, j, k).mu;
     134       124936 :                 dst(i, j, k, a_dstcomp + 1) = src(i, j, k).kappa;
     135              : #if AMREX_SPACEDIM==2
     136       124936 :                 dst(i, j, k, a_dstcomp + 2) = src(i, j, k).F0(0, 0);
     137       124936 :                 dst(i, j, k, a_dstcomp + 3) = src(i, j, k).F0(0, 1);
     138       124936 :                 dst(i, j, k, a_dstcomp + 4) = src(i, j, k).F0(1, 0);
     139       124936 :                 dst(i, j, k, a_dstcomp + 5) = src(i, j, k).F0(1, 1);
     140              : #elif AMREX_SPACEDIM==3
     141            0 :                 dst(i, j, k, a_dstcomp + 2) = src(i, j, k).F0(0, 0);
     142            0 :                 dst(i, j, k, a_dstcomp + 3) = src(i, j, k).F0(0, 1);
     143            0 :                 dst(i, j, k, a_dstcomp + 4) = src(i, j, k).F0(1, 0);
     144            0 :                 dst(i, j, k, a_dstcomp + 5) = src(i, j, k).F0(1, 1);
     145              :                 //Util::Abort(INFO, "Not implemented");
     146              : #endif
     147              : 
     148              :                 //dst(i, j, k, a_dstcomp + 0) = src(i, j, k).ddw(0, 0, 0, 0);
     149        62468 :             });
     150              :         }
     151           22 :     }
     152           22 : }
     153              : 
     154              : 
     155              : #endif
        

Generated by: LCOV version 2.0-1