PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
IP_H1NormFunctional.hh
Go to the documentation of this file.
1 // Copyright (C) 2012, 2013, 2014, 2015, 2020 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_H1NORMFUNCTIONAL_HH_TF8AKRNQ
20 #define IP_H1NORMFUNCTIONAL_HH_TF8AKRNQ
21 
22 #include "pism/inverse/functional/IPFunctional.hh"
23 
24 namespace pism {
25 namespace inverse {
26 
27 
28 //! Implements a functional corresponding to (the square of) an \f$H^1\f$ norm of a scalar valued function.
29 /*! The functional is, in continuous terms
30  \f[
31  J(f) = \int_{\Omega} c_{H^1} \left|\nabla f\right|^2 + c_{L^2}f^2 \; dA
32  \f]
33  where \f$\Omega\f$ is the square domain. Numerically it is implemented using
34  Q1 finite elements. Integration can be 'restricted', in a sense, to a subset of the domain
35  using a projection that forces \f$f\f$ to equal zero at nodes specified
36  by the constructor argument \a dirichletLocations.
37 */
38 class IP_H1NormFunctional2S : public IPInnerProductFunctional<array::Scalar> {
39 public:
40  /*!
41  * @param[in] grid computational grid
42  * @param[in] cL2 The constant \f$c_{L^2}\f$.
43  * @param[in] cH1 The constant \f$c_{H^1}\f$.
44  * @param[in] dirichletLocations Nodes where the function will be set to zero prior to integration.
45  */
46  IP_H1NormFunctional2S(std::shared_ptr<const Grid> grid,
47  double cL2,
48  double cH1,
49  array::Scalar *dirichletLocations=NULL)
50  : IPInnerProductFunctional<array::Scalar>(grid),
51  m_cL2(cL2),
52  m_cH1(cH1),
53  m_dirichletIndices(dirichletLocations) {};
54  virtual ~IP_H1NormFunctional2S() {};
55 
56  virtual void valueAt(array::Scalar &x, double *OUTPUT);
57  virtual void dot(array::Scalar &a, array::Scalar &b, double *OUTPUT);
58  virtual void gradientAt(array::Scalar &x, array::Scalar &gradient);
59  virtual void assemble_form(Mat J);
60 
61 protected:
62 
63  double m_cL2, m_cH1;
65 
66 private:
69 };
70 
71 } // end of namespace inverse
72 } // end of namespace pism
73 
74 #endif /* end of include guard: H1NORMFUNCTIONAL_HH_TF8AKRNQ */
Abstract base class for IPFunctionals arising from an inner product.
Definition: IPFunctional.hh:94
virtual void dot(array::Scalar &a, array::Scalar &b, double *OUTPUT)
Computes the inner product .
IP_H1NormFunctional2S(IP_H1NormFunctional2S const &)
IP_H1NormFunctional2S & operator=(IP_H1NormFunctional2S const &)
IP_H1NormFunctional2S(std::shared_ptr< const Grid > grid, double cL2, double cH1, array::Scalar *dirichletLocations=NULL)
virtual void gradientAt(array::Scalar &x, array::Scalar &gradient)
Computes the gradient of the functional at the vector x.
virtual void valueAt(array::Scalar &x, double *OUTPUT)
Computes the value of the functional at the vector x.
Implements a functional corresponding to (the square of) an norm of a scalar valued function.
const int J[]
Definition: ssafd_code.cc:34