Nektar++
Loading...
Searching...
No Matches
Functions | Variables
Nektar::VarcoeffHashingTest Namespace Reference

Functions

void createSessionFile (fs::path &ph)
 
void setupContFieldSolve (fs::path &ph, LibUtilities::SessionReaderSharedPtr &Session, MultiRegions::ContFieldSharedPtr &Exp, MultiRegions::ContFieldSharedPtr &Fce)
 
 BOOST_AUTO_TEST_CASE (TestVarcoeffHashing)
 
 BOOST_AUTO_TEST_CASE (TestUnsetGlobalLinSys)
 

Variables

fs::path pathGlobal
 
LibUtilities::SessionReaderSharedPtr lsession
 
MultiRegions::ContFieldSharedPtr contfield
 
MultiRegions::ContFieldSharedPtr forcefield
 
StdRegions::ConstFactorMap factors
 
StdRegions::VarCoeffMap varcoeffs1
 
StdRegions::VarCoeffMap varcoeffs2
 
static const std::string sessionfile
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

Nektar::VarcoeffHashingTest::BOOST_AUTO_TEST_CASE ( TestUnsetGlobalLinSys  )

Definition at line 296 of file TestVarcoeffHashing.cpp.

297{
298 // Check that the test setup is clear i.e. count == 0
299 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 0);
300
301 // Create 1st GlobalLinSys
302 auto gkey1 = contfield->LinearAdvectionDiffusionReactionSolve(
303 forcefield->GetPhys(), contfield->UpdateCoeffs(), factors, varcoeffs1);
304
305 // Check count == 1
306 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 1);
307
308 // Create 2nd GlobalLinSys
309 auto gkey2 = contfield->LinearAdvectionDiffusionReactionSolve(
310 forcefield->GetPhys(), contfield->UpdateCoeffs(), factors, varcoeffs2);
311
312 // Check count == 2
313 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 2);
314
315 // Unset GlobalLinSys1
316 contfield->UnsetGlobalLinSys(gkey1, true);
317
318 // Check count == 1
319 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 1);
320
321 // Unset GlobalLinSys2
322 contfield->UnsetGlobalLinSys(gkey2, true);
323
324 // Check count == 0
325 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 0);
326
327 // Clear for next tests
328 contfield->ClearGlobalLinSysManager();
329}
MultiRegions::ContFieldSharedPtr forcefield
MultiRegions::ContFieldSharedPtr contfield

References contfield, factors, forcefield, varcoeffs1, and varcoeffs2.

◆ BOOST_AUTO_TEST_CASE() [2/2]

Nektar::VarcoeffHashingTest::BOOST_AUTO_TEST_CASE ( TestVarcoeffHashing  )

Definition at line 255 of file TestVarcoeffHashing.cpp.

256{
257 // Create session file and setup Contfield
258 createSessionFile(pathGlobal);
259 setupContFieldSolve(pathGlobal, lsession, contfield, forcefield);
260
261 // Check no initial GlobalLinSys i.e. count == 0
262 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 0);
263
264 // Create GlobalLinSys(varcoeff1)
265 contfield->HelmSolve(forcefield->GetPhys(), contfield->UpdateCoeffs(),
266 factors, varcoeffs1);
267
268 // Check count == 1
269 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 1);
270
271 // Create new GlobalLinSys(varcoeff2)
272 contfield->HelmSolve(forcefield->GetPhys(), contfield->UpdateCoeffs(),
273 factors, varcoeffs2);
274
275 // Check count == 2
276 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 2);
277
278 // Again use 2nd GlobalLinSys(varcoeff2)
279 contfield->HelmSolve(forcefield->GetPhys(), contfield->UpdateCoeffs(),
280 factors, varcoeffs2);
281
282 // Check count still == 2
283 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 2);
284
285 // Again use 1st GlobalLinSys(varcoeff1)
286 contfield->HelmSolve(forcefield->GetPhys(), contfield->UpdateCoeffs(),
287 factors, varcoeffs1);
288
289 // Check count still == 2
290 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 2);
291
292 // Clear for next tests
293 contfield->ClearGlobalLinSysManager();
294}
void setupContFieldSolve(fs::path &ph, LibUtilities::SessionReaderSharedPtr &Session, MultiRegions::ContFieldSharedPtr &Exp, MultiRegions::ContFieldSharedPtr &Fce)

References contfield, createSessionFile(), factors, forcefield, lsession, pathGlobal, setupContFieldSolve(), varcoeffs1, and varcoeffs2.

◆ createSessionFile()

void Nektar::VarcoeffHashingTest::createSessionFile ( fs::path &  ph)

Definition at line 168 of file TestVarcoeffHashing.cpp.

169{
170 // Create temporary directory
171 ph = fs::temp_directory_path() / LibUtilities::UniquePath("varctest");
172 fs::create_directories(ph);
173
174 // Create file in working directory
175 ph /= "TestVarcoeffHashing.xml"; // append filename
176 std::ofstream sfile(ph);
177 sfile << sessionfile;
178 sfile.close();
179}
static const std::string sessionfile

References sessionfile, and Nektar::LibUtilities::UniquePath().

Referenced by BOOST_AUTO_TEST_CASE().

◆ setupContFieldSolve()

