PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
IP_L2NormFunctional.hh
Go to the documentation of this file.
1 // Copyright (C) 2012, 2014, 2015, 2022 David Maxwell and Constantine Khroulev
2 //
3 // This file is part of PISM.
4 //
5 // PISM is free software; you can redistribute it and/or modify it under the
6 // terms of the GNU General Public License as published by the Free Software
7 // Foundation; either version 3 of the License, or (at your option) any later
8 // version.
9 //
10 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with PISM; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef IP_L2NORMFUNCTIONAL_HH_BSVF8BMQ
20 #define IP_L2NORMFUNCTIONAL_HH_BSVF8BMQ
21 
22 #include "pism/inverse/functional/IPFunctional.hh"
23 
24 namespace pism {
25 namespace inverse {
26 
27 //! Implements a functional corresponding to (the square of) an \f$L^2\f$ norm of a scalar valued function.
28 /*! The functional is, in continuous terms
29  \f[
30  J(f) = \int_{\Omega} f^2 \; dA
31  \f]
32  where \f$\Omega\f$ is the square domain. Numerically it is implemented using
33  Q1 finite elements.
34 */
35 class IP_L2NormFunctional2S : public IPInnerProductFunctional<array::Scalar> {
36 public:
37  IP_L2NormFunctional2S(std::shared_ptr<const Grid> grid) : IPInnerProductFunctional<array::Scalar>(grid) {};
38  virtual ~IP_L2NormFunctional2S() {};
39 
40  virtual void valueAt(array::Scalar &x, double *OUTPUT);
41  virtual void dot(array::Scalar &a, array::Scalar &b, double *v);
42  virtual void gradientAt(array::Scalar &x, array::Scalar &gradient);
43 
44 private:
47 };
48 
49 //! Implements a functional corresponding to (the square of) an \f$L^2\f$ norm of a vector valued function.
50 /*! The functional is, in continuous terms
51  \f[
52  J(f) = \int_{\Omega} f^2 \; dA
53  \f]
54  where \f$\Omega\f$ is the square domain. Numerically it is implemented using
55  Q1 finite elements.
56 */
57 class IP_L2NormFunctional2V : public IPInnerProductFunctional<array::Vector> {
58 public:
59  IP_L2NormFunctional2V(std::shared_ptr<const Grid> grid) : IPInnerProductFunctional<array::Vector>(grid) {};
60  virtual ~IP_L2NormFunctional2V() {};
61 
62  virtual void valueAt(array::Vector &x, double *v);
63  virtual void dot(array::Vector &a, array::Vector &b, double *v);
64  virtual void gradientAt(array::Vector &x, array::Vector &gradient);
65 
66 private:
69 };
70 
71 } // end of namespace inverse
72 } // end of namespace pism
73 
74 #endif /* end of include guard: IP_L2NORMFUNCTIONAL_HH_BSVF8BMQ */
Abstract base class for IPFunctionals arising from an inner product.
Definition: IPFunctional.hh:94
virtual void valueAt(array::Scalar &x, double *OUTPUT)
Computes the value of the functional at the vector x.
IP_L2NormFunctional2S(std::shared_ptr< const Grid > grid)
virtual void gradientAt(array::Scalar &x, array::Scalar &gradient)
Computes the gradient of the functional at the vector x.
virtual void dot(array::Scalar &a, array::Scalar &b, double *v)
Computes the inner product .
IP_L2NormFunctional2S & operator=(IP_L2NormFunctional2S const &)
IP_L2NormFunctional2S(IP_L2NormFunctional2S const &)
Implements a functional corresponding to (the square of) an norm of a scalar valued function.
IP_L2NormFunctional2V & operator=(IP_L2NormFunctional2V const &)
virtual void gradientAt(array::Vector &x, array::Vector &gradient)
Computes the gradient of the functional at the vector x.
virtual void valueAt(array::Vector &x, double *v)
Computes the value of the functional at the vector x.
virtual void dot(array::Vector &a, array::Vector &b, double *v)
Computes the inner product .
IP_L2NormFunctional2V(IP_L2NormFunctional2V const &)
IP_L2NormFunctional2V(std::shared_ptr< const Grid > grid)
Implements a functional corresponding to (the square of) an norm of a vector valued function.