v0.9.0
LobattoPolynomial.cpp
Go to the documentation of this file.
1 /** \file LobattoPolynomial.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 {
22 
24  *iface = NULL;
25  if (uuid == IDD_LOBATTO_BASE_FUNCTION) {
26  *iface = const_cast<LobattoPolynomialCtx *>(this);
28  } else {
29  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY, "wrong interference");
30  }
32  CHKERRG(ierr);
34 }
35 
38  BaseFunctionUnknownInterface **iface) const {
39 
41  *iface = NULL;
42  if (uuid == IDD_LOBATTO_BASE_FUNCTION) {
43  *iface = const_cast<LobattoPolynomial *>(this);
45  } else {
46  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY, "wrong interference");
47  }
49  CHKERRG(ierr);
51 }
52 
55  boost::shared_ptr<BaseFunctionCtx> ctx_ptr) {
56 
59  ierr = ctx_ptr->query_interface(IDD_LOBATTO_BASE_FUNCTION, &iface);
60  CHKERRG(ierr);
61  LobattoPolynomialCtx *ctx = reinterpret_cast<LobattoPolynomialCtx *>(iface);
62  // Polynomial order start from 2nd order
63  ctx->baseFunPtr->resize(pts.size2(), ctx->P + 1 - 2, false);
64  ctx->baseDiffFunPtr->resize(pts.size2(), ctx->dIm * (ctx->P + 1 - 2), false);
65  double *l = NULL;
66  double *diff_l = NULL;
67  for (unsigned int gg = 0; gg < pts.size2(); gg++) {
68  if (ctx->baseFunPtr)
69  l = &((*ctx->baseFunPtr)(gg, 0));
70  if (ctx->baseDiffFunPtr)
71  diff_l = &((*ctx->baseDiffFunPtr)(gg, 0));
72  ierr = (ctx->basePolynomialsType0)(ctx->P, pts(0, gg), ctx->diffS, l,
73  diff_l, ctx->dIm);
74  CHKERRG(ierr);
75  }
77 }
78 
80  const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const {
81 
83  *iface = NULL;
84  if (uuid == IDD_KERNEL_BASE_FUNCTION) {
85  *iface = const_cast<KernelLobattoPolynomialCtx *>(this);
87  } else {
88  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY, "wrong interference");
89  }
91  CHKERRG(ierr);
93 }
94 
96  const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const {
97 
99  *iface = NULL;
100  if (uuid == IDD_KERNEL_BASE_FUNCTION) {
101  *iface = const_cast<KernelLobattoPolynomial *>(this);
103  } else {
104  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY, "wrong interference");
105  }
107  CHKERRG(ierr);
109 }
110 
113  boost::shared_ptr<BaseFunctionCtx> ctx_ptr) {
114 
117  ierr = ctx_ptr->query_interface(IDD_KERNEL_BASE_FUNCTION, &iface);
118  CHKERRG(ierr);
119  LobattoPolynomialCtx *ctx = reinterpret_cast<LobattoPolynomialCtx *>(iface);
120  ctx->baseFunPtr->resize(pts.size2(), ctx->P + 1, false);
121  ctx->baseDiffFunPtr->resize(pts.size2(), ctx->dIm * (ctx->P + 1), false);
122  double *l = NULL;
123  double *diff_l = NULL;
124  for (unsigned int gg = 0; gg < pts.size2(); gg++) {
125  if (ctx->baseFunPtr)
126  l = &((*ctx->baseFunPtr)(gg, 0));
127  if (ctx->baseDiffFunPtr)
128  diff_l = &((*ctx->baseDiffFunPtr)(gg, 0));
129  ierr = (ctx->basePolynomialsType0)(ctx->P, pts(0, gg), ctx->diffS, l,
130  diff_l, ctx->dIm);
131  CHKERRG(ierr);
132  }
134 }
135 
136 } // namespace MoFEM
PetscErrorCode(* basePolynomialsType0)(int p, double s, double *diff_s, double *L, double *diffL, const int dim)
MoFEM interface unique ID.
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const
boost::shared_ptr< MatrixDouble > baseFunPtr
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
ublas::matrix< double, ublas::row_major, DoubleAllocator > MatrixDouble
Definition: Types.hpp:74
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:544
Class used to give arguments to Lobatto base functions.
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, BaseFunctionUnknownInterface **iface) const
MoFEMErrorCode getValue(MatrixDouble &pts, boost::shared_ptr< BaseFunctionCtx > ctx_ptr)
MoFEMErrorCode getValue(MatrixDouble &pts, boost::shared_ptr< BaseFunctionCtx > ctx_ptr)
static const MOFEMuuid IDD_LOBATTO_BASE_FUNCTION
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
boost::shared_ptr< MatrixDouble > baseDiffFunPtr
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
static const MOFEMuuid IDD_KERNEL_BASE_FUNCTION