v0.13.2
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
MixedPoisson Struct Reference
Collaboration diagram for MixedPoisson:
[legend]

Classes

struct  CommonData
 
struct  OpError
 

Public Member Functions

 MixedPoisson (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 [Run programme] More...
 

Private Member Functions

MoFEMErrorCode readMesh ()
 [Run programme] More...
 
MoFEMErrorCode setupProblem ()
 [Read mesh] More...
 
MoFEMErrorCode setIntegrationRules ()
 [Set up problem] More...
 
MoFEMErrorCode createCommonData ()
 [Set integration rule] More...
 
MoFEMErrorCode assembleSystem ()
 [Create common data] More...
 
MoFEMErrorCode solveSystem ()
 [Assemble system] More...
 
MoFEMErrorCode checkError (int iter_num=0)
 [Solve and refine loop] More...
 
MoFEMErrorCode refineOrder ()
 [Solve] More...
 
MoFEMErrorCode solveRefineLoop ()
 [Refine] More...
 
MoFEMErrorCode outputResults (int iter_num=0)
 [Check error] More...
 

Static Private Member Functions

static double analyticalFunction (const double x, const double y, const double z)
 [Analytical function] More...
 
static VectorDouble analyticalFunctionGrad (const double x, const double y, const double z)
 [Analytical function] More...
 
static double sourceFunction (const double x, const double y, const double z)
 [Analytical function gradient] More...
 
static MoFEMErrorCode getTagHandle (MoFEM::Interface &m_field, const char *name, DataType type, Tag &tag_handle)
 [Source function] More...
 

Private Attributes

MoFEM::InterfacemField
 
SimplesimpleInterface
 
Range domainEntities
 
double errorIndicatorIntegral
 
int totalElementNumber
 
int baseOrder
 
int refIterNum
 
boost::shared_ptr< CommonDatacommonDataPtr
 

Detailed Description

Examples
mixed_poisson.cpp.

Definition at line 31 of file mixed_poisson.cpp.

Constructor & Destructor Documentation

◆ MixedPoisson()

MixedPoisson::MixedPoisson ( MoFEM::Interface m_field)
inline

Definition at line 33 of file mixed_poisson.cpp.

33: mField(m_field) {}
MoFEM::Interface & mField

Member Function Documentation

◆ analyticalFunction()

static double MixedPoisson::analyticalFunction ( const double  x,
const double  y,
const double  z 
)
inlinestaticprivate

[Analytical function]

Examples
mixed_poisson.cpp.

Definition at line 47 of file mixed_poisson.cpp.

48 {
49 return exp(-100. * (sqr(x) + sqr(y))) * cos(M_PI * x) * cos(M_PI * y);
50 }
double sqr(double x)

◆ analyticalFunctionGrad()

static VectorDouble MixedPoisson::analyticalFunctionGrad ( const double  x,
const double  y,
const double  z 
)
inlinestaticprivate

[Analytical function]

[Analytical function gradient]

Examples
mixed_poisson.cpp.

Definition at line 54 of file mixed_poisson.cpp.

55 {
56 VectorDouble res;
57 res.resize(2);
58 res[0] = -exp(-100. * (sqr(x) + sqr(y))) *
59 (200. * x * cos(M_PI * x) + M_PI * sin(M_PI * x)) * cos(M_PI * y);
60 res[1] = -exp(-100. * (sqr(x) + sqr(y))) *
61 (200. * y * cos(M_PI * y) + M_PI * sin(M_PI * y)) * cos(M_PI * x);
62 return res;
63 }

◆ assembleSystem()

MoFEMErrorCode MixedPoisson::assembleSystem ( )
private

[Create common data]

[Assemble system]

Examples
mixed_poisson.cpp.

Definition at line 229 of file mixed_poisson.cpp.

229 {
232 pipeline_mng->getDomainLhsFE().reset();
233 pipeline_mng->getDomainRhsFE().reset();
234 pipeline_mng->getOpDomainRhsPipeline().clear();
235 pipeline_mng->getOpDomainLhsPipeline().clear();
236
237 auto det_ptr = boost::make_shared<VectorDouble>();
238 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
239 auto jac_ptr = boost::make_shared<MatrixDouble>();
240 pipeline_mng->getOpDomainLhsPipeline().push_back(
241 new OpCalculateHOJacForFace(jac_ptr));
242 pipeline_mng->getOpDomainLhsPipeline().push_back(
243 new OpInvertMatrix<2>(jac_ptr, det_ptr, inv_jac_ptr));
244 pipeline_mng->getOpDomainLhsPipeline().push_back(new OpMakeHdivFromHcurl());
245 pipeline_mng->getOpDomainLhsPipeline().push_back(
247 pipeline_mng->getOpDomainLhsPipeline().push_back(
248 new OpSetInvJacHcurlFace(inv_jac_ptr));
249 pipeline_mng->getOpDomainLhsPipeline().push_back(new OpSetHOWeightsOnFace());
250
251 auto beta = [](const double, const double, const double) { return 1; };
252 pipeline_mng->getOpDomainLhsPipeline().push_back(
253 new OpHdivHdiv("FLUX", "FLUX", beta));
254 auto unity = []() { return 1; };
255 pipeline_mng->getOpDomainLhsPipeline().push_back(
256 new OpHdivU("FLUX", "U", unity, true));
257 auto source = [&](const double x, const double y, const double z) {
258 return -sourceFunction(x, y, z);
259 };
260 pipeline_mng->getOpDomainRhsPipeline().push_back(
261 new OpDomainSource("U", source));
263}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
boost::ptr_deque< UserDataOperator > & getOpDomainLhsPipeline()
Get the Op Domain Lhs Pipeline object.
boost::ptr_deque< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMixDivTimesScalar< 2 > OpHdivU
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 3, 3 > OpHdivHdiv
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpSource< 1, 1 > OpDomainSource
OpSetInvJacHcurlFaceImpl< 2 > OpSetInvJacHcurlFace
OpCalculateHOJacForFaceImpl< 2 > OpCalculateHOJacForFace
OpSetContravariantPiolaTransformOnFace2DImpl< 2 > OpSetContravariantPiolaTransformOnFace2D
static double sourceFunction(const double x, const double y, const double z)
[Analytical function gradient]
Make Hdiv space from Hcurl space in 2d.
Modify integration weights on face to take in account higher-order geometry.
PipelineManager interface.
boost::shared_ptr< FEMethod > & getDomainRhsFE()
boost::shared_ptr< FEMethod > & getDomainLhsFE()
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.

◆ checkError()

MoFEMErrorCode MixedPoisson::checkError ( int  iter_num = 0)
private

[Solve and refine loop]

[Check error]

Examples
mixed_poisson.cpp.

Definition at line 355 of file mixed_poisson.cpp.

355 {
358 pipeline_mng->getDomainLhsFE().reset();
359 pipeline_mng->getDomainRhsFE().reset();
360 pipeline_mng->getOpDomainRhsPipeline().clear();
361
362 auto det_ptr = boost::make_shared<VectorDouble>();
363 auto jac_ptr = boost::make_shared<MatrixDouble>();
364 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
365
366 pipeline_mng->getOpDomainRhsPipeline().push_back(
367 new OpCalculateHOJacForFace(jac_ptr));
368 pipeline_mng->getOpDomainRhsPipeline().push_back(
369 new OpInvertMatrix<2>(jac_ptr, det_ptr, inv_jac_ptr));
370 pipeline_mng->getOpDomainRhsPipeline().push_back(new OpMakeHdivFromHcurl());
371 pipeline_mng->getOpDomainRhsPipeline().push_back(
373 pipeline_mng->getOpDomainRhsPipeline().push_back(
374 new OpSetInvJacHcurlFace(inv_jac_ptr));
375 pipeline_mng->getOpDomainRhsPipeline().push_back(
376 new OpSetInvJacL2ForFace(inv_jac_ptr));
377 pipeline_mng->getOpDomainRhsPipeline().push_back(new OpSetHOWeightsOnFace());
378
379 pipeline_mng->getOpDomainRhsPipeline().push_back(
380 new OpCalculateScalarFieldValues("U", commonDataPtr->approxVals));
381 pipeline_mng->getOpDomainRhsPipeline().push_back(
383 commonDataPtr->approxValsGrad));
384 pipeline_mng->getOpDomainRhsPipeline().push_back(
385 new OpCalculateHVecVectorField<3>("FLUX", commonDataPtr->approxFlux));
386 pipeline_mng->getOpDomainRhsPipeline().push_back(
388
389 CHKERR VecZeroEntries(commonDataPtr->petscVec);
390 CHKERR VecGhostUpdateBegin(commonDataPtr->petscVec, INSERT_VALUES,
391 SCATTER_FORWARD);
392 CHKERR VecGhostUpdateEnd(commonDataPtr->petscVec, INSERT_VALUES,
393 SCATTER_FORWARD);
394 CHKERR pipeline_mng->loopFiniteElements();
395 CHKERR VecAssemblyBegin(commonDataPtr->petscVec);
396 CHKERR VecAssemblyEnd(commonDataPtr->petscVec);
397 CHKERR VecGhostUpdateBegin(commonDataPtr->petscVec, ADD_VALUES,
398 SCATTER_REVERSE);
399 CHKERR VecGhostUpdateEnd(commonDataPtr->petscVec, ADD_VALUES,
400 SCATTER_REVERSE);
401 CHKERR VecGhostUpdateBegin(commonDataPtr->petscVec, INSERT_VALUES,
402 SCATTER_FORWARD);
403 CHKERR VecGhostUpdateEnd(commonDataPtr->petscVec, INSERT_VALUES,
404 SCATTER_FORWARD);
405 const double *array;
406 CHKERR VecGetArrayRead(commonDataPtr->petscVec, &array);
407 MOFEM_LOG("EXAMPLE", Sev::inform)
408 << "Global error L2 norm: " << std::sqrt(array[0]);
409 MOFEM_LOG("EXAMPLE", Sev::inform)
410 << "Global error H1 seminorm: " << std::sqrt(array[1]);
411 MOFEM_LOG("EXAMPLE", Sev::inform)
412 << "Global error indicator: " << std::sqrt(array[2]);
413 MOFEM_LOG("EXAMPLE", Sev::inform)
414 << "Total number of elements: " << (int)array[3];
415
416 errorIndicatorIntegral = array[2];
417 totalElementNumber = (int)array[3];
418 CHKERR VecRestoreArrayRead(commonDataPtr->petscVec, &array);
419
420 std::vector<Tag> tag_handles;
421 tag_handles.resize(4);
422 CHKERR getTagHandle(mField, "ERROR_L2_NORM", MB_TYPE_DOUBLE, tag_handles[0]);
423 CHKERR getTagHandle(mField, "ERROR_H1_SEMINORM", MB_TYPE_DOUBLE,
424 tag_handles[1]);
425 CHKERR getTagHandle(mField, "ERROR_INDICATOR", MB_TYPE_DOUBLE,
426 tag_handles[2]);
427 CHKERR getTagHandle(mField, "ORDER", MB_TYPE_INTEGER, tag_handles[3]);
428
429 ParallelComm *pcomm =
430 ParallelComm::get_pcomm(&mField.get_moab(), MYPCOMM_INDEX);
431 if (pcomm == NULL)
432 SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY, "Communicator not set");
433
434 tag_handles.push_back(pcomm->part_tag());
435 std::ostringstream strm;
436 strm << "error_" << iter_num << ".h5m";
437 CHKERR mField.get_moab().write_file(strm.str().c_str(), "MOAB",
438 "PARALLEL=WRITE_PART", 0, 0,
439 tag_handles.data(), tag_handles.size());
441}
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:215
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
boost::shared_ptr< CommonData > commonDataPtr
double errorIndicatorIntegral
static MoFEMErrorCode getTagHandle(MoFEM::Interface &m_field, const char *name, DataType type, Tag &tag_handle)
[Source function]
virtual moab::Interface & get_moab()=0
Get vector field for H-div approximation.
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Get value at integration points for scalar field.

◆ createCommonData()

MoFEMErrorCode MixedPoisson::createCommonData ( )
private

[Set integration rule]

[Create common data]

Examples
mixed_poisson.cpp.

Definition at line 211 of file mixed_poisson.cpp.

211 {
213 commonDataPtr = boost::make_shared<CommonData>();
214 PetscInt ghosts[4] = {0, 1, 2, 3};
215 if (!mField.get_comm_rank())
216 commonDataPtr->petscVec =
217 createGhostVector(mField.get_comm(), 4, 4, 0, ghosts);
218 else
219 commonDataPtr->petscVec =
220 createGhostVector(mField.get_comm(), 0, 4, 4, ghosts);
221 commonDataPtr->approxVals = boost::make_shared<VectorDouble>();
222 commonDataPtr->approxValsGrad = boost::make_shared<MatrixDouble>();
223 commonDataPtr->approxFlux = boost::make_shared<MatrixDouble>();
225}
auto createGhostVector(MPI_Comm comm, PetscInt n, PetscInt N, PetscInt nghost, const PetscInt ghosts[])
Create smart ghost vector.
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0

◆ getTagHandle()

static MoFEMErrorCode MixedPoisson::getTagHandle ( MoFEM::Interface m_field,
const char *  name,
DataType  type,
Tag &  tag_handle 
)
inlinestaticprivate

[Source function]

Examples
mixed_poisson.cpp.

Definition at line 77 of file mixed_poisson.cpp.

79 {
81 int int_val = 0;
82 double double_val = 0;
83 switch (type) {
84 case MB_TYPE_INTEGER:
85 CHKERR m_field.get_moab().tag_get_handle(
86 name, 1, type, tag_handle, MB_TAG_CREAT | MB_TAG_SPARSE, &int_val);
87 break;
88 case MB_TYPE_DOUBLE:
89 CHKERR m_field.get_moab().tag_get_handle(
90 name, 1, type, tag_handle, MB_TAG_CREAT | MB_TAG_SPARSE, &double_val);
91 break;
92 default:
93 SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
94 "Wrong data type %d for tag", type);
95 }
97 }

◆ outputResults()

MoFEMErrorCode MixedPoisson::outputResults ( int  iter_num = 0)
private

[Check error]

[Output results]

Examples
mixed_poisson.cpp.

Definition at line 445 of file mixed_poisson.cpp.

445 {
448 pipeline_mng->getDomainLhsFE().reset();
449
451
452 auto post_proc_fe =
453 boost::make_shared<PostProcEle>(mField);
454
455 auto det_ptr = boost::make_shared<VectorDouble>();
456 auto jac_ptr = boost::make_shared<MatrixDouble>();
457 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
458
459 post_proc_fe->getOpPtrVector().push_back(
460 new OpCalculateHOJacForFace(jac_ptr));
461 post_proc_fe->getOpPtrVector().push_back(
462 new OpInvertMatrix<2>(jac_ptr, det_ptr, inv_jac_ptr));
463 post_proc_fe->getOpPtrVector().push_back(new OpMakeHdivFromHcurl());
464 post_proc_fe->getOpPtrVector().push_back(
466 post_proc_fe->getOpPtrVector().push_back(
467 new OpSetInvJacHcurlFace(inv_jac_ptr));
468
469 auto u_ptr = boost::make_shared<VectorDouble>();
470 auto flux_ptr = boost::make_shared<MatrixDouble>();
471 post_proc_fe->getOpPtrVector().push_back(
472 new OpCalculateScalarFieldValues("U", u_ptr));
473 post_proc_fe->getOpPtrVector().push_back(
474 new OpCalculateHVecVectorField<3>("FLUX", flux_ptr));
475
477
478 post_proc_fe->getOpPtrVector().push_back(
479
480 new OpPPMap(post_proc_fe->getPostProcMesh(),
481 post_proc_fe->getMapGaussPts(),
482
483 OpPPMap::DataMapVec{{"U", u_ptr}},
484
485 OpPPMap::DataMapMat{{"FLUX", flux_ptr}},
486
488
490
491 )
492
493 );
494
495 pipeline_mng->getDomainRhsFE() = post_proc_fe;
496 CHKERR pipeline_mng->loopFiniteElements();
497
498 std::ostringstream strm;
499 strm << "out_" << iter_num << ".h5m";
500 CHKERR post_proc_fe->writeFile(strm.str().c_str());
502}
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
Post post-proc data at points from hash maps.
std::map< std::string, boost::shared_ptr< VectorDouble > > DataMapVec
std::map< std::string, boost::shared_ptr< MatrixDouble > > DataMapMat

◆ readMesh()

MoFEMErrorCode MixedPoisson::readMesh ( )
private

[Run programme]

[Read mesh]

Examples
mixed_poisson.cpp.

Definition at line 153 of file mixed_poisson.cpp.

153 {
159}
Simple * simpleInterface
MoFEMErrorCode getOptions()
get options
Definition: Simple.cpp:180
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name)
Load mesh file.
Definition: Simple.cpp:194

◆ refineOrder()

MoFEMErrorCode MixedPoisson::refineOrder ( )
private

[Solve]

[Refine]

Examples
mixed_poisson.cpp.

Definition at line 288 of file mixed_poisson.cpp.

288 {
290 Tag th_error_ind, th_order;
291 CHKERR getTagHandle(mField, "ERROR_INDICATOR", MB_TYPE_DOUBLE, th_error_ind);
292 CHKERR getTagHandle(mField, "ORDER", MB_TYPE_INTEGER, th_order);
293
294 std::vector<Range> refinement_levels;
295 refinement_levels.resize(refIterNum + 1);
296 for (auto ent : domainEntities) {
297 double err_indic = 0;
298 CHKERR mField.get_moab().tag_get_data(th_error_ind, &ent, 1, &err_indic);
299 int order, new_order;
300 CHKERR mField.get_moab().tag_get_data(th_order, &ent, 1, &order);
301 new_order = order + 1;
302 Range refined_ents;
303 if (err_indic > errorIndicatorIntegral / totalElementNumber) {
304 refined_ents.insert(ent);
305 Range adj;
306 CHKERR mField.get_moab().get_adjacencies(&ent, 1, 1, false, adj,
307 moab::Interface::UNION);
308 refined_ents.merge(adj);
309 refinement_levels[new_order - baseOrder].merge(refined_ents);
310 CHKERR mField.get_moab().tag_set_data(th_order, &ent, 1, &new_order);
311 }
312 }
313
314 for (int ll = 1; ll < refinement_levels.size(); ll++) {
315 CHKERR mField.getInterface<CommInterface>()->synchroniseEntities(
316 refinement_levels[ll]);
317 CHKERR mField.set_field_order(refinement_levels[ll], "FLUX",
318 baseOrder + ll);
319 CHKERR mField.set_field_order(refinement_levels[ll], "U",
320 baseOrder + ll - 1);
321 }
322
323 CHKERR mField.getInterface<CommInterface>()->synchroniseFieldEntities("FLUX");
324 CHKERR mField.getInterface<CommInterface>()->synchroniseFieldEntities("U");
328 mField.getInterface<ProblemsManager>()->buildProblemFromFields = PETSC_TRUE;
331}
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition: DMMoFEM.cpp:1267
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.
Range domainEntities
Managing BitRefLevels.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
Problem manager is used to build and partition problems.
MoFEMErrorCode getDM(DM *dm)
Get DM.
Definition: Simple.cpp:667
BitRefLevel & getBitRefLevel()
Get the BitRefLevel.
Definition: Simple.hpp:313

◆ runProblem()

MoFEMErrorCode MixedPoisson::runProblem ( )

[Run programme]

Examples
mixed_poisson.cpp.

Definition at line 141 of file mixed_poisson.cpp.

141 {
149}
MoFEMErrorCode solveRefineLoop()
[Refine]
MoFEMErrorCode createCommonData()
[Set integration rule]
MoFEMErrorCode setIntegrationRules()
[Set up problem]
MoFEMErrorCode setupProblem()
[Read mesh]
MoFEMErrorCode readMesh()
[Run programme]

◆ setIntegrationRules()

MoFEMErrorCode MixedPoisson::setIntegrationRules ( )
private

[Set up problem]

[Set integration rule]

Examples
mixed_poisson.cpp.

Definition at line 197 of file mixed_poisson.cpp.

197 {
199
200 auto rule = [](int, int, int p) -> int { return 2 * p + 1; };
201
203 CHKERR pipeline_mng->setDomainLhsIntegrationRule(rule);
204 CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule);
205
207}
static Index< 'p', 3 > p
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)

