|
| v0.14.0
|
Go to the documentation of this file.
20 using namespace MoFEM;
25 static char help[] =
"...\n\n";
54 return 2. * M_PI * M_PI * sin(M_PI * x) * sin(M_PI * y);
59 enum NORMS { NORM = 0, LAST_NORM };
83 auto get_ents_by_dim = [&](
const auto dim) {
97 auto get_base = [&]() {
98 auto domain_ents = get_ents_by_dim(
SPACE_DIM);
99 if (domain_ents.empty())
116 auto base = get_base();
155 pipeline_mng->getOpDomainLhsPipeline(), {H1});
156 pipeline_mng->getOpDomainLhsPipeline().push_back(
162 auto set_values_to_bc_dofs = [&](
auto &fe) {
163 auto get_bc_hook = [&]() {
167 fe->preProcessHook = get_bc_hook();
171 auto calculate_residual_from_set_values_on_bc = [&](
auto &pipeline) {
178 auto grad_u_vals_ptr = boost::make_shared<MatrixDouble>();
179 pipeline_mng->getOpDomainRhsPipeline().push_back(
182 pipeline_mng->getOpDomainRhsPipeline().push_back(
184 [](
double,
double,
double) constexpr {
return -1; }));
188 pipeline_mng->getOpDomainRhsPipeline(), {H1});
189 set_values_to_bc_dofs(pipeline_mng->getDomainRhsFE());
190 calculate_residual_from_set_values_on_bc(
191 pipeline_mng->getOpDomainRhsPipeline());
192 pipeline_mng->getOpDomainRhsPipeline().push_back(
204 auto rule_lhs = [](
int,
int,
int p) ->
int {
return 2 * (p - 1); };
205 auto rule_rhs = [](
int,
int,
int p) ->
int {
return p; };
208 CHKERR pipeline_mng->setDomainLhsIntegrationRule(rule_lhs);
209 CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule_rhs);
221 auto ksp_solver = pipeline_mng->
createKSP();
222 CHKERR KSPSetFromOptions(ksp_solver);
223 CHKERR KSPSetUp(ksp_solver);
234 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
235 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
249 auto post_proc_fe = boost::make_shared<PostProcFaceEle>(
mField);
251 post_proc_fe->getOpPtrVector(), {H1});
253 auto u_ptr = boost::make_shared<VectorDouble>();
254 auto grad_u_ptr = boost::make_shared<MatrixDouble>();
255 post_proc_fe->getOpPtrVector().push_back(
258 post_proc_fe->getOpPtrVector().push_back(
263 post_proc_fe->getOpPtrVector().push_back(
265 new OpPPMap(post_proc_fe->getPostProcMesh(),
266 post_proc_fe->getMapGaussPts(),
280 pipeline_mng->getDomainRhsFE() = post_proc_fe;
281 CHKERR pipeline_mng->loopFiniteElements();
282 CHKERR post_proc_fe->writeFile(
"out_result.h5m");
292 auto check_result_fe_ptr = boost::make_shared<DomainEle>(
mField);
298 check_result_fe_ptr->getOpPtrVector(), {H1})),
301 check_result_fe_ptr->getRuleHook = [](
int,
int,
int p) {
return p; };
302 auto analyticalFunction = [&](
double x,
double y,
double z) {
303 return sin(M_PI * x) * sin(M_PI * y);
306 auto u_ptr = boost::make_shared<VectorDouble>();
308 check_result_fe_ptr->getOpPtrVector().push_back(
310 auto mValFuncPtr = boost::make_shared<VectorDouble>();
311 check_result_fe_ptr->getOpPtrVector().push_back(
313 check_result_fe_ptr->getOpPtrVector().push_back(
318 check_result_fe_ptr);
327 <<
"NORM: " << std::sqrt(norms[
NORM]);
334 double ref_norm = 2.2e-04;
338 cal_norm = sqrt(t_ptr[0]);
342 "atom test %d does not exist",
atom_test);
344 if (cal_norm > ref_norm) {
346 "atom test %d failed! Calculated Norm %3.16e is greater than "
347 "reference Norm %3.16e",
374 int main(
int argc,
char *argv[]) {
377 const char param_file[] =
"param_file.petsc";
383 DMType dm_name =
"DMMOFEM";
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
MoFEMErrorCode solveSystem()
[Set integration rules]
#define EXECUTABLE_DIMENSION
static double sourceTermFunction(const double x, const double y, const double z)
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
MoFEMErrorCode setupProblem()
[Read mesh]
std::map< std::string, boost::shared_ptr< VectorDouble > > DataMapVec
virtual MPI_Comm & get_comm() const =0
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
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 assembleSystem()
[Boundary condition]
MoFEMErrorCode outputResults()
[Solve system]
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Poisson2DHomogeneous(MoFEM::Interface &m_field)
Simple interface for fast problem set-up.
Deprecated interface functions.
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
DeprecatedCoreInterface Interface
MoFEMErrorCode getOptions()
get options
MoFEMErrorCode getDM(DM *dm)
Get DM.
#define CHKERR
Inline error check.
auto createDMVector(DM dm)
Get smart vector from DM.
virtual moab::Interface & get_moab()=0
implementation of Data Operators for Forces and Sources
Simple interface for fast problem set-up.
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpGradGrad< BASE_DIM, FIELD_DIM, SPACE_DIM > OpDomainLhsMatrixK
SmartPetscObj< Vec > petscVec
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.
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
const std::string getDomainFEName() const
Get the Domain FE Name.
auto type_from_handle(const EntityHandle h)
get type from entity handle
MoFEM::Interface & mField
MoFEMErrorCode setIntegrationRules()
[Assemble system]
Get values from scalar function at integration points and save them to VectorDouble for Tensor0.
std::map< std::string, boost::shared_ptr< MatrixDouble > > DataMapMat
int main(int argc, char *argv[])
[Run program]
FormsIntegrators< DomainEleOp >::Assembly< A >::LinearForm< I >::OpGradTimesTensor< 1, FIELD_DIM, SPACE_DIM > OpGradTimesTensor
constexpr auto field_name
MoFEMErrorCode boundaryCondition()
[Setup problem]
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
Add operators pushing bases from local to physical configuration.
MoFEMErrorCode checkResults()
[Output results]
Specialization for TemperatureCubitBcData.
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_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
#define CATCH_ERRORS
Catch errors.
MoFEMErrorCode runProgram()
[Check]
ForcesAndSourcesCore::UserDataOperator UserDataOperator
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Get norm of input VectorDouble for Tensor0.
auto createVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
const double D
diffusivity
@ MOFEM_ATOM_TEST_INVALID
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
MoFEMErrorCode readMesh()
[Read mesh]
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
const std::string getProblemName() const
Get the Problem Name.
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Post post-proc data at points from hash maps.