Peano
CCZ4SBH_FD4.cpp
Go to the documentation of this file.
1 // This file is part of the ExaHyPE2 project. For conditions of distribution and
2 // use, please see the copyright notice at www.peano-framework.org
3 #include "CCZ4SBH_FD4.h"
4 
5 #include "exahype2/RefinementControl.h"
6 #include "repositories/SolverRepository.h"
7 
8 tarch::logging::Log benchmarks::exahype2::ccz4::CCZ4SBH_FD4::_log("benchmarks::exahype2::ccz4::CCZ4SBH_FD4");
9 
11 
13  if (twoPunctures == nullptr) {
15 
16  // first we set the parameter. TODO:find a way to read parameter from python script
17  // int swi=0;//0--single black hole, 1--BBH hoc, 2--BBH rotation, 3--GW150914
18 
19  twoPunctures->par_b = 1.0;
20  twoPunctures->center_offset[0] = -1.0;
21  twoPunctures->center_offset[1] = 0.0;
22  twoPunctures->center_offset[2] = 0.0;
23  twoPunctures->target_M_plus = 1.0; // adm mass
24  twoPunctures->par_P_plus[0] = 0.0;
25  twoPunctures->par_P_plus[1] = 0.0;
26  twoPunctures->par_P_plus[2] = 0.0; // linear momentum
27  twoPunctures->par_S_plus[0] = 0.0;
28  twoPunctures->par_S_plus[1] = 0.0;
29  twoPunctures->par_S_plus[2] = 0.0; // spin
30  twoPunctures->target_M_minus = 0.0; // adm mass
31  twoPunctures->par_P_minus[0] = 0.0;
32  twoPunctures->par_P_minus[1] = 0.0;
33  twoPunctures->par_P_minus[2] = 0.0; // linear momentum
34  twoPunctures->par_S_minus[0] = 0.0;
35  twoPunctures->par_S_minus[1] = 0.0;
36  twoPunctures->par_S_minus[2] = 0.0; // spin
37  twoPunctures->grid_setup_method = "evaluation"; // evaluation or Taylor expansion
38  twoPunctures->TP_epsilon = 1e-6;
39 
41 
42  // then solve the equation
43  twoPunctures->Run();
44  }
45 }
46 
48  const double* NOALIAS Q, // Q[59+0]
49  const tarch::la::Vector<DIMENSIONS, double>& volumeX,
50  const tarch::la::Vector<DIMENSIONS, double>& meshCellH,
51  double t
52 ) {
53  return tarch::la::norm2(volumeX) - std::sqrt(DIMENSIONS)*meshCellH(0) < BlackHoleFVRegion
54  ? ::exahype2::RefinementCommand::Refine
55  : ::exahype2::RefinementCommand::Keep;
56 }
57 
59 
61  double* NOALIAS Q,
62  const tarch::la::Vector<DIMENSIONS, double>& meshCellCentre,
63  const tarch::la::Vector<DIMENSIONS, double>& meshCellH,
64  bool gridIsConstructed
65 ) {
66  logTraceInWith3Arguments("initialCondition(...)", meshCellCentre, meshCellH, gridIsConstructed);
67 
68  applications::exahype2::ccz4::ApplyTwoPunctures(Q, meshCellCentre, 0, twoPunctures, not gridIsConstructed);
69 
70  logTraceOut("initialCondition(...)");
71 }
72 
74  double globalMinTimeStamp, double globalMaxTimeStamp, double globalMinTimeStepSize, double globalMaxTimeStepSize
75 ) {
76  AbstractCCZ4SBH_FD4::startTimeStep(
77  globalMinTimeStamp, globalMaxTimeStamp, globalMinTimeStepSize, globalMaxTimeStepSize
78  );
79 
80 #if defined(CoupleWithFV)
81  if (isFirstGridSweepOfTimeStep()) {
82  double fvTimeStepSize = repositories::instanceOfCCZ4SBH_FV.getAdmissibleTimeStepSize();
83  double newTimeStepSize = std::min(fvTimeStepSize, _admissibleTimeStepSize);
84  if (tarch::la::smaller(newTimeStepSize, fvTimeStepSize)) {
85  logInfo(
86  "startTimeStep(...)",
87  "reduce admissible time step size from dt_{dg}="
88  << _admissibleTimeStepSize << " vs dt_{fv}=" << fvTimeStepSize << " to dt=" << newTimeStepSize
89  << " (previously reported time step sizes for this step are invalid)"
90  );
91  }
92  _admissibleTimeStepSize = newTimeStepSize;
93  repositories::instanceOfCCZ4SBH_FV.reduceAdmissibleTimeStepSize(newTimeStepSize);
94  }
95 #endif
96 }
static tarch::logging::Log _log
Definition: CCZ4SBH_FD4.h:27
CCZ4SBH_FD4()
Initialise the two punctures object if required.
Definition: CCZ4SBH_FD4.cpp:58
virtual ::exahype2::RefinementCommand refinementCriterion(const double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &meshCellCentre, const tarch::la::Vector< DIMENSIONS, double > &meshCellH, double t) override
Refinement criterion.
Definition: CCZ4SBH_FD4.cpp:47
virtual void initialCondition(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &meshCellCentre, const tarch::la::Vector< DIMENSIONS, double > &meshCellH, bool gridIsConstructed) override
Definition: CCZ4SBH_FD4.cpp:60
virtual void startTimeStep(double globalMinTimeStamp, double globalMaxTimeStamp, double globalMinTimeStepSize, double globalMaxTimeStepSize) override
Start a new time step.
Definition: CCZ4SBH_FD4.cpp:73
double norm2(double *v, int n)
static double min(double const x, double const y)
void ApplyTwoPunctures(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &X, double t, TP::TwoPunctures *tp, bool low_res)
TP::TwoPunctures * twoPunctures
Definition: CCZ4SBH_FV.h:14
double par_S_plus[3]
Definition: TP_Parameters.h:46
std::string grid_setup_method
Definition: TP_Parameters.h:23
double par_P_plus[3]
Definition: TP_Parameters.h:44
void PrintParameters()
double par_S_minus[3]
Definition: TP_Parameters.h:47
double center_offset[3]
Definition: TP_Parameters.h:48
double target_M_minus
Definition: TP_Parameters.h:43
double par_P_minus[3]
Definition: TP_Parameters.h:45
double target_M_plus
Definition: TP_Parameters.h:42