Skip to content

Commit 7dc6eed

Browse files
committed
propagate twopi constant
1 parent 4581cfd commit 7dc6eed

File tree

4 files changed

+69
-72
lines changed

4 files changed

+69
-72
lines changed

components/omega/src/ocn/CustomTendencyTerms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ void ManufacturedSolution::init() {
8080
R8 H0 = DefHorzMesh->BottomDepthH(0);
8181

8282
// Define and compute common constants
83-
R8 Kx = 2.0_Real * Pi / WavelengthX; // Wave in X-dir
84-
R8 Ky = 2.0_Real * Pi / WavelengthY; // Wave in Y-dir
83+
R8 Kx = TwoPi / WavelengthX; // Wave in X-dir
84+
R8 Ky = TwoPi / WavelengthY; // Wave in Y-dir
8585
R8 AngFreq = sqrt(H0 * Gravity * (Kx * Kx + Ky * Ky)); // Angular frequency
8686

8787
// Assign constants for thickness tendency function

components/omega/test/ocn/AuxiliaryVarsTest.cpp

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,54 +69,55 @@ struct TestSetupPlane {
6969
0.0039954090464502795};
7070

7171
KOKKOS_FUNCTION Real layerThickness(Real X, Real Y) const {
72-
return 2 + std::cos(2 * Pi * X / Lx) * std::cos(2 * Pi * Y / Ly);
72+
return 2 + std::cos(TwoPi * X / Lx) * std::cos(TwoPi * Y / Ly);
7373
}
7474

7575
KOKKOS_FUNCTION Real velocityX(Real X, Real Y) const {
76-
return std::sin(2 * Pi * X / Lx) * std::cos(2 * Pi * Y / Ly);
76+
return std::sin(TwoPi * X / Lx) * std::cos(TwoPi * Y / Ly);
7777
}
7878

7979
KOKKOS_FUNCTION Real velocityY(Real X, Real Y) const {
80-
return std::cos(2 * Pi * X / Lx) * std::sin(2 * Pi * Y / Ly);
80+
return std::cos(TwoPi * X / Lx) * std::sin(TwoPi * Y / Ly);
8181
}
8282

8383
KOKKOS_FUNCTION Real windStressX(Real X, Real Y) const {
84-
return std::cos(2 * Pi * X / Lx) * std::sin(2 * Pi * Y / Ly);
84+
return std::cos(TwoPi * X / Lx) * std::sin(TwoPi * Y / Ly);
8585
}
8686

8787
KOKKOS_FUNCTION Real windStressY(Real X, Real Y) const {
88-
return std::sin(2 * Pi * X / Lx) * std::cos(2 * Pi * Y / Ly);
88+
return std::sin(TwoPi * X / Lx) * std::cos(TwoPi * Y / Ly);
8989
}
9090

9191
KOKKOS_FUNCTION Real divergence(Real X, Real Y) const {
92-
return 2 * Pi * (1. / Lx + 1. / Ly) * std::cos(2 * Pi * X / Lx) *
93-
std::cos(2 * Pi * Y / Ly);
92+
return TwoPi * (1. / Lx + 1. / Ly) * std::cos(TwoPi * X / Lx) *
93+
std::cos(TwoPi * Y / Ly);
9494
}
9595

9696
KOKKOS_FUNCTION Real relativeVorticity(Real X, Real Y) const {
97-
return 2 * Pi * (-1. / Lx + 1. / Ly) * std::sin(2 * Pi * X / Lx) *
98-
std::sin(2 * Pi * Y / Ly);
97+
return TwoPi * (-1. / Lx + 1. / Ly) * std::sin(TwoPi * X / Lx) *
98+
std::sin(TwoPi * Y / Ly);
9999
}
100100

101101
KOKKOS_FUNCTION Real velocityDel2X(Real X, Real Y) const {
102-
return -4 * Pi * Pi * (1 / (Lx * Lx) + 1 / (Ly * Ly)) * velocityX(X, Y);
102+
return -TwoPi * TwoPi * (1 / (Lx * Lx) + 1 / (Ly * Ly)) * velocityX(X, Y);
103103
}
104104

105105
KOKKOS_FUNCTION Real velocityDel2Y(Real X, Real Y) const {
106-
return -4 * Pi * Pi * (1 / (Lx * Lx) + 1 / (Ly * Ly)) * velocityY(X, Y);
106+
return -TwoPi * TwoPi * (1 / (Lx * Lx) + 1 / (Ly * Ly)) * velocityY(X, Y);
107107
}
108108

109109
KOKKOS_FUNCTION Real velocityDel2Div(Real X, Real Y) const {
110-
return -4 * Pi * Pi * (1 / (Lx * Lx) + 1 / (Ly * Ly)) * divergence(X, Y);
110+
return -TwoPi * TwoPi * (1 / (Lx * Lx) + 1 / (Ly * Ly)) *
111+
divergence(X, Y);
111112
}
112113

113114
KOKKOS_FUNCTION Real velocityDel2Curl(Real X, Real Y) const {
114-
return -4 * Pi * Pi * (1 / (Lx * Lx) + 1 / (Ly * Ly)) *
115+
return -TwoPi * TwoPi * (1 / (Lx * Lx) + 1 / (Ly * Ly)) *
115116
relativeVorticity(X, Y);
116117
}
117118

118119
KOKKOS_FUNCTION Real planetaryVorticity(Real X, Real Y) const {
119-
return std::sin(2 * Pi * X / Lx) * std::sin(2 * Pi * Y / Ly);
120+
return std::sin(TwoPi * X / Lx) * std::sin(TwoPi * Y / Ly);
120121
}
121122

122123
KOKKOS_FUNCTION Real normalizedRelativeVorticity(Real X, Real Y) const {
@@ -134,23 +135,23 @@ struct TestSetupPlane {
134135
}
135136

136137
KOKKOS_FUNCTION Real tracer(Real X, Real Y) const {
137-
return 2 - std::cos(2 * Pi * X / Lx) * std::cos(2 * Pi * Y / Ly);
138+
return 2 - std::cos(TwoPi * X / Lx) * std::cos(TwoPi * Y / Ly);
138139
}
139140

140141
KOKKOS_FUNCTION Real thickTracer(Real X, Real Y) const {
141-
return 4 - std::pow(std::cos(2 * Pi * X / Lx), 2) *
142-
std::pow(std::cos(2 * Pi * Y / Ly), 2);
142+
return 4 - std::pow(std::cos(TwoPi * X / Lx), 2) *
143+
std::pow(std::cos(TwoPi * Y / Ly), 2);
143144
}
144145

145146
KOKKOS_FUNCTION Real del2Tracer(Real X, Real Y) const {
146-
return 2 * Pi * Pi *
147-
(4 * (1 / Lx / Lx + 1 / Ly / Ly) * std::cos(2 * Pi * X / Lx) *
148-
std::cos(2 * Pi * Y / Ly) +
149-
std::pow(std::cos(2 * Pi * X / Lx), 2) *
147+
return TwoPi * Pi *
148+
(4 * (1 / Lx / Lx + 1 / Ly / Ly) * std::cos(TwoPi * X / Lx) *
149+
std::cos(TwoPi * Y / Ly) +
150+
std::pow(std::cos(TwoPi * X / Lx), 2) *
150151
(1 / Lx / Lx +
151-
(2 / Ly / Ly + 1 / Lx / Lx) * std::cos(4 * Pi * Y / Ly)) -
152-
(2 / Lx / Lx) * std::pow(std::sin(2 * Pi * X / Lx), 2) *
153-
std::pow(std::cos(2 * Pi * Y / Ly), 2));
152+
(2 / Ly / Ly + 1 / Lx / Lx) * std::cos(2 * TwoPi * Y / Ly)) -
153+
(2 / Lx / Lx) * std::pow(std::sin(TwoPi * X / Lx), 2) *
154+
std::pow(std::cos(TwoPi * Y / Ly), 2));
154155
}
155156
};
156157

