v0.13.1
Public Member Functions | Public Attributes | List of all members
Op< OP > Struct Template Reference
Inheritance diagram for Op< OP >:
[legend]
Collaboration diagram for Op< OP >:
[legend]

Public Member Functions

 Op (moab::Interface &post_proc, MapCoords &map_coords, EntityHandle prism)
 
MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 

Public Attributes

moab::Interface & postProc
 
MapCoordsmapCoords
 
EntityHandle prism
 
std::vector< EntityHandle > nodeHandles
 

Detailed Description

template<typename OP>
struct Op< OP >
Examples
build_large_problem.cpp, and prism_elements_from_surface.cpp.

Definition at line 90 of file prism_elements_from_surface.cpp.

Constructor & Destructor Documentation

◆ Op()

template<typename OP >
Op< OP >::Op ( moab::Interface &  post_proc,
MapCoords map_coords,
EntityHandle  prism 
)
Examples
build_large_problem.cpp, and prism_elements_from_surface.cpp.

Definition at line 590 of file prism_elements_from_surface.cpp.

592 : OP("FIELD1", "FIELD1", ForcesAndSourcesCore::UserDataOperator::OPROW),
593 postProc(post_proc), mapCoords(map_coords), prism(prism) {}
MapCoords & mapCoords
moab::Interface & postProc
EntityHandle prism

Member Function Documentation

◆ doWork()

template<typename OP >
MoFEMErrorCode Op< OP >::doWork ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)
Examples
build_large_problem.cpp, and prism_elements_from_surface.cpp.

Definition at line 596 of file prism_elements_from_surface.cpp.

