DOLFIN
DOLFIN C++ interface
MultiMeshFunction.h
1 // Copyright (C) 2013-2016 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: 2013-09-25
19 // Last changed: 2016-03-02
20 
21 #ifndef __MULTI_MESH_FUNCTION_H
22 #define __MULTI_MESH_FUNCTION_H
23 
24 #include <memory>
25 #include <boost/ptr_container/ptr_map.hpp>
26 #include <dolfin/common/Variable.h>
27 
28 namespace dolfin
29 {
30 
31  // Forward declarations
32  class MultiMeshFunctionSpace;
33  class GenericVector;
34  class Function;
35  class MultiMeshFunction;
36  class FiniteElement;
37 
41 
42  class MultiMeshFunction : public Variable
43  {
44  public:
45 
48 
54  explicit MultiMeshFunction(std::shared_ptr<const MultiMeshFunctionSpace> V);
55 
66  MultiMeshFunction(std::shared_ptr<const MultiMeshFunctionSpace> V,
67  std::shared_ptr<GenericVector> x);
68 
70  virtual ~MultiMeshFunction();
71 
79  void assign_part(std::size_t a, const Function& v);
80 
86  std::shared_ptr<const Function> part(std::size_t i) const;
87 
94  std::shared_ptr<const Function> part(std::size_t i, bool deepcopy) const;
95 
101  std::shared_ptr<GenericVector> vector();
102 
108  std::shared_ptr<const GenericVector> vector() const;
109 
115  virtual std::shared_ptr<const MultiMeshFunctionSpace> function_space() const
116  {
117  return _function_space;
118  }
119 
133  void restrict(double* w,
134  const FiniteElement& element,
135  std::size_t part,
136  const Cell& dolfin_cell,
137  const double* coordinate_dofs,
138  const ufc::cell& ufc_cell) const;
139 
149  void eval(Array<double>& values, const Array<double>& x,
150  std::size_t part,
151  const ufc::cell& cell) const;
152 
154  void eval(Array<double>& values, const Array<double>& x) const;
155 
157  void restrict_as_ufc_function(double* w,
158  const FiniteElement& element,
159  std::size_t part,
160  const Cell& dolfin_cell,
161  const double* coordinate_dofs,
162  const ufc::cell& ufc_cell) const;
163 
164  private:
165 
166  // Initialize vector
167  void init_vector();
168 
169  // Compute ghost indices
170  void compute_ghost_indices(std::pair<std::size_t, std::size_t> range,
171  std::vector<la_index>& ghost_indices) const;
172 
173  // The function space
174  std::shared_ptr<const MultiMeshFunctionSpace> _function_space;
175 
176  // The vector of expansion coefficients (local)
177  std::shared_ptr<GenericVector> _vector;
178 
179  // Cache of regular functions for the parts
180  mutable std::map<std::size_t, std::shared_ptr<const Function> > _function_parts;
181 
182  };
183 
184 }
185 
186 #endif
Common base class for DOLFIN variables.
Definition: Variable.h:35
Definition: MultiMeshFunction.h:42
Definition: adapt.h:29
Definition: Array.h:41
void restrict(double *w, const FiniteElement &element, std::size_t part, const Cell &dolfin_cell, const double *coordinate_dofs, const ufc::cell &ufc_cell) const
Definition: MultiMeshFunction.cpp:215
std::shared_ptr< const Function > part(std::size_t i) const
Definition: MultiMeshFunction.cpp:65
void assign_part(std::size_t a, const Function &v)
Definition: MultiMeshFunction.cpp:88
MultiMeshFunction()
Constructor.
Definition: MultiMeshFunction.cpp:34
A Cell is a MeshEntity of topological codimension 0.
Definition: Cell.h:42
void eval(Array< double > &values, const Array< double > &x, std::size_t part, const ufc::cell &cell) const
Definition: MultiMeshFunction.cpp:246
void restrict_as_ufc_function(double *w, const FiniteElement &element, std::size_t part, const Cell &dolfin_cell, const double *coordinate_dofs, const ufc::cell &ufc_cell) const
Restrict as UFC function (by calling eval)
Definition: MultiMeshFunction.cpp:288
Definition: Function.h:65
std::shared_ptr< GenericVector > vector()
Definition: MultiMeshFunction.cpp:150
virtual ~MultiMeshFunction()
Destructor.
Definition: MultiMeshFunction.cpp:60
virtual std::shared_ptr< const MultiMeshFunctionSpace > function_space() const
Definition: MultiMeshFunction.h:115
This is a wrapper for a UFC finite element (ufc::finite_element).
Definition: FiniteElement.h:35