MFEM  v4.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
operator.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_OPERATOR
13 #define MFEM_OPERATOR
14 
15 #include "vector.hpp"
16 
17 namespace mfem
18 {
19 
20 /// Abstract operator
21 class Operator
22 {
23 protected:
24  int height; ///< Dimension of the output / number of rows in the matrix.
25  int width; ///< Dimension of the input / number of columns in the matrix.
26 
27 public:
28  /// Construct a square Operator with given size s (default 0).
29  explicit Operator(int s = 0) { height = width = s; }
30 
31  /** @brief Construct an Operator with the given height (output size) and
32  width (input size). */
33  Operator(int h, int w) { height = h; width = w; }
34 
35  /// Get the height (size of output) of the Operator. Synonym with NumRows().
36  inline int Height() const { return height; }
37  /** @brief Get the number of rows (size of output) of the Operator. Synonym
38  with Height(). */
39  inline int NumRows() const { return height; }
40 
41  /// Get the width (size of input) of the Operator. Synonym with NumCols().
42  inline int Width() const { return width; }
43  /** @brief Get the number of columns (size of input) of the Operator. Synonym
44  with Width(). */
45  inline int NumCols() const { return width; }
46 
47  /// Return the MemoryClass preferred by the Operator.
48  /** This is the MemoryClass that will be used to access the input and output
49  vectors in the Mult() and MultTranspose() methods.
50 
51  For example, classes using the MFEM_FORALL macro for implementation can
52  return the value returned by Device::GetMemoryClass().
53 
54  The default implementation of this method in class Operator returns
55  MemoryClass::HOST. */
56  virtual MemoryClass GetMemoryClass() const { return MemoryClass::HOST; }
57 
58  /// Operator application: `y=A(x)`.
59  virtual void Mult(const Vector &x, Vector &y) const = 0;
60 
61  /** @brief Action of the transpose operator: `y=A^t(x)`. The default behavior
62  in class Operator is to generate an error. */
63  virtual void MultTranspose(const Vector &x, Vector &y) const
64  { mfem_error("Operator::MultTranspose() is not overloaded!"); }
65 
66  /** @brief Evaluate the gradient operator at the point @a x. The default
67  behavior in class Operator is to generate an error. */
68  virtual Operator &GetGradient(const Vector &x) const
69  {
70  mfem_error("Operator::GetGradient() is not overloaded!");
71  return const_cast<Operator &>(*this);
72  }
73 
74  /** @brief Prolongation operator from linear algebra (linear system) vectors,
75  to input vectors for the operator. `NULL` means identity. */
76  virtual const Operator *GetProlongation() const { return NULL; }
77  /** @brief Restriction operator from input vectors for the operator to linear
78  algebra (linear system) vectors. `NULL` means identity. */
79  virtual const Operator *GetRestriction() const { return NULL; }
80 
81  /** @brief Form a constrained linear system using a matrix-free approach.
82 
83  Assuming square operator, form the operator linear system `A(X)=B`,
84  corresponding to it and the right-hand side @a b, by applying any
85  necessary transformations such as: parallel assembly, conforming
86  constraints for non-conforming AMR and eliminating boundary conditions.
87  @note Static condensation and hybridization are not supported for general
88  operators (cf. the analogous methods BilinearForm::FormLinearSystem() and
89  ParBilinearForm::FormLinearSystem()).
90 
91  The constraints are specified through the prolongation P from
92  GetProlongation(), and restriction R from GetRestriction() methods, which
93  are e.g. available through the (parallel) finite element space of any
94  (parallel) bilinear form operator. We assume that the operator is square,
95  using the same input and output space, so we have: `A(X)=[P^t (*this)
96  P](X)`, `B=P^t(b)`, and `x=P(X)`.
97 
98  The vector @a x must contain the essential boundary condition values.
99  These are eliminated through the ConstrainedOperator class and the vector
100  @a X is initialized by setting its essential entries to the boundary
101  conditions and all other entries to zero (@a copy_interior == 0) or
102  copied from @a x (@a copy_interior != 0).
103 
104  After solving the system `A(X)=B`, the (finite element) solution @a x can
105  be recovered by calling Operator::RecoverFEMSolution() with the same
106  vectors @a X, @a b, and @a x.
107 
108  @note The caller is responsible for destroying the output operator @a A!
109  @note If there are no transformations, @a X simply reuses the data of @a
110  x. */
111  void FormLinearSystem(const Array<int> &ess_tdof_list,
112  Vector &x, Vector &b,
113  Operator* &A, Vector &X, Vector &B,
114  int copy_interior = 0);
115 
116  /** @brief Reconstruct a solution vector @a x (e.g. a GridFunction) from the
117  solution @a X of a constrained linear system obtained from
118  Operator::FormLinearSystem().
119 
120  Call this method after solving a linear system constructed using
121  Operator::FormLinearSystem() to recover the solution as an input vector,
122  @a x, for this Operator (presumably a finite element grid function). This
123  method has identical signature to the analogous method for bilinear
124  forms, though currently @a b is not used in the implementation. */
125  virtual void RecoverFEMSolution(const Vector &X, const Vector &b, Vector &x);
126 
127  /// Prints operator with input size n and output size m in Matlab format.
128  void PrintMatlab(std::ostream & out, int n = 0, int m = 0) const;
129 
130  /// Virtual destructor.
131  virtual ~Operator() { }
132 
133  /// Enumeration defining IDs for some classes derived from Operator.
134  /** This enumeration is primarily used with class OperatorHandle. */
135  enum Type
136  {
137  ANY_TYPE, ///< ID for the base class Operator, i.e. any type.
138  MFEM_SPARSEMAT, ///< ID for class SparseMatrix
139  Hypre_ParCSR, ///< ID for class HypreParMatrix.
140  PETSC_MATAIJ, ///< ID for class PetscParMatrix, MATAIJ format.
141  PETSC_MATIS, ///< ID for class PetscParMatrix, MATIS format.
142  PETSC_MATSHELL, ///< ID for class PetscParMatrix, MATSHELL format.
143  PETSC_MATNEST, ///< ID for class PetscParMatrix, MATNEST format.
144  PETSC_MATHYPRE, ///< ID for class PetscParMatrix, MATHYPRE format.
145  PETSC_MATGENERIC ///< ID for class PetscParMatrix, unspecified format.
146  };
147 
148  /// Return the type ID of the Operator class.
149  /** This method is intentionally non-virtual, so that it returns the ID of
150  the specific pointer or reference type used when calling this method. If
151  not overridden by derived classes, they will automatically use the type ID
152  of the base Operator class, ANY_TYPE. */
153  Type GetType() const { return ANY_TYPE; }
154 };
155 
156 
157 /// Base abstract class for time dependent operators.
158 /** Operator of the form: (x,t) -> f(x,t), where k = f(x,t) generally solves the
159  algebraic equation F(x,k,t) = G(x,t). The functions F and G represent the
160  _implicit_ and _explicit_ parts of the operator, respectively. For explicit
161  operators, F(x,k,t) = k, so f(x,t) = G(x,t).*/
163 {
164 public:
165  enum Type
166  {
167  EXPLICIT, ///< This type assumes F(x,k,t) = k, i.e. k = f(x,t) = G(x,t).
168  IMPLICIT, ///< This is the most general type, no assumptions on F and G.
169  HOMOGENEOUS ///< This type assumes that G(x,t) = 0.
170  };
171 
172 protected:
173  double t; ///< Current time.
174  Type type; ///< Describes the form of the TimeDependentOperator.
175 
176 public:
177  /** @brief Construct a "square" TimeDependentOperator y = f(x,t), where x and
178  y have the same dimension @a n. */
179  explicit TimeDependentOperator(int n = 0, double t_ = 0.0,
180  Type type_ = EXPLICIT)
181  : Operator(n) { t = t_; type = type_; }
182 
183  /** @brief Construct a TimeDependentOperator y = f(x,t), where x and y have
184  dimensions @a w and @a h, respectively. */
185  TimeDependentOperator(int h, int w, double t_ = 0.0, Type type_ = EXPLICIT)
186  : Operator(h, w) { t = t_; type = type_; }
187 
188  /// Read the currently set time.
189  virtual double GetTime() const { return t; }
190 
191  /// Set the current time.
192  virtual void SetTime(const double _t) { t = _t; }
193 
194  /// True if #type is #EXPLICIT.
195  bool isExplicit() const { return (type == EXPLICIT); }
196  /// True if #type is #IMPLICIT or #HOMOGENEOUS.
197  bool isImplicit() const { return !isExplicit(); }
198  /// True if #type is #HOMOGENEOUS.
199  bool isHomogeneous() const { return (type == HOMOGENEOUS); }
200 
201  /** @brief Perform the action of the explicit part of the operator, G:
202  @a y = G(@a x, t) where t is the current time.
203 
204  Presently, this method is used by some PETSc ODE solvers, for more
205  details, see the PETSc Manual. */
206  virtual void ExplicitMult(const Vector &x, Vector &y) const
207  {
208  mfem_error("TimeDependentOperator::ExplicitMult() is not overridden!");
209  }
210 
211  /** @brief Perform the action of the implicit part of the operator, F:
212  @a y = F(@a x, @a k, t) where t is the current time.
213 
214  Presently, this method is used by some PETSc ODE solvers, for more
215  details, see the PETSc Manual.*/
216  virtual void ImplicitMult(const Vector &x, const Vector &k, Vector &y) const
217  {
218  mfem_error("TimeDependentOperator::ImplicitMult() is not overridden!");
219  }
220 
221  /** @brief Perform the action of the operator: @a y = k = f(@a x, t), where
222  k solves the algebraic equation F(@a x, k, t) = G(@a x, t) and t is the
223  current time. */
224  virtual void Mult(const Vector &x, Vector &y) const
225  {
226  mfem_error("TimeDependentOperator::Mult() is not overridden!");
227  }
228 
229  /** @brief Solve the equation: @a k = f(@a x + @a dt @a k, t), for the
230  unknown @a k at the current time t.
231 
232  For general F and G, the equation for @a k becomes:
233  F(@a x + @a dt @a k, @a k, t) = G(@a x + @a dt @a k, t).
234 
235  The input vector @a x corresponds to time index (or cycle) n, while the
236  currently set time, #t, and the result vector @a k correspond to time
237  index n+1. The time step @a dt corresponds to the time interval between
238  cycles n and n+1.
239 
240  This method allows for the abstract implementation of some time
241  integration methods, including diagonal implicit Runge-Kutta (DIRK)
242  methods and the backward Euler method in particular.
243 
244  If not re-implemented, this method simply generates an error. */
245  virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k)
246  {
247  mfem_error("TimeDependentOperator::ImplicitSolve() is not overridden!");
248  }
249 
250  /** @brief Return an Operator representing (dF/dk @a shift + dF/dx) at the
251  given @a x, @a k, and the currently set time.
252 
253  Presently, this method is used by some PETSc ODE solvers, for more
254  details, see the PETSc Manual. */
255  virtual Operator& GetImplicitGradient(const Vector &x, const Vector &k,
256  double shift) const
257  {
258  mfem_error("TimeDependentOperator::GetImplicitGradient() is "
259  "not overridden!");
260  return const_cast<Operator &>(dynamic_cast<const Operator &>(*this));
261  }
262 
263  /** @brief Return an Operator representing dG/dx at the given point @a x and
264  the currently set time.
265 
266  Presently, this method is used by some PETSc ODE solvers, for more
267  details, see the PETSc Manual. */
268  virtual Operator& GetExplicitGradient(const Vector &x) const
269  {
270  mfem_error("TimeDependentOperator::GetExplicitGradient() is "
271  "not overridden!");
272  return const_cast<Operator &>(dynamic_cast<const Operator &>(*this));
273  }
274 
276 };
277 
278 /// Base class for solvers
279 class Solver : public Operator
280 {
281 public:
282  /// If true, use the second argument of Mult() as an initial guess.
284 
285  /** @brief Initialize a square Solver with size @a s.
286 
287  @warning Use a Boolean expression for the second parameter (not an int)
288  to distinguish this call from the general rectangular constructor. */
289  explicit Solver(int s = 0, bool iter_mode = false)
290  : Operator(s) { iterative_mode = iter_mode; }
291 
292  /// Initialize a Solver with height @a h and width @a w.
293  Solver(int h, int w, bool iter_mode = false)
294  : Operator(h, w) { iterative_mode = iter_mode; }
295 
296  /// Set/update the solver for the given operator.
297  virtual void SetOperator(const Operator &op) = 0;
298 };
299 
300 
301 /// Identity Operator I: x -> x.
303 {
304 public:
305  /// Create an identity operator of size @a n.
306  explicit IdentityOperator(int n) : Operator(n) { }
307 
308  /// Operator application
309  virtual void Mult(const Vector &x, Vector &y) const { y = x; }
310 
311  /// Application of the transpose
312  virtual void MultTranspose(const Vector &x, Vector &y) const { y = x; }
313 };
314 
315 
316 /** @brief The transpose of a given operator. Switches the roles of the methods
317  Mult() and MultTranspose(). */
319 {
320 private:
321  const Operator &A;
322 
323 public:
324  /// Construct the transpose of a given operator @a *a.
326  : Operator(a->Width(), a->Height()), A(*a) { }
327 
328  /// Construct the transpose of a given operator @a a.
330  : Operator(a.Width(), a.Height()), A(a) { }
331 
332  /// Operator application. Apply the transpose of the original Operator.
333  virtual void Mult(const Vector &x, Vector &y) const
334  { A.MultTranspose(x, y); }
335 
336  /// Application of the transpose. Apply the original Operator.
337  virtual void MultTranspose(const Vector &x, Vector &y) const
338  { A.Mult(x, y); }
339 };
340 
341 
342 /// General product operator: x -> (A*B)(x) = A(B(x)).
343 class ProductOperator : public Operator
344 {
345  const Operator *A, *B;
346  bool ownA, ownB;
347  mutable Vector z;
348 
349 public:
350  ProductOperator(const Operator *A, const Operator *B, bool ownA, bool ownB);
351 
352  virtual void Mult(const Vector &x, Vector &y) const
353  { B->Mult(x, z); A->Mult(z, y); }
354 
355  virtual void MultTranspose(const Vector &x, Vector &y) const
356  { A->MultTranspose(x, z); B->MultTranspose(z, y); }
357 
358  virtual ~ProductOperator();
359 };
360 
361 
362 /// The operator x -> R*A*P*x constructed through the actions of R^T, A and P
363 class RAPOperator : public Operator
364 {
365 private:
366  const Operator & Rt;
367  const Operator & A;
368  const Operator & P;
369  mutable Vector Px;
370  mutable Vector APx;
371  MemoryClass mem_class;
372 
373 public:
374  /// Construct the RAP operator given R^T, A and P.
375  RAPOperator(const Operator &Rt_, const Operator &A_, const Operator &P_);
376 
377  virtual MemoryClass GetMemoryClass() const { return mem_class; }
378 
379  /// Operator application.
380  virtual void Mult(const Vector & x, Vector & y) const
381  { P.Mult(x, Px); A.Mult(Px, APx); Rt.MultTranspose(APx, y); }
382 
383  /// Application of the transpose.
384  virtual void MultTranspose(const Vector & x, Vector & y) const
385  { Rt.Mult(x, APx); A.MultTranspose(APx, Px); P.MultTranspose(Px, y); }
386 };
387 
388 
389 /// General triple product operator x -> A*B*C*x, with ownership of the factors.
391 {
392  const Operator *A;
393  const Operator *B;
394  const Operator *C;
395  bool ownA, ownB, ownC;
396  mutable Vector t1, t2;
397  MemoryClass mem_class;
398 
399 public:
400  TripleProductOperator(const Operator *A, const Operator *B,
401  const Operator *C, bool ownA, bool ownB, bool ownC);
402 
403  virtual MemoryClass GetMemoryClass() const { return mem_class; }
404 
405  virtual void Mult(const Vector &x, Vector &y) const
406  { C->Mult(x, t1); B->Mult(t1, t2); A->Mult(t2, y); }
407 
408  virtual void MultTranspose(const Vector &x, Vector &y) const
409  { A->MultTranspose(x, t2); B->MultTranspose(t2, t1); C->MultTranspose(t1, y); }
410 
411  virtual ~TripleProductOperator();
412 };
413 
414 
415 /** @brief Square Operator for imposing essential boundary conditions using only
416  the action, Mult(), of a given unconstrained Operator.
417 
418  Square operator constrained by fixing certain entries in the solution to
419  given "essential boundary condition" values. This class is used by the
420  general, matrix-free system formulation of Operator::FormLinearSystem. */
422 {
423 protected:
424  Array<int> constraint_list; ///< List of constrained indices/dofs.
425  Operator *A; ///< The unconstrained Operator.
426  bool own_A; ///< Ownership flag for A.
427  mutable Vector z, w; ///< Auxiliary vectors.
429 
430 public:
431  /** @brief Constructor from a general Operator and a list of essential
432  indices/dofs.
433 
434  Specify the unconstrained operator @a *A and a @a list of indices to
435  constrain, i.e. each entry @a list[i] represents an essential-dof. If the
436  ownership flag @a own_A is true, the operator @a *A will be destroyed
437  when this object is destroyed. */
438  ConstrainedOperator(Operator *A, const Array<int> &list, bool own_A = false);
439 
440  virtual MemoryClass GetMemoryClass() const { return mem_class; }
441 
442  /** @brief Eliminate "essential boundary condition" values specified in @a x
443  from the given right-hand side @a b.
444 
445  Performs the following steps:
446 
447  z = A((0,x_b)); b_i -= z_i; b_b = x_b;
448 
449  where the "_b" subscripts denote the essential (boundary) indices/dofs of
450  the vectors, and "_i" -- the rest of the entries. */
451  void EliminateRHS(const Vector &x, Vector &b) const;
452 
453  /** @brief Constrained operator action.
454 
455  Performs the following steps:
456 
457  z = A((x_i,0)); y_i = z_i; y_b = x_b;
458 
459  where the "_b" subscripts denote the essential (boundary) indices/dofs of
460  the vectors, and "_i" -- the rest of the entries. */
461  virtual void Mult(const Vector &x, Vector &y) const;
462 
463  /// Destructor: destroys the unconstrained Operator, if owned.
464  virtual ~ConstrainedOperator() { if (own_A) { delete A; } }
465 };
466 
467 }
468 
469 #endif
virtual double GetTime() const
Read the currently set time.
Definition: operator.hpp:189
bool isImplicit() const
True if type is IMPLICIT or HOMOGENEOUS.
Definition: operator.hpp:197
bool isHomogeneous() const
True if type is HOMOGENEOUS.
Definition: operator.hpp:199
Solver(int s=0, bool iter_mode=false)
Initialize a square Solver with size s.
Definition: operator.hpp:289
virtual ~ProductOperator()
Definition: operator.cpp:114
Array< int > constraint_list
List of constrained indices/dofs.
Definition: operator.hpp:424
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
Definition: operator.hpp:380
Type type
Describes the form of the TimeDependentOperator.
Definition: operator.hpp:174
Base abstract class for time dependent operators.
Definition: operator.hpp:162
virtual Operator & GetGradient(const Vector &x) const
Evaluate the gradient operator at the point x. The default behavior in class Operator is to generate ...
Definition: operator.hpp:68
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
Definition: operator.hpp:42
virtual void Mult(const Vector &x, Vector &y) const
Constrained operator action.
Definition: operator.cpp:206
virtual void SetTime(const double _t)
Set the current time.
Definition: operator.hpp:192
virtual MemoryClass GetMemoryClass() const
Return the MemoryClass preferred by the Operator.
Definition: operator.hpp:403
virtual void MultTranspose(const Vector &x, Vector &y) const
Application of the transpose.
Definition: operator.hpp:312
ProductOperator(const Operator *A, const Operator *B, bool ownA, bool ownB)
Definition: operator.cpp:104
ID for class PetscParMatrix, MATHYPRE format.
Definition: operator.hpp:144
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
virtual void MultTranspose(const Vector &x, Vector &y) const
Application of the transpose. Apply the original Operator.
Definition: operator.hpp:337
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
Definition: operator.hpp:283
virtual Operator & GetExplicitGradient(const Vector &x) const
Return an Operator representing dG/dx at the given point x and the currently set time.
Definition: operator.hpp:268
virtual MemoryClass GetMemoryClass() const
Return the MemoryClass preferred by the Operator.
Definition: operator.hpp:440
bool own_A
Ownership flag for A.
Definition: operator.hpp:426
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
Definition: operator.hpp:63
Solver(int h, int w, bool iter_mode=false)
Initialize a Solver with height h and width w.
Definition: operator.hpp:293
double t
Current time.
Definition: operator.hpp:173
virtual void Mult(const Vector &x, Vector &y) const
Operator application. Apply the transpose of the original Operator.
Definition: operator.hpp:333
virtual Operator & GetImplicitGradient(const Vector &x, const Vector &k, double shift) const
Return an Operator representing (dF/dk shift + dF/dx) at the given x, k, and the currently set time...
Definition: operator.hpp:255
ID for class SparseMatrix.
Definition: operator.hpp:138
virtual const Operator * GetProlongation() const
Prolongation operator from linear algebra (linear system) vectors, to input vectors for the operator...
Definition: operator.hpp:76
TransposeOperator(const Operator &a)
Construct the transpose of a given operator a.
Definition: operator.hpp:329
virtual void MultTranspose(const Vector &x, Vector &y) const
Application of the transpose.
Definition: operator.hpp:384
General product operator: x -&gt; (A*B)(x) = A(B(x)).
Definition: operator.hpp:343
ID for the base class Operator, i.e. any type.
Definition: operator.hpp:137
virtual MemoryClass GetMemoryClass() const
Return the MemoryClass preferred by the Operator.
Definition: operator.hpp:56
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
Definition: operator.hpp:36
virtual ~ConstrainedOperator()
Destructor: destroys the unconstrained Operator, if owned.
Definition: operator.hpp:464
void mfem_error(const char *msg)
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY.
Definition: error.cpp:146
This type assumes F(x,k,t) = k, i.e. k = f(x,t) = G(x,t).
Definition: operator.hpp:167
ID for class PetscParMatrix, unspecified format.
Definition: operator.hpp:145
TimeDependentOperator(int h, int w, double t_=0.0, Type type_=EXPLICIT)
Construct a TimeDependentOperator y = f(x,t), where x and y have dimensions w and h...
Definition: operator.hpp:185
The operator x -&gt; R*A*P*x constructed through the actions of R^T, A and P.
Definition: operator.hpp:363
ID for class PetscParMatrix, MATNEST format.
Definition: operator.hpp:143
bool isExplicit() const
True if type is EXPLICIT.
Definition: operator.hpp:195
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k)
Solve the equation: k = f(x + dt k, t), for the unknown k at the current time t.
Definition: operator.hpp:245
RAPOperator(const Operator &Rt_, const Operator &A_, const Operator &P_)
Construct the RAP operator given R^T, A and P.
Definition: operator.cpp:121
virtual const Operator * GetRestriction() const
Restriction operator from input vectors for the operator to linear algebra (linear system) vectors...
Definition: operator.hpp:79
This is the most general type, no assumptions on F and G.
Definition: operator.hpp:168
ID for class PetscParMatrix, MATSHELL format.
Definition: operator.hpp:142
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Definition: operator.hpp:405
Operator(int s=0)
Construct a square Operator with given size s (default 0).
Definition: operator.hpp:29
IdentityOperator(int n)
Create an identity operator of size n.
Definition: operator.hpp:306
Type
Enumeration defining IDs for some classes derived from Operator.
Definition: operator.hpp:135
TimeDependentOperator(int n=0, double t_=0.0, Type type_=EXPLICIT)
Construct a &quot;square&quot; TimeDependentOperator y = f(x,t), where x and y have the same dimension n...
Definition: operator.hpp:179
Vector w
Auxiliary vectors.
Definition: operator.hpp:427
virtual void Mult(const Vector &x, Vector &y) const
Perform the action of the operator: y = k = f(x, t), where k solves the algebraic equation F(x...
Definition: operator.hpp:224
virtual void ExplicitMult(const Vector &x, Vector &y) const
Perform the action of the explicit part of the operator, G: y = G(x, t) where t is the current time...
Definition: operator.hpp:206
int NumRows() const
Get the number of rows (size of output) of the Operator. Synonym with Height().
Definition: operator.hpp:39
int NumCols() const
Get the number of columns (size of input) of the Operator. Synonym with Width().
Definition: operator.hpp:45
void FormLinearSystem(const Array< int > &ess_tdof_list, Vector &x, Vector &b, Operator *&A, Vector &X, Vector &B, int copy_interior=0)
Form a constrained linear system using a matrix-free approach.
Definition: operator.cpp:23
The transpose of a given operator. Switches the roles of the methods Mult() and MultTranspose().
Definition: operator.hpp:318
Type GetType() const
Return the type ID of the Operator class.
Definition: operator.hpp:153
virtual void RecoverFEMSolution(const Vector &X, const Vector &b, Vector &x)
Reconstruct a solution vector x (e.g. a GridFunction) from the solution X of a constrained linear sys...
Definition: operator.cpp:59
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
Definition: operator.hpp:355
int height
Dimension of the output / number of rows in the matrix.
Definition: operator.hpp:24
This type assumes that G(x,t) = 0.
Definition: operator.hpp:169
Host memory; using new[] and delete[].
void EliminateRHS(const Vector &x, Vector &b) const
Eliminate &quot;essential boundary condition&quot; values specified in x from the given right-hand side b...
Definition: operator.cpp:180
void PrintMatlab(std::ostream &out, int n=0, int m=0) const
Prints operator with input size n and output size m in Matlab format.
Definition: operator.cpp:78
ID for class PetscParMatrix, MATAIJ format.
Definition: operator.hpp:140
General triple product operator x -&gt; A*B*C*x, with ownership of the factors.
Definition: operator.hpp:390
ConstrainedOperator(Operator *A, const Array< int > &list, bool own_A=false)
Constructor from a general Operator and a list of essential indices/dofs.
Definition: operator.cpp:167
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
Definition: operator.hpp:309
Operator(int h, int w)
Construct an Operator with the given height (output size) and width (input size). ...
Definition: operator.hpp:33
TripleProductOperator(const Operator *A, const Operator *B, const Operator *C, bool ownA, bool ownB, bool ownC)
Definition: operator.cpp:139
virtual void SetOperator(const Operator &op)=0
Set/update the solver for the given operator.
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Definition: operator.hpp:352
Vector data type.
Definition: vector.hpp:48
Identity Operator I: x -&gt; x.
Definition: operator.hpp:302
ID for class HypreParMatrix.
Definition: operator.hpp:139
TransposeOperator(const Operator *a)
Construct the transpose of a given operator *a.
Definition: operator.hpp:325
Base class for solvers.
Definition: operator.hpp:279
Operator * A
The unconstrained Operator.
Definition: operator.hpp:425
Square Operator for imposing essential boundary conditions using only the action, Mult()...
Definition: operator.hpp:421
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Definition: globals.hpp:64
Abstract operator.
Definition: operator.hpp:21
virtual ~Operator()
Virtual destructor.
Definition: operator.hpp:131
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
Definition: operator.hpp:408
ID for class PetscParMatrix, MATIS format.
Definition: operator.hpp:141
MemoryClass
Memory classes identify subsets of memory types.
Definition: mem_manager.hpp:40
int width
Dimension of the input / number of columns in the matrix.
Definition: operator.hpp:25
virtual void ImplicitMult(const Vector &x, const Vector &k, Vector &y) const
Perform the action of the implicit part of the operator, F: y = F(x, k, t) where t is the current tim...
Definition: operator.hpp:216
virtual MemoryClass GetMemoryClass() const
Return the MemoryClass preferred by the Operator.
Definition: operator.hpp:377