libMesh
Loading...
Searching...
No Matches
const_fem_function.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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"
23#include "libmesh/fem_function_base.h"
24#include "libmesh/int_range.h"
25
26// C++ includes
27#include <memory>
28#include <string>
29
30namespace libMesh
31{
32
33// Forward declarations
34class Point;
35
44template <typename Output=Number>
45class ConstFEMFunction : public FEMFunctionBase<Output>
46{
47public:
48 ConstFEMFunction (const Output c) : _c(c) {}
49
57 virtual ~ConstFEMFunction () = default;
58
59 virtual std::unique_ptr<FEMFunctionBase<Output>> clone () const override
60 {return std::make_unique<ConstFEMFunction>(*this); }
61
62 virtual Output operator() (const FEMContext &,
63 const Point &,
64 const Real /* time */ = 0.) override
65 { return _c; }
66
67 virtual void operator() (const FEMContext &,
68 const Point &,
69 const Real,
70 DenseVector<Output> & output) override
71 {
72 for (auto i : index_range(output))
73 output(i) = _c;
74 }
75
76private:
77 Output _c;
78};
79
80} // namespace libMesh;
81
82
83#endif // LIBMESH_CONST_FEM_FUNCTION_H
FEMFunction that returns a single value, regardless of the time and location inputs.
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const override
virtual Output operator()(const FEMContext &, const Point &, const Real=0.) override
ConstFEMFunction(ConstFEMFunction &&)=default
The 5 special functions can be defaulted for this class.
ConstFEMFunction & operator=(const ConstFEMFunction &)=default
ConstFEMFunction(const ConstFEMFunction &)=default
virtual ~ConstFEMFunction()=default
Defines a dense vector for use in Finite Element-type computations.
This class provides all data required for a physics package (e.g.
Definition fem_context.h:63
FEMFunctionBase is a base class from which users can derive in order to define "function-like" object...
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real