25static char help[] =
"...\n\n";
72 OpRhs(boost::shared_ptr<MatrixDouble> u_grad_ptr);
116 moab::Interface::UNION);
118 for (
auto e : edges) {
124 for (
int j = 0;
j != 3; ++
j) {
125 l2e += pow(coords(0,
j) - coords(1,
j), 2);
127 l2 = std::max(l2, l2e);
142 constexpr int order = 1;
155 auto rule = [](
int,
int,
int p) ->
int {
return 2 * p; };
188 auto grad_u_ptr = boost::make_shared<MatrixDouble>();
192 auto set_domain_general = [&](
auto &pipeline) {
193 auto det_ptr = boost::make_shared<VectorDouble>();
194 auto jac_ptr = boost::make_shared<MatrixDouble>();
195 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
202 auto set_domain_lhs_first = [&](
auto &pipeline) {
204 pipeline.push_back(
new OpGradGrad(
"U",
"U", one));
206 pipeline.push_back(
new OpMass(
"U",
"U",
rho));
212 auto set_domain_rhs_first = [&](
auto &pipeline) {};
216 auto set_domain_lhs_second = [&](
auto &pipeline) {
218 pipeline.push_back(
new OpGradGrad(
"U",
"U", one));
222 auto set_domain_rhs_second = [&](
auto &pipeline) {
224 pipeline.push_back(
new OpRhs(grad_u_ptr));
228 auto solve_first = [&]() {
233 auto solver = pipeline_mng->createKSP();
234 CHKERR KSPSetFromOptions(solver);
245 auto dofs_ptr = problem_ptr->getNumeredRowDofsPtr();
250 if (dof != dofs_ptr->end())
251 VecSetValue(
F, (*dof)->getPetscGlobalDofIdx(), 1, INSERT_VALUES);
258 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
259 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
265 auto solve_second = [&]() {
271 CHKERR prb_mng->removeDofsOnEntities(
simple->getProblemName(),
"U",
276 auto solver = pipeline_mng->createKSP();
277 CHKERR KSPSetFromOptions(solver);
285 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
286 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
292 auto post_proc = [&](
const std::string out_name) {
297 auto det_ptr = boost::make_shared<VectorDouble>();
298 auto jac_ptr = boost::make_shared<MatrixDouble>();
299 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
303 boost::make_shared<PostProcBrokenMeshInMoab<DomainEle>>(
mField);
305 post_proc_fe->getOpPtrVector().push_back(
307 post_proc_fe->getOpPtrVector().push_back(
309 post_proc_fe->getOpPtrVector().push_back(
312 auto u_ptr = boost::make_shared<VectorDouble>();
313 auto grad_ptr = boost::make_shared<MatrixDouble>();
315 post_proc_fe->getOpPtrVector().push_back(
317 post_proc_fe->getOpPtrVector().push_back(
322 post_proc_fe->getOpPtrVector().push_back(
new OpPPMap(
323 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
327 {{
"GRAD_U", grad_ptr}},
333 CHKERR post_proc_fe->writeFile(out_name);
345 CHKERR post_proc(
"out_heat_method_first.h5m");
356 CHKERR post_proc(
"out_heat_method_second.h5m");
383int main(
int argc,
char *argv[]) {
386 const char param_file[] =
"param_file.petsc";
390 auto core_log = logging::core::get();
399 DMType dm_name =
"DMMOFEM";
404 moab::Core mb_instance;
405 moab::Interface &moab = mb_instance;
435 auto t_grad = getFTensor1FromMat<3>(*uGradPtr);
437 auto nb_base_functions = data.
getN().size2();
438 auto nb_gauss_pts = getGaussPts().size2();
439 std::array<double, MAX_DOFS_ON_ENTITY> nf;
440 std::fill(nf.begin(), &nf[nb_dofs], 0);
443 auto t_w = getFTensor0IntegrationWeight();
444 auto a = getMeasure();
446 for (
size_t gg = 0; gg != nb_gauss_pts; ++gg) {
447 double alpha = t_w *
a;
449 const auto l2 = t_grad(
i) * t_grad(
i);
451 if (l2 > std::numeric_limits<double>::epsilon())
452 t_one(
i) = t_grad(
i) / std::sqrt(l2);
457 for (; bb != nb_dofs; ++bb) {
458 nf[bb] -= alpha * t_diff_base(
i) * t_one(
i);
462 for (; bb < nb_base_functions; ++bb) {
469 CHKERR VecSetValues<MoFEM::EssentialBcStorage>(getKSPf(), data, &nf[0],
void simple(double P1[], double P2[], double P3[], double c[], const int N)
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#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)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
auto createDMVector(DM dm)
Get smart vector from DM.
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
boost::ptr_deque< UserDataOperator > & getOpDomainLhsPipeline()
Get the Op Domain Lhs Pipeline object.
boost::ptr_deque< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
FTensor::Index< 'i', SPACE_DIM > i
const double v
phase velocity of light in medium (cm/ns)
FTensor::Index< 'j', 3 > j
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
OpCalculateHOJacForFaceImpl< 3 > OpCalculateHOJacForFaceEmbeddedIn3DSpace
FormsIntegrators< DomainEleOp >::Assembly< A >::BiLinearForm< I >::OpGradGrad< 1, FIELD_DIM, SPACE_DIM > OpGradGrad
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM > OpMass
[Only used with Hooke equation (linear material model)]
boost::shared_ptr< MatrixDouble > uGradPtr
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
OpRhs(boost::shared_ptr< MatrixDouble > u_grad_ptr)
MoFEMErrorCode boundaryCondition()
MoFEMErrorCode assembleSystem()
MoFEMErrorCode readMesh()
MoFEMErrorCode setIntegrationRules()
MoFEMErrorCode checkResults()
MoFEMErrorCode solveSystem()
MoFEMErrorCode createCommonData()
Example(MoFEM::Interface &m_field)
MoFEMErrorCode runProblem()
MoFEM::Interface & mField
Reference to MoFEM interface.
MoFEMErrorCode setupProblem()
MoFEMErrorCode outputResults()
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
virtual moab::Interface & get_moab()=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.
static UId getUniqueIdCalculate(const DofIdx dof, UId ent_uid)
Data on single entity (This is passed as argument to DataOperator::doWork)
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1DiffN(const FieldApproximationBase base)
Get derivatives of base functions.
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
const VectorInt & getIndices() const
Get global indices of degrees of freedom on entity.
UId getLocalUniqueIdCalculate()
Get the Local Unique Id Calculate object.
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Get field gradients at integration pts for scalar field rank 0, i.e. vector field.
Specialization for double precision scalar field values calculation.
Operator for inverting matrices at integration points.
Post post-proc data at points from hash maps.
PipelineManager interface.
boost::shared_ptr< FEMethod > & getDomainRhsFE()
Get domain right-hand side finite element.
boost::shared_ptr< FEMethod > & getDomainLhsFE()
Get domain left-hand side finite element.
MoFEM::FaceElementForcesAndSourcesCore FaceEle
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
Set integration rule for domain right-hand side finite element.
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
Set integration rule for domain left-hand side finite element.
Problem manager is used to build and partition problems.
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.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.