Alamo
Crack.H
Go to the documentation of this file.
1#ifndef MODEL_INTERFACE_CRACK_H
2#define MODEL_INTERFACE_CRACK_H
3
4#include <AMReX.H>
5#include <AMReX_AmrCore.H>
6
7#include <iostream>
8#include <fstream>
9
10namespace Model
11{
12namespace Interface
13{
14namespace Crack
15{
16class Crack
17{
18 public:
22
23 Crack() {};
24
25 // Geometric function involved in representing sharp crack as a band.
26 // Often this function is given in terms of a variable d = 1-c.
27 // Here we are implementing w as a function of c.
28 AMREX_FORCE_INLINE
30 {
31 switch(w_type)
32 {
33 case WSQUARE: return (1.-c)*(1.-c);
34 case WMULTIWELL: return (1.-c)*(1.-c)*c*c;
35 case WMULTIWELL2: return (1.+c)*(1.+c)*(1.-c)*(1.-c);
36 case WPHI4C3: return 1. - 4.*c*c*c + 3.*c*c*c*c;
37 case WU: return 2.0*(1.-c) - (1.-c)*(1.-c);
38
39 default: return (1.-c)*(1.-c);
40 }
41 }
42 AMREX_FORCE_INLINE
44 {
45 switch(g_type)
46 {
47 case GSQUARE: return c*c;
48 case GMULTIWELL: return (2.-c)*(2.-c)*c*c;
49 case GPHI4C3: return 4.*c*c*c - 3.*c*c*c*c;
50 case GSQUAREP: return std::pow(c,2.*p);
51 case GSQUAREPM: return std::pow(c,2.*(std::pow(p,m_d_exponent)));
52 case GCUBICM: return m_d_exponent*(c*c*c - c*c) + 3.*c*c - 2.*c*c*c;
53 case GWULINEAR: {
54 // this is for a linear softening curve for the CZM model
55 // Obtain from Wu 2018 CMAME
56 // w(c) = c^p / (c^p + Q(c))
57 // where, Q(c) = a1 (1-c) + a1 a2 (1-c)^2 + a1 a2 a3 (1-c)^3
58 // for linear law with p=2, a1 = 4 * l_w / (pi * b)
59 // a2 = -1/2, a3 = 0
60 Set::Scalar d = 1.0-c;
61 return (c*c) / (c*c + ((2.0 * m_pf_czm_a0 * d) - (m_pf_czm_a0 * d * d)));
62 // if (c < 1.e-5) c = 1.e-5;
63 // double phi = m_pf_czm_a0 * m_pf_czm_order* std::sqrt(w_phi(c,0.));
64 // phi *= std::sqrt(1 - std::pow(c, 2*m_pf_czm_order));
65 // phi /= std::pow(c, m_pf_czm_order+1);
66 // return 1.0 / (1.0 + phi);
67 }
68 default: return c*c;
69 }
70 }
71
72 // The derivative of the geometric function is often written in terms of w'(d).
73 // Here, we are taking w'(c). It's better to just take the derivative of the function
74 // we implemented in w_phi(c) with respect to c.
75 AMREX_FORCE_INLINE
77 {
78 switch(w_type)
79 {
80 case WSQUARE: return -2.*(1.-c);
81 case WMULTIWELL: return 4.*c*c*c - 6.*c*c + 2.*c;
82 case WMULTIWELL2: return 4.*c*c*c - 4.*c;
83 case WPHI4C3: return 12.*(c-1.)*c*c;
84 case WU: return -2.*c;
85
86 default: return -2.*(1.-c);
87 }
88 }
89 AMREX_FORCE_INLINE
91 {
92 switch(g_type)
93 {
94 case GSQUARE: return 2.*c;
95 case GMULTIWELL: return 4.*c*c*c - 12.*c*c + 8.*c;
96 case GPHI4C3: return 12.*(1.-c)*c*c;
97 case GSQUAREP: return 2.*p*std::pow(c,2*p -1.);
98 case GSQUAREPM: return 2.*std::pow(p,m_d_exponent)*(std::pow(c, 2*std::pow(p,m_d_exponent)-1));
99 case GCUBICM: return m_d_exponent*(3.*c*c - 2.*c) + 6.*c - 6.*c*c;
100 case GWULINEAR: {
101 // Derivative of c^2 / (c^2 + Q(c))
102 // 2c / (c^2 + Q(c)) - c^2 (2c + Q'(c)) / (c^2+Q(c))^2
103 // ( 2c (c^2 + Q(c)) - c^2 (2c + Q'(c)) ) / (c^2 + Q(c))^2
104 // ( 2c Q(c) - c^2 Q'(c) ) / (c^2 + Q(c))^2
105 // Q(d) = a1 d + a1 a2 d^2 + a1 a2 a3 d^3
106 // In this case, a = 2*a0, a2 = -0.5, a3 = 0
107 // Q(d) = 2 a0 d - a0 d^2
108 // Q'(d) = 2 a0 - 2 a0 d
109 // Q'(c) - -Q'(d) = -2 a0 + 2 a0 d
110 Set::Scalar d = 1.0 -c;
111 Set::Scalar dQ_c = (-2.0*m_pf_czm_a0) + (2.0*m_pf_czm_a0*d);
112 Set::Scalar Q_c = (2.0*m_pf_czm_a0*d) - (m_pf_czm_a0*d*d);
113 return (2.0*c*Q_c - c*c*dQ_c) / ((c*c + Q_c)*(c*c + Q_c));
114 }
115
116 default: return 2*c;
117 }
118 }
119
120 AMREX_FORCE_INLINE
122 {
123 switch (g2_type)
124 {
125 case G2WULINEAR: {
126 if (c < 1.e-5) c = 1.e-5;
127 // Set::Scalar mu = m_pf_czm_a0 * w_phi(c,0.) / (std::pow(c, 2*m_pf_czm_order));
128 Set::Scalar Dmu = m_pf_czm_a0 * ( (2.*m_pf_czm_order*w_phi(c,0.)) + (c * -1. * Dw_phi(c,0.)) ) / (std::pow(c, 1 + 2*m_pf_czm_order));
129 return Dmu * g_phi(c,0.) * g_phi(c,0.);
130 }
131
132 default: Util::Abort(INFO, "Dissipation function type must be specified");
133 }
134 return NAN;
135 }
136
137 virtual Set::Scalar Gc(Set::Scalar theta) = 0;
138 virtual Set::Scalar DGc(Set::Scalar theta) = 0;
139 virtual Set::Scalar DDGc(Set::Scalar theta) = 0;
140 virtual Set::Scalar Zeta(Set::Scalar theta) = 0;
141 virtual Set::Scalar Mobility(Set::Scalar theta) = 0;
143
144 void ExportToFile(std::string filename, amrex::Real dTheta)
145 {
146 std::ofstream outFile;
147 outFile.open(filename);
148
149 for(amrex::Real theta=0; theta<2*pi; theta=theta+dTheta)
150 {
151 outFile << theta << " " << Gc(theta) << std::endl;
152 }
153 outFile.close();
154
155 }
156 void SetGType(const GType a_type)
157 {
158 g_type = a_type;
159 }
160
161 void SetWType(const WType a_type)
162 {
163 w_type = a_type;
164 }
165
166 void SetG2Type (const G2Type /*a_type*/)
167 {
168
169 }
170
172 {
173 m_d_exponent = m;
174 }
175
176 void SetPFCZMConstants(const Set::Scalar a_pf_czm_order, const Set::Scalar a_pf_czm_a0)
177 {
178 m_pf_czm_order = a_pf_czm_order;
179 m_pf_czm_a0 = a_pf_czm_a0;
180 }
181
182protected:
183 static constexpr Set::Scalar pi = 3.14159265359;
190};
191}
192}
193}
194
195#endif
#define INFO
Definition Util.H:21
void SetPFCZMConstants(const Set::Scalar a_pf_czm_order, const Set::Scalar a_pf_czm_a0)
Definition Crack.H:176
virtual AMREX_FORCE_INLINE Set::Scalar Dw_phi(Set::Scalar c, Set::Scalar)
Definition Crack.H:76
virtual AMREX_FORCE_INLINE Set::Scalar Dg_phi(Set::Scalar c, Set::Scalar p=0.)
Definition Crack.H:90
void SetWType(const WType a_type)
Definition Crack.H:161
virtual Set::Scalar Gc(Set::Scalar theta)=0
void SetDuctileExponent(const Set::Scalar m)
Definition Crack.H:171
virtual AMREX_FORCE_INLINE Set::Scalar Dg2_phi(Set::Scalar c)
Definition Crack.H:121
void ExportToFile(std::string filename, amrex::Real dTheta)
Definition Crack.H:144
static constexpr Set::Scalar pi
Definition Crack.H:183
virtual Set::Scalar Mobility(Set::Scalar theta)=0
virtual AMREX_FORCE_INLINE Set::Scalar w_phi(Set::Scalar c, Set::Scalar)
Definition Crack.H:29
void SetGType(const GType a_type)
Definition Crack.H:156
virtual Set::Scalar DDGc(Set::Scalar theta)=0
virtual Set::Scalar DrivingForceThreshold(Set::Scalar theta)=0
virtual Set::Scalar DGc(Set::Scalar theta)=0
virtual AMREX_FORCE_INLINE Set::Scalar g_phi(Set::Scalar c, Set::Scalar p=0.)
Definition Crack.H:43
void SetG2Type(const G2Type)
Definition Crack.H:166
virtual Set::Scalar Zeta(Set::Scalar theta)=0
amrex::Real Scalar
Definition Base.H:18
void Abort(const char *msg)
Definition Util.cpp:225