v0.9.1
Field Basic Algebra

Basic algebraic operation on fields. More...

Collaboration diagram for Field Basic Algebra:


This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.

Classes

struct  MoFEM::FieldBlas
Basic algebra on fields. More...

Functions

MoFEMErrorCode MoFEM::FieldBlas::fieldLambda (TwoFieldFunction lambda, const std::string field_name_x, const std::string field_name_y, bool error_if_missing=false, bool creat_if_missing=false)
filed lambdaDo calculation on two fields and save result to field fy More...

MoFEMErrorCode MoFEM::FieldBlas::fieldAxpy (const double alpha, const std::string field_name_x, const std::string field_name_y, bool error_if_missing=false, bool creat_if_missing=false)
axpy fieldsfield_y = field_y + alpha*field_x More...

MoFEMErrorCode MoFEM::FieldBlas::fieldCopy (const double alpha, const std::string field_name_x, const std::string field_name_y, bool error_if_missing=false, bool creat_if_missing=false)
copy and scale fieldsfield_y = alpha*field_x More...

MoFEMErrorCode MoFEM::FieldBlas::setVertexDofs (VertexCoordsFunction lambda, const std::string field_name, Range *verts=nullptr)
Set DOFs on vertices using user functionExample: More...

MoFEMErrorCode MoFEM::FieldBlas::setField (const double val, const EntityType type, const std::string field_name)
scale field More...

MoFEMErrorCode MoFEM::FieldBlas::setField (const double val, const EntityType type, const Range &ents, const std::string field_name)
set fieldfield_y = val More...

MoFEMErrorCode MoFEM::FieldBlas::setField (const double val, const std::string field_name)
set fieldfield_y = val More...

MoFEMErrorCode MoFEM::FieldBlas::fieldScale (const double alpha, const std::string field_name)
set fieldfield_y = val More...

Field algebra

DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::field_axpy (const double alpha, const std::string &fiel_name_x, const std::string &field_name_y, bool error_if_missing=false, bool creat_if_missing=false)
axpy fields More...

DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::field_scale (const double alpha, const std::string &field_name)
scale field More...

DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_field (const double val, const EntityType type, const std::string &field_name)
use FieldBlas More...

DEPRECATED MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_field (const double val, const EntityType type, const Range &ents, const std::string &field_name)
set field More...

Detailed Description

Basic algebraic operation on fields.

◆ field_axpy()

 MoFEMErrorCode MoFEM::DeprecatedCoreInterface::field_axpy ( const double alpha, const std::string & fiel_name_x, const std::string & field_name_y, bool error_if_missing = false, bool creat_if_missing = false )

axpy fields

Deprecated:
use FieldBlas
Todo:
should be moved to independent interface, i.e. FieldAlgebra

field_y = field_y + alpha*field_x

Parameters
 alpha field_name_x name of field_x field_name_y name of field_y error_if_missing throw error if entity/dof exist in field_x but not on field_y create_if_missing creat dof in field_y from fiedl_x if it is not database

Definition at line 68 of file DeprecatedCoreInterface.cpp.

71  {
72  return getInterface<FieldBlas>()->fieldAxpy(
73  alpha, field_name_x, field_name_y, error_if_missing, creat_if_missing);
74 }

◆ field_scale()

 MoFEMErrorCode MoFEM::DeprecatedCoreInterface::field_scale ( const double alpha, const std::string & field_name )

scale field

Deprecated:
use FieldBlas
Todo:
should be moved to independent interface, i.e. FieldAlgebra
Parameters
 alpha is a scaling factor \field_name is a field name

Definition at line 87 of file DeprecatedCoreInterface.cpp.

88  {
89  return getInterface<FieldBlas>()->fieldScale(alpha, field_name);
90 }

◆ fieldAxpy()

 MoFEMErrorCode MoFEM::FieldBlas::fieldAxpy ( const double alpha, const std::string field_name_x, const std::string field_name_y, bool error_if_missing = false, bool creat_if_missing = false )

