v0.9.0
JacobiPolynomial.cpp
Go to the documentation of this file.
1 /** \file legendrepolynomial.cpp
2  * \brief implementation of multi-grid solver for p- adaptivity
3  *
4  * MoFEM is free software: you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the
6  * Free Software Foundation, either version 3 of the License, or (at your
7  * option) any later version.
8  *
9  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12  * License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
16  */
17 
18 namespace MoFEM {
19 
21  const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const {
23  *iface = NULL;
24  if (uuid == IDD_JACOBI_BASE_FUNCTION) {
25  *iface = const_cast<JacobiPolynomialCtx *>(this);
27  } else {
28  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY, "wrong interference");
29  }
31  CHKERRG(ierr);
33 }
34 
37  BaseFunctionUnknownInterface **iface) const {
39  *iface = NULL;
40  if (uuid == IDD_JACOBI_BASE_FUNCTION) {
41  *iface = const_cast<JacobiPolynomial *>(this);
43  } else {
44  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY, "wrong interference");
45  }
46  ierr = BaseFunction::query_interface(uuid, iface);
47  CHKERRG(ierr);
49 }
50 
51 template <class TYPE>
53  TYPE *ctx) {
55  ctx->baseFunPtr->resize(pts_x.size2(), ctx->P + 1, false);
56  ctx->baseDiffFunPtr->resize(pts_x.size2(), ctx->dIm * (ctx->P + 1), false);
57  if (pts_x.size1() != pts_t.size1() || pts_x.size2() != pts_t.size2()) {
58  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
59  "Inconsistent size of arguments");
60  }
61  double *l = NULL;
62  double *diff_l = NULL;
63  for (unsigned int gg = 0; gg < pts_x.size2(); gg++) {
64  if (ctx->baseFunPtr)
65  l = &((*ctx->baseFunPtr)(gg, 0));
66  if (ctx->baseDiffFunPtr)
67  diff_l = &((*ctx->baseDiffFunPtr)(gg, 0));
68  ierr = (ctx->basePolynomialsType1)(ctx->P, ctx->aLpha, pts_x(0, gg),
69  pts_t(0, gg), ctx->diffX, ctx->diffT, l,
70  diff_l, ctx->dIm);
71  CHKERRG(ierr);
72  }
74 }
75 
78  boost::shared_ptr<BaseFunctionCtx> ctx_ptr) {
81  CHKERR ctx_ptr->query_interface(IDD_JACOBI_BASE_FUNCTION, &iface);
82  JacobiPolynomialCtx *ctx = reinterpret_cast<JacobiPolynomialCtx *>(iface);
83  CHKERR get_value(pts_x, pts_t, ctx);
85 }
86 
88  const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const {
90  *iface = NULL;
92  *iface = const_cast<IntegratedJacobiPolynomialCtx *>(this);
94  } else {
95  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY, "wrong interference");
96  }
98  CHKERRG(ierr);
100 }
101 
103  const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const {
105  *iface = NULL;
107  *iface = const_cast<IntegratedJacobiPolynomial *>(this);
109  } else {
110  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY, "wrong interference");
111  }
112  ierr = BaseFunction::query_interface(uuid, iface);
113  CHKERRG(ierr);
115 }
116 
118  MatrixDouble &pts_x, MatrixDouble &pts_t,
119  boost::shared_ptr<BaseFunctionCtx> ctx_ptr) {
122  CHKERR ctx_ptr->query_interface(IDD_INTEGRATED_JACOBI_BASE_FUNCTION, &iface);
124  reinterpret_cast<IntegratedJacobiPolynomialCtx *>(iface);
125  CHKERR get_value(pts_x, pts_t, ctx);
127 }
128 
129 } // namespace MoFEM
static const MOFEMuuid IDD_INTEGRATED_JACOBI_BASE_FUNCTION
MoFEMErrorCode getValue(MatrixDouble &pts_x, MatrixDouble &pts_t, boost::shared_ptr< BaseFunctionCtx > ctx_ptr)
MoFEM interface unique ID.
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, MoFEM::BaseFunctionUnknownInterface **iface) const
ublas::matrix< double, ublas::row_major, DoubleAllocator > MatrixDouble
Definition: Types.hpp:74
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:544
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
Class used to give arguments to Legendre base functions.
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
static const MOFEMuuid IDD_JACOBI_BASE_FUNCTION
MoFEMErrorCode getValue(MatrixDouble &pts_x, MatrixDouble &pts_t, boost::shared_ptr< BaseFunctionCtx > ctx_ptr)
#define CHKERR
Inline error check.
Definition: definitions.h:596
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407
static MoFEMErrorCode get_value(MatrixDouble &pts_x, MatrixDouble &pts_t, TYPE *ctx)
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const