v0.13.2
Loading...
Searching...
No Matches
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< EntityHandlenodeHandles
 

Detailed Description

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

Definition at line 78 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
prism_elements_from_surface.cpp.

Definition at line 578 of file prism_elements_from_surface.cpp.

580 : OP("FIELD1", "FIELD1", ForcesAndSourcesCore::UserDataOperator::OPROW),
581 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 584 of file prism_elements_from_surface.cpp.

585 {
586 constexpr double def_val[] = {0, 0, 0};
588 switch (type) {
589 case MBVERTEX:
590 case MBEDGE:
591 case MBTRI:
592 case MBQUAD:
593 break;
594 default:
596 }
597
598 const int nb_dofs = data.getIndices().size();
599 for (int dd = 0; dd != nb_dofs; ++dd)
600 if (data.getFieldData()[dd] != data.getIndices()[dd]) {
601 std::cerr << "Indices: " << data.getIndices() << std::endl;
602 std::cerr << "Local indices: " << data.getLocalIndices() << std::endl;
603 std::cerr << "Data: " << data.getFieldData() << std::endl;
604 SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
605 "Indicices/data inconsistency %3.1f != %d",
606 data.getFieldData()[dd], data.getIndices()[dd]);
607 }
608
609 const EntityHandle fe_ent = OP::getFEEntityHandle();
610 const EntityHandle ent = OP::getSideEntity(side, type);
611 int side_prism, sense, offset;
612 if (type == MBVERTEX) {
613 CHKERR postProc.side_number(prism, fe_ent, side_prism, sense, offset);
614 } else
615 CHKERR postProc.side_number(prism, ent, side_prism, sense, offset);
616
617 if (type == MBVERTEX) {
618 auto &coords_at_pts = OP::getCoordsAtGaussPts();
619 const size_t nb_gauss_pts = coords_at_pts.size1();
620
621 nodeHandles.reserve(nb_gauss_pts);
622 nodeHandles.clear();
623 for (size_t gg = 0; gg != nb_gauss_pts; ++gg) {
624 auto t = boost::make_tuple(CoordsAndHandle::getArg(coords_at_pts(gg, 0)),
625 CoordsAndHandle::getArg(coords_at_pts(gg, 1)),
626 CoordsAndHandle::getArg(coords_at_pts(gg, 2)));
627
628 auto it = mapCoords.find(t);
629 if (it != mapCoords.end())
630 nodeHandles.emplace_back(it->node);
631 else
632 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "Vertex not found");
633 }
634 }
635
636 auto to_str = [](auto i) { return boost::lexical_cast<std::string>(i); };
637 std::string tag_name_base =
638 "FEType" + to_str(OP::getNumeredEntFiniteElementPtr()->getEntType()) +
639 "Type" + to_str(type) + "Side" + to_str(side_prism);
640
641 std::string tag_prism_name_base =
642 "PrismType" + to_str(type) + "Side" + to_str(side_prism);
643
644 MatrixDouble trans_base = trans(data.getN());
645 MatrixDouble prism_base(trans_base.size1(), trans_base.size2());
646 if (trans_base.size2() != nodeHandles.size())
647 SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID, "wrong size %d != %d",
648 trans_base.size2(), nodeHandles.size());
649
650 for (size_t rr = 0; rr != trans_base.size1(); ++rr) {
651
652 std::string tag_name = tag_name_base + "Base";
653 if (type == MBVERTEX) {
654 EntityHandle node = data.getFieldDofs()[rr]->getEnt();
655 int prism_mode_side;
656 CHKERR postProc.side_number(prism, node, prism_mode_side, sense, offset);
657 tag_name += to_str(prism_mode_side);
658 } else {
659 tag_name += to_str(rr);
660 }
661
662 std::cout << tag_name << endl;
663
664 Tag th;
665 CHKERR postProc.tag_get_handle(tag_name.c_str(), 1, MB_TYPE_DOUBLE, th,
666 MB_TAG_CREAT | MB_TAG_DENSE, def_val);
667 CHKERR postProc.tag_set_data(th, &nodeHandles[0], nodeHandles.size(),
668 &trans_base(rr, 0));
669
670 if (type != MBVERTEX) {
671 auto tag_prism_name = tag_prism_name_base + "Base" + to_str(rr);
672 Tag th_prism;
673 CHKERR postProc.tag_get_handle(tag_prism_name.c_str(), th_prism);
674 CHKERR postProc.tag_get_data(th_prism, &nodeHandles[0],
675 nodeHandles.size(), &prism_base(rr, 0));
676 }
677 }
678
679 auto sum_matrix = [](MatrixDouble &m) {
680 double s = 0;
681 for (unsigned int ii = 0; ii < m.size1(); ii++) {
682 for (unsigned int jj = 0; jj < m.size2(); jj++) {
683 s += std::abs(m(ii, jj));
684 }
685 }
686 return s;
687 };
688
689 if (type != MBVERTEX) {
690 prism_base -= trans_base;
691 double sum = sum_matrix(prism_base);
692 constexpr double eps = 1e-6;
693
694 if (std::abs(sum) > eps)
695 cout << "Inconsistent base " << tag_prism_name_base << " "
696 << tag_name_base << " sum " << sum << endl;
697
698 if (std::abs(sum) > eps)
699 SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
700 "Inconsistent base %s sum %6.4e", tag_prism_name_base.c_str(),
701 sum);
702 }
703
705}
static const double eps
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ MOFEM_ATOM_TEST_INVALID
Definition: definitions.h:40
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
static double sum_matrix(MatrixDouble &m)
FTensor::Index< 'm', SPACE_DIM > 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
constexpr double t
plate stiffness
Definition: plate.cpp:59
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: