Loading...
Searching...
No Matches
Constant.h
// Copyright (C) 2006-2009 Anders Logg
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Martin Sandve Alnes, 2008.
// Modified by Garth N. Wells, 2008-2011.
#ifndef __CONSTANT_H
#define __CONSTANT_H
#include <vector>
#include <Eigen/Dense>
#include "Expression.h"
namespace dolfin
{
template<typename T> class Array;
class Mesh;
class Constant : public Expression
{
public:
explicit Constant(double value);
Constant(double value0, double value1);
Constant(double value0, double value1, double value2);
explicit Constant(std::vector<double> values);
Constant(std::vector<std::size_t> value_shape,
std::vector<double> values);
Constant(const Constant& constant);
~Constant();
const Constant& operator= (const Constant& constant);
const Constant& operator= (double constant);
operator double() const;
std::vector<double> values() const;
//--- Implementation of Expression interface ---
void eval(Array<double>& values, const Array<double>& x) const override;
void eval(Eigen::Ref<Eigen::VectorXd> values,
Eigen::Ref<const Eigen::VectorXd> x) const override;
virtual std::string str(bool verbose) const override;
private:
// Values of constant function
std::vector<double> _values;
};
}
#endif
dolfin::Array
Definition Array.h:42
dolfin::Constant::~Constant
~Constant()
Destructor.
Definition Constant.cpp:71
dolfin::Constant::eval
void eval(Array< double > &values, const Array< double > &x) const override
Definition Constant.cpp:130
dolfin::Constant::str
virtual std::string str(bool verbose) const override
Return informal string representation (pretty-print).
Definition Constant.cpp:143
dolfin::Constant::values
std::vector< double > values() const
Definition Constant.cpp:124
dolfin::Constant::Constant
Constant(double value)
Definition Constant.cpp:29
dolfin::Constant::operator=
const Constant & operator=(const Constant &constant)
Definition Constant.cpp:76
dolfin::Expression::value_shape
virtual std::vector< std::size_t > value_shape() const override
Definition Expression.cpp:119
dolfin::Expression::Expression
Expression()
Create scalar expression.
Definition Expression.cpp:32
dolfin::Mesh
Definition Mesh.h:84
dolfin
Definition adapt.h:30