86 {
87
88
90
91 moab::Core moab_core;
92 moab::Interface &moab = moab_core;
93
94 try {
95
96
98 PetscBool flg_test = PETSC_FALSE;
99 PetscOptionsBegin(PETSC_COMM_WORLD, "", "Poisson's problem options",
100 "none");
101
103 PETSC_NULLPTR);
104
105 CHKERR PetscOptionsBool(
"-test",
"if true is ctest",
"", flg_test,
106 &flg_test, PETSC_NULLPTR);
107 PetscOptionsEnd();
108
109
112
114
115
116 Vec global_error;
118
119
120
121
122
123
124
125
126 boost::shared_ptr<ForcesAndSourcesCore>
127 domain_lhs_fe;
128 boost::shared_ptr<ForcesAndSourcesCore>
129 boundary_lhs_fe;
130 boost::shared_ptr<ForcesAndSourcesCore>
131 domain_rhs_fe;
132 boost::shared_ptr<ForcesAndSourcesCore>
133 boundary_rhs_fe;
134 boost::shared_ptr<ForcesAndSourcesCore>
135 domain_error;
136 boost::shared_ptr<PoissonExample::PostProcFE>
137 post_proc_volume;
138 boost::shared_ptr<ForcesAndSourcesCore> null;
139 {
140
141
145 domain_lhs_fe, boundary_lhs_fe, domain_rhs_fe, boundary_rhs_fe,
147
148
151 global_error, domain_error);
152
155 }
156
157
158
160
162
163
164 {
165
166
168
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
186 1);
187
190
191
192
193
196
197
203 "ERROR", 0);
204
205
206
207
209 }
210
211
212
213
214
215
216
217
218
219 DM dm;
220
222
223
224
225
226
227
228
229 {
230
232 domain_lhs_fe, null, null);
234 boundary_lhs_fe, null, null);
235
237 domain_rhs_fe, null, null);
239 boundary_rhs_fe, null, null);
240 }
241
242
243 {
244
245
247 CHKERR DMCreateGlobalVector(dm, &
F);
248
249
251
252
253 SNES solver;
254 CHKERR SNESCreate(PETSC_COMM_WORLD, &solver);
255 CHKERR SNESSetFromOptions(solver);
256 CHKERR SNESSetDM(solver, dm);
257
259
260
261
263
264
265
267
268
269 CHKERR SNESDestroy(&solver);
272 }
273
274
275 {
276
277
279 domain_error);
281 global_error);
283 if (flg_test == PETSC_TRUE) {
285 }
286 }
287
288 {
289
290
292 post_proc_volume);
293
294 post_proc_volume->writeFile("out_vol.h5m");
295 }
296
297
299
300
301 CHKERR VecDestroy(&global_error);
302 }
304
305
307
308 return 0;
309}
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base nme:nme847.
@ L2
field with C-1 continuity
#define CHKERR
Inline error check.
PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES residual evaluation function
PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES Jacobian evaluation function
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode)
set ghosted vector values on all existing mesh entities
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.
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.
const std::string getBoundaryFEName() const
Get the Boundary FE Name.
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
MoFEMErrorCode addBoundaryField(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 boundary.
MoFEMErrorCode getOptions()
get options
MoFEMErrorCode getDM(DM *dm)
Get DM.
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
MoFEMErrorCode addDataField(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 setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
const std::string getDomainFEName() const
Get the Domain FE Name.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
MoFEMErrorCode createGhostVec(Vec *ghost_vec) const
MoFEMErrorCode testError(Vec ghost_vec)
Test error.
MoFEMErrorCode assembleGhostVector(Vec ghost_vec) const
Assemble error vector.
MoFEMErrorCode printError(Vec ghost_vec)
Print error.
Create finite elements instances.
MoFEMErrorCode creatFEToPostProcessResults(boost::shared_ptr< PostProcFE > &post_proc_volume) const
Create finite element to post-process results.
MoFEMErrorCode createFEToAssembleMatrixAndVectorForNonlinearProblem(boost::function< double(const double, const double, const double)> f_u, boost::function< double(const double, const double, const double)> f_source, boost::function< double(const double)> a, boost::function< double(const double)> diff_a, boost::shared_ptr< ForcesAndSourcesCore > &domain_lhs_fe, boost::shared_ptr< ForcesAndSourcesCore > &boundary_lhs_fe, boost::shared_ptr< ForcesAndSourcesCore > &domain_rhs_fe, boost::shared_ptr< ForcesAndSourcesCore > &boundary_rhs_fe, ForcesAndSourcesCore::RuleHookFun vol_rule, ForcesAndSourcesCore::RuleHookFun face_rule=FaceRule(), bool trans=true) const
Create finite element to calculate matrix and vectors.
MoFEMErrorCode createFEToEvaluateError(boost::function< double(const double, const double, const double)> f_u, boost::function< FTensor::Tensor1< double, 3 >(const double, const double, const double)> g_u, Vec global_error, boost::shared_ptr< ForcesAndSourcesCore > &domain_error) const
Create finite element to calculate error.