v0.14.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MoFEM::OpBaseDerivativesNext< 1 > Struct Reference

Specialisation for calculate directives for scalar base functions. More...

#include <src/finite_elements/BaseDerivativesDataOperators.hpp>

Inheritance diagram for MoFEM::OpBaseDerivativesNext< 1 >:
[legend]
Collaboration diagram for MoFEM::OpBaseDerivativesNext< 1 >:
[legend]

Public Member Functions

 OpBaseDerivativesNext (int derivative, boost::shared_ptr< MatrixDouble > base_mass_ptr, boost::shared_ptr< EntitiesFieldData > data_l2, const FieldApproximationBase b, const FieldSpace s, int verb=QUIET, Sev sev=Sev::verbose)
 
MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 Operator for linear form, usually to calculate values on right hand side. More...
 
- Public Member Functions inherited from MoFEM::OpBaseDerivativesBase
 OpBaseDerivativesBase (boost::shared_ptr< MatrixDouble > base_mass_ptr, boost::shared_ptr< EntitiesFieldData > data_l2, const FieldApproximationBase b, const FieldSpace s, int verb=QUIET, Sev sev=Sev::verbose)
 
- Public Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
 UserDataOperator (const FieldSpace space, const char type=OPSPACE, const bool symm=true)
 
 UserDataOperator (const std::string field_name, const char type, const bool symm=true)
 
 UserDataOperator (const std::string row_field_name, const std::string col_field_name, const char type, const bool symm=true)
 
boost::shared_ptr< const NumeredEntFiniteElementgetNumeredEntFiniteElementPtr () const
 Return raw pointer to NumeredEntFiniteElement. More...
 
EntityHandle getFEEntityHandle () const
 Return finite element entity handle. More...
 
int getFEDim () const
 Get dimension of finite element. More...
 
EntityType getFEType () const
 Get dimension of finite element. More...
 
boost::weak_ptr< SideNumbergetSideNumberPtr (const int side_number, const EntityType type)
 Get the side number pointer. More...
 
EntityHandle getSideEntity (const int side_number, const EntityType type)
 Get the side entity. More...
 
int getNumberOfNodesOnElement () const
 Get the number of nodes on finite element. More...
 
MoFEMErrorCode getProblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get row indices. More...
 
MoFEMErrorCode getProblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get col indices. More...
 
const FEMethodgetFEMethod () const
 Return raw pointer to Finite Element Method object. More...
 
int getOpType () const
 Get operator types. More...
 
void setOpType (const OpType type)
 Set operator type. More...
 
void addOpType (const OpType type)
 Add operator type. More...
 
int getNinTheLoop () const
 get number of finite element in the loop More...
 
int getLoopSize () const
 get size of elements in the loop More...
 
std::string getFEName () const
 Get name of the element. More...
 
ForcesAndSourcesCoregetPtrFE () const
 
ForcesAndSourcesCoregetSidePtrFE () const
 
ForcesAndSourcesCoregetRefinePtrFE () const
 
const PetscData::SwitchesgetDataCtx () const
 
const KspMethod::KSPContext getKSPCtx () const
 
const SnesMethod::SNESContext getSNESCtx () const
 
const TSMethod::TSContext getTSCtx () const
 
Vec getKSPf () const
 
Mat getKSPA () const
 
Mat getKSPB () const
 
Vec getSNESf () const
 
Vec getSNESx () const
 
Mat getSNESA () const
 
Mat getSNESB () const
 
Vec getTSu () const
 
Vec getTSu_t () const
 
Vec getTSu_tt () const
 
Vec getTSf () const
 
Mat getTSA () const
 
Mat getTSB () const
 
int getTSstep () const
 
double getTStime () const
 
double getTStimeStep () const
 
double getTSa () const
 
double getTSaa () const
 
MatrixDoublegetGaussPts ()
 matrix of integration (Gauss) points for Volume Element More...
 
auto getFTensor0IntegrationWeight ()
 Get integration weights. More...
 
MatrixDoublegetCoordsAtGaussPts ()
 Gauss points and weight, matrix (nb. of points x 3) More...
 
auto getFTensor1CoordsAtGaussPts ()
 Get coordinates at integration points assuming linear geometry. More...
 
