v0.9.1
Public Member Functions | Private Attributes | List of all members
MoFEM::FieldEntity_change_order Struct Reference

structure to change FieldEntity order More...

#include <src/multi_indices/EntsMultiIndices.hpp>

Collaboration diagram for MoFEM::FieldEntity_change_order:
[legend]

Public Member Functions

 FieldEntity_change_order (const ApproximationOrder order, const bool reduce_tag_size=false)
 
void operator() (boost::shared_ptr< FieldEntity > &e)
 
void operator() (FieldEntity *e)
 

Private Attributes

const ApproximationOrder order
 
const bool reduceTagSize
 
std::vector< FieldDatadata
 

Detailed Description

structure to change FieldEntity order

Definition at line 820 of file EntsMultiIndices.hpp.

Constructor & Destructor Documentation

◆ FieldEntity_change_order()

MoFEM::FieldEntity_change_order::FieldEntity_change_order ( const ApproximationOrder  order,
const bool  reduce_tag_size = false 
)

Definition at line 822 of file EntsMultiIndices.hpp.

824  : order(order), reduceTagSize(reduce_tag_size) {}
const ApproximationOrder order

Member Function Documentation

◆ operator()() [1/2]

void MoFEM::FieldEntity_change_order::operator() ( boost::shared_ptr< FieldEntity > &  e)

Definition at line 825 of file EntsMultiIndices.hpp.

825  {
826  (*this)(e.get());
827  }

◆ operator()() [2/2]

void MoFEM::FieldEntity_change_order::operator() ( FieldEntity e)

Definition at line 196 of file EntsMultiIndices.cpp.

196  {
197 
198  moab::Interface &moab = e->sPtr->basicDataPtr->moab;
199  const EntityHandle ent = e->getEnt();
200  *const_cast<ApproximationOrder *>(e->getMaxOrderPtr()) = order;
201  std::size_t nb_dofs = e->getOrderNbDofs(order) * e->getNbOfCoeffs();
202 
203  double *tag_field_data = nullptr;
204  int tag_field_data_size = 0;
205 
206  auto set_verts = [&]() {
207  if (e->sFieldPtr->th_FieldDataVertsType == MB_TAG_SPARSE) {
208  // Get pointer and size of field values tag
209  rval = moab.tag_get_by_ptr(e->sFieldPtr->th_FieldDataVerts, &ent, 1,
210  (const void **)&tag_field_data,
211  &tag_field_data_size);
212  if (nb_dofs) {
213  if (nb_dofs != tag_field_data_size) {
214  rval = moab.tag_set_data(e->sFieldPtr->th_FieldDataVerts, &ent, 1,
215  &*data.begin());
216  MOAB_THROW(rval);
217  }
218  } else if (rval == MB_SUCCESS) {
219  rval = moab.tag_delete_data(e->sFieldPtr->th_FieldDataVerts, &ent, 1);
220  MOAB_THROW(rval);
221  }
222  } else {
223  rval = moab.tag_get_by_ptr(e->sFieldPtr->th_FieldDataVerts, &ent, 1,
224  (const void **)&tag_field_data);
225  MOAB_THROW(rval);
226  rval = moab.tag_set_data(e->sFieldPtr->th_FieldDataVerts, &ent, 1,
227  tag_field_data);
228  MOAB_THROW(rval);
229  }
230  };
231 
232  auto set_default = [&]() {
233  if (reduceTagSize || nb_dofs) {
234 
235  // Get pointer and size of field values tag
236  rval = moab.tag_get_by_ptr(e->sFieldPtr->th_FieldData, &ent, 1,
237  (const void **)&tag_field_data,
238  &tag_field_data_size);
239 
240  if ((reduceTagSize && nb_dofs != tag_field_data_size) ||
241  nb_dofs > tag_field_data_size) {
242 
243  // Tag exist and are some data on it
244  if (rval == MB_SUCCESS) {
245  // Size of tag is different than new size, so copy data to new
246  // container
247  data.resize(tag_field_data_size);
248  FieldData *ptr_begin = static_cast<FieldData *>(tag_field_data);
249  FieldData *ptr_end =
250  static_cast<FieldData *>(tag_field_data) + tag_field_data_size;
251  std::copy(ptr_begin, ptr_end, data.begin());
252  }
253 
254  if (rval != MB_SUCCESS || nb_dofs) {
255 
256  // Set field dof data
257  data.resize(nb_dofs, 0);
258  int tag_size[1];
259  tag_size[0] = data.size();
260  void const *tag_data[] = {&data[0]};
261  rval = moab.tag_set_by_ptr(e->sFieldPtr->th_FieldData, &ent, 1,
262  tag_data, tag_size);
263  MOAB_THROW(rval);
264  rval = moab.tag_get_by_ptr(e->sFieldPtr->th_FieldData, &ent, 1,
265  (const void **)&tag_field_data,
266  &tag_field_data_size);
267  MOAB_THROW(rval);
268 
269  } else {
270 
271  rval = moab.tag_delete_data(e->sFieldPtr->th_FieldData, &ent, 1);
272  MOAB_THROW(rval);
273  }
274  }
275  }
276  };
277 
278  switch (e->getEntType()) {
279  case MBVERTEX:
280  set_verts();
281  break;
282  default:
283  set_default();
284  }
285 
286  if (nb_dofs)
287  const_cast<double *&>(*(e->getEntFieldDataPtr())) = tag_field_data;
288  else
289  const_cast<double *&>(*(e->getEntFieldDataPtr())) = nullptr;
290 }
#define MOAB_THROW(a)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:607
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:84
double FieldData
Field data type.
Definition: Types.hpp:36
const ApproximationOrder order
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1791
std::vector< FieldData > data

Member Data Documentation

◆ data

std::vector<FieldData> MoFEM::FieldEntity_change_order::data
private

Definition at line 833 of file EntsMultiIndices.hpp.

◆ order

const ApproximationOrder MoFEM::FieldEntity_change_order::order
private

Definition at line 831 of file EntsMultiIndices.hpp.

◆ reduceTagSize

const bool MoFEM::FieldEntity_change_order::reduceTagSize
private

Definition at line 832 of file EntsMultiIndices.hpp.


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