void Nektar::VarcoeffHashingTest::setupContFieldSolve ( fs::path &  ph,
LibUtilities::SessionReaderSharedPtr Session,
MultiRegions::ContFieldSharedPtr Exp,
MultiRegions::ContFieldSharedPtr Fce 
)

Definition at line 186 of file TestVarcoeffHashing.cpp.

190{
191#ifdef _WIN32
192 // Prepare input file name - convert wstring to string to support Windows
193 const std::wstring input_file_wstr(ph.c_str());
194 const std::string input_file_str(input_file_wstr.begin(),
195 input_file_wstr.end());
196 char *input_file = (char *)input_file_str.c_str();
197#else
198 char *input_file = (char *)ph.c_str();
199#endif
200
201 // Setup parameters for call to IncNavierStokesSolver
202 int argc = 2;
203 char *argv[] = {(char *)("IncNavierStokesSolver"), input_file, nullptr};
204
205 // Read Session, MeshGraph and create ContField
206 Session = LibUtilities::SessionReader::CreateInstance(argc, argv);
208 SpatialDomains::MeshGraphIO::Read(Session);
210 Session, Graph, Session->GetVariable(0));
212
213 // Read functons for varcoeffs and Forcing
214 LibUtilities::EquationSharedPtr d00func = Session->GetFunction("d00", 0);
215 LibUtilities::EquationSharedPtr d00Bfunc = Session->GetFunction("d00B", 0);
216 LibUtilities::EquationSharedPtr ffunc = Session->GetFunction("Forcing", 0);
217
218 // Get coordinates to evaluate functions
219 unsigned int npoints = Exp->GetNpoints();
220 unsigned int coordim = Exp->GetCoordim(0);
221 Array<OneD, NekDouble> x0(npoints), x1(npoints), x2(npoints);
222 Array<OneD, NekDouble> d00(npoints, 0.0), d00B(npoints, 0.0),
223 fcePhys(npoints);
224
225 // Define lambda
226 factors[StdRegions::eFactorLambda] = Session->GetParameter("lambda");
227 Exp->GetCoords(x0, x1, x2);
228
229 // Define 1st varcoeff
230 d00func->Evaluate(x0, x1, x2, d00);
231 varcoeffs1[StdRegions::eVarCoeffD00] = d00;
232
233 // Define 2nd varcoeff
234 d00Bfunc->Evaluate(x0, x1, x2, d00B);
235 varcoeffs2[StdRegions::eVarCoeffD00] = d00B;
236
237 // Define Forcing
238 ffunc->Evaluate(x0, x1, x2, fcePhys);
239 Fce->SetPhys(fcePhys);
240
241 // Define Advection velocities and add to varcoeff1 or 2
242 StdRegions::VarCoeffType varcoefftypes[] = {StdRegions::eVarCoeffVelX,
243 StdRegions::eVarCoeffVelY,
244 StdRegions::eVarCoeffVelZ};
245 for (int i = 0; i < coordim; i++)
246 {
247 varcoeffs1[varcoefftypes[i]] = Array<OneD, NekDouble>(npoints, 0.1);
248 varcoeffs2[varcoefftypes[i]] = Array<OneD, NekDouble>(npoints, 0.2);
249 }
250
251 // Clear solution
252 Vmath::Zero(Exp->GetNcoeffs(), Exp->UpdateCoeffs(), 1);
253}
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< Equation > EquationSharedPtr
Definition Equation.h:131
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition MeshGraph.h:217
void Zero(int n, T *x, const int incx)
Zero vector.
Definition Vmath.hpp:273

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::StdRegions::eFactorLambda, Nektar::StdRegions::eVarCoeffD00, Nektar::StdRegions::eVarCoeffVelX, Nektar::StdRegions::eVarCoeffVelY, Nektar::StdRegions::eVarCoeffVelZ, factors, Nektar::SpatialDomains::MeshGraphIO::Read(), varcoeffs1, varcoeffs2, and Vmath::Zero().

Referenced by BOOST_AUTO_TEST_CASE().

Variable Documentation

◆ contfield

MultiRegions::ContFieldSharedPtr Nektar::VarcoeffHashingTest::contfield

Definition at line 50 of file TestVarcoeffHashing.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ factors

StdRegions::ConstFactorMap Nektar::VarcoeffHashingTest::factors

◆ forcefield

MultiRegions::ContFieldSharedPtr Nektar::VarcoeffHashingTest::forcefield

Definition at line 50 of file TestVarcoeffHashing.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ lsession

LibUtilities::SessionReaderSharedPtr Nektar::VarcoeffHashingTest::lsession

Definition at line 49 of file TestVarcoeffHashing.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ pathGlobal

fs::path Nektar::VarcoeffHashingTest::pathGlobal

Definition at line 48 of file TestVarcoeffHashing.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ sessionfile

const std::string Nektar::VarcoeffHashingTest::sessionfile
static

Definition at line 57 of file TestVarcoeffHashing.cpp.

Referenced by createSessionFile().

◆ varcoeffs1

StdRegions::VarCoeffMap Nektar::VarcoeffHashingTest::varcoeffs1

◆ varcoeffs2

StdRegions::VarCoeffMap Nektar::VarcoeffHashingTest::varcoeffs2