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 825 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 827 of file EntsMultiIndices.hpp.

829  : 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 830 of file EntsMultiIndices.hpp.

830  {
831  (*this)(e.get());
832  }

◆ operator()() [2/2]

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

Definition at line 195 of file EntsMultiIndices.cpp.

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

Member Data Documentation

◆ data

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

Definition at line 838 of file EntsMultiIndices.hpp.

◆ order

const ApproximationOrder MoFEM::FieldEntity_change_order::order
private

Definition at line 836 of file EntsMultiIndices.hpp.

◆ reduceTagSize

const bool MoFEM::FieldEntity_change_order::reduceTagSize
private

Definition at line 837 of file EntsMultiIndices.hpp.


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