MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
pnonlinearform.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, 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_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
22namespace mfem
23{
24
25/// Parallel non-linear operator on the true dofs
27{
28protected:
31
32public:
34
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(). */
44
45 /// Compute the energy of a ParGridFunction
47 { return GetParGridFunctionEnergy(x); }
48
49 virtual real_t GetEnergy(const Vector &x) const
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{
79protected:
83
84public:
85 /// Computes the energy of the system
86 virtual real_t GetEnergy(const Vector &x) const;
87
88 /// Construct an empty ParBlockNonlinearForm. Initialize with SetParSpaces().
90
91 /** @brief Construct a ParBlockNonlinearForm on the given set of
92 ParFiniteElementSpace%s. */
94
95 /// Return the @a k-th parallel FE space of the ParBlockNonlinearForm.
97 /** @brief Return the @a k-th parallel FE space of the ParBlockNonlinearForm
98 (const version). */
99 const ParFiniteElementSpace *ParFESpace(int k) const;
100
101 /** @brief After a call to SetParSpaces(), the essential b.c. and the
102 gradient-type (if different from the default) must be set again. */
104
105 // Here, rhs is a true dof vector
106 virtual void SetEssentialBC(const Array<Array<int> *>&bdr_attr_is_ess,
107 Array<Vector *> &rhs);
108
109 /// Block T-Vector to Block T-Vector
110 virtual void Mult(const Vector &x, Vector &y) const;
111
112 /// Return the local block gradient matrix for the given true-dof vector x
113 const BlockOperator &GetLocalGradient(const Vector &x) const;
114
115 virtual BlockOperator &GetGradient(const Vector &x) const;
116
117 /** @brief Set the operator type id for the blocks of the parallel gradient
118 matrix/operator. The default type is Operator::Hypre_ParCSR. */
120
121 /// Destructor.
122 virtual ~ParBlockNonlinearForm();
123};
124
125}
126
127#endif // MFEM_USE_MPI
128
129#endif
Dynamic 2D array using row-major layout.
Definition array.hpp:372
A class representing a general block nonlinear operator defined on the Cartesian product of multiple ...
A class to handle Block systems in a matrix-free implementation.
A class to handle Vectors in a block fashion.
FiniteElementSpace * fes
FE space on which the form lives.
const Vector & Prolongate(const Vector &x) const
Pointer to an Operator of a specified type.
Definition handle.hpp:34
void SetType(Operator::Type tid)
Invoke Clear() and set a new type id.
Definition handle.hpp:132
Abstract operator.
Definition operator.hpp:25
Type
Enumeration defining IDs for some classes derived from Operator.
Definition operator.hpp:284
A class representing a general parallel block nonlinear operator defined on the Cartesian product of ...
const BlockOperator & GetLocalGradient(const Vector &x) const
Return the local block gradient matrix for the given true-dof vector x.
virtual real_t GetEnergy(const Vector &x) const
Computes the energy of the system.
virtual BlockOperator & GetGradient(const Vector &x) const
Array2D< OperatorHandle * > phBlockGrad
ParFiniteElementSpace * ParFESpace(int k)
Return the k-th parallel FE space of the ParBlockNonlinearForm.
ParBlockNonlinearForm()
Construct an empty ParBlockNonlinearForm. Initialize with SetParSpaces().
virtual ~ParBlockNonlinearForm()
Destructor.
void SetParSpaces(Array< ParFiniteElementSpace * > &pf)
After a call to SetParSpaces(), the essential b.c. and the gradient-type (if different from the defau...
virtual void Mult(const Vector &x, Vector &y) const
Block T-Vector to Block T-Vector.
void SetGradientType(Operator::Type tid)
Set the operator type id for the blocks of the parallel gradient matrix/operator. The default type is...
virtual void SetEssentialBC(const Array< Array< int > * > &bdr_attr_is_ess, Array< Vector * > &rhs)
Abstract parallel finite element space.
Definition pfespace.hpp:29
Class for parallel grid function.
Definition pgridfunc.hpp:33
Parallel non-linear operator on the true dofs.
const SparseMatrix & GetLocalGradient(const Vector &x) const
Return the local gradient matrix for the given true-dof vector x.
ParNonlinearForm(ParFiniteElementSpace *pf)
virtual real_t GetEnergy(const Vector &x) const
Compute the energy corresponding to the state x.
void SetGradientType(Operator::Type tid)
Set the operator type id for the parallel gradient matrix/operator.
real_t GetParGridFunctionEnergy(const Vector &x) const
Compute the energy corresponding to the state x.
virtual void Mult(const Vector &x, Vector &y) const
Evaluate the action of the NonlinearForm.
real_t GetEnergy(const ParGridFunction &x) const
Compute the energy of a ParGridFunction.
virtual void Update()
Update the ParNonlinearForm to propagate updates of the associated parallel FE space.
virtual Operator & GetGradient(const Vector &x) const
Compute the gradient Operator of the NonlinearForm corresponding to the state x.
ParFiniteElementSpace * ParFESpace() const
Data type sparse matrix.
Definition sparsemat.hpp:51
Vector data type.
Definition vector.hpp:80
float real_t
Definition config.hpp:43