components/omega/test/ocn/HorzOperatorsTest.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,35 +44,33 @@ struct TestSetupPlane {
4444
0.004200067675522098};
4545

4646
KOKKOS_FUNCTION Real exactScalar(Real X, Real Y) const {
47-
return std::sin(2 * Pi * X / Lx) * std::sin(2 * Pi * Y / Ly);
47+
return std::sin(TwoPi * X / Lx) * std::sin(TwoPi * Y / Ly);
4848
}
4949

5050
KOKKOS_FUNCTION Real exactGradScalarX(Real X, Real Y) const {
51-
return 2 * Pi / Lx * std::cos(2 * Pi * X / Lx) *
52-
std::sin(2 * Pi * Y / Ly);
51+
return TwoPi / Lx * std::cos(TwoPi * X / Lx) * std::sin(TwoPi * Y / Ly);
5352
}
5453

5554
KOKKOS_FUNCTION Real exactGradScalarY(Real X, Real Y) const {
56-
return 2 * Pi / Ly * std::sin(2 * Pi * X / Lx) *
57-
std::cos(2 * Pi * Y / Ly);
55+
return TwoPi / Ly * std::sin(TwoPi * X / Lx) * std::cos(TwoPi * Y / Ly);
5856
}
5957

6058
KOKKOS_FUNCTION Real exactVecX(Real X, Real Y) const {
61-
return std::sin(2 * Pi * X / Lx) * std::cos(2 * Pi * Y / Ly);
59+
return std::sin(TwoPi * X / Lx) * std::cos(TwoPi * Y / Ly);
6260
}
6361

