|
| v0.14.0
|
Go to the documentation of this file.
10 using namespace MoFEM;
12 static char help[] =
"...\n\n";
46 double operator()(
const double x,
const double y,
const double z) {
47 return x * x + y * y + x * y + pow(x, 3) + pow(y, 3) + pow(x, 4) +
74 checkResults(boost::function<
bool(
FEMethod *fe_method_ptr)> test_bit);
90 OpError(boost::shared_ptr<CommonData> &common_data_ptr)
95 if (
const size_t nb_dofs = data.
getIndices().size()) {
97 const int nb_integration_pts = getGaussPts().size2();
98 auto t_w = getFTensor0IntegrationWeight();
100 auto t_coords = getFTensor1CoordsAtGaussPts();
106 const double volume = getMeasure();
110 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
112 const double alpha = t_w * volume;
115 error += alpha * pow(diff, 2);
117 for (
size_t r = 0;
r != nb_dofs; ++
r) {
118 nf[
r] += alpha * t_row_base * diff;
128 CHKERR VecSetValue(commonDataPtr->L2Vec, index, error, ADD_VALUES);
136 template <
typename ELE_OP,
typename PARENT_ELE>
146 PARENT_ELE parent_fe(this->getPtrFE()->mField);
154 <<
"parent_coords in op "
155 <<
static_cast<ELE_OP *
>(op_ptr)->getCoordsAtGaussPts();
157 parent_coords =
static_cast<ELE_OP *
>(op_ptr)->getCoordsAtGaussPts();
160 parent_fe.getOpPtrVector().push_back(op);
162 MOFEM_LOG(
"SELF", Sev::noisy) <<
"fe name " << this->getFEName();
163 CHKERR this->loopParent(this->getFEName(), &parent_fe);
164 MOFEM_LOG(
"SELF", Sev::noisy) <<
"parent_coords " << parent_coords;
166 MatrixDouble child_coords = this->getCoordsAtGaussPts();
167 MOFEM_LOG(
"SELF", Sev::noisy) <<
"child_coords " << child_coords;
169 child_coords -= parent_coords;
171 MOFEM_LOG(
"SELF", Sev::noisy) <<
"Corrds diffs" << child_coords;
174 for (
auto d : child_coords.data())
179 "Parent and child global coords at integration points are "
180 "diffrent norm = %3.2e",
196 const auto &
bit = fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel();
215 MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Dim " << simpleInterface->
getDim();
221 auto refine_mesh = [&](
auto bit_level1) {
228 bit_level0,
BitRefLevel().set(), *meshset_level0_ptr);
232 Range edges_to_refine;
233 CHKERR moab.get_entities_by_type(*meshset_level0_ptr, MBEDGE,
236 for (Range::iterator eit = edges_to_refine.begin();
237 eit != edges_to_refine.end(); eit++, ii++) {
240 CHKERR moab.add_entities(*meshset_ref_edges_ptr, &*eit, 1);
243 CHKERR refine->addVerticesInTheMiddleOfEdges(*meshset_ref_edges_ptr,
245 if (simpleInterface->
getDim() == 3) {
246 CHKERR refine->refineTets(*meshset_level0_ptr, bit_level1,
VERBOSE);
247 }
else if (simpleInterface->
getDim() == 2) {
248 CHKERR refine->refineTris(*meshset_level0_ptr, bit_level1,
VERBOSE);
251 "Dimension not handled by test");
259 CHKERR refine_mesh(bit_level1);
275 constexpr
int order = 4;
294 auto rule = [](
int,
int,
int p) ->
int {
return 2 * p; };
299 auto test_bit_parent = [](
FEMethod *fe_ptr) {
300 const auto &
bit = fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel();
322 parent_op_lhs->doWorkRhsHook = [&](
DataOperator *op_ptr,
int side,
325 auto domain_op =
static_cast<DomainEleOp *
>(op_ptr);
328 MOFEM_LOG(
"SELF", Sev::noisy) <<
"LHS Pipeline FE";
334 domain_op->getFEMethod()->numeredEntFiniteElementPtr->getBitRefLevel();
336 CHKERR domain_op->loopChildren(domain_op->getFEName(),
346 parent_op_rhs->doWorkRhsHook = [&](
DataOperator *op_ptr,
int side,
349 auto domain_op =
static_cast<DomainEleOp *
>(op_ptr);
352 MOFEM_LOG(
"SELF", Sev::noisy) <<
"RHS Pipeline FE";
358 domain_op->getFEMethod()->numeredEntFiniteElementPtr->getBitRefLevel();
360 CHKERR domain_op->loopChildren(domain_op->getFEName(),
381 MOFEM_LOG(
"WORLD", Sev::inform) <<
"Solve problem";
384 CHKERR KSPSetFromOptions(solver);
387 auto dm = simpleInterface->
getDM();
392 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
393 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
408 auto refine_mesh = [&]() {
416 *meshset_level1_ptr);
420 Range edges_to_refine;
422 bit_level1,
BitRefLevel().set(), MBEDGE, edges_to_refine);
424 CHKERR refine->addVerticesInTheMiddleOfEdges(edges_to_refine, bit_level2,
426 if (simpleInterface->
getDim() == 3) {
427 CHKERR refine->refineTets(*meshset_level1_ptr, bit_level2,
VERBOSE);
428 }
else if (simpleInterface->
getDim() == 2) {
429 CHKERR refine->refineTris(*meshset_level1_ptr, bit_level2,
VERBOSE);
432 "Dimension not handled by test");
436 CHKERR moab.get_entities_by_type(0, MBENTITYSET, meshsets,
true);
437 for (
auto m : meshsets) {
439 ->updateMeshsetByEntitiesChildren(
m, bit_level2,
m, MBMAXTYPE,
false);
454 bit_level0 | bit_level1);
456 auto project_data = [&]() {
465 auto rule = [](
int,
int,
int p) ->
int {
return 2 * p; };
471 auto test_bit_ref = [](
FEMethod *fe_ptr) {
472 const auto &
bit = fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel();
473 MOFEM_LOG(
"SELF", Sev::noisy) <<
"ref : " <<
bit <<
" " <<
bit.test(2);
482 auto field_vals_ptr = boost::make_shared<VectorDouble>();
484 auto domainParentRhs = boost::make_shared<DomainParentEle>(mField);
485 domainParentRhs->getOpPtrVector().push_back(
491 new OpRunParent(domainParentRhs, bit_level2, bit_level2,
492 domainParentRhs, bit_level2,
BitRefLevel().set()));
495 PETSC>::LinearForm<GAUSS>::OpBaseTimesScalar<1>;
524 boost::function<
bool(
FEMethod *fe_method_ptr)> test_bit) {
531 auto rule = [](
int,
int,
int p) ->
int {
return 2 * p + 1; };
535 auto common_data_ptr = boost::make_shared<CommonData>();
539 common_data_ptr->approxVals = boost::make_shared<VectorDouble>();
543 common_data_ptr->approxVals));
547 CHKERR VecZeroEntries(common_data_ptr->L2Vec);
548 CHKERR VecZeroEntries(common_data_ptr->resVec);
552 CHKERR VecAssemblyBegin(common_data_ptr->L2Vec);
553 CHKERR VecAssemblyEnd(common_data_ptr->L2Vec);
554 CHKERR VecAssemblyBegin(common_data_ptr->resVec);
555 CHKERR VecAssemblyEnd(common_data_ptr->resVec);
557 CHKERR VecNorm(common_data_ptr->resVec, NORM_2, &nrm2);
559 CHKERR VecGetArrayRead(common_data_ptr->L2Vec, &array);
560 MOFEM_LOG_C(
"WORLD", Sev::inform,
"Error %6.4e Vec norm %6.4e\n",
561 std::sqrt(array[0]), nrm2);
562 CHKERR VecRestoreArrayRead(common_data_ptr->L2Vec, &array);
564 constexpr
double eps = 1e-8;
567 "Not converged solution err = %6.4e", nrm2);
572 int main(
int argc,
char *argv[]) {
580 DMType dm_name =
"DMMOFEM";
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Data on single entity (This is passed as argument to DataOperator::doWork)
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
boost::shared_ptr< FEMethod > & getDomainRhsFE()
base operator to do operations at Gauss Pt. level
Problem manager is used to build and partition problems.
structure for User Loop Methods on finite elements
Operator to execute finite element instance on parent element. This operator is typically used to pro...
virtual MPI_Comm & get_comm() const =0
constexpr char FIELD_NAME[]
MoFEM::Interface & mField
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
double operator()(const double x, const double y, const double z)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
UBlasMatrix< double > MatrixDouble
boost::ptr_deque< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
virtual int get_comm_rank() const =0
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
PipelineManager interface.
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
boost::shared_ptr< FEMethod > & getBoundaryRhsFE()
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
MoFEMErrorCode assembleSystem()
[Push operators to pipeline]
BitRefLevel & getBitRefLevelMask()
Get the BitRefLevel.
auto test_bit_child
lambda function used to select elements on which finite element pipelines are executed.
Simple interface for fast problem set-up.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, FIELD_DIM > OpDomainMass
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
SmartPetscObj< Vec > L2Vec
Deprecated interface functions.
DeprecatedCoreInterface Interface
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
MoFEMErrorCode getOptions()
get options
MoFEM::EdgeElementForcesAndSourcesCore EdgeEle
OpError(boost::shared_ptr< CommonData > &common_data_ptr)
Operator to evaluate errors.
MoFEMErrorCode getDM(DM *dm)
Get DM.
#define CHKERR
Inline error check.
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
auto createDMVector(DM dm)
Get smart vector from DM.
boost::shared_ptr< DomainEle > domainChildLhs
[Set up problem]
boost::shared_ptr< CommonData > commonDataPtr
virtual moab::Interface & get_moab()=0
implementation of Data Operators for Forces and Sources
DomainEle::UserDataOperator DomainEleOp
Finire element operator type.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesScalar< 1 > OpDomainTimesScalarField
default operator for TRI element
Mesh refinement interface.
#define MOFEM_LOG_C(channel, severity, format,...)
auto get_temp_meshset_ptr(moab::Interface &moab)
Create smart pointer to temporary meshset.
MoFEM::FaceElementForcesAndSourcesCore FaceEle
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
ElementsAndOps< SPACE_DIM >::DomianParentEle DomainParentEle
Get value at integration points for scalar field.
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.
SmartPetscObj< KSP > createKSP(SmartPetscObj< DM > dm=nullptr)
Create KSP (linear) solver.
const VectorInt & getIndices() const
Get global indices of dofs on entity.
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Base face element used to integrate on skeleton.
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
Collected data use d by operator to evaluate errors for the test.
MoFEMErrorCode refineResults()
[Solve]
AtomTest(MoFEM::Interface &m_field)
static ApproxFieldFunction< FIELD_DIM > approxFunction
boost::ptr_deque< UserDataOperator > & getOpDomainLhsPipeline()
Get the Op Domain Lhs Pipeline object.
Volume finite element base.
FTensor::Index< 'i', SPACE_DIM > i
EntitiesFieldData::EntData EntData
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
MoFEMErrorCode solveSystem()
[Push operators to pipeline]
default operator for EDGE element
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
boost::shared_ptr< FEMethod > & getDomainLhsFE()
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
#define MOFEM_LOG(channel, severity)
Log.
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
#define CATCH_ERRORS
Catch errors.
int main(int argc, char *argv[])
[Check results]
Base face element used to integrate on skeleton.
ForcesAndSourcesCore::UserDataOperator UserDataOperator
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
@ MOFEM_DATA_INCONSISTENCY
MoFEMErrorCode checkResults()
[Check results]
BitRefLevel & getBitRefLevel()
Get the BitRefLevel.
auto createVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
int getDim() const
Get the problem dimension.
SmartPetscObj< Vec > resVec
boost::ptr_deque< UserDataOperator > & getOpBoundaryRhsPipeline()
Get the Op Boundary Rhs Pipeline object.
UBlasVector< double > VectorDouble
MoFEMErrorCode readMesh()
[Run programme]
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 reSetUp(bool only_dm=false)
Rebuild internal MoFEM data structures.
const double D
diffusivity
boost::shared_ptr< DomainEle > domainChildRhs
MoFEMErrorCode setBoundaryRhsIntegrationRule(RuleHookFun rule)
FTensor::Index< 'm', 3 > m
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
boost::shared_ptr< VectorDouble > approxVals
@ MOFEM_ATOM_TEST_INVALID
ElementsAndOps< SPACE_DIM >::BoundaryParentEle BoundaryParentEle
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpSource< 1, FIELD_DIM > OpDomainSource
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
const std::string getProblemName() const
Get the Problem Name.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
MoFEMErrorCode setupProblem()
[Read mesh]
MoFEMErrorCode runProblem()
[Run programme]
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...