118 def __init__(self, name, patch_size, min_volume_h, max_volume_h, cfl, domain_r, KOSig):
140 number_of_unknowns = sum(unknowns.values())
143#include "../CCZ4Kernels.h"
149 name=name, patch_size=patch_size,
150 unknowns=number_of_unknowns,
151 auxiliary_variables=0,
152 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
153 normalised_time_step_size=1e-2
158 name=name, patch_size=patch_size,
159 unknowns=number_of_unknowns,
160 auxiliary_variables=0,
161 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
168 name=name, patch_size=patch_size,
169 unknowns=number_of_unknowns,
170 auxiliary_variables=0,
171 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
172 time_step_relaxation=cfl
175 if args.implementation==
"fd4-rk1-adaptive" or args.implementation==
"fd4-rk1-adaptive-enclave":
181 name=name, patch_size=patch_size, rk_order=rk_order,
182 unknowns=number_of_unknowns,
183 auxiliary_variables=0,
184 min_meshcell_h=min_volume_h, max_meshcell_h=max_volume_h,
185 time_step_relaxation=cfl,
189 if args.implementation==
"fd4-rk1-adaptive" or args.implementation==
"fd4-rk1-adaptive-enclave":
195 name=name, patch_size=patch_size, rk_order=rk_order,
196 unknowns=number_of_unknowns,
197 auxiliary_variables=0,
198 min_meshcell_h=min_volume_h, max_meshcell_h=max_volume_h,
199 time_step_relaxation=cfl,
201 pde_terms_without_state=
True
204 if args.implementation==
"fd4-rk1-fixed":
210 name=name, patch_size=patch_size, rk_order=rk_order,
211 unknowns=number_of_unknowns,
212 auxiliary_variables=0,
213 min_meshcell_h=min_volume_h, max_meshcell_h=max_volume_h,
214 normalised_time_step_size=0.01,
223 face_projections = exahype2.solvers.rkdg.FaceProjections.Solution,
224 unknowns=number_of_unknowns,
225 auxiliary_variables=0,
226 min_cell_h=min_volume_h, max_cell_h=max_volume_h,
227 time_step_relaxation=cfl
232 name=name, patch_size=patch_size,
233 unknowns=number_of_unknowns,
234 auxiliary_variables=0,
235 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
236 time_step_relaxation=cfl
244 self.set_implementation(
245 boundary_conditions=exahype2.solvers.PDETerms.User_Defined_Implementation,
246 ncp=exahype2.solvers.PDETerms.User_Defined_Implementation,
247 flux=exahype2.solvers.PDETerms.None_Implementation,
248 source_term=exahype2.solvers.PDETerms.User_Defined_Implementation,
249 refinement_criterion = exahype2.solvers.PDETerms.User_Defined_Implementation,
250 eigenvalues = exahype2.solvers.PDETerms.User_Defined_Implementation
258 compute_max_eigenvalue_of_next_time_step =
True,
259 solver_variant = exahype2.solvers.rkfd.kernels.SolverVariant.Multicore,
260 kernel_variant = exahype2.solvers.rkfd.kernels.KernelVariant.BatchedAoSHeap,
261 KOSigma = self._KO_Sigma
264 self.switch_to_heap_storage(
265 exahype2.solvers.rkfd.Storage.Heap, exahype2.solvers.rkfd.Storage.Heap
280 constexpr int itmax = {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}} * {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}};
284 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}};
294 constexpr int itmax = {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}};
298 constexpr int itmax = {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}};
304 for (int i=0;i<itmax;i++)
306 applications::exahype2::ccz4::enforceCCZ4constraints( newQ+index );
307 index += {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}};
314 SuperClass.create_action_sets(self)
315 self._action_set_couple_resolution_transitions_and_handle_dynamic_mesh_refinement.additional_includes +=
"""
316#include "../CCZ4Kernels.h"
321 We take this routine to add a few additional include statements.
323 return SuperClass.get_user_action_set_includes(self) + self._my_user_includes
327 @add adm constriants (Hamilton and Momentum)
329 self._auxiliary_variables = 7
331 self._my_user_includes +=
"""
332 #include "../CCZ4Kernels.h"
335 self._preprocess_reconstructed_patch =
"""
336 const int patchSize = """ + str( self._patch.dim[0] ) +
""";
337 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
340 const int overlap=3; //make sure you are using fd4 solver!
342 //if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()==FiniteVolumeCCZ4::SolverState::RungeKuttaSubStep0) {
343 if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction) {
344 dfor(cell,patchSize) {
345 tarch::la::Vector<Dimensions,int> currentCell = cell + tarch::la::Vector<Dimensions,int>(overlap);
347 double gradQ[3*59]={ 0 };
349 for (int d=0; d<3; d++) {
350 tarch::la::Vector<Dimensions,int> leftCell = currentCell;
351 tarch::la::Vector<Dimensions,int> rightCell = currentCell;
354 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*overlap);
355 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*overlap);
356 for(int i=0; i<59; i++) {
357 gradQ[d*59+i] = ( oldQWithHalo[rightCellSerialised*(59+n_a_v)+i] - oldQWithHalo[leftCellSerialised*(59+n_a_v)+i] ) / 2.0 / volumeH;
361 const int cellSerialised = peano4::utils::dLinearised(currentCell, patchSize + 2*overlap);
363 double constraints[7]={0,0,0,0,0,0,0};
364 admconstraints(constraints, oldQWithHalo+cellSerialised*(59+n_a_v), gradQ);
365 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, 0, 59, n_a_v);
366 for (int i=0;i<7;i++){
367 fineGridCellFiniteVolumeCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+i) ] = constraints[i];
373 self.create_data_structures()
374 self.create_action_sets()
380 self._auxiliary_variables = 2
382 self._my_user_includes +=
"""
383 #include "../libtwopunctures/TP_PunctureTracker.h"
384 #include "../CCZ4Kernels.h"
387 self._preprocess_reconstructed_patch =
"""
388 const int patchSize = """ + str( self._patch.dim[0] ) +
""";
389 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
392 const int overlap=3; //make sure you are using fd4 solver!
394 //if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()==FiniteVolumeCCZ4::SolverState::RungeKuttaSubStep0) {
395 if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction) {
396 dfor(cell,patchSize) {
397 tarch::la::Vector<Dimensions,int> currentCell = cell + tarch::la::Vector<Dimensions,int>(overlap);
399 double gradQ[3*59]={ 0 };
401 for (int d=0; d<3; d++) {
402 tarch::la::Vector<Dimensions,int> leftCell = currentCell;
403 tarch::la::Vector<Dimensions,int> rightCell = currentCell;
406 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*overlap);
407 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*overlap);
408 for(int i=0; i<59; i++) {
409 gradQ[d*59+i] = ( oldQWithHalo[rightCellSerialised*(59+n_a_v)+i] - oldQWithHalo[leftCellSerialised*(59+n_a_v)+i] ) / 2.0 / volumeH;
413 const int cellSerialised = peano4::utils::dLinearised(currentCell, patchSize + 2*overlap);
415 double Psi4[2]={0,0};
416 double currentPosition[3];
417 for (int d=0; d<3; d++) currentPosition[d]=marker.getOffset()(d)+(cell(d)+0.5)*volumeH;
418 Psi4Calc(Psi4, oldQWithHalo+cellSerialised*(59+n_a_v), gradQ, currentPosition);
419 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, 0, 59, n_a_v);
420 fineGridCellFiniteVolumeCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+0) ] = Psi4[0];
421 fineGridCellFiniteVolumeCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+1) ] = Psi4[1];
426 self.create_data_structures()
427 self.create_action_sets()
431 @add adm intermediate quantites
433 self._auxiliary_variables = 15
435 self._my_user_includes +=
"""
436 #include "../CCZ4Kernels.h"
439 self._preprocess_reconstructed_patch =
"""
440 const int patchSize = """ + str( self._patch.dim[0] ) +
""";
441 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
443 const int n_a_v=""" + str( self._auxiliary_variables ) +
""";
444 const int overlap=3; //make sure you are using fd4 solver!
446 //if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()==FiniteVolumeCCZ4::SolverState::RungeKuttaSubStep0) {
447 if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction) {
448 dfor(cell,patchSize) {
449 tarch::la::Vector<Dimensions,int> currentCell = cell + tarch::la::Vector<Dimensions,int>(overlap);
451 double gradQ[3*59]={ 0 };
453 for (int d=0; d<3; d++) {
454 tarch::la::Vector<Dimensions,int> leftCell = currentCell;
455 tarch::la::Vector<Dimensions,int> leftCell2 = currentCell;
456 tarch::la::Vector<Dimensions,int> rightCell = currentCell;
457 tarch::la::Vector<Dimensions,int> rightCell2 = currentCell;
458 leftCell(d) -= 1; leftCell2(d) -= 2;
459 rightCell(d) += 1; rightCell2(d) += 2;
460 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*overlap);
461 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*overlap);
462 const int leftCellSerialised2 = peano4::utils::dLinearised(leftCell2, patchSize + 2*overlap);
463 const int rightCellSerialised2 = peano4::utils::dLinearised(rightCell2,patchSize + 2*overlap);
464 for(int i=0; i<59; i++) {
465 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]
466 +(1.0/12.0)*oldQWithHalo[leftCellSerialised2*(59+n_a_v)+i] - (1.0/12.0)*oldQWithHalo[rightCellSerialised2*(59+n_a_v)+i] )/volumeH;
470 const int cellSerialised = peano4::utils::dLinearised(currentCell, patchSize + 2*overlap);
472 double terms[""" + str( self._auxiliary_variables ) +
"""]={0,0,0,0,0,0,0};
473 TestingOutput(terms, oldQWithHalo+cellSerialised*(59+n_a_v), gradQ);
474 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, 0, 59, n_a_v);
475 for (int i=0;i<""" + str( self._auxiliary_variables ) +
""";i++){
476 fineGridCellFiniteVolumeCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+i) ] = terms[i];
482 self.create_data_structures()
483 self.create_action_sets()
489 self._auxiliary_variables = 0
491 self._user_solver_includes +=
"""
492 #include "libtwopunctures/TP_PunctureTracker.h"
493 #include "CCZ4Kernels.h"
505 self._preprocess_reconstructed_patch =
"""
506 const int patchSize = """ + str( self._patch.dim[0] ) +
""";
507 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
510 std::string att="_"""+args.exe_name+
""".txt"; std::string p1="puncture1"; std::string p2="puncture2"; std::string tem="ztem";
511 const int n_a_v=""" + str( self._auxiliary_variables ) +
""";
512 const double overlap=3;
514 if (tarch::la::equals(timeStamp,0.0)){//initialization
515 fin.open((p1+att),std::ios::out|std::ios::trunc);
516 fin << "2.0 0.0 0.0 0.0 0.0" << std::endl;//4.461538
518 fin.open((p2+att),std::ios::out|std::ios::trunc);
519 fin << "-2.0 0.0 0.0 0.0 0.0" << std::endl;//-5.538462
521 //fin.open((tem+att),std::ios::out|std::ios::trunc);
522 //fin << "tem file" << std::endl;
525 fin.open((p1+att),std::ios::in);
526 std::string pos=getLastLine(fin);
528 double coor1[5]={0};//read in previous coordinates
529 CoorReadIn(coor1,pos);
530 fin.open((p2+att),std::ios::in);
531 std::string pos2=getLastLine(fin);
534 CoorReadIn(coor2,pos2);
536 if (marker.isContained(coor1)){
537 tarch::la::Vector<Dimensions*2,int> IndexOfCell=FindCellIndex(coor1,marker.getOffset(),volumeH,patchSize); //find where the puncture is
538 tarch::la::Vector<Dimensions,int> IndexForInterpolate[8];
539 FindInterIndex(IndexForInterpolate,IndexOfCell);//find the closest 8 cells
541 for (int i=0;i<8;i++){
542 int Lindex=peano4::utils::dLinearised(IndexForInterpolate[i], patchSize + 2*overlap);
543 for (int j=0;j<Dimensions;j++) {raw[i*inter_number+j]=oldQWithHalo[Lindex*(59+n_a_v)+17+j];} //read in corresponding beta
544 raw[i*inter_number+3]=oldQWithHalo[Lindex*(59+n_a_v)+16];
545 //std::cout << IndexForInterpolate[i](0) << " " << IndexForInterpolate[i](1) << " " << IndexForInterpolate[i](2) << std::endl;
546 //std::cout << raw[i*inter_number+0] << " " << raw[i*inter_number+1] << " " << raw[i*inter_number+2] << " " << raw[i*inter_number+3] << std::endl;
547 //::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, overlap, 59, n_a_v);
548 //std::cout << oldQWithHalo[enumeratorWithAuxiliaryVariables(0,IndexForInterpolate[i],0)] << std::endl;
550 double result[inter_number];
551 Interpolation(result,IndexForInterpolate,raw,coor1,marker.getOffset(),volumeH,patchSize);
553 coor1[0]-=timeStepSize*result[0]; coor1[1]-=timeStepSize*result[1]; coor1[2]-=timeStepSize*result[2];//updates position
554 fin.open((p1+att),std::ios::app);//output
555 fin << std::setprecision (17) << coor1[0] << " " << coor1[1];
556 fin << " " << coor1[2] << " " << timeStamp << " " << result[3] << std::endl;
558 //fin.open((tem+att),std::ios::app);
559 //fin << "for cellindex" << IndexOfCell(0) << " " << IndexOfCell(1) << " " << IndexOfCell(2) << " " << IndexOfCell(3) << " " << IndexOfCell(4) << " " << IndexOfCell(5) << std::endl;
560 //for (int i=0;i<8;i++){
561 //fin << IndexForInterpolate[i](0) << " " << IndexForInterpolate[i](1) << " " << IndexForInterpolate[i](2) << std::endl;
562 //fin << raw[i*inter_number+0] << " " << raw[i*inter_number+1] << " " << raw[i*inter_number+2] << " " << raw[i*inter_number+3] << std::endl;
565 //fin << "after inter" << result[0] << " " << result[1] << " " << result[2] << " " << result[3] << " " << timeStamp << std::endl;
568 if (marker.isContained(coor2)){//do the same for the second puncutre
569 tarch::la::Vector<Dimensions*2,int> IndexOfCell=FindCellIndex(coor2,marker.getOffset(),volumeH,patchSize);
570 tarch::la::Vector<Dimensions,int> IndexForInterpolate[8];
571 FindInterIndex(IndexForInterpolate,IndexOfCell);
572 double raw[8*inter_number];
573 for (int i=0;i<8;i++){
574 int Lindex=peano4::utils::dLinearised(IndexForInterpolate[i], patchSize + 2*overlap);
575 for (int j=0;j<Dimensions;j++) {raw[i*inter_number+j]=oldQWithHalo[Lindex*(59+n_a_v)+17+j];}
576 raw[i*inter_number+3]=oldQWithHalo[Lindex*(59+n_a_v)+16];
578 double result[inter_number];
579 Interpolation(result,IndexForInterpolate,raw,coor2,marker.getOffset(),volumeH,patchSize);
581 coor2[0]-=timeStepSize*result[0]; coor2[1]-=timeStepSize*result[1]; coor2[2]-=timeStepSize*result[2];
582 fin.open((p2+att),std::ios::app);
583 fin << std::setprecision (17) << coor2[0] << " " << coor2[1];
584 fin << " " << coor2[2] << " " << timeStamp << " " << result[3] << std::endl;
590 self.create_data_structures()
591 self.create_action_sets()
600 if args.exe_name!=
"":
603 if not args.tra_name==
"de":
604 exe +=
"_" + args.tra_name
614 if SuperClass==exahype2.solvers.aderdg.NonFusedGenericRusanovFixedTimeStepSize:
618 time_step_size = 0.001
619 except Exception
as e:
628 except Exception
as e:
630 msg =
"Warning: RKDG not supported on this machine"
632 userinfo.append((msg,e))
635 solver_name =
"ADERDG" + solver_name
637 solver_name =
"RKDG" + solver_name
639 solver_name =
"FiniteVolume" + solver_name
641 if args.DC_flag==
True:
646 print(
"No minimal mesh size chosen. Set it to max mesh size (regular grid)" )
650 my_solver = exahype2.solvers.aderdg.NonFusedGenericRusanovFixedTimeStepSize(
651 solver_name, order, unknowns, 0,
652 exahype2.solvers.aderdg.Polynomials.Gauss_Legendre,
653 min_h, args.max_h, time_step_size,
655 ncp = exahype2.solvers.PDETerms.User_Defined_Implementation,
656 sources = exahype2.solvers.PDETerms.User_Defined_Implementation
659 my_solver =
CCZ4Solver(solver_name, args.patch_size, min_h, args.max_h, args.cfl, args.CCZ4domain_r,args.CCZ4KOSigma)
660 userinfo.append((
"CFL ratio set as "+str(args.cfl),
None))
662 userinfo.append((
"The solver is "+args.implementation,
None))
668 if args.marker==
"poisson":
670 project.add_solver( amr_label )
671 my_solver._auxiliary_variables+=1
672 print(
"Add Poisson AMR marker for variable {}".format(my_solver._auxiliary_variables-1) )
673 amr_label.couple_with_FV_solver( my_solver, my_solver._auxiliary_variables-1 )
679 if args.interpolation==
"order-2":
682 if args.interpolation==
"constant":
683 my_solver.interpolation =
"piecewise_constant"
684 print(
"Interpolation rule: piecewise_constant" )
685 if args.interpolation==
"linear-constant-extrap":
686 my_solver.interpolation =
"linear_with_constant_extrapolation"
687 print(
"Interpolation rule: linear constant extrapolation" )
688 if args.interpolation==
"linear-linear-extrap":
689 my_solver.interpolation =
"linear_with_linear_extrapolation"
690 print(
"Interpolation rule: linear extrapolation" )
691 if args.interpolation==
"linear-con-extrap-lin-normal-interp":
692 my_solver.interpolation =
"linear_with_constant_extrapolation_and_linear_normal_interpolation"
693 print(
"Interpolation rule: linear+constant extrapolation and linear normal interpolation" )
695 if args.interpolation==
"order-2":
696 my_solver.interpolation =
"linear"
703 tem_interp=[
"TP_constant",
"TP_linear_with_linear_extrap_normal_interp"]
704 tem_restrict=[
"TP_inject_normal_extrap",
"TP_average_normal_extrap"]
705 if (
"fd4-rk" in args.implementation):
706 exahype2.solvers.rkfd.fd4.switch_to_FD4_tensor_product_interpolation( my_solver, tem_interp[1] )
707 exahype2.solvers.rkfd.fd4.switch_to_FD4_tensor_product_restriction( my_solver, tem_restrict[1] )
708 userinfo.append((
"FD4 Interpolation: " + tem_interp[1] +
" & Restriction: " + tem_restrict[1],
None))
719 if args.extension==
"adm":
720 my_solver.add_adm_constriants()
721 if args.extension==
"Psi4":
722 my_solver.add_Psi4W()
723 if args.extension==
"phy-debug":
724 my_solver.add_intermediate_quantities()
725 if args.extension==
"PT":
726 my_solver.add_puncture_tracker()
733 for k, v
in intparams.items():
734 intparams.update({k:eval(
"args.CCZ4{}".format(k))})
735 for k, v
in floatparams.items():
736 floatparams.update({k:eval(
"args.CCZ4{}".format(k))})
738 if args.scenario==
"two-punctures":
739 msg =
"Periodic BC deactivated because you pick Puncture scenario\nInitialize binary black holes"
741 periodic_boundary_conditions = [
False,
False,
False]
742 intparams.update({
"swi":2})
744 userinfo.append((msg,
None))
745 elif args.scenario==
"single-puncture":
746 msg =
"Periodic BC deactivated because you pick Puncture scenario\nInitialize single black hole"
748 periodic_boundary_conditions = [
False,
False,
False]
749 intparams.update({
"swi":0})
750 userinfo.append((msg,
None))
751 elif args.periodic_bc==
True:
752 msg =
"Periodic BC set"
754 periodic_boundary_conditions = [
True,
True,
True]
755 userinfo.append((msg,
None))
757 msg =
"WARNING: Periodic BC deactivated by hand"
759 periodic_boundary_conditions = [
False,
False,
False]
760 userinfo.append((msg,
None))
762 if args.sommerfeld_bc==
True:
763 msg =
"set Sommerfeld boundary condition"
764 userinfo.append((msg,
None))
765 periodic_boundary_conditions = [
False,
False,
False]
766 if args.scenario==
"single-puncture":
767 my_solver._action_set_handle_boundary.TemplateHandleBoundary_KernelCalls =
"""
768 ::exahype2::fd::applySommerfeldConditions(
770 const double * __restrict__ Q,
771 const tarch::la::Vector<Dimensions,double>& faceCentre,
772 const tarch::la::Vector<Dimensions,double>& gridCellH,
777 return repositories::{{SOLVER_INSTANCE}}.maxEigenvalue( Q, faceCentre, gridCellH, t, dt, normal );
780 double * __restrict__ Q,
781 const tarch::la::Vector<Dimensions,double>& faceCentre,
782 const tarch::la::Vector<Dimensions,double>& gridCellH
784 for (int i=0; i<"""+str(my_solver._unknowns+my_solver._auxiliary_variables)+
"""; i++) {
787 Q[0] = 1.0; Q[3] = 1.0; Q[5] = 1.0;
788 //const double r=tarch::la::norm2(faceCentre);
789 //Q[16] = 0.5*(1+(1-1.0/2/r)/(1+1.0/2/r));
790 //Q[54] = 1/(1+1.0/2/r)/(1+1.0/2/r);
791 Q[16] = 1.0; Q[54] = 1.0;
795 {{FACE_METADATA_ACCESSOR}}.getOldTimeStamp(marker.getSelectedFaceNumber()<Dimensions ? 1 : 0),
796 repositories::{{SOLVER_INSTANCE}}.getMinTimeStepSize(),
797 {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}},
799 {{NUMBER_OF_UNKNOWNS}},
800 {{NUMBER_OF_AUXILIARY_VARIABLES}},
801 marker.getSelectedFaceNumber(),
803 fineGridFace{{UNKNOWN_IDENTIFIER}}Old.value,
804 fineGridFace{{UNKNOWN_IDENTIFIER}}New.value
808 my_solver._action_set_handle_boundary.TemplateHandleBoundary_KernelCalls =
"""
809 ::exahype2::fd::applySommerfeldConditions(
811 const double * __restrict__ Q,
812 const tarch::la::Vector<Dimensions,double>& faceCentre,
813 const tarch::la::Vector<Dimensions,double>& gridCellH,
818 return repositories::{{SOLVER_INSTANCE}}.maxEigenvalue( Q, faceCentre, gridCellH, t, dt, normal );
821 double * __restrict__ Q,
822 const tarch::la::Vector<Dimensions,double>& faceCentre,
823 const tarch::la::Vector<Dimensions,double>& gridCellH
825 for (int i=0; i<"""+str(my_solver._unknowns+my_solver._auxiliary_variables)+
"""; i++) {
828 Q[0] = 1.0; Q[3] = 1.0; Q[5] = 1.0;
829 Q[16] = 1.0; Q[54] = 1.0;
833 {{FACE_METADATA_ACCESSOR}}.getOldTimeStamp(marker.getSelectedFaceNumber()<Dimensions ? 1 : 0),
834 repositories::{{SOLVER_INSTANCE}}.getMinTimeStepSize(),
835 {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}},
837 {{NUMBER_OF_UNKNOWNS}},
838 {{NUMBER_OF_AUXILIARY_VARIABLES}},
839 marker.getSelectedFaceNumber(),
841 fineGridFace{{UNKNOWN_IDENTIFIER}}Old.value,
842 fineGridFace{{UNKNOWN_IDENTIFIER}}New.value
850 if args.scenario==
"gauge":
851 solverconstants+=
"static constexpr int Scenario=0; /* Gauge wave */ \n "
852 userinfo.append((
"picking gauge wave scenario",
None))
853 floatparams.update({
"sk":0.0}); floatparams.update({
"bs":0.0})
854 intparams.update({
"LapseType":0})
855 elif args.scenario==
"dia_gauge":
856 solverconstants+=
"static constexpr int Scenario=3; /* Diagonal Gauge wave */ \n "
857 userinfo.append((
"picking diagonal gauge wave scenario",
None))
858 floatparams.update({
"sk":0.0}); floatparams.update({
"bs":0.0})
859 intparams.update({
"LapseType":0})
860 elif args.scenario==
"linear":
861 solverconstants+=
"static constexpr int Scenario=1; /* Linear wave */ \n "
862 userinfo.append((
"picking linear wave scenario",
None))
863 floatparams.update({
"sk":0.0}); floatparams.update({
"bs":0.0})
864 intparams.update({
"LapseType":0})
865 elif args.scenario==
"flat":
866 solverconstants+=
"static constexpr int Scenario=4; /* flat spacetime */ \n "
867 userinfo.append((
"picking flat scenario",
None))
868 elif (args.scenario==
"two-punctures")
or (args.scenario==
"single-puncture"):
869 solverconstants+=
"static constexpr int Scenario=2; /* Two-puncture */ \n"
870 userinfo.append((
"picking black hole scenario",
None))
872 raise Exception(
"Scenario " + args.scenario +
" is now unknown")
874 for k, v
in floatparams.items(): solverconstants+=
"static constexpr double {} = {};\n".format(
"CCZ4{}".format(k), v)
875 for k, v
in intparams.items(): solverconstants+=
"static constexpr int {} = {};\n".format(
"CCZ4{}".format(k), v)
876 my_solver.add_solver_constants(solverconstants)
878 project.add_solver(my_solver)
880 build_mode = modes[args.mode]
887 floatparams.update({
"domain_r":args.CCZ4domain_r})
888 dr=floatparams[
"domain_r"]
889 offset=[-dr, -dr, -dr]; domain_size=[2*dr, 2*dr, 2*dr]
890 msg =
"domain set as "+str(offset)+
" and "+str(domain_size)
892 userinfo.append((msg,
None))
894 project.set_global_simulation_parameters(
898 args.plot_start_time, args.plot_step_size,
899 periodic_boundary_conditions,
902 userinfo.append((
"plot start time: "+str(args.plot_start_time)+
", plot step size: "+str(args.plot_step_size),
None))
903 userinfo.append((
"Terminal time: "+str(args.end_time),
None))
905 project.set_Peano4_installation(
"../../..", build_mode)
911 if not args.path==
"./":
915 project.set_output_path(path)
916 probe_point = [-12,-12,0.0]
917 project.add_plot_filter( probe_point,[24.0,24.0,0.01],1 )
918 if args.extension==
"Psi4":
919 my_solver.select_dofs_to_print = [0,12,16,17,18,53,54,59,60]
920 elif args.extension==
"adm" or args.extension==
"phy-debug":
930 project.set_load_balancing(
"toolbox::loadbalancing::strategies::SpreadOutHierarchically",
"(new ::exahype2::LoadBalancingConfiguration(0.98))" )
938 if args.add_tracer==1:
939 tracer_particles = project.add_tracer( name=
"Tracer",attribute_count=61 )
941 particle_set=tracer_particles, coordinates=[[0,0,8.0],[0,0,-8.0],[8.0,8.0,0],[-8.0,-8.0,0]])
946 init_action_set.priority = 0
947 project.add_action_set_to_initialisation( init_action_set )
961 project_on_tracer_properties_kernel=
"::exahype2::fv::projectAllValuesOntoParticle_piecewiseLinear",
963 tracer_action_set.priority = my_solver._action_set_update_cell.priority+1
964 project.add_action_set_to_timestepping(tracer_action_set)
965 project.add_action_set_to_initialisation(tracer_action_set)
968 particle_set=tracer_particles,
970 filename=args.path+
"Tracer-test",
971 number_of_entries_between_two_db_flushes=1000,
973 data_delta_between_two_snapsots=1e16,
974 position_delta_between_two_snapsots=1e16,
975 time_delta_between_two_snapsots=0.02
977 dump_action_set.priority = my_solver._action_set_update_cell.priority+2
978 project.add_action_set_to_timestepping(dump_action_set)
980 if args.add_tracer==2:
981 tracer_particles = project.add_tracer( name=
"Tracer",attribute_count=59 )
983 particle_set=tracer_particles, coordinates=[[2.0,0,0],[-2.0,0,0]])
984 init_action_set.priority = 0
985 project.add_action_set_to_initialisation( init_action_set )
998 project_on_tracer_properties_kernel=
"::exahype2::fv::projectAllValuesOntoParticle_piecewiseLinear_explicit_Euler",
999 projection_kernel_arguments=
"""
1002 {{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}},
1003 fineGridCell{{SOLVER_NAME}}Q.value,
1004 fineGridCell{{SOLVER_NAME}}CellLabel.getTimeStepSize(),
1010 tracer_action_set.priority = my_solver._action_set_compute_final_linear_combination.priority+1
1011 project.add_action_set_to_timestepping(tracer_action_set)
1012 project.add_action_set_to_initialisation(tracer_action_set)
1015 particle_set=tracer_particles,
1017 filename=args.path+
"Tracer-test",
1018 number_of_entries_between_two_db_flushes=500,
1020 data_delta_between_two_snapsots=1e16,
1021 position_delta_between_two_snapsots=1e16,
1022 time_delta_between_two_snapsots=0.02
1024 dump_action_set.priority = my_solver._action_set_compute_final_linear_combination.priority+2
1025 project.add_action_set_to_timestepping(dump_action_set)
1030 peano4_project = project.generate_Peano4_project(verbose=
True)
1032 if args.scenario==
"gauge" or args.scenario==
"linear" or args.scenario==
"dia_gauge" or args.scenario==
"flat":
1034 elif args.scenario==
"two-punctures" or args.scenario==
"single-puncture":
1041 peano4_project.output.makefile.add_linker_flag(
"-lm -lgsl -lgslcblas" )
1042 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/TP_Utilities.cpp" )
1043 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/TP_Parameters.cpp" )
1044 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/TP_Logging.cpp" )
1045 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/TwoPunctures.cpp" )
1046 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/CoordTransf.cpp" )
1047 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/Equations.cpp" )
1048 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/FuncAndJacobian.cpp" )
1049 peano4_project.output.makefile.add_cpp_file(
"libtwopunctures/Newton.cpp" )
1050 peano4_project.output.makefile.add_CXX_flag(
"-DIncludeTwoPunctures" )
1052 raise Exception(
"Scenario " + args.scenario +
" is now unknown")
1054 peano4_project.output.makefile.add_CXX_flag(
"-DCCZ4EINSTEIN" )
1055 peano4_project.output.makefile.add_cpp_file(
"InitialValues.cpp" )
1056 peano4_project.output.makefile.add_cpp_file(
"CCZ4Kernels.cpp" )
1090 if args.DC_flag==
True:
1091 userinfo.append((
"Enable double communication, make sure you are using the Second formulism.",
None))
1093 add_user_defined_actions=
False,
1096 project_patch_onto_faces.guards = [ my_solver._store_cell_data_default_guard()
for x
in range(0,my_solver.number_of_Runge_Kutta_steps()+1) ]
1099 my_solver._store_face_data_default_guard(),
1104 interpolation=my_solver.interpolation,
1105 restriction=my_solver.restriction,
1109 is_enclave_solver =
False,
1111 additional_mesh_traversal.add_action_set( project_patch_onto_faces )
1112 additional_mesh_traversal.add_action_set( roll_over_projected_faces )
1113 additional_mesh_traversal.add_action_set( dynamic_AMR )
1115 project.register_new_user_defined_algorithmic_step( additional_mesh_traversal )
1116 peano4_project.solversteps.add_step( additional_mesh_traversal )
1119 peano4_project.generate( throw_away_data_after_generation=
False )
1120 peano4_project.build( make_clean_first =
True )
1123 userinfo.append((
"the executable file name: "+exe,
None))
1124 userinfo.append((
"output directory: "+path,
None))
1125 print(
"=========================================================")
1126 if not args.add_tracer==0:
1127 userinfo.append((
"tracer output file: "+args.path+
"Tracer-test",
None))
1128 if len(userinfo) >0:
1129 print(
"The building information:")
1130 for msg, exception
in userinfo:
1131 if exception
is None:
1133 else: print(msg,
"Exception: {}".format(exception))
1136 print(
"=========================================================")