v0.8.17
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, DataForcesAndSourcesCore::EntData &data)
 
- Public Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
 UserDataOperator (const FieldSpace space, const char type=OPLAST, 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)
 
virtual ~UserDataOperator ()
 
boost::shared_ptr< const NumeredEntFiniteElementgetNumeredEntFiniteElementPtr () const
 Return raw pointer to NumeredEntFiniteElement. More...
 
EntityHandle getFEEntityHandle () const
 Return finite element entity handle. More...
 
MoFEMErrorCode getProblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get row indices. More...
 
DEPRECATED MoFEMErrorCode getPorblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 
MoFEMErrorCode getProblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get col indices. More...
 
virtual MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
DEPRECATED MoFEMErrorCode getPorblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 
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...
 
const std::string & getFEName () const
 Get name of the element. More...
 
Vec getSnesF () const
 
Vec getSnesX () const
 
Mat getSnesA () const
 
Mat getSnesB () const
 
Vec getTSu () const
 
Vec getTSu_t () const
 
Vec getTSf () const
 
Mat getTSA () const
 
Mat getTSB () const
 
int getTSstep () const
 
double getTStime () const
 
double getTSa () const
 
MatrixDoublegetGaussPts ()
 matrix of integration (Gauss) points for Volume Element More...
 
auto getFTensor0IntegrationWeight ()
 Get integration weights. More...
 
- Public Member Functions inherited from MoFEM::DataOperator
 DataOperator (const bool symm=true, const bool do_vertices=true, const bool do_edges=true, const bool do_quads=true, const bool do_tris=true, const bool do_tets=true, const bool do_prisms=true)
 
virtual ~DataOperator ()
 
virtual MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
 Operator for bi-linear form, usually to calculate values on right hand side. More...
 
virtual MoFEMErrorCode opLhs (DataForcesAndSourcesCore &row_data, DataForcesAndSourcesCore &col_data, bool symm=true)
 
virtual MoFEMErrorCode opLhs (DataForcesAndSourcesCore &row_data, DataForcesAndSourcesCore &col_data)
 
virtual MoFEMErrorCode doWork (int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
 Operator for linear form, usually to calculate values on left hand side. More...
 
virtual MoFEMErrorCode opRhs (DataForcesAndSourcesCore &data, const bool do_vertices, const bool do_edges, const bool do_quads, const bool do_tris, const bool do_tets, const bool do_prisms, const bool error_if_no_base=true)
 
virtual MoFEMErrorCode opRhs (DataForcesAndSourcesCore &data, const bool error_if_no_base=true)
 
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
bool sYmm
 If true assume that matrix is symmetric structure. More...
 
bool doVertices
 If false skip vertices. More...
 
bool doEdges
 If false skip edges. More...
 
bool doQuads
 
bool doTris
 
bool doTets
 
bool doPrisms
 

Additional Inherited Members

- Public Types inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
enum  OpType { OPROW = 1 << 0, OPCOL = 1 << 1, OPROWCOL = 1 << 2, OPLAST = 1 << 3 }
 Controls loop over entities on element. More...
 
- 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 61 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 
)

Definition at line 70 of file PostProcOnRefMesh.hpp.

75  field_name, UserDataOperator::OPCOL),
76  postProcMesh(post_proc_mesh), mapGaussPts(map_gauss_pts),
77  commonData(common_data), tagName(tag_name), V(v) {}
std::vector< EntityHandle > & mapGaussPts
moab::Interface & postProcMesh
const std::string tagName
Vec V
CommonData & commonData
ForcesAndSourcesCore::UserDataOperator UserDataOperator

Member Function Documentation

◆ doWork()

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

Definition at line 37 of file PostProcOnRefMesh.cpp.

