zero_function.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 #ifndef LIBMESH_ZERO_FUNCTION_H
19 #define LIBMESH_ZERO_FUNCTION_H
20 
21 // Local includes
22 #include "libmesh/const_function.h"
23 #include "libmesh/auto_ptr.h" // libmesh_make_unique
24 
25 namespace libMesh
26 {
27 
35 template <typename Output=Number>
36 class ZeroFunction : public ConstFunction<Output>
37 {
38 public:
39  ZeroFunction () : ConstFunction<Output>(0) {}
40 
44  ZeroFunction (ZeroFunction &&) = default;
45  ZeroFunction (const ZeroFunction &) = default;
46  ZeroFunction & operator= (const ZeroFunction &) = default;
47  ZeroFunction & operator= (ZeroFunction &&) = default;
48  virtual ~ZeroFunction () = default;
49 
50  virtual std::unique_ptr<FunctionBase<Output>> clone() const override
51  {
52  return libmesh_make_unique<ZeroFunction<Output>>();
53  }
54 };
55 
56 } // namespace libMesh
57 
58 #endif // LIBMESH_ZERO_FUNCTION_H
ConstFunction that simply returns 0.
Definition: zero_function.h:36
virtual ~ZeroFunction()=default
ZeroFunction & operator=(const ZeroFunction &)=default
virtual std::unique_ptr< FunctionBase< Output > > clone() const override
Definition: zero_function.h:50
Function that returns a single value that never changes.