◆ setupProblem()

MoFEMErrorCode MixedPoisson::setupProblem ( )
private

[Read mesh]

[Set up problem]

Examples
mixed_poisson.cpp.

Definition at line 163 of file mixed_poisson.cpp.

163 {
165 // Note that in 2D case HDIV and HCURL spaces are isomorphic, and therefore
166 // only base for HCURL has been implemented in 2D. Base vectors for HDIV space
167 // are be obtained after rotation of HCURL base vectors by a right angle
169 1);
170 // We use AINSWORTH_LEGENDRE_BASE since DEMKOWICZ_JACOBI_BASE for triangle
171 // is not yet implemented for L2 space. For quads DEMKOWICZ_JACOBI_BASE and
172 // AINSWORTH_LEGENDRE_BASE are construcreed in the same way
174
175 refIterNum = 0;
176 CHKERR PetscOptionsGetInt(PETSC_NULL, "", "-ref_iter_num", &refIterNum,
177 PETSC_NULL);
178 baseOrder = 2;
179 CHKERR PetscOptionsGetInt(PETSC_NULL, "", "-base_order", &baseOrder,
180 PETSC_NULL);
184
185 CHKERR mField.get_moab().get_entities_by_dimension(0, 2, domainEntities,
186 false);
187 Tag th_order;
188 CHKERR getTagHandle(mField, "ORDER", MB_TYPE_INTEGER, th_order);
189 for (auto ent : domainEntities) {
190 CHKERR mField.get_moab().tag_set_data(th_order, &ent, 1, &baseOrder);
191 }
193}
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
@ DEMKOWICZ_JACOBI_BASE
Definition: definitions.h:66
@ L2
field with C-1 continuity
Definition: definitions.h:88
@ HCURL
field with continuous tangents
Definition: definitions.h:86
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
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.
Definition: Simple.cpp:264
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
Definition: Simple.cpp:473
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
Definition: Simple.cpp:611

