v0.5.86
Public Member Functions | Public Attributes | List of all members
PostProcCommonOnRefMesh::OpGetFieldValues Struct Reference

operator to post-process (save gardients 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)
 
PetscErrorCode 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...
 
PetscErrorCode getPorblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get row indices. More...
 
PetscErrorCode getPorblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get col indices. More...
 
virtual PetscErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
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...
 
- 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 PetscErrorCode 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 PetscErrorCode opLhs (DataForcesAndSourcesCore &row_data, DataForcesAndSourcesCore &col_data, bool symm=true)
 
virtual PetscErrorCode opLhs (DataForcesAndSourcesCore &row_data, DataForcesAndSourcesCore &col_data)
 
virtual PetscErrorCode doWork (int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
 Operator for linear form, usually to calculate values on left hand side. More...
 
virtual PetscErrorCode 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 PetscErrorCode 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 gardients on refined post-processing mesh) field gradient

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

Definition at line 56 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 64 of file PostProcOnRefMesh.hpp.

71  :
72  MoFEM::ForcesAndSourcesCore::UserDataOperator(field_name,UserDataOperator::OPCOL),
73  postProcMesh(post_proc_mesh),
74  mapGaussPts(map_gauss_pts),
75  commonData(common_data),
76  tagName(tag_name),
77  V(v) {}
std::vector< EntityHandle > & mapGaussPts
moab::Interface & postProcMesh
const std::string tagName
Vec V
CommonData & commonData
Data operator to do calculations at integration points.Is inherited and implemented by user to do cal...

Member Function Documentation

◆ doWork()

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

Definition at line 38 of file PostProcOnRefMesh.cpp.

