DOLFIN
DOLFIN C++ interface
Expression.h
1// Copyright (C) 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// First added: 2009-09-28
19// Last changed: 2011-08-15
20
21#ifndef __EXPRESSION_H
22#define __EXPRESSION_H
23
24#include <vector>
25#include <ufc.h>
26#include <Eigen/Dense>
27#include <dolfin/common/Array.h>
28#include "GenericFunction.h"
29
30namespace dolfin
31{
32
33 class Mesh;
34
48
50 {
51
52 public:
53
55 Expression();
56
61 explicit Expression(std::size_t dim);
62
69 Expression(std::size_t dim0, std::size_t dim1);
70
75 explicit Expression(std::vector<std::size_t> value_shape);
76
81 Expression(const Expression& expression);
82
84 virtual ~Expression();
85
86 //--- Implementation of GenericFunction interface ---
87
96 virtual void eval(Array<double>& values,
97 const Array<double>& x,
98 const ufc::cell& cell) const override;
99
108 virtual void eval(Eigen::Ref<Eigen::VectorXd> values,
109 Eigen::Ref<const Eigen::VectorXd> x,
110 const ufc::cell& cell) const override;
111
118 virtual void eval(Array<double>& values, const Array<double>& x) const override;
119
126 virtual void eval(Eigen::Ref<Eigen::VectorXd> values,
127 Eigen::Ref<const Eigen::VectorXd> x) const override;
128
133 virtual std::size_t value_rank() const override;
134
142 virtual std::size_t value_dimension(std::size_t i) const override;
143
148 virtual std::vector<std::size_t> value_shape() const override;
149
153 virtual void set_property(std::string name, double value);
154
158 virtual double get_property(std::string name) const;
159
163 virtual void set_generic_function(std::string name, std::shared_ptr<GenericFunction> f);
164
168 virtual std::shared_ptr<dolfin::GenericFunction> get_generic_function(std::string name) const;
169
182 virtual void restrict(double* w,
183 const FiniteElement& element,
184 const Cell& dolfin_cell,
185 const double* coordinate_dofs,
186 const ufc::cell& ufc_cell) const override;
187
194 virtual void compute_vertex_values(std::vector<double>& vertex_values,
195 const Mesh& mesh) const override;
196
202 virtual std::shared_ptr<const FunctionSpace> function_space() const override;
203
204 protected:
205
206 // Value shape
207 std::vector<std::size_t> _value_shape;
208
209 };
210
211}
212
213#endif
Definition: Array.h:42
A Cell is a MeshEntity of topological codimension 0.
Definition: Cell.h:43
Definition: Expression.h:50
virtual ~Expression()
Destructor.
Definition: Expression.cpp:62
virtual std::shared_ptr< const FunctionSpace > function_space() const override
Definition: Expression.cpp:202
virtual std::vector< std::size_t > value_shape() const override
Definition: Expression.cpp:119
virtual std::size_t value_rank() const override
Definition: Expression.cpp:102
virtual void restrict(double *w, const FiniteElement &element, const Cell &dolfin_cell, const double *coordinate_dofs, const ufc::cell &ufc_cell) const override
Definition: Expression.cpp:154
virtual std::size_t value_dimension(std::size_t i) const override
Definition: Expression.cpp:107
virtual void eval(Array< double > &values, const Array< double > &x, const ufc::cell &cell) const override
Definition: Expression.cpp:67
virtual void set_generic_function(std::string name, std::shared_ptr< GenericFunction > f)
Definition: Expression.cpp:139
virtual void set_property(std::string name, double value)
Definition: Expression.cpp:124
virtual void compute_vertex_values(std::vector< double > &vertex_values, const Mesh &mesh) const override
Definition: Expression.cpp:165
virtual double get_property(std::string name) const
Definition: Expression.cpp:131
virtual std::shared_ptr< dolfin::GenericFunction > get_generic_function(std::string name) const
Definition: Expression.cpp:146
Expression()
Create scalar expression.
Definition: Expression.cpp:32
This is a wrapper for a UFC finite element (ufc::finite_element).
Definition: FiniteElement.h:36
Definition: GenericFunction.h:54
Definition: Mesh.h:84
std::string name() const
Return name.
Definition: Variable.cpp:71
Definition: adapt.h:30