double getMeasure () const
 get measure of element More...
 
doublegetMeasure ()
 get measure of element More...
 
MoFEMErrorCode loopSide (const string &fe_name, ForcesAndSourcesCore *side_fe, const size_t dim, const EntityHandle ent_for_side=0, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy, AdjCache *adj_cache=nullptr)
 User calls this function to loop over elements on the side of face. This function calls finite element with its operator to do calculations. More...
 
MoFEMErrorCode loopThis (const string &fe_name, ForcesAndSourcesCore *this_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over the same element using a different set of integration points. This function calls finite element with its operator to do calculations. More...
 
MoFEMErrorCode loopParent (const string &fe_name, ForcesAndSourcesCore *parent_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations. More...
 
MoFEMErrorCode loopChildren (const string &fe_name, ForcesAndSourcesCore *child_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations. More...
 
- Public Member Functions inherited from MoFEM::DataOperator
 DataOperator (const bool symm=true)
 
virtual ~DataOperator ()=default
 
virtual MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Operator for bi-linear form, usually to calculate values on left hand side. More...
 
virtual MoFEMErrorCode opLhs (EntitiesFieldData &row_data, EntitiesFieldData &col_data)
 
virtual MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 Operator for linear form, usually to calculate values on right hand side. More...
 
virtual MoFEMErrorCode opRhs (EntitiesFieldData &data, const bool error_if_no_base=false)
 
bool getSymm () const
 Get if operator uses symmetry of DOFs or not. More...
 
void setSymm ()
 set if operator is executed taking in account symmetry More...
 
void unSetSymm ()
 unset if operator is executed for non symmetric problem More...
 

Protected Member Functions

template<int BASE_DIM>
MoFEMErrorCode doWorkImpl (int side, EntityType type, EntitiesFieldData::EntData &data)
 
template<int BASE_DIM, int SPACE_DIM>
MoFEMErrorCode setBaseImpl (EntitiesFieldData::EntData &data, EntitiesFieldData::EntData &ent_data)
 
- Protected Member Functions inherited from MoFEM::OpBaseDerivativesBase
MoFEMErrorCode calculateBase (GetOrderFun get_order)
 
MoFEMErrorCode calculateMass ()
 
- Protected Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
virtual MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 

Protected Attributes

int calcBaseDerivative
 
MatrixDouble nF
 
- Protected Attributes inherited from MoFEM::OpBaseDerivativesBase
FieldApproximationBase base
 
int verbosity
 
Sev severityLevel
 
boost::shared_ptr< MatrixDoublebaseMassPtr
 
boost::shared_ptr< EntitiesFieldDatadataL2
 
- Protected Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoreptrFE
 

Additional Inherited Members

- Public Types inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
enum  OpType {
  OPROW = 1 << 0 , OPCOL = 1 << 1 , OPROWCOL = 1 << 2 , OPSPACE = 1 << 3 ,
  OPLAST = 1 << 3
}
 Controls loop over entities on element. More...
 
using AdjCache = std::map< EntityHandle, std::vector< boost::weak_ptr< NumeredEntFiniteElement > > >
 
- Public Types inherited from MoFEM::DataOperator
using DoWorkLhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)>
 
using DoWorkRhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int side, EntityType type, EntitiesFieldData::EntData &data)>
 
- Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
char opType
 
std::string rowFieldName
 
std::string colFieldName
 
FieldSpace sPace
 
- Public Attributes inherited from MoFEM::DataOperator
DoWorkLhsHookFunType doWorkLhsHook
 
DoWorkRhsHookFunType doWorkRhsHook
 
bool sYmm
 If true assume that matrix is symmetric structure. More...
 
std::array< bool, MBMAXTYPE > doEntities
 If true operator is executed for entity. More...
 
booldoVertices
 \deprectaed If false skip vertices More...
 
booldoEdges
 \deprectaed If false skip edges More...
 
booldoQuads
 \deprectaed More...
 
booldoTris
 \deprectaed More...
 
booldoTets
 \deprectaed More...
 
booldoPrisms
 \deprectaed More...
 
- Static Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
static const char *const OpTypeNames []
 
- Protected Types inherited from MoFEM::OpBaseDerivativesBase
using GetOrderFun = boost::function< int()>
 

Detailed Description

Specialisation for calculate directives for scalar base functions.

Template Parameters
<br>

Definition at line 74 of file BaseDerivativesDataOperators.hpp.

Constructor & Destructor Documentation

◆ OpBaseDerivativesNext()

MoFEM::OpBaseDerivativesNext< 1 >::OpBaseDerivativesNext ( int  derivative,
boost::shared_ptr< MatrixDouble base_mass_ptr,
boost::shared_ptr< EntitiesFieldData data_l2,
const FieldApproximationBase  b,
const FieldSpace  s,
int  verb = QUIET,
Sev  sev = Sev::verbose 
)

Definition at line 146 of file BaseDerivativesDataOperators.cpp.

150 : OpBaseDerivativesBase(base_mass_ptr, data_l2, b, s, verb, sev),
151 calcBaseDerivative(derivative) {
152 if (s != H1)
153 doEntities[MBVERTEX] = false;
154}
@ H1
continuous field
Definition: definitions.h:85
std::array< bool, MBMAXTYPE > doEntities
If true operator is executed for entity.
OpBaseDerivativesBase(boost::shared_ptr< MatrixDouble > base_mass_ptr, boost::shared_ptr< EntitiesFieldData > data_l2, const FieldApproximationBase b, const FieldSpace s, int verb=QUIET, Sev sev=Sev::verbose)

Member Function Documentation

◆ doWork()

MoFEMErrorCode MoFEM::OpBaseDerivativesNext< 1 >::doWork ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)
virtual

