DOLFIN-X
DOLFIN-X C++ interface
FormCoefficients.h
1 // Copyright (C) 2018 Chris Richardson
2 //
3 // This file is part of DOLFINX (https://www.fenicsproject.org)
4 //
5 // SPDX-License-Identifier: LGPL-3.0-or-later
6 
7 #pragma once
8 
9 #include <memory>
10 #include <string>
11 #include <utility>
12 #include <vector>
13 
14 namespace dolfinx
15 {
16 
17 namespace function
18 {
19 class Function;
20 }
21 
22 namespace fem
23 {
24 class FiniteElement;
25 
28 
30 {
31 public:
36  const std::vector<
37  std::tuple<int, std::string, std::shared_ptr<function::Function>>>&
38  coefficients);
39 
41  int size() const;
42 
46  std::vector<int> offsets() const;
47 
49  void set(int i, std::shared_ptr<const function::Function> coefficient);
50 
52  void set(std::string name,
53  std::shared_ptr<const function::Function> coefficient);
54 
56  std::shared_ptr<const function::Function> get(int i) const;
57 
59  int original_position(int i) const;
60 
64  int get_index(std::string name) const;
65 
69  std::string get_name(int index) const;
70 
71 private:
72  // Functions for the coefficients
73  std::vector<std::shared_ptr<const function::Function>> _coefficients;
74 
75  // Copy of 'original positions' in UFL form
76  std::vector<int> _original_pos;
77 
78  // Names of coefficients
79  std::vector<std::string> _names;
80 };
81 } // namespace fem
82 } // namespace dolfinx
dolfinx::fem::FormCoefficients::offsets
std::vector< int > offsets() const
Offset for each coefficient expansion array on a cell. Used to pack data for multiple coefficients in...
Definition: FormCoefficients.cpp:32
dolfinx::fem::FormCoefficients::FormCoefficients
FormCoefficients(const std::vector< std::tuple< int, std::string, std::shared_ptr< function::Function >>> &coefficients)
Initialise the FormCoefficients, using tuples of (original_coeff_position, name, shared_ptr<function:...
Definition: FormCoefficients.cpp:18
dolfinx::fem::FormCoefficients::get_index
int get_index(std::string name) const
Get index from name of coefficient.
Definition: FormCoefficients.cpp:73
dolfinx::fem::FormCoefficients::size
int size() const
Get number of coefficients.
Definition: FormCoefficients.cpp:30
dolfinx::fem::FormCoefficients::original_position
int original_position(int i) const
Original position of coefficient in UFL form.
Definition: FormCoefficients.cpp:68
dolfinx::fem::FormCoefficients::get
std::shared_ptr< const function::Function > get(int i) const
Get the Function coefficient i.
Definition: FormCoefficients.cpp:63
dolfinx::fem::FormCoefficients::set
void set(int i, std::shared_ptr< const function::Function > coefficient)
Set coefficient with index i to be a Function.
Definition: FormCoefficients.cpp:44
dolfinx::fem::FormCoefficients
Storage for the coefficients of a Form consisting of Function and the Element objects they are define...
Definition: FormCoefficients.h:29
dolfinx::fem::FormCoefficients::get_name
std::string get_name(int index) const
Get name from index of coefficient.
Definition: FormCoefficients.cpp:82