MFEM  v3.4
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
pnonlinearform.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_PNONLINEARFORM
13 #define MFEM_PNONLINEARFORM
14 
15 #include "../config/config.hpp"
16 
17 #ifdef MFEM_USE_MPI
18 
19 #include "pgridfunc.hpp"
20 #include "nonlinearform.hpp"
21 
22 namespace mfem
23 {
24 
25 /// Parallel non-linear operator on the true dofs
27 {
28 protected:
29  mutable ParGridFunction X, Y;
31 
32 public:
34 
36  { return (ParFiniteElementSpace *)fes; }
37 
38  /// Compute the energy corresponding to the state @a x.
39  /** In general, @a x may have non-homogeneous essential boundary values.
40 
41  The state @a x must be a "GridFunction size" vector, i.e. its size must
42  be fes->GetVSize(). */
43  double GetParGridFunctionEnergy(const Vector &x) const;
44 
45  /// Compute the energy of a ParGridFunction
46  double GetEnergy(const ParGridFunction &x) const
47  { return GetParGridFunctionEnergy(x); }
48 
49  virtual double GetEnergy(const Vector &x) const
50  { return GetParGridFunctionEnergy(Prolongate(x)); }
51 
52  virtual void Mult(const Vector &x, Vector &y) const;
53 
54  /// Return the local gradient matrix for the given true-dof vector x.
55  /** The returned matrix does NOT have any boundary conditions imposed. */
56  const SparseMatrix &GetLocalGradient(const Vector &x) const;
57 
58  virtual Operator &GetGradient(const Vector &x) const;
59 
60  /// Set the operator type id for the parallel gradient matrix/operator.
62 
63  /** @brief Update the ParNonlinearForm to propagate updates of the associated
64  parallel FE space. */
65  /** After calling this method, the essential boundary conditions need to be
66  set again. */
67  virtual void Update();
68 
69  virtual ~ParNonlinearForm() { }
70 };
71 
72 
73 /** @brief A class representing a general parallel block nonlinear operator
74  defined on the Cartesian product of multiple ParFiniteElementSpace%s. */
75 /** The ParBlockNonlinearForm takes as input, and returns as output, vectors on
76  the true dofs. */
78 {
79 protected:
83 
84 public:
85  /// Construct an empty ParBlockNonlinearForm. Initialize with SetParSpaces().
87 
88  /** @brief Construct a ParBlockNonlinearForm on the given set of
89  ParFiniteElementSpace%s. */
91 
92  /// Return the @a k-th parallel FE space of the ParBlockNonlinearForm.
94  /** @brief Return the @a k-th parallel FE space of the ParBlockNonlinearForm
95  (const version). */
96  const ParFiniteElementSpace *ParFESpace(int k) const;
97 
98  /** @brief After a call to SetParSpaces(), the essential b.c. and the
99  gradient-type (if different from the default) must be set again. */
101 
102  // Here, rhs is a true dof vector
103  virtual void SetEssentialBC(const Array<Array<int> *>&bdr_attr_is_ess,
104  Array<Vector *> &rhs);
105 
106  virtual void Mult(const Vector &x, Vector &y) const;
107 
108  /// Return the local block gradient matrix for the given true-dof vector x
109  const BlockOperator &GetLocalGradient(const Vector &x) const;
110 
111  virtual BlockOperator &GetGradient(const Vector &x) const;
112 
113  /** @brief Set the operator type id for the blocks of the parallel gradient
114  matrix/operator. The default type is Operator::Hypre_ParCSR. */
116 
117  /// Destructor.
118  virtual ~ParBlockNonlinearForm();
119 };
120 
121 }
122 
123 #endif // MFEM_USE_MPI
124 
125 #endif
void SetGradientType(Operator::Type tid)
Set the operator type id for the parallel gradient matrix/operator.
ParFiniteElementSpace * ParFESpace() const
virtual double GetEnergy(const Vector &x) const
Compute the enery corresponding to the state x.
Pointer to an Operator of a specified type.
Definition: handle.hpp:33
Parallel non-linear operator on the true dofs.
A class representing a general block nonlinear operator defined on the Cartesian product of multiple ...
virtual void Update()
Update the ParNonlinearForm to propagate updates of the associated parallel FE space.
Abstract parallel finite element space.
Definition: pfespace.hpp:28
FiniteElementSpace * fes
FE space on which the form lives.
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
ParBlockNonlinearForm()
Construct an empty ParBlockNonlinearForm. Initialize with SetParSpaces().
void SetGradientType(Operator::Type tid)
Set the operator type id for the blocks of the parallel gradient matrix/operator. The default type is...
ParNonlinearForm(ParFiniteElementSpace *pf)
double GetEnergy(const ParGridFunction &x) const
Compute the energy of a ParGridFunction.
Data type sparse matrix.
Definition: sparsemat.hpp:38
virtual void Mult(const Vector &x, Vector &y) const
Evaluate the action of the NonlinearForm.
const BlockOperator & GetLocalGradient(const Vector &x) const
Return the local block gradient matrix for the given true-dof vector x.
void SetParSpaces(Array< ParFiniteElementSpace * > &pf)
After a call to SetParSpaces(), the essential b.c. and the gradient-type (if different from the defau...
Dynamic 2D array using row-major layout.
Definition: array.hpp:289
double GetParGridFunctionEnergy(const Vector &x) const
Compute the energy corresponding to the state x.
Type
Enumeration defining IDs for some classes derived from Operator.
Definition: operator.hpp:124
const SparseMatrix & GetLocalGradient(const Vector &x) const
Return the local gradient matrix for the given true-dof vector x.
A class representing a general parallel block nonlinear operator defined on the Cartesian product of ...
virtual Operator & GetGradient(const Vector &x) const
Compute the gradient Operator of the NonlinearForm corresponding to the state x.
Array2D< OperatorHandle * > phBlockGrad
Vector data type.
Definition: vector.hpp:48
virtual BlockOperator & GetGradient(const Vector &x) const
Evaluate the gradient operator at the point x. The default behavior in class Operator is to generate ...
virtual ~ParBlockNonlinearForm()
Destructor.
Class for parallel grid function.
Definition: pgridfunc.hpp:32
ParFiniteElementSpace * ParFESpace(int k)
Return the k-th parallel FE space of the ParBlockNonlinearForm.
Abstract operator.
Definition: operator.hpp:21
A class to handle Block systems in a matrix-free implementation.
const Vector & Prolongate(const Vector &x) const
void SetType(Operator::Type tid)
Invoke Clear() and set a new type id.
Definition: handle.hpp:118
virtual void SetEssentialBC(const Array< Array< int > * > &bdr_attr_is_ess, Array< Vector * > &rhs)