axpy fieldsfield_y = field_y + alpha*field_x

Parameters
 alpha field_name_x name of field_x field_name_y name of field_y error_if_missing throw error if entity/dof exist in field_x but not on field_y create_if_missing creat dof in field_y from fiedl_x if it is not database
Examples
field_axpy_atom_test.cpp.

Definition at line 135 of file FieldBlas.cpp.

139  {
141  struct Axpy {
142  const double alpha;
143  Axpy(const double alpha) : alpha(alpha) {}
144  inline MoFEMErrorCode operator()(double &fy, const double fx) {
146  fy += alpha * fx;
148  }
149  };
150  CHKERR fieldLambda(Axpy(alpha), field_name_x, field_name_y, error_if_missing,
151  creat_if_missing);
153 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:506
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:513
MoFEMErrorCode fieldLambda(TwoFieldFunction lambda, const std::string field_name_x, const std::string field_name_y, bool error_if_missing=false, bool creat_if_missing=false)
filed lambdaDo calculation on two fields and save result to field fy
Definition: FieldBlas.cpp:38
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
#define CHKERR
Inline error check.
Definition: definitions.h:601
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412

◆ fieldCopy()

 MoFEMErrorCode MoFEM::FieldBlas::fieldCopy ( const double alpha, const std::string field_name_x, const std::string field_name_y, bool error_if_missing = false, bool creat_if_missing = false )

copy and scale fieldsfield_y = alpha*field_x

Parameters
 alpha field_name_x name of field_x field_name_y name of field_y error_if_missing throw error if entity/dof exist in field_x but not on field_y create_if_missing creat dof in field_y from fiedl_x if it is not database

Definition at line 155 of file FieldBlas.cpp.

159  {
161  struct Copy {
162  const double alpha;
163  Copy(const double alpha) : alpha(alpha) {}
164  inline MoFEMErrorCode operator()(double &fy, const double fx) {
166  fy = alpha * fx;
168  }
169  };
170  CHKERR fieldLambda(Copy(alpha), field_name_x, field_name_y, error_if_missing,
171  creat_if_missing);
173 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:506
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:513
MoFEMErrorCode fieldLambda(TwoFieldFunction lambda, const std::string field_name_x, const std::string field_name_y, bool error_if_missing=false, bool creat_if_missing=false)
filed lambdaDo calculation on two fields and save result to field fy
Definition: FieldBlas.cpp:38
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
#define CHKERR
Inline error check.
Definition: definitions.h:601
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412

◆ fieldLambda()

 MoFEMErrorCode MoFEM::FieldBlas::fieldLambda ( FieldBlas::TwoFieldFunction lambda, const std::string field_name_x, const std::string field_name_y, bool error_if_missing = false, bool creat_if_missing = false )

filed lambdaDo calculation on two fields and save result to field fy

struct Axpy {
const double aLpha;
Axpy(const double alpha) : aLpha(alpha) {}
inline MoFEMErrorCode operator(double &fy, double fx) {
fy += Alpha * fx;
}
};
CHKERR m_fiel.getInterface<FieldBlas>()->fieldLambda(Axpy(aLpha),
field_name_x, field_name_y);
Parameters
 function f(double &x, double) field_name_x name of field_x field_name_y name of field_y error_if_missing throw error if entity/dof exist in field_x but not on field_y create_if_missing creat dof in field_y from field_x if it is not database

Definition at line 38 of file FieldBlas.cpp.

42  {
43  const MoFEM::Interface &m_field = cOre;
44  const Field_multiIndex *fields_ptr;
45  const FieldEntity_multiIndex *field_ents;
46  const DofEntity_multiIndex *dofs_ptr;
48  CHKERR m_field.get_fields(&fields_ptr);
49  CHKERR m_field.get_field_ents(&field_ents);
50  CHKERR m_field.get_dofs(&dofs_ptr);
51
52  auto x_fit = fields_ptr->get<FieldName_mi_tag>().find(field_name_x);
53  if (x_fit == fields_ptr->get<FieldName_mi_tag>().end()) {
54  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
55  "x field < %s > not found, (top tip: check spelling)",
56  field_name_x.c_str());
57  }
58  auto y_fit = fields_ptr->get<FieldName_mi_tag>().find(field_name_y);
59  if (y_fit == fields_ptr->get<FieldName_mi_tag>().end()) {
60  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
61  "y field < %s > not found, (top tip: check spelling)",
62  field_name_y.c_str());
63  }
64  if ((*x_fit)->getSpace() != (*y_fit)->getSpace()) {
65  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
66  "space for field < %s > and field <%s> are not compatible",
67  field_name_x.c_str(), field_name_y.c_str());
68  }
69  if ((*x_fit)->getNbOfCoeffs() != (*y_fit)->getNbOfCoeffs()) {
70  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
71  "rank for field < %s > and field <%s> are not compatible",
72  field_name_x.c_str(), field_name_y.c_str());
73  }
74
75  typedef multi_index_container<
76  boost::shared_ptr<DofEntity>,
77  indexed_by<
78
79  hashed_non_unique<
80  tag<Composite_Ent_Order_And_CoeffIdx_mi_tag>,
81  composite_key<
82
83  DofEntity,
84  const_mem_fun<DofEntity, EntityHandle, &DofEntity::getEnt>,
85  const_mem_fun<DofEntity, ApproximationOrder,
87  const_mem_fun<DofEntity, FieldCoefficientsNumber,
89
90  >>
91
92  >>
93  DofEntity_multiIndex_composite_view;
94
95  auto dof_lo_for_view =
96  dofs_ptr->get<FieldName_mi_tag>().lower_bound(field_name_y);
97  auto dof_hi_for_view =
98  dofs_ptr->get<FieldName_mi_tag>().upper_bound(field_name_y);
99  DofEntity_multiIndex_composite_view dof_composite_view;
100  dof_composite_view.insert(dof_lo_for_view, dof_hi_for_view);
101
102  auto x_eit = field_ents->get<FieldName_mi_tag>().lower_bound(field_name_x);
103  auto x_eit_hi = field_ents->get<FieldName_mi_tag>().upper_bound(field_name_x);
104  for (; x_eit != x_eit_hi; x_eit++) {
105  int nb_dofs_on_x_entity = (*x_eit)->getNbDofsOnEnt();
107  for (int dd = 0; dd != nb_dofs_on_x_entity; ++dd) {
108  ApproximationOrder dof_order = (*x_eit)->getDofOrderMap()[dd];
109  FieldCoefficientsNumber dof_rank = dd % (*x_eit)->getNbOfCoeffs();
110  FieldData data = field_data[dd];
111  auto dit = dof_composite_view.find(
112  boost::make_tuple((*x_eit)->getEnt(), dof_order, dof_rank));
113  if (dit == dof_composite_view.end()) {
114  if (creat_if_missing) {
115  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
116  "not yet implemented");
117  } else {
118  if (error_if_missing) {
119  std::ostringstream ss;
120  ss << "dof on ent " << (*x_eit)->getEnt() << " order " << dof_order
121  << " rank " << dof_rank << " does not exist";
122  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
123  ss.str().c_str());
124  } else {
125  continue;
126  }
127  }
128  }
129  CHKERR lambda((*dit)->getFieldData(),data);
130  }
131  }
133 }
Deprecated interface functions.
FieldCoefficientsNumber getDofCoeffIdx() const
int ApproximationOrder
Approximation on the entity.
Definition: Types.hpp:37
multi_index_container< boost::shared_ptr< FieldEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, member< FieldEntity, UId, &FieldEntity::globalUId > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< FieldEntity::interface_type_Field, boost::string_ref, &FieldEntity::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< FieldEntity, EntityHandle, &FieldEntity::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< FieldEntity, const_mem_fun< FieldEntity::interface_type_Field, boost::string_ref, &FieldEntity::getNameRef >, const_mem_fun< FieldEntity, EntityHandle, &FieldEntity::getEnt > > > > > FieldEntity_multiIndex
MultiIndex container keeps FieldEntity.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
multi_index_container< boost::shared_ptr< Field >, indexed_by< hashed_unique< tag< BitFieldId_mi_tag >, const_mem_fun< Field, const BitFieldId &, &Field::getId >, HashBit< BitFieldId >, EqBit< BitFieldId > >, ordered_unique< tag< Meshset_mi_tag >, member< Field, EntityHandle, &Field::meshSet > >, ordered_unique< tag< FieldName_mi_tag >, const_mem_fun< Field, boost::string_ref, &Field::getNameRef > >, ordered_non_unique< tag< BitFieldId_space_mi_tag >, const_mem_fun< Field, FieldSpace, &Field::getSpace > > > > Field_multiIndex
Field_multiIndex for Field.
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, member< DofEntity, UId, &DofEntity::globalUId > >, ordered_non_unique< tag< Composite_Name_And_Ent_And_EntDofIdx_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, DofIdx, &DofEntity::getEntDofIdx > > >, ordered_non_unique< tag< Unique_Ent_mi_tag >, const_mem_fun< DofEntity, const UId &, &DofEntity::getEntGlobalUniqueId > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > > >, ordered_non_unique< tag< Composite_Name_And_Type_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity::interface_type_RefEntity, EntityType, &DofEntity::getEntType > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
Definition: Types.hpp:108
#define CHKERR
Inline error check.
Definition: definitions.h:601
virtual MoFEMErrorCode get_field_ents(const FieldEntity_multiIndex **field_ents) const =0
Get field multi index.
double FieldData
Field data type.
Definition: Types.hpp:36
ApproximationOrder getDofOrder() const
int FieldCoefficientsNumber
Number of field coefficients.
Definition: Types.hpp:38
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412
virtual MoFEMErrorCode get_fields(const Field_multiIndex **fields_ptr) const =0
Get fields multi-index from database.

