v0.14.0
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
PostProcCommonOnRefMesh::OpGetFieldValues Struct Reference

operator to post-process (save gradients on refined post-processing mesh) field gradient More...

#include <users_modules/basic_finite_elements/src/PostProcOnRefMesh.hpp>

Inheritance diagram for PostProcCommonOnRefMesh::OpGetFieldValues:
[legend]
Collaboration diagram for PostProcCommonOnRefMesh::OpGetFieldValues:
[legend]

Public Member Functions

 OpGetFieldValues (moab::Interface &post_proc_mesh, std::vector< EntityHandle > &map_gauss_pts, const std::string field_name, const std::string tag_name, CommonData &common_data, Vec v=PETSC_NULL)
 
MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 
- Public Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
 UserDataOperator (const FieldSpace space, const char type=OPSPACE, const bool symm=true)
 
 UserDataOperator (const std::string field_name, const char type, const bool symm=true)
 
 UserDataOperator (const std::string row_field_name, const std::string col_field_name, const char type, const bool symm=true)
 
boost::shared_ptr< const NumeredEntFiniteElementgetNumeredEntFiniteElementPtr () const
 Return raw pointer to NumeredEntFiniteElement. More...
 
EntityHandle getFEEntityHandle () const
 Return finite element entity handle. More...
 
int getFEDim () const
 Get dimension of finite element. More...
 
EntityType getFEType () const
 Get dimension of finite element. More...
 
boost::weak_ptr< SideNumbergetSideNumberPtr (const int side_number, const EntityType type)
 Get the side number pointer. More...
 
EntityHandle getSideEntity (const int side_number, const EntityType type)
 Get the side entity. More...
 
int getNumberOfNodesOnElement () const
 Get the number of nodes on finite element. More...
 
MoFEMErrorCode getProblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get row indices. More...
 
MoFEMErrorCode getProblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get col indices. More...
 
const FEMethodgetFEMethod () const
 Return raw pointer to Finite Element Method object. More...
 
int getOpType () const
 Get operator types. More...
 
void setOpType (const OpType type)
 Set operator type. More...
 
void addOpType (const OpType type)
 Add operator type. More...
 
int getNinTheLoop () const
 get number of finite element in the loop More...
 
int getLoopSize () const
 get size of elements in the loop More...
 
std::string getFEName () const
 Get name of the element. More...
 
ForcesAndSourcesCoregetPtrFE () const
 
ForcesAndSourcesCoregetSidePtrFE () const
 
ForcesAndSourcesCoregetRefinePtrFE () const
 
const PetscData::SwitchesgetDataCtx () const
 
const KspMethod::KSPContext getKSPCtx () const
 
const SnesMethod::SNESContext getSNESCtx () const
 
const TSMethod::TSContext getTSCtx () const
 
Vec getKSPf () const
 
Mat getKSPA () const
 
Mat getKSPB () const
 
Vec getSNESf () const
 
Vec getSNESx () const
 
Mat getSNESA () const
 
Mat getSNESB () const
 
Vec getTSu () const
 
Vec getTSu_t () const
 
Vec getTSu_tt () const
 
Vec getTSf () const
 
Mat getTSA () const
 
Mat getTSB () const
 
int getTSstep () const
 
double getTStime () const
 
double getTStimeStep () const
 
double getTSa () const
 
double getTSaa () const
 
MatrixDoublegetGaussPts ()
 matrix of integration (Gauss) points for Volume Element More...
 
auto getFTensor0IntegrationWeight ()
 Get integration weights. More...
 
MatrixDoublegetCoordsAtGaussPts ()
 Gauss points and weight, matrix (nb. of points x 3) More...
 
auto getFTensor1CoordsAtGaussPts ()
 Get coordinates at integration points assuming linear geometry. More...
 
double getMeasure () const
 get measure of element More...
 
doublegetMeasure ()
 get measure of element More...
 
MoFEMErrorCode loopSide (const string &fe_name, ForcesAndSourcesCore *side_fe, const size_t dim, const EntityHandle ent_for_side=0, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy, AdjCache *adj_cache=nullptr)
 User calls this function to loop over elements on the side of face. This function calls finite element with its operator to do calculations. More...
 
