v0.9.0
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 int 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 int  order,
const bool  reduce_tag_size = false 
)

Definition at line 827 of file EntsMultiIndices.hpp.

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

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

◆ operator()() [2/2]

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

Definition at line 197 of file EntsMultiIndices.cpp.

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

Member Data Documentation

◆ data

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

Definition at line 837 of file EntsMultiIndices.hpp.

◆ order

const ApproximationOrder MoFEM::FieldEntity_change_order::order
private

Definition at line 835 of file EntsMultiIndices.hpp.

◆ reduceTagSize

const bool MoFEM::FieldEntity_change_order::reduceTagSize
private

Definition at line 836 of file EntsMultiIndices.hpp.


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