◆ fieldScale()

 MoFEMErrorCode MoFEM::FieldBlas::fieldScale ( const double alpha, const std::string field_name )

set fieldfield_y = val

Parameters
 val entity type on enties field_name
Examples
field_axpy_atom_test.cpp.

Definition at line 320 of file FieldBlas.cpp.

321  {
322  const MoFEM::Interface &m_field = cOre;
323  const DofEntity_multiIndex *dofs_ptr;
325  const Field_multiIndex *fields_ptr;
326  CHKERR m_field.get_fields(&fields_ptr);
327
328  auto fit = fields_ptr->get<FieldName_mi_tag>().find(field_name);
329  if (fit == fields_ptr->get<FieldName_mi_tag>().end()) {
330  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
331  " field < %s > not found, (top tip: check spelling)",
332  field_name.c_str());
333  }
334  CHKERR m_field.get_dofs(&dofs_ptr);
335
336  DofEntityByFieldName::iterator dit, hi_dit;
337  dit = dofs_ptr->get<FieldName_mi_tag>().lower_bound(field_name);
338  hi_dit = dofs_ptr->get<FieldName_mi_tag>().upper_bound(field_name);
339  for (; dit != hi_dit; dit++) {
340  (*dit)->getFieldData() *= alpha;
341  }
343 }
Deprecated interface functions.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:506
multi_index_container< boost::shared_ptr< Field >, indexed_by< hashed_unique< tag< BitFieldId_mi_tag >, const_mem_fun< Field, const BitFieldId &, &Field::getId >, HashBit< BitFieldId >, EqBit< BitFieldId > >, ordered_unique< tag< Meshset_mi_tag >, member< Field, EntityHandle, &Field::meshSet > >, ordered_unique< tag< FieldName_mi_tag >, const_mem_fun< Field, boost::string_ref, &Field::getNameRef > >, ordered_non_unique< tag< BitFieldId_space_mi_tag >, const_mem_fun< Field, FieldSpace, &Field::getSpace > > > > Field_multiIndex
Field_multiIndex for Field.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:513
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, member< DofEntity, UId, &DofEntity::globalUId > >, ordered_non_unique< tag< Composite_Name_And_Ent_And_EntDofIdx_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, DofIdx, &DofEntity::getEntDofIdx > > >, ordered_non_unique< tag< Unique_Ent_mi_tag >, const_mem_fun< DofEntity, const UId &, &DofEntity::getEntGlobalUniqueId > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > > >, ordered_non_unique< tag< Composite_Name_And_Type_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity::interface_type_RefEntity, EntityType, &DofEntity::getEntType > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
#define CHKERR
Inline error check.
Definition: definitions.h:601
virtual MoFEMErrorCode get_fields(const Field_multiIndex **fields_ptr) const =0
Get fields multi-index from database.