6462
KOKKOS_FUNCTION Real exactVecY(Real X, Real Y) const {
65-
return std::cos(2 * Pi * X / Lx) * std::sin(2 * Pi * Y / Ly);
63+
return std::cos(TwoPi * X / Lx) * std::sin(TwoPi * Y / Ly);
6664
}
6765

6866
KOKKOS_FUNCTION Real exactDivVec(Real X, Real Y) const {
69-
return 2 * Pi * (1. / Lx + 1. / Ly) * std::cos(2 * Pi * X / Lx) *
70-
std::cos(2 * Pi * Y / Ly);
67+
return TwoPi * (1. / Lx + 1. / Ly) * std::cos(TwoPi * X / Lx) *
68+
std::cos(TwoPi * Y / Ly);
7169
}
7270

7371
KOKKOS_FUNCTION Real exactCurlVec(Real X, Real Y) const {
74-
return 2 * Pi * (-1. / Lx + 1. / Ly) * std::sin(2 * Pi * X / Lx) *
75-
std::sin(2 * Pi * Y / Ly);
72+
return TwoPi * (-1. / Lx + 1. / Ly) * std::sin(TwoPi * X / Lx) *
73+
std::sin(TwoPi * Y / Ly);
7674
}
7775
};
7876

components/omega/test/ocn/TendencyTermsTest.cpp

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -59,52 +59,50 @@ struct TestSetupPlane {
5959
0.01000133508329411};
6060

6161
KOKKOS_FUNCTION Real vectorX(Real X, Real Y) const {
62-
return std::sin(2 * Pi * X / Lx) * std::cos(2 * Pi * Y / Ly);
62+
return std::sin(TwoPi * X / Lx) * std::cos(TwoPi * Y / Ly);
6363
}
6464

6565
KOKKOS_FUNCTION Real vectorY(Real X, Real Y) const {
66-
return std::cos(2 * Pi * X / Lx) * std::sin(2 * Pi * Y / Ly);
66+
return std::cos(TwoPi * X / Lx) * std::sin(TwoPi * Y / Ly);
6767
}
6868

