13 {
14
15
17
18 try {
19
20 PetscBool flg = PETSC_TRUE;
22#if PETSC_VERSION_GE(3, 6, 4)
24 255, &flg);
25#else
28#endif
29 if (flg != PETSC_TRUE) {
30 SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
31 }
32 const char *option;
33 option = "";
34
35
36 DMType dm_name = "DMMOFEM";
38
39
40 DM dm;
41 CHKERR DMCreate(PETSC_COMM_WORLD, &dm);
42 CHKERR DMSetType(dm, dm_name);
43
44
45 moab::Core mb_instance;
46 moab::Interface &moab = mb_instance;
50
52
54 bit_level0.set(0);
56 root_set, 3, bit_level0);
57
58 const int field_rank = 1;
60
62
68
70
71
73
77
79
81
83
84
86 CHKERR DMSetFromOptions(dm);
89
92
93 CHKERR DMCreateGlobalVector(dm, &
g);
94 CHKERR DMCreateLocalVector(dm, &
l);
96
97
99 CHKERR VecGhostUpdateBegin(
g, INSERT_VALUES, SCATTER_FORWARD);
100 CHKERR VecGhostUpdateEnd(
g, INSERT_VALUES, SCATTER_FORWARD);
101
102 CHKERR DMGlobalToLocalBegin(dm,
g, ADD_VALUES,
l);
103 CHKERR DMGlobalToLocalEnd(dm,
g, ADD_VALUES,
l);
104
105
106 CHKERR DMLocalToGlobalBegin(dm,
l, ADD_VALUES,
g);
107 CHKERR DMLocalToGlobalEnd(dm,
l, ADD_VALUES,
g);
108
110
114
115 FILE *file = std::fopen("dm_mofem.txt", "w");
116 if (file == nullptr) {
118 "Failed to open file for logging");
119 }
120
124
125
126 auto core_log = logging::core::get();
129 "LOG_TEST_METHOD"));
131
132 MOFEM_LOG(
"LOG_TEST_METHOD", Sev::inform)
133 << "Pre-processing for DM MoFEM test started";
135 };
138 MOFEM_LOG(
"LOG_TEST_METHOD", Sev::inform)
139 << *method.
entPtr <<
" : " << method.
entPtr->getEntFieldData();
141 };
144 MOFEM_LOG(
"LOG_TEST_METHOD", Sev::inform)
145 << "Post-processing for DM MoFEM test finished";
148 };
149
152
153
154 std::fclose(file);
155
156
158 }
160
161
163
164 return 0;
165}
#define MOFEM_LOG_FILE_SYNCHRONISE(comm, fd)
Synchronise "SYNC" channel.
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base nme:nme847.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_OPERATION_UNSUCCESSFUL
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
PetscErrorCode DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
Must be called by user to set MoFEM data structures.
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string name, const bool recursive=true)=0
add entities to finite element
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
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.
virtual MoFEMErrorCode loop_entities(const std::string field_name, EntityMethod &method, Range const *const ents=nullptr, int verb=DEFAULT_VERBOSITY)=0
Loop over field entities.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
FTensor::Index< 'l', 3 > l
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
FTensor::Index< 'm', 3 > m
boost::function< MoFEMErrorCode()> preProcessHook
Hook function for pre-processing.
boost::function< MoFEMErrorCode()> operatorHook
Hook function for operator.
boost::function< MoFEMErrorCode()> postProcessHook
Hook function for post-processing.
virtual int get_comm_size() const =0
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.
virtual MPI_Comm & get_comm() const =0
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 structure to exchange data between mofem and User Loop Methods on entities.
boost::shared_ptr< FieldEntity > entPtr
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 > getStrmSync()
Get the strm sync object.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.