Line data Source code
1 : //
2 : // This class extends :ref:`Model::Solid::Linear::Cubic`
3 : // by adding an eigenstrain :math:`\mathbf{F}_0`.
4 : //
5 :
6 : #ifndef MODEL_SOLID_AFFINE_CUBIC_H_
7 : #define MODEL_SOLID_AFFINE_CUBIC_H_
8 :
9 : #include "Model/Solid/Solid.H"
10 : #include "Model/Solid/Linear/Cubic.H"
11 : #include "IO/ParmParse.H"
12 :
13 : namespace Model
14 : {
15 : namespace Solid
16 : {
17 : namespace Affine
18 : {
19 : class Cubic : public Linear::Cubic
20 : {
21 : public:
22 : static constexpr const char *name = "cubic";
23 :
24 48 : Cubic() = default;
25 : //Cubic(Linear::Cubic base) : Linear::Cubic(base) {};
26 : ~Cubic() = default;
27 :
28 : void
29 : Define(Set::Scalar C11, Set::Scalar C12, Set::Scalar C44, Set::Scalar phi1, Set::Scalar Phi, Set::Scalar phi2,Set::Matrix a_F0=Set::Matrix::Zero())
30 : {
31 : Linear::Cubic::Define(C11,C12,C44,phi1,Phi,phi2);
32 : F0 = a_F0;
33 : }
34 : void
35 : Define(Set::Scalar C11, Set::Scalar C12, Set::Scalar C44, Eigen::Matrix3d R, Set::Matrix a_F0=Set::Matrix::Zero())
36 : {
37 : Linear::Cubic::Define(C11,C12,C44,R);
38 : F0 = a_F0;
39 : }
40 260 : Set::Scalar W(const Set::Matrix & gradu) const
41 : {
42 260 : return Linear::Cubic::W(gradu - F0);
43 : }
44 1960 : Set::Matrix DW(const Set::Matrix & gradu) const
45 : {
46 3920 : return Linear::Cubic::DW(gradu - F0);
47 : }
48 20 : Set::Matrix4<AMREX_SPACEDIM,Set::Sym::MajorMinor> DDW(const Set::Matrix & gradu) const
49 : {
50 20 : return Linear::Cubic::DDW(gradu - F0);
51 : }
52 : void Print(std::ostream &out) const
53 : {
54 : out << ddw;
55 : }
56 : AMREX_FORCE_INLINE
57 : void SetF0 (Set::Matrix &a_F0) {F0 = a_F0;}
58 :
59 : public:
60 : Set::Matrix F0 = Set::Matrix::Zero();
61 : static const KinematicVariable kinvar = KinematicVariable::gradu;
62 :
63 2 : static Cubic Zero()
64 : {
65 2 : Cubic ret;
66 2 : ret.ddw = Linear::Cubic::Zero().ddw;
67 2 : ret.F0 = Set::Matrix::Zero();
68 2 : return ret;
69 : }
70 42 : static Cubic Random()
71 : {
72 42 : return Random(Util::Random(), Util::Random(), Util::Random());
73 : }
74 42 : static Cubic Random(Set::Scalar C11, Set::Scalar C12, Set::Scalar C44)
75 : {
76 42 : Cubic ret;
77 42 : ret.ddw = Linear::Cubic::Random(C11,C12,C44).ddw;
78 42 : ret.F0 = Set::Matrix::Random();
79 42 : return ret;
80 : }
81 : // This class extends :ref:`Model::Solid::Linear::Cubic` by adding
82 : // an eigenstrain. (See the Linear::Cubic class for more inputs for this model)
83 0 : static void Parse(Cubic & value, IO::ParmParse & pp)
84 : {
85 0 : pp.queryclass<Linear::Cubic>(value);
86 0 : if (pp.contains("F0"))
87 0 : pp_queryarr("F0",value.F0); // Eigenstrain
88 0 : }
89 :
90 : AMREX_FORCE_INLINE
91 : static Cubic Combine(const std::vector<Cubic> &models, const std::vector<Set::Scalar> &eta, int order)
92 : {
93 0 : Cubic ret;
94 0 : ret.ddw = Set::Matrix4<AMREX_SPACEDIM,Set::Sym::MajorMinor>::Zero();
95 0 : ret.F0 = Set::Matrix::Zero();
96 0 : if (order == 1)
97 : {
98 0 : Set::Scalar etasum = 0.;
99 0 : for (unsigned int n = 0 ; n < models.size(); n++) etasum += eta[n];
100 0 : for (unsigned int n = 0 ; n < models.size(); n++)
101 : {
102 0 : ret.ddw += models[n].ddw * (eta[n] / etasum);
103 0 : ret.F0 += models[n].F0 * (eta[n] / etasum);
104 : }
105 0 : return ret;
106 : }
107 0 : else if (order == 2)
108 : {
109 0 : Set::Scalar etasum = 0.;
110 0 : for (unsigned int n = 0 ; n < models.size(); n++) etasum += eta[n]*eta[n];
111 0 : for (unsigned int n = 0 ; n < models.size(); n++)
112 : {
113 0 : ret.ddw += models[n].ddw * (eta[n]*eta[n] / etasum);
114 0 : ret.F0 += models[n].F0 * (eta[n]*eta[n] / etasum);
115 : }
116 0 : return ret;
117 : }
118 :
119 0 : Util::Exception(INFO,"invalid value used for order, ",order);
120 0 : return ret; // should never happen
121 : }
122 :
123 : #define OP_CLASS Cubic
124 : #define OP_VARS X(ddw) X(F0)
125 : #include "Model/Solid/InClassOperators.H"
126 : };
127 : #include "Model/Solid/ExtClassOperators.H"
128 :
129 : }
130 : }
131 : }
132 :
133 : template<>
134 : ALAMO_SINGLE_DEFINITION
135 0 : int Set::Field<Model::Solid::Affine::Cubic>::NComp() const
136 : {
137 0 : return 1;
138 : }
139 :
140 : template<>
141 : ALAMO_SINGLE_DEFINITION
142 0 : std::string Set::Field<Model::Solid::Affine::Cubic>::Name(int i) const
143 : {
144 0 : if (i==0) return name + ".Cxxxx";
145 0 : return name;
146 : }
147 :
148 : template<>
149 : ALAMO_SINGLE_DEFINITION
150 0 : void Set::Field<Model::Solid::Affine::Cubic>::Copy(int a_lev, amrex::MultiFab &a_dst, int a_dstcomp, int a_nghost) const
151 : {
152 0 : for (amrex::MFIter mfi(a_dst, amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
153 : {
154 0 : const amrex::Box& bx = mfi.growntilebox(amrex::IntVect(a_nghost));
155 0 : if (bx.ok())
156 : {
157 0 : amrex::Array4<const Model::Solid::Affine::Cubic> const & src = ((*this)[a_lev])->array(mfi);
158 0 : amrex::Array4<Set::Scalar> const & dst = a_dst.array(mfi);
159 0 : amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
160 : {
161 0 : dst(i,j,k,a_dstcomp + 0) = src(i,j,k).ddw(0,0,0,0);
162 0 : });
163 : }
164 0 : }
165 0 : }
166 :
167 : #endif
168 :
|