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