v0.8.19
Public Member Functions | Public 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 (ApproximationOrder order)
 
void operator() (boost::shared_ptr< FieldEntity > &e)
 
void operator() (FieldEntity *e)
 

Public Attributes

ApproximationOrder order
 
std::vector< FieldDatadata
 
std::vector< ApproximationOrderdata_dof_order
 
std::vector< FieldCoefficientsNumberdata_dof_rank
 

Detailed Description

structure to change FieldEntity order

Definition at line 787 of file EntsMultiIndices.hpp.

Constructor & Destructor Documentation

◆ FieldEntity_change_order()

MoFEM::FieldEntity_change_order::FieldEntity_change_order ( ApproximationOrder  order)

Definition at line 792 of file EntsMultiIndices.hpp.

792 : order(order) {}

Member Function Documentation

◆ operator()() [1/2]

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

Definition at line 793 of file EntsMultiIndices.hpp.

793  {
794  (*this)(e.get());
795  }

◆ operator()() [2/2]

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

Definition at line 220 of file EntsMultiIndices.cpp.

220  {
221 
222  moab::Interface &moab = e->sPtr->basicDataPtr->moab;
223  const EntityHandle ent = e->getEnt();
224  *(e->getMaxOrderPtr()) = order;
225  unsigned int nb_dofs = e->getOrderNbDofs(order) * e->getNbOfCoeffs();
226 
227  double *tag_field_data;
228  int tag_field_data_size;
229 
230  switch (e->getEntType()) {
231  case MBVERTEX: {
232  if (e->sFieldPtr->th_FieldDataVertsType == MB_TAG_SPARSE) {
233  // Get pointer and size of field values tag
234  rval = moab.tag_get_by_ptr(e->sFieldPtr->th_FieldDataVerts, &ent, 1,
235  (const void **)&tag_field_data,
236  &tag_field_data_size);
237  if (nb_dofs) {
238  if (nb_dofs != tag_field_data_size) {
239 
240  rval = moab.tag_set_data(e->sFieldPtr->th_FieldDataVerts, &ent, 1,
241  &*data.begin());
242  MOAB_THROW(rval);
243  }
244  } else if (rval == MB_SUCCESS) {
245  rval = moab.tag_delete_data(e->sFieldPtr->th_FieldDataVerts, &ent, 1);
246  MOAB_THROW(rval);
247  }
248  } else {
249  rval = moab.tag_get_by_ptr(e->sFieldPtr->th_FieldDataVerts, &ent, 1,
250  (const void **)&tag_field_data);
251  MOAB_THROW(rval);
252  rval = moab.tag_set_data(e->sFieldPtr->th_FieldDataVerts, &ent, 1,
253  tag_field_data);
254  MOAB_THROW(rval);
255  }
256  } break;
257  default: {
258  // Get pointer and size of field values tag
259  rval = moab.tag_get_by_ptr(e->sFieldPtr->th_FieldData, &ent, 1,
260  (const void **)&tag_field_data,
261  &tag_field_data_size);
262  // Tag exist and are some data on it
263  if (rval == MB_SUCCESS) {
264  // Check if size of filed values tag is correct
265  if (nb_dofs * sizeof(FieldData) <= (unsigned int)tag_field_data_size)
266  return;
267  else if (nb_dofs == 0) {
268  // Delete data on this entity
269  rval = moab.tag_delete_data(e->sFieldPtr->th_FieldData, &ent, 1);
270  MOAB_THROW(rval);
271  return;
272  }
273  // Size of tag is different than new seize, so copy data to new
274  // container
275  data.resize(tag_field_data_size / sizeof(FieldData));
276  FieldData *ptr_begin = (FieldData *)tag_field_data;
277  FieldData *ptr_end =
278  (FieldData *)tag_field_data + tag_field_data_size / sizeof(FieldData);
279  std::copy(ptr_begin, ptr_end, data.begin());
280  }
281  // Set new data
282  if (nb_dofs > 0) {
283  // Set field dof data
284  data.resize(nb_dofs, 0);
285  int tag_size[1];
286  tag_size[0] = data.size() * sizeof(FieldData);
287  void const *tag_data[] = {&data[0]};
288  rval = moab.tag_set_by_ptr(e->sFieldPtr->th_FieldData, &ent, 1, tag_data,
289  tag_size);
290  MOAB_THROW(rval);
291  rval = moab.tag_get_by_ptr(e->sFieldPtr->th_FieldData, &ent, 1,
292  (const void **)&tag_field_data,
293  &tag_field_data_size);
294  MOAB_THROW(rval);
295  if (nb_dofs != tag_field_data_size / sizeof(FieldData))
296  THROW_MESSAGE("Data inconsistency");
297  }
298  }
299  }
300 }
double FieldData
Field data type.
Definition: Common.hpp:130
#define THROW_MESSAGE(a)
Throw MoFEM exception.
Definition: definitions.h:618
#define MOAB_THROW(a)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:600
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Common.hpp:78
std::vector< FieldData > data

Member Data Documentation

◆ data

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

Definition at line 789 of file EntsMultiIndices.hpp.

◆ data_dof_order

std::vector<ApproximationOrder> MoFEM::FieldEntity_change_order::data_dof_order

Definition at line 790 of file EntsMultiIndices.hpp.

◆ data_dof_rank

std::vector<FieldCoefficientsNumber> MoFEM::FieldEntity_change_order::data_dof_rank

Definition at line 791 of file EntsMultiIndices.hpp.

◆ order

ApproximationOrder MoFEM::FieldEntity_change_order::order

Definition at line 788 of file EntsMultiIndices.hpp.


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