46 {
47
49
50 try {
51
52 moab::Core mb_instance;
53 moab::Interface &moab = mb_instance;
54 int rank;
55 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
56
57 PetscBool flg = PETSC_TRUE;
58 char mesh_file_name[255];
60 mesh_file_name, 255, &flg);
61 if (flg != PETSC_TRUE) {
62 SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
63 }
64
65 const char *option;
66 option = "";
67 CHKERR moab.load_file(mesh_file_name, 0, option);
68
69
72
73
75 bit_level0.set(0);
76 EntityHandle meshset_level0;
77 CHKERR moab.create_meshset(MESHSET_SET, meshset_level0);
79 0, 3, bit_level0);
80
81
83
84
87
88
91
92
93 EntityHandle root_set = moab.get_root_set();
95 3);
97 "MESH_NODE_POSITIONS");
102
103
105
106
107
108
111 &flg);
112 if (flg != PETSC_TRUE) {
114 }
119
121 CHKERR thermal_elements.addThermalElements(
"TEMP");
123 "THERMAL_FE");
124
127 CHKERR moab.get_entities_by_type(it->getMeshset(), MBTRI, bc_tris,
true);
128 }
129
131 CHKERR analytical_bc.setFiniteElement(m_field,
"BC_FE",
"TEMP", bc_tris);
133
134
135
136
138
140
142
147
149 "MESH_NODE_POSITIONS");
151
152
153
154
157
159
162
164
172 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>("TEST_PROBLEM", &A);
173
175 thermal_elements.getLoopFeRhs().getOpPtrVector(), {H1},
176 "MESH_NODE_POSITIONS");
178 thermal_elements.getLoopFeLhs().getOpPtrVector(), {H1},
179 "MESH_NODE_POSITIONS");
180
181 CHKERR thermal_elements.setThermalFiniteElementRhsOperators(
"TEMP",
F);
182 CHKERR thermal_elements.setThermalFiniteElementLhsOperators(
"TEMP", A);
183 CHKERR thermal_elements.setThermalFluxFiniteElementRhsOperators(
"TEMP",
F);
184
188
189
192
193
194 CHKERR analytical_bc.setUpProblem(m_field,
"BC_PROBLEM");
195
196 boost::shared_ptr<AnalyticalFunction> testing_function =
198
199 CHKERR analytical_bc.setApproxOps(m_field,
"TEMP", testing_function, 0);
200 CHKERR analytical_bc.solveProblem(m_field,
"BC_PROBLEM",
"BC_FE",
201 analytical_dirichlet_bc);
202
203 CHKERR analytical_bc.destroyProblem();
204
205
207 analytical_dirichlet_bc);
208
210 thermal_elements.getLoopFeRhs());
212 thermal_elements.getLoopFeLhs());
215 thermal_elements.getLoopFeFlux());
216
217
219 analytical_dirichlet_bc);
220
221 CHKERR VecGhostUpdateBegin(
F, ADD_VALUES, SCATTER_REVERSE);
222 CHKERR VecGhostUpdateEnd(
F, ADD_VALUES, SCATTER_REVERSE);
225 CHKERR MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);
226 CHKERR MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);
227
229
230
231
232
233
234
235 KSP solver;
236 CHKERR KSPCreate(PETSC_COMM_WORLD, &solver);
237 CHKERR KSPSetOperators(solver, A, A);
238 CHKERR KSPSetFromOptions(solver);
240
242 CHKERR VecGhostUpdateBegin(T, INSERT_VALUES, SCATTER_FORWARD);
243 CHKERR VecGhostUpdateEnd(T, INSERT_VALUES, SCATTER_FORWARD);
244
245
246
247
249 "TEST_PROBLEM",
ROW, T, ADD_VALUES, SCATTER_REVERSE);
251 "TEST_PROBLEM",
ROW, T, INSERT_VALUES, SCATTER_FORWARD);
252
253
254
255
256
257 PetscReal pointwisenorm;
258 CHKERR VecMax(T, NULL, &pointwisenorm);
259 std::cout << "\n The Global Pointwise Norm of error for this problem is : "
260 << pointwisenorm << std::endl;
261
262
263
264
265
266
267
268 double sum = 0;
270 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"sum = %9.8e\n", sum);
271 double fnorm;
272 CHKERR VecNorm(T, NORM_2, &fnorm);
273 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"fnorm = %9.8e\n", fnorm);
274 if (fabs(sum + 6.46325818e-01) > 1e-7) {
276 }
277 if (fabs(fnorm - 4.26078597e+00) > 1e-6) {
279 }
280
282
284 m_field);
286 "MESH_NODE_POSITIONS");
287 auto temp_ptr = boost::make_shared<VectorDouble>();
288 auto temp_grad_ptr = boost::make_shared<MatrixDouble>();
289 auto mesh_pos_ptr = boost::make_shared<MatrixDouble>();
290 post_proc.getOpPtrVector().push_back(
292 post_proc.getOpPtrVector().push_back(
294 mesh_pos_ptr));
295 post_proc.getOpPtrVector().push_back(
298 post_proc.getOpPtrVector().push_back(
new OpPPMap(
299 post_proc.getPostProcMesh(), post_proc.getMapGaussPts(),
300 {{"TEMP", temp_ptr}},
301 {{"MESH_NODE_POSITIONS", mesh_pos_ptr},
302 {"TEMP_GRAD", temp_grad_ptr}},
303 {}, {}));
305 post_proc);
306 CHKERR post_proc.writeFile(
"out.h5m");
307 }
308
312 CHKERR KSPDestroy(&solver);
313 }
315
317
318 return 0;
319}
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
@ MOFEM_ATOM_TEST_INVALID
#define CHKERR
Inline error check.
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
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.
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
virtual MoFEMErrorCode problem_basic_method_postProcess(const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)=0
Set data for BasicMethod.
virtual MoFEMErrorCode loop_finite_elements(const std::string problem_name, const std::string &fe_name, FEMethod &method, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)=0
Make a loop over finite elements.
#define _IT_CUBITMESHSETS_BY_NAME_FOR_LOOP_(MESHSET_MANAGER, NAME, IT)
Iterator that loops over Cubit BlockSet having a particular name.
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
const FTensor::Tensor2< T, Dim, Dim > Vec
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
Structure used to enforce analytical boundary conditions.
Analytical Dirichlet boundary conditions.
Add operators pushing bases from local to physical configuration.
virtual bool check_finite_element(const std::string &name) const =0
Check if finite element is in database.
virtual MoFEMErrorCode problem_basic_method_preProcess(const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)=0
Set data for BasicMethod.
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.
Get field gradients at integration pts for scalar field rank 0, i.e. vector field.
Specialization for double precision scalar field values calculation.
Specialization for MatrixDouble vector field values calculation.
Post post-proc data at points from hash maps.
Problem manager is used to build and partition problems.
Projection of edge entities with one mid-node on hierarchical basis.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Vector manager is used to create vectors \mofem_vectors.
structure grouping operators and data used for thermal problems