DOLFIN
DOLFIN C++ interface
Form.h
1 // Copyright (C) 2007-2014 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 // Modified by Garth N. Wells 2008-2011
19 // Modified by Martin Alnes 2008
20 //
21 // First added: 2007-04-02
22 // Last changed: 2014-02-14
23 
24 #ifndef __FORM_H
25 #define __FORM_H
26 
27 #include <map>
28 #include <vector>
29 #include <memory>
30 
31 #include <dolfin/common/Hierarchical.h>
32 #include <dolfin/common/types.h>
33 #include "Equation.h"
34 
35 // Forward declaration
36 namespace ufc
37 {
38  class form;
39 }
40 
41 namespace dolfin
42 {
43 
44  class FunctionSpace;
45  class GenericFunction;
46  class Mesh;
47  template <typename T> class MeshFunction;
48 
50 
84 
85  class Form : public Hierarchical<Form>
86  {
87  public:
88 
95  Form(std::size_t rank, std::size_t num_coefficients);
96 
103  Form(std::shared_ptr<const ufc::form> ufc_form,
104  std::vector<std::shared_ptr<const FunctionSpace>> function_spaces);
105 
107  virtual ~Form();
108 
114  std::size_t rank() const;
115 
120  std::size_t num_coefficients() const;
121 
127  std::size_t original_coefficient_position(std::size_t i) const;
128 
137  std::vector<std::size_t> coloring(std::size_t entity_dim) const;
138 
144  void set_mesh(std::shared_ptr<const Mesh> mesh);
145 
150  std::shared_ptr<const Mesh> mesh() const;
151 
159  std::shared_ptr<const FunctionSpace> function_space(std::size_t i) const;
160 
165  std::vector<std::shared_ptr<const FunctionSpace>> function_spaces() const;
166 
173  void set_coefficient(std::size_t i,
174  std::shared_ptr<const GenericFunction> coefficient);
175 
182  void set_coefficient(std::string name,
183  std::shared_ptr<const GenericFunction> coefficient);
184 
191  void set_coefficients(std::map<std::string,
192  std::shared_ptr<const GenericFunction>> coefficients);
193 
207  void set_some_coefficients(std::map<std::string,
208  std::shared_ptr<const GenericFunction>> coefficients);
209 
217  std::shared_ptr<const GenericFunction> coefficient(std::size_t i) const;
218 
226  std::shared_ptr<const GenericFunction> coefficient(std::string name) const;
227 
232  std::vector<std::shared_ptr<const GenericFunction>> coefficients() const;
233 
241  virtual std::size_t coefficient_number(const std::string & name) const;
242 
250  virtual std::string coefficient_name(std::size_t i) const;
251 
257  std::shared_ptr<const MeshFunction<std::size_t>> cell_domains() const;
258 
264  std::shared_ptr<const MeshFunction<std::size_t>>
265  exterior_facet_domains() const;
266 
272  std::shared_ptr<const MeshFunction<std::size_t>>
273  interior_facet_domains() const;
274 
280  std::shared_ptr<const MeshFunction<std::size_t>> vertex_domains() const;
281 
286  void set_cell_domains(std::shared_ptr<const MeshFunction<std::size_t>>
287  cell_domains);
288 
293  void set_exterior_facet_domains(std::shared_ptr<const MeshFunction<std::size_t>> exterior_facet_domains);
294 
299  void set_interior_facet_domains(std::shared_ptr<const MeshFunction<std::size_t>> interior_facet_domains);
300 
305  void set_vertex_domains(std::shared_ptr<const MeshFunction<std::size_t>> vertex_domains);
306 
311  std::shared_ptr<const ufc::form> ufc_form() const;
312 
314  void check() const;
315 
317  Equation operator==(const Form& rhs) const;
318 
320  Equation operator==(int rhs) const;
321 
323  std::shared_ptr<const MeshFunction<std::size_t>> dx;
325  std::shared_ptr<const MeshFunction<std::size_t>> ds;
327  std::shared_ptr<const MeshFunction<std::size_t>> dS;
329  std::shared_ptr<const MeshFunction<std::size_t>> dP;
330 
331  protected:
332 
333  // The UFC form
334  std::shared_ptr<const ufc::form> _ufc_form;
335 
336  // Function spaces (one for each argument)
337  std::vector<std::shared_ptr<const FunctionSpace>> _function_spaces;
338 
339  // Coefficients
340  std::vector<std::shared_ptr<const GenericFunction>> _coefficients;
341 
342  // The mesh (needed for functionals when we don't have any spaces)
343  std::shared_ptr<const Mesh> _mesh;
344 
345  private:
346 
347  const std::size_t _rank;
348 
349  };
350 
351 }
352 
353 #endif
std::shared_ptr< const MeshFunction< std::size_t > > dS
Domain markers for interior facets.
Definition: Form.h:327
Base class for UFC code generated by FFC for DOLFIN with option -l.
Definition: Form.h:85
Definition: Hierarchical.h:43
Definition: adapt.h:29
std::shared_ptr< const MeshFunction< std::size_t > > dP
Domain markers for vertices.
Definition: Form.h:329
Definition: Extrapolation.h:34
std::shared_ptr< const MeshFunction< std::size_t > > dx
Domain markers for cells.
Definition: Form.h:323
std::shared_ptr< const MeshFunction< std::size_t > > ds
Domain markers for exterior facets.
Definition: Form.h:325
Definition: Equation.h:40