◆ set_field() [1/2]

 MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_field ( const double val, const EntityType type, const std::string & field_name )

use FieldBlas

set field

Todo:
should be moved to independent interface, i.e. FieldAlgebra

field_y = val

Parameters
 val entity type field_name

Definition at line 76 of file DeprecatedCoreInterface.cpp.

77  {
78  return getInterface<FieldBlas>()->setField(val, type, field_name);
79 }

◆ set_field() [2/2]

 MoFEMErrorCode MoFEM::DeprecatedCoreInterface::set_field ( const double val, const EntityType type, const Range & ents, const std::string & field_name )

set field

Deprecated:
use FieldBlas
Todo:
should be moved to independent interface, i.e. FieldAlgebra

field_y = val

Parameters
 val entity type on enties field_name

Definition at line 81 of file DeprecatedCoreInterface.cpp.

83  {
84  return getInterface<FieldBlas>()->setField(val, type, ents, field_name);
85 }

◆ setField() [1/3]

 MoFEMErrorCode MoFEM::FieldBlas::setField ( const double val, const EntityType type, const std::string field_name )

scale field

Parameters
 val is a set parameter \field_name is a field name
Examples
field_axpy_atom_test.cpp.

Definition at line 243 of file FieldBlas.cpp.

244  {
245  const MoFEM::Interface &m_field = cOre;
246  const DofEntity_multiIndex *dofs_ptr;
248  CHKERR m_field.get_dofs(&dofs_ptr);
249
250  DofEntity_multiIndex::index<Composite_Name_And_Type_mi_tag>::type::iterator
251  dit,
252  hi_dit;
253  dit = dofs_ptr->get<Composite_Name_And_Type_mi_tag>().lower_bound(
254  boost::make_tuple(field_name, type));
255  hi_dit = dofs_ptr->get<Composite_Name_And_Type_mi_tag>().upper_bound(
256  boost::make_tuple(field_name, type));
257  for (; dit != hi_dit; dit++) {
258  (*dit)->getFieldData() = val;
259  }
261 }
Deprecated interface functions.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:506
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:513
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, member< DofEntity, UId, &DofEntity::globalUId > >, ordered_non_unique< tag< Composite_Name_And_Ent_And_EntDofIdx_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, DofIdx, &DofEntity::getEntDofIdx > > >, ordered_non_unique< tag< Unique_Ent_mi_tag >, const_mem_fun< DofEntity, const UId &, &DofEntity::getEntGlobalUniqueId > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > > >, ordered_non_unique< tag< Composite_Name_And_Type_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity::interface_type_RefEntity, EntityType, &DofEntity::getEntType > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
#define CHKERR
Inline error check.
Definition: definitions.h:601

