25static char help[] =
"...\n\n";
54 return 2. * M_PI * M_PI * sin(M_PI * x) * sin(M_PI * y);
84 auto get_ents_by_dim = [&](
const auto dim) {
98 auto get_base = [&]() {
99 auto domain_ents = get_ents_by_dim(
SPACE_DIM);
100 if (domain_ents.empty())
117 auto base = get_base();
156 pipeline_mng->getOpDomainLhsPipeline(), {H1});
157 pipeline_mng->getOpDomainLhsPipeline().push_back(
163 auto set_values_to_bc_dofs = [&](
auto &fe) {
164 auto get_bc_hook = [&]() {
168 fe->preProcessHook = get_bc_hook();
172 auto calculate_residual_from_set_values_on_bc = [&](
auto &pipeline) {
179 auto grad_u_vals_ptr = boost::make_shared<MatrixDouble>();
180 pipeline_mng->getOpDomainRhsPipeline().push_back(
183 pipeline_mng->getOpDomainRhsPipeline().push_back(
185 [](
double,
double,
double)
constexpr {
return -1; }));
189 pipeline_mng->getOpDomainRhsPipeline(), {H1});
190 set_values_to_bc_dofs(pipeline_mng->getDomainRhsFE());
191 calculate_residual_from_set_values_on_bc(
192 pipeline_mng->getOpDomainRhsPipeline());
193 pipeline_mng->getOpDomainRhsPipeline().push_back(
205 auto rule_lhs = [](int, int,
int p) ->
int {
return 2 * (p - 1); };
206 auto rule_rhs = [](int, int,
int p) ->
int {
return p; };
210 CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule_rhs);
222 auto ksp_solver = pipeline_mng->
createKSP();
223 CHKERR KSPSetFromOptions(ksp_solver);
224 CHKERR KSPSetUp(ksp_solver);
235 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
236 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
250 auto post_proc_fe = boost::make_shared<PostProcFaceEle>(
mField);
252 post_proc_fe->getOpPtrVector(), {H1});
254 auto u_ptr = boost::make_shared<VectorDouble>();
255 auto grad_u_ptr = boost::make_shared<MatrixDouble>();
256 post_proc_fe->getOpPtrVector().push_back(
259 post_proc_fe->getOpPtrVector().push_back(
264 post_proc_fe->getOpPtrVector().push_back(
266 new OpPPMap(post_proc_fe->getPostProcMesh(),
267 post_proc_fe->getMapGaussPts(),
281 pipeline_mng->getDomainRhsFE() = post_proc_fe;
282 CHKERR pipeline_mng->loopFiniteElements();
283 CHKERR post_proc_fe->writeFile(
"out_result.h5m");
293 auto check_result_fe_ptr = boost::make_shared<DomainEle>(
mField);
299 check_result_fe_ptr->getOpPtrVector(), {H1})),
302 check_result_fe_ptr->getRuleHook = [](int, int,
int p) {
return p; };
303 auto analyticalFunction = [&](
double x,
double y,
double z) {
304 return sin(M_PI * x) * sin(M_PI * y);
307 auto u_ptr = boost::make_shared<VectorDouble>();
309 check_result_fe_ptr->getOpPtrVector().push_back(
311 auto mValFuncPtr = boost::make_shared<VectorDouble>();
312 check_result_fe_ptr->getOpPtrVector().push_back(
314 check_result_fe_ptr->getOpPtrVector().push_back(
319 check_result_fe_ptr);
328 <<
"NORM: " << std::sqrt(norms[
NORM]);
335 double ref_norm = 2.2e-04;
339 cal_norm = sqrt(t_ptr[0]);
343 "atom test %d does not exist",
atom_test);
345 if (cal_norm > ref_norm) {
347 "atom test %d failed! Calculated Norm %3.16e is greater than "
348 "reference Norm %3.16e",
375int main(
int argc,
char *argv[]) {
378 const char param_file[] =
"param_file.petsc";
384 DMType dm_name =
"DMMOFEM";
388 moab::Core mb_instance;
389 moab::Interface &moab = mb_instance;
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#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.
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
set local (or ghosted) vector values on mesh for partition only
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, RowColData rc=RowColData::COL)
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.
MoFEMErrorCode removeBlockDOFsOnEntities(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, bool is_distributed_mesh=true)
Remove DOFs from problem based on block entities.
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.
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
constexpr auto field_name
Add operators pushing bases from local to physical configuration.
Boundary condition manager for finite element problem setup.
Template specialization for scalar field boundary conditions.
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.
Class (Function) to enforce essential constrains.
Interface for managing meshsets containing materials and boundary conditions.
Get norm of input VectorDouble for Tensor0.
Get field gradients at integration pts for scalar field rank 0, i.e. vector field.
Specialization for double precision scalar field values calculation.
Get values from scalar function at integration points and save them to VectorDouble for Tensor0.
Post post-proc data at points from hash maps.
std::map< std::string, ScalarDataPtr > DataMapVec
std::map< std::string, boost::shared_ptr< MatrixDouble > > DataMapMat
Template struct for dimension-specific finite element types.
PipelineManager interface.
boost::shared_ptr< FEMethod > & getDomainLhsFE()
Get domain left-hand side finite element.
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
Set integration rule for domain left-hand side finite element.
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 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.
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
MoFEMErrorCode setupProblem()
[Read mesh]
MoFEMErrorCode boundaryCondition()
[Setup problem]
Poisson2DHomogeneous(MoFEM::Interface &m_field)
MoFEMErrorCode runProgram()
[Check]
MoFEMErrorCode readMesh()
[Read mesh]
MoFEM::Interface & mField
MoFEMErrorCode checkResults()
[Output results]
SmartPetscObj< Vec > petscVec
MoFEMErrorCode outputResults()
[Solve system]
MoFEMErrorCode assembleSystem()
[Boundary condition]
MoFEMErrorCode solveSystem()
[Set integration rules]
static double sourceTermFunction(const double x, const double y, const double z)
MoFEMErrorCode setIntegrationRules()
[Assemble system]
#define EXECUTABLE_DIMENSION