Skip to content

Commit 4581cfd

Browse files
committed
rebases and adds more constant replacements
1 parent 0a2fe67 commit 4581cfd

File tree

8 files changed

+19
-24
lines changed

8 files changed

+19
-24
lines changed

components/omega/src/ocn/GlobalConstants.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "DataTypes.h"
15+
#include <cmath>
1516

1617
namespace OMEGA {
1718

1819
// Earth constants
19-
constexpr Real Gravity = 9.80616; // Acceleration due to gravity ~ m/s^2
20-
constexpr Real Pi = 3.14159265358979323846; // Pi
21-
constexpr Real TwoPi = 2.0 * Pi; // 2*Pi
22-
constexpr Real CDay = 86400.0; // Seconds in a calendar day ~ sec
23-
constexpr Real SDay = 86164.0; // Seconds in a sidereal day ~ sec
20+
constexpr Real Gravity = 9.80616; // Acceleration due to gravity ~ m/s^2
21+
constexpr Real Pi = M_PI; // Pi
22+
constexpr Real TwoPi = 2.0 * M_PI; // 2*Pi
23+
constexpr Real CDay = 86400.0; // Seconds in a calendar day ~ sec
24+
constexpr Real SDay = 86164.0; // Seconds in a sidereal day ~ sec
2425
constexpr Real Omega =
2526
2.0 * Pi / SDay; // Angular velocity of the Earth ~ rad/sec
2627
constexpr Real REarth = 6.37122e6; // Mean radius of the Earth ~ m

components/omega/src/ocn/VertCoord.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "VertCoord.h"
1111
#include "Dimension.h"
1212
#include "Field.h"
13+
#include "GlobalConstants.h"
1314
#include "IO.h"
1415
#include "IOStream.h"
1516
#include "OmegaKokkos.h"
@@ -656,8 +657,6 @@ void VertCoord::computePressure(
656657
const Array1DReal &SurfacePressure // [in] surface pressure
657658
) {
658659

659-
Real Gravity = 9.80616_Real; // gravitationl acceleration
660-
661660
OMEGA_SCOPE(LocRho0, Rho0);
662661
OMEGA_SCOPE(LocMinLayerCell, MinLayerCell);
663662
OMEGA_SCOPE(LocMaxLayerCell, MaxLayerCell);
@@ -745,8 +744,6 @@ void VertCoord::computeGeopotential(
745744
const Array1DReal &SelfAttractionLoading // [in] self attraction and loading
746745
) {
747746

748-
Real Gravity = 9.80616_Real; // gravitationl acceleration
749-
750747
OMEGA_SCOPE(LocMinLayerCell, MinLayerCell);
751748
OMEGA_SCOPE(LocMaxLayerCell, MaxLayerCell);
752749
OMEGA_SCOPE(LocGeopotMid, GeopotentialMid);
@@ -784,8 +781,6 @@ void VertCoord::computeGeopotential(
784781
// reductions and a parallel_for over the active layers within a column.
785782
void VertCoord::computeTargetThickness() {
786783

787-
Real Gravity = 9.80616_Real; // gravitationl acceleration
788-
789784
OMEGA_SCOPE(LocRho0, Rho0);
790785
OMEGA_SCOPE(LocMinLayerCell, MinLayerCell);
791786
OMEGA_SCOPE(LocMaxLayerCell, MaxLayerCell);

components/omega/test/ocn/AuxiliaryStateTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "Decomp.h"
55
#include "Dimension.h"
66
#include "Field.h"
7+
#include "GlobalConstants.h"
78
#include "Halo.h"
89
#include "HorzMesh.h"
910
#include "IO.h"
@@ -23,7 +24,7 @@
2324
using namespace OMEGA;
2425

2526
struct TestSetup {
26-
Real Radius = 6371220;
27+
Real Radius = REarth;
2728

2829
KOKKOS_FUNCTION Real layerThickness(Real Lon, Real Lat) const {
2930
return (2 + std::cos(Lon) * std::pow(std::cos(Lat), 4));

components/omega/test/ocn/AuxiliaryVarsTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "Decomp.h"
44
#include "Dimension.h"
55
#include "Field.h"
6+
#include "GlobalConstants.h"
67
#include "Halo.h"
78
#include "HorzMesh.h"
89
#include "IO.h"
@@ -26,7 +27,6 @@
2627
using namespace OMEGA;
2728

2829
struct TestSetupPlane {
29-
Real Pi = M_PI;
3030

3131
Real Lx = 1;
3232
Real Ly = std::sqrt(3) / 2;
@@ -156,7 +156,7 @@ struct TestSetupPlane {
156156

157157
struct TestSetupSphere {
158158

159-
Real Radius = 6371220;
159+
Real Radius = REarth;
160160

161161
ErrorMeasures ExpectedKineticEnergyErrors = {0.0143579382532765844,
162162
0.00681096618897046764};

components/omega/test/ocn/HorzOperatorsTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "DataTypes.h"
44
#include "Decomp.h"
55
#include "Dimension.h"
6+
#include "GlobalConstants.h"
67
#include "Halo.h"
78
#include "HorzMesh.h"
89
#include "IO.h"
@@ -22,7 +23,6 @@ using namespace OMEGA;
2223
// operator tests together with exact values of operators for computing errors
2324
// and expected error values
2425
struct TestSetupPlane {
25-
Real Pi = M_PI;
2626

2727
// lengths of periodic planar mesh
2828
// TODO: get this from the horizontal mesh once it supports periodic planar
@@ -79,7 +79,7 @@ struct TestSetupPlane {
7979
struct TestSetupSphere1 {
8080
// radius of spherical mesh
8181
// TODO: get this from the mesh
82-
Real Radius = 6371220;
82+
Real Radius = REarth;
8383

8484
ErrorMeasures ExpectedDivErrors = {0.013659577398978353,
8585
0.00367052484586382743};
@@ -129,7 +129,7 @@ struct TestSetupSphere1 {
129129
struct TestSetupSphere2 {
130130
// radius of spherical mesh
131131
// TODO: get this from the mesh
132-
Real Radius = 6371220;
132+
Real Radius = REarth;
133133

134134
ErrorMeasures ExpectedDivErrors = {1.37734693033362766e-10,
135135
0.000484370621558727582};

components/omega/test/ocn/TendenciesTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "Dimension.h"
77
#include "Error.h"
88
#include "Field.h"
9+
#include "GlobalConstants.h"
910
#include "Halo.h"
1011
#include "HorzMesh.h"
1112
#include "IO.h"
@@ -24,7 +25,7 @@
2425
using namespace OMEGA;
2526

2627
struct TestSetup {
27-
Real Radius = 6371220;
28+
Real Radius = REarth;
2829

2930
KOKKOS_FUNCTION Real layerThickness(Real Lon, Real Lat) const {
3031
return (2 + std::cos(Lon) * std::pow(std::cos(Lat), 4));

components/omega/test/ocn/TendencyTermsTest.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
using namespace OMEGA;
3737

3838
struct TestSetupPlane {
39-
Real Pi = M_PI;
4039

4140
Real Lx = 1;
4241
Real Ly = std::sqrt(3) / 2;
@@ -182,9 +181,7 @@ struct TestSetupPlane {
182181
struct TestSetupSphere {
183182
// radius of spherical mesh
184183
// TODO: get this from the mesh
185-
Real Radius = 6371220;
186-
187-
Real Pi = M_PI;
184+
Real Radius = REarth;
188185

189186
ErrorMeasures ExpectedDivErrors = {0.0136595773989796766,
190187
0.00367052484586384131};

components/omega/test/ocn/VertCoordTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "Decomp.h"
1313
#include "Dimension.h"
1414
#include "Error.h"
15+
#include "GlobalConstants.h"
1516
#include "Halo.h"
1617
#include "HorzMesh.h"
1718
#include "IO.h"
@@ -107,8 +108,7 @@ int main(int argc, char *argv[]) {
107108

108109
/// Initialize layer thickness and surface pressure so that resulting
109110
/// interface pressure is the number of layers above plus one
110-
Real Gravity = 9.80616_Real;
111-
Real Rho0 = DefVertCoord->Rho0;
111+
Real Rho0 = DefVertCoord->Rho0;
112112
parallelFor(
113113
{NCellsAll}, KOKKOS_LAMBDA(int ICell) {
114114
SurfacePressure(ICell) = 1.0_Real;

0 commit comments

Comments
 (0)