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:
21
22 Crack() {};
23
24 AMREX_FORCE_INLINE
26 {
27 switch(w_type)
28 {
29 case WSQUARE: return (1.-c)*(1.-c);
30 case WMULTIWELL: return (1.-c)*(1.-c)*c*c;
31 case WMULTIWELL2: return (1.+c)*(1.+c)*(1.-c)*(1.-c);
32 case WPHI4C3: return 1. - 4.*c*c*c + 3.*c*c*c*c;
33
34 default: return (1.-c)*(1.-c);
35 }
36 }
37 AMREX_FORCE_INLINE
39 {
40 switch(g_type)
41 {
42 case GSQUARE: return c*c;
43 case GMULTIWELL: return (2.-c)*(2.-c)*c*c;
44 case GPHI4C3: return 4.*c*c*c - 3.*c*c*c*c;
45 case GSQUAREP: return std::pow(c,2.*p);
46 case GSQUAREPM: return std::pow(c,2.*(std::pow(p,m_d_exponent)));
47 case GCUBICM: return m_d_exponent*(c*c*c - c*c) + 3.*c*c - 2.*c*c*c;
48
49 default: return c*c;
50 }
51 }
52 AMREX_FORCE_INLINE
54 {
55 switch(w_type)
56 {
57 case WSQUARE: return -2.*(1.-c);
58 case WMULTIWELL: return 4.*c*c*c - 6.*c*c + 2.*c;
59 case WMULTIWELL2: return 4.*c*c*c - 4.*c;
60 case WPHI4C3: return 12.*(c-1.)*c*c;
61
62 default: return -2.*(1.-c);
63 }
64 }
65 AMREX_FORCE_INLINE
67 {
68 switch(g_type)
69 {
70 case GSQUARE: return 2.*c;
71 case GMULTIWELL: return 4.*c*c*c - 12.*c*c + 8.*c;
72 case GPHI4C3: return 12.*(1.-c)*c*c;
73 case GSQUAREP: return 2.*p*std::pow(c,2*p -1.);
74 case GSQUAREPM: return 2.*std::pow(p,m_d_exponent)*(std::pow(c, 2*std::pow(p,m_d_exponent)-1));
75 case GCUBICM: return m_d_exponent*(3.*c*c - 2.*c) + 6.*c - 6.*c*c;
76
77 default: return 2*c;
78 }
79 }
80
81 virtual Set::Scalar Gc(Set::Scalar theta) = 0;
82 virtual Set::Scalar DGc(Set::Scalar theta) = 0;
83 virtual Set::Scalar DDGc(Set::Scalar theta) = 0;
84 virtual Set::Scalar Zeta(Set::Scalar theta) = 0;
85 virtual Set::Scalar Mobility(Set::Scalar theta) = 0;
87
88 void ExportToFile(std::string filename, amrex::Real dTheta)
89 {
90 std::ofstream outFile;
91 outFile.open(filename);
92
93 for(amrex::Real theta=0; theta<2*pi; theta=theta+dTheta)
94 {
95 outFile << theta << " " << Gc(theta) << std::endl;
96 }
97 outFile.close();
98
99 }
100 void SetGType(const GType a_type)
101 {
102 g_type = a_type;
103 }
104
105 void SetWType(const WType a_type)
106 {
107 w_type = a_type;
108 }
109
111 {
112 m_d_exponent = m;
113 }
114
115protected:
116 static constexpr amrex::Real pi = 3.14159265359;
120};
121}
122}
123}
124
125#endif
virtual AMREX_FORCE_INLINE Set::Scalar Dw_phi(Set::Scalar c, Set::Scalar)
Definition Crack.H:53
virtual AMREX_FORCE_INLINE Set::Scalar Dg_phi(Set::Scalar c, Set::Scalar p=0.)
Definition Crack.H:66
void SetWType(const WType a_type)
Definition Crack.H:105
virtual Set::Scalar Gc(Set::Scalar theta)=0
static constexpr amrex::Real pi
Definition Crack.H:116
void SetDuctileExponent(const Set::Scalar m)
Definition Crack.H:110
void ExportToFile(std::string filename, amrex::Real dTheta)
Definition Crack.H:88
virtual Set::Scalar Mobility(Set::Scalar theta)=0
virtual AMREX_FORCE_INLINE Set::Scalar w_phi(Set::Scalar c, Set::Scalar)
Definition Crack.H:25
void SetGType(const GType a_type)
Definition Crack.H:100
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:38
virtual Set::Scalar Zeta(Set::Scalar theta)=0
amrex::Real Scalar
Definition Base.H:19