6969
KOKKOS_FUNCTION Real divergence(Real X, Real Y) const {
70-
return 2 * Pi * (1. / Lx + 1. / Ly) * std::cos(2 * Pi * X / Lx) *
71-
std::cos(2 * Pi * Y / Ly);
70+
return TwoPi * (1. / Lx + 1. / Ly) * std::cos(TwoPi * X / Lx) *
71+
std::cos(TwoPi * Y / Ly);
7272
}
7373

7474
KOKKOS_FUNCTION Real scalar(Real X, Real Y) const {
75-
return std::sin(2 * Pi * X / Lx) * std::sin(2 * Pi * Y / Ly);
75+
return std::sin(TwoPi * X / Lx) * std::sin(TwoPi * Y / Ly);
7676
}
7777

7878
KOKKOS_FUNCTION Real gradX(Real X, Real Y) const {
79-
return 2 * Pi / Lx * std::cos(2 * Pi * X / Lx) *
80-
std::sin(2 * Pi * Y / Ly);
79+
return TwoPi / Lx * std::cos(TwoPi * X / Lx) * std::sin(TwoPi * Y / Ly);
8180
}
8281
KOKKOS_FUNCTION Real gradY(Real X, Real Y) const {
83-
return 2 * Pi / Ly * std::sin(2 * Pi * X / Lx) *
84-
std::cos(2 * Pi * Y / Ly);
82+
return TwoPi / Ly * std::sin(TwoPi * X / Lx) * std::cos(TwoPi * Y / Ly);
8583
}
8684

8785
KOKKOS_FUNCTION Real curl(Real X, Real Y) const {
88-
return 2 * Pi * (-1. / Lx + 1. / Ly) * std::sin(2 * Pi * X / Lx) *
89-
std::sin(2 * Pi * Y / Ly);
86+
return TwoPi * (-1. / Lx + 1. / Ly) * std::sin(TwoPi * X / Lx) *
87+
std::sin(TwoPi * Y / Ly);
9088
}
9189

9290
KOKKOS_FUNCTION Real laplaceVecX(Real X, Real Y) const {
93-
return -4 * Pi * Pi * (1. / Lx / Lx + 1. / Ly / Ly) *
94-
std::sin(2 * Pi * X / Lx) * std::cos(2 * Pi * Y / Ly);
91+
return -TwoPi * TwoPi * (1. / Lx / Lx + 1. / Ly / Ly) *
92+
std::sin(TwoPi * X / Lx) * std::cos(TwoPi * Y / Ly);
9593
}
9694

9795
KOKKOS_FUNCTION Real laplaceVecY(Real X, Real Y) const {
98-
return -4 * Pi * Pi * (1. / Lx / Lx + 1. / Ly / Ly) *
99-
std::cos(2 * Pi * X / Lx) * std::sin(2 * Pi * Y / Ly);
96+
return -TwoPi * TwoPi * (1. / Lx / Lx + 1. / Ly / Ly) *
97+
std::cos(TwoPi * X / Lx) * std::sin(TwoPi * Y / Ly);
10098
}
10199

102100
KOKKOS_FUNCTION Real layerThick(Real X, Real Y) const {
103-
return 2. + std::sin(2 * Pi * X / Lx) * std::cos(2 * Pi * Y / Ly);
101+
return 2. + std::sin(TwoPi * X / Lx) * std::cos(TwoPi * Y / Ly);
104102
}
105103

106104
KOKKOS_FUNCTION Real planetaryVort(Real X, Real Y) const {
107-
return std::cos(2 * Pi * X / Lx) * std::cos(2 * Pi * Y / Ly);
105+
return std::cos(TwoPi * X / Lx) * std::cos(TwoPi * Y / Ly);
108106
}
109107

