1 def initial(pointwise_initial_conditions):
3 std::fill_n(Q, (NumberOfAuxiliaryVariables + NumberOfUnknowns) * (Order + 1) * (Order + 1) * (Order + 1), 0);
5 context->initUnknownsPatch(Q, x, h, 0.0, 0.0,
7 const {{SOLUTION_STORAGE_PRECISION}}* const x,
8 const tarch::la::Vector<DIMENSIONS,double>& center,
11 {{SOLUTION_STORAGE_PRECISION}}* Q
12 ) -> void { """ + pointwise_initial_conditions +
"""
19 auto sigma_xx = Q[Shortcuts::sigma + 0];
20 auto sigma_yy = Q[Shortcuts::sigma + 1];
21 auto sigma_zz = Q[Shortcuts::sigma + 2];
22 auto sigma_xy = Q[Shortcuts::sigma + 3];
23 auto sigma_xz = Q[Shortcuts::sigma + 4];
24 auto sigma_yz = Q[Shortcuts::sigma + 5];
26 auto jacobian = Q[Shortcuts::jacobian];
28 std::fill_n(F, NumberOfUnknowns, 0.);
32 auto q_x = Q[Shortcuts::metric_derivative + 0];
33 auto q_y = Q[Shortcuts::metric_derivative + 1];
34 auto q_z = Q[Shortcuts::metric_derivative + 2];
35 F[0] = -jacobian * (q_x * sigma_xx + q_y * sigma_xy + q_z * sigma_xz);
36 F[1] = -jacobian * (q_x * sigma_xy + q_y * sigma_yy + q_z * sigma_yz);
37 F[2] = -jacobian * (q_x * sigma_xz + q_y * sigma_yz + q_z * sigma_zz);
40 auto r_x = Q[Shortcuts::metric_derivative + 3];
41 auto r_y = Q[Shortcuts::metric_derivative + 4];
42 auto r_z = Q[Shortcuts::metric_derivative + 5];
43 F[0] = -jacobian * (r_x * sigma_xx + r_y * sigma_xy + r_z * sigma_xz);
44 F[1] = -jacobian * (r_x * sigma_xy + r_y * sigma_yy + r_z * sigma_yz);
45 F[2] = -jacobian * (r_x * sigma_xz + r_y * sigma_yz + r_z * sigma_zz);
48 auto s_x = Q[Shortcuts::metric_derivative + 6];
49 auto s_y = Q[Shortcuts::metric_derivative + 7];
50 auto s_z = Q[Shortcuts::metric_derivative + 8];
51 F[0] = -jacobian * (s_x * sigma_xx + s_y * sigma_xy + s_z * sigma_xz);
52 F[1] = -jacobian * (s_x * sigma_xy + s_y * sigma_yy + s_z * sigma_yz);
53 F[2] = -jacobian * (s_x * sigma_xz + s_y * sigma_yz + s_z * sigma_zz);
60 auto rho = Q[Shortcuts::rho];
61 auto cp = Q[Shortcuts::cp];
62 auto cs = Q[Shortcuts::cs];
63 auto jacobian = Q[Shortcuts::jacobian];
64 auto mu = rho * cs * cs;
65 auto lambda = rho * cp * cp - 2 * mu;
66 auto rho_inv = 1.0 / (rho * jacobian);
68 std::fill_n(BTimesDeltaQ, NumberOfUnknowns, 0.0);
72 auto u_q = deltaQ[Shortcuts::v + 0];
73 auto v_q = deltaQ[Shortcuts::v + 1];
74 auto w_q = deltaQ[Shortcuts::v + 2];
75 auto q_x = Q[Shortcuts::metric_derivative + 0];
76 auto q_y = Q[Shortcuts::metric_derivative + 1];
77 auto q_z = Q[Shortcuts::metric_derivative + 2];
78 BTimesDeltaQ[Shortcuts::sigma + 0] = -q_x*u_q;
79 BTimesDeltaQ[Shortcuts::sigma + 1] = -q_y*v_q;
80 BTimesDeltaQ[Shortcuts::sigma + 2] = -q_z*w_q;
81 BTimesDeltaQ[Shortcuts::sigma + 3] = -(q_y*u_q+q_x*v_q); //sigma_xy
82 BTimesDeltaQ[Shortcuts::sigma + 4] = -(q_z*u_q+q_x*w_q); //sigma_xz
83 BTimesDeltaQ[Shortcuts::sigma + 5] = -(q_z*v_q+q_y*w_q); //sigma_yz
86 auto u_r = deltaQ[Shortcuts::v + 0];
87 auto v_r = deltaQ[Shortcuts::v + 1];
88 auto w_r = deltaQ[Shortcuts::v + 2];
89 auto r_x = Q[Shortcuts::metric_derivative + 3];
90 auto r_y = Q[Shortcuts::metric_derivative + 4];
91 auto r_z = Q[Shortcuts::metric_derivative + 5];
92 BTimesDeltaQ[Shortcuts::sigma + 0] = -r_x*u_r;
93 BTimesDeltaQ[Shortcuts::sigma + 1] = -r_y*v_r;
94 BTimesDeltaQ[Shortcuts::sigma + 2] = -r_z*w_r;
95 BTimesDeltaQ[Shortcuts::sigma + 3] = -(r_y*u_r+r_x*v_r); //sigma_xy
96 BTimesDeltaQ[Shortcuts::sigma + 4] = -(r_z*u_r+r_x*w_r); //sigma_xz
97 BTimesDeltaQ[Shortcuts::sigma + 5] = -(r_z*v_r+r_y*w_r); //sigma_yz
100 auto u_s = deltaQ[Shortcuts::v + 0];
101 auto v_s = deltaQ[Shortcuts::v + 1];
102 auto w_s = deltaQ[Shortcuts::v + 2];
103 auto s_x = Q[Shortcuts::metric_derivative + 6];
104 auto s_y = Q[Shortcuts::metric_derivative + 7];
105 auto s_z = Q[Shortcuts::metric_derivative + 8];
106 BTimesDeltaQ[Shortcuts::sigma + 0] = -s_x*u_s;
107 BTimesDeltaQ[Shortcuts::sigma + 1] = -s_y*v_s;
108 BTimesDeltaQ[Shortcuts::sigma + 2] = -s_z*w_s;
109 BTimesDeltaQ[Shortcuts::sigma + 3] = -(s_y*u_s+s_x*v_s); //sigma_xy
110 BTimesDeltaQ[Shortcuts::sigma + 4] = -(s_z*u_s+s_x*w_s); //sigma_xz
111 BTimesDeltaQ[Shortcuts::sigma + 5] = -(s_z*v_s+s_y*w_s); //sigma_yz
118 std::fill_n(S, NumberOfAuxiliaryVariables, 0);
127 auto rho = Q[Shortcuts::rho];
128 auto cp = Q[Shortcuts::cp];
129 auto cs = Q[Shortcuts::cs];
130 auto jacobian = Q[Shortcuts::jacobian];
132 auto mu = rho * cs * cs;
133 auto lambda = rho * cp * cp - 2 * mu;
134 auto rho_inv=1.0/(rho*jacobian);
136 // Rhs uses the same formula regardless of dimension, hence no switch necessary
138 rhs[Shortcuts::v + 0] = rho_inv * rhs[Shortcuts::v + 0];
139 rhs[Shortcuts::v + 1] = rho_inv * rhs[Shortcuts::v + 1];
140 rhs[Shortcuts::v + 2] = rho_inv * rhs[Shortcuts::v + 2];
142 double lam_temp = lambda * (rhs[3] + rhs[4] + rhs[5]);
144 rhs[3]=(2*mu) * rhs[3] +lam_temp;
145 rhs[4]=(2*mu) * rhs[4] +lam_temp;
146 rhs[5]=(2*mu) * rhs[5] +lam_temp;
161 context->riemannSolver(
175 #define _CUSTOM_COORDINATES
179 #include "../ExaSeis_core/Curvilinear/ContextDynamicRupture.h"
180 #include "../ExaSeis_core/Numerics/riemannsolverDynamicRupture.h"
185 ContextDynamicRupture<{{NAMESPACE | join("::")}}::VariableShortcuts{{SOLVER_NAME}},
186 {{NAMESPACE | join("::")}}::{{CLASSNAME}}::Order + 1,
187 {{NAMESPACE | join("::")}}::{{CLASSNAME}}::NumberOfUnknowns,
188 {{NAMESPACE | join("::")}}::{{CLASSNAME}}::NumberOfAuxiliaryVariables,
189 {{SOLUTION_STORAGE_PRECISION}}>* {{NAMESPACE | join("::")}}::{{CLASSNAME}}::context;
195 double QuadraturePoints1d[Order+1];
198 static ContextDynamicRupture<VariableShortcuts{{SOLVER_NAME}}, Order + 1, NumberOfUnknowns, NumberOfAuxiliaryVariables, {{SOLUTION_STORAGE_PRECISION}}>* context;
204 kernels::{{SOLVER_NAME}}::Quadrature<{{SOLUTION_STORAGE_PRECISION}}>::nodes,
209 std::string topography_string = \"""" + scenario_string +
""".yaml";
211 //setting coarsestMeshLevel and maxAdaptiveMeshLevel
212 double maxDSize = std::numeric_limits<double>::min();
213 double minDSize = std::numeric_limits<double>::max();
214 tarch::la::Vector<DIMENSIONS, double> sizes = DomainSize;
216 for(int i=0; i<DIMENSIONS; i++){
217 if(sizes[i]>maxDSize){
220 if(sizes[i]<minDSize){
227 //finding coarsest possible Mesh level
228 while(maxDSize>MaxAdmissibleCellH){
233 double realCoarsestMeshSize = maxDSize;
234 double coarsestMeshLevel = depth;
237 while(minDSize>MinAdmissibleCellH){
242 logTraceOutWith1Argument("Freesurface set at ", std::to_string(_TOP * 2));
244 context = new ContextDynamicRupture<VariableShortcuts{{SOLVER_NAME}}, Order + 1, NumberOfUnknowns, NumberOfAuxiliaryVariables, {{SOLUTION_STORAGE_PRECISION}}>(
246 // filename_rupture_model,
248 realCoarsestMeshSize,
250 DomainOffset, DomainSize,
251 kernels::{{SOLVER_NAME}}::Quadrature<{{SOLUTION_STORAGE_PRECISION}}>::nodes,
252 kernels::{{SOLVER_NAME}}::DGMatrices<{{SOLUTION_STORAGE_PRECISION}}>::dudx
255 std::cout << "Freesurface set at " << _TOP * 2 << std::endl;
265 if (_solverState==SolverState::GridInitialisation) {
266 std::string filename_rupture_model = \"""" + scenario_string +
"""_fault.yaml";
267 context->initRuptureModel(filename_rupture_model);
def abstractDeclarations()
def finish_time_step_implementation(scenario_string)
def multiplyMaterialParameterMatrix()
def initial(pointwise_initial_conditions)
def init_grid_step_implementation(scenario_string)
def abstractUserDefinitions()