v0.8.23
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 820 of file EntsMultiIndices.hpp.

Constructor & Destructor Documentation

◆ FieldEntity_change_order()

MoFEM::FieldEntity_change_order::FieldEntity_change_order ( ApproximationOrder  order)

Definition at line 825 of file EntsMultiIndices.hpp.

825 : order(order) {}

Member Function Documentation

◆ operator()() [1/2]

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

Definition at line 826 of file EntsMultiIndices.hpp.

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

◆ operator()() [2/2]

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

Definition at line 198 of file EntsMultiIndices.cpp.

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

◆ data_dof_order

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

Definition at line 823 of file EntsMultiIndices.hpp.

◆ data_dof_rank

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

Definition at line 824 of file EntsMultiIndices.hpp.

◆ order

ApproximationOrder MoFEM::FieldEntity_change_order::order

Definition at line 821 of file EntsMultiIndices.hpp.


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