38  {
40 
41  if (data.getFieldData().size() == 0)
43 
44  if (V) {
45  vAlues.resize(data.getFieldData().size());
46  double *a;
47  CHKERR VecGetArray(V, &a);
48  VectorDofs::iterator it, hi_it;
49  it = data.getFieldDofs().begin();
50  hi_it = data.getFieldDofs().end();
51  for (int ii = 0; it != hi_it; it++, ii++) {
52  int local_idx = getFEMethod()
53  ->rowPtr->find((*it)->getGlobalUniqueId())
54  ->get()
55  ->getPetscLocalDofIdx();
56  vAlues[ii] = a[local_idx];
57  }
58  CHKERR VecRestoreArray(V, &a);
59  vAluesPtr = &vAlues;
60  } else {
61  vAluesPtr = &data.getFieldData();
62  }
63 
64  const MoFEM::FEDofEntity *dof_ptr = data.getFieldDofs()[0].get();
65  int rank = dof_ptr->getNbOfCoeffs();
66 
67  int tag_length = rank;
68  FieldSpace space = dof_ptr->getSpace();
69  switch (space) {
70  case L2:
71  case H1:
72  break;
73  case HCURL:
74  case HDIV:
75  tag_length *= 3;
76  break;
77  default:
78  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
79  "field with that space is not implemented");
80  }
81 
82  if (tag_length > 1 && tag_length < 3) {
83  tag_length = 3;
84  } else if (tag_length > 3 && tag_length < 9) {
85  tag_length = 9;
86  }
87 
88  double def_VAL[tag_length];
89  bzero(def_VAL, tag_length * sizeof(double));
90  Tag th;
91  CHKERR postProcMesh.tag_get_handle(tagName.c_str(), tag_length,
92  MB_TYPE_DOUBLE, th,
93  MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
94 
95  // zero tags, this for Vertex if H1 and TRI if Hdiv, EDGE for Hcurl
96  // no need for L2
97  const void *tags_ptr[mapGaussPts.size()];
98  int nb_gauss_pts = data.getN().size1();
99  if (mapGaussPts.size() != (unsigned int)nb_gauss_pts) {
100  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
101  "data inconsistency %d!=%d", mapGaussPts.size(), nb_gauss_pts);
102  }
103 
104  switch (space) {
105  case H1:
106  commonData.fieldMap[rowFieldName].resize(nb_gauss_pts);
107  if (type == MBVERTEX) {
108  for (int gg = 0; gg < nb_gauss_pts; gg++) {
109  rval = postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
110  (commonData.fieldMap[rowFieldName])[gg].resize(rank);
111  (commonData.fieldMap[rowFieldName])[gg].clear();
112  }
113  }
114  CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
115  tags_ptr);
116  for (int gg = 0; gg < nb_gauss_pts; gg++) {
117  for (int rr = 0; rr < rank; rr++) {
118  const double val =
119  cblas_ddot((vAluesPtr->size() / rank), &(data.getN(gg)[0]), 1,
120  &((*vAluesPtr)[rr]), rank);
121  (commonData.fieldMap[rowFieldName])[gg][rr] =
122  ((double *)tags_ptr[gg])[rr] += val;
123  }
124  }
125  break;
126  case L2:
127  commonData.fieldMap[rowFieldName].resize(nb_gauss_pts);
128  for (int gg = 0; gg < nb_gauss_pts; gg++) {
129  CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
130  (commonData.fieldMap[rowFieldName])[gg].resize(rank);
131  (commonData.fieldMap[rowFieldName])[gg].clear();
132  }
133  CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
134  tags_ptr);
135  for (int gg = 0; gg < nb_gauss_pts; gg++) {
136  bzero((double *)tags_ptr[gg], sizeof(double) * tag_length);
137  for (int rr = 0; rr < rank; rr++) {
138  const double val =
139  cblas_ddot((vAluesPtr->size() / rank), &(data.getN(gg)[0]), 1,
140  &((*vAluesPtr)[rr]), rank);
141  (commonData.fieldMap[rowFieldName])[gg][rr] =
142  ((double *)tags_ptr[gg])[rr] = val;
143  }
144  }
145  break;
146  case HCURL:
147  // FIXME: fieldMap not set
148  if (type == MBEDGE && side == 0) {
149  for (int gg = 0; gg < nb_gauss_pts; gg++) {
150  CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
151  }
152  }
153  CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
154  tags_ptr);
155  {
157  auto t_n_hcurl = data.getFTensor1N<3>();
158  for (int gg = 0; gg != nb_gauss_pts; gg++) {
159  double *ptr = &((double *)tags_ptr[gg])[0];
160  int ll = 0;
161  for (; ll != static_cast<int>(vAluesPtr->size() / rank); ll++) {
162  FTensor::Tensor1<double *, 3> t_tag_val(ptr, &ptr[1], &ptr[2], 3);
163  for (int rr = 0; rr != rank; rr++) {
164  const double dof_val = (*vAluesPtr)[ll * rank + rr];
165  t_tag_val(i) += dof_val * t_n_hcurl(i);
166  ++t_tag_val;
167  }
168  ++t_n_hcurl;
169  }
170  for (; ll != static_cast<int>(data.getN().size2() / 3); ll++) {
171  ++t_n_hcurl;
172  }
173  }
174  }
175  break;
176  case HDIV:
177  // FIXME: fieldMap not set
178  if (type == MBTRI && side == 0) {
179  for (int gg = 0; gg < nb_gauss_pts; gg++) {
180  CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
181  }
182  }
183  CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
184  tags_ptr);
185  {
187  auto t_n_hdiv = data.getFTensor1N<3>();
188  for (int gg = 0; gg != nb_gauss_pts; gg++) {
189  double *ptr = &((double *)tags_ptr[gg])[0];
190  int ll = 0;
191  for (; ll != static_cast<int>(vAluesPtr->size() / rank); ll++) {
192  FTensor::Tensor1<double *, 3> t_tag_val(ptr, &ptr[1], &ptr[2], 3);
193  for (int rr = 0; rr != rank; rr++) {
194  const double dof_val = (*vAluesPtr)[ll * rank + rr];
195  t_tag_val(i) += dof_val * t_n_hdiv(i);
196  ++t_tag_val;
197  }
198  ++t_n_hdiv;
199  }
200  for (; ll != static_cast<int>(data.getN().size2() / 3); ll++) {
201  ++t_n_hdiv;
202  }
203  }
204  }
205  break;
206  default:
207  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
208  "field with that space is not implemented");
209  }
210 
212 }
std::vector< EntityHandle > & mapGaussPts
field with continuous normal traction
Definition: definitions.h:170
VectorDouble * vAluesPtr
VectorDouble vAlues
moab::Interface & postProcMesh
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:467
const VectorDofs & getFieldDofs() const
get dofs data stature FEDofEntity
FieldCoefficientsNumber getNbOfCoeffs() const
const std::string tagName
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:498
virtual const MatrixDouble & getN(const FieldApproximationBase base) const
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb. of columns is equal to number of base functions on this entity.
keeps information about indexed dofs for the finite element
double cblas_ddot(const int N, const double *X, const int incX, const double *Y, const int incY)
Definition: cblas_ddot.c:12
Vec V
CommonData & commonData
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
std::map< std::string, std::vector< VectorDouble > > fieldMap
FieldSpace getSpace() const
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Common.hpp:78
const VectorDouble & getFieldData() const
get dofs values
field with continuous tangents
Definition: definitions.h:169
FieldSpace
approximation spaces
Definition: definitions.h:165
#define CHKERR
Inline error check.
Definition: definitions.h:586
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:404
continuous field
Definition: definitions.h:168
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1N(FieldApproximationBase base)
Get base functions for Hdiv/Hcurl spaces.
boost::shared_ptr< const FENumeredDofEntity_multiIndex > rowPtr
field with C-1 continuity
Definition: definitions.h:171

Member Data Documentation

◆ commonData

CommonData& PostProcCommonOnRefMesh::OpGetFieldValues::commonData

Definition at line 66 of file PostProcOnRefMesh.hpp.

◆ mapGaussPts

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

Definition at line 65 of file PostProcOnRefMesh.hpp.

◆ postProcMesh

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

Definition at line 64 of file PostProcOnRefMesh.hpp.

◆ tagName

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

Definition at line 67 of file PostProcOnRefMesh.hpp.

◆ V

Vec PostProcCommonOnRefMesh::OpGetFieldValues::V

Definition at line 68 of file PostProcOnRefMesh.hpp.

◆ vAlues

VectorDouble PostProcCommonOnRefMesh::OpGetFieldValues::vAlues

Definition at line 79 of file PostProcOnRefMesh.hpp.

◆ vAluesPtr

VectorDouble* PostProcCommonOnRefMesh::OpGetFieldValues::vAluesPtr

Definition at line 80 of file PostProcOnRefMesh.hpp.


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