110108
KOKKOS_FUNCTION Real normRelVort(Real X, Real Y) const {
@@ -116,40 +114,40 @@ struct TestSetupPlane {
116114
}
117115

118116
KOKKOS_FUNCTION Real tracerFluxDiv(Real X, Real Y) const {
119-
return (2 * Pi / (Lx * Ly)) *
120-
(std::cos(2 * Pi * X / Lx) *
121-
(2 * (Lx + Ly) * std::cos(2 * Pi * Y / Ly) +
122-
(Lx + 2 * Ly) * std::sin(2 * Pi * X / Lx) *
123-
std::pow(std::cos(2 * Pi * Y / Ly), 2) -
124-
Lx * std::sin(2 * Pi * X / Lx) *
125-
std::pow(std::sin(2 * Pi * Y / Ly), 2)));
117+
return (TwoPi / (Lx * Ly)) *
118+
(std::cos(TwoPi * X / Lx) *
119+
(2 * (Lx + Ly) * std::cos(TwoPi * Y / Ly) +
120+
(Lx + 2 * Ly) * std::sin(TwoPi * X / Lx) *
121+
std::pow(std::cos(TwoPi * Y / Ly), 2) -
122+
Lx * std::sin(TwoPi * X / Lx) *
123+
std::pow(std::sin(TwoPi * Y / Ly), 2)));
126124
}
127125

128126
KOKKOS_FUNCTION Real scalarA(Real X, Real Y) const {
129-
return std::cos(2 * Pi * X / Lx) * std::sin(2 * Pi * Y / Ly);
127+
return std::cos(TwoPi * X / Lx) * std::sin(TwoPi * Y / Ly);
130128
}
131129

132130
KOKKOS_FUNCTION Real scalarB(Real X, Real Y) const {
133-
return 2. + std::cos(2 * Pi * X / Lx) * std::cos(2 * Pi * Y / Ly);
131+
return 2. + std::cos(TwoPi * X / Lx) * std::cos(TwoPi * Y / Ly);
134132
}
135133

136134
KOKKOS_FUNCTION Real tracerDiff(Real X, Real Y) const {
137-
return -4 * Pi * Pi * std::sin(2 * Pi * Y / Ly) *
138-
(2 * (1 / Lx / Lx + 1 / Ly / Ly) * std::cos(2 * Pi * X / Lx) +
135+
return -TwoPi * TwoPi * std::sin(TwoPi * Y / Ly) *
136+
(2 * (1 / Lx / Lx + 1 / Ly / Ly) * std::cos(TwoPi * X / Lx) +
139137
(1 / Ly / Ly +
140-
(1 / Lx / Lx + 1 / Ly / Ly) * std::cos(4 * Pi * X / Lx)) *
141-
std::cos(2 * Pi * Y / Ly));
138+
(1 / Lx / Lx + 1 / Ly / Ly) * std::cos(2 * TwoPi * X / Lx)) *
139+
std::cos(TwoPi * Y / Ly));
142140
}
143141

144142
KOKKOS_FUNCTION Real scalarC(Real X, Real Y) const {
145-
return std::pow(std::cos(2 * Pi * X / Lx), 2) -
146-
std::pow(std::sin(2 * Pi * Y / Ly), 2);
143+
return std::pow(std::cos(TwoPi * X / Lx), 2) -
144+
std::pow(std::sin(TwoPi * Y / Ly), 2);
147145
}
148146

149147
KOKKOS_FUNCTION Real tracerHyperDiff(Real X, Real Y) const {
150-
return -8 * Pi * Pi *
151-
(std::cos(4 * Pi * X / Lx) / Lx / Lx +
152-
std::cos(4 * Pi * Y / Ly) / Ly / Ly);
148+
return -2 * TwoPi * TwoPi *
149+
(std::cos(2 * TwoPi * X / Lx) / Lx / Lx +
150+
std::cos(2 * TwoPi * Y / Ly) / Ly / Ly);
153151
}
154152

155153
KOKKOS_FUNCTION Real windForcingX(Real X, Real Y,

0 commit comments

Comments
 (0)