v0.9.0
Public Member Functions | Public Attributes | List of all members
AnalyticalDirichletHelmholtzBC::ApproxField::OpRhs< FUNEVAL > Struct Template Reference

Rhs operator used to build matrix. More...

#include <users_modules/helmholtz/src/AnalyticalDirichletHelmholtz.hpp>

Inherits UserDataOperator.

Collaboration diagram for AnalyticalDirichletHelmholtzBC::ApproxField::OpRhs< FUNEVAL >:
[legend]

Public Member Functions

 OpRhs (const string field_name, Range tris, MatrixDouble &ho_coords, boost::shared_ptr< FUNEVAL > function_evaluator, int field_number)
 
PetscErrorCode doWork (int side, EntityType type, DataForcesAndSurcesCore::EntData &data)
 

Public Attributes

Range tRis
 
MatrixDoublehoCoords
 
boost::shared_ptr< FUNEVAL > functionEvaluator
 
int fieldNumber
 
VectorDouble NTf
 
VectorInt iNdices
 

Detailed Description

template<typename FUNEVAL>
struct AnalyticalDirichletHelmholtzBC::ApproxField::OpRhs< FUNEVAL >

Rhs operator used to build matrix.

Definition at line 84 of file AnalyticalDirichletHelmholtz.hpp.

Constructor & Destructor Documentation

◆ OpRhs()

template<typename FUNEVAL >
AnalyticalDirichletHelmholtzBC::ApproxField::OpRhs< FUNEVAL >::OpRhs ( const string  field_name,
Range  tris,
MatrixDouble ho_coords,
boost::shared_ptr< FUNEVAL >  function_evaluator,
int  field_number 
)

Definition at line 91 of file AnalyticalDirichletHelmholtz.hpp.

94  :
95  FaceElementForcesAndSourcesCore::UserDataOperator(field_name,ForcesAndSurcesCore::UserDataOperator::OPROW),
96  tRis(tris),
97  hoCoords(ho_coords),functionEvaluator(function_evaluator),
98  fieldNumber(field_number)
99  {
100 
101  }
ForcesAndSourcesCore::UserDataOperator UserDataOperator

Member Function Documentation

◆ doWork()

template<typename FUNEVAL >
PetscErrorCode AnalyticalDirichletHelmholtzBC::ApproxField::OpRhs< FUNEVAL >::doWork ( int  side,
EntityType  type,
DataForcesAndSurcesCore::EntData data 
)

Definition at line 106 of file AnalyticalDirichletHelmholtz.hpp.

108  {
109  PetscFunctionBegin;
110  PetscErrorCode ierr;
111 
112  try {
113 
114  unsigned int nb_row = data.getIndices().size();
115  if(nb_row==0) PetscFunctionReturn(0);
116  if(tRis.find(getNumeredEntFiniteElementPtr()->getEnt()) == tRis.end()) {
117  PetscFunctionReturn(0);
118  }
119 
120  const FENumeredDofEntity *dof_ptr;
121  ierr = getNumeredEntFiniteElementPtr()->getRowDofsByPetscGlobalDofIdx(data.getIndices()[0],&dof_ptr); CHKERRQ(ierr);
122  unsigned int rank = dof_ptr->getNbOfCoeffs();
123 
124  NTf.resize(nb_row/rank);
125  iNdices.resize(nb_row/rank);
126 
127  for(unsigned int gg = 0;gg<data.getN().size1();gg++) {
128 
129  double x,y,z;
130  double val = getGaussPts()(2,gg);
131  if(hoCoords.size1() == data.getN().size1()) {
132  double area = ublas::norm_2(getNormalsAtGaussPt(gg))*0.5;
133  val *= area;
134  x = hoCoords(gg,0);
135  y = hoCoords(gg,1);
136  z = hoCoords(gg,2);
137  } else {
138  val *= getArea();
139  x = getCoordsAtGaussPts()(gg,0);
140  y = getCoordsAtGaussPts()(gg,1);
141  z = getCoordsAtGaussPts()(gg,2);
142  }
143 
144  VectorDouble a;
145  try {
146 
147  a = (*functionEvaluator)(x,y,z)[fieldNumber];
148 
149  } catch (exception& ex) {
150  ostringstream ss;
151  ss << "thorw in method: " << ex.what() << " at line " << __LINE__ << " in file " << __FILE__;
152  SETERRQ(PETSC_COMM_SELF,MOFEM_STD_EXCEPTION_THROW,ss.str().c_str());
153  }
154  if(a.size()!=rank) {
155  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"data inconsistency");
156  }
157 
158 
159  for(unsigned int rr = 0;rr<rank;rr++) {
160 
161  ublas::noalias(iNdices) = ublas::vector_slice<VectorInt >
162  (data.getIndices(), ublas::slice(rr, rank, data.getIndices().size()/rank));
163 
164  noalias(NTf) = data.getN(gg,nb_row/rank)*a[rr]*val;
165  ierr = VecSetValues(getFEMethod()->snes_f,iNdices.size(),
166  &iNdices[0],&*NTf.data().begin(),ADD_VALUES); CHKERRQ(ierr);
167 
168  }
169 
170  }
171 
172 
173  } catch (const std::exception& ex) {
174  ostringstream ss;
175  ss << "throw in method: " << ex.what() << endl;
176  SETERRQ(PETSC_COMM_SELF,1,ss.str().c_str());
177  }
178 
179  PetscFunctionReturn(0);
180  }
keeps information about indexed dofs for the finite element
FieldCoefficientsNumber getNbOfCoeffs() const
CHKERRQ(ierr)
MoFEMErrorCode VecSetValues(Vec V, const DataForcesAndSourcesCore::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
ublas::vector< double, DoubleAllocator > VectorDouble
Definition: Types.hpp:72

Member Data Documentation

◆ fieldNumber

template<typename FUNEVAL >
int AnalyticalDirichletHelmholtzBC::ApproxField::OpRhs< FUNEVAL >::fieldNumber

Definition at line 89 of file AnalyticalDirichletHelmholtz.hpp.

◆ functionEvaluator

template<typename FUNEVAL >
boost::shared_ptr<FUNEVAL> AnalyticalDirichletHelmholtzBC::ApproxField::OpRhs< FUNEVAL >::functionEvaluator

Definition at line 88 of file AnalyticalDirichletHelmholtz.hpp.

◆ hoCoords

template<typename FUNEVAL >
MatrixDouble& AnalyticalDirichletHelmholtzBC::ApproxField::OpRhs< FUNEVAL >::hoCoords

Definition at line 87 of file AnalyticalDirichletHelmholtz.hpp.

◆ iNdices

template<typename FUNEVAL >
VectorInt AnalyticalDirichletHelmholtzBC::ApproxField::OpRhs< FUNEVAL >::iNdices

Definition at line 104 of file AnalyticalDirichletHelmholtz.hpp.

◆ NTf

template<typename FUNEVAL >
VectorDouble AnalyticalDirichletHelmholtzBC::ApproxField::OpRhs< FUNEVAL >::NTf

Definition at line 103 of file AnalyticalDirichletHelmholtz.hpp.

◆ tRis

template<typename FUNEVAL >
Range AnalyticalDirichletHelmholtzBC::ApproxField::OpRhs< FUNEVAL >::tRis

Definition at line 86 of file AnalyticalDirichletHelmholtz.hpp.


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