Loading...
Searching...
No Matches
Function.h
// Copyright (C) 2003-2012 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 Garth N. Wells, 2005-2010.
// Modified by Kristian B. Oelgaard, 2007.
// Modified by Martin Sandve Alnes, 2008-2014.
// Modified by Andre Massing, 2009.
#ifndef __FUNCTION_H
#define __FUNCTION_H
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <boost/ptr_container/ptr_map.hpp>
#include <Eigen/Dense>
#include <dolfin/common/types.h>
#include <dolfin/common/Hierarchical.h>
#include "GenericFunction.h"
#include "FunctionAXPY.h"
namespace ufc
{
// Forward declarations
class cell;
}
namespace dolfin
{
// Forward declarations
class Cell;
class Expression;
class FunctionSpace;
class GenericVector;
class SubDomain;
template<typename T> class Array;
class Function : public GenericFunction, public Hierarchical<Function>
{
public:
Function() : Hierarchical<Function>(*this) {}
explicit Function(std::shared_ptr<const FunctionSpace> V);
Function(std::shared_ptr<const FunctionSpace> V,
std::shared_ptr<GenericVector> x);
Function(std::shared_ptr<const FunctionSpace> V,
std::string filename);
Function(const Function& v);
Function(const Function& v, std::size_t i);
virtual ~Function();
const Function& operator= (const Function& v);
const Function& operator= (const Expression& v);
void operator=(const FunctionAXPY& axpy);
Function& operator[] (std::size_t i) const;
virtual std::shared_ptr<const FunctionSpace> function_space() const override
{
dolfin_assert(_function_space);
return _function_space;
}
std::shared_ptr<GenericVector> vector();
std::shared_ptr<const GenericVector> vector() const;
bool in(const FunctionSpace& V) const;
std::size_t geometric_dimension() const;
void eval(Array<double>& values, const Array<double>& x) const override;
void eval(Array<double>& values, const Array<double>& x,
const Cell& dolfin_cell, const ufc::cell& ufc_cell) const;
void eval(Eigen::Ref<Eigen::VectorXd> values,
Eigen::Ref<const Eigen::VectorXd> x) const override;
void eval(Eigen::Ref<Eigen::VectorXd> values,
Eigen::Ref<const Eigen::VectorXd> x,
const dolfin::Cell& dolfin_cell, const ufc::cell& ufc_cell) const;
void interpolate(const GenericFunction& v);
void extrapolate(const Function& v);
//--- Implementation of GenericFunction interface ---
virtual std::size_t value_rank() const override;
virtual std::size_t value_dimension(std::size_t i) const override;
virtual std::vector<std::size_t> value_shape() const override;
virtual void eval(Array<double>& values, const Array<double>& x,
const ufc::cell& cell) const override;
virtual void eval(Eigen::Ref<Eigen::VectorXd> values,
Eigen::Ref<const Eigen::VectorXd> x,
const ufc::cell& cell) const override;
virtual void restrict(double* w,
const FiniteElement& element,
const Cell& dolfin_cell,
const double* coordinate_dofs,
const ufc::cell& ufc_cell) const override;
virtual void compute_vertex_values(std::vector<double>& vertex_values,
const Mesh& mesh) const override;
void compute_vertex_values(std::vector<double>& vertex_values);
void set_allow_extrapolation(bool allow_extrapolation)
{ _allow_extrapolation = allow_extrapolation; }
bool get_allow_extrapolation() const
{ return _allow_extrapolation; }
private:
// Friends
friend class FunctionSpace;
friend class FunctionAssigner;
// Collection of sub-functions which share data with the function
mutable boost::ptr_map<std::size_t, Function> _sub_functions;
// Initialize vector
void init_vector();
// The function space
std::shared_ptr<const FunctionSpace> _function_space;
// The vector of expansion coefficients (local)
std::shared_ptr<GenericVector> _vector;
// True if extrapolation should be allowed
bool _allow_extrapolation;
};
}
#endif
dolfin::Array
Definition Array.h:42
dolfin::Cell
A Cell is a MeshEntity of topological codimension 0.
Definition Cell.h:43
dolfin::Expression
Definition Expression.h:50
dolfin::FiniteElement
This is a wrapper for a UFC finite element (ufc::finite_element).
Definition FiniteElement.h:36
dolfin::FunctionAXPY
Definition FunctionAXPY.h:36
dolfin::FunctionAssigner
Definition FunctionAssigner.h:41
dolfin::FunctionSpace
Definition FunctionSpace.h:54
dolfin::Function
Definition Function.h:66
dolfin::Function::geometric_dimension
std::size_t geometric_dimension() const
Definition Function.cpp:276
dolfin::Function::value_dimension
virtual std::size_t value_dimension(std::size_t i) const override
Definition Function.cpp:406
dolfin::Function::interpolate
void interpolate(const GenericFunction &v)
Definition Function.cpp:385
dolfin::Function::compute_vertex_values
virtual void compute_vertex_values(std::vector< double > &vertex_values, const Mesh &mesh) const override
Definition Function.cpp:512
dolfin::Function::eval
void eval(Array< double > &values, const Array< double > &x) const override
Definition Function.cpp:283
dolfin::Function::~Function
virtual ~Function()
Destructor.
Definition Function.cpp:131
dolfin::Function::value_shape
virtual std::vector< std::size_t > value_shape() const override
Definition Function.cpp:413
dolfin::Function::value_rank
virtual std::size_t value_rank() const override
Definition Function.cpp:399
dolfin::Function::extrapolate
void extrapolate(const Function &v)
Definition Function.cpp:394
dolfin::Function::set_allow_extrapolation
void set_allow_extrapolation(bool allow_extrapolation)
Definition Function.h:342
dolfin::Function::restrict
virtual void restrict(double *w, const FiniteElement &element, const Cell &dolfin_cell, const double *coordinate_dofs, const ufc::cell &ufc_cell) const override
Definition Function.cpp:451
dolfin::Function::get_allow_extrapolation
bool get_allow_extrapolation() const
Definition Function.h:349
dolfin::Function::vector
std::shared_ptr< GenericVector > vector()
Definition Function.cpp:248
dolfin::Function::operator[]
Function & operator[](std::size_t i) const
Definition Function.cpp:202
dolfin::Function::function_space
virtual std::shared_ptr< const FunctionSpace > function_space() const override
Definition Function.h:158
dolfin::Function::operator=
const Function & operator=(const Function &v)
Definition Function.cpp:136
dolfin::Function::in
bool in(const FunctionSpace &V) const
Definition Function.cpp:270
dolfin::GenericFunction
Definition GenericFunction.h:54
dolfin::GenericFunction::GenericFunction
GenericFunction()
Constructor.
Definition GenericFunction.cpp:31
dolfin::GenericVector
This class defines a common interface for vectors.
Definition GenericVector.h:48
dolfin::Hierarchical< Function >::Hierarchical
Hierarchical(Function &self)
Definition Hierarchical.h:48
dolfin::Mesh
Definition Mesh.h:84
dolfin::SubDomain
Definition SubDomain.h:43
dolfin
Definition adapt.h:30