42  {
43  PetscFunctionBegin;
44 
45 
46 
47 
48  if(data.getFieldData().size()==0) PetscFunctionReturn(0);
49 
50  if(V) {
51  vAlues.resize(data.getFieldData().size());
52  double *a;
53  ierr = VecGetArray(V,&a); CHKERRQ(ierr);
54  VectorDofs::iterator it,hi_it;
55  it = data.getFieldDofs().begin();
56  hi_it = data.getFieldDofs().end();
57  for(int ii = 0;it!=hi_it;it++,ii++) {
58  int local_idx = getFEMethod()->rowPtr->find((*it)->getGlobalUniqueId())->get()->getPetscLocalDofIdx();
59  vAlues[ii] = a[local_idx];
60  }
61  ierr = VecRestoreArray(V,&a); CHKERRQ(ierr);
62  vAluesPtr = &vAlues;
63  } else {
64  vAluesPtr = &data.getFieldData();
65  }
66 
67  const MoFEM::FEDofEntity *dof_ptr = data.getFieldDofs()[0].get();
68  int rank = dof_ptr->getNbOfCoeffs();
69 
70  int tag_length = rank;
71  FieldSpace space = dof_ptr->getSpace();
72  switch(space) {
73  case L2:
74  case H1:
75  break;
76  case HCURL:
77  case HDIV:
78  tag_length *= 3;
79  break;
80  default:
81  SETERRQ(PETSC_COMM_SELF,MOFEM_NOT_IMPLEMENTED,"field with that space is not implemented");
82  }
83 
84  if(tag_length>1 && tag_length < 3) {
85  tag_length = 3;
86  } else if(tag_length > 3 && tag_length < 9) {
87  tag_length = 9;
88  }
89 
90  double def_VAL[tag_length];
91  bzero(def_VAL,tag_length*sizeof(double));
92  Tag th;
93  rval = postProcMesh.tag_get_handle(
94  tagName.c_str(),tag_length,MB_TYPE_DOUBLE,th,MB_TAG_CREAT|MB_TAG_SPARSE,def_VAL
95  ); CHKERRQ_MOAB(rval);
96 
97  // zero tags, this for Vertex if H1 and TRI if Hdiv, EDGE for Hcurl
98  // no need for L2
99  const void* tags_ptr[mapGaussPts.size()];
100  int nb_gauss_pts = data.getN().size1();
101  if(mapGaussPts.size()!=(unsigned int)nb_gauss_pts) {
102  // cerr << *data.getFieldDofs()[0] << endl;
103  // cerr << data.getFieldData().size() << " " << data.getN().size2() << endl;
104  // cerr << data.getDataOrder() << endl;
105  SETERRQ2(
106  PETSC_COMM_SELF,
108  "data inconsistency %d!=%d",
109  mapGaussPts.size(),nb_gauss_pts
110  );
111  }
112 
113  switch(space) {
114  case H1:
115  commonData.fieldMap[rowFieldName].resize(nb_gauss_pts);
116  if(type == MBVERTEX) {
117  for(int gg = 0;gg<nb_gauss_pts;gg++) {
118  rval = postProcMesh.tag_set_data(th,&mapGaussPts[gg],1,def_VAL); CHKERRQ_MOAB(rval);
119  (commonData.fieldMap[rowFieldName])[gg].resize(rank);
120  (commonData.fieldMap[rowFieldName])[gg].clear();
121  }
122  }
123  rval = postProcMesh.tag_get_by_ptr(th,&mapGaussPts[0],mapGaussPts.size(),tags_ptr); CHKERRQ_MOAB(rval);
124  for(int gg = 0;gg<nb_gauss_pts;gg++) {
125  for(int rr = 0;rr<rank;rr++) {
126  const double val = cblas_ddot(
127  (vAluesPtr->size()/rank),&(data.getN(gg)[0]),1,&((*vAluesPtr)[rr]),rank
128  );
129  (commonData.fieldMap[rowFieldName])[gg][rr] = ((double*)tags_ptr[gg])[rr] += val;
130  }
131  }
132  break;
133  case L2:
134  commonData.fieldMap[rowFieldName].resize(nb_gauss_pts);
135  for(int gg = 0;gg<nb_gauss_pts;gg++) {
136  rval = postProcMesh.tag_set_data(th,&mapGaussPts[gg],1,def_VAL); CHKERRQ_MOAB(rval);
137  (commonData.fieldMap[rowFieldName])[gg].resize(rank);
138  (commonData.fieldMap[rowFieldName])[gg].clear();
139  }
140  rval = postProcMesh.tag_get_by_ptr(
141  th,&mapGaussPts[0],mapGaussPts.size(),tags_ptr
142  ); CHKERRQ_MOAB(rval);
143  for(int gg = 0;gg<nb_gauss_pts;gg++) {
144  bzero((double*)tags_ptr[gg],sizeof(double)*tag_length);
145  for(int rr = 0;rr<rank;rr++) {
146  const double val = cblas_ddot(
147  (vAluesPtr->size()/rank),&(data.getN(gg)[0]),1,&((*vAluesPtr)[rr]),rank
148  );
149  (commonData.fieldMap[rowFieldName])[gg][rr] = ((double*)tags_ptr[gg])[rr] = val;
150  }
151  }
152  break;
153  case HCURL:
154  // FIXME: fieldMap not set
155  if(type == MBEDGE && side == 0) {
156  for(int gg = 0;gg<nb_gauss_pts;gg++) {
157  rval = postProcMesh.tag_set_data(th,&mapGaussPts[gg],1,def_VAL); CHKERRQ_MOAB(rval);
158  }
159  }
160  rval = postProcMesh.tag_get_by_ptr(th,&mapGaussPts[0],mapGaussPts.size(),tags_ptr); CHKERRQ_MOAB(rval);
161  {
163  FTensor::Tensor1<double*,3> t_n_hcurl = data.getFTensor1HcurlN<3>();
164  for(int gg = 0;gg!=nb_gauss_pts;gg++) {
165  double *ptr = &((double*)tags_ptr[gg])[0];
166  int ll = 0;
167  for(;ll!=(vAluesPtr->size()/rank);ll++) {
168  FTensor::Tensor1<double*,3> t_tag_val(ptr,&ptr[1],&ptr[2],3);
169  for(int rr = 0;rr!=rank;rr++) {
170  const double dof_val = (*vAluesPtr)[ll*rank+rr];
171  t_tag_val(i) += dof_val*t_n_hcurl(i);
172  ++t_tag_val;
173  }
174  ++t_n_hcurl;
175  }
176  for(;ll!=data.getHcurlN().size2()/3;ll++) {
177  ++t_n_hcurl;
178  }
179  }
180  }
181  break;
182  case HDIV:
183  // FIXME: fieldMap not set
184  if(type == MBTRI && side == 0) {
185  for(int gg = 0;gg<nb_gauss_pts;gg++) {
186  rval = postProcMesh.tag_set_data(th,&mapGaussPts[gg],1,def_VAL); CHKERRQ_MOAB(rval);
187  }
188  }
189  rval = postProcMesh.tag_get_by_ptr(th,&mapGaussPts[0],mapGaussPts.size(),tags_ptr); CHKERRQ_MOAB(rval);
190  {
192  FTensor::Tensor1<double*,3> t_n_hdiv = data.getFTensor1HdivN<3>();
193  for(int gg = 0;gg!=nb_gauss_pts;gg++) {
194  double *ptr = &((double*)tags_ptr[gg])[0];
195  int ll = 0;
196  for(;ll!=(vAluesPtr->size()/rank);ll++) {
197  FTensor::Tensor1<double*,3> t_tag_val(ptr,&ptr[1],&ptr[2],3);
198  for(int rr = 0;rr!=rank;rr++) {
199  const double dof_val = (*vAluesPtr)[ll*rank+rr];
200  t_tag_val(i) += dof_val*t_n_hdiv(i);
201  ++t_tag_val;
202  }
203  ++t_n_hdiv;
204  }
205  for(;ll!=data.getHdivN().size2()/3;ll++) {
206  ++t_n_hdiv;
207  }
208  }
209  }
210  break;
211  default:
212  SETERRQ(PETSC_COMM_SELF,MOFEM_NOT_IMPLEMENTED,"field with that space is not implemented");
213  }
214 
215  PetscFunctionReturn(0);
216 }
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:362
std::vector< EntityHandle > & mapGaussPts
field with continuous normal traction
Definition: definitions.h:160
VectorDouble * vAluesPtr
static MoABErrorCode rval
Definition: Common.hpp:25
VectorDouble vAlues
moab::Interface & postProcMesh
const VectorDofs & getFieldDofs() const
get dofs data stature FEDofEntity
FieldCoefficientsNumber getNbOfCoeffs() const
const MatrixDouble & getHcurlN(const FieldApproximationBase base) const
const std::string tagName
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
FTensor::Tensor1< double *, Tensor_Dim > getFTensor1HcurlN(FieldApproximationBase base)
Get base functions for Hcurl space.
std::map< std::string, std::vector< VectorDouble > > fieldMap
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.
FieldSpace getSpace() const
const MatrixDouble & getHdivN(const FieldApproximationBase base) const
CHKERRQ(ierr)
const VectorDouble & getFieldData() const
get dofs values
field with continuous tangents
Definition: definitions.h:161
FieldSpace
approximation spaces
Definition: definitions.h:156
FTensor::Tensor1< double *, Tensor_Dim > getFTensor1HdivN(FieldApproximationBase base)
Get base functions for Hdiv space.
continuous field
Definition: definitions.h:159
boost::shared_ptr< const FENumeredDofEntity_multiIndex > rowPtr
field with C-1 continuity
Definition: definitions.h:162

Member Data Documentation

◆ commonData

CommonData& PostProcCommonOnRefMesh::OpGetFieldValues::commonData

Definition at line 60 of file PostProcOnRefMesh.hpp.

◆ mapGaussPts

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

Definition at line 59 of file PostProcOnRefMesh.hpp.

◆ postProcMesh

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

Definition at line 58 of file PostProcOnRefMesh.hpp.

◆ tagName

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

Definition at line 61 of file PostProcOnRefMesh.hpp.

◆ V

Vec PostProcCommonOnRefMesh::OpGetFieldValues::V

Definition at line 62 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: