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
7namespace Model
8{
9namespace Solid
10{
11namespace Finite
12{
14{
15public:
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
37public:
38 Set::Matrix F0 = Set::Matrix::Identity();
39
40public:
42 {
44 ret.F0 = Set::Matrix::Zero();
45 return ret;
46 }
48 {
50 ret.F0 = Set::Matrix::Random();
51 return ret;
52 }
53 static void Parse(NeoHookeanPredeformed& value, IO::ParmParse& pp)
54 {
55 pp.queryclass<NeoHookean>(value);
56
57 if (pp.contains("eps0") && pp.contains("F0"))
58 {
59 Util::Abort("Cannot specify both F0 and eps0");
60 }
61 else if (pp.contains("F0"))
62 {
64 pp_queryarr("F0", F0); // Large-deformation eigendeformation (Identity = no deformation)
65 value.F0 = F0;
66 }
67 else if (pp.contains("eps0"))
68 {
69 Set::Matrix eps0;
70 pp_queryarr("eps0",eps0); // Small-deformation eigendeformation (Zero = no deformation)
71 value.F0 = eps0 + Set::Matrix::Identity();
72 }
73 else
74 {
75 value.F0 = Set::Matrix::Identity();
76 }
77 Util::Assert(INFO,TEST(fabs(value.F0.determinant()) > 1E-8 ),"F0 must be non-singular");
78 }
79
80#define OP_CLASS NeoHookeanPredeformed
81#define OP_VARS X(kappa) X(mu) X(F0)
83};
85
86}
87}
88}
89
90
91
92template<>
98
99template<>
102{
103 if (i == 0) return name + "_mu";
104 if (i == 1) return name + "_kappa";
105#if AMREX_SPACEDIM==2
106 if (i == 2) return name + "_F0xx";
107 if (i == 3) return name + "_F0xy";
108 if (i == 4) return name + "_F0yx";
109 if (i == 5) return name + "_F0yy";
110#elif AMREX_SPACEDIM==3
111 //Util::Abort(INFO, "Not implemented yet");
112 if (i == 2) return name + "_F0xx";
113 if (i == 3) return name + "_F0xy";
114 if (i == 4) return name + "_F0yx";
115 if (i == 5) return name + "_F0yy";
116#endif
117 return name;
118}
119
120template<>
123{
124 for (amrex::MFIter mfi(a_dst, amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
125 {
126 const amrex::Box& bx = mfi.growntilebox(amrex::IntVect(a_nghost));
127 if (bx.ok())
128 {
129 amrex::Array4<const Model::Solid::Finite::NeoHookeanPredeformed> const& src = ((*this)[a_lev])->array(mfi);
130 amrex::Array4<Set::Scalar> const& dst = a_dst.array(mfi);
131 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
132 {
133 dst(i, j, k, a_dstcomp + 0) = src(i, j, k).mu;
134 dst(i, j, k, a_dstcomp + 1) = src(i, j, k).kappa;
135#if AMREX_SPACEDIM==2
136 dst(i, j, k, a_dstcomp + 2) = src(i, j, k).F0(0, 0);
137 dst(i, j, k, a_dstcomp + 3) = src(i, j, k).F0(0, 1);
138 dst(i, j, k, a_dstcomp + 4) = src(i, j, k).F0(1, 0);
139 dst(i, j, k, a_dstcomp + 5) = src(i, j, k).F0(1, 1);
140#elif AMREX_SPACEDIM==3
141 dst(i, j, k, a_dstcomp + 2) = src(i, j, k).F0(0, 0);
142 dst(i, j, k, a_dstcomp + 3) = src(i, j, k).F0(0, 1);
143 dst(i, j, k, a_dstcomp + 4) = src(i, j, k).F0(1, 0);
144 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 });
150 }
151 }
152}
153
154
155#endif
#define pp_queryarr(...)
Definition ParmParse.H:103
#define TEST(x)
Definition Util.H:21
#define ALAMO_SINGLE_DEFINITION
Definition Util.H:25
#define INFO
Definition Util.H:20
bool contains(std::string name)
Definition ParmParse.H:154
void queryclass(std::string name, T *value, std::string file="", std::string func="", int line=-1)
Definition ParmParse.H:604
virtual void Print(std::ostream &out) const override
Set::Scalar W(const Set::Matrix &F) const override
Set::Matrix DW(const Set::Matrix &F) const override
Set::Matrix4< AMREX_SPACEDIM, Set::Sym::Major > DDW(const Set::Matrix &F) const override
static void Parse(NeoHookeanPredeformed &value, IO::ParmParse &pp)
Set::Matrix4< AMREX_SPACEDIM, Set::Sym::Major > DDW(const Set::Matrix &a_F) const override
Definition NeoHookean.H:71
Set::Matrix DW(const Set::Matrix &a_F) const override
Definition NeoHookean.H:39
Set::Scalar W(const Set::Matrix &a_F) const override
Definition NeoHookean.H:20
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:19
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
Definition Base.H:20
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, AMREX_SPACEDIM > Matrix
Definition Base.H:23
void Abort(const char *msg)
Definition Util.cpp:170
AMREX_FORCE_INLINE void Assert(std::string file, std::string func, int line, std::string smt, bool pass, Args const &... args)
Definition Util.H:70