MoFEMErrorCode loopThis (const string &fe_name, ForcesAndSourcesCore *this_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over the same element using a different set of integration points. This function calls finite element with its operator to do calculations. More...
 
MoFEMErrorCode loopParent (const string &fe_name, ForcesAndSourcesCore *parent_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations. More...
 
MoFEMErrorCode loopChildren (const string &fe_name, ForcesAndSourcesCore *child_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations. More...
 
- Public Member Functions inherited from MoFEM::DataOperator
 DataOperator (const bool symm=true)
 
virtual ~DataOperator ()=default
 
virtual MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Operator for bi-linear form, usually to calculate values on left hand side. More...
 
virtual MoFEMErrorCode opLhs (EntitiesFieldData &row_data, EntitiesFieldData &col_data)
 
virtual MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 Operator for linear form, usually to calculate values on right hand side. More...
 
virtual MoFEMErrorCode opRhs (EntitiesFieldData &data, const bool error_if_no_base=false)
 
bool getSymm () const
 Get if operator uses symmetry of DOFs or not. More...
 
void setSymm ()
 set if operator is executed taking in account symmetry More...
 
void unSetSymm ()
 unset if operator is executed for non symmetric problem More...
 

Public Attributes

moab::Interface & postProcMesh
 
std::vector< EntityHandle > & mapGaussPts
 
CommonDatacommonData
 
const std::string tagName
 
Vec V
 
VectorDouble vAlues
 
VectorDouble * vAluesPtr
 
- Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
char opType
 
std::string rowFieldName
 
std::string colFieldName
 
FieldSpace sPace
 
- Public Attributes inherited from MoFEM::DataOperator
DoWorkLhsHookFunType doWorkLhsHook
 
DoWorkRhsHookFunType doWorkRhsHook
 
bool sYmm
 If true assume that matrix is symmetric structure. More...
 
std::array< bool, MBMAXTYPE > doEntities
 If true operator is executed for entity. More...
 
booldoVertices
 \deprectaed If false skip vertices More...
 
booldoEdges
 \deprectaed If false skip edges More...
 
booldoQuads
 \deprectaed More...
 
booldoTris
 \deprectaed More...
 
booldoTets
 \deprectaed More...
 
booldoPrisms
 \deprectaed More...
 

Additional Inherited Members

- Public Types inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
enum  OpType {
  OPROW = 1 << 0 , OPCOL = 1 << 1 , OPROWCOL = 1 << 2 , OPSPACE = 1 << 3 ,
  OPLAST = 1 << 3
}
 Controls loop over entities on element. More...
 
using AdjCache = std::map< EntityHandle, std::vector< boost::weak_ptr< NumeredEntFiniteElement > > >
 
- Public Types inherited from MoFEM::DataOperator
using DoWorkLhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)>
 
using DoWorkRhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int side, EntityType type, EntitiesFieldData::EntData &data)>
 
- Static Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
static const char *const OpTypeNames []
 
- Protected Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
virtual MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
- Protected Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoreptrFE
 

Detailed Description

operator to post-process (save gradients on refined post-processing mesh) field gradient

Todo:
Implamentation of setting values to fieldMap for Hcurl and Hdiv not implemented

Definition at line 49 of file PostProcOnRefMesh.hpp.

Constructor & Destructor Documentation

◆ OpGetFieldValues()

PostProcCommonOnRefMesh::OpGetFieldValues::OpGetFieldValues ( moab::Interface &  post_proc_mesh,
std::vector< EntityHandle > &  map_gauss_pts,
const std::string  field_name,
const std::string  tag_name,
CommonData common_data,
Vec  v = PETSC_NULL 
)
inline

Definition at line 58 of file PostProcOnRefMesh.hpp.

63 field_name, UserDataOperator::OPCOL),
64 postProcMesh(post_proc_mesh), mapGaussPts(map_gauss_pts),
65 commonData(common_data), tagName(tag_name), V(v) {}
const double v
phase velocity of light in medium (cm/ns)
constexpr auto field_name
const std::string tagName
std::vector< EntityHandle > & mapGaussPts
moab::Interface & postProcMesh
Vec V
CommonData & commonData

Member Function Documentation

◆ doWork()

MoFEMErrorCode PostProcCommonOnRefMesh::OpGetFieldValues::doWork ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)

Definition at line 16 of file PostProcOnRefMesh.cpp.