◆ setField() [2/3]

 MoFEMErrorCode MoFEM::FieldBlas::setField ( const double val, const EntityType type, const Range & ents, const std::string field_name )

set fieldfield_y = val

Parameters
 val entity type field_name

Definition at line 263 of file FieldBlas.cpp.

265  {
266  const MoFEM::Interface &m_field = cOre;
267  const DofEntity_multiIndex *dofs_ptr;
269  CHKERR m_field.get_dofs(&dofs_ptr);
270
271  DofEntity_multiIndex::index<Composite_Name_And_Type_mi_tag>::type::iterator
272  dit,
273  hi_dit;
274  dit = dofs_ptr->get<Composite_Name_And_Type_mi_tag>().lower_bound(
275  boost::make_tuple(field_name, type));
276  hi_dit = dofs_ptr->get<Composite_Name_And_Type_mi_tag>().upper_bound(
277  boost::make_tuple(field_name, type));
278  EntityHandle ent, last = 0;
279  bool cont = true;
280  for (; dit != hi_dit; dit++) {
281  ent = (*dit)->getEnt();
282  if (ent != last) {
283  if (ents.find(ent) == ents.end()) {
284  cont = true;
285  } else {
286  cont = false;
287  }
288  last = ent;
289  }
290  if (cont)
291  continue;
292  (*dit)->getFieldData() = val;
293  }
295 }
Deprecated interface functions.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:506
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:513
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, member< DofEntity, UId, &DofEntity::globalUId > >, ordered_non_unique< tag< Composite_Name_And_Ent_And_EntDofIdx_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, DofIdx, &DofEntity::getEntDofIdx > > >, ordered_non_unique< tag< Unique_Ent_mi_tag >, const_mem_fun< DofEntity, const UId &, &DofEntity::getEntGlobalUniqueId > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > > >, ordered_non_unique< tag< Composite_Name_And_Type_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity::interface_type_RefEntity, EntityType, &DofEntity::getEntType > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
#define CHKERR
Inline error check.
Definition: definitions.h:601

