v0.8.15
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::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 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
alphais a scaling factor 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 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 114 of file FieldBlas.cpp.

118  {
120  struct Axpy {
121  const double alpha;
122  Axpy(const double alpha) : alpha(alpha) {}
123  inline MoFEMErrorCode operator()(double &fy, const double fx) {
125  fy += alpha * fx;
127  }
128  };
129  CHKERR fieldLambda(Axpy(alpha), field_name_x, field_name_y, error_if_missing,
130  creat_if_missing);
132 }
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:483
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:459
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:490
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:578
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:403

◆ 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 134 of file FieldBlas.cpp.

138  {
140  struct Copy {
141  const double alpha;
142  Copy(const double alpha) : alpha(alpha) {}
143  inline MoFEMErrorCode operator()(double &fy, const double fx) {
145  fy = alpha * fx;
147  }
148  };
149  CHKERR fieldLambda(Copy(alpha), field_name_x, field_name_y, error_if_missing,
150  creat_if_missing);
152 }
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:483
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:459
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:490
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:578
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:403

◆ 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  Field_multiIndex::index<FieldName_mi_tag>::type::iterator x_fit =
52  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  Field_multiIndex::index<FieldName_mi_tag>::type::iterator y_fit =
59  fields_ptr->get<FieldName_mi_tag>().find(field_name_y);
60  if (y_fit == fields_ptr->get<FieldName_mi_tag>().end()) {
61  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
62  "y field < %s > not found, (top tip: check spelling)",
63  field_name_y.c_str());
64  }
65  if ((*x_fit)->getSpace() != (*y_fit)->getSpace()) {
66  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
67  "space for field < %s > and field <%s> are not compatible",
68  field_name_x.c_str(), field_name_y.c_str());
69  }
70  if ((*x_fit)->getNbOfCoeffs() != (*y_fit)->getNbOfCoeffs()) {
71  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
72  "rank for field < %s > and field <%s> are not compatible",
73  field_name_x.c_str(), field_name_y.c_str());
74  }
75  FieldEntityByFieldName::iterator x_eit;
76  x_eit = field_ents->get<FieldName_mi_tag>().lower_bound(field_name_x.c_str());
77  for (; x_eit !=
78  field_ents->get<FieldName_mi_tag>().upper_bound(field_name_x.c_str());
79  x_eit++) {
80  int nb_dofs_on_x_entity = (*x_eit)->getNbDofsOnEnt();
81  VectorAdaptor field_data = (*x_eit)->getEntFieldData();
82  for (int dd = 0; dd != nb_dofs_on_x_entity; ++dd) {
83  ApproximationOrder dof_order = (*x_eit)->getDofOrderMap()[dd];
84  FieldCoefficientsNumber dof_rank = dd % (*x_eit)->getNbOfCoeffs();
85  FieldData data = field_data[dd];
86  DofEntity_multiIndex::index<
87  Composite_Name_Ent_Order_And_CoeffIdx_mi_tag>::type::iterator dit;
88  dit = dofs_ptr->get<Composite_Name_Ent_Order_And_CoeffIdx_mi_tag>().find(
89  boost::make_tuple(field_name_y.c_str(), (*x_eit)->getEnt(), dof_order,
90  dof_rank));
91  if (dit ==
92  dofs_ptr->get<Composite_Name_Ent_Order_And_CoeffIdx_mi_tag>().end()) {
93  if (creat_if_missing) {
94  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
95  "not yet implemented");
96  } else {
97  if (error_if_missing) {
98  std::ostringstream ss;
99  ss << "dof on ent " << (*x_eit)->getEnt() << " order " << dof_order
100  << " rank " << dof_rank << " does not exist";
101  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
102  ss.str().c_str());
103  } else {
104  continue;
105  }
106  }
107  }
108  CHKERR lambda((*dit)->getFieldData(),data);
109  }
110  }
112 }
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
double FieldData
Field data type.
Definition: Common.hpp:130
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:459
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.
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.
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
VectorShallowArrayAdaptor< double > VectorAdaptor
Definition: Common.hpp:234
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< DofEntity, UId, &DofEntity::getGlobalUniqueId > >, ordered_non_unique< tag< Composite_Ent_and_ShortId_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, ShortId, &DofEntity::getNonNonuniqueShortId > > >, 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, 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 > > >, ordered_non_unique< tag< Composite_Name_Ent_Order_And_CoeffIdx_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, ApproximationOrder, &DofEntity::getDofOrder >, const_mem_fun< DofEntity, FieldCoefficientsNumber, &DofEntity::getDofCoeffIdx > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
#define CHKERR
Inline error check.
Definition: definitions.h:578
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
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:403
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 208 of file FieldBlas.cpp.

