MFEM  v4.1.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
bilinearform_ext.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2020, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_BILINEARFORM_EXT
13 #define MFEM_BILINEARFORM_EXT
14 
15 #include "../config/config.hpp"
16 #include "fespace.hpp"
17 #include "../general/device.hpp"
18 
19 namespace mfem
20 {
21 
22 class BilinearForm;
23 class MixedBilinearForm;
24 
25 
26 /** @brief Class extending the BilinearForm class to support the different
27  AssemblyLevel%s. */
29 {
30 protected:
31  BilinearForm *a; ///< Not owned
32 
33 public:
35 
36  virtual MemoryClass GetMemoryClass() const
37  { return Device::GetDeviceMemoryClass(); }
38 
39  /// Get the finite element space prolongation matrix
40  virtual const Operator *GetProlongation() const;
41 
42  /// Get the finite element space restriction matrix
43  virtual const Operator *GetRestriction() const;
44 
45  virtual void Assemble() = 0;
46 
47  virtual void AssembleDiagonal(Vector &diag) const
48  {
49  MFEM_ABORT("AssembleDiagonal not implemented for this assembly level!");
50  }
51 
52  virtual void FormSystemMatrix(const Array<int> &ess_tdof_list,
53  OperatorHandle &A) = 0;
54  virtual void FormLinearSystem(const Array<int> &ess_tdof_list,
55  Vector &x, Vector &b,
56  OperatorHandle &A, Vector &X, Vector &B,
57  int copy_interior = 0) = 0;
58  virtual void Update() = 0;
59 };
60 
61 /// Data and methods for fully-assembled bilinear forms
63 {
64 public:
66  : BilinearFormExtension(form) { }
67 
68  /// TODO
69  void Assemble() {}
70  void FormSystemMatrix(const Array<int> &ess_tdof_list, OperatorHandle &A) {}
71  void FormLinearSystem(const Array<int> &ess_tdof_list,
72  Vector &x, Vector &b,
73  OperatorHandle &A, Vector &X, Vector &B,
74  int copy_interior = 0) {}
75  void Mult(const Vector &x, Vector &y) const {}
76  void MultTranspose(const Vector &x, Vector &y) const {}
77  void Update() {}
79 };
80 
81 /// Data and methods for element-assembled bilinear forms
83 {
84 public:
86  : BilinearFormExtension(form) { }
87 
88  /// TODO
89  void Assemble() {}
90  void FormSystemMatrix(const Array<int> &ess_tdof_list, OperatorHandle &A) {}
91  void FormLinearSystem(const Array<int> &ess_tdof_list,
92  Vector &x, Vector &b,
93  OperatorHandle &A, Vector &X, Vector &B,
94  int copy_interior = 0) {}
95  void Mult(const Vector &x, Vector &y) const {}
96  void MultTranspose(const Vector &x, Vector &y) const {}
97  void Update() {}
99 };
100 
101 /// Data and methods for partially-assembled bilinear forms
103 {
104 protected:
105  const FiniteElementSpace *trialFes, *testFes; // Not owned
106  mutable Vector localX, localY;
109  const Operator *elem_restrict; // Not owned
110  const Operator *int_face_restrict_lex; // Not owned
111  const Operator *bdr_face_restrict_lex; // Not owned
112 
113 public:
115 
117  void Assemble();
118  void AssembleDiagonal(Vector &diag) const;
119  void FormSystemMatrix(const Array<int> &ess_tdof_list, OperatorHandle &A);
120  void FormLinearSystem(const Array<int> &ess_tdof_list,
121  Vector &x, Vector &b,
122  OperatorHandle &A, Vector &X, Vector &B,
123  int copy_interior = 0);
124 
125  void Mult(const Vector &x, Vector &y) const;
126  void MultTranspose(const Vector &x, Vector &y) const;
127  void Update();
128 };
129 
130 
131 /// Data and methods for matrix-free bilinear forms
133 {
134 public:
136  : BilinearFormExtension(form) { }
137 
138  /// TODO
139  void Assemble() {}
140  void FormSystemMatrix(const Array<int> &ess_tdof_list, OperatorHandle &A) {}
141  void FormLinearSystem(const Array<int> &ess_tdof_list,
142  Vector &x, Vector &b,
143  OperatorHandle &A, Vector &X, Vector &B,
144  int copy_interior = 0) {}
145  void Mult(const Vector &x, Vector &y) const {}
146  void MultTranspose(const Vector &x, Vector &y) const {}
147  void Update() {}
149 };
150 
151 /** @brief Class extending the MixedBilinearForm class to support the different
152  AssemblyLevel%s. */
154 {
155 protected:
156  MixedBilinearForm *a; ///< Not owned
157 
158 public:
160 
161  virtual MemoryClass GetMemoryClass() const
162  { return Device::GetMemoryClass(); }
163 
164  /// Get the finite element space prolongation matrix
165  virtual const Operator *GetProlongation() const;
166 
167  /// Get the finite element space restriction matrix
168  virtual const Operator *GetRestriction() const;
169 
170  /// Get the output finite element space restriction matrix
171  virtual const Operator *GetOutputProlongation() const;
172 
173  /// Get the output finite element space restriction matrix
174  virtual const Operator *GetOutputRestriction() const;
175 
176  virtual void Assemble() = 0;
177  virtual void FormRectangularSystemOperator(const Array<int> &trial_tdof_list,
178  const Array<int> &test_tdof_list,
179  OperatorHandle &A) = 0;
180  virtual void FormRectangularLinearSystem(const Array<int> &trial_tdof_list,
181  const Array<int> &test_tdof_list,
182  Vector &x, Vector &b,
183  OperatorHandle &A, Vector &X, Vector &B) = 0;
184 
185  virtual void AddMult(const Vector &x, Vector &y, const double c=1.0) const = 0;
186  virtual void AddMultTranspose(const Vector &x, Vector &y,
187  const double c=1.0) const = 0;
188 
189  virtual void Update() = 0;
190 };
191 
192 /// Data and methods for partially-assembled mixed bilinear forms
194 {
195 protected:
196  const FiniteElementSpace *trialFes, *testFes; // Not owned
198  const Operator *elem_restrict_trial; // Not owned
199  const Operator *elem_restrict_test; // Not owned
200 private:
201  /// Helper function to set up inputs/outputs for Mult or MultTranspose
202  void SetupMultInputs(const Operator *elem_restrict_x,
203  const Vector &x, Vector &localX,
204  const Operator *elem_restrict_y,
205  Vector &y, Vector &localY, const double c) const;
206 
207 public:
209 
210  /// Partial assembly of all internal integrators
211  void Assemble();
212  /**
213  @brief Setup OperatorHandle A to contain constrained linear operator
214 
215  OperatorHandle A contains matrix-free constrained operator formed for RAP
216  system where ess_tdof_list are in trial space and eliminated from
217  "columns" of A.
218  */
219  void FormRectangularSystemOperator(const Array<int> &trial_tdof_list,
220  const Array<int> &test_tdof_list,
221  OperatorHandle &A);
222  /**
223  Setup OperatorHandle A to contain constrained linear operator and
224  eliminate columns corresponding to essential dofs from system,
225  updating RHS B vector with the results.
226  */
227  void FormRectangularLinearSystem(const Array<int> &trial_tdof_list,
228  const Array<int> &test_tdof_list,
229  Vector &x, Vector &b,
230  OperatorHandle &A, Vector &X, Vector &B);
231  /// y = A*x
232  void Mult(const Vector &x, Vector &y) const;
233  /// y += c*A*x
234  void AddMult(const Vector &x, Vector &y, const double c=1.0) const;
235  /// y = A^T*x
236  void MultTranspose(const Vector &x, Vector &y) const;
237  /// y += c*A^T*x
238  void AddMultTranspose(const Vector &x, Vector &y, const double c=1.0) const;
239  /// Update internals for when a new MixedBilinearForm is given to this class
240  void Update();
241 };
242 
243 }
244 
245 #endif
static MemoryClass GetMemoryClass()
(DEPRECATED) Equivalent to GetDeviceMemoryClass().
Definition: device.hpp:261
void FormLinearSystem(const Array< int > &ess_tdof_list, Vector &x, Vector &b, OperatorHandle &A, Vector &X, Vector &B, int copy_interior=0)
void FormRectangularSystemOperator(const Array< int > &trial_tdof_list, const Array< int > &test_tdof_list, OperatorHandle &A)
Setup OperatorHandle A to contain constrained linear operator.
void FormLinearSystem(const Array< int > &ess_tdof_list, Vector &x, Vector &b, OperatorHandle &A, Vector &X, Vector &B, int copy_interior=0)
Data and methods for matrix-free bilinear forms.
const FiniteElementSpace * testFes
void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
MFBilinearFormExtension(BilinearForm *form)
void AddMultTranspose(const Vector &x, Vector &y, const double c=1.0) const
y += c*A^T*x
Pointer to an Operator of a specified type.
Definition: handle.hpp:33
PAMixedBilinearFormExtension(MixedBilinearForm *form)
void MultTranspose(const Vector &x, Vector &y) const
y = A^T*x
virtual void AddMult(const Vector &x, Vector &y, const double c=1.0) const =0
virtual const Operator * GetRestriction() const
Get the finite element space restriction matrix.
virtual const Operator * GetRestriction() const
Get the finite element space restriction matrix.
BilinearFormExtension(BilinearForm *form)
virtual void AddMultTranspose(const Vector &x, Vector &y, const double c=1.0) const =0
Data and methods for partially-assembled bilinear forms.
virtual void FormLinearSystem(const Array< int > &ess_tdof_list, Vector &x, Vector &b, OperatorHandle &A, Vector &X, Vector &B, int copy_interior=0)=0
Class extending the MixedBilinearForm class to support the different AssemblyLevels.
virtual const Operator * GetOutputProlongation() const
Get the output finite element space restriction matrix.
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 ...
virtual const Operator * GetProlongation() const
Get the finite element space prolongation matrix.
void Assemble()
Partial assembly of all internal integrators.
virtual void FormRectangularSystemOperator(const Array< int > &trial_tdof_list, const Array< int > &test_tdof_list, OperatorHandle &A)=0
virtual void AssembleDiagonal(Vector &diag) const
static MemoryClass GetDeviceMemoryClass()
Get the current Device MemoryClass. This is the MemoryClass used by most MFEM device kernels to acces...
Definition: device.hpp:257
Data and methods for fully-assembled bilinear forms.
const FiniteElementSpace * trialFes
double b
Definition: lissajous.cpp:42
BilinearForm * a
Not owned.
virtual void Assemble()=0
void AddMult(const Vector &x, Vector &y, const double c=1.0) const
y += c*A*x
void FormSystemMatrix(const Array< int > &ess_tdof_list, OperatorHandle &A)
Class extending the BilinearForm class to support the different AssemblyLevels.
virtual const Operator * GetProlongation() const
Get the finite element space prolongation matrix.
FABilinearFormExtension(BilinearForm *form)
void FormLinearSystem(const Array< int > &ess_tdof_list, Vector &x, Vector &b, OperatorHandle &A, Vector &X, Vector &B, int copy_interior=0)
void FormRectangularLinearSystem(const Array< int > &trial_tdof_list, const Array< int > &test_tdof_list, Vector &x, Vector &b, OperatorHandle &A, Vector &X, Vector &B)
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 ...
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 ...
void Mult(const Vector &x, Vector &y) const
y = A*x
void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Data and methods for element-assembled bilinear forms.
void FormLinearSystem(const Array< int > &ess_tdof_list, Vector &x, Vector &b, OperatorHandle &A, Vector &X, Vector &B, int copy_interior=0)
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition: fespace.hpp:87
void FormSystemMatrix(const Array< int > &ess_tdof_list, OperatorHandle &A)
EABilinearFormExtension(BilinearForm *form)
void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
MixedBilinearForm * a
Not owned.
virtual const Operator * GetOutputRestriction() const
Get the output finite element space restriction matrix.
void Update()
Update internals for when a new MixedBilinearForm is given to this class.
virtual MemoryClass GetMemoryClass() const
Return the MemoryClass preferred by the Operator.
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 ...
Data and methods for partially-assembled mixed bilinear forms.
void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Vector data type.
Definition: vector.hpp:48
const FiniteElementSpace * trialFes
virtual void FormSystemMatrix(const Array< int > &ess_tdof_list, OperatorHandle &A)=0
const FiniteElementSpace * testFes
void AssembleDiagonal(Vector &diag) const
virtual MemoryClass GetMemoryClass() const
Return the MemoryClass preferred by the Operator.
Abstract operator.
Definition: operator.hpp:24
MixedBilinearFormExtension(MixedBilinearForm *form)
void FormSystemMatrix(const Array< int > &ess_tdof_list, OperatorHandle &A)
void FormSystemMatrix(const Array< int > &ess_tdof_list, OperatorHandle &A)
MemoryClass
Memory classes identify sets of memory types.
Definition: mem_manager.hpp:57
virtual void FormRectangularLinearSystem(const Array< int > &trial_tdof_list, const Array< int > &test_tdof_list, Vector &x, Vector &b, OperatorHandle &A, Vector &X, Vector &B)=0