38#include <SolverCore/TimeOps/TimeOp.hpp>
111 std::vector<TData> in;
116 for (
size_t el = 0;
el < block.GetNumElements(); ++
el)
118 for (
unsigned int phys = 0; phys < block.GetNumData();
121 in.push_back(1.0 + phys);
126 m_in.template CopyVector<NektarSpaces::HostSpace>(in);
132 const double final_time = 0.5;
142 void RunTestCase(
const std::string scheme,
const std::string variant,
143 const unsigned int order,
144 const std::vector<TData> freeParams,
145 const unsigned int numsteps)
148 m_out.template Copy<NektarSpaces::HostSpace>(
m_in);
152 scheme, order, variant, freeParams);
160 while (op->GetStep() < numsteps)
188 const std::string variant,
189 const unsigned int order,
190 const std::vector<TData> freeParams = {})
196 const double final_time = 0.5;
198 std::vector<double> timesteps;
202 timesteps = {0.1, 0.05, 0.025, 0.01, 0.005, 0.001, 0.0005};
206 timesteps = {0.1, 0.05, 0.025, 0.01, 0.005, 0.001};
210 timesteps = {0.1, 0.05, 0.02, 0.01, 0.005};
214 if (scheme ==
"ImplicitSDC" || scheme ==
"IMEXSDC" ||
215 scheme ==
"ImplicitGEM" || scheme ==
"IMEXGEM")
217 timesteps = {0.1, 0.05, 0.02, 0.01, 0.005};
221 timesteps = {0.2, 0.1, 0.05, 0.025};
226 if (scheme ==
"IMEXSDC")
228 timesteps = {0.1, 0.05, 0.02, 0.01, 0.005};
232 timesteps = {0.4, 0.2, 0.1};
236 std::vector<TData> errors;
238 for (
double dt : timesteps)
244 RunTestCase(scheme, variant, order, freeParams, final_time / dt);
249 errors.push_back(error);
253 std::vector<TData> orders;
254 for (
size_t i = 0; i < timesteps.size() - 1; ++i)
256 TData order =
log(errors[i] / errors[i + 1]) /
257 log(timesteps[i] / timesteps[i + 1]);
258 orders.push_back(order);
262 TData observedOrder = orders.back();
265 if (std::isnan(observedOrder) || std::isinf(observedOrder) ||
266 observedOrder < 0.9 * order)
268 std::cerr <<
"Order of accuracy test failed! Observed: "
269 << observedOrder <<
", Expected: " << order << std::endl;
274 std::cout <<
"Order of accuracy verified: " << observedOrder
299 std::string execStr(GlobalConfiguration::ExecStr());
301 BOOST_TEST_MESSAGE(
"Creating input and output fields");
307 char **argv =
new char *[argc];
308 argv[0] = strdup(
"exe_name");
310 argv[2] = strdup((
"--opExecSpace=" + execStr).c_str());
314 for (
int i = 0; i < argc; ++i)
331 const unsigned int ncomp =
m_session->GetVariables().size();
332 auto blockAttr = GetBlockAttributes<TData, FieldState::Phys>(
m_expList);
345 [[maybe_unused]]
const TData &time,
const TData &lambda)
348 auto factor = 1.0 / (1.0 - lambda *
m_beta);
359 [[maybe_unused]]
const TData &time,
const TData &factor)
370 [[maybe_unused]]
const TData &time,
const TData &factor)
381 [[maybe_unused]]
const TData &time)
389#if defined(NEKTAR_ENABLE_SINGLE_PRECISION)
390#define TESTFLOAT(type, filename) \
391 class type##float : public TestTimeOps<float> \
396 m_meshName = filename; \
400#define TESTFLOAT(type, filename)
402#if defined(NEKTAR_ENABLE_DOUBLE_PRECISION)
403#define TESTDOUBLE(type, filename) \
404 class type : public TestTimeOps<double> \
409 m_meshName = filename; \
413#define TESTDOUBLE(type, filename)
415#define TEST(type, filename) \
416 TESTFLOAT(type, filename) \
417 TESTDOUBLE(type, filename)
420TEST(segment,
"run/segment.xml")
422#include <UnitTests/TestBoostTeardown.hpp>
SpatialDomains::MeshGraphSharedPtr graph
#define NEKTAR_TEST_GLOBAL_CONFIGURATION(args)
#define TEST(type, filename)
SpatialDomains::Geometry * el
A Field represents expansion data to be operated on.
std::vector< BlockAccessor< TData, TState > > & GetBlocks()
Get BlockAccessors for the field.
unsigned int GetNumComponents() const
Gets the number of components for a vector field.
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
LIB_MATH_EXPORT T::value_type l2norm(T &, const std::string &execSpace="")
LIB_MATH_EXPORT void sub(T &x, T &y, T &z, const std::string &execSpace="")
LIB_MATH_EXPORT void mul(const typename T::value_type alpha, T &x, T &y, const std::string &execSpace="")
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static std::string GetOpExecSpace(std::shared_ptr< LibUtilities::SessionReader > session, const bool warn=true)
Return the execution space name ("opExecSpace") for an operator.
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
SessionReaderSharedPtr m_session
void DoExplicitRHS(Field< TData, FieldState::Phys > &in, Field< TData, FieldState::Phys > &out, const TData &time, const TData &factor)
Right-hand side of the non-stiff part of the test problem.
Field< TData, FieldState::Phys > m_expected
Field< TData, FieldState::Phys > m_in
void DoImplicitRHS(Field< TData, FieldState::Phys > &in, Field< TData, FieldState::Phys > &out, const TData &time, const TData &factor)
Right-hand side of the stiff part of the test problem.
ExpListSharedPtr m_expList
void RunTestCase(const std::string scheme, const std::string variant, const unsigned int order, const std::vector< TData > freeParams, const unsigned int numsteps)
Integrate the test problem for numsteps steps of the scheme given, leaving the result in the output f...
void DoProjection(Field< TData, FieldState::Phys > &in, Field< TData, FieldState::Phys > &out, const TData &time)
Projection between timesteps, the identity for this test problem.
Field< TData, FieldState::Phys > m_out
void Configure()
Read the session, build the expansion list and allocate the fields the test cases work on.
void SetSession()
Create the session from the mesh named by the derived fixture and the execution space given on the co...
void SetTestCase(const TData alpha, const TData beta)
Set the initial condition and the analytic solution it is expected to reach at the final time.
bool CheckOrderOfAccuracy(const std::string scheme, const std::string variant, const unsigned int order, const std::vector< TData > freeParams={})
Integrate the test problem over a sequence of timesteps and check the order the error converges at ag...
void DoLHS(Field< TData, FieldState::Phys > &in, Field< TData, FieldState::Phys > &out, const TData &time, const TData &lambda)
Implicit solve of the stiff part of the test problem.
void ExpectedSolution(const double final_time)
Fill the expected field with the analytic solution at final_time.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
@ beta
Gauss Radau pinned at x=-1,.
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
scalarT< T > log(scalarT< T > in)