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