DOLFIN
DOLFIN C++ interface
Loading...
Searching...
No Matches
Constant.h
1// Copyright (C) 2006-2009 Anders Logg
2//
3// This file is part of DOLFIN.
4//
5// DOLFIN is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// DOLFIN is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17//
18// Modified by Martin Sandve Alnes, 2008.
19// Modified by Garth N. Wells, 2008-2011.
20
21#ifndef __CONSTANT_H
22#define __CONSTANT_H
23
24#include <vector>
25#include <Eigen/Dense>
26#include "Expression.h"
27
28namespace dolfin
29{
30 template<typename T> class Array;
31 class Mesh;
32
34
35 class Constant : public Expression
36 {
37 public:
38
47 explicit Constant(double value);
48
59 Constant(double value0, double value1);
60
73 Constant(double value0, double value1, double value2);
74
79 explicit Constant(std::vector<double> values);
80
87 Constant(std::vector<std::size_t> value_shape,
88 std::vector<double> values);
89
94 Constant(const Constant& constant);
95
97 ~Constant();
98
103 const Constant& operator= (const Constant& constant);
104
109 const Constant& operator= (double constant);
110
115 operator double() const;
116
121 std::vector<double> values() const;
122
123 //--- Implementation of Expression interface ---
124
125 void eval(Array<double>& values, const Array<double>& x) const override;
126
127 void eval(Eigen::Ref<Eigen::VectorXd> values,
128 Eigen::Ref<const Eigen::VectorXd> x) const override;
129
130 virtual std::string str(bool verbose) const override;
131
132 private:
133
134 // Values of constant function
135 std::vector<double> _values;
136
137 };
138
139}
140
141#endif
Definition Array.h:42
This class represents a constant-valued expression.
Definition Constant.h:36
~Constant()
Destructor.
Definition Constant.cpp:71
void eval(Array< double > &values, const Array< double > &x) const override
Definition Constant.cpp:130
virtual std::string str(bool verbose) const override
Return informal string representation (pretty-print)
Definition Constant.cpp:143
std::vector< double > values() const
Definition Constant.cpp:124
const Constant & operator=(const Constant &constant)
Definition Constant.cpp:76
Definition Expression.h:50
virtual std::vector< std::size_t > value_shape() const override
Definition Expression.cpp:119
Definition adapt.h:30