Peano
Loading...
Searching...
No Matches
PMLDynamicRuptureElastic.py
Go to the documentation of this file.
2 return """
3//This term is not present in the Zenodo repository at https://zenodo.org/records/6386282
4//however it is present in Leo's "phd" tag at https://gitlab.lrz.de/ExaHyPE-Seismic/ExaSeis/-/blob/leo/phd/Applications/DynamicRupture/PMLSlipWeakening/PMLSlipWeakening.cpp?ref_type=tags#L468
5// We are working on the assumption that it should be in there.
6
7 S[9] = -Q[0];
8 S[10] = -Q[1];
9 S[11] = -Q[2];
10"""
11
12
14 return """
15 context->riemannSolver(
16 FL, FR,
17 QL, QR,
18 t, dt,
19 h,
20 direction,
21 isBoundaryFace,
22 faceIndex,
23 1 //surface
24 );
25"""
26
28 return """
29#define _CUSTOM_COORDINATES
30#define ASAGI_NOMPI
31#define _TOP 1
32
33#include "../ExaSeis_core/Curvilinear/ContextDynamicRupture.h"
34#include "../ExaSeis_core/Numerics/riemannsolverPMLDynamicRupture.h"
35
36#include "peano4/datamanagement/CellMarker.h"
37"""
38
40 return """
41ContextDynamicRupture<{{NAMESPACE | join("::")}}::VariableShortcuts{{SOLVER_NAME}},
42 {{NAMESPACE | join("::")}}::{{CLASSNAME}}::Order + 1,
43 {{NAMESPACE | join("::")}}::{{CLASSNAME}}::NumberOfUnknowns,
44 {{NAMESPACE | join("::")}}::{{CLASSNAME}}::NumberOfAuxiliaryVariables,
45 {{SOLUTION_STORAGE_PRECISION}}>* {{NAMESPACE | join("::")}}::{{CLASSNAME}}::context;
46
47tarch::la::Vector<DIMENSIONS,double> {{NAMESPACE | join("::")}}::{{CLASSNAME}}::invertProjection(const tarch::la::Vector<DIMENSIONS,double> coordinates){
48
49 if(peano4::datamanagement::CellMarker::isContained(
50 coordinates, DomainOffset+0.5*DomainSize, DomainSize, 0.
51 )){
52 double fixedCoords[3];
53 fixedCoords[toolbox::curvi::Coordinate::X] = coordinates[0];
54 fixedCoords[toolbox::curvi::Coordinate::Y] = coordinates[1];
55 fixedCoords[toolbox::curvi::Coordinate::Z] = coordinates[2];
56
57 tarch::la::Vector<DIMENSIONS,double> result;
58 toolbox::curvi::Interface* curviInterface = context->getInterface();
59 result[0] = curviInterface->invertProjection(toolbox::curvi::Coordinate::X, fixedCoords);
60 result[1] = curviInterface->invertProjection(toolbox::curvi::Coordinate::Y, fixedCoords);
61 result[2] = curviInterface->invertProjection(toolbox::curvi::Coordinate::Z, fixedCoords);
62
63 return result;
64 }
65 return coordinates;
66}
67"""
68
70 return """
71public:
72 double QuadraturePoints1d[Order+1];
73
74 tarch::la::Vector<DIMENSIONS,double> invertProjection(const tarch::la::Vector<DIMENSIONS,double> coordinates);
75
76protected:
77 static ContextDynamicRupture<VariableShortcutsElasticSolver, Order + 1, NumberOfUnknowns, NumberOfAuxiliaryVariables, {{SOLUTION_STORAGE_PRECISION}}>* context;
78
79 static constexpr int pml_cell_width = 1;
80 static constexpr double pml_alpha_const = 1.5;
81 static constexpr double pml_alpha_scalar = 0.0;
82 static constexpr double pml_rel_error = 0.001;
83 static constexpr int pml_power = 1;
84"""
85
86def init_grid_step_implementation(scenario_string):
87 return """
88 std::copy_n(
89 kernels::{{SOLVER_NAME}}::Quadrature<{{SOLUTION_STORAGE_PRECISION}}>::nodes,
90 (Order+1),
91 QuadraturePoints1d
92 );
93
94 std::string topography_string = \"""" + scenario_string + """.yaml";
95
96 //setting coarsestMeshLevel and maxAdaptiveMeshLevel
97 double maxDSize = std::numeric_limits<double>::min();
98 double minDSize = std::numeric_limits<double>::max();
99 tarch::la::Vector<DIMENSIONS, double> sizes = DomainSize;
100
101 for(int i=0; i<DIMENSIONS; i++){
102 if(sizes[i]>maxDSize){
103 maxDSize = sizes[i];
104 }
105 if(sizes[i]<minDSize){
106 minDSize = sizes[i];
107 }
108 }
109
110 int depth = 0;
111
112 //finding coarsest possible Mesh level
113 while(maxDSize>MaxAdmissibleCellH){
114 depth += 1;
115 maxDSize /= 3.0;
116 }
117
118 double realCoarsestMeshSize = maxDSize;
119 double coarsestMeshLevel = depth;
120
121 depth = 0;
122 while(minDSize>MinAdmissibleCellH){
123 depth += 1;
124 minDSize /= 3.0;
125 }
126
127 logTraceOutWith1Argument("Freesurface set at ", std::to_string(_TOP * 2));
128
129 context = new ContextDynamicRupture<VariableShortcutsElasticSolver, Order + 1, NumberOfUnknowns, NumberOfAuxiliaryVariables, {{SOLUTION_STORAGE_PRECISION}}>(
130 topography_string,
131 coarsestMeshLevel,
132 realCoarsestMeshSize,
133 depth,
134 DomainOffset, DomainSize,
135 kernels::ElasticSolver::Quadrature<{{SOLUTION_STORAGE_PRECISION}}>::nodes,
136 kernels::ElasticSolver::DGMatrices<{{SOLUTION_STORAGE_PRECISION}}>::dudx
137 );
138
139 std::cout << "PML is using " << pml_cell_width << " elements" << std::endl;
140 std::cout << "Freesurface set at " << _TOP * 2 << std::endl;
141"""
142
144 return """
145 if (_solverState==SolverState::GridInitialisation) {
146 std::string filename_rupture_model = \"""" + scenario_string + """_fault.yaml";
147 context->initRuptureModel(filename_rupture_model);
148 }
149"""
finish_time_step_implementation(scenario_string)
init_grid_step_implementation(scenario_string)