IFEM  90A354
GlbL2projector.h
Go to the documentation of this file.
1 // $Id$
2 //==============================================================================
12 //==============================================================================
13 
14 #ifndef _GLB_L2_PROJECTOR_H
15 #define _GLB_L2_PROJECTOR_H
16 
17 #include "Integrand.h"
18 #include "LinAlgenums.h"
19 #include "MatVec.h"
20 
21 class ASMbase;
22 class IntegrandBase;
23 class FunctionBase;
24 class LinSolParams;
25 class SparseMatrix;
26 class StdVector;
27 class ProcessAdm;
28 
29 typedef std::vector<int> IntVec;
30 typedef std::vector<size_t> uIntVec;
31 typedef std::vector<FunctionBase*> FunctionVec;
32 
33 
39 {
40 public:
44  L2Integrand(const ASMbase& patch, const ProcessAdm& adm)
45  : m_patch(patch), m_adm(adm) {}
46 
50  virtual bool evaluate(Matrix& sField, const RealArray* gpar) const = 0;
51 
53  virtual size_t dim() const = 0;
54 
56  const ProcessAdm& getAdm() const { return m_adm; }
57 
58 protected:
59  const ASMbase& m_patch;
60  const ProcessAdm& m_adm;
61 };
62 
63 
69 {
70 public:
75  L2ProbIntegrand(const ASMbase& patch,
76  const IntegrandBase& itg,
77  const ProcessAdm& adm);
78 
82  bool evaluate(Matrix& sField, const RealArray* gpar) const override;
83 
85  size_t dim() const override;
86 
87 private:
89 };
90 
91 
97 {
98 public:
103  L2FuncIntegrand(const ASMbase& patch,
104  const FunctionBase& func,
105  const ProcessAdm& adm);
106 
110  bool evaluate(Matrix& sField, const RealArray* gpar) const override;
111 
113  size_t dim() const override;
114 
115 private:
117 };
118 
119 
124 class GlbL2 : public Integrand
125 {
126 public:
129 
133  GlbL2(IntegrandBase* p, size_t n);
137  GlbL2(FunctionBase* f, size_t n);
141  GlbL2(const FunctionVec& f, size_t n);
143  virtual ~GlbL2();
144 
146  virtual SIM::SolutionMode getMode(bool) const { return SIM::RECOVERY; }
148  virtual int getIntegrandType() const;
149 
155  virtual LocalIntegral* getLocalIntegral(size_t nen, size_t iEl,
156  bool neumann) const;
157 
164  virtual bool initElement(const IntVec& MNPC, const FiniteElement& fe,
165  const Vec3& X0, size_t nPt,
166  LocalIntegral& elmInt);
173  virtual bool initElement(const IntVec& MNPC1,
174  const MxFiniteElement& fe,
175  const uIntVec& elem_sizes,
176  const uIntVec& basis_sizes,
177  LocalIntegral& elmInt);
178 
180  virtual bool initElement(const IntVec& MNPC1,
181  const uIntVec& elem_sizes,
182  const uIntVec& basis_sizes,
183  LocalIntegral& elmInt) { return false; }
185  virtual bool initElement(const IntVec&, LocalIntegral&) { return false; }
187  virtual bool initElementBou(const IntVec&, LocalIntegral&) { return false; }
189  virtual bool initElementBou(const IntVec&, const uIntVec&, const uIntVec&,
190  LocalIntegral&) { return false; }
191 
192  using Integrand::evalInt;
197  virtual bool evalInt(LocalIntegral& elmInt,
198  const FiniteElement& fe, const Vec3& X) const;
199 
200  using Integrand::evalIntMx;
205  virtual bool evalIntMx(LocalIntegral& elmInt, const MxFiniteElement& fe,
206  const Vec3& X) const;
207 
211  void preAssemble(const std::vector<IntVec>& MMNPC, size_t nel);
212 
215  bool solve(Matrix& sField);
218  bool solve(const std::vector<Matrix*>& sField);
219 
220 private:
222  void allocate(size_t n);
223 
224 public:
225  mutable SparseMatrix* pA;
226  mutable StdVector* pB;
227 
228 private:
231  size_t nrhs;
232 };
233 
234 #endif
std::vector< int > IntVec
General integer vector.
Definition: ASMbase.h:25
std::vector< int > IntVec
Vector of integers.
Definition: GlbL2projector.h:27
std::vector< FunctionBase * > FunctionVec
Vector of functions.
Definition: GlbL2projector.h:31
std::vector< size_t > uIntVec
Vector of unsigned integers.
Definition: GlbL2projector.h:30
std::vector< Real > RealArray
A real-valued array without algebraic operations.
Definition: ImmersedBoundaries.h:29
Abstract interface for classes representing FEM integrands.
Various enums for linear algebra scope.
Global algebraic operations on index 1-based matrices and vectors.
Base class for spline-based finite element (FE) assembly drivers.
Definition: ASMbase.h:70
Class representing a finite element.
Definition: FiniteElement.h:29
Base class for unary spatial functions of arbitrary result type.
Definition: Function.h:147
General integrand for L2-projection of secondary solutions.
Definition: GlbL2projector.h:125
FunctionVec functions
Explicit functions to L2-project.
Definition: GlbL2projector.h:230
virtual LocalIntegral * getLocalIntegral(size_t nen, size_t iEl, bool neumann=false) const=0
Returns a local integral contribution object for the given element.
virtual bool initElementBou(const IntVec &, const uIntVec &, const uIntVec &, LocalIntegral &)
Dummy implementation.
Definition: GlbL2projector.h:189
virtual bool evalInt(LocalIntegral &elmInt, const FiniteElement &fe, const TimeDomain &time, const Vec3 &X) const
Evaluates the integrand at an interior point.
Definition: Integrand.h:209
bool solve(Matrix &sField)
Solves the projection equation system and evaluates nodal values.
Definition: GlbL2projector.C:394
virtual bool evalIntMx(LocalIntegral &elmInt, const MxFiniteElement &fe, const TimeDomain &time, const Vec3 &X) const
Evaluates the integrand at an interior point.
Definition: Integrand.h:224
StdVector * pB
Right-hand-side vectors of the L2-projection.
Definition: GlbL2projector.h:226
virtual SIM::SolutionMode getMode(bool) const
Returns current solution mode.
Definition: GlbL2projector.h:146
IntegrandBase * problem
The main problem integrand.
Definition: GlbL2projector.h:229
virtual bool initElementBou(const IntVec &, LocalIntegral &)
Dummy implementation.
Definition: GlbL2projector.h:187
void allocate(size_t n)
Allocates the system L2-projection matrices.
Definition: GlbL2projector.C:273
static LinSolParams * SolverParams
Linear solver params projection.
Definition: GlbL2projector.h:128
virtual bool initElement(const IntVec &, LocalIntegral &)
Dummy implementation.
Definition: GlbL2projector.h:185
SparseMatrix * pA
Left-hand-side matrix of the L2-projection.
Definition: GlbL2projector.h:225
virtual bool initElement(const IntVec &MNPC1, const uIntVec &elem_sizes, const uIntVec &basis_sizes, LocalIntegral &elmInt)
Dummy implementation.
Definition: GlbL2projector.h:180
virtual ~GlbL2()
The destructor frees the system matrix and system vector.
Definition: GlbL2projector.C:266
virtual int getIntegrandType() const
Defines which FE quantities are needed by the integrand.
Definition: GlbL2projector.C:281
size_t nrhs
Number of right-hand-size vectors.
Definition: GlbL2projector.h:231
static LinAlg::MatrixType MatrixType
Matrix type for projection.
Definition: GlbL2projector.h:127
virtual bool initElement(const IntVec &MNPC, const FiniteElement &fe, const Vec3 &X0, size_t nPt, LocalIntegral &elmInt)
Initializes current element for numerical integration.
Definition: GlbL2projector.C:302
GlbL2(IntegrandBase *p, size_t n)
The constructor initializes the projection matrices.
Definition: GlbL2projector.C:243
void preAssemble(const std::vector< IntVec > &MMNPC, size_t nel)
Pre-computes the sparsity pattern of the projection matrix A.
Definition: GlbL2projector.C:388
Base class representing a system level integrated quantity.
Definition: IntegrandBase.h:42
Abstract base class representing a system level integrated quantity.
Definition: Integrand.h:44
virtual LocalIntegral * getLocalIntegral(size_t nen, size_t iEl, bool neumann=false) const =0
Returns a local integral contribution object for the given element.
virtual bool evalInt(LocalIntegral &elmInt, const FiniteElement &fe, const TimeDomain &time, const Vec3 &X) const
Evaluates the integrand at an interior point.
Definition: Integrand.h:209
virtual bool evalIntMx(LocalIntegral &elmInt, const MxFiniteElement &fe, const TimeDomain &time, const Vec3 &X) const
Evaluates the integrand at an interior point.
Definition: Integrand.h:224
Evaluation class for functions.
Definition: GlbL2projector.h:97
bool evaluate(Matrix &sField, const RealArray *gpar) const override
Evaluates the function in a set of points.
Definition: GlbL2projector.C:133
L2FuncIntegrand(const ASMbase &patch, const FunctionBase &func, const ProcessAdm &adm)
The constructor initializes the function reference.
Definition: GlbL2projector.C:125
const FunctionBase & m_func
Reference to function.
Definition: GlbL2projector.h:116
size_t dim() const override
Returns number of function components.
Definition: GlbL2projector.C:163
Abstract class for evaluating integrand or function.
Definition: GlbL2projector.h:39
virtual size_t dim() const =0
Returns dimension of entity to evaluate.
const ProcessAdm & getAdm() const
Returns a const-ref to associated process administrator.
Definition: GlbL2projector.h:56
const ASMbase & m_patch
Reference to ASM holding geometry.
Definition: GlbL2projector.h:59
L2Integrand(const ASMbase &patch, const ProcessAdm &adm)
The constructor initializes the patch reference.
Definition: GlbL2projector.h:44
const ProcessAdm & m_adm
Reference to process administrator.
Definition: GlbL2projector.h:60
virtual bool evaluate(Matrix &sField, const RealArray *gpar) const =0
Evaluates the entity in a set of points.
Evaluation class for secondary solutions of an integrand.
Definition: GlbL2projector.h:69
bool evaluate(Matrix &sField, const RealArray *gpar) const override
Evaluates the secondary solutions in a set of points.
Definition: GlbL2projector.C:113
L2ProbIntegrand(const ASMbase &patch, const IntegrandBase &itg, const ProcessAdm &adm)
The constructor initializes the integrand reference.
Definition: GlbL2projector.C:105
size_t dim() const override
Returns number of secondary solutions.
Definition: GlbL2projector.C:119
const IntegrandBase & m_itg
Reference to integrand.
Definition: GlbL2projector.h:88
Class for linear solver parameters.
Definition: LinSolParams.h:67
Abstract base class representing an element level integrated quantity.
Definition: LocalIntegral.h:25
Class representing a mixed finite element.
Definition: FiniteElement.h:115
Class for administration of MPI processes in IFEM library.
Definition: ProcessAdm.h:33
Class for representing a system matrix on an unstructured sparse form.
Definition: SparseMatrix.h:38
Standard system vector stored as a single continuous array.
Definition: SystemMatrix.h:124
Simple class for representing a point in 3D space.
Definition: Vec3.h:27
MatrixType
The available system matrix formats and associated solvers.
Definition: LinAlgenums.h:22
SolutionMode
Enum defining the various solution modes that may occur.
Definition: SIMenums.h:31