Nektar++
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
StdRegions::VarCoeffMap varcoeffs1
StdRegions::VarCoeffMap varcoeffs2
StdRegions::ConstFactorMap factors

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
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(),
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(),
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(),
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(),
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)
LibUtilities::SessionReaderSharedPtr lsession

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 fs::path UniquePath(std::string specFileStem)
Create a unique (random) path, based on an input stem string. The returned string is a filename or di...
Definition: Filesystem.hpp:69
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);
232
233 // Define 2nd varcoeff
234 d00Bfunc->Evaluate(x0, x1, x2, 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
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:125
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
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().

◆ factors

StdRegions::ConstFactorMap Nektar::VarcoeffHashingTest::factors

Definition at line 52 of file TestVarcoeffHashing.cpp.

Referenced by Nektar::VelocityCorrectionScheme::AppendSVVFactors(), Nektar::HexCollectionTests::BOOST_AUTO_TEST_CASE(), Nektar::PrismCollectionTests::BOOST_AUTO_TEST_CASE(), Nektar::PyrCollectionTests::BOOST_AUTO_TEST_CASE(), Nektar::QuadCollectionTests::BOOST_AUTO_TEST_CASE(), Nektar::SegCollectionTests::BOOST_AUTO_TEST_CASE(), Nektar::TetCollectionTests::BOOST_AUTO_TEST_CASE(), Nektar::TriCollectionTests::BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), Nektar::LinearElasticSystem::BuildMatrixSystem(), Nektar::SpatialDomains::GeomFactors::ComputeDerivFactors(), Nektar::SpatialDomains::GeomFactors::ComputeMovingFrames(), Nektar::SpatialDomains::GeomFactors::ComputePrincipleDirection(), Nektar::LocalRegions::Expansion2D::CreateMatrix(), Nektar::LocalRegions::SegExp::CreateMatrix(), Diffusion::DoImplicitSolve(), Nektar::UnsteadyAdvectionDiffusion::DoImplicitSolve(), Nektar::UnsteadyDiffusion::DoImplicitSolve(), Nektar::UnsteadyViscousBurgers::DoImplicitSolve(), Nektar::Bidomain::DoImplicitSolve(), Nektar::Monodomain::DoImplicitSolve(), Nektar::MMFDiffusion::DoImplicitSolve(), Nektar::UnsteadyAdvection::DoOdeProjection(), Nektar::ImageWarpingSystem::DoOdeRhs(), Nektar::LocalRegions::QuadExp::GetEdgeInterpVals(), Nektar::LocalRegions::Expansion::GetLocMatrix(), Nektar::Collections::Helmholtz_NoCollection::Helmholtz_NoCollection(), Nektar::MultiRegions::ExpList::HelmSolve(), Nektar::Collections::Collection::Initialise(), Nektar::MultiRegions::ContField::LaplaceSolve(), Nektar::Collections::LinearAdvectionDiffusionReaction_NoCollection::LinearAdvectionDiffusionReaction_NoCollection(), Nektar::MultiRegions::ExpList::LinearAdvectionDiffusionReactionSolve(), Nektar::MultiRegions::ContField::LinearAdvectionEigs(), main(), Nektar::LocalRegions::Expansion::NormalTraceDerivFactors(), Nektar::Collections::PhysInterp1DScaled_MatrixFree::PhysInterp1DScaled_MatrixFree(), Nektar::Collections::PhysInterp1DScaled_NoCollection::PhysInterp1DScaled_NoCollection(), Nektar::SolverUtils::CouplingCwipi::ReceiveCwipi(), setupContFieldSolve(), Nektar::CoupledLinearNS::SetUpCoupledMatrix(), Nektar::Collections::CollectionOptimisation::SetWithTimings(), Nektar::SmoothedProfileMethod::SolveCorrectionPressure(), Nektar::Collections::Collection::UpdateFactors(), Nektar::Collections::Helmholtz_NoCollection::UpdateFactors(), Nektar::Collections::Helmholtz_IterPerExp::UpdateFactors(), Nektar::Collections::Helmholtz_MatrixFree::UpdateFactors(), Nektar::Collections::LinearAdvectionDiffusionReaction_NoCollection::UpdateFactors(), Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::UpdateFactors(), Nektar::Collections::LinearAdvectionDiffusionReaction_MatrixFree::UpdateFactors(), Nektar::Collections::PhysInterp1DScaled_Helper::UpdateFactors(), Nektar::Collections::PhysInterp1DScaled_MatrixFree::UpdateFactors(), Nektar::Collections::PhysInterp1DScaled_NoCollection::UpdateFactors(), Nektar::LocalRegions::Expansion2D::v_AddEdgeNormBoundaryInt(), Nektar::SteadyAdvectionDiffusion::v_DoSolve(), Nektar::StdRegions::StdQuadExp::v_GenMatrix(), Nektar::LocalRegions::Expansion1D::v_GenMatrix(), Nektar::LocalRegions::SegExp::v_GetVertexPhysVals(), Nektar::MultiRegions::ContField::v_HelmSolve(), Nektar::MultiRegions::ContField3DHomogeneous1D::v_HelmSolve(), Nektar::MultiRegions::ContField3DHomogeneous2D::v_HelmSolve(), Nektar::MultiRegions::DisContField::v_HelmSolve(), Nektar::MultiRegions::DisContField3DHomogeneous1D::v_HelmSolve(), Nektar::MultiRegions::DisContField3DHomogeneous2D::v_HelmSolve(), Nektar::MultiRegions::ContField::v_LinearAdvectionDiffusionReactionSolve(), Nektar::MultiRegions::ContField::v_LinearAdvectionReactionSolve(), Nektar::LocalRegions::Expansion1D::v_NormalTraceDerivFactors(), Nektar::MultiRegions::ExpList::v_PhysInterp1DScaled(), Nektar::FieldUtils::ProcessC0Projection::v_Process(), Nektar::VelocityCorrectionScheme::v_SolvePressure(), Nektar::VCSMapping::v_SolvePressure(), Nektar::VCSImplicit::v_SolvePressure(), Nektar::VCSWeakPressure::v_SolvePressure(), Nektar::VelocityCorrectionScheme::v_SolveViscous(), Nektar::VCSMapping::v_SolveViscous(), and Nektar::VCSImplicit::v_SolveViscous().

◆ forcefield

MultiRegions::ContFieldSharedPtr Nektar::VarcoeffHashingTest::forcefield

Definition at line 50 of file TestVarcoeffHashing.cpp.

Referenced by 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

Definition at line 53 of file TestVarcoeffHashing.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and setupContFieldSolve().

◆ varcoeffs2

StdRegions::VarCoeffMap Nektar::VarcoeffHashingTest::varcoeffs2

Definition at line 53 of file TestVarcoeffHashing.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and setupContFieldSolve().