tIP_H1NormFunctional.hh - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
(HTM) git clone git://src.adamsgaard.dk/pism
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
tIP_H1NormFunctional.hh (2697B)
---
1 // Copyright (C) 2012, 2013, 2014, 2015 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 "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<IceModelVec2S> {
39 public:
40 IP_H1NormFunctional2S(IceGrid::ConstPtr grid, ///< computational grid
41 double cL2, ///< The constant \f$c_{L^2}\f$.
42 double cH1, ///< The constant \f$c_{H^1}\f$.
43 IceModelVec2Int *dirichletLocations=NULL ///< Nodes where the function will be set to zero prior to integration.
44 ) :
45 IPInnerProductFunctional<IceModelVec2S>(grid),
46 m_cL2(cL2), m_cH1(cH1), m_dirichletIndices(dirichletLocations) {};
47 virtual ~IP_H1NormFunctional2S() {};
48
49 virtual void valueAt(IceModelVec2S &x, double *OUTPUT);
50 virtual void dot(IceModelVec2S &a, IceModelVec2S &b, double *OUTPUT);
51 virtual void gradientAt(IceModelVec2S &x, IceModelVec2S &gradient);
52 virtual void assemble_form(Mat J);
53
54 protected:
55
56 double m_cL2, m_cH1;
57 IceModelVec2Int *m_dirichletIndices;
58
59 private:
60 IP_H1NormFunctional2S(IP_H1NormFunctional2S const &);
61 IP_H1NormFunctional2S & operator=(IP_H1NormFunctional2S const &);
62 };
63
64 } // end of namespace inverse
65 } // end of namespace pism
66
67 #endif /* end of include guard: H1NORMFUNCTIONAL_HH_TF8AKRNQ */