Skip to content

Commit 75af359

Browse files
committed
Testing for the derived expressions between variables and constants
1 parent e49442d commit 75af359

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

testing/adios2/derived/TestBPDerivedCorrectnessMPI.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ TEST_P(DerivedCorrectnessMPIP, ScalarFunctionsCorrectnessTest)
4040
std::vector<std::string> varname = {"sim/Ux", "sim/Uy", "sim/Uz"};
4141
const std::string derAgrAdd = "derived/agradd";
4242
const std::string derAddName = "derived/add";
43+
const std::string derConstAdd = "derived/constadd";
4344
const std::string derSubtrName = "derived/subtr";
4445
const std::string derMultName = "derived/mult";
46+
const std::string derConstMult = "derived/constmult";
4547
const std::string derDivName = "derived/div";
4648
const std::string derPowName = "derived/pow";
4749
const std::string derSqrtName = "derived/sqrt";
@@ -86,6 +88,10 @@ TEST_P(DerivedCorrectnessMPIP, ScalarFunctionsCorrectnessTest)
8688
"z =" + varname[2] + " \n"
8789
"x+y+z",
8890
mode);
91+
bpOut.DefineDerivedVariable(derConstAdd,
92+
"x =" + varname[0] + " \n"
93+
"add(x+4, 1)",
94+
mode);
8995
bpOut.DefineDerivedVariable(derSubtrName,
9096
"x =" + varname[0] + " \n"
9197
"y =" + varname[1] + " \n"
@@ -98,6 +104,10 @@ TEST_P(DerivedCorrectnessMPIP, ScalarFunctionsCorrectnessTest)
98104
"z =" + varname[2] + " \n"
99105
"x*y*z",
100106
mode);
107+
bpOut.DefineDerivedVariable(derConstMult,
108+
"x =" + varname[0] + " \n"
109+
"multiply(x,5)*2",
110+
mode);
101111
bpOut.DefineDerivedVariable(derDivName,
102112
"x =" + varname[0] + " \n"
103113
"y =" + varname[1] + " \n"
@@ -134,8 +144,10 @@ TEST_P(DerivedCorrectnessMPIP, ScalarFunctionsCorrectnessTest)
134144
std::vector<float> readUz(mpiSize * Nx * Ny * Nz);
135145
std::vector<float> readAdd(mpiSize * Nx * Ny * Nz);
136146
std::vector<float> readAgrAdd(mpiSize * Nx * Ny * Nz);
147+
std::vector<float> readConstAdd(mpiSize * Nx * Ny * Nz);
137148
std::vector<float> readSubtr(mpiSize * Nx * Ny * Nz);
138149
std::vector<float> readMult(mpiSize * Nx * Ny * Nz);
150+
std::vector<float> readConstMult(mpiSize * Nx * Ny * Nz);
139151
std::vector<float> readDiv(mpiSize * Nx * Ny * Nz);
140152
std::vector<double> readPow(mpiSize * Nx * Ny * Nz);
141153
std::vector<double> readSqrt(mpiSize * Nx * Ny * Nz);
@@ -149,8 +161,10 @@ TEST_P(DerivedCorrectnessMPIP, ScalarFunctionsCorrectnessTest)
149161
auto varUz = bpIn.InquireVariable<float>(varname[2]);
150162
auto varAdd = bpIn.InquireVariable<float>(derAddName);
151163
auto varAgrAdd = bpIn.InquireVariable<float>(derAgrAdd);
164+
auto varConstAdd = bpIn.InquireVariable<float>(derConstAdd);
152165
auto varSubtr = bpIn.InquireVariable<float>(derSubtrName);
153166
auto varMult = bpIn.InquireVariable<float>(derMultName);
167+
auto varConstMult = bpIn.InquireVariable<float>(derConstMult);
154168
auto varDiv = bpIn.InquireVariable<float>(derDivName);
155169
auto varPow = bpIn.InquireVariable<double>(derPowName);
156170
auto varSqrt = bpIn.InquireVariable<double>(derSqrtName);
@@ -160,9 +174,11 @@ TEST_P(DerivedCorrectnessMPIP, ScalarFunctionsCorrectnessTest)
160174
bpFileReader.Get(varUz, readUz);
161175
bpFileReader.Get(varAdd, readAdd);
162176
bpFileReader.Get(varAgrAdd, readAgrAdd);
177+
bpFileReader.Get(varConstAdd, readConstAdd);
163178

164179
bpFileReader.Get(varSubtr, readSubtr);
165180
bpFileReader.Get(varMult, readMult);
181+
bpFileReader.Get(varConstMult, readConstMult);
166182
bpFileReader.Get(varDiv, readDiv);
167183
bpFileReader.Get(varPow, readPow);
168184
bpFileReader.Get(varSqrt, readSqrt);
@@ -173,12 +189,18 @@ TEST_P(DerivedCorrectnessMPIP, ScalarFunctionsCorrectnessTest)
173189
calcFloat = readUx[ind] + readUy[ind] + readUz[ind];
174190
EXPECT_TRUE(fabs(calcFloat - readAdd[ind]) < epsilon);
175191

192+
calcFloat = readUx[ind] + 5;
193+
EXPECT_TRUE(fabs(calcFloat - readConstAdd[ind]) < epsilon);
194+
176195
calcFloat = readUx[ind] - readUy[ind] - readUz[ind];
177196
EXPECT_TRUE(fabs(calcFloat - readSubtr[ind]) < epsilon);
178197

179198
calcFloat = readUx[ind] * readUy[ind] * readUz[ind];
180199
EXPECT_TRUE(fabs(calcFloat - readMult[ind]) < epsilon);
181200

201+
calcFloat = readUx[ind] * 10;
202+
EXPECT_TRUE(fabs(calcFloat - readConstMult[ind]) < epsilon);
203+
182204
calcFloat = readUx[ind] / readUy[ind] / readUz[ind];
183205
EXPECT_TRUE(fabs(calcFloat - readDiv[ind]) < epsilon);
184206

0 commit comments

Comments
 (0)