17 {
19
20 if (data.getFieldData().size() == 0)
22
23 if (V) {
24 vAlues.resize(data.getFieldData().size());
25 double *a;
26 CHKERR VecGetArray(V, &a);
27 VectorDofs::iterator it, hi_it;
28 it = data.getFieldDofs().begin();
29 hi_it = data.getFieldDofs().end();
30 auto row_dofs = getFEMethod()->getRowDofsPtr();
31 for (int ii = 0; it != hi_it; it++, ii++) {
32 int local_idx = row_dofs->find((*it)->getLocalUniqueId())
33 ->get()
34 ->getPetscLocalDofIdx();
35 vAlues[ii] = a[local_idx];
36 }
37 CHKERR VecRestoreArray(V, &a);
39 } else {
40 vAluesPtr = &data.getFieldData();
41 }
42
43 auto dof_ptr = data.getFieldDofs()[0];
44 int rank = dof_ptr->getNbOfCoeffs();
45
46 int tag_length = rank;
47 FieldSpace space = dof_ptr->getSpace();
48 switch (space) {
49 case L2:
50 case H1:
51 break;
52 case HCURL:
53 case HDIV:
54 tag_length *= 3;
55 break;
56 default:
57 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
58 "field with that space is not implemented");
59 }
60
61 if (tag_length > 1 && tag_length < 3)
62 tag_length = 3;
63 else if (tag_length > 3 && tag_length < 9)
64 tag_length = 9;
65
66 double def_VAL[tag_length];
67 bzero(def_VAL, tag_length * sizeof(double));
68 Tag th;
69 CHKERR postProcMesh.tag_get_handle(tagName.c_str(), tag_length,
70 MB_TYPE_DOUBLE, th,
71 MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
72
73 // zero tags, this for Vertex if H1 and TRI if Hdiv, EDGE for Hcurl
74 // no need for L2
75 const void *tags_ptr[mapGaussPts.size()];
76 int nb_gauss_pts = data.getN().size1();
77 if (mapGaussPts.size() != (unsigned int)nb_gauss_pts) {
78 SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
79 "data inconsistency %d!=%d", mapGaussPts.size(), nb_gauss_pts);
80 }
81
82 auto set_float_precision = [](const double x) {
83 if (std::abs(x) < std::numeric_limits<float>::epsilon())
84 return 0.;
85 else
86 return x;
87 };
88
89 switch (space) {
90 case H1:
91 commonData.fieldMap[rowFieldName].resize(nb_gauss_pts);
92 if (type == MBVERTEX) {
93 for (int gg = 0; gg < nb_gauss_pts; gg++) {
94 rval = postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
95 (commonData.fieldMap[rowFieldName])[gg].resize(rank);
96 (commonData.fieldMap[rowFieldName])[gg].clear();
97 }
98 }
99 CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
100 tags_ptr);
101 for (int gg = 0; gg < nb_gauss_pts; gg++) {
102 for (int rr = 0; rr < rank; rr++) {
103 const double val =
104 cblas_ddot((vAluesPtr->size() / rank), &(data.getN(gg)[0]), 1,
105 &((*vAluesPtr)[rr]), rank);
106 (commonData.fieldMap[rowFieldName])[gg][rr] =
107 ((double *)tags_ptr[gg])[rr] += set_float_precision(val);
108 }
109 }
110 break;
111 case L2:
112 commonData.fieldMap[rowFieldName].resize(nb_gauss_pts);
113 for (int gg = 0; gg < nb_gauss_pts; gg++) {
114 CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
115 (commonData.fieldMap[rowFieldName])[gg].resize(rank);
116 (commonData.fieldMap[rowFieldName])[gg].clear();
117 }
118 CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
119 tags_ptr);
120 for (int gg = 0; gg < nb_gauss_pts; gg++) {
121 bzero((double *)tags_ptr[gg], sizeof(double) * tag_length);
122 for (int rr = 0; rr < rank; rr++) {
123 const double val =
124 cblas_ddot((vAluesPtr->size() / rank), &(data.getN(gg)[0]), 1,
125 &((*vAluesPtr)[rr]), rank);
126 (commonData.fieldMap[rowFieldName])[gg][rr] =
127 ((double *)tags_ptr[gg])[rr] = set_float_precision(val);
128 }
129 }
130 break;
131 case HCURL:
132 // FIXME: fieldMap not set
133 if (type == MBEDGE && side == 0) {
134 for (int gg = 0; gg < nb_gauss_pts; gg++) {
135 CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
136 }
137 }
138 CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
139 tags_ptr);
140 {
142 auto t_n_hcurl = data.getFTensor1N<3>();
143 for (int gg = 0; gg != nb_gauss_pts; gg++) {
144 double *ptr = &((double *)tags_ptr[gg])[0];
145 int ll = 0;
146 for (; ll != static_cast<int>(vAluesPtr->size() / rank); ll++) {
147 FTensor::Tensor1<double *, 3> t_tag_val(ptr, &ptr[1], &ptr[2], 3);
148 for (int rr = 0; rr != rank; rr++) {
149 const double dof_val = (*vAluesPtr)[ll * rank + rr];
150 t_tag_val(i) += set_float_precision(dof_val) * t_n_hcurl(i);
151 ++t_tag_val;
152 }
153 ++t_n_hcurl;
154 }
155 for (; ll != static_cast<int>(data.getN().size2() / 3); ll++) {
156 ++t_n_hcurl;
157 }
158 }
159 }
160 break;
161 case HDIV:
162 // FIXME: fieldMap not set
163 if (moab::CN::Dimension(type) == 2 && side == 0) {
164 for (int gg = 0; gg < nb_gauss_pts; gg++) {
165 CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
166 }
167 }
168 CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
169 tags_ptr);
170 {
172 auto t_n_hdiv = data.getFTensor1N<3>();
173 for (int gg = 0; gg != nb_gauss_pts; gg++) {
174 double *ptr = &((double *)tags_ptr[gg])[0];
175 int ll = 0;
176 for (; ll != static_cast<int>(vAluesPtr->size() / rank); ll++) {
177 FTensor::Tensor1<double *, 3> t_tag_val(ptr, &ptr[1], &ptr[2], 3);
178 for (int rr = 0; rr != rank; rr++) {
179 const double dof_val = (*vAluesPtr)[ll * rank + rr];
180 t_tag_val(i) += set_float_precision(dof_val) * t_n_hdiv(i);
181 ++t_tag_val;
182 }
183 ++t_n_hdiv;
184 }
185 for (; ll != static_cast<int>(data.getN().size2() / 3); ll++) {
186 ++t_n_hdiv;
187 }
188 }
189 }
190 break;
191 default:
192 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
193 "field with that space is not implemented");
194 }
195
197}
constexpr double a
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
FieldSpace
approximation spaces
Definition: definitions.h:82
@ L2
field with C-1 continuity
Definition: definitions.h:88
@ H1
continuous field
Definition: definitions.h:85
@ HCURL
field with continuous tangents
Definition: definitions.h:86
@ HDIV
field with continuous normal traction
Definition: definitions.h:87
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
#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
FTensor::Index< 'i', SPACE_DIM > i
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:74
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
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1N(FieldApproximationBase base)
Get base functions for Hdiv/Hcurl spaces.
const VectorDofs & getFieldDofs() const
get dofs data stature FEDofEntity
auto getRowDofsPtr() const
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
std::map< std::string, std::vector< VectorDouble > > fieldMap
VectorDouble vAlues
VectorDouble * vAluesPtr

