12 {
13
15
16 try {
17
18 moab::Core mb_instance;
19 moab::Interface &moab = mb_instance;
20 int rank;
21 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
22
23 PetscBool flg = PETSC_TRUE;
27 if (flg != PETSC_TRUE) {
28 SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
29 }
30
31 const char *option;
32 option = "";
34
35
38
39
41 bit_level0.set(0);
43 rval = moab.create_meshset(MESHSET_SET, meshset_level0);
45 0, 3, bit_level0);
46
47
50
51
53
54
56
57
59
62
63
64
65
71
76
78 CHKERR thermal_elements.addThermalElements(
"TEMP");
79 CHKERR thermal_elements.addThermalFluxElement(
"TEMP");
80
82 "TEMP_RATE");
83
85 "THERMAL_FE");
87 "THERMAL_FLUX_FE");
88
89
90
91
93
95
97
101
102
103
104
107
109
113 Vec T;
117 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>("TEST_PROBLEM", &A);
118
119
121 TS ts;
122 CHKERR TSCreate(PETSC_COMM_WORLD, &ts);
123 CHKERR TSSetType(ts, TSBEULER);
124
127 "TEMP_RATE");
129
130
134
135
136 CHKERR thermal_elements.setTimeSteppingProblem(
ts_ctx,
"TEMP",
"TEMP_RATE");
137
138
142
146
147 double ftime = 1;
148 CHKERR TSSetDuration(ts, PETSC_DEFAULT, ftime);
149 CHKERR TSSetSolution(ts, T);
150 CHKERR TSSetFromOptions(ts);
151
156
157#if PETSC_VERSION_GE(3, 7, 0)
158 CHKERR TSSetExactFinalTime(ts, TS_EXACTFINALTIME_STEPOVER);
159#endif
161 CHKERR TSGetTime(ts, &ftime);
162
164
165 PetscInt steps, snesfails, rejects, nonlinits, linits;
166 CHKERR TSGetTimeStepNumber(ts, &steps);
167 CHKERR TSGetSNESFailures(ts, &snesfails);
168 CHKERR TSGetStepRejections(ts, &rejects);
169 CHKERR TSGetSNESIterations(ts, &nonlinits);
170 CHKERR TSGetKSPIterations(ts, &linits);
171 PetscPrintf(PETSC_COMM_WORLD,
172 "steps %D (%D rejected, %D SNES fails), ftime %g, nonlinits "
173 "%D, linits %D\n",
174 steps, rejects, snesfails, ftime, nonlinits, linits);
175
176
177
178
179 double sum = 0;
180 double fnorm = 0;
181
183 sit)) {
184
186 sit->get_step_number());
188 "TEST_PROBLEM",
ROW, T, INSERT_VALUES, SCATTER_FORWARD);
189
190 double sum0;
192 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"sum0 = %9.8e\n", sum0);
193 double fnorm0;
194 CHKERR VecNorm(T, NORM_2, &fnorm0);
195 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"fnorm0 = %9.8e\n", fnorm0);
196
197 sum += sum0;
198 fnorm += fnorm0;
199
200
201
202 }
203 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"sum = %9.8e\n", sum);
204 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"fnorm = %9.8e\n", fnorm);
205 if (fabs(sum + 1.32314077e+01) > 1e-7) {
207 }
208 if (fabs(fnorm - 4.59664623e+00) > 1e-6) {
210 }
211
212
213
214
215
216
217
218
219
220
221
222
223
224
229 }
231
233
234 return 0;
235}
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base nme:nme847.
@ MOFEM_ATOM_TEST_INVALID
#define CHKERR
Inline error check.
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_field)=0
set finite element field data
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
virtual MoFEMErrorCode add_ents_to_field_by_type(const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
MoFEMErrorCode partitionGhostDofs(const std::string name, int verb=VERBOSE)
determine ghost nodes
MoFEMErrorCode partitionSimpleProblem(const std::string name, int verb=VERBOSE)
partition problem dofs
MoFEMErrorCode buildProblem(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures
MoFEMErrorCode partitionFiniteElements(const std::string name, bool part_from_moab=false, int low_proc=-1, int hi_proc=-1, int verb=VERBOSE)
partition finite elements
virtual MoFEMErrorCode add_problem(const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add problem.
virtual MoFEMErrorCode modify_problem_ref_level_add_bit(const std::string &name_problem, const BitRefLevel &bit)=0
add ref level to problem
virtual MoFEMErrorCode modify_problem_add_finite_element(const std::string name_problem, const std::string &fe_name)=0
add finite element to problem, this add entities assigned to finite element to a particular problem
virtual MoFEMErrorCode load_series_data(const std::string &serie_name, const int step_number)
virtual MoFEMErrorCode finalize_series_recorder(const std::string &serie_name)
virtual MoFEMErrorCode initialize_series_recorder(const std::string &serie_name)
#define _IT_SERIES_STEPS_BY_NAME_FOR_LOOP_(RECORDER, NAME, IT)
loop over recorded series step
virtual MoFEMErrorCode add_series_recorder(const std::string &series_name)
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
PetscErrorCode TsSetIJacobian(TS ts, PetscReal t, Vec u, Vec u_t, PetscReal a, Mat A, Mat B, void *ctx)
Set function evaluating jacobian in TS solver.
PetscErrorCode TsMonitorSet(TS ts, PetscInt step, PetscReal t, Vec u, void *ctx)
Set monitor for TS solver.
PetscErrorCode TsSetIFunction(TS ts, PetscReal t, Vec u, Vec u_t, Vec F, void *ctx)
Set IFunction for TS solver.
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual MoFEMErrorCode add_field(const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
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.
Matrix manager is used to build and partition problems.
Problem manager is used to build and partition problems.
Interface for Time Stepping (TS) solver.
BasicMethodsSequence & getPostProcessIJacobian()
Get the postProcess to do IJacobian object.
BasicMethodsSequence & getPostProcessIFunction()
Get the postProcess to do IFunction object.
BasicMethodsSequence & getPreProcessIFunction()
Get the preProcess to do IFunction object.
BasicMethodsSequence & getPostProcessMonitor()
Get the postProcess to do Monitor object.
BasicMethodsSequence & getPreProcessIJacobian()
Get the preProcess to do IJacobian object.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Vector manager is used to create vectors \mofem_vectors.
TS monitore it records temperature at time steps.
this calass is to control time stepping
structure grouping operators and data used for thermal problems