10from Probe_file_gene
import tracer_seeds_generate
21 data.append(list(map(float,line.split(
' ')[1:])))
28 "release": peano4.output.CompileMode.Release,
29 "trace": peano4.output.CompileMode.Trace,
30 "assert": peano4.output.CompileMode.Asserts,
"stats": peano4.output.CompileMode.Stats,
31 "debug": peano4.output.CompileMode.Debug,
35 "GLMc0":1.5,
"GLMc":1.2,
"GLMd":2.0,
"GLMepsA":1.0,
"GLMepsP":1.0,
37 "itau":1.0,
"k1":0.1,
"k2":0.0,
"k3":0.5,
"eta":1.0,
38 "f":0.75,
"g":0.0,
"xi":1.0,
"e":1.0,
"c":1.0,
"mu":0.2,
"ds":1.0,
40 "domain_r":0.5,
"smoothing":0.0,
"KOSigma":4.0
52intparams = {
"BBHType":2,
"LapseType":1,
"tp_grid_setup":0,
"swi":99,
"ReSwi":0,
"source":0}
54if __name__ ==
"__main__":
55 parser = argparse.ArgumentParser(description=
'ExaHyPE 2 - CCZ4 script')
56 parser.add_argument(
"-maxh",
"--max-h", dest=
"max_h", type=float, required=
"True", help=
"upper limit for refinement. Refers to volume size, i.e. not to patch size" )
57 parser.add_argument(
"-minh",
"--min-h", dest=
"min_h", type=float, default=0, help=
"lower limit for refinement (set to 0 to make it equal to max_h - default). Refers to volume size, i.e. not to patch size" )
58 parser.add_argument(
"-ps",
"--patch-size", dest=
"patch_size", type=int, default=6, help=
"Patch size, i.e. number of volumes per patch per direction" )
59 parser.add_argument(
"-plt",
"--plot-step-size", dest=
"plot_step_size", type=float, default=0.04, help=
"Plot step size (0 to switch it off)" )
60 parser.add_argument(
"-m",
"--mode", dest=
"mode", default=
"release", help=
"|".join(modes.keys()) )
61 parser.add_argument(
"--gpu", dest=
"GPU", default=
False, action=
"store_true", help=
"Run with accelerator support" )
62 parser.add_argument(
"-ext",
"--extension", dest=
"extension", choices=[
"none",
"adm",
"Psi4",
"phy-debug",
"PT"], default=
"none", help=
"Pick extension, i.e. what should be plotted on top. Default is none" )
63 parser.add_argument(
"-impl",
"--implementation", dest=
"implementation", choices=[
"fv-global-fixed",
"fv-global-adaptive",
"fv-global-fixed-enclave",
"fv-global-adaptive-enclave",
"fv-subcyling-adaptive-enclave",
"fv-local-enclave",
"fv-musclhancock",
"fd4-rk1-adaptive",
"fd4-rk1-adaptive-enclave",
"fd4-rk1-fixed",
"fd4-rk4-adaptive",
"fd4-rk4-fixed",
"RKDG"], required=
"True", help=
"Pick solver type" )
64 parser.add_argument(
"-no-pbc",
"--no-periodic-boundary-conditions", dest=
"periodic_bc", action=
"store_false", default=
True, help=
"switch on or off the periodic BC" )
65 parser.add_argument(
"-sommerfeld",
"--sommerfeld-boundary-conditions", dest=
"sommerfeld_bc", action=
"store_true", default=
False, help=
"switch on or off the Sommerfeld radiative BC" )
66 parser.add_argument(
"-AMRMarker",
"--AMR-marker", dest=
"marker", choices=[
"none",
"poisson"], default=
"none", help=
"switch on or off the AMR boundary marker" )
67 parser.add_argument(
"-et",
"--end-time", dest=
"end_time", type=float, default=1.0, help=
"End (terminal) time" )
68 parser.add_argument(
"-pst",
"--plot-start-time", dest=
"plot_start_time", type=float, default=0.0, help=
"start time for plot" )
69 parser.add_argument(
"-s",
"--scenario", dest=
"scenario", choices=[
"gauge",
"dia_gauge",
"linear",
"single-puncture",
"two-punctures",
"flat"], required=
"True", help=
"Scenario" )
70 parser.add_argument(
"-cfl",
"--CFL-ratio", dest=
"cfl", type=float, default=0.1, help=
"Set CFL ratio" )
71 parser.add_argument(
"-tracer",
"--add-tracer", dest=
"add_tracer", type=int, default=0, help=
"Add tracers and specify the seeds. 0-switch off, 1-static point tracer, 2-moving point tracer" )
72 parser.add_argument(
"-tn",
"--tracer-name", dest=
"tra_name", type=str, default=
"de", help=
"name of output tracer file (temporary)" )
73 parser.add_argument(
"-exn",
"--exe-name", dest=
"exe_name", type=str, default=
"", help=
"name of output executable file" )
74 parser.add_argument(
"-outdir",
"--output-directory", dest=
"path", type=str, default=
"./", help=
"specify the output directory, include the patch file and tracer file" )
75 parser.add_argument(
"-interp",
"--interpolation", dest=
"interpolation", choices=[
"constant",
"order-2",
"linear-constant-extrap",
"linear-linear-extrap",
"linear-con-extrap-lin-normal-interp",
"linear-lin-extrap-lin-normal-interp"], default=
"linear-lin-extrap-lin-normal-interp", help=
"interpolation scheme for AMR" )
76 parser.add_argument(
"-restrict",
"--restriction", dest=
"restriction", choices=[
"average",
"inject" ], default=
"average", help=
"restriction scheme for AMR" )
79 for k, v
in floatparams.items(): parser.add_argument(
"--{}".format(k), dest=
"CCZ4{}".format(k), type=float, default=v, help=
"default: %(default)s")
80 for k, v
in intparams.items():
82 parser.add_argument(
"--{}".format(k), dest=
"CCZ4{}".format(k), type=int, default=v, help=
"default: %(default)s, choose refinement criterion, 0-no refinement, 1-radius based, 2-SBH phi gradient based, 3-BBH phi gradient based. Notice: 2 and 3 only work with -ext Full")
83 else: parser.add_argument(
"--{}".format(k), dest=
"CCZ4{}".format(k), type=int, default=v, help=
"default: %(default)s")
85 args = parser.parse_args()
89 print(args.implementation)
90 if args.implementation==
"fv-global-fixed":
92 if args.implementation==
"fv-global-adaptive":
94 if args.implementation==
"fv-global-fixed-enclave":
96 if args.implementation==
"fv-global-adaptive-enclave":
98 if args.implementation==
"fv-subcyling-adaptive-enclave":
100 if args.implementation==
"fv-local-enclave":
102 if args.implementation==
"fv-musclhancock":
104 if args.implementation==
"fd4-rk1-adaptive" or args.implementation==
"fd4-rk4-adaptive":
106 if args.implementation==
"fd4-rk1-adaptive-enclave":
108 if args.implementation==
"fd4-rk1-fixed" or args.implementation==
"fd4-rk4-fixed":
110 if args.implementation==
"RKDG":
115 def __init__(self, name, patch_size, min_volume_h, max_volume_h, cfl, domain_r, KOSig):
137 number_of_unknowns = sum(unknowns.values())
140#include "../CCZ4Kernels.h"
146 name=name, patch_size=patch_size,
147 unknowns=number_of_unknowns,
148 auxiliary_variables=0,
149 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
150 normalised_time_step_size=1e-2
155 name=name, patch_size=patch_size,
156 unknowns=number_of_unknowns,
157 auxiliary_variables=0,
158 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
165 name=name, patch_size=patch_size,
166 unknowns=number_of_unknowns,
167 auxiliary_variables=0,
168 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
169 time_step_relaxation=cfl
172 if args.implementation==
"fd4-rk1-adaptive" or args.implementation==
"fd4-rk1-adaptive-enclave":
178 name=name, patch_size=patch_size, rk_order=rk_order,
179 unknowns=number_of_unknowns,
180 auxiliary_variables=0,
181 min_meshcell_h=min_volume_h, max_meshcell_h=max_volume_h,
182 time_step_relaxation=cfl,
186 if args.implementation==
"fd4-rk1-adaptive" or args.implementation==
"fd4-rk1-adaptive-enclave":
192 name=name, patch_size=patch_size, rk_order=rk_order,
193 unknowns=number_of_unknowns,
194 auxiliary_variables=0,
195 min_meshcell_h=min_volume_h, max_meshcell_h=max_volume_h,
196 time_step_relaxation=cfl,
198 pde_terms_without_state=
True
201 if args.implementation==
"fd4-rk1-fixed":
207 name=name, patch_size=patch_size, rk_order=rk_order,
208 unknowns=number_of_unknowns,
209 auxiliary_variables=0,
210 min_meshcell_h=min_volume_h, max_meshcell_h=max_volume_h,
211 normalised_time_step_size=0.01,
220 face_projections = exahype2.solvers.rkdg.FaceProjections.Solution,
221 unknowns=number_of_unknowns,
222 auxiliary_variables=0,
223 min_cell_h=min_volume_h, max_cell_h=max_volume_h,
224 time_step_relaxation=cfl
229 name=name, patch_size=patch_size,
230 unknowns=number_of_unknowns,
231 auxiliary_variables=0,
232 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
233 time_step_relaxation=cfl
241 self.set_implementation(
242 boundary_conditions=exahype2.solvers.PDETerms.User_Defined_Implementation,
243 ncp=exahype2.solvers.PDETerms.User_Defined_Implementation,
244 flux=exahype2.solvers.PDETerms.None_Implementation,
245 source_term=exahype2.solvers.PDETerms.User_Defined_Implementation,
246 refinement_criterion = exahype2.solvers.PDETerms.User_Defined_Implementation,
247 eigenvalues = exahype2.solvers.PDETerms.User_Defined_Implementation
255 compute_max_eigenvalue_of_next_time_step =
True,
256 solver_variant = exahype2.solvers.rkfd.kernels.SolverVariant.Multicore,
257 kernel_variant = exahype2.solvers.rkfd.kernels.KernelVariant.BatchedAoSHeap,
258 KOSigma = self._KO_Sigma
261 self.switch_to_heap_storage(
True,
True)
275 constexpr int itmax = {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}} * {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}};
279 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}};
289 constexpr int itmax = {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}};
293 constexpr int itmax = {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}};
299 for (int i=0;i<itmax;i++)
301 applications::exahype2::ccz4::enforceCCZ4constraints( newQ+index );
302 index += {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}};
309 SuperClass.create_action_sets(self)
310 self._action_set_couple_resolution_transitions_and_handle_dynamic_mesh_refinement.additional_includes +=
"""
311#include "../CCZ4Kernels.h"
316 We take this routine to add a few additional include statements.
318 return SuperClass.get_user_action_set_includes(self) + self._my_user_includes
322 @add adm constriants (Hamilton and Momentum)
324 self._auxiliary_variables = 7
326 self._my_user_includes +=
"""
327 #include "../CCZ4Kernels.h"
330 self._preprocess_reconstructed_patch =
"""
331 const int patchSize = """ + str( self._patch.dim[0] ) +
""";
332 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
335 const int overlap=3; //make sure you are using fd4 solver!
337 //if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()==FiniteVolumeCCZ4::SolverState::RungeKuttaSubStep0) {
338 if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction) {
339 dfor(cell,patchSize) {
340 tarch::la::Vector<Dimensions,int> currentCell = cell + tarch::la::Vector<Dimensions,int>(overlap);
342 double gradQ[3*59]={ 0 };
344 for (int d=0; d<3; d++) {
345 tarch::la::Vector<Dimensions,int> leftCell = currentCell;
346 tarch::la::Vector<Dimensions,int> rightCell = currentCell;
349 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*overlap);
350 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*overlap);
351 for(int i=0; i<59; i++) {
352 gradQ[d*59+i] = ( oldQWithHalo[rightCellSerialised*(59+n_a_v)+i] - oldQWithHalo[leftCellSerialised*(59+n_a_v)+i] ) / 2.0 / volumeH;
356 const int cellSerialised = peano4::utils::dLinearised(currentCell, patchSize + 2*overlap);
358 double constraints[7]={0,0,0,0,0,0,0};
359 admconstraints(constraints, oldQWithHalo+cellSerialised*(59+n_a_v), gradQ);
360 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, 0, 59, n_a_v);
361 for (int i=0;i<7;i++){
362 fineGridCellFiniteVolumeCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+i) ] = constraints[i];
368 self.create_data_structures()
369 self.create_action_sets()
375 self._auxiliary_variables = 2
377 self._my_user_includes +=
"""
378 #include "../libtwopunctures/TP_PunctureTracker.h"
379 #include "../CCZ4Kernels.h"
382 self._preprocess_reconstructed_patch =
"""
383 const int patchSize = """ + str( self._patch.dim[0] ) +
""";
384 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
387 const int overlap=3; //make sure you are using fd4 solver!
389 //if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()==FiniteVolumeCCZ4::SolverState::RungeKuttaSubStep0) {
390 if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction) {
391 dfor(cell,patchSize) {
392 tarch::la::Vector<Dimensions,int> currentCell = cell + tarch::la::Vector<Dimensions,int>(overlap);
394 double gradQ[3*59]={ 0 };
396 for (int d=0; d<3; d++) {
397 tarch::la::Vector<Dimensions,int> leftCell = currentCell;
398 tarch::la::Vector<Dimensions,int> rightCell = currentCell;
401 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*overlap);
402 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*overlap);
403 for(int i=0; i<59; i++) {
404 gradQ[d*59+i] = ( oldQWithHalo[rightCellSerialised*(59+n_a_v)+i] - oldQWithHalo[leftCellSerialised*(59+n_a_v)+i] ) / 2.0 / volumeH;
408 const int cellSerialised = peano4::utils::dLinearised(currentCell, patchSize + 2*overlap);
410 double Psi4[2]={0,0};
411 double currentPosition[3];
412 for (int d=0; d<3; d++) currentPosition[d]=marker.getOffset()(d)+(cell(d)+0.5)*volumeH;
413 Psi4Calc(Psi4, oldQWithHalo+cellSerialised*(59+n_a_v), gradQ, currentPosition);
414 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, 0, 59, n_a_v);
415 fineGridCellFiniteVolumeCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+0) ] = Psi4[0];
416 fineGridCellFiniteVolumeCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+1) ] = Psi4[1];
421 self.create_data_structures()
422 self.create_action_sets()
426 @add adm intermediate quantites
428 self._auxiliary_variables = 15
430 self._my_user_includes +=
"""
431 #include "../CCZ4Kernels.h"
434 self._preprocess_reconstructed_patch =
"""
435 const int patchSize = """ + str( self._patch.dim[0] ) +
""";
436 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
438 const int n_a_v=""" + str( self._auxiliary_variables ) +
""";
439 const int overlap=3; //make sure you are using fd4 solver!
441 //if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()==FiniteVolumeCCZ4::SolverState::RungeKuttaSubStep0) {
442 if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction) {
443 dfor(cell,patchSize) {
444 tarch::la::Vector<Dimensions,int> currentCell = cell + tarch::la::Vector<Dimensions,int>(overlap);
446 double gradQ[3*59]={ 0 };
448 for (int d=0; d<3; d++) {
449 tarch::la::Vector<Dimensions,int> leftCell = currentCell;
450 tarch::la::Vector<Dimensions,int> leftCell2 = currentCell;
451 tarch::la::Vector<Dimensions,int> rightCell = currentCell;
452 tarch::la::Vector<Dimensions,int> rightCell2 = currentCell;
453 leftCell(d) -= 1; leftCell2(d) -= 2;
454 rightCell(d) += 1; rightCell2(d) += 2;
455 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*overlap);
456 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*overlap);
457 const int leftCellSerialised2 = peano4::utils::dLinearised(leftCell2, patchSize + 2*overlap);
458 const int rightCellSerialised2 = peano4::utils::dLinearised(rightCell2,patchSize + 2*overlap);
459 for(int i=0; i<59; i++) {
460 gradQ[d*59+i] = ( (2.0/3.0)*oldQWithHalo[rightCellSerialised*(59+n_a_v)+i] - (2.0/3.0)*oldQWithHalo[leftCellSerialised*(59+n_a_v)+i]
461 +(1.0/12.0)*oldQWithHalo[leftCellSerialised2*(59+n_a_v)+i] - (1.0/12.0)*oldQWithHalo[rightCellSerialised2*(59+n_a_v)+i] )/volumeH;
465 const int cellSerialised = peano4::utils::dLinearised(currentCell, patchSize + 2*overlap);
467 double terms[""" + str( self._auxiliary_variables ) +
"""]={0,0,0,0,0,0,0};
468 TestingOutput(terms, oldQWithHalo+cellSerialised*(59+n_a_v), gradQ);
469 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, 0, 59, n_a_v);
470 for (int i=0;i<""" + str( self._auxiliary_variables ) +
""";i++){
471 fineGridCellFiniteVolumeCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+i) ] = terms[i];
477 self.create_data_structures()
478 self.create_action_sets()
484 self._auxiliary_variables = 0
486 self._user_solver_includes +=
"""
487 #include "libtwopunctures/TP_PunctureTracker.h"
488 #include "CCZ4Kernels.h"
500 self._preprocess_reconstructed_patch =
"""
501 const int patchSize = """ + str( self._patch.dim[0] ) +
""";
502 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
505 std::string att="_"""+args.exe_name+
""".txt"; std::string p1="puncture1"; std::string p2="puncture2"; std::string tem="ztem";
506 const int n_a_v=""" + str( self._auxiliary_variables ) +
""";
507 const double overlap=3;
509 if (tarch::la::equals(timeStamp,0.0)){//initialization
510 fin.open((p1+att),std::ios::out|std::ios::trunc);
511 fin << "2.0 0.0 0.0 0.0 0.0" << std::endl;//4.461538
513 fin.open((p2+att),std::ios::out|std::ios::trunc);
514 fin << "-2.0 0.0 0.0 0.0 0.0" << std::endl;//-5.538462
516 //fin.open((tem+att),std::ios::out|std::ios::trunc);
517 //fin << "tem file" << std::endl;
520 fin.open((p1+att),std::ios::in);
521 std::string pos=getLastLine(fin);
523 double coor1[5]={0};//read in previous coordinates
524 CoorReadIn(coor1,pos);
525 fin.open((p2+att),std::ios::in);
526 std::string pos2=getLastLine(fin);
529 CoorReadIn(coor2,pos2);
531 if (marker.isContained(coor1)){
532 tarch::la::Vector<Dimensions*2,int> IndexOfCell=FindCellIndex(coor1,marker.getOffset(),volumeH,patchSize); //find where the puncture is
533 tarch::la::Vector<Dimensions,int> IndexForInterpolate[8];
534 FindInterIndex(IndexForInterpolate,IndexOfCell);//find the closest 8 cells
536 for (int i=0;i<8;i++){
537 int Lindex=peano4::utils::dLinearised(IndexForInterpolate[i], patchSize + 2*overlap);
538 for (int j=0;j<Dimensions;j++) {raw[i*inter_number+j]=oldQWithHalo[Lindex*(59+n_a_v)+17+j];} //read in corresponding beta
539 raw[i*inter_number+3]=oldQWithHalo[Lindex*(59+n_a_v)+16];
540 //std::cout << IndexForInterpolate[i](0) << " " << IndexForInterpolate[i](1) << " " << IndexForInterpolate[i](2) << std::endl;
541 //std::cout << raw[i*inter_number+0] << " " << raw[i*inter_number+1] << " " << raw[i*inter_number+2] << " " << raw[i*inter_number+3] << std::endl;
542 //::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, overlap, 59, n_a_v);
543 //std::cout << oldQWithHalo[enumeratorWithAuxiliaryVariables(0,IndexForInterpolate[i],0)] << std::endl;
545 double result[inter_number];
546 Interpolation(result,IndexForInterpolate,raw,coor1,marker.getOffset(),volumeH,patchSize);
548 coor1[0]-=timeStepSize*result[0]; coor1[1]-=timeStepSize*result[1]; coor1[2]-=timeStepSize*result[2];//updates position
549 fin.open((p1+att),std::ios::app);//output
550 fin << std::setprecision (17) << coor1[0] << " " << coor1[1];
551 fin << " " << coor1[2] << " " << timeStamp << " " << result[3] << std::endl;
553 //fin.open((tem+att),std::ios::app);
554 //fin << "for cellindex" << IndexOfCell(0) << " " << IndexOfCell(1) << " " << IndexOfCell(2) << " " << IndexOfCell(3) << " " << IndexOfCell(4) << " " << IndexOfCell(5) << std::endl;
555 //for (int i=0;i<8;i++){
556 //fin << IndexForInterpolate[i](0) << " " << IndexForInterpolate[i](1) << " " << IndexForInterpolate[i](2) << std::endl;
557 //fin << raw[i*inter_number+0] << " " << raw[i*inter_number+1] << " " << raw[i*inter_number+2] << " " << raw[i*inter_number+3] << std::endl;
560 //fin << "after inter" << result[0] << " " << result[1] << " " << result[2] << " " << result[3] << " " << timeStamp << std::endl;
563 if (marker.isContained(coor2)){//do the same for the second puncutre
564 tarch::la::Vector<Dimensions*2,int> IndexOfCell=FindCellIndex(coor2,marker.getOffset(),volumeH,patchSize);
565 tarch::la::Vector<Dimensions,int> IndexForInterpolate[8];
566 FindInterIndex(IndexForInterpolate,IndexOfCell);
567 double raw[8*inter_number];
568 for (int i=0;i<8;i++){
569 int Lindex=peano4::utils::dLinearised(IndexForInterpolate[i], patchSize + 2*overlap);
570 for (int j=0;j<Dimensions;j++) {raw[i*inter_number+j]=oldQWithHalo[Lindex*(59+n_a_v)+17+j];}
571 raw[i*inter_number+3]=oldQWithHalo[Lindex*(59+n_a_v)+16];
573 double result[inter_number];
574 Interpolation(result,IndexForInterpolate,raw,coor2,marker.getOffset(),volumeH,patchSize);
576 coor2[0]-=timeStepSize*result[0]; coor2[1]-=timeStepSize*result[1]; coor2[2]-=timeStepSize*result[2];
577 fin.open((p2+att),std::ios::app);
578 fin << std::setprecision (17) << coor2[0] << " " << coor2[1];
579 fin << " " << coor2[2] << " " << timeStamp << " " << result[3] << std::endl;
585 self.create_data_structures()
586 self.create_action_sets()
595 if args.exe_name!=
"":
598 if not args.tra_name==
"de":
599 exe +=
"_" + args.tra_name
600 project =
exahype2.Project( [
"applications",
"exahype2",
"ccz4"],
"ccz4", executable=exe)
609 if SuperClass==exahype2.solvers.aderdg.NonFusedGenericRusanovFixedTimeStepSize:
613 time_step_size = 0.001
614 except Exception
as e:
623 except Exception
as e:
625 msg =
"Warning: RKDG not supported on this machine"
627 userinfo.append((msg,e))
630 solver_name =
"ADERDG" + solver_name
632 solver_name =
"RKDG" + solver_name
634 solver_name =
"FiniteVolume" + solver_name
639 print(
"No minimal mesh size chosen. Set it to max mesh size (regular grid)" )
643 my_solver = exahype2.solvers.aderdg.NonFusedGenericRusanovFixedTimeStepSize(
644 solver_name, order, unknowns, 0,
645 exahype2.solvers.aderdg.Polynomials.Gauss_Legendre,
646 min_h, args.max_h, time_step_size,
648 ncp = exahype2.solvers.PDETerms.User_Defined_Implementation,
649 sources = exahype2.solvers.PDETerms.User_Defined_Implementation
652 my_solver =
CCZ4Solver(solver_name, args.patch_size, min_h, args.max_h, args.cfl, args.CCZ4domain_r,args.CCZ4KOSigma)
653 userinfo.append((
"CFL ratio set as "+str(args.cfl),
None))
655 userinfo.append((
"The solver is "+args.implementation,
None))
661 if args.marker==
"poisson":
663 project.add_solver( amr_label )
664 my_solver._auxiliary_variables+=1
665 print(
"Add Poisson AMR marker for variable {}".format(my_solver._auxiliary_variables-1) )
666 amr_label.couple_with_FV_solver( my_solver, my_solver._auxiliary_variables-1 )
672 if args.interpolation==
"order-2":
675 if args.interpolation==
"constant":
676 my_solver.interpolation =
"piecewise_constant"
677 print(
"Interpolation rule: piecewise_constant" )
678 if args.interpolation==
"linear-constant-extrap":
679 my_solver.interpolation =
"linear_with_constant_extrapolation"
680 print(
"Interpolation rule: linear constant extrapolation" )
681 if args.interpolation==
"linear-linear-extrap":
682 my_solver.interpolation =
"linear_with_linear_extrapolation"
683 print(
"Interpolation rule: linear extrapolation" )
684 if args.interpolation==
"linear-con-extrap-lin-normal-interp":
685 my_solver.interpolation =
"linear_with_constant_extrapolation_and_linear_normal_interpolation"
686 print(
"Interpolation rule: linear+constant extrapolation and linear normal interpolation" )
688 if args.interpolation==
"order-2":
689 my_solver.interpolation =
"linear"
696 tem_interp=[
"TP_constant",
"TP_linear_with_linear_extrap_normal_interp"]
697 tem_restrict=[
"TP_inject_normal_extrap",
"TP_average_normal_extrap"]
698 if (
"fd4-rk" in args.implementation):
699 exahype2.solvers.rkfd.fd4.switch_to_FD4_tensor_product_interpolation( my_solver, tem_interp[1] )
700 exahype2.solvers.rkfd.fd4.switch_to_FD4_tensor_product_restriction( my_solver, tem_restrict[1] )
701 userinfo.append((
"FD4 Interpolation: " + tem_interp[1] +
" & Restriction: " + tem_restrict[1],
None))
712 if args.extension==
"adm":
713 my_solver.add_adm_constriants()
714 if args.extension==
"Psi4":
715 my_solver.add_Psi4W()
716 if args.extension==
"phy-debug":
717 my_solver.add_intermediate_quantities()
718 if args.extension==
"PT":
719 my_solver.add_puncture_tracker()
726 for k, v
in intparams.items():
727 intparams.update({k:eval(
"args.CCZ4{}".format(k))})
728 for k, v
in floatparams.items():
729 floatparams.update({k:eval(
"args.CCZ4{}".format(k))})
731 if args.scenario==
"two-punctures":
732 msg =
"Periodic BC deactivated because you pick Puncture scenario\nInitialize binary black holes"
734 periodic_boundary_conditions = [
False,
False,
False]
735 intparams.update({
"swi":2})
737 userinfo.append((msg,
None))
738 elif args.scenario==
"single-puncture":
739 msg =
"Periodic BC deactivated because you pick Puncture scenario\nInitialize single black hole"
741 periodic_boundary_conditions = [
False,
False,
False]
742 intparams.update({
"swi":0})
743 userinfo.append((msg,
None))
744 elif args.periodic_bc==
True:
745 msg =
"Periodic BC set"
747 periodic_boundary_conditions = [
True,
True,
True]
748 userinfo.append((msg,
None))
750 msg =
"WARNING: Periodic BC deactivated by hand"
752 periodic_boundary_conditions = [
False,
False,
False]
753 userinfo.append((msg,
None))
755 if args.sommerfeld_bc==
True:
756 msg =
"set Sommerfeld boundary condition"
757 userinfo.append((msg,
None))
758 periodic_boundary_conditions = [
False,
False,
False]
759 if args.scenario==
"single-puncture":
760 my_solver._action_set_handle_boundary.TemplateHandleBoundary_KernelCalls =
"""
761 ::exahype2::fd::applySommerfeldConditions(
763 const double * __restrict__ Q,
764 const tarch::la::Vector<Dimensions,double>& faceCentre,
765 const tarch::la::Vector<Dimensions,double>& gridCellH,
770 return repositories::{{SOLVER_INSTANCE}}.maxEigenvalue( Q, faceCentre, gridCellH, t, dt, normal );
773 double * __restrict__ Q,
774 const tarch::la::Vector<Dimensions,double>& faceCentre,
775 const tarch::la::Vector<Dimensions,double>& gridCellH
777 for (int i=0; i<"""+str(my_solver._unknowns+my_solver._auxiliary_variables)+
"""; i++) {
780 Q[0] = 1.0; Q[3] = 1.0; Q[5] = 1.0;
781 //const double r=tarch::la::norm2(faceCentre);
782 //Q[16] = 0.5*(1+(1-1.0/2/r)/(1+1.0/2/r));
783 //Q[54] = 1/(1+1.0/2/r)/(1+1.0/2/r);
784 Q[16] = 1.0; Q[54] = 1.0;
788 {{FACE_METADATA_ACCESSOR}}.getOldTimeStamp(marker.getSelectedFaceNumber()<Dimensions ? 1 : 0),
789 repositories::{{SOLVER_INSTANCE}}.getMinTimeStepSize(),
790 {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}},
792 {{NUMBER_OF_UNKNOWNS}},
793 {{NUMBER_OF_AUXILIARY_VARIABLES}},
794 marker.getSelectedFaceNumber(),
796 fineGridFace{{UNKNOWN_IDENTIFIER}}Old.value,
797 fineGridFace{{UNKNOWN_IDENTIFIER}}New.value
801 my_solver._action_set_handle_boundary.TemplateHandleBoundary_KernelCalls =
"""
802 ::exahype2::fd::applySommerfeldConditions(
804 const double * __restrict__ Q,
805 const tarch::la::Vector<Dimensions,double>& faceCentre,
806 const tarch::la::Vector<Dimensions,double>& gridCellH,
811 return repositories::{{SOLVER_INSTANCE}}.maxEigenvalue( Q, faceCentre, gridCellH, t, dt, normal );
814 double * __restrict__ Q,
815 const tarch::la::Vector<Dimensions,double>& faceCentre,
816 const tarch::la::Vector<Dimensions,double>& gridCellH
818 for (int i=0; i<"""+str(my_solver._unknowns+my_solver._auxiliary_variables)+
"""; i++) {
821 Q[0] = 1.0; Q[3] = 1.0; Q[5] = 1.0;
822 Q[16] = 1.0; Q[54] = 1.0;
826 {{FACE_METADATA_ACCESSOR}}.getOldTimeStamp(marker.getSelectedFaceNumber()<Dimensions ? 1 : 0),
827 repositories::{{SOLVER_INSTANCE}}.getMinTimeStepSize(),
828 {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}},
830 {{NUMBER_OF_UNKNOWNS}},
831 {{NUMBER_OF_AUXILIARY_VARIABLES}},
832 marker.getSelectedFaceNumber(),
834 fineGridFace{{UNKNOWN_IDENTIFIER}}Old.value,
835 fineGridFace{{UNKNOWN_IDENTIFIER}}New.value
843 if args.scenario==
"gauge":
844 solverconstants+=
"static constexpr int Scenario=0; /* Gauge wave */ \n "
845 userinfo.append((
"picking gauge wave scenario",
None))
846 floatparams.update({
"sk":0.0}); floatparams.update({
"bs":0.0})
847 intparams.update({
"LapseType":0})
848 elif args.scenario==
"dia_gauge":
849 solverconstants+=
"static constexpr int Scenario=3; /* Diagonal Gauge wave */ \n "
850 userinfo.append((
"picking diagonal gauge wave scenario",
None))
851 floatparams.update({
"sk":0.0}); floatparams.update({
"bs":0.0})
852 intparams.update({
"LapseType":0})
853 elif args.scenario==
"linear":
854 solverconstants+=
"static constexpr int Scenario=1; /* Linear wave */ \n "
855 userinfo.append((
"picking linear wave scenario",
None))
856 floatparams.update({
"sk":0.0}); floatparams.update({
"bs":0.0})
857 intparams.update({
"LapseType":0})
858 elif args.scenario==
"flat":
859 solverconstants+=
"static constexpr int Scenario=4; /* flat spacetime */ \n "
860 userinfo.append((
"picking flat scenario",
None))
861 elif (args.scenario==
"two-punctures")
or (args.scenario==
"single-puncture"):
862 solverconstants+=
"static constexpr int Scenario=2; /* Two-puncture */ \n"
863 userinfo.append((
"picking black hole scenario",
None))
865 raise Exception(
"Scenario " + args.scenario +
" is now unknown")
867 for k, v
in floatparams.items(): solverconstants+=
"static constexpr double {} = {};\n".format(
"CCZ4{}".format(k), v)
868 for k, v
in intparams.items(): solverconstants+=
"static constexpr int {} = {};\n".format(
"CCZ4{}".format(k), v)
869 my_solver.add_solver_constants(solverconstants)
871 project.add_solver(my_solver)
873 build_mode = modes[args.mode]
880 floatparams.update({
"domain_r":args.CCZ4domain_r})
881 dr=floatparams[
"domain_r"]
882 offset=[-dr, -dr, -dr]; domain_size=[2*dr, 2*dr, 2*dr]
883 msg =
"domain set as "+str(offset)+
" and "+str(domain_size)
885 userinfo.append((msg,
None))
887 project.set_global_simulation_parameters(
891 args.plot_start_time, args.plot_step_size,
892 periodic_boundary_conditions,
895 userinfo.append((
"plot start time: "+str(args.plot_start_time)+
", plot step size: "+str(args.plot_step_size),
None))
896 userinfo.append((
"Terminal time: "+str(args.end_time),
None))
898 project.set_Peano4_installation(
"../../..", build_mode)
904 if not args.path==
"./":
908 project.set_output_path(path)
909 probe_point = [-12,-12,0.0]
910 project.add_plot_filter( probe_point,[24.0,24.0,0.01],1 )
911 if args.extension==
"Psi4":
912 my_solver.select_dofs_to_print = [0,12,16,17,18,53,54,59,60]
913 elif args.extension==
"adm" or args.extension==
"phy-debug":
923 project.set_load_balancing(
"toolbox::loadbalancing::strategies::SpreadOutHierarchically",
"(new ::exahype2::LoadBalancingConfiguration(0.98))" )
930 if args.add_tracer==1:
931 tracer_particles = project.add_tracer( name=
"Tracer",attribute_count=61 )
933 particle_set=tracer_particles, coordinates=[[0,0,8.0],[0,0,-8.0],[8.0,8.0,0],[-8.0,-8.0,0]])
938 init_action_set.priority = 0
939 project.add_action_set_to_initialisation( init_action_set )
953 project_on_tracer_properties_kernel=
"::exahype2::fv::projectAllValuesOntoParticle_piecewiseLinear",
955 tracer_action_set.priority = my_solver._action_set_update_cell.priority+1
956 project.add_action_set_to_timestepping(tracer_action_set)
957 project.add_action_set_to_initialisation(tracer_action_set)
960 particle_set=tracer_particles,
962 filename=args.path+
"Tracer-test",
963 number_of_entries_between_two_db_flushes=1000,
965 data_delta_between_two_snapsots=1e16,
966 position_delta_between_two_snapsots=1e16,
967 time_delta_between_two_snapsots=0.02
969 dump_action_set.priority = my_solver._action_set_update_cell.priority+2
970 project.add_action_set_to_timestepping(dump_action_set)
972 if args.add_tracer==2:
973 tracer_particles = project.add_tracer( name=
"Tracer",attribute_count=59 )
975 particle_set=tracer_particles, coordinates=[[2.0,0,0],[-2.0,0,0]])
976 init_action_set.priority = 0
977 project.add_action_set_to_initialisation( init_action_set )
990 project_on_tracer_properties_kernel=
"::exahype2::fv::projectAllValuesOntoParticle_piecewiseLinear_explicit_Euler",
991 projection_kernel_arguments=
"""
994 {{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}},
995 fineGridCell{{SOLVER_NAME}}Q.value,
996 fineGridCell{{SOLVER_NAME}}CellLabel.getTimeStepSize(),
1002 tracer_action_set.priority = my_solver._action_set_compute_final_linear_combination.priority+1
1003 project.add_action_set_to_timestepping(tracer_action_set)
1004 project.add_action_set_to_initialisation(tracer_action_set)
1007 particle_set=tracer_particles,
1009 filename=args.path+
"Tracer-test",
1010 number_of_entries_between_two_db_flushes=500,
1012 data_delta_between_two_snapsots=1e16,
1013 position_delta_between_two_snapsots=1e16,
1014 time_delta_between_two_snapsots=0.02
1016 dump_action_set.priority = my_solver._action_set_compute_final_linear_combination.priority+2
1017 project.add_action_set_to_timestepping(dump_action_set)
1022 peano4_project = project.generate_Peano4_project(verbose=
True)
1024 if args.scenario==
"gauge" or args.scenario==
"linear" or args.scenario==
"dia_gauge" or args.scenario==
"flat":
1026 elif args.scenario==
"two-punctures" or args.scenario==
"single-puncture":
1033 peano4_project.output.makefile.add_linker_flag(
"-lm -lgsl -lgslcblas" )
1034 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/TP_Utilities.cpp" )
1035 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/TP_Parameters.cpp" )
1036 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/TP_Logging.cpp" )
1037 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/TwoPunctures.cpp" )
1038 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/CoordTransf.cpp" )
1039 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/Equations.cpp" )
1040 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/FuncAndJacobian.cpp" )
1041 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/Newton.cpp" )
1042 peano4_project.output.makefile.add_CXX_flag(
"-DIncludeTwoPunctures" )
1044 raise Exception(
"Scenario " + args.scenario +
" is now unknown")
1046 peano4_project.output.makefile.add_CXX_flag(
"-DCCZ4EINSTEIN" )
1047 peano4_project.output.makefile.add_cpp_file(
"InitialValues.cpp" )
1048 peano4_project.output.makefile.add_cpp_file(
"CCZ4Kernels.cpp" )
1081 peano4_project.generate( throw_away_data_after_generation=
False )
1083 peano4_project.build( make_clean_first =
True )
1086 userinfo.append((
"the executable file name: "+exe,
None))
1087 userinfo.append((
"output directory: "+path,
None))
1088 print(
"=========================================================")
1089 if not args.add_tracer==0:
1090 userinfo.append((
"tracer output file: "+args.path+
"Tracer-test",
None))
1091 if len(userinfo) >0:
1092 print(
"The building information:")
1093 for msg, exception
in userinfo:
1094 if exception
is None:
1096 else: print(msg,
"Exception: {}".format(exception))
1099 print(
"=========================================================")
postprocess_updated_patch
_source_term_implementation
__init__(self, name, patch_size, min_mesh_unit_h, max_mesh_unit_h, cfl, domain_r, KOSig)
_fused_compute_kernel_call_cpu
The Gauss-Legendre Basis is by construction the only basis which yields diagonal mass matrices.
A very simple Poisson equation system solver to identify AMR transitions.
RKDG solver with global adaptive time step.
RKDG solver with Rusanov Riemann solver employing global adaptive time stepping.
Dump the tracer data into a csv database.
Particle tracing over the Finite Volumes solver.
Basically superclass, though we add these numbers.
add_adm_constriants(self)
@add adm constriants (Hamilton and Momentum)
CoordListFromFile(file, scale)
add_Psi4W(self)
add psi4 writer
add_intermediate_quantities(self)
@add adm intermediate quantites
add_puncture_tracker(self)
@add
get_user_action_set_includes(self)
We take this routine to add a few additional include statements.
create_compute_kernel_for_FD4(flux_implementation, ncp_implementation, source_implementation, compute_max_eigenvalue_of_next_time_step, solver_variant, kernel_variant, KOSigma)
I return only the unqualified function call, i.e.