v0.14.0
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
PostProcCommonOnRefMesh::OpGetFieldGradientValues 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::OpGetFieldGradientValues:
[legend]
Collaboration diagram for PostProcCommonOnRefMesh::OpGetFieldGradientValues:
[legend]

Public Member Functions

 OpGetFieldGradientValues (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, int space_dim=3)
 
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
 
int spaceDim
 
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:
Implementation for Hdiv and Hcurl to be implemented

Definition at line 81 of file PostProcOnRefMesh.hpp.

Constructor & Destructor Documentation

◆ OpGetFieldGradientValues()

PostProcCommonOnRefMesh::OpGetFieldGradientValues::OpGetFieldGradientValues ( 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,
int  space_dim = 3 
)
inline

Member Function Documentation

◆ doWork()

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

Definition at line 199 of file PostProcOnRefMesh.cpp.

200 {
202
203 if (data.getFieldData().size() == 0)
205 if (V) {
206 vAlues.resize(data.getFieldData().size());
207 double *a;
208 CHKERR VecGetArray(V, &a);
209 VectorDofs::iterator it, hi_it;
210 it = data.getFieldDofs().begin();
211 hi_it = data.getFieldDofs().end();
212 auto row_dofs = getFEMethod()->getRowDofsPtr();
213 for (int ii = 0; it != hi_it; it++, ii++) {
214 int local_idx = row_dofs->find((*it)->getLocalUniqueId())
215 ->get()
216 ->getPetscLocalDofIdx();
217 vAlues[ii] = a[local_idx];
218 }
219 CHKERR VecRestoreArray(V, &a);
220 vAluesPtr = &vAlues;
221 } else {
222 vAluesPtr = &data.getFieldData();
223 }
224
225 auto dof_ptr = data.getFieldDofs()[0];
226 int rank = dof_ptr->getNbOfCoeffs();
227
228 FieldSpace space = dof_ptr->getSpace();
229 int space_dim = spaceDim;
230 if (space == HCURL || space == HDIV)
231 space_dim = 3;
232
233 int tag_length = rank * space_dim;
234 // FieldSpace space = dof_ptr->getSpace();
235 switch (space) {
236 case L2:
237 case H1:
238 break;
239 case HCURL:
240 case HDIV:
241 tag_length *= space_dim;
242 break;
243 default:
244 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
245 "field with that space is not implemented");
246 }
247
248 double def_VAL[tag_length];
249 bzero(def_VAL, tag_length * sizeof(double));
250 Tag th;
251 CHKERR postProcMesh.tag_get_handle(tagName.c_str(), tag_length,
252 MB_TYPE_DOUBLE, th,
253 MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
254
255 // zero tags, this for Vertex if H1 and TRI if Hdiv, EDGE for Hcurl
256 // no need for L2
257 const void *tags_ptr[mapGaussPts.size()];
258 int nb_gauss_pts = data.getN().size1();
259 if (mapGaussPts.size() != (unsigned int)nb_gauss_pts) {
260 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
261 }
262
263 auto set_float_precision = [](const double x) {
264 if (std::abs(x) < std::numeric_limits<float>::epsilon())
265 return 0.;
266 else
267 return x;
268 };
269
270 auto clear_vals = [&]() {
272 for (int gg = 0; gg < nb_gauss_pts; gg++) {
273 (commonData.gradMap[rowFieldName])[gg].resize(rank, space_dim);
274 (commonData.gradMap[rowFieldName])[gg].clear();
275 CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
276 }
278 };
279
280 auto set_vals = [&]() {
282 CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
283 tags_ptr);
284 for (int gg = 0; gg < nb_gauss_pts; gg++) {
285 for (int rr = 0; rr < rank; rr++) {
286 for (int dd = 0; dd < space_dim; dd++) {
287 for (unsigned int dof = 0; dof < (vAluesPtr->size() / rank); dof++) {
288 const double val =
289 data.getDiffN(gg)(dof, dd) * (*vAluesPtr)[rank * dof + rr];
290 (commonData.gradMap[rowFieldName])[gg](rr, dd) += val;
291 }
292 ((double *)tags_ptr[gg])[rank * rr + dd] =
293 (commonData.gradMap[rowFieldName])[gg](rr, dd);
294 }
295 }
296 }
298 };
299
300 commonData.gradMap[rowFieldName].resize(nb_gauss_pts);
301
302 switch (space) {
303 case H1:
304 if (type == MBVERTEX)
305 clear_vals();
306 CHKERR set_vals();
307 break;
308 case L2:
309 clear_vals();
310 CHKERR set_vals();
311 break;
312 default:
313 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
314 "field with that space is not implemented");
315 }
316
318}
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
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
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
MatrixDouble & getDiffN(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 VectorDouble & getFieldData() const
get dofs values
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< MatrixDouble > > gradMap
VectorDouble vAlues
VectorDouble * vAluesPtr

Member Data Documentation

◆ commonData

CommonData& PostProcCommonOnRefMesh::OpGetFieldGradientValues::commonData

Definition at line 86 of file PostProcOnRefMesh.hpp.

◆ mapGaussPts

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

Definition at line 85 of file PostProcOnRefMesh.hpp.

◆ postProcMesh

moab::Interface& PostProcCommonOnRefMesh::OpGetFieldGradientValues::postProcMesh

Definition at line 84 of file PostProcOnRefMesh.hpp.

◆ spaceDim

int PostProcCommonOnRefMesh::OpGetFieldGradientValues::spaceDim

Definition at line 89 of file PostProcOnRefMesh.hpp.

◆ tagName

const std::string PostProcCommonOnRefMesh::OpGetFieldGradientValues::tagName

Definition at line 87 of file PostProcOnRefMesh.hpp.

◆ V

Vec PostProcCommonOnRefMesh::OpGetFieldGradientValues::V

Definition at line 88 of file PostProcOnRefMesh.hpp.

◆ vAlues

VectorDouble PostProcCommonOnRefMesh::OpGetFieldGradientValues::vAlues

Definition at line 103 of file PostProcOnRefMesh.hpp.

◆ vAluesPtr

VectorDouble* PostProcCommonOnRefMesh::OpGetFieldGradientValues::vAluesPtr

Definition at line 104 of file PostProcOnRefMesh.hpp.


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