◆ setField() [3/3]

 MoFEMErrorCode MoFEM::FieldBlas::setField ( const double val, const std::string field_name )

set fieldfield_y = val

Parameters
 val field_name

Definition at line 297 of file FieldBlas.cpp.

298  {
299  const MoFEM::Interface &m_field = cOre;
300  const DofEntity_multiIndex *dofs_ptr;
302  const Field_multiIndex *fields_ptr;
303  CHKERR m_field.get_fields(&fields_ptr);
304  auto fit = fields_ptr->get<FieldName_mi_tag>().find(field_name);
305  if (fit == fields_ptr->get<FieldName_mi_tag>().end()) {
306  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
307  " field < %s > not found, (top tip: check spelling)",
308  field_name.c_str());
309  }
310  CHKERR m_field.get_dofs(&dofs_ptr);
311
312  auto dit = dofs_ptr->get<FieldName_mi_tag>().lower_bound(field_name);
313  auto hi_dit = dofs_ptr->get<FieldName_mi_tag>().upper_bound(field_name);
314  for (; dit != hi_dit; dit++) {
315  (*dit)->getFieldData() = val;
316  }
318 }
Deprecated interface functions.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
multi_index_container< boost::shared_ptr< Field >, indexed_by< hashed_unique< tag< BitFieldId_mi_tag >, const_mem_fun< Field, const BitFieldId &, &Field::getId >, HashBit< BitFieldId >, EqBit< BitFieldId > >, ordered_unique< tag< Meshset_mi_tag >, member< Field, EntityHandle, &Field::meshSet > >, ordered_unique< tag< FieldName_mi_tag >, const_mem_fun< Field, boost::string_ref, &Field::getNameRef > >, ordered_non_unique< tag< BitFieldId_space_mi_tag >, const_mem_fun< Field, FieldSpace, &Field::getSpace > > > > Field_multiIndex
Field_multiIndex for Field.
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, member< DofEntity, UId, &DofEntity::globalUId > >, ordered_non_unique< tag< Composite_Name_And_Ent_And_EntDofIdx_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, DofIdx, &DofEntity::getEntDofIdx > > >, ordered_non_unique< tag< Unique_Ent_mi_tag >, const_mem_fun< DofEntity, const UId &, &DofEntity::getEntGlobalUniqueId > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > > >, ordered_non_unique< tag< Composite_Name_And_Type_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity::interface_type_RefEntity, EntityType, &DofEntity::getEntType > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
#define CHKERR
Inline error check.
Definition: definitions.h:601
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412
virtual MoFEMErrorCode get_fields(const Field_multiIndex **fields_ptr) const =0
Get fields multi-index from database.

