Peano
Elastic.py
Go to the documentation of this file.
1 
2 
3 def initial():
4  return """
5 
6  //stresses
7  Q[3+0] = 0.0; //xx
8  Q[3+1] = 0.0; //yy
9  Q[3+2] = 0.0; //zz
10  Q[3+3] = 0.0; //xy
11  Q[3+4] = 0.0; //xz
12  Q[3+5] = 0.0; //yz
13 
14  // LOH1
15  double layerWidth = 1.0;
16  bool upperLayer = x(1) <= layerWidth;
17 
18  // HHS
19  // bool upperLayer = false;
20 
21  Q[ 0 + 0 ] = 0.0;
22  Q[ 0 + 1 ] = Q[ 0 + 0 ];
23  Q[ 0 + 2 ] = Q[ 0 + 1 ];
24 
25  //auxiliary variables
26  Q[9] = upperLayer ? 2.6 : 2.7;
27  Q[10] = upperLayer ? 4.0 : 6.0;
28  Q[11] = upperLayer ? 2.0 : 3.464;
29 """
30 
31 
32 def boundary():
33  return """
34  switch(normal){
35  case 0:
36  Qoutside[3+0] = 0.; //xx
37  Qoutside[3+3] = 0.; //xy
38  Qoutside[3+4] = 0.; //xz
39  Qoutside[0+0] = 0.;
40  Qoutside[0+1] = 0.;
41  Qoutside[0+2] = 0.;
42  break;
43  case 1:
44  // free surface boundary condition
45  Qoutside[3+1] = -Qinside[3+1]; //yy
46  Qoutside[3+3] = -Qinside[3+3]; //xy
47  Qoutside[3+5] = -Qinside[3+5]; //yz
48  Qoutside[0+0] = Qinside[0+0];
49  Qoutside[0+1] = Qinside[0+1];
50  Qoutside[0+2] = Qinside[0+2];
51  break;
52  case 2:
53  Qoutside[3+2] = 0.; //zz
54  Qoutside[3+4] = 0.; //xz
55  Qoutside[3+5] = 0.; //yz
56  Qoutside[0+0] = 0.;
57  Qoutside[0+1] = 0.;
58  Qoutside[0+2] = 0.;
59  }
60 
61  //auxiliary variables
62  Qoutside[9] = Qinside[9];
63  Qoutside[10] = Qinside[10];
64  Qoutside[11] = Qinside[11];
65 
66 """
67 
68 def eigenvalue():
69  return """
70  return std::max(std::abs(Q[10]), std::abs(Q[11]));
71 """
72 
73 def flux():
74  return """
75  //Lamé parameters
76  auto mu(Q[9] * Q[11] * Q[11]); //rho*cs^2
77  auto lambda(Q[9] * Q[10] * Q[10] - 2.0 * mu); //rho*cp^2 - 2 mu
78  auto neg_irho(-1.0/Q[9]);
79 
80  switch(normal) {
81  case 0:
82  F[0+0] = neg_irho*Q[3+0]; //sigma_xx
83  F[0+1] = neg_irho*Q[3+3]; //sigma_xy
84  F[0+2] = neg_irho*Q[3+4]; //sigma_xz
85  F[3+0] = -(lambda + 2*mu) * Q[0+0]; //xx
86  F[3+1] = -lambda * Q[0+0]; //yy
87  F[3+2] = -lambda * Q[0+0]; //zz
88  F[3+3] = -mu * Q[0+1]; //xy
89  F[3+4] = -mu * Q[0+2]; //xz
90  F[3+5] = 0.0; //yz
91  break;
92  case 1:
93  F[0+0] = neg_irho*Q[3+3]; //sigma_xy
94  F[0+1] = neg_irho*Q[3+1]; //sigma_yy
95  F[0+2] = neg_irho*Q[3+5]; //sigma_yz
96  F[3+0] = -lambda * Q[0+1]; //xx
97  F[3+1] = -(lambda + 2*mu) * Q[0+1]; //yy
98  F[3+2] = - lambda * Q[0+1]; //zz
99  F[3+3] = -mu * Q[0+0]; //xy
100  F[3+4] = 0.0; //xz
101  F[3+5] = -mu * Q[0+2]; //yz
102  break;
103  case 2:
104  F[0+0] = neg_irho*Q[3+4]; //sigma_xz
105  F[0+1] = neg_irho*Q[3+5]; //sigma_yz
106  F[0+2] = neg_irho*Q[3+2]; //sigma_zz
107  F[3+0] = -lambda * Q[0+2]; //xx
108  F[3+1] = -lambda * Q[0+2]; //yy
109  F[3+2] = -(lambda + 2*mu) * Q[0+2]; //zz
110  F[3+3] = 0.0; //xy
111  F[3+4] = -mu * Q[0+0]; //xz
112  F[3+5] = -mu * Q[0+1]; //yz
113  }
114 """
115 
117  return """
118  auto result = ::exahype2::RefinementCommand::Keep;
119 
120  tarch::la::Vector<DIMENSIONS, double> sourceLocation = {
121  pointSourceLocation[0][0],
122  pointSourceLocation[0][1],
123  #if DIMENSIONS == 3
124  pointSourceLocation[0][2]
125  #endif
126  };
127 
128  if (tarch::la::equals(t, 0.0)) {
129  if (tarch::la::norm2(x - sourceLocation) < 1.0) {
130  result = ::exahype2::RefinementCommand::Refine;
131  }
132  }
133 
134  return result;
135 """
136 
138  return """
139  for (int i = 0; i < NumberOfUnknowns; i++) {
140  forceVector[i] = 0.0;
141  }
142 
143  constexpr double t0 = 0.1;
144  constexpr double M0 = 10.;//1000.0;
145  double f = M0 * t / (t0 * t0) * std::exp(-t / t0);
146 
147  forceVector[3+4] = f; //sigma_xy
148 """
150  return """
151  location[0][0] = 0.0;
152  location[0][1] = 2.0;
153  location[0][2] = 0.0;
154 """
155 
157  return """
158  Numerics::riemannSolver<VariableShortcuts{{SOLVER_NAME}}, {{CORRECTOR_COMPUTATION_PRECISION}}, Order+1, NumberOfUnknowns, NumberOfUnknowns+NumberOfAuxiliaryVariables, 1>(
159  FL, FR, QL, QR, dt, direction, isBoundaryFace, faceIndex
160  );
161 """
def point_source()
Definition: Elastic.py:137
def flux()
Definition: Elastic.py:73
def refinement_criterion()
Definition: Elastic.py:116
def initial()
Definition: Elastic.py:3
def init_point_source()
Definition: Elastic.py:149
def eigenvalue()
Definition: Elastic.py:68
def boundary()
Definition: Elastic.py:32
def riemann_solver()
Definition: Elastic.py:156