v0.8.13
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
 
- 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  // cerr << *data.getFieldDofs()[0] << endl;
101  // cerr << data.getFieldData().size() << " " << data.getN().size2() << endl;
102  // cerr << data.getDataOrder() << endl;
103  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
104  "data inconsistency %d!=%d", mapGaussPts.size(), nb_gauss_pts);
105  }
106 
107  switch (space) {
108  case H1:
109  commonData.fieldMap[rowFieldName].resize(nb_gauss_pts);
110  if (type == MBVERTEX) {
111  for (int gg = 0; gg < nb_gauss_pts; gg++) {
112  rval = postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
113  (commonData.fieldMap[rowFieldName])[gg].resize(rank);
114  (commonData.fieldMap[rowFieldName])[gg].clear();
115  }
116  }
117  CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
118  tags_ptr);
119  for (int gg = 0; gg < nb_gauss_pts; gg++) {
120  for (int rr = 0; rr < rank; rr++) {
121  const double val =
122  cblas_ddot((vAluesPtr->size() / rank), &(data.getN(gg)[0]), 1,
123  &((*vAluesPtr)[rr]), rank);
124  (commonData.fieldMap[rowFieldName])[gg][rr] =
125  ((double *)tags_ptr[gg])[rr] += val;
126  }
127  }
128  break;
129  case L2:
130  commonData.fieldMap[rowFieldName].resize(nb_gauss_pts);
131  for (int gg = 0; gg < nb_gauss_pts; gg++) {
132  CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
133  (commonData.fieldMap[rowFieldName])[gg].resize(rank);
134  (commonData.fieldMap[rowFieldName])[gg].clear();
135  }
136  CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
137  tags_ptr);
138  for (int gg = 0; gg < nb_gauss_pts; gg++) {
139  bzero((double *)tags_ptr[gg], sizeof(double) * tag_length);
140  for (int rr = 0; rr < rank; rr++) {
141  const double val =
142  cblas_ddot((vAluesPtr->size() / rank), &(data.getN(gg)[0]), 1,
143  &((*vAluesPtr)[rr]), rank);
144  (commonData.fieldMap[rowFieldName])[gg][rr] =
145  ((double *)tags_ptr[gg])[rr] = val;
146  }
147  }
148  break;
149  case HCURL:
150  // FIXME: fieldMap not set
151  if (type == MBEDGE && side == 0) {
152  for (int gg = 0; gg < nb_gauss_pts; gg++) {
153  CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
154  }
155  }
156  CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
157  tags_ptr);
158  {
160  auto t_n_hcurl = data.getFTensor1HcurlN<3>();
161  for (int gg = 0; gg != nb_gauss_pts; gg++) {
162  double *ptr = &((double *)tags_ptr[gg])[0];
163  int ll = 0;
164  for (; ll != static_cast<int>(vAluesPtr->size() / rank); ll++) {
165  FTensor::Tensor1<double *, 3> t_tag_val(ptr, &ptr[1], &ptr[2], 3);
166  for (int rr = 0; rr != rank; rr++) {
167  const double dof_val = (*vAluesPtr)[ll * rank + rr];
168  t_tag_val(i) += dof_val * t_n_hcurl(i);
169  ++t_tag_val;
170  }
171  ++t_n_hcurl;
172  }
173  for (; ll != static_cast<int>(data.getHcurlN().size2() / 3); ll++) {
174  ++t_n_hcurl;
175  }
176  }
177  }
178  break;
179  case HDIV:
180  // FIXME: fieldMap not set
181  if (type == MBTRI && side == 0) {
182  for (int gg = 0; gg < nb_gauss_pts; gg++) {
183  CHKERR postProcMesh.tag_set_data(th, &mapGaussPts[gg], 1, def_VAL);
184  }
185  }
186  CHKERR postProcMesh.tag_get_by_ptr(th, &mapGaussPts[0], mapGaussPts.size(),
187  tags_ptr);
188  {
190  auto t_n_hdiv = data.getFTensor1HdivN<3>();
191  for (int gg = 0; gg != nb_gauss_pts; gg++) {
192  double *ptr = &((double *)tags_ptr[gg])[0];
193  int ll = 0;
194  for (; ll != static_cast<int>(vAluesPtr->size() / rank); ll++) {
195  FTensor::Tensor1<double *, 3> t_tag_val(ptr, &ptr[1], &ptr[2], 3);
196  for (int rr = 0; rr != rank; rr++) {
197  const double dof_val = (*vAluesPtr)[ll * rank + rr];
198  t_tag_val(i) += dof_val * t_n_hdiv(i);
199  ++t_tag_val;
200  }
201  ++t_n_hdiv;
202  }
203  for (; ll != static_cast<int>(data.getHdivN().size2() / 3); ll++) {
204  ++t_n_hdiv;
205  }
206  }
207  }
208  break;
209  default:
210  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
211  "field with that space is not implemented");
212  }
213 
215 }
std::vector< EntityHandle > & mapGaussPts
field with continuous normal traction
Definition: definitions.h:181
VectorDouble * vAluesPtr
VectorDouble vAlues
moab::Interface & postProcMesh
auto getFTensor1HcurlN(FieldApproximationBase base)
Get base functions for Hcurl space.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:495
const VectorDofs & getFieldDofs() const
get dofs data stature FEDofEntity
FieldCoefficientsNumber getNbOfCoeffs() const
const MatrixDouble & getHcurlN(const FieldApproximationBase base) const
const std::string tagName
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:526
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
FTensor::Tensor1< FTensor::PackPtr< double *, 3 >, Tensor_Dim > getFTensor1HdivN(FieldApproximationBase base)
Get base functions for Hdiv space.
const MatrixDouble & getHdivN(const FieldApproximationBase base) const
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Common.hpp:78
const VectorDouble & getFieldData() const
get dofs values
field with continuous tangents
Definition: definitions.h:180
FieldSpace
approximation spaces
Definition: definitions.h:176
#define CHKERR
Inline error check.
Definition: definitions.h:614
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:439
continuous field
Definition: definitions.h:179
boost::shared_ptr< const FENumeredDofEntity_multiIndex > rowPtr
field with C-1 continuity
Definition: definitions.h:182

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: