79 BOOST_TEST_MESSAGE(
"teardown this->fixture");
101 BOOST_TEST_MESSAGE(
"Creating input and output fields");
107 char **argv =
new char *[argc];
108 argv[0] = strdup(
"exe_name");
114 for (
int i = 0; i < argc; ++i)
125 const auto &components = this->
m_session->GetVariables();
126 auto blockAttr = GetBlockAttributes<TData, FieldState::Phys>(
135 "f_expected", blockAttr, components, 1);
142 std::string execName(
143 boost::unit_test::framework::master_test_suite().argv[1]);
163 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
166 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
168 .template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
174 ++nc, x += stride, y += stride)
176 std::transform(x, x + size, y,
177 [](
const TData &xi) {
return std::abs(xi); });
184 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
187 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
189 .template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
195 ++nc, x += stride, y += stride)
197 std::transform(x, x + size, y,
198 [](
const TData &xi) {
return -xi; });
205 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
208 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
210 .template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
216 ++nc, x += stride, y += stride)
220 std::transform(x, x + size, y, [](
const TData &xi) {
221 return std::sqrt(std::abs(xi));
229 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
232 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
234 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
236 .template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
242 ++nc, x += stride, y += stride, z += stride)
246 [](
const TData &xi,
const TData &yi) {
return xi + yi; });
253 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
256 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
258 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
260 .template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
266 ++nc, x += stride, y += stride, z += stride)
270 [](
const TData &xi,
const TData &yi) {
return xi - yi; });
277 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
280 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
282 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
284 .template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
290 ++nc, x += stride, y += stride, z += stride)
294 [](
const TData &xi,
const TData &yi) {
return xi * yi; });
301 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
304 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
306 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
308 .template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
314 ++nc, x += stride, y += stride, z += stride)
316 std::transform(x, x + size, y, z,
317 [](
const TData &xi,
const TData &yi) {
318 return (yi == TData(0)) ? TData(0) : xi / yi;
326 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
329 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
331 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
333 .template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
339 ++nc, x += stride, y += stride, z += stride)
341 std::transform(x, x + size, y, z,
342 [=](
const TData &xi,
const TData &yi) {
343 return alpha * xi + yi;
351 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
354 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
356 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
358 .template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
364 ++nc, x += stride, y += stride, z += stride)
366 std::transform(x, x + size, y, z,
367 [=](
const TData &xi,
const TData &yi) {
368 return alpha * xi +
beta * yi;
377 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
380 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
382 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
384 .template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
390 ++nc, x += stride, y += stride, z += stride)
392 std::transform(x, x + size, y, z,
393 [=](
const TData &xi,
const TData &yi) {
394 return alpha * xi +
beta * yi + gamma * xi;
403 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
406 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
414 out = std::accumulate(x, x + size, out);
422 TData out = std::numeric_limits<TData>::lowest();
423 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
426 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
434 out = std::max(out, *(std::max_element(x, x + size)));
442 TData out = std::numeric_limits<TData>::max();
443 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
446 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
454 out = std::min(out, *(std::min_element(x, x + size)));
463 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
466 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
468 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
474 ++nc, x += stride, y += stride)
476 out = std::inner_product(x, x + size, y, out);
485 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
488 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
496 out = std::accumulate(x, x + size, out,
497 [](
const TData &acc,
const TData &val) {
498 return acc + std::abs(val);
508 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
511 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
519 out = std::accumulate(x, x + size, out,
520 [](
const TData &acc,
const TData &val) {
521 return acc + val * val;
531 for (
unsigned int blk = 0; blk < this->
m_in1->
GetBlocks().size(); ++blk)
534 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
542 out = std::accumulate(
543 x, x + size, out, [](
const TData &acc,
const TData &val) {
544 return std::max(std::abs(acc), std::abs(val));
563 this->m_out->GetNumComponents())
565 std::cout <<
"Mismatch of number of components." << std::endl;
570 this->m_out->GetNumHomoModes())
572 std::cout <<
"Mismatch of number of homogeneous modes."
578 this->m_out->GetBlocks().size())
580 std::cout <<
"Mismatch of block size." << std::endl;
588 printf(
"#elm #pts output expected "
591 for (
unsigned int blk = 0; blk < this->
m_out->
GetBlocks().size(); ++blk)
593 const TData *outptr =
595 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
596 const TData *expptr =
598 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
601 this->m_expected->GetBlocks()[blk].GetNumElements()) ||
602 (this->m_out->GetBlocks()[blk].GetNumData() !=
603 this->m_expected->GetBlocks()[blk].GetNumData()))
605 std::cout <<
"Mismatch of block structure." << std::endl;
613 size_t MisMatchcnt = 0, total = 0;
615 for (
size_t el = 0, cnt = 0;
618 for (
unsigned int pts = 0;
622 if (std::isnan(outptr[cnt]) ||
623 std::isinf(outptr[cnt]) ||
624 std::abs(outptr[cnt] - expptr[cnt]) > tol)
626 printf(
"%04lu %04u %20.16f %20.16f %20.16f\n",
el,
627 pts, outptr[cnt], expptr[cnt],
628 std::abs(outptr[cnt] - expptr[cnt]));
640 std::cout <<
"Number of mismatches in component " << n
641 <<
" on block " << blk <<
" is " << MisMatchcnt
642 <<
" out of " << total <<
" on rank: " <<
rank
678 for (
unsigned int nc = 0; nc < field.GetNumComponents(); ++nc)
680 auto func = this->m_session->GetFunction(name, nc);
681 func->Evaluate(x, y, z, fce);
683 auto ptr = fce.data();
684 for (
unsigned int blk = 0; blk < field.GetBlocks().size(); ++blk)
686 auto &block = field.GetBlocks()[blk];
688 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
689 auto size = block.GetNumElements() * block.GetNumData();
690 std::copy(ptr, ptr + size, inptr + nc * block.CompSize());
SpatialDomains::MeshGraphSharedPtr graph
#define NEKTAR_TEST_GLOBAL_CONFIGURATION(args)
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 GetNumHomoModes() const
Gets the number of homogeneous modes.
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.
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)
ExpListSharedPtr m_expList
SessionReaderSharedPtr m_session
void daxpbypcz(TData alpha, TData beta, TData gamma)
w = alpha x + beta y + gamma z, with z = x.
Field< TData, FieldState::Phys > * m_expected
void Evaluate(const std::string &name, Field< TData, FieldState::Phys > &field, Array< OneD, double > &x, Array< OneD, double > &y, Array< OneD, double > &z, Array< OneD, double > &fce)
Fills every component of field with the session function name evaluated for the variable of that comp...
bool Compare(TData tol)
Compare this field to another field, with absolute tolerance tol. Two fields must have same storage s...
Field< TData, FieldState::Phys > * m_in1
void daxpby(TData alpha, TData beta)
Field< TData, FieldState::Phys > * m_out
Field< TData, FieldState::Phys > * m_in2
std::shared_ptr< SessionReader > SessionReaderSharedPtr
@ beta
Gauss Radau pinned at x=-1,.
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.