37#include <boost/filesystem.hpp>
38#include <boost/filesystem/fstream.hpp>
39#include <boost/test/unit_test.hpp>
43namespace VarcoeffHashingTest
45using namespace MultiRegions;
58 R
"END(<?xml version="1.0" encoding="UTF-8"?>
60 <GEOMETRY DIM="2" SPACE="2">
63 <V ID="0"> 0.0 0.0 0.0 </V>
64 <V ID="1"> 0.5 0.0 0.0 </V>
65 <V ID="2"> 1.0 0.0 0.0 </V>
66 <V ID="3"> 0.0 0.5 0.0 </V>
67 <V ID="4"> 0.5 0.5 0.0 </V>
68 <V ID="5"> 1.0 0.5 0.0 </V>
69 <V ID="6"> 0.0 1.0 0.0 </V>
70 <V ID="7"> 0.5 1.0 0.0 </V>
71 <V ID="8"> 1.0 1.0 0.0 </V>
90 <Q ID="0"> 0 3 5 2 </Q>
91 <Q ID="1"> 1 4 6 3 </Q>
92 <Q ID="2"> 5 8 10 7 </Q>
93 <Q ID="3"> 6 9 11 8 </Q>
97 <C ID="0"> Q[0-3] </C>
98 <C ID="1"> E[0,1] </C> <!-- Lower wall -->
99 <C ID="2"> E[2,7] </C> <!-- Inflow -->
100 <C ID="3"> E[4,9] </C> <!-- Outflow -->
101 <C ID="4"> E[10,11] </C> <!-- Upper wall -->
104 <DOMAIN> C[0] </DOMAIN>
109 <E COMPOSITE="C[0]" FIELDS="u" TYPE="MODIFIED" NUMMODES="3"/>
115 <P> lambda = 1.0 </P>
129 <REGION REF="0"> <!-- Stationary -->
130 <D VAR="u" VALUE="0" />
132 <REGION REF="1"> <!-- Inflow -->
133 <D VAR="u" VALUE="y" />
135 <REGION REF="2"> <!-- Outflow -->
136 <N VAR="u" VALUE="0" />
138 <REGION REF="3"> <!-- Moving -->
139 <D VAR="u" VALUE="1" />
141 </BOUNDARYCONDITIONS>
143 <FUNCTION NAME="d00">
144 <E VAR="u" VALUE="0.1*y" />
147 <FUNCTION NAME="d00B">
148 <E VAR="u" VALUE="0.5*y" />
151 <FUNCTION NAME="Forcing">
152 <E VAR="u" VALUE="sin(y)" />
155 <FUNCTION NAME="ExactSolution">
156 <E VAR="u" VALUE="y" />
171 using namespace boost::filesystem;
172 ph = temp_directory_path() / unique_path();
173 create_directories(ph);
176 ph /=
"TestVarcoeffHashing.xml";
177 boost::filesystem::ofstream sfile(ph);
194 const std::wstring input_file_wstr(ph.c_str());
195 const std::string input_file_str(input_file_wstr.begin(),
196 input_file_wstr.end());
197 char *input_file = (
char *)input_file_str.c_str();
199 char *input_file = (
char *)ph.c_str();
204 char *argv[] = {(
char *)(
"IncNavierStokesSolver"), input_file,
nullptr};
211 Session,
Graph, Session->GetVariable(0));
220 unsigned int npoints = Exp->GetNpoints();
221 unsigned int coordim = Exp->GetCoordim(0);
228 Exp->GetCoords(x0, x1, x2);
231 d00func->Evaluate(x0, x1, x2, d00);
235 d00Bfunc->Evaluate(x0, x1, x2, d00B);
239 ffunc->Evaluate(x0, x1, x2, fcePhys);
240 Fce->SetPhys(fcePhys);
246 for (
int i = 0; i < coordim; i++)
253 Vmath::Zero(Exp->GetNcoeffs(), Exp->UpdateCoeffs(), 1);
263 BOOST_CHECK_EQUAL(
contfield->GetPoolCount(
"GlobalLinSys"), 0);
270 BOOST_CHECK_EQUAL(
contfield->GetPoolCount(
"GlobalLinSys"), 1);
277 BOOST_CHECK_EQUAL(
contfield->GetPoolCount(
"GlobalLinSys"), 2);
284 BOOST_CHECK_EQUAL(
contfield->GetPoolCount(
"GlobalLinSys"), 2);
291 BOOST_CHECK_EQUAL(
contfield->GetPoolCount(
"GlobalLinSys"), 2);
300 BOOST_CHECK_EQUAL(
contfield->GetPoolCount(
"GlobalLinSys"), 0);
303 auto gkey1 =
contfield->LinearAdvectionDiffusionReactionSolve(
307 BOOST_CHECK_EQUAL(
contfield->GetPoolCount(
"GlobalLinSys"), 1);
310 auto gkey2 =
contfield->LinearAdvectionDiffusionReactionSolve(
314 BOOST_CHECK_EQUAL(
contfield->GetPoolCount(
"GlobalLinSys"), 2);
317 contfield->UnsetGlobalLinSys(gkey1,
true);
320 BOOST_CHECK_EQUAL(
contfield->GetPoolCount(
"GlobalLinSys"), 1);
323 contfield->UnsetGlobalLinSys(gkey2,
true);
326 BOOST_CHECK_EQUAL(
contfield->GetPoolCount(
"GlobalLinSys"), 0);
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
std::shared_ptr< ContField > ContFieldSharedPtr
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::map< ConstFactorType, NekDouble > ConstFactorMap
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
MultiRegions::ContFieldSharedPtr forcefield
static const std::string sessionfile
MultiRegions::ContFieldSharedPtr contfield
void setupContFieldSolve(boost::filesystem::path &ph, LibUtilities::SessionReaderSharedPtr &Session, MultiRegions::ContFieldSharedPtr &Exp, MultiRegions::ContFieldSharedPtr &Fce)
boost::filesystem::path pathGlobal
BOOST_AUTO_TEST_CASE(TestVarcoeffHashing)
LibUtilities::SessionReaderSharedPtr lsession
StdRegions::VarCoeffMap varcoeffs1
StdRegions::VarCoeffMap varcoeffs2
void createSessionFile(boost::filesystem::path &ph)
StdRegions::ConstFactorMap factors
The above copyright notice and this permission notice shall be included.
void Zero(int n, T *x, const int incx)
Zero vector.