v0.8.20
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 205 of file EntsMultiIndices.cpp.

205  {
206 
207  moab::Interface &moab = e->sPtr->basicDataPtr->moab;
208  const EntityHandle ent = e->getEnt();
209  *(e->getMaxOrderPtr()) = order;
210  unsigned int nb_dofs = e->getOrderNbDofs(order) * e->getNbOfCoeffs();
211 
212  double *tag_field_data;
213  int tag_field_data_size;
214 
215  switch (e->getEntType()) {
216  case MBVERTEX: {
217  if (e->sFieldPtr->th_FieldDataVertsType == MB_TAG_SPARSE) {
218  // Get pointer and size of field values tag
219  rval = moab.tag_get_by_ptr(e->sFieldPtr->th_FieldDataVerts, &ent, 1,
220  (const void **)&tag_field_data,
221  &tag_field_data_size);
222  if (nb_dofs) {
223  if (nb_dofs != tag_field_data_size) {
224 
225  rval = moab.tag_set_data(e->sFieldPtr->th_FieldDataVerts, &ent, 1,
226  &*data.begin());
227  MOAB_THROW(rval);
228  }
229  } else if (rval == MB_SUCCESS) {
230  rval = moab.tag_delete_data(e->sFieldPtr->th_FieldDataVerts, &ent, 1);
231  MOAB_THROW(rval);
232  }
233  } else {
234  rval = moab.tag_get_by_ptr(e->sFieldPtr->th_FieldDataVerts, &ent, 1,
235  (const void **)&tag_field_data);
236  MOAB_THROW(rval);
237  rval = moab.tag_set_data(e->sFieldPtr->th_FieldDataVerts, &ent, 1,
238  tag_field_data);
239  MOAB_THROW(rval);
240  }
241  } break;
242  default: {
243  // Get pointer and size of field values tag
244  rval = moab.tag_get_by_ptr(e->sFieldPtr->th_FieldData, &ent, 1,
245  (const void **)&tag_field_data,
246  &tag_field_data_size);
247  // Tag exist and are some data on it
248  if (rval == MB_SUCCESS) {
249  // Check if size of filed values tag is correct
250  if (nb_dofs * sizeof(FieldData) <= (unsigned int)tag_field_data_size)
251  return;
252  else if (nb_dofs == 0) {
253  // Delete data on this entity
254  rval = moab.tag_delete_data(e->sFieldPtr->th_FieldData, &ent, 1);
255  MOAB_THROW(rval);
256  return;
257  }
258  // Size of tag is different than new seize, so copy data to new
259  // container
260  data.resize(tag_field_data_size / sizeof(FieldData));
261  FieldData *ptr_begin = (FieldData *)tag_field_data;
262  FieldData *ptr_end =
263  (FieldData *)tag_field_data + tag_field_data_size / sizeof(FieldData);
264  std::copy(ptr_begin, ptr_end, data.begin());
265  }
266  // Set new data
267  if (nb_dofs > 0) {
268  // Set field dof data
269  data.resize(nb_dofs, 0);
270  int tag_size[1];
271  tag_size[0] = data.size() * sizeof(FieldData);
272  void const *tag_data[] = {&data[0]};
273  rval = moab.tag_set_by_ptr(e->sFieldPtr->th_FieldData, &ent, 1, tag_data,
274  tag_size);
275  MOAB_THROW(rval);
276  rval = moab.tag_get_by_ptr(e->sFieldPtr->th_FieldData, &ent, 1,
277  (const void **)&tag_field_data,
278  &tag_field_data_size);
279  MOAB_THROW(rval);
280  if (nb_dofs != tag_field_data_size / sizeof(FieldData))
281  THROW_MESSAGE("Data inconsistency");
282  }
283  }
284  }
285 }
#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: Exceptions.hpp:84
double FieldData
Field data type.
Definition: Types.hpp:36
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: