MFEM  v3.4
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
complex_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_COMPLEX_OPERATOR
13 #define MFEM_COMPLEX_OPERATOR
14 
15 #include "operator.hpp"
16 #include "sparsemat.hpp"
17 
18 namespace mfem
19 {
20 
21 /** @brief Mimic the action of a complex operator using two real operators.
22 
23  This operator requires vectors that are twice the length of its internally
24  stored real operators, Op_Real and Op_Imag. It is assumed that these vectors
25  store the real part of the vector first followed by its imaginary part.
26 
27  ComplexOperator allows one to choose a convention upon construction, which
28  facilitates symmetry.
29 
30  Matrix-vector products are then computed as:
31 
32  1. When Convention::HERMITIAN is used (default)
33  / y_r \ / Op_r -Op_i \ / x_r \
34  | | = | | | |
35  \ y_i / \ Op_i Op_r / \ x_i /
36 
37  2. When Convention::BLOCK_SYMMETRIC is used
38  / y_r \ / Op_r -Op_i \ / x_r \
39  | | = | | | |
40  \-y_i / \-Op_i -Op_r / \ x_i /
41 
42  Either convention can be used with a given complex operator,
43  however, each of them is best suited for certain classes of
44  problems. For example:
45 
46  1. Convention::HERMITIAN, is well suited for Hermitian operators,
47  i.e. operators where the real part is symmetric and the imaginary part of
48  the operator is anti-symmetric, hence the name. In such cases the resulting
49  2 x 2 operator will be symmetric.
50 
51  2. Convention::BLOCK_SYMMETRIC, is well suited for operators where both the
52  real and imaginary parts are symmetric. In this case the resulting 2 x 2
53  operator will again be symmetric. Such operators are common when studying
54  damped oscillations, for example.
55 
56  Note: this class cannot be used to represent a general nonlinear complex
57  operator.
58  */
59 class ComplexOperator : public Operator
60 {
61 public:
63  {
64  HERMITIAN, ///< Native convention for Hermitian operators
65  BLOCK_SYMMETRIC ///< Alternate convention for damping operators
66  };
67 
68  /** @brief Constructs complex operator object
69 
70  Note that either @p Op_Real or @p Op_Imag can be NULL,
71  thus eliminating their action (see documentation of the
72  class for more details).
73 
74  In case ownership of the passed operator is transferred
75  to this class through @p ownReal and @p ownImag,
76  the operators will be explicitly destroyed at the end
77  of the life of this object.
78  */
79  ComplexOperator(Operator * Op_Real, Operator * Op_Imag,
80  bool ownReal, bool ownImag,
81  Convention convention = HERMITIAN);
82 
83  virtual ~ComplexOperator();
84 
85  virtual void Mult(const Vector &x, Vector &y) const;
86  virtual void MultTranspose(const Vector &x, Vector &y) const;
87 
88 protected:
89  // Let this be hidden from the public interface since the implementation
90  // depends on internal members
91  void Mult(const Vector &x_r, const Vector &x_i,
92  Vector &y_r, Vector &y_i) const;
93  void MultTranspose(const Vector &x_r, const Vector &x_i,
94  Vector &y_r, Vector &y_i) const;
95 
96 protected:
99 
100  bool ownReal_;
101  bool ownImag_;
102 
104 
105  mutable Vector x_r_, x_i_, y_r_, y_i_;
106  mutable Vector *u_, *v_;
107 };
108 
109 
110 /** @brief Specialization of the ComplexOperator built from a pair of Sparse
111  Matrices.
112 
113  The purpose of this specialization is to construct a single SparseMatrix
114  object which is equivalent to the 2x2 block system that the ComplexOperator
115  mimics. The resulting SparseMatrix can then be passed along to solvers which
116  require access to the CSR matrix data such as SuperLU, STRUMPACK, or similar
117  sparse linear solvers.
118 
119  See ComplexOperator documentation in operator.hpp for more information.
120  */
122 {
123 public:
125  bool ownReal, bool ownImag,
126  Convention convention = HERMITIAN)
127  : ComplexOperator(A_Real, A_Imag, ownReal, ownImag, convention)
128  {}
129 
130  SparseMatrix * GetSystemMatrix() const;
131 };
132 
133 }
134 
135 #endif
Mimic the action of a complex operator using two real operators.
ComplexSparseMatrix(SparseMatrix *A_Real, SparseMatrix *A_Imag, bool ownReal, bool ownImag, Convention convention=HERMITIAN)
Alternate convention for damping operators.
ComplexOperator(Operator *Op_Real, Operator *Op_Imag, bool ownReal, bool ownImag, Convention convention=HERMITIAN)
Constructs complex operator object.
Data type sparse matrix.
Definition: sparsemat.hpp:38
SparseMatrix * GetSystemMatrix() const
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Specialization of the ComplexOperator built from a pair of Sparse Matrices.
Native convention for Hermitian operators.
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 ...
Vector data type.
Definition: vector.hpp:48
Abstract operator.
Definition: operator.hpp:21