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 295 of file TestVarcoeffHashing.cpp.

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

255{
256 // Create session file and setup Contfield
259
260 // Check no initial GlobalLinSys i.e. count == 0
261 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 0);
262
263 // Create GlobalLinSys(varcoeff1)
264 contfield->HelmSolve(forcefield->GetPhys(), contfield->UpdateCoeffs(),
266
267 // Check count == 1
268 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 1);
269
270 // Create new GlobalLinSys(varcoeff2)
271 contfield->HelmSolve(forcefield->GetPhys(), contfield->UpdateCoeffs(),
273
274 // Check count == 2
275 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 2);
276
277 // Again use 2nd GlobalLinSys(varcoeff2)
278 contfield->HelmSolve(forcefield->GetPhys(), contfield->UpdateCoeffs(),
280
281 // Check count still == 2
282 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 2);
283
284 // Again use 1st GlobalLinSys(varcoeff1)
285 contfield->HelmSolve(forcefield->GetPhys(), contfield->UpdateCoeffs(),
287
288 // Check count still == 2
289 BOOST_CHECK_EQUAL(contfield->GetPoolCount("GlobalLinSys"), 2);
290
291 // Clear for next tests
292 contfield->ClearGlobalLinSysManager();
293}
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 167 of file TestVarcoeffHashing.cpp.

168{
169 // Create temporary directory
170 ph = fs::temp_directory_path() / LibUtilities::UniquePath("varctest");
171 fs::create_directories(ph);
172
173 // Create file in working directory
174 ph /= "TestVarcoeffHashing.xml"; // append filename
175 std::ofstream sfile(ph);
176 sfile << sessionfile;
177 sfile.close();
178}
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 185 of file TestVarcoeffHashing.cpp.

189{
190#ifdef _WIN32
191 // Prepare input file name - convert wstring to string to support Windows
192 const std::wstring input_file_wstr(ph.c_str());
193 const std::string input_file_str(input_file_wstr.begin(),
194 input_file_wstr.end());
195 char *input_file = (char *)input_file_str.c_str();
196#else
197 char *input_file = (char *)ph.c_str();
198#endif
199
200 // Setup parameters for call to IncNavierStokesSolver
201 int argc = 2;
202 char *argv[] = {(char *)("IncNavierStokesSolver"), input_file, nullptr};
203
204 // Read Session, MeshGraph and create ContField
205 Session = LibUtilities::SessionReader::CreateInstance(argc, argv);
207 SpatialDomains::MeshGraph::Read(Session);
209 Session, Graph, Session->GetVariable(0));
211
212 // Read functons for varcoeffs and Forcing
213 LibUtilities::EquationSharedPtr d00func = Session->GetFunction("d00", 0);
214 LibUtilities::EquationSharedPtr d00Bfunc = Session->GetFunction("d00B", 0);
215 LibUtilities::EquationSharedPtr ffunc = Session->GetFunction("Forcing", 0);
216
217 // Get coordinates to evaluate functions
218 unsigned int npoints = Exp->GetNpoints();
219 unsigned int coordim = Exp->GetCoordim(0);
220 Array<OneD, NekDouble> x0(npoints), x1(npoints), x2(npoints);
221 Array<OneD, NekDouble> d00(npoints, 0.0), d00B(npoints, 0.0),
222 fcePhys(npoints);
223
224 // Define lambda
225 factors[StdRegions::eFactorLambda] = Session->GetParameter("lambda");
226 Exp->GetCoords(x0, x1, x2);
227
228 // Define 1st varcoeff
229 d00func->Evaluate(x0, x1, x2, d00);
231
232 // Define 2nd varcoeff
233 d00Bfunc->Evaluate(x0, x1, x2, d00B);
235
236 // Define Forcing
237 ffunc->Evaluate(x0, x1, x2, fcePhys);
238 Fce->SetPhys(fcePhys);
239
240 // Define Advection velocities and add to varcoeff1 or 2
244 for (int i = 0; i < coordim; i++)
245 {
246 varcoeffs1[varcoefftypes[i]] = Array<OneD, NekDouble>(npoints, 0.1);
247 varcoeffs2[varcoefftypes[i]] = Array<OneD, NekDouble>(npoints, 0.2);
248 }
249
250 // Clear solution
251 Vmath::Zero(Exp->GetNcoeffs(), Exp->UpdateCoeffs(), 1);
252}
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::MeshGraph::Read(), varcoeffs1, varcoeffs2, and Vmath::Zero().

Referenced by BOOST_AUTO_TEST_CASE().

Variable Documentation

◆ contfield

MultiRegions::ContFieldSharedPtr Nektar::VarcoeffHashingTest::contfield

Definition at line 49 of file TestVarcoeffHashing.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ factors

StdRegions::ConstFactorMap Nektar::VarcoeffHashingTest::factors

Definition at line 51 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::TetCollectionTests::BOOST_AUTO_TEST_CASE(), Nektar::TriCollectionTests::BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), Nektar::LinearElasticSystem::BuildMatrixSystem(), Nektar::Collections::Collection::CheckFactors(), Nektar::Collections::Helmholtz_NoCollection::CheckFactors(), Nektar::Collections::Helmholtz_IterPerExp::CheckFactors(), Nektar::Collections::Helmholtz_MatrixFree::CheckFactors(), Nektar::Collections::PhysInterp1DScaled_Helper::CheckFactors(), Nektar::Collections::PhysInterp1DScaled_StdMat::CheckFactors(), Nektar::Collections::PhysInterp1DScaled_IterPerExp::CheckFactors(), Nektar::Collections::PhysInterp1DScaled_NoCollection::CheckFactors(), 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::MultiRegions::ExpList::LinearAdvectionDiffusionReactionSolve(), Nektar::MultiRegions::ContField::LinearAdvectionEigs(), main(), Nektar::LocalRegions::Expansion::NormalTraceDerivFactors(), Nektar::Collections::PhysInterp1DScaled_NoCollection::PhysInterp1DScaled_NoCollection(), Nektar::SolverUtils::CouplingCwipi::ReceiveCwipi(), setupContFieldSolve(), Nektar::CoupledLinearNS::SetUpCoupledMatrix(), Nektar::Collections::CollectionOptimisation::SetWithTimings(), Nektar::SmoothedProfileMethod::SolveCorrectionPressure(), 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 49 of file TestVarcoeffHashing.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ lsession

LibUtilities::SessionReaderSharedPtr Nektar::VarcoeffHashingTest::lsession

Definition at line 48 of file TestVarcoeffHashing.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ pathGlobal

fs::path Nektar::VarcoeffHashingTest::pathGlobal

Definition at line 47 of file TestVarcoeffHashing.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ sessionfile

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

Definition at line 56 of file TestVarcoeffHashing.cpp.

Referenced by createSessionFile().

◆ varcoeffs1

StdRegions::VarCoeffMap Nektar::VarcoeffHashingTest::varcoeffs1

Definition at line 52 of file TestVarcoeffHashing.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and setupContFieldSolve().

◆ varcoeffs2

StdRegions::VarCoeffMap Nektar::VarcoeffHashingTest::varcoeffs2

Definition at line 52 of file TestVarcoeffHashing.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and setupContFieldSolve().