v0.16.3
Loading...
Searching...
No Matches
Functions
testing_interface.cpp File Reference

Collective comparisons and accepted-step numerical testing. More...

#include <MoFEM.hpp>
#include <memory>
#include <sstream>
#include <type_traits>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

Collective comparisons and accepted-step numerical testing.

Definition in file testing_interface.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 591 of file testing_interface.cpp.

591 {
592 MoFEM::Core::Initialize(&argc, &argv, nullptr,
593 "Numerical testing interface\n");
594 try {
595 moab::Core moab_core;
596 MoFEM::Core mofem_core(moab_core);
597 std::unique_ptr<TestingInterface> owned_testing(
599 if (owned_testing->getInterface<TestingInterface>() != owned_testing.get())
600 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
601 "Factory-created testing interface cannot be queried");
602 CHKERR owned_testing->checkValue<TestType::SCALAR>(
603 "factory-created interface", 1., 1., {0., 0.});
604 auto calls = std::make_shared<int>(0);
605 auto hook = [calls]() -> MoFEMErrorCode { ++*calls; return 0; };
606 CHKERR PetscOptionsSetValue(nullptr, "-registry_test_nb", "2");
607 CHKERR owned_testing->getOptions("registry_");
608 CHKERR owned_testing->addTestCommandLine("registry_", 1, "first", hook);
609 CHKERR owned_testing->addTestCommandLine("registry_", 2, "second", hook);
610 CHKERR owned_testing->runTests();
611 CHKERR owned_testing->checkValue<TestType::SCALAR>(
612 "number selection", *calls, 1., {0., 0.});
613 CHKERR PetscOptionsClearValue(nullptr, "-registry_test_nb");
614 CHKERR PetscOptionsSetValue(nullptr, "-registry_test_name", "second");
615 // Cached selection remains valid until explicitly refreshed.
616 CHKERR owned_testing->runTestCommandLine("registry_");
617 CHKERR owned_testing->getOptions("registry_");
618 CHKERR owned_testing->runTestCommandLine("registry_");
619 CHKERR owned_testing->checkValue<TestType::SCALAR>(
620 "cached and named selection", *calls, 3., {0., 0.});
621 CHKERR PetscOptionsClearValue(nullptr, "-registry_test_name");
622 CHKERR checkSelection(mofem_core);
623 CHKERR checkSelectedExecution(mofem_core);
624 CHKERR runTests(mofem_core);
625 }
628 return 0;
629}
TestHook hook
#define CATCH_ERRORS
Catch errors.
@ MOFEM_ATOM_TEST_INVALID
Definition definitions.h:40
#define CHKERR
Inline error check.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
TestingInterface * createInterface< TestingInterface >(const Core &core)
Core (interface) class.
Definition Core.hpp:83
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition Core.cpp:68
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:123