v0.8.19
Classes | Functions
Field Basic Algebra

Basic algebraic operation on fields. More...

Collaboration diagram for Field Basic Algebra:

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 lambda 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 fields 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 fields 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 field More...
 
MoFEMErrorCode MoFEM::FieldBlas::setField (const double val, const std::string field_name)
 set field More...
 
MoFEMErrorCode MoFEM::FieldBlas::fieldScale (const double alpha, const std::string field_name)
 set field 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.

Function Documentation

◆ 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_xname of field_x
field_name_yname of field_y
error_if_missingthrow error if entity/dof exist in field_x but not on field_y
create_if_missingcreat dof in field_y from fiedl_x if it is not database

Definition at line 67 of file DeprecatedCoreInterface.cpp.

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

◆ 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
alphais a scaling factor is a field name

Definition at line 86 of file DeprecatedCoreInterface.cpp.

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

◆ 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 fields

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

field_y = field_y + alpha*field_x

Parameters
alpha
field_name_xname of field_x
field_name_yname of field_y
error_if_missingthrow error if entity/dof exist in field_x but not on field_y
create_if_missingcreat dof in field_y from fiedl_x if it is not database

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 }
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Common.hpp:60
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:499
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:475
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:506
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 lambda
Definition: FieldBlas.cpp:38
#define CHKERR
Inline error check.
Definition: definitions.h:594
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:405

◆ 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 fields

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

field_y = alpha*field_x

Parameters
alpha
field_name_xname of field_x
field_name_yname of field_y
error_if_missingthrow error if entity/dof exist in field_x but not on field_y
create_if_missingcreat 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 }
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Common.hpp:60
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:499
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:475
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:506
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 lambda
Definition: FieldBlas.cpp:38
#define CHKERR
Inline error check.
Definition: definitions.h:594
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:405

◆ 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 lambda

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

Do 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
functionf(double &x, double)
field_name_xname of field_x
field_name_yname of field_y
error_if_missingthrow error if entity/dof exist in field_x but not on field_y
create_if_missingcreat 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();
106  VectorAdaptor field_data = (*x_eit)->getEntFieldData();
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 }
int FieldCoefficientsNumber
Number of field coefficients.
Definition: Common.hpp:132
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
FieldCoefficientsNumber getDofCoeffIdx() const
double FieldData
Field data type.
Definition: Common.hpp:130
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:475
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.
VectorShallowArrayAdaptor< double > VectorAdaptor
Definition: Common.hpp:234
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:594
virtual MoFEMErrorCode get_field_ents(const FieldEntity_multiIndex **field_ents) const =0
Get field multi index.
int ApproximationOrder
Approximation on the entity.
Definition: Common.hpp:131
ApproximationOrder getDofOrder() const
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:405
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 field

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

field_y = val

Parameters
val
entitytype
onenties
field_name

Definition at line 240 of file FieldBlas.cpp.

241  {
242  const MoFEM::Interface &m_field = cOre;
243  const DofEntity_multiIndex *dofs_ptr;
245  ierr = m_field.get_dofs(&dofs_ptr);
246  CHKERRG(ierr);
247  DofEntityByFieldName::iterator dit, hi_dit;
248  dit = dofs_ptr->get<FieldName_mi_tag>().lower_bound(field_name);
249  hi_dit = dofs_ptr->get<FieldName_mi_tag>().upper_bound(field_name);
250  for (; dit != hi_dit; dit++) {
251  (*dit)->getFieldData() *= alpha;
252  }
254 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:499
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:542
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:506
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Common.hpp:80
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.

◆ 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
entitytype
field_name

Definition at line 75 of file DeprecatedCoreInterface.cpp.

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

◆ 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
entitytype
onenties
field_name

Definition at line 80 of file DeprecatedCoreInterface.cpp.

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

◆ setField() [1/3]

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

scale field

Todo:
should be moved to independent interface, i.e. FieldAlgebra
Parameters
alphais a scaling factor is a field name

Definition at line 175 of file FieldBlas.cpp.

176  {
177  const MoFEM::Interface &m_field = cOre;
178  const DofEntity_multiIndex *dofs_ptr;
180  ierr = m_field.get_dofs(&dofs_ptr);
181  CHKERRG(ierr);
182  DofEntity_multiIndex::index<Composite_Name_And_Type_mi_tag>::type::iterator
183  dit,
184  hi_dit;
185  dit = dofs_ptr->get<Composite_Name_And_Type_mi_tag>().lower_bound(
186  boost::make_tuple(field_name, type));
187  hi_dit = dofs_ptr->get<Composite_Name_And_Type_mi_tag>().upper_bound(
188  boost::make_tuple(field_name, type));
189  for (; dit != hi_dit; dit++) {
190  (*dit)->getFieldData() = val;
191  }
193 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:499
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:542
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:506
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Common.hpp:80
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.

◆ setField() [2/3]

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

set field

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

field_y = val

Parameters
val
entitytype
field_name

Definition at line 195 of file FieldBlas.cpp.

197  {
198  const MoFEM::Interface &m_field = cOre;
199  const DofEntity_multiIndex *dofs_ptr;
201  ierr = m_field.get_dofs(&dofs_ptr);
202  CHKERRG(ierr);
203  DofEntity_multiIndex::index<Composite_Name_And_Type_mi_tag>::type::iterator
204  dit,
205  hi_dit;
206  dit = dofs_ptr->get<Composite_Name_And_Type_mi_tag>().lower_bound(
207  boost::make_tuple(field_name, type));
208  hi_dit = dofs_ptr->get<Composite_Name_And_Type_mi_tag>().upper_bound(
209  boost::make_tuple(field_name, type));
210  EntityHandle ent, last = 0;
211  bool cont = true;
212  for (; dit != hi_dit; dit++) {
213  ent = (*dit)->getEnt();
214  if (ent != last) {
215  if (ents.find(ent) == ents.end()) {
216  cont = true;
217  } else {
218  cont = false;
219  }
220  last = ent;
221  }
222  if (cont)
223  continue;
224  (*dit)->getFieldData() = val;
225  }
227 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:499
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:542
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:506
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Common.hpp:80
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.

◆ setField() [3/3]

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

set field

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

field_y = val

Parameters
val
field_name

Definition at line 229 of file FieldBlas.cpp.

230  {
231  const MoFEM::Interface &m_field = cOre;
232  const DofEntity_multiIndex *dofs_ptr;
234  CHKERR m_field.get_dofs(&dofs_ptr);
235  for (auto &dof : *dofs_ptr)
236  dof->getFieldData() = val;
238 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:475
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:594
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:405