209  {
210  const MoFEM::Interface &m_field = cOre;
211  const DofEntity_multiIndex *dofs_ptr;
213  ierr = m_field.get_dofs(&dofs_ptr);
214  CHKERRG(ierr);
215  DofEntityByFieldName::iterator dit, hi_dit;
216  dit = dofs_ptr->get<FieldName_mi_tag>().lower_bound(field_name);
217  hi_dit = dofs_ptr->get<FieldName_mi_tag>().upper_bound(field_name);
218  for (; dit != hi_dit; dit++) {
219  (*dit)->getFieldData() *= alpha;
220  }
222 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:483
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:526
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:490
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< DofEntity, UId, &DofEntity::getGlobalUniqueId > >, ordered_non_unique< tag< Composite_Ent_and_ShortId_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, ShortId, &DofEntity::getNonNonuniqueShortId > > >, 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, 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 > > >, ordered_non_unique< tag< Composite_Name_Ent_Order_And_CoeffIdx_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, ApproximationOrder, &DofEntity::getDofOrder >, const_mem_fun< DofEntity, FieldCoefficientsNumber, &DofEntity::getDofCoeffIdx > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Common.hpp:80

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

Definition at line 81 of file DeprecatedCoreInterface.cpp.

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

◆ setField() [1/2]

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 154 of file FieldBlas.cpp.

155  {
156  const MoFEM::Interface &m_field = cOre;
157  const DofEntity_multiIndex *dofs_ptr;
159  ierr = m_field.get_dofs(&dofs_ptr);
160  CHKERRG(ierr);
161  DofEntity_multiIndex::index<Composite_Name_And_Type_mi_tag>::type::iterator
162  dit,
163  hi_dit;
164  dit = dofs_ptr->get<Composite_Name_And_Type_mi_tag>().lower_bound(
165  boost::make_tuple(field_name, type));
166  hi_dit = dofs_ptr->get<Composite_Name_And_Type_mi_tag>().upper_bound(
167  boost::make_tuple(field_name, type));
168  for (; dit != hi_dit; dit++) {
169  (*dit)->getFieldData() = val;
170  }
172 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:483
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:526
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:490
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< DofEntity, UId, &DofEntity::getGlobalUniqueId > >, ordered_non_unique< tag< Composite_Ent_and_ShortId_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, ShortId, &DofEntity::getNonNonuniqueShortId > > >, 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, 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 > > >, ordered_non_unique< tag< Composite_Name_Ent_Order_And_CoeffIdx_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, ApproximationOrder, &DofEntity::getDofOrder >, const_mem_fun< DofEntity, FieldCoefficientsNumber, &DofEntity::getDofCoeffIdx > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Common.hpp:80

◆ setField() [2/2]

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 174 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  EntityHandle ent, last = 0;
190  bool cont = true;
191  for (; dit != hi_dit; dit++) {
192  ent = (*dit)->getEnt();
193  if (ent != last) {
194  if (ents.find(ent) == ents.end()) {
195  cont = true;
196  } else {
197  cont = false;
198  }
199  last = ent;
200  }
201  if (cont)
202  continue;
203  (*dit)->getFieldData() = val;
204  }
206 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:483
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:526
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:490
virtual MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const =0
Get dofs multi index.
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< DofEntity, UId, &DofEntity::getGlobalUniqueId > >, ordered_non_unique< tag< Composite_Ent_and_ShortId_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, ShortId, &DofEntity::getNonNonuniqueShortId > > >, 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, 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 > > >, ordered_non_unique< tag< Composite_Name_Ent_Order_And_CoeffIdx_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, ApproximationOrder, &DofEntity::getDofOrder >, const_mem_fun< DofEntity, FieldCoefficientsNumber, &DofEntity::getDofCoeffIdx > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
const MoFEM::Interface & cOre
Definition: FieldBlas.hpp:39
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Common.hpp:80