597 {
598 constexpr double def_val[] = {0, 0, 0};
600 switch (type) {
601 case MBVERTEX:
602 case MBEDGE:
603 case MBTRI:
604 case MBQUAD:
605 break;
606 default:
608 }
609
610 const int nb_dofs = data.getIndices().size();
611 for (int dd = 0; dd != nb_dofs; ++dd)
612 if (data.getFieldData()[dd] != data.getIndices()[dd]) {
613 std::cerr << "Indices: " << data.getIndices() << std::endl;
614 std::cerr << "Local indices: " << data.getLocalIndices() << std::endl;
615 std::cerr << "Data: " << data.getFieldData() << std::endl;
616 SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
617 "Indicices/data inconsistency %3.1f != %d",
618 data.getFieldData()[dd], data.getIndices()[dd]);
619 }
620
621 const EntityHandle fe_ent = OP::getFEEntityHandle();
622 const EntityHandle ent = OP::getSideEntity(side, type);
623 int side_prism, sense, offset;
624 if (type == MBVERTEX) {
625 CHKERR postProc.side_number(prism, fe_ent, side_prism, sense, offset);
626 } else
627 CHKERR postProc.side_number(prism, ent, side_prism, sense, offset);
628
629 if (type == MBVERTEX) {
630 auto &coords_at_pts = OP::getCoordsAtGaussPts();
631 const size_t nb_gauss_pts = coords_at_pts.size1();
632
633 nodeHandles.reserve(nb_gauss_pts);
634 nodeHandles.clear();
635 for (size_t gg = 0; gg != nb_gauss_pts; ++gg) {
636 auto t = boost::make_tuple(CoordsAndHandle::getArg(coords_at_pts(gg, 0)),
637 CoordsAndHandle::getArg(coords_at_pts(gg, 1)),
638 CoordsAndHandle::getArg(coords_at_pts(gg, 2)));
639
640 auto it = mapCoords.find(t);
641 if (it != mapCoords.end())
642 nodeHandles.emplace_back(it->node);
643 else
644 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "Vertex not found");
645 }
646 }
647
648 auto to_str = [](auto i) { return boost::lexical_cast<std::string>(i); };
649 std::string tag_name_base =
650 "FEType" + to_str(OP::getNumeredEntFiniteElementPtr()->getEntType()) +
651 "Type" + to_str(type) + "Side" + to_str(side_prism);
652
653 std::string tag_prism_name_base =
654 "PrismType" + to_str(type) + "Side" + to_str(side_prism);
655
656 MatrixDouble trans_base = trans(data.getN());
657 MatrixDouble prism_base(trans_base.size1(), trans_base.size2());
658 if (trans_base.size2() != nodeHandles.size())
659 SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID, "wrong size %d != %d",
660 trans_base.size2(), nodeHandles.size());
661
662 for (size_t rr = 0; rr != trans_base.size1(); ++rr) {
663
664 std::string tag_name = tag_name_base + "Base";
665 if (type == MBVERTEX) {
666 EntityHandle node = data.getFieldDofs()[rr]->getEnt();
667 int prism_mode_side;
668 CHKERR postProc.side_number(prism, node, prism_mode_side, sense, offset);
669 tag_name += to_str(prism_mode_side);
670 } else {
671 tag_name += to_str(rr);
672 }
673
674 std::cout << tag_name << endl;
675
676 Tag th;
677 CHKERR postProc.tag_get_handle(tag_name.c_str(), 1, MB_TYPE_DOUBLE, th,
678 MB_TAG_CREAT | MB_TAG_DENSE, def_val);
679 CHKERR postProc.tag_set_data(th, &nodeHandles[0], nodeHandles.size(),
680 &trans_base(rr, 0));
681
682 if (type != MBVERTEX) {
683 auto tag_prism_name = tag_prism_name_base + "Base" + to_str(rr);
684 Tag th_prism;
685 CHKERR postProc.tag_get_handle(tag_prism_name.c_str(), th_prism);
686 CHKERR postProc.tag_get_data(th_prism, &nodeHandles[0],
687 nodeHandles.size(), &prism_base(rr, 0));
688 }
689 }
690
691 auto sum_matrix = [](MatrixDouble &m) {
692 double s = 0;
693 for (unsigned int ii = 0; ii < m.size1(); ii++) {
694 for (unsigned int jj = 0; jj < m.size2(); jj++) {
695 s += std::abs(m(ii, jj));
696 }
697 }
698 return s;
699 };
700
701 if (type != MBVERTEX) {
702 prism_base -= trans_base;
703 double sum = sum_matrix(prism_base);
704 constexpr double eps = 1e-6;
705
706 if (std::abs(sum) > eps)
707 cout << "Inconsistent base " << tag_prism_name_base << " "
708 << tag_name_base << " sum " << sum << endl;
709
710 if (std::abs(sum) > eps)
711 SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
712 "Inconsistent base %s sum %6.4e", tag_prism_name_base.c_str(),
713 sum);
714 }
715
717}
static const double eps
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
@ MOFEM_ATOM_TEST_INVALID
Definition: definitions.h:53
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:44
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
#define CHKERR
Inline error check.
Definition: definitions.h:548
static double sum_matrix(MatrixDouble &m)
FTensor::Index< 'i', SPACE_DIM > i
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:88
constexpr double t
plate stiffness
Definition: plate.cpp:76
FTensor::Index< 'm', 3 > m
static double getArg(double x)
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
const VectorDouble & getFieldData() const
get dofs values
const VectorInt & getLocalIndices() const
get local indices of dofs on entity
const VectorDofs & getFieldDofs() const
get dofs data stature FEDofEntity
const VectorInt & getIndices() const
Get global indices of dofs on entity.
std::vector< EntityHandle > nodeHandles

Member Data Documentation

◆ mapCoords

template<typename OP >
MapCoords& Op< OP >::mapCoords

◆ nodeHandles

template<typename OP >
std::vector<EntityHandle> Op< OP >::nodeHandles

◆ postProc

template<typename OP >
moab::Interface& Op< OP >::postProc

◆ prism

template<typename OP >
EntityHandle Op< OP >::prism

The documentation for this struct was generated from the following file: