Skip to content

Commit d90ed3a

Browse files
Add base compiled code from GRChombo
1 parent 7993ab9 commit d90ed3a

File tree

330 files changed

+57337
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

330 files changed

+57337
-0
lines changed

Examples/BinaryBH/BinaryBHLevel.cpp

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/* GRChombo
2+
* Copyright 2012 The GRChombo collaboration.
3+
* Please refer to LICENSE in GRChombo's root directory.
4+
*/
5+
6+
#include "BinaryBHLevel.hpp"
7+
#include "BinaryBH.hpp"
8+
#include "BoxLoops.hpp"
9+
#include "CCZ4.hpp"
10+
#include "ChiExtractionTaggingCriterion.hpp"
11+
#include "ComputePack.hpp"
12+
#include "Constraints.hpp"
13+
#include "NanCheck.hpp"
14+
#include "PositiveChiAndAlpha.hpp"
15+
#include "SetValue.hpp"
16+
#include "TraceARemoval.hpp"
17+
#include "Weyl4.hpp"
18+
#include "WeylExtraction.hpp"
19+
20+
void BinaryBHLevel::specificAdvance()
21+
{
22+
// Enforce the trace free A_ij condition and positive chi and alpha
23+
BoxLoops::loop(make_compute_pack(TraceARemoval(), PositiveChiAndAlpha()),
24+
m_state_new, m_state_new, INCLUDE_GHOST_CELLS);
25+
26+
// Check for nan's
27+
if (m_p.nan_check)
28+
BoxLoops::loop(NanCheck("NaNCheck in specific Advance: "), m_state_new,
29+
m_state_new, EXCLUDE_GHOST_CELLS, disable_simd());
30+
}
31+
32+
void BinaryBHLevel::initialData()
33+
{
34+
CH_TIME("BinaryBHLevel::initialData");
35+
if (m_verbosity)
36+
pout() << "BinaryBHLevel::initialData " << m_level << endl;
37+
38+
// Set up the compute class for the BinaryBH initial data
39+
BinaryBH binary(m_p.bh1_params, m_p.bh2_params, m_dx);
40+
41+
// First set everything to zero (to avoid undefinded values in constraints)
42+
// then calculate initial data
43+
BoxLoops::loop(make_compute_pack(SetValue(0.), binary), m_state_new,
44+
m_state_new, INCLUDE_GHOST_CELLS);
45+
}
46+
47+
void BinaryBHLevel::preCheckpointLevel()
48+
{
49+
fillAllGhosts();
50+
BoxLoops::loop(Constraints(m_dx), m_state_new, m_state_new,
51+
EXCLUDE_GHOST_CELLS);
52+
}
53+
54+
void BinaryBHLevel::specificEvalRHS(GRLevelData &a_soln, GRLevelData &a_rhs,
55+
const double a_time)
56+
{
57+
// Enforce positive chi and alpha and trace free A
58+
BoxLoops::loop(make_compute_pack(TraceARemoval(), PositiveChiAndAlpha()),
59+
a_soln, a_soln, INCLUDE_GHOST_CELLS);
60+
61+
// Calculate CCZ4 right hand side and set constraints to zero to avoid
62+
// undefined values
63+
BoxLoops::loop(
64+
make_compute_pack(CCZ4(m_p.ccz4_params, m_dx, m_p.sigma),
65+
SetValue(0, Interval(c_Ham, NUM_VARS - 1))),
66+
a_soln, a_rhs, EXCLUDE_GHOST_CELLS);
67+
}
68+
69+
void BinaryBHLevel::specificUpdateODE(GRLevelData &a_soln,
70+
const GRLevelData &a_rhs, Real a_dt)
71+
{
72+
// Enforce the trace free A_ij condition
73+
BoxLoops::loop(TraceARemoval(), a_soln, a_soln, INCLUDE_GHOST_CELLS);
74+
}
75+
76+
void BinaryBHLevel::computeTaggingCriterion(FArrayBox &tagging_criterion,
77+
const FArrayBox &current_state)
78+
{
79+
BoxLoops::loop(
80+
ChiExtractionTaggingCriterion(m_dx, m_level, m_p.extraction_params),
81+
current_state, tagging_criterion);
82+
}
83+
84+
void BinaryBHLevel::specificPostTimeStep()
85+
{
86+
CH_TIME("BinaryBHLevel::specificPostTimeStep");
87+
if (m_p.activate_extraction == 1)
88+
{
89+
// Populate the Weyl Scalar values on the grid
90+
fillAllGhosts();
91+
BoxLoops::loop(Weyl4(m_p.extraction_params.extraction_center, m_dx),
92+
m_state_new, m_state_new, EXCLUDE_GHOST_CELLS);
93+
94+
// Do the extraction on the min extraction level
95+
if (m_level == m_p.extraction_params.min_extraction_level)
96+
{
97+
// Now refresh the interpolator and do the interpolation
98+
m_gr_amr.m_interpolator->refresh();
99+
WeylExtraction my_extraction(m_p.extraction_params, m_dt, m_time,
100+
m_restart_time);
101+
my_extraction.execute_query(m_gr_amr.m_interpolator);
102+
}
103+
}
104+
}
105+
106+
// Things to do before a plot level - need to calculate the Weyl scalars
107+
void BinaryBHLevel::prePlotLevel()
108+
{
109+
fillAllGhosts();
110+
if (m_p.activate_extraction == 1)
111+
{
112+
BoxLoops::loop(Weyl4(m_p.extraction_params.extraction_center, m_dx),
113+
m_state_new, m_state_new, EXCLUDE_GHOST_CELLS);
114+
}
115+
}
116+
117+
// Specify if you want any plot files to be written, with which vars
118+
void BinaryBHLevel::specificWritePlotHeader(std::vector<int> &plot_states) const
119+
{
120+
plot_states = {c_chi, c_Weyl4_Re, c_Weyl4_Im};
121+
}