Operator for linear form, usually to calculate values on right hand side.

Reimplemented from MoFEM::DataOperator.

Reimplemented in MoFEM::OpBaseDerivativesNext< 3 >.

Definition at line 296 of file BaseDerivativesDataOperators.cpp.

297 {
298 return doWorkImpl<1>(side, type, data);
299}

◆ doWorkImpl()

template<int BASE_DIM>
MoFEMErrorCode MoFEM::OpBaseDerivativesNext< 1 >::doWorkImpl ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)
protected

Definition at line 206 of file BaseDerivativesDataOperators.cpp.

207 {
209
210 auto &approx_base = data.getN(base);
211 const auto nb_approx_bases = approx_base.size2() / BASE_DIM;
212
213 if (nb_approx_bases) {
214
215 const auto fe_type = getFEType();
216 const auto nb_integration_pts = approx_base.size1();
217
218 const auto space_dim =
219 data.getDiffN(base).size2() / (BASE_DIM * nb_approx_bases);
220 auto &diff_approx_base = *(data.getNSharedPtr(
221 base, static_cast<BaseDerivatives>(calcBaseDerivative - 1)));
222 int nb_derivatives = BASE_DIM * pow(space_dim, calcBaseDerivative - 1);
223
224 auto &ent_data = dataL2->dataOnEntities[fe_type][0];
225 const int nb_prj_bases = ent_data.getN().size2();
226
227#ifndef NDEBUG
228 if (!baseMassPtr)
229 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
230 "Mass matrix is null pointer");
231#endif
232 auto &nN = *baseMassPtr;
233
234#ifndef NDEBUG
235 if (diff_approx_base.size2() != nb_approx_bases * nb_derivatives) {
236 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
237 "Number of derivatives and basses do not match");
238 }
239 if (ent_data.getN().size1() != nb_integration_pts) {
240 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
241 "Number of integration points is not consistent");
242 }
243 if (nN.size2() != nb_prj_bases) {
244 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
245 "Number of base functions and size of mass matrix does not math");
246 }
247#endif
248
249 nF.resize(nb_approx_bases * nb_derivatives, nb_prj_bases, false);
250 nF.clear();
251
252 auto t_w = getFTensor0IntegrationWeight();
253 // get base function gradient on rows
254
255 auto diff_base_ptr = &*diff_approx_base.data().begin();
256 // loop over integration points
257 for (int gg = 0; gg != nb_integration_pts; ++gg) {
258 // take into account Jacobian
259 const double alpha = t_w;
260
261 for (int r = 0; r != nb_approx_bases * nb_derivatives; ++r) {
262
263 // Rows are base functions
264 auto t_base = ent_data.getFTensor0N(base, gg, 0);
265 for (int rr = 0; rr != nb_prj_bases; ++rr) {
266 nF(r, rr) += alpha * (t_base * (*diff_base_ptr));
267 ++t_base;
268 }
269
270 ++diff_base_ptr;
271 }
272
273 ++t_w; // move to another integration weight
274 }
275
276 for (auto r = 0; r != nb_approx_bases * nb_derivatives; ++r) {
277 ublas::matrix_row<MatrixDouble> mc(nF, r);
278 cholesky_solve(nN, mc, ublas::lower());
279 }
280
281 if (space_dim == 3)
282 CHKERR setBaseImpl<BASE_DIM, 3>(data, ent_data);
283 else if (space_dim == 2)
284 CHKERR setBaseImpl<BASE_DIM, 2>(data, ent_data);
285 // else if (space_dim == 1)
286 // CHKERR setBaseImpl<BASE_DIM, 1>(data, ent_data);
287 else
288 SETERRQ1(PETSC_COMM_SELF, MOFEM_IMPOSSIBLE_CASE,
289 "Space dim can be only 1,2,3 but is %d", space_dim);
290 }
291
293}
void cholesky_solve(const TRIA &L, VEC &x, ublas::lower)
solve system L L^T x = b inplace
Definition: cholesky.hpp:221
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ MOFEM_IMPOSSIBLE_CASE
Definition: definitions.h:35
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
constexpr int BASE_DIM
EntitiesFieldData::EntData::BaseDerivatives BaseDerivatives
int r
Definition: sdf.py:8
EntityType getFEType() const
Get dimension of finite element.
auto getFTensor0IntegrationWeight()
Get integration weights.
boost::shared_ptr< EntitiesFieldData > dataL2
boost::shared_ptr< MatrixDouble > baseMassPtr

