v0.13.2
Loading...
Searching...
No Matches
Functions | Variables
scaling_method_with_program_args.cpp File Reference
#include <MoFEM.hpp>

Go to the source code of this file.

Functions

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

Variables

static char help [] = "...\n\n"
 

Function Documentation

◆ main()

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

Definition at line 13 of file scaling_method_with_program_args.cpp.

13 {
14
15 MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
16 std::vector<double> scalar_values = {1.1, 2.4, 3.6, 4.1, 3.1,
17 5.1, 9.1, 10.5, 11.2, 15.3};
18 try {
19 auto time_scale = std::make_shared<TimeScale>();
20 for (int i = 1; i <= scalar_values.size(); i++) {
21 if (std::fabs(time_scale->getScale(double(i)) - scalar_values[i - 1]) >
22 std::numeric_limits<double>::epsilon()) {
23 SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
24 "Validation for data scaling from csv "
25 "failed for time: %d value: %d",
26 double(i), time_scale->getScale(i));
27 }
28 }
29 double time1 = 3.0;
30 double time0 = 2.0;
31 double scale1 = scalar_values[2];
32 double scale0 = scalar_values[1];
33 double input_time = 2.5;
34 double interp_t = (input_time - time0) / (time1 - time0);
35 double expected_scale = scale0 + (scale1 - scale0) * interp_t;
36 double actual_scale = time_scale->getScale(2.5);
37 if (std::fabs(expected_scale - actual_scale) >
38 std::numeric_limits<double>::epsilon()) {
39 SETERRQ2(
40 PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
41 "Validation for data scaling from csv failed for time: %f value: %f",
42 2.5, time_scale->getScale(2.5));
43 }
44 }
46
48
49 return 0;
50}
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
@ MOFEM_ATOM_TEST_INVALID
Definition: definitions.h:40
FTensor::Index< 'i', SPACE_DIM > i
static char help[]
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:72
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112

Variable Documentation

◆ help

char help[] = "...\n\n"
static

Definition at line 11 of file scaling_method_with_program_args.cpp.