const_fem_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_CONST_FEM_FUNCTION_H
19 #define LIBMESH_CONST_FEM_FUNCTION_H
20 
21 // libMesh includes
22 #include "libmesh/dense_vector.h"
24 #include "libmesh/auto_ptr.h" // libmesh_make_unique
25 
26 // C++ includes
27 #include <string>
28 
29 namespace libMesh
30 {
31 
32 // Forward declarations
33 class Point;
34 
43 template <typename Output=Number>
44 class ConstFEMFunction : public FEMFunctionBase<Output>
45 {
46 public:
47  ConstFEMFunction (const Output c) : _c(c) {}
48 
52  ConstFEMFunction (ConstFEMFunction &&) = default;
53  ConstFEMFunction (const ConstFEMFunction &) = default;
54  ConstFEMFunction & operator= (const ConstFEMFunction &) = default;
56  virtual ~ConstFEMFunction () = default;
57 
58  virtual std::unique_ptr<FEMFunctionBase<Output>> clone () const
59  {return libmesh_make_unique<ConstFEMFunction>(*this); }
60 
61  virtual Output operator() (const FEMContext &,
62  const Point &,
63  const Real /* time */ = 0.)
64  { return _c; }
65 
66  virtual void operator() (const FEMContext &,
67  const Point &,
68  const Real,
69  DenseVector<Output> & output)
70  {
71  for (unsigned int i = 0; i < output.size(); i++)
72  output(i) = _c;
73  }
74 
75 private:
76  Output _c;
77 };
78 
79 } // namespace libMesh;
80 
81 
82 #endif // LIBMESH_CONST_FEM_FUNCTION_H
virtual unsigned int size() const override
Definition: dense_vector.h:92
virtual Output operator()(const FEMContext &, const Point &, const Real=0.)
ConstFEMFunction(const Output c)
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual ~ConstFEMFunction()=default
FEMFunction that returns a single value.
ConstFEMFunction & operator=(const ConstFEMFunction &)=default
A geometric point in (x,y,z) space.
Definition: point.h:38