12static char help[] =
"...\n\n";
35 using PostProcEle::PostProcEle;
92 PetscBool load_file = PETSC_FALSE;
96 if (load_file == PETSC_FALSE) {
103 double tet_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
105 for (
int nn = 0; nn < 4; nn++) {
106 CHKERR moab.create_vertex(&tet_coords[3 * nn], nodes[nn]);
109 CHKERR moab.create_element(MBTET, nodes, 4, tet);
111 for (
auto d : {1, 2})
112 CHKERR moab.get_adjacencies(&tet, 1, d,
true, adj);
118 double tri_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0};
120 for (
int nn = 0; nn < 3; nn++) {
121 CHKERR moab.create_vertex(&tri_coords[3 * nn], nodes[nn]);
124 CHKERR moab.create_element(MBTRI, nodes, 3, tri);
126 CHKERR moab.get_adjacencies(&tri, 1, 1,
true, adj);
154 enum bases { AINSWORTH, AINSWORTH_LOBATTO, DEMKOWICZ, BERNSTEIN, LASBASETOP };
155 const char *list_bases[] = {
"ainsworth",
"ainsworth_lobatto",
"demkowicz",
159 PetscInt choice_base_value = AINSWORTH;
161 &choice_base_value, &flg);
162 if (flg != PETSC_TRUE)
165 if (choice_base_value == AINSWORTH)
167 if (choice_base_value == AINSWORTH_LOBATTO)
169 else if (choice_base_value == DEMKOWICZ)
171 else if (choice_base_value == BERNSTEIN)
174 const char *list_continuity[] = {
"continuous",
"discontinuous"};
175 PetscInt choice_continuity_value =
CONTINUOUS;
187 enum spaces { H1SPACE, L2SPACE, HCURLSPACE, HDIVSPACE, LASBASETSPACE };
188 const char *list_spaces[] = {
"h1",
"l2",
"hcurl",
"hdiv"};
189 PetscInt choice_space_value = H1SPACE;
191 LASBASETSPACE, &choice_space_value, &flg);
192 if (flg != PETSC_TRUE)
195 if (choice_space_value == H1SPACE)
197 else if (choice_space_value == L2SPACE)
199 else if (choice_space_value == HCURLSPACE)
201 else if (choice_space_value == HDIVSPACE)
256 auto post_proc_fe = boost::make_shared<MyPostProc>(
mField);
257 post_proc_fe->generateReferenceElementMesh();
262 auto jac_ptr = boost::make_shared<MatrixDouble>();
263 post_proc_fe->getOpPtrVector().push_back(
266 post_proc_fe->getOpPtrVector().push_back(
279 auto u_ptr = boost::make_shared<VectorDouble>();
280 post_proc_fe->getOpPtrVector().push_back(
282 post_proc_fe->getOpPtrVector().push_back(
286 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
307 post_proc_fe->getOpPtrVector(), {space});
308 auto u_ptr = boost::make_shared<MatrixDouble>();
309 post_proc_fe->getOpPtrVector().push_back(
312 post_proc_fe->getOpPtrVector().push_back(
316 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
334 auto scale_tag_val = [&]() {
336 auto &post_proc_mesh = post_proc_fe->getPostProcMesh();
338 CHKERR post_proc_mesh.get_entities_by_type(0, MBVERTEX, nodes);
340 CHKERR post_proc_mesh.tag_get_handle(
"U",
th);
342 CHKERR post_proc_mesh.tag_get_length(
th, length);
343 std::vector<double> data(nodes.size() * length);
344 CHKERR post_proc_mesh.tag_get_data(
th, nodes, &*data.begin());
346 for (
int i = 0;
i != nodes.size(); ++
i) {
348 for (
int d = 0;
d != length; ++
d)
349 v += pow(data[length *
i + d], 2);
351 max_v = std::max(max_v,
v);
355 CHKERR post_proc_mesh.tag_set_data(
th, nodes, &*data.begin());
359 auto prb_ptr = mField.get_problem(simpleInterface->getProblemName());
362 auto dofs_ptr = prb_ptr->getNumeredRowDofsPtr();
364 for (
auto dof_ptr : (*dofs_ptr)) {
365 MOFEM_LOG(
"PLOTBASE", Sev::verbose) << *dof_ptr;
366 auto &val =
const_cast<double &
>(dof_ptr->getFieldData());
370 CHKERR post_proc_fe->writeFile(
371 "out_base_dof_" + boost::lexical_cast<std::string>(nb) +
".h5m");
372 CHKERR post_proc_fe->getPostProcMesh().delete_mesh();
385int main(
int argc,
char *argv[]) {
393 DMType dm_name =
"DMMOFEM";
398 auto core_log = logging::core::get();
405 moab::Core mb_instance;
406 moab::Interface &moab = mb_instance;
429 moab::Interface &moab_ref = core_ref;
431 char ref_mesh_file_name[255];
434 strcpy(ref_mesh_file_name,
"ref_mesh2d.h5m");
436 strcpy(ref_mesh_file_name,
"ref_mesh3d.h5m");
439 "Dimension not implemented");
443 CHKERR moab_ref.load_file(ref_mesh_file_name, 0,
"");
451 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
452 CHKERR moab_ref.add_entities(meshset, elems);
453 CHKERR moab_ref.convert_entities(meshset,
true,
false,
false);
454 CHKERR moab_ref.delete_entities(&meshset, 1);
458 CHKERR moab_ref.get_connectivity(elems, elem_nodes,
false);
461 std::map<EntityHandle, int> nodes_pts_map;
464 gaussPts.resize(
SPACE_DIM + 1, elem_nodes.size(),
false);
466 Range::iterator nit = elem_nodes.begin();
467 for (
int gg = 0; nit != elem_nodes.end(); nit++, gg++) {
469 CHKERR moab_ref.get_coords(&*nit, 1, coords);
470 for (
auto d : {0, 1, 2})
471 gaussPts(d, gg) = coords[d];
472 nodes_pts_map[*nit] = gg;
484 Range::iterator tit = elems.begin();
485 for (
int tt = 0; tit != elems.end(); ++tit, ++tt) {
488 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes,
false);
489 for (
int nn = 0; nn != num_nodes; ++nn) {
490 refEleMap(tt, nn) = nodes_pts_map[conn[nn]];
500 const int num_nodes = gaussPts.size2();
504 switch (numeredEntFiniteElementPtr->getEntType()) {
508 &gaussPts(0, 0), &gaussPts(1, 0), num_nodes);
512 for (
int gg = 0; gg != num_nodes; gg++) {
513 double ksi = gaussPts(0, gg);
514 double eta = gaussPts(1, gg);
524 &gaussPts(0, 0), &gaussPts(1, 0),
525 &gaussPts(2, 0), num_nodes);
529 for (
int gg = 0; gg != num_nodes; gg++) {
530 double ksi = gaussPts(0, gg);
531 double eta = gaussPts(1, gg);
532 double zeta = gaussPts(2, gg);
545 "Not implemented element type");
551 ReadUtilIface *iface;
552 CHKERR getPostProcMesh().query_interface(iface);
554 std::vector<double *> arrays;
559 CHKERR iface->get_node_coords(3, num_nodes, 0, startv, arrays);
561 mapGaussPts.resize(gaussPts.size2());
562 for (
int gg = 0; gg != num_nodes; ++gg)
563 mapGaussPts[gg] = startv + gg;
566 int def_in_the_loop = -1;
567 CHKERR getPostProcMesh().tag_get_handle(
"NB_IN_THE_LOOP", 1, MB_TYPE_INTEGER,
568 th, MB_TAG_CREAT | MB_TAG_SPARSE,
574 const int num_nodes_on_ele =
refEleMap.size2();
581 CHKERR iface->get_element_connect(num_el, num_nodes_on_ele, MBTRI, 0,
584 CHKERR iface->get_element_connect(num_el, num_nodes_on_ele, MBTET, 0,
588 "Dimension not implemented");
592 for (
unsigned int tt = 0; tt !=
refEleMap.size1(); ++tt) {
593 for (
int nn = 0; nn != num_nodes_on_ele; ++nn)
594 conn[num_nodes_on_ele * tt + nn] = mapGaussPts[
refEleMap(tt, nn)];
599 CHKERR iface->update_adjacencies(starte, num_el, num_nodes_on_ele, conn);
601 auto physical_elements =
Range(starte, starte + num_el - 1);
602 CHKERR getPostProcMesh().tag_clear_data(
th, physical_elements, &(nInTheLoop));
604 EntityHandle fe_ent = numeredEntFiniteElementPtr->getEnt();
608 mField.get_moab().get_connectivity(fe_ent, conn, fe_num_nodes,
true);
609 coords.resize(3 * fe_num_nodes,
false);
610 CHKERR mField.get_moab().get_coords(conn, fe_num_nodes, &coords[0]);
619 arrays[0], arrays[1], arrays[2]);
620 const double *t_coords_ele_x = &coords[0];
621 const double *t_coords_ele_y = &coords[1];
622 const double *t_coords_ele_z = &coords[2];
623 for (
int gg = 0; gg != num_nodes; ++gg) {
625 t_coords_ele_x, t_coords_ele_y, t_coords_ele_z);
627 for (
int nn = 0; nn != fe_num_nodes; ++nn) {
628 t_coords(
i) += t_n * t_ele_coords(
i);
629 for (
auto ii : {0, 1, 2})
630 if (std::abs(t_coords(ii)) < std::numeric_limits<float>::epsilon())
643 ParallelComm *pcomm_post_proc_mesh =
645 if (pcomm_post_proc_mesh != NULL)
646 delete pcomm_post_proc_mesh;
653 auto resolve_shared_ents = [&]() {
656 ParallelComm *pcomm_post_proc_mesh =
657 ParallelComm::get_pcomm(&(getPostProcMesh()),
MYPCOMM_INDEX);
658 if (pcomm_post_proc_mesh == NULL) {
661 pcomm_post_proc_mesh =
new ParallelComm(
662 &(getPostProcMesh()),
666 CHKERR pcomm_post_proc_mesh->resolve_shared_ents(0);
671 CHKERR resolve_shared_ents();
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
#define CATCH_ERRORS
Catch errors.
FieldApproximationBase
approximation base
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
@ AINSWORTH_BERNSTEIN_BEZIER_BASE
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
FieldSpace
approximation spaces
@ L2
field with C-1 continuity
@ HCURL
field with continuous tangents
@ HDIV
field with continuous normal traction
#define MYPCOMM_INDEX
default communicator number PCOMM
FieldContinuity
Field continuity.
@ CONTINUOUS
Regular field.
@ DISCONTINUOUS
Broken continuity (No effect on L2 space)
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
MoFEMErrorCode loopFiniteElementsPostProc(SmartPetscObj< DM > dm=nullptr)
Iterate postprocessing finite elements.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
MoFEMErrorCode removeSideDOFs(const std::string problem_name, const std::string block_name, const std::string field_name, int bridge_dim, int lo, int hi, bool is_distributed_mesh=true)
Remove DOFs on side entities from problem.
FTensor::Index< 'i', SPACE_DIM > i
const double v
phase velocity of light in medium (cm/ns)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
OpCalculateHOJacForFaceImpl< 2 > OpCalculateHOJacForFace
OpSetContravariantPiolaTransformOnFace2DImpl< 2 > OpSetContravariantPiolaTransformOnFace2D
PetscErrorCode PetscOptionsGetEList(PetscOptions *, const char pre[], const char name[], const char *const *list, PetscInt next, PetscInt *value, PetscBool *set)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
MoFEMErrorCode boundaryCondition()
MoFEMErrorCode assembleSystem()
MoFEMErrorCode readMesh()
MoFEMErrorCode setIntegrationRules()
[Set up problem]
FieldApproximationBase base
Choice of finite element basis functions.
MoFEMErrorCode checkResults()
MoFEMErrorCode solveSystem()
MoFEMErrorCode createCommonData()
Example(MoFEM::Interface &m_field)
MoFEMErrorCode runProblem()
MoFEM::Interface & mField
Reference to MoFEM interface.
MoFEMErrorCode setupProblem()
MoFEMErrorCode outputResults()
Add operators pushing bases from local to physical configuration.
static boost::function< int(int)> broken_nbvolumetet_edge_hdiv
static boost::function< int(int)> broken_nbvolumetet_face_hdiv
static boost::function< int(int)> broken_nbfacetri_face_hdiv
static boost::function< int(int)> broken_nbvolumetet_volume_hdiv
static boost::function< int(int)> broken_nbfacetri_edge_hdiv
Boundary condition manager for finite element problem setup.
virtual moab::Interface & get_moab()=0
virtual MoFEMErrorCode rebuild_database(int verb=DEFAULT_VERBOSITY)=0
Clear database and initialize it once again.
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.
Data on single entity (This is passed as argument to DataOperator::doWork)
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Get vector field for H-div approximation.
Specialization for double precision scalar field values calculation.
Make Hdiv space from Hcurl space in 2d.
Post post-proc data at points from hash maps.
PipelineManager interface.
boost::shared_ptr< FEMethod > & getDomainPostProcFE()
Get domain postprocessing finite element.
Simple interface for fast problem set-up.
MoFEMErrorCode addDomainField(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_ZERO, int verb=-1)
Add field on domain.
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
void setDim(int dim)
Set the problem dimension.
MoFEMErrorCode getOptions()
get options
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
const std::string getProblemName() const
Get the Problem Name.
BitRefLevel & getBitRefLevel()
Get the BitRefLevel.
MoFEMErrorCode addDomainBrokenField(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_ZERO, int verb=-1)
Add broken field on domain.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Volume finite element base.
MoFEMErrorCode postProcess()
MoFEMErrorCode generateReferenceElementMesh()
ublas::matrix< int > refEleMap
MoFEMErrorCode setGaussPts(int order)
MoFEMErrorCode preProcess()
MatrixDouble shapeFunctions
#define EXECUTABLE_DIMENSION
double zeta
Viscous hardening.