Skip to content

Commit 0cc630d

Browse files
committed
Matter: Move the gauge calculation re:matter to its own file
1 parent 8bcbe96 commit 0cc630d

File tree

5 files changed

+65
-26
lines changed

5 files changed

+65
-26
lines changed

Source/CCZ4/MovingPunctureGauge.hpp

-22
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,6 @@ class MovingPunctureGauge
6565
rhs.Gamma[i] - m_params.eta * vars.B[i];
6666
}
6767
}
68-
69-
// Add the matter terms to the rhs of the gauge equations
70-
// For the MP gauge, this only changes the rhs of B through the rhs of Gamma
71-
template <class data_t, template <typename> class vars_t>
72-
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void rhs_gauge_add_matter_terms(
73-
vars_t<data_t> &matter_rhs, const vars_t<data_t> &matter_vars,
74-
Tensor<2, data_t, 3> h_UU, const emtensor_t<data_t> emtensor,
75-
const double G_Newton) const
76-
{
77-
FOR (i)
78-
{
79-
data_t matter_term_Gamma = 0.0;
80-
FOR (j)
81-
{
82-
matter_term_Gamma += -16.0 * M_PI * G_Newton *
83-
matter_vars.lapse * h_UU[i][j] *
84-
emtensor.Si[j];
85-
}
86-
87-
matter_rhs.B[i] += matter_term_Gamma;
88-
}
89-
}
9068
};
9169

9270
#endif /* MOVINGPUNCTUREGAUGE_HPP_ */

Source/Matter/CCZ4RHSWithMatter.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "CCZ4RHS.hpp"
1111
#include "Cell.hpp"
1212
#include "FourthOrderDerivatives.hpp"
13-
#include "MovingPunctureGauge.hpp"
13+
#include "MovingPunctureGaugeWithMatter.hpp"
1414
#include "StateVariables.hpp" //This files needs NUM_VARS - total number of components
1515
#include "Tensor.hpp"
1616
#include "TensorAlgebra.hpp"
@@ -29,7 +29,7 @@
2929
an example of a matter_t. \sa CCZ4RHS(), ScalarField()
3030
*/
3131

32-
template <class matter_t, class gauge_t = MovingPunctureGauge,
32+
template <class matter_t, class gauge_t = MovingPunctureGaugeWithMatter,
3333
class deriv_t = FourthOrderDerivatives>
3434
class CCZ4RHSWithMatter : public CCZ4RHS<gauge_t, deriv_t>
3535
{

Source/Matter/Make.package

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ GRTECLYN_CEXE_headers += ChiRelaxation.hpp \
99
MatterConstraints.impl.hpp \
1010
MatterWeyl4.hpp \
1111
MatterWeyl4.impl.hpp \
12+
MovingPunctureGaugeWithMatter \
1213
ScalarField.hpp \
1314
ScalarField.impl.hpp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* GRTeclyn
2+
* Copyright 2022 The GRTL collaboration.
3+
* Please refer to LICENSE in GRTeclyn's root directory.
4+
*/
5+
6+
#ifndef MOVINGPUNCTUREGAUGEWITHMATTER_HPP_
7+
#define MOVINGPUNCTUREGAUGEWITHMATTER_HPP_
8+
9+
#include "CCZ4RHSWithMatter.hpp"
10+
#include "DimensionDefinitions.hpp"
11+
// #include "EMTensor.hpp"
12+
#include "Tensor.hpp"
13+
14+
#include <cmath>
15+
16+
/**
17+
* This class implements a slightly more generic version of the moving puncture
18+
* gauge. In particular it uses a Bona-Masso slicing condition of the form
19+
* f(lapse) = -c*lapse^(p-2)
20+
* and a Gamma-driver shift condition
21+
**/
22+
23+
/// This class adds the matter terms to the RHS of the gauge equation
24+
/// for the moving puncture gauge
25+
26+
class MovingPunctureGaugeWithMatter : public MovingPunctureGauge
27+
{
28+
29+
public:
30+
MovingPunctureGaugeWithMatter(const params_t &a_params)
31+
: MovingPunctureGauge(a_params)
32+
{
33+
}
34+
35+
// NOLINTBEGIN(bugprone-easily-swappable-parameters)
36+
template <class data_t, template <typename> class vars_t>
37+
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void rhs_gauge_add_matter_terms(
38+
vars_t<data_t> &matter_rhs, const vars_t<data_t> &matter_vars,
39+
Tensor<2, data_t, 3> h_UU, const emtensor_t<data_t> emtensor,
40+
const double G_Newton) const
41+
// NOLINTEND(bugprone-easily-swappable-parameters)
42+
{
43+
FOR (i)
44+
{
45+
data_t matter_term_Gamma = 0.0;
46+
FOR (j)
47+
{
48+
matter_term_Gamma += -16.0 * M_PI * G_Newton *
49+
matter_vars.lapse * h_UU[i][j] *
50+
emtensor.Si[j];
51+
}
52+
53+
matter_rhs.B[i] += matter_term_Gamma;
54+
}
55+
}
56+
};
57+
58+
#endif /* MOVINGPUNCTUREGAUGEWITHMATTER_HPP_ */

Tests/BSSNMatterTest/BSSNMatterTest.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ void run_bssn_matter_test()
6969

7070
const auto &in_array = in_mf.arrays();
7171

72+
// NOLINTBEGIN(bugprone-easily-swappable-parameters)
7273
amrex::ParallelFor(
7374
in_mf, in_mf.nGrowVect(),
7475
[=] AMREX_GPU_DEVICE(int ibox, int i, int j, int k)
76+
// NOLINTEND(bugprone-easily-swappable-parameters)
7577
{
7678
const amrex::IntVect iv{i, j, k};
7779
const amrex::RealVect coords = amrex::RealVect{iv} * dx;
@@ -84,7 +86,7 @@ void run_bssn_matter_test()
8486
random_matter_bssn_initial_data(iv, in_array[ibox], coords);
8587
});
8688

87-
CCZ4_params_t<MovingPunctureGauge::params_t> ccz4_params;
89+
CCZ4_params_t<MovingPunctureGaugeWithMatter::params_t> ccz4_params;
8890
ccz4_params.kappa1 = 0.0;
8991
ccz4_params.kappa2 = 0.0;
9092
ccz4_params.kappa3 = 0.0;
@@ -103,7 +105,7 @@ void run_bssn_matter_test()
103105
GRParmParse pp;
104106
pp.queryAdd("G_Newton", G_Newton);
105107

106-
CCZ4RHSWithMatter<DefaultScalarField, MovingPunctureGauge,
108+
CCZ4RHSWithMatter<DefaultScalarField, MovingPunctureGaugeWithMatter,
107109
FourthOrderDerivatives>
108110
current_ccz4_rhs{ccz4_params, dx, sigma, CCZ4RHS<>::USE_BSSN,
109111
G_Newton};

0 commit comments

Comments
 (0)