◆ setBaseImpl()

template<int BASE_DIM, int SPACE_DIM>
MoFEMErrorCode MoFEM::OpBaseDerivativesNext< 1 >::setBaseImpl ( EntitiesFieldData::EntData data,
EntitiesFieldData::EntData ent_data 
)
protected

Definition at line 158 of file BaseDerivativesDataOperators.cpp.

159 {
161
162 const int nb_gauss_pts = data.getN(base).size1();
163 const int nb_approx_bases = data.getN(base).size2() / BASE_DIM;
164 const int nb_derivatives =
165 BASE_DIM * std::pow(SPACE_DIM, calcBaseDerivative - 1);
166
167 const int nb_prj_bases = ent_data.getN().size2();
168
169 auto &n_diff_shared_ptr = data.getNSharedPtr(
171 if (!n_diff_shared_ptr)
172 n_diff_shared_ptr = boost::make_shared<MatrixDouble>();
173
174 auto &nex_diff_base = *(n_diff_shared_ptr);
175 const int next_nb_derivatives = BASE_DIM * pow(SPACE_DIM, calcBaseDerivative);
176 nex_diff_base.resize(nb_gauss_pts, nb_approx_bases * next_nb_derivatives,
177 false);
178 nex_diff_base.clear();
179
181 auto next_diffs_ptr = &*nex_diff_base.data().begin();
182 auto t_next_diff = getFTensor1FromPtr<SPACE_DIM>(next_diffs_ptr);
183
184 for (int gg = 0; gg != nb_gauss_pts; ++gg) {
185
186 auto ptr = &*nF.data().begin();
187
188 for (auto r = 0; r != nb_approx_bases * nb_derivatives; ++r) {
189
190 auto l2_diff_base = ent_data.getFTensor1DiffN<SPACE_DIM>(base, gg, 0);
191 for (int rr = 0; rr != nb_prj_bases; ++rr) {
192 t_next_diff(i) += l2_diff_base(i) * (*ptr);
193 ++l2_diff_base;
194 ++ptr;
195 }
196
197 ++t_next_diff;
198 }
199 }
200
202}
constexpr int SPACE_DIM
FTensor::Index< 'i', SPACE_DIM > i

Member Data Documentation

◆ calcBaseDerivative

int MoFEM::OpBaseDerivativesNext< 1 >::calcBaseDerivative
protected

Definition at line 86 of file BaseDerivativesDataOperators.hpp.

◆ nF

Definition at line 87 of file BaseDerivativesDataOperators.hpp.


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