◆ solveRefineLoop()

MoFEMErrorCode MixedPoisson::solveRefineLoop ( )
private

[Refine]

[Solve and refine loop]

Examples
mixed_poisson.cpp.

Definition at line 335 of file mixed_poisson.cpp.

335 {
341
342 for (int ii = 0; ii < refIterNum; ii++) {
344
347 CHKERR checkError(ii + 1);
348 CHKERR outputResults(ii + 1);
349 }
351}
MoFEMErrorCode assembleSystem()
[Create common data]
MoFEMErrorCode outputResults(int iter_num=0)
[Check error]
MoFEMErrorCode refineOrder()
[Solve]
MoFEMErrorCode checkError(int iter_num=0)
[Solve and refine loop]
MoFEMErrorCode solveSystem()
[Assemble system]

◆ solveSystem()

MoFEMErrorCode MixedPoisson::solveSystem ( )
private

[Assemble system]

[Solve]

Examples
mixed_poisson.cpp.

Definition at line 267 of file mixed_poisson.cpp.

267 {
270 auto solver = pipeline_mng->createKSP();
271 CHKERR KSPSetFromOptions(solver);
272 CHKERR KSPSetUp(solver);
273
274 auto dm = simpleInterface->getDM();
275 auto D = createDMVector(dm);
276 auto F = vectorDuplicate(D);
277 CHKERR VecZeroEntries(D);
278
279 CHKERR KSPSolve(solver, F, D);
280 CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
281 CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
282 CHKERR DMoFEMMeshToLocalVector(dm, D, INSERT_VALUES, SCATTER_REVERSE);
284}
@ F
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition: DMMoFEM.cpp:509
auto createDMVector(DM dm)
Get smart vector from DM.
Definition: DMMoFEM.hpp:1003
SmartPetscObj< KSP > createKSP(SmartPetscObj< DM > dm=nullptr)
Create KSP (linear) solver.
double D
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.

