Loading...
Searching...
No Matches
FiniteElement.h
// Copyright (C) 2008-2013 Anders Logg and Garth N. Wells
//
// 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/>.
#ifndef __FINITE_ELEMENT_H
#define __FINITE_ELEMENT_H
#include <memory>
#include <vector>
#include <ufc.h>
#include <boost/multi_array.hpp>
#include <dolfin/common/types.h>
#include <dolfin/log/log.h>
namespace dolfin
{
class Cell;
class FiniteElement
{
public:
FiniteElement(std::shared_ptr<const ufc::finite_element> element);
virtual ~FiniteElement() {}
//--- Direct wrappers for ufc::finite_element ---
std::string signature() const
{
dolfin_assert(_ufc_element);
return _ufc_element->signature();
}
ufc::shape cell_shape() const
{
dolfin_assert(_ufc_element);
return _ufc_element->cell_shape();
}
std::size_t topological_dimension() const
{
dolfin_assert(_ufc_element);
return _ufc_element->topological_dimension();
}
virtual unsigned int geometric_dimension() const
{
dolfin_assert(_ufc_element);
return _ufc_element->geometric_dimension();
}
std::size_t space_dimension() const
{
dolfin_assert(_ufc_element);
return _ufc_element->space_dimension();
}
std::size_t value_rank() const
{
dolfin_assert(_ufc_element);
return _ufc_element->value_rank();
}
std::size_t value_dimension(std::size_t i) const
{
dolfin_assert(_ufc_element);
return _ufc_element->value_dimension(i);
}
void evaluate_basis(std::size_t i, double* values, const double* x,
const double* coordinate_dofs,
int cell_orientation) const
{
dolfin_assert(_ufc_element);
_ufc_element->evaluate_basis(i, values, x, coordinate_dofs,
cell_orientation);
}
void evaluate_basis_all(double* values,
const double* x,
const double* coordinate_dofs,
int cell_orientation) const
{
dolfin_assert(_ufc_element);
_ufc_element->evaluate_basis_all(values, x, coordinate_dofs,
cell_orientation);
}
void evaluate_basis_derivatives(unsigned int i,
unsigned int n,
double* values,
const double* x,
const double* coordinate_dofs,
int cell_orientation) const
{
dolfin_assert(_ufc_element);
_ufc_element->evaluate_basis_derivatives(i, n, values, x,
coordinate_dofs,
cell_orientation);
}
void evaluate_basis_derivatives_all(unsigned int n,
double* values,
const double* x,
const double* coordinate_dofs,
int cell_orientation) const
{
dolfin_assert(_ufc_element);
_ufc_element->evaluate_basis_derivatives_all(n, values, x,
coordinate_dofs,
cell_orientation);
}
double evaluate_dof(std::size_t i,
const ufc::function& function,
const double* coordinate_dofs,
int cell_orientation,
const ufc::cell& c) const
{
dolfin_assert(_ufc_element);
return _ufc_element->evaluate_dof(i, function, coordinate_dofs,
cell_orientation, c);
}
void evaluate_dofs(double* values,
const ufc::function& f,
const double* coordinate_dofs,
int cell_orientation,
const ufc::cell& c) const
{
dolfin_assert(_ufc_element);
_ufc_element->evaluate_dofs(values, f, coordinate_dofs,
cell_orientation, c);
}
void interpolate_vertex_values(double* vertex_values,
double* coefficients,
const double* coordinate_dofs,
int cell_orientation) const
{
dolfin_assert(_ufc_element);
_ufc_element->interpolate_vertex_values(vertex_values, coefficients,
coordinate_dofs,
cell_orientation);
}
void tabulate_dof_coordinates(boost::multi_array<double, 2>& coordinates,
const std::vector<double>& coordinate_dofs,
const Cell& cell) const;
std::size_t num_sub_elements() const
{
dolfin_assert(_ufc_element);
return _ufc_element->num_sub_elements();
}
//--- DOLFIN-specific extensions of the interface ---
std::size_t hash() const
{ return _hash; }
std::shared_ptr<const FiniteElement>
create_sub_element(std::size_t i) const
{
dolfin_assert(_ufc_element);
std::shared_ptr<const ufc::finite_element>
ufc_element(_ufc_element->create_sub_element(i));
std::shared_ptr<const FiniteElement>
element(new const FiniteElement(ufc_element));
return element;
}
std::shared_ptr<const FiniteElement> create() const
{
dolfin_assert(_ufc_element);
std::shared_ptr<const ufc::finite_element>
ufc_element(_ufc_element->create());
return std::shared_ptr<const FiniteElement>(new FiniteElement(ufc_element));
}
std::shared_ptr<const FiniteElement>
extract_sub_element(const std::vector<std::size_t>& component) const;
std::shared_ptr<const ufc::finite_element> ufc_element() const
{ return _ufc_element; }
private:
// UFC finite element
std::shared_ptr<const ufc::finite_element> _ufc_element;
// Recursively extract sub finite element
static std::shared_ptr<const FiniteElement>
extract_sub_element(const FiniteElement& finite_element,
const std::vector<std::size_t>& component);
// Simple hash of the signature string
std::size_t _hash;
};
}
#endif
dolfin::Cell
A Cell is a MeshEntity of topological codimension 0.
Definition Cell.h:43
dolfin::FiniteElement
This is a wrapper for a UFC finite element (ufc::finite_element).
Definition FiniteElement.h:36
dolfin::FiniteElement::num_sub_elements
std::size_t num_sub_elements() const
Definition FiniteElement.h:207
dolfin::FiniteElement::tabulate_dof_coordinates
void tabulate_dof_coordinates(boost::multi_array< double, 2 > &coordinates, const std::vector< double > &coordinate_dofs, const Cell &cell) const
Definition FiniteElement.cpp:35
dolfin::FiniteElement::FiniteElement
FiniteElement(std::shared_ptr< const ufc::finite_element > element)
Definition FiniteElement.cpp:29
dolfin::FiniteElement::interpolate_vertex_values
void interpolate_vertex_values(double *vertex_values, double *coefficients, const double *coordinate_dofs, int cell_orientation) const
Definition FiniteElement.h:181
dolfin::FiniteElement::evaluate_dofs
void evaluate_dofs(double *values, const ufc::function &f, const double *coordinate_dofs, int cell_orientation, const ufc::cell &c) const
Evaluate linear functionals for all dofs on the function f.
Definition FiniteElement.h:165
dolfin::FiniteElement::create_sub_element
std::shared_ptr< const FiniteElement > create_sub_element(std::size_t i) const
Create a new finite element for sub element i (for a mixed element).
Definition FiniteElement.h:221
dolfin::FiniteElement::geometric_dimension
virtual unsigned int geometric_dimension() const
Definition FiniteElement.h:75
dolfin::FiniteElement::hash
std::size_t hash() const
Return simple hash of the signature string.
Definition FiniteElement.h:216
dolfin::FiniteElement::evaluate_basis_all
void evaluate_basis_all(double *values, const double *x, const double *coordinate_dofs, int cell_orientation) const
Evaluate all basis functions at given point in cell.
Definition FiniteElement.h:114
dolfin::FiniteElement::evaluate_dof
double evaluate_dof(std::size_t i, const ufc::function &function, const double *coordinate_dofs, int cell_orientation, const ufc::cell &c) const
Evaluate linear functional for dof i on the function f.
Definition FiniteElement.h:153
dolfin::FiniteElement::create
std::shared_ptr< const FiniteElement > create() const
Create a new class instance.
Definition FiniteElement.h:232
dolfin::FiniteElement::evaluate_basis_derivatives
void evaluate_basis_derivatives(unsigned int i, unsigned int n, double *values, const double *x, const double *coordinate_dofs, int cell_orientation) const
Evaluate order n derivatives of basis function i at given point in cell.
Definition FiniteElement.h:125
dolfin::FiniteElement::signature
std::string signature() const
Definition FiniteElement.h:51
dolfin::FiniteElement::extract_sub_element
std::shared_ptr< const FiniteElement > extract_sub_element(const std::vector< std::size_t > &component) const
Extract sub finite element for component.
Definition FiniteElement.cpp:57
dolfin::FiniteElement::space_dimension
std::size_t space_dimension() const
Definition FiniteElement.h:83
dolfin::FiniteElement::value_rank
std::size_t value_rank() const
Return the rank of the value space.
Definition FiniteElement.h:90
dolfin::FiniteElement::evaluate_basis_derivatives_all
void evaluate_basis_derivatives_all(unsigned int n, double *values, const double *x, const double *coordinate_dofs, int cell_orientation) const
Definition FiniteElement.h:140
dolfin::FiniteElement::cell_shape
ufc::shape cell_shape() const
Definition FiniteElement.h:59
dolfin::FiniteElement::value_dimension
std::size_t value_dimension(std::size_t i) const
Return the dimension of the value space for axis i.
Definition FiniteElement.h:97
dolfin::FiniteElement::ufc_element
std::shared_ptr< const ufc::finite_element > ufc_element() const
Definition FiniteElement.h:246
dolfin::FiniteElement::evaluate_basis
void evaluate_basis(std::size_t i, double *values, const double *x, const double *coordinate_dofs, int cell_orientation) const
Evaluate basis function i at given point in cell.
Definition FiniteElement.h:104
dolfin::FiniteElement::topological_dimension
std::size_t topological_dimension() const
Definition FiniteElement.h:67
dolfin::FiniteElement::~FiniteElement
virtual ~FiniteElement()
Destructor.
Definition FiniteElement.h:45
dolfin
Definition adapt.h:30