13static char help[] =
"...\n\n";
40 DomainEle::UserDataOperator;
48 GAUSS>::OpGradGradSymTensorGradGrad<1, 1, SPACE_DIM, 0>;
57constexpr double mu = 1;
58constexpr double t = 1;
72 return cos(2 * x * M_PI) * sin(2 * y * M_PI);
81 auto mat_D_ptr = boost::make_shared<MatrixDouble>(1,
a *
a);
82 auto t_D = getFTensor4DdgFromMat<2, 2, 0>(*(mat_D_ptr));
83 constexpr double t3 =
t *
t *
t;
84 constexpr double A =
mu * t3 / 12;
85 constexpr double B =
lambda * t3 / 12;
95std::array<std::vector<VectorInt>, 2>
97std::array<std::vector<MatrixDouble>, 2>
99std::array<std::vector<MatrixDouble>, 2>
128 boost::shared_ptr<MatrixDouble> d_mat_ptr);
134 boost::shared_ptr<FaceSideEle>
203 auto get_skin = [&]() {
209 MOAB_THROW(skin.find_skin(0, body_ents,
false, skin_ents));
212 skin_ents.merge(verts);
217 auto remove_dofs_from_problem = [&](
Range &&skin) {
221 CHKERR problem_mng->removeDofsOnEntities(
simple->getProblemName(),
"U",
227 CHKERR remove_dofs_from_problem(get_skin());
239 auto rule_lhs = [](int, int,
int p) ->
int {
return 2 * p; };
240 auto rule_rhs = [](int, int,
int p) ->
int {
return 2 * p; };
241 auto rule_2 = [
this](int, int, int) {
return 2 *
order; };
244 CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule_rhs);
246 CHKERR pipeline_mng->setSkeletonLhsIntegrationRule(rule_2);
247 CHKERR pipeline_mng->setSkeletonRhsIntegrationRule(rule_2);
248 CHKERR pipeline_mng->setBoundaryLhsIntegrationRule(rule_2);
249 CHKERR pipeline_mng->setBoundaryRhsIntegrationRule(rule_2);
251 auto det_ptr = boost::make_shared<VectorDouble>();
252 auto jac_ptr = boost::make_shared<MatrixDouble>();
253 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
254 auto base_mass_ptr = boost::make_shared<MatrixDouble>();
255 auto data_l2_ptr = boost::make_shared<EntitiesFieldData>(MBENTITYSET);
259 auto push_ho_direcatives = [&](
auto &pipeline) {
263 BaseDerivatives::SecondDerivative, base_mass_ptr, data_l2_ptr,
271 auto push_jacobian = [&](
auto &pipeline) {
282 push_ho_direcatives(pipeline_mng->getOpDomainLhsPipeline());
283 push_jacobian(pipeline_mng->getOpDomainLhsPipeline());
285 pipeline_mng->getOpDomainLhsPipeline().push_back(
290 pipeline_mng->getOpDomainRhsPipeline().push_back(
294 auto side_fe_ptr = boost::make_shared<FaceSideEle>(
mField);
295 push_ho_direcatives(side_fe_ptr->getOpPtrVector());
296 push_jacobian(side_fe_ptr->getOpPtrVector());
300 pipeline_mng->getOpSkeletonLhsPipeline().push_back(
314 auto ksp_solver = pipeline_mng->createKSP();
315 CHKERR KSPSetFromOptions(ksp_solver);
316 CHKERR KSPSetUp(ksp_solver);
319 auto dm =
simple->getDM();
326 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
327 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
340 auto post_proc_fe = boost::make_shared<PostProcEle>(
mField);
342 auto u_ptr = boost::make_shared<VectorDouble>();
343 post_proc_fe->getOpPtrVector().push_back(
348 post_proc_fe->getOpPtrVector().push_back(
350 new OpPPMap(post_proc_fe->getPostProcMesh(),
351 post_proc_fe->getMapGaussPts(),
362 CHKERR pipeline_mng->loopFiniteElementsPostProc();
363 CHKERR post_proc_fe->writeFile(
"out_result.h5m");
385int main(
int argc,
char *argv[]) {
388 const char param_file[] =
"param_file.petsc";
392 auto core_log = logging::core::get();
400 DMType dm_name =
"DMMOFEM";
405 moab::Core mb_instance;
406 moab::Interface &moab = mb_instance;
425 std::string col_field_name)
432 const auto nb_in_loop = getFEMethod()->nInTheLoop;
434 auto clear = [](
auto nb) {
440 if (
type == MBVERTEX) {
441 areaMap[nb_in_loop] = getMeasure();
442 senseMap[nb_in_loop] = getSkeletonSense();
451 const auto nb_dofs = data.
getIndices().size();
455 data.
getN(BaseDerivatives::FirstDerivative));
457 data.
getN(BaseDerivatives::SecondDerivative));
465 &*base_mat.data().begin());
468template <
typename T>
inline auto get_ntensor(T &base_mat,
int gg,
int bb) {
469 double *ptr = &base_mat(gg, bb);
474 double *ptr = &*base_mat.data().begin();
475 return getFTensor1FromPtr<2>(ptr);
480 double *ptr = &base_mat(gg, 2 * bb);
481 return getFTensor1FromPtr<2>(ptr);
485 double *ptr = &*base_mat.data().begin();
491 double *ptr = &base_mat(gg, 4 * bb);
501 boost::shared_ptr<MatrixDouble> mat_d_ptr)
503 dMatPtr(mat_d_ptr) {}
511 const auto in_the_loop =
519 auto t_normal = getFTensor1Normal();
520 t_normal.normalize();
524 auto t_D = getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*
dMatPtr);
527 const size_t nb_integration_pts = getGaussPts().size2();
531 const double beta =
static_cast<double>(
nitsche) / (in_the_loop + 1);
533 auto integrate = [&](
auto sense_row,
auto &row_ind,
auto &row_diff,
534 auto &row_diff2,
auto sense_col,
auto &col_ind,
535 auto &col_diff,
auto &col_diff2) {
540 const auto nb_rows = row_ind.size();
541 const auto nb_cols = col_ind.size();
543 const auto nb_row_base_functions = row_diff.size2() /
SPACE_DIM;
548 locMat.resize(nb_rows, nb_cols,
false);
555 auto t_w = getFTensor0IntegrationWeight();
558 for (
size_t gg = 0; gg != nb_integration_pts; ++gg) {
562 const double alpha = getMeasure() * t_w;
563 auto t_mat =
locMat.data().begin();
567 for (; rr != nb_rows; ++rr) {
570 t_mv(
i,
j) = t_D(
i,
j,
k,
l) * t_diff2_row_base(
k,
l);
574 t_vn_plus(
i,
j) = beta * (
phi * t_mv(
i,
j) / p);
576 t_vn(
i,
j) = (t_diff_row_base(
j) * (t_normal(
i) * sense_row)) -
584 for (
size_t cc = 0; cc != nb_cols; ++cc) {
587 t_mu(
i,
j) = t_D(
i,
j,
k,
l) * t_diff2_col_base(
k,
l);
591 t_un(
i,
j) = -p * ((t_diff_col_base(
j) * (t_normal(
i) * sense_col) -
592 beta * t_mu(
i,
j) / p));
595 *t_mat -= alpha * (t_vn(
i,
j) * t_un(
i,
j));
596 *t_mat -= alpha * (t_vn_plus(
i,
j) * (beta * t_mu(
i,
j)));
614 for (; rr < nb_row_base_functions; ++rr) {
623 CHKERR ::MatSetValues(getKSPB(), nb_rows, &*row_ind.begin(),
624 col_ind.size(), &*col_ind.begin(),
625 &*
locMat.data().begin(), ADD_VALUES);
634 const auto sense_row =
senseMap[s0];
639 const auto sense_col =
senseMap[s1];
void simple(double P1[], double P2[], double P3[], double c[], const int N)
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
Kronecker Delta class symmetric.
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MOAB_THROW(err)
Check error code of MoAB function and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ L2
field with C-1 continuity
#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.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
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.
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpGradGrad< 1, 1, SPACE_DIM > OpDomainGradGrad
PipelineManager::ElementsAndOpsByDim< FE_DIM >::FaceSideEle FaceSideEle
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
auto getFTensor2SymmetricLowerFromPtr< 2 >(double *ptr)
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetScalar(PetscOptions *, const char pre[], const char name[], PetscScalar *dval, PetscBool *set)
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
constexpr double mu
lame parameter
auto get_diff_ntensor(T &base_mat)
std::array< std::vector< MatrixDouble >, 2 > diff2BaseSideMap
FTensor::Index< 'j', SPACE_DIM > j
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpGradGradSymTensorGradGrad< 1, 1, SPACE_DIM, 0 > OpDomainPlateStiffness
std::array< std::vector< MatrixDouble >, 2 > diffBaseSideMap
FTensor::Index< 'k', SPACE_DIM > k
FTensor::Index< 'i', SPACE_DIM > i
auto get_ntensor(T &base_mat)
constexpr int SPACE_DIM
dimension of space
FTensor::Index< 'l', SPACE_DIM > l
constexpr int FIELD_DIM
dimension of approx. field
auto plate_stiffness
get fourth-order constitutive tensor
std::array< double, 2 > areaMap
std::array< std::vector< VectorInt >, 2 > indicesSideMap
indices on rows for left hand-side
std::array< int, 2 > senseMap
constexpr int BASE_DIM
dimension of base
constexpr double t
plate stiffness
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpSource< BASE_DIM, FIELD_DIM > OpDomainPlateLoad
auto get_diff2_ntensor(T &base_mat)
constexpr auto field_name
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.
Data on single entity (This is passed as argument to DataOperator::doWork)
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.
default operator for Face element
Base face element used to integrate on skeleton.
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.
Specialization for double precision scalar field values calculation.
Operator for inverting matrices at integration points.
Post post-proc data at points from hash maps.
Modify integration weights on face to take into account higher-order geometry.
PipelineManager interface.
MoFEM::FaceElementForcesAndSourcesCore FaceEle
boost::shared_ptr< FEMethod > & getDomainPostProcFE()
Get domain postprocessing finite element.
MoFEM::EdgeElementForcesAndSourcesCore EdgeEle
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 getOptions()
get options
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Operator tp collect data from elements on the side of Edge/Face.
OpCalculateSideData(std::string field_name, std::string col_field_name)
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
Operator the left hand side matrix.
boost::shared_ptr< MatrixDouble > dMatPtr
boost::shared_ptr< FaceSideEle > sideFEPtr
pointer to element to get data on edge/face sides
MatrixDouble locMat
local operator matrix
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
OpH1LhsSkeleton(boost::shared_ptr< FaceSideEle > side_fe_ptr, boost::shared_ptr< MatrixDouble > d_mat_ptr)
Construct a new OpH1LhsSkeleton.
MoFEMErrorCode setupProblem()
[Read mesh]
MoFEM::Interface & mField
MoFEMErrorCode runProblem()
[Output results]
MoFEMErrorCode boundaryCondition()
[Set up problem]
MoFEMErrorCode outputResults()
[Solve system]
MoFEMErrorCode solveSystem()
[Push operators to pipeline]
MoFEMErrorCode assembleSystem()
[Boundary condition]
Plate(MoFEM::Interface &m_field)
MoFEMErrorCode readMesh()
[Read mesh]