Examples/BinaryBH/BinaryBHLevel.hpp

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* GRChombo
2+
* Copyright 2012 The GRChombo collaboration.
3+
* Please refer to LICENSE in GRChombo's root directory.
4+
*/
5+
6+
#ifndef BINARYBHLEVEL_HPP_
7+
#define BINARYBHLEVEL_HPP_
8+
9+
#include "DefaultLevelFactory.hpp"
10+
#include "GRAMRLevel.hpp"
11+
12+
class BinaryBHLevel : public GRAMRLevel
13+
{
14+
friend class DefaultLevelFactory<BinaryBHLevel>;
15+
// Inherit the contructors from GRAMRLevel
16+
using GRAMRLevel::GRAMRLevel;
17+
18+
/// Things to do at every full timestep
19+
///(might include several substeps, e.g. in RK4)
20+
virtual void specificAdvance() override;
21+
22+
/// Initial data calculation
23+
virtual void initialData() override;
24+
25+
/// Any actions that should happen just before checkpointing
26+
virtual void preCheckpointLevel() override;
27+
28+
/// Calculation of the right hand side for the time stepping
29+
virtual void specificEvalRHS(GRLevelData &a_soln, GRLevelData &a_rhs,
30+
const double a_time) override;
31+
32+
/// Things to do after dt*rhs has been added to the solution
33+
virtual void specificUpdateODE(GRLevelData &a_soln,
34+
const GRLevelData &a_rhs,
35+
Real a_dt) override;
36+
37+
/// Identify and tag the cells that need higher resolution
38+
virtual void
39+
computeTaggingCriterion(FArrayBox &tagging_criterion,
40+
const FArrayBox &current_state) override;
41+
42+
// to do post each time step on every level
43+
virtual void specificPostTimeStep() override;
44+
45+
/// Any actions that should happen just before plot files output
46+
virtual void prePlotLevel() override;
47+
48+
//! Specify which variables to write at plot intervals
49+
virtual void specificWritePlotHeader(std::vector<int> &plot_states) const;
50+
};
51+
52+
#endif /* BINARYBHLEVEL_HPP_ */

0 commit comments

Comments
 (0)