DOLFIN-X
DOLFIN-X C++ interface
|
10 #include <dolfinx/function/Function.h>
44 for (
const auto& c : coefficients)
46 _original_pos.push_back(std::get<0>(c));
47 _names.push_back(std::get<1>(c));
48 _coefficients.push_back(std::get<2>(c));
53 int size()
const {
return _coefficients.size(); }
60 std::vector<int> n{0};
61 for (
const auto& c : _coefficients)
64 throw std::runtime_error(
"Not all form coefficients have been set.");
65 n.push_back(n.back() + c->function_space()->element()->space_dimension());
74 if (i >= (
int)_coefficients.size())
75 _coefficients.resize(i + 1);
76 _coefficients[i] = coefficient;
80 void set(
const std::string& name,
84 if (i >= (
int)_coefficients.size())
85 _coefficients.resize(i + 1);
86 _coefficients[i] = coefficient;
90 std::shared_ptr<const function::Function<T>>
get(
int i)
const
92 return _coefficients.at(i);
105 auto it = std::find(_names.begin(), _names.end(), name);
106 if (it == _names.end())
107 throw std::runtime_error(
"Cannot find coefficient name:" + name);
108 return std::distance(_names.begin(), it);
116 if (index >= (
int)_names.size())
117 throw std::runtime_error(
"Invalid coefficient index");
118 return _names[index];
123 std::vector<std::shared_ptr<const function::Function<T>>> _coefficients;
126 std::vector<int> _original_pos;
129 std::vector<std::string> _names;
This class represents a function in a finite element function space , given by.
Definition: DirichletBC.h:22