Member Data Documentation

◆ commonData

CommonData& PostProcCommonOnRefMesh::OpGetFieldValues::commonData

Definition at line 54 of file PostProcOnRefMesh.hpp.

◆ mapGaussPts

std::vector<EntityHandle>& PostProcCommonOnRefMesh::OpGetFieldValues::mapGaussPts

Definition at line 53 of file PostProcOnRefMesh.hpp.

◆ postProcMesh

moab::Interface& PostProcCommonOnRefMesh::OpGetFieldValues::postProcMesh

Definition at line 52 of file PostProcOnRefMesh.hpp.

◆ tagName

const std::string PostProcCommonOnRefMesh::OpGetFieldValues::tagName

Definition at line 55 of file PostProcOnRefMesh.hpp.

◆ V

Vec PostProcCommonOnRefMesh::OpGetFieldValues::V

Definition at line 56 of file PostProcOnRefMesh.hpp.

◆ vAlues

VectorDouble PostProcCommonOnRefMesh::OpGetFieldValues::vAlues

Definition at line 67 of file PostProcOnRefMesh.hpp.

◆ vAluesPtr

VectorDouble* PostProcCommonOnRefMesh::OpGetFieldValues::vAluesPtr

Definition at line 68 of file PostProcOnRefMesh.hpp.


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