5 constexpr int itmax = {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}} * {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}};
9 constexpr int itmax = {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}} * {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}} * {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}};
13 for (int i=0;i<itmax;i++)
15 applications::exahype2::ccz4::enforceCCZ4constraints( newQ+index );
16 index += {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}};
23 extra_derivative_assign=
"""
24 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariablesOnReconstructedPatch( 1, {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}}, {{HALO_SIZE}}, {{NUMBER_OF_UNKNOWNS}}, {{NUMBER_OF_AUXILIARY_VARIABLES}});
25 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithoutAuxiliaryVariables( {{RK_STEPS}}, {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}}, 0, {{NUMBER_OF_UNKNOWNS}}, 0 );
26 {{PRIMARY_VARS_INDICES}}
27 {{AUXILIARY_VARS_INDICES}}
30 for (int unknown : auxiliaryVarsIndices) {
31 oldQWithHalo[ enumeratorWithAuxiliaryVariablesOnReconstructedPatch(0,dof,unknown) ] = //abuse of RHS, auxiliary variables are stored there.
32 fineGridCellCCZ4QRhsEstimates.value[ enumeratorWithoutAuxiliaryVariables(0,dof,unknown) ];
37 extra_derivative_assign=
""
39 const int patchSize = """ +
str( patch_size ) +
""";
40 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
42 const int n_a_v="""+
str(number_of_output_variable)+
""";
43 const int overlap=3; //make sure you are using fd4 solver!
45 if (not marker.willBeRefined() and repositories::instanceOfCCZ4.getSolverState()!=CCZ4::SolverState::GridConstruction and repositories::instanceOfCCZ4.getSolverState()==CCZ4::SolverState::RungeKuttaSubStep0) {"""+extra_derivative_assign+
"""
47 dfor(cell,patchSize) {
48 tarch::la::Vector<DIMENSIONS,int> currentCell = cell + tarch::la::Vector<DIMENSIONS,int>(overlap);
50 double gradQ[3*59]={ 0 };
52 for (int d=0; d<3; d++) {
53 tarch::la::Vector<DIMENSIONS,int> leftCell = currentCell;
54 tarch::la::Vector<DIMENSIONS,int> rightCell = currentCell;
55 tarch::la::Vector<DIMENSIONS,int> DouleftCell = currentCell;
56 tarch::la::Vector<DIMENSIONS,int> DourightCell = currentCell;
57 leftCell(d) -= 1; DouleftCell(d) -= 2;
58 rightCell(d) += 1; DourightCell(d) += 2;
59 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*overlap);
60 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*overlap);
61 const int DouleftCellSerialised = peano4::utils::dLinearised(DouleftCell, patchSize + 2*overlap);
62 const int DourightCellSerialised = peano4::utils::dLinearised(DourightCell,patchSize + 2*overlap);
63 for(int i=0; i<59; i++) {
64 gradQ[d*59+i] = ( -1*oldQWithHalo[DourightCellSerialised*(59+n_a_v)+i] + 8*oldQWithHalo[rightCellSerialised*(59+n_a_v)+i] - 8*oldQWithHalo[leftCellSerialised*(59+n_a_v)+i] + 1*oldQWithHalo[DouleftCellSerialised*(59+n_a_v)+i]) / 12.0 / volumeH;
68 const int cellSerialised = peano4::utils::dLinearised(currentCell, patchSize + 2*overlap);
70 double constraints[n_a_v]={0};
71 admconstraints(constraints, oldQWithHalo+cellSerialised*(59+n_a_v), gradQ);
72 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, 0, 59, n_a_v);
73 for (int i=0;i<n_a_v;i++){
74 fineGridCellCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+i) ] = constraints[i];
82 extra_derivative_assign=
"""
83 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariablesOnReconstructedPatch( 1, {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}}, {{HALO_SIZE}}, {{NUMBER_OF_UNKNOWNS}}, {{NUMBER_OF_AUXILIARY_VARIABLES}});
84 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithoutAuxiliaryVariables( {{RK_STEPS}}, {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}}, 0, {{NUMBER_OF_UNKNOWNS}}, 0 );
85 {{PRIMARY_VARS_INDICES}}
86 {{AUXILIARY_VARS_INDICES}}
89 for (int unknown : auxiliaryVarsIndices) {
90 oldQWithHalo[ enumeratorWithAuxiliaryVariablesOnReconstructedPatch(0,dof,unknown) ] = //abuse of RHS, auxiliary variables are stored there.
91 fineGridCellCCZ4QRhsEstimates.value[ enumeratorWithoutAuxiliaryVariables(0,dof,unknown) ];
96 extra_derivative_assign=
""
98 const int patchSize = """ +
str( patch_size ) +
""";
99 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
101 const int n_a_v="""+
str(number_of_output_variable)+
""";
102 const int overlap=3; //make sure you are using fd4 solver!
104 if (not marker.willBeRefined() and repositories::instanceOfCCZ4.getSolverState()!=CCZ4::SolverState::GridConstruction and repositories::instanceOfCCZ4.getSolverState()==CCZ4::SolverState::RungeKuttaSubStep0) {"""+extra_derivative_assign+
"""
106 dfor(cell,patchSize) {
107 tarch::la::Vector<DIMENSIONS,int> currentCell = cell + tarch::la::Vector<DIMENSIONS,int>(overlap);
109 double gradQ[3*59]={ 0 };
111 /*for (int d=0; d<3; d++) {
112 tarch::la::Vector<DIMENSIONS,int> leftCell = currentCell;
113 tarch::la::Vector<DIMENSIONS,int> rightCell = currentCell;
116 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*overlap);
117 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*overlap);
118 for(int i=0; i<59; i++) {
119 gradQ[d*59+i] = ( oldQWithHalo[rightCellSerialised*(59+n_a_v)+i] - oldQWithHalo[leftCellSerialised*(59+n_a_v)+i] ) / 2.0 / volumeH;
123 for (int d=0; d<3; d++) {
124 tarch::la::Vector<DIMENSIONS,int> leftCell = currentCell;
125 tarch::la::Vector<DIMENSIONS,int> rightCell = currentCell;
126 tarch::la::Vector<DIMENSIONS,int> DouleftCell = currentCell;
127 tarch::la::Vector<DIMENSIONS,int> DourightCell = currentCell;
128 leftCell(d) -= 1; DouleftCell(d) -= 2;
129 rightCell(d) += 1; DourightCell(d) += 2;
130 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*overlap);
131 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*overlap);
132 const int DouleftCellSerialised = peano4::utils::dLinearised(DouleftCell, patchSize + 2*overlap);
133 const int DourightCellSerialised = peano4::utils::dLinearised(DourightCell,patchSize + 2*overlap);
134 for(int i=0; i<59; i++) {
135 gradQ[d*59+i] = ( -1*oldQWithHalo[DourightCellSerialised*(59+n_a_v)+i] + 8*oldQWithHalo[rightCellSerialised*(59+n_a_v)+i] - 8*oldQWithHalo[leftCellSerialised*(59+n_a_v)+i] + 1*oldQWithHalo[DouleftCellSerialised*(59+n_a_v)+i]) / 12.0 / volumeH;
139 const int cellSerialised = peano4::utils::dLinearised(currentCell, patchSize + 2*overlap);
141 double Psi4[n_a_v]={0};
142 double currentPosition[3];
143 for (int d=0; d<3; d++) currentPosition[d]=marker.getOffset()(d)+(cell(d)+0.5)*volumeH;
144 Psi4Calc(Psi4, oldQWithHalo+cellSerialised*(59+n_a_v), gradQ, currentPosition);
145 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, 0, 59, n_a_v);
146 fineGridCellCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+0) ] = Psi4[0];
147 fineGridCellCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+1) ] = Psi4[1];
154 timeStamp=
"CheckpointTimeStamp"
158 if scenario==
"single-puncture":
160 ::exahype2::fd::applySommerfeldConditions(
162 const double * NOALIAS Q,
163 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
164 const tarch::la::Vector<DIMENSIONS,double>& gridCellH,
169 return repositories::{{SOLVER_INSTANCE}}.maxEigenvalue( Q, faceCentre, gridCellH, t, dt, normal );
173 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
174 const tarch::la::Vector<DIMENSIONS,double>& gridCellH
176 for (int i=0; i<"""+
str(unknowns + auxiliary_variables)+
"""; i++) {
179 Q[0] = 1.0; Q[3] = 1.0; Q[5] = 1.0;
180 //const double r=tarch::la::norm2(faceCentre);
181 //Q[16] = 0.5*(1+(1-1.0/2/r)/(1+1.0/2/r));
182 //Q[54] = 1/(1+1.0/2/r)/(1+1.0/2/r);
183 Q[16] = 1.0; Q[54] = 1.0;
187 {{FACE_METADATA_ACCESSOR}}.getOldTimeStamp(marker.getSelectedFaceNumber()<DIMENSIONS ? 1 : 0),
188 repositories::{{SOLVER_INSTANCE}}.getMinTimeStepSize(),
189 {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}},
191 {{NUMBER_OF_UNKNOWNS}},
192 {{NUMBER_OF_AUXILIARY_VARIABLES}},
193 marker.getSelectedFaceNumber(),
195 fineGridFace{{UNKNOWN_IDENTIFIER}}Old.value,
196 fineGridFace{{UNKNOWN_IDENTIFIER}}New.value,
202 ::exahype2::fd::applySommerfeldConditions(
204 const double * NOALIAS Q,
205 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
206 const tarch::la::Vector<DIMENSIONS,double>& gridCellH,
211 return repositories::{{SOLVER_INSTANCE}}.maxEigenvalue( Q, faceCentre, gridCellH, t, dt, normal );
215 const tarch::la::Vector<DIMENSIONS,double>& faceCentre,
216 const tarch::la::Vector<DIMENSIONS,double>& gridCellH
218 for (int i=0; i<"""+
str(unknowns + auxiliary_variables)+
"""; i++) {
221 Q[0] = 1.0; Q[3] = 1.0; Q[5] = 1.0;
222 Q[16] = 1.0; Q[54] = 1.0;
226 {{FACE_METADATA_ACCESSOR}}.getOldTimeStamp(marker.getSelectedFaceNumber()<DIMENSIONS ? 1 : 0),
227 repositories::{{SOLVER_INSTANCE}}.getMinTimeStepSize(),
228 {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}},
230 {{NUMBER_OF_UNKNOWNS}},
231 {{NUMBER_OF_AUXILIARY_VARIABLES}},
232 marker.getSelectedFaceNumber(),
234 fineGridFace{{UNKNOWN_IDENTIFIER}}Old.value,
235 fineGridFace{{UNKNOWN_IDENTIFIER}}New.value,
def get_body_of_adm_constraints(patch_size, number_of_output_variable, so_flag)
def get_body_of_SommerfeldCondition(scenario, unknowns, auxiliary_variables, restart_time=-1)
def get_body_of_Psi_Calc(patch_size, number_of_output_variable, so_flag)
def get_body_of_enforceCCZ4constraint()