◆ setVertexDofs()

 MoFEMErrorCode MoFEM::FieldBlas::setVertexDofs ( FieldBlas::VertexCoordsFunction lambda, const std::string field_name, Range * verts = nullptr )

Set DOFs on vertices using user functionExample:

auto do_something = [&](VectorAdaptor &field_data, double *x,
double *y, double *z) {
field_data[0] = (*x);
field_data[1] = (*y);
field_data[2] = (*z);
};
CHKERR m_field.getInterface<FieldBlas>()->setVertexDofs(set_distance,
"DISP");
Note
Function works both ways, using it coordinates can be set from field.
Parameters
 lambda function evaluating field at points field_name is a field name verts pointer to vertices if null all vertices in the field are evaluated)
Examples

Definition at line 175 of file FieldBlas.cpp.

177  {
178  const MoFEM::Interface &m_field = cOre;
180
181  EntityHandle meshset = m_field.get_field_meshset(field_name);
182  Range verts;
183  CHKERR m_field.get_moab().get_entities_by_type(meshset, MBVERTEX, verts,
184  true);
185  if (sub_verts)
186  verts = intersect(*sub_verts, verts);
187
188  struct LambdaMethod : EntityMethod {
189  LambdaMethod(MoFEM::Interface &m_field, Range &verts,
191  : EntityMethod(), mField(m_field), verts(verts), lambda(lambda),
192  count(0), total(0) {}
193  MoFEMErrorCode preProcess() {
194  vit = verts.begin();
195  return 0;
196  }
197  MoFEMErrorCode operator()() {
199  if (*vit != entPtr->getEnt())
200  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
201  "Inconsistent entity %ld != %ld", *vit, entPtr->getEnt());
202  if(!count)
203  CHKERR mField.get_moab().coords_iterate(vit, verts.end(), xCoord,
204  yCoord, zCoord, count);
205  CHKERR lambda(entPtr->getEntFieldData(), xCoord, yCoord, zCoord);
206  ++xCoord;
207  ++yCoord;
208  ++zCoord;
209  ++vit;
210  ++total;
211  --count;
213  }
214  MoFEMErrorCode postProcess() {
216  if(total != verts.size())
217  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
218  "Inconsistent number of vertices in field meshset and in the "
219  "field %d != %d",
220  total, verts.size());
222  }
223
224  private:
225  MoFEM::Interface &mField;
226  Range &verts;
228  int count;
229  int total;
230  Range::iterator vit;
231  double *xCoord;
232  double *yCoord;
233  double *zCoord;
234  };
235
236  LambdaMethod lambda_method(const_cast<MoFEM::Interface &>(m_field), verts,
237  lambda);
238  CHKERR const_cast<MoFEM::Interface &>(m_field).loop_entities(
239  field_name, lambda_method, &verts, QUIET);
241 }
Deprecated interface functions.
virtual moab::Interface & get_moab()=0
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
boost::function< MoFEMErrorCode(VectorAdaptor &&field_data, double *xcoord, double *ycoord, double *zcoord)> VertexCoordsFunction
Definition: FieldBlas.hpp:124
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
virtual EntityHandle get_field_meshset(const std::string &name) const =0
get field meshset
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
#define CHKERR
Inline error check.
Definition: definitions.h:601
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412