v0.14.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/FieldEntsMultiIndices.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 394 of file FieldEntsMultiIndices.hpp.

Constructor & Destructor Documentation

◆ FieldEntity_change_order()

MoFEM::FieldEntity_change_order::FieldEntity_change_order ( const ApproximationOrder  order,
const bool  reduce_tag_size = false 
)
inline

Definition at line 396 of file FieldEntsMultiIndices.hpp.

398  : order(order), reduceTagSize(reduce_tag_size) {}

Member Function Documentation

◆ operator()() [1/2]

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

Definition at line 399 of file FieldEntsMultiIndices.hpp.

399  {
400  (*this)(e.get());
401  }

◆ operator()() [2/2]

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

Definition at line 63 of file FieldEntsMultiIndices.cpp.

63  {
64 
65  moab::Interface &moab = e->sPtr->getBasicDataPtr()->moab;
66  const EntityHandle ent = e->getEnt();
67  *const_cast<ApproximationOrder *>(e->getMaxOrderPtr()) = order;
68  std::size_t nb_dofs = e->getOrderNbDofs(order) * e->getNbOfCoeffs();
69 
70  double *tag_field_data = nullptr;
71  int tag_field_data_size = 0;
72 
73  auto set_verts = [&]() {
74  if (e->getFieldRawPtr()->tagFieldDataVertsType == MB_TAG_SPARSE) {
75  // Get pointer and size of field values tag
76  rval = moab.tag_get_by_ptr(e->getFieldRawPtr()->th_FieldDataVerts, &ent,
77  1, (const void **)&tag_field_data,
78  &tag_field_data_size);
79  if (nb_dofs) {
80  if (nb_dofs != tag_field_data_size) {
81  rval = moab.tag_set_data(e->getFieldRawPtr()->th_FieldDataVerts, &ent,
82  1, &*data.begin());
84  }
85  } else if (rval == MB_SUCCESS) {
86  rval = moab.tag_delete_data(e->getFieldRawPtr()->th_FieldDataVerts,
87  &ent, 1);
89  }
90  } else {
91  rval = moab.tag_get_by_ptr(e->getFieldRawPtr()->th_FieldDataVerts, &ent,
92  1, (const void **)&tag_field_data);
94  rval = moab.tag_set_data(e->getFieldRawPtr()->th_FieldDataVerts, &ent, 1,
95  tag_field_data);
97  }
98  };
99 
100  auto set_default = [&]() {
101  if (reduceTagSize || nb_dofs) {
102 
103  // Get pointer and size of field values tag
104  rval = moab.tag_get_by_ptr(e->getFieldRawPtr()->th_FieldData, &ent, 1,
105  (const void **)&tag_field_data,
106  &tag_field_data_size);
107 
108  if ((reduceTagSize && nb_dofs != tag_field_data_size) ||
109  nb_dofs > tag_field_data_size) {
110 
111  // Tag exist and are some data on it
112  if (rval == MB_SUCCESS) {
113  // Size of tag is different than new size, so copy data to new
114  // container
115  data.resize(tag_field_data_size);
116  FieldData *ptr_begin = static_cast<FieldData *>(tag_field_data);
117  FieldData *ptr_end =
118  static_cast<FieldData *>(tag_field_data) + tag_field_data_size;
119  std::copy(ptr_begin, ptr_end, data.begin());
120  }
121 
122  if (rval != MB_SUCCESS || nb_dofs) {
123 
124  // Set field dof data
125  data.resize(nb_dofs, 0);
126  int tag_size[1];
127  tag_size[0] = data.size();
128  void const *tag_data[] = {&data[0]};
129  rval = moab.tag_set_by_ptr(e->getFieldRawPtr()->th_FieldData, &ent, 1,
130  tag_data, tag_size);
131  MOAB_THROW(rval);
132  rval = moab.tag_get_by_ptr(e->getFieldRawPtr()->th_FieldData, &ent, 1,
133  (const void **)&tag_field_data,
134  &tag_field_data_size);
135  MOAB_THROW(rval);
136 
137  } else {
138 
139  rval =
140  moab.tag_delete_data(e->getFieldRawPtr()->th_FieldData, &ent, 1);
141  MOAB_THROW(rval);
142  }
143  }
144  }
145  };
146 
147  switch (e->getEntType()) {
148  case MBVERTEX:
149  set_verts();
150  break;
151  default:
152  set_default();
153  }
154 
155  if (nb_dofs)
156  const_cast<double *&>(*(e->getEntFieldDataPtr())) = tag_field_data;
157  else
158  const_cast<double *&>(*(e->getEntFieldDataPtr())) = nullptr;
159 }

Member Data Documentation

◆ data

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

Definition at line 407 of file FieldEntsMultiIndices.hpp.

◆ order

const ApproximationOrder MoFEM::FieldEntity_change_order::order
private

Definition at line 405 of file FieldEntsMultiIndices.hpp.

◆ reduceTagSize

const bool MoFEM::FieldEntity_change_order::reduceTagSize
private

Definition at line 406 of file FieldEntsMultiIndices.hpp.


The documentation for this struct was generated from the following files:
EntityHandle
MoFEM::FieldEntity_change_order::order
const ApproximationOrder order
Definition: FieldEntsMultiIndices.hpp:405
MOAB_THROW
#define MOAB_THROW(err)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:554
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:2010
MoFEM::Exceptions::rval
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:74
MoFEM::FieldEntity_change_order::reduceTagSize
const bool reduceTagSize
Definition: FieldEntsMultiIndices.hpp:406
MoFEM::Types::ApproximationOrder
int ApproximationOrder
Approximation on the entity.
Definition: Types.hpp:26
MoFEM::Types::FieldData
double FieldData
Field data type.
Definition: Types.hpp:25
MoFEM::FieldEntity_change_order::data
std::vector< FieldData > data
Definition: FieldEntsMultiIndices.hpp:407