9static char help[] =
"...\n\n";
31 return 2. * M_PI * M_PI * cos(x * M_PI) * cos(y * M_PI);
36 return cos(x * M_PI) * cos(y * M_PI);
77 auto get_ents_by_dim = [&](
const auto dim) {
90 auto get_base = [&]() {
91 auto domain_ents = get_ents_by_dim(
SPACE_DIM);
92 if (domain_ents.empty())
109 auto base = get_base();
133 boundaryMarker = bc_mng->getMergedBlocksMarker({
"BOUNDARY_CONDITION"});
136 bc_mng->getMergedBlocksRange({
"BOUNDARY_CONDITION"});
151 pipeline_mng->getOpDomainLhsPipeline(), {H1});
152 pipeline_mng->getOpDomainLhsPipeline().push_back(
154 pipeline_mng->getOpDomainLhsPipeline().push_back(
156 pipeline_mng->getOpDomainLhsPipeline().push_back(
162 pipeline_mng->getOpDomainRhsPipeline().push_back(
164 pipeline_mng->getOpDomainRhsPipeline().push_back(
166 pipeline_mng->getOpDomainRhsPipeline().push_back(
172 pipeline_mng->getOpBoundaryLhsPipeline().push_back(
174 pipeline_mng->getOpBoundaryLhsPipeline().push_back(
176 pipeline_mng->getOpBoundaryLhsPipeline().push_back(
182 pipeline_mng->getOpBoundaryRhsPipeline().push_back(
184 pipeline_mng->getOpBoundaryRhsPipeline().push_back(
186 pipeline_mng->getOpBoundaryRhsPipeline().push_back(
200 auto domain_rule_lhs = [](int, int,
int p) ->
int {
return 2 * (p - 1); };
201 auto domain_rule_rhs = [](int, int,
int p) ->
int {
return 2 * (p - 1); };
203 CHKERR pipeline_mng->setDomainRhsIntegrationRule(domain_rule_rhs);
205 auto boundary_rule_lhs = [](int, int,
int p) ->
int {
return 2 * p; };
206 auto boundary_rule_rhs = [](int, int,
int p) ->
int {
return 2 * p; };
207 CHKERR pipeline_mng->setBoundaryLhsIntegrationRule(boundary_rule_lhs);
208 CHKERR pipeline_mng->setBoundaryLhsIntegrationRule(boundary_rule_rhs);
220 auto ksp_solver = pipeline_mng->
createKSP();
221 CHKERR KSPSetFromOptions(ksp_solver);
231 CHKERR KSPGetPC(ksp_solver, &pc);
232 PetscBool is_pcfs = PETSC_FALSE;
233 PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &is_pcfs);
238 if (is_pcfs == PETSC_TRUE) {
239 IS is_domain, is_boundary;
246 CHKERR PCFieldSplitSetIS(pc, NULL, is_boundary);
247 CHKERR ISDestroy(&is_boundary);
251 CHKERR KSPSetUp(ksp_solver);
257 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
258 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
271 pipeline_mng->getBoundaryLhsFE().reset();
272 pipeline_mng->getDomainRhsFE().reset();
273 pipeline_mng->getBoundaryRhsFE().reset();
275 auto d_ptr = boost::make_shared<VectorDouble>();
276 auto l_ptr = boost::make_shared<VectorDouble>();
280 auto post_proc_fe = boost::make_shared<PostProcFaceEle>(
mField);
282 post_proc_fe->getOpPtrVector().push_back(
284 post_proc_fe->getOpPtrVector().push_back(
new OpPPMap(
285 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
286 {{domainField, d_ptr}}, {}, {}, {}));
287 pipeline_mng->getDomainRhsFE() = post_proc_fe;
289 CHKERR pipeline_mng->loopFiniteElements();
290 CHKERR post_proc_fe->writeFile(
"out_result.h5m");
300 auto check_result_fe_ptr = boost::make_shared<FaceEle>(
mField);
306 check_result_fe_ptr->getOpPtrVector(), {H1})),
309 check_result_fe_ptr->getRuleHook = [](int, int,
int p) {
return 2 * p; };
310 auto analyticalFunction = [&](
double x,
double y,
double z) {
311 return cos(x * M_PI) * cos(y * M_PI);
314 auto u_ptr = boost::make_shared<VectorDouble>();
316 check_result_fe_ptr->getOpPtrVector().push_back(
318 auto mValFuncPtr = boost::make_shared<VectorDouble>();
319 check_result_fe_ptr->getOpPtrVector().push_back(
321 check_result_fe_ptr->getOpPtrVector().push_back(
323 CHKERR VecZeroEntries(petscVec);
326 check_result_fe_ptr);
327 CHKERR VecAssemblyBegin(petscVec);
328 CHKERR VecAssemblyEnd(petscVec);
332 CHKERR VecGetArrayRead(petscVec, &norms);
334 <<
"NORM: " << std::sqrt(norms[
NORM]);
335 CHKERR VecRestoreArrayRead(petscVec, &norms);
339 CHKERR VecGetArrayRead(petscVec, &t_ptr);
340 double ref_norm = 1.4e-04;
344 cal_norm = sqrt(t_ptr[0]);
348 "atom test %d does not exist",
atom_test);
350 if (cal_norm > ref_norm) {
352 "atom test %d failed! Calculated Norm %3.16e is greater than "
353 "reference Norm %3.16e",
356 CHKERR VecRestoreArrayRead(petscVec, &t_ptr);
379int main(
int argc,
char *argv[]) {
382 const char param_file[] =
"param_file.petsc";
388 DMType dm_name =
"DMMOFEM";
392 moab::Core mb_instance;
393 moab::Interface &moab = mb_instance;
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base nme:nme847.
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr auto domainField
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
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.
auto createDMVector(DM dm)
Get smart vector from DM.
SmartPetscObj< KSP > createKSP(SmartPetscObj< DM > dm=nullptr)
Create KSP (linear) solver.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
auto type_from_handle(const EntityHandle h)
get type from entity handle
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
auto createVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
FormsIntegrators< BoundaryEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesScalar< 1 > OpBoundaryRhs
FormsIntegrators< BoundaryEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, 1 > OpBoundaryLhs
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
Add operators pushing bases from local to physical configuration.
Simple interface for fast problem set-up.
MoFEMErrorCode pushMarkDOFsOnEntities(const std::string problem_name, const std::string block_name, const std::string field_name, int lo, int hi, bool get_low_dim_ents=true)
Mark block DOFs.
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() 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.
Section manager is used to create indexes and sections.
Get norm of input VectorDouble for Tensor0.
Get value at integration points for scalar field.
Get values from scalar function at integration points and save them to VectorDouble for Tensor0.
Post post-proc data at points from hash maps.
Set indices on entities on finite element.
PipelineManager interface.
boost::shared_ptr< FEMethod > & getDomainLhsFE()
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
keeps basic data about problem
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.
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 setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
const std::string getProblemName() const
Get the Problem Name.
const std::string getDomainFEName() const
Get the Domain FE Name.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
static double boundaryFunction(const double x, const double y, const double z)
Poisson2DNonhomogeneous(MoFEM::Interface &m_field)
MoFEMErrorCode solveSystem()
[Set integration rules]
MoFEMErrorCode setIntegrationRules()
[Assemble system]
static double sourceTermFunction(const double x, const double y, const double z)
MoFEMErrorCode setupProblem()
[Read mesh]
MoFEMErrorCode boundaryCondition()
[Setup problem]
Range boundaryEntitiesForFieldsplit
MoFEMErrorCode checkResults()
[Output results]
boost::shared_ptr< std::vector< unsigned char > > boundaryMarker
MoFEMErrorCode runProgram()
[Check]
MoFEM::Interface & mField
MoFEMErrorCode outputResults()
[Solve system]
MoFEMErrorCode readMesh()
[Read mesh]
MoFEMErrorCode assembleSystem()
[Boundary condition]