v0.9.0
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)
 
boost::shared_ptr< const NumeredEntFiniteElementgetNumeredEntFiniteElementPtr () const
 Return raw pointer to NumeredEntFiniteElement. More...
 
EntityHandle getFEEntityHandle () const
 Return finite element entity handle. More...
 
boost::weak_ptr< SideNumber > getSideNumberPtr (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 ()
 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...
 
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...
 
DEPRECATED MoFEMErrorCode getPorblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) 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 left 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 right 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 Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
ForcesAndSourcesCoregetPtrFE () const
 
ForcesAndSourcesCoregetSidePtrFE () const
 
- 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

Member Function Documentation

◆ doWork()

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

Definition at line 29 of file PostProcOnRefMesh.cpp.

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

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: