20 {
21
22 const string default_options = "-ksp_type fgmres \n"
23 "-pc_type lu \n"
24 "-pc_factor_mat_solver_type mumps \n"
25 "-mat_mumps_icntl_20 0 \n"
26 "-mat_mumps_icntl_13 1 \n"
27 "-ksp_monitor \n"
28 "-mat_mumps_icntl_24 1 \n"
29 "-mat_mumps_icntl_13 1 \n";
30
31 string param_file = "param_file.petsc";
32 if (!static_cast<bool>(ifstream(param_file))) {
33 std::ofstream file(param_file.c_str(), std::ios::ate);
34 if (file.is_open()) {
35 file << default_options;
36 file.close();
37 }
38 }
39
41
42 try {
43
44 moab::Core mb_instance;
45 moab::Interface &moab = mb_instance;
46
47 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
48 auto moab_comm_wrap =
49 boost::make_shared<WrapMPIComm>(PETSC_COMM_WORLD, false);
50 if (pcomm == NULL)
51 pcomm =
52 new ParallelComm(&moab, moab_comm_wrap->get_comm());
53
54
55 PetscBool flg_file;
58 PetscBool regression_test = PETSC_FALSE;
59
60 PetscOptionsBegin(PETSC_COMM_WORLD, "", "Magnetostatics options",
61 "none");
62 CHKERR PetscOptionsString(
"-my_file",
"mesh file name",
"",
"mesh.h5m",
64 CHKERR PetscOptionsInt(
"-my_order",
"default approximation order",
"",
67 "-regression_test",
68 "if set norm of solution vector is check agains expected value ",
69 "",
70 PETSC_FALSE, ®ression_test, PETSC_NULLPTR);
71
72 PetscOptionsEnd();
73
74
75 const char *option;
76 option = "PARALLEL=READ_PART;"
77 "PARALLEL_RESOLVE_SHARED_ENTS;"
78 "PARTITION=PARALLEL_PARTITION;";
80
81
84
86 magnetic.blockData.oRder =
order;
87 CHKERR magnetic.getNaturalBc();
88 CHKERR magnetic.getEssentialBc();
89 CHKERR magnetic.createFields();
90 CHKERR magnetic.createElements();
91 CHKERR magnetic.createProblem();
92 CHKERR magnetic.solveProblem(regression_test == PETSC_TRUE);
93 CHKERR magnetic.postProcessResults();
94 CHKERR magnetic.destroyProblem();
95
96
97 CHKERR moab.write_file(
"solution.h5m",
"MOAB",
"PARALLEL=WRITE_PART");
98 }
100
102 return 0;
103}
#define CATCH_ERRORS
Catch errors.
#define MYPCOMM_INDEX
default communicator number PCOMM
#define CHKERR
Inline error check.
Implementation of magneto-static problem (basic Implementation)
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.