◆ sourceFunction()

static double MixedPoisson::sourceFunction ( const double  x,
const double  y,
const double  z 
)
inlinestaticprivate

[Analytical function gradient]

[Source function]

Examples
mixed_poisson.cpp.

Definition at line 67 of file mixed_poisson.cpp.

67 {
68 return -exp(-100. * (sqr(x) + sqr(y))) *
69 (400. * M_PI *
70 (x * cos(M_PI * y) * sin(M_PI * x) +
71 y * cos(M_PI * x) * sin(M_PI * y)) +
72 2. * (20000. * (sqr(x) + sqr(y)) - 200. - sqr(M_PI)) *
73 cos(M_PI * x) * cos(M_PI * y));
74 }

Member Data Documentation

◆ baseOrder

int MixedPoisson::baseOrder
private
Examples
mixed_poisson.cpp.

Definition at line 43 of file mixed_poisson.cpp.

◆ commonDataPtr

boost::shared_ptr<CommonData> MixedPoisson::commonDataPtr
private
Examples
mixed_poisson.cpp.

Definition at line 125 of file mixed_poisson.cpp.

◆ domainEntities

Range MixedPoisson::domainEntities
private
Examples
mixed_poisson.cpp.

Definition at line 40 of file mixed_poisson.cpp.

◆ errorIndicatorIntegral

double MixedPoisson::errorIndicatorIntegral
private
Examples
mixed_poisson.cpp.

Definition at line 41 of file mixed_poisson.cpp.

◆ mField

MoFEM::Interface& MixedPoisson::mField
private
Examples
mixed_poisson.cpp.

Definition at line 37 of file mixed_poisson.cpp.

◆ refIterNum

int MixedPoisson::refIterNum
private
Examples
mixed_poisson.cpp.

Definition at line 44 of file mixed_poisson.cpp.

◆ simpleInterface

Simple* MixedPoisson::simpleInterface
private
Examples
mixed_poisson.cpp.

Definition at line 38 of file mixed_poisson.cpp.

◆ totalElementNumber

int MixedPoisson::totalElementNumber
private
Examples
mixed_poisson.cpp.

Definition at line 42 of file mixed_poisson.cpp.


The documentation for this struct was generated from the following file: