9 #include "assemble_matrix_impl.h"
10 #include "assemble_scalar_impl.h"
11 #include "assemble_vector_impl.h"
12 #include <Eigen/Dense>
40 return fem::impl::assemble_scalar(M);
53 fem::impl::assemble_vector(b, L);
76 Eigen::Ref<Eigen::Matrix<T, Eigen::Dynamic, 1>> b,
77 const std::vector<std::shared_ptr<
const Form<T>>>& a,
78 const std::vector<std::vector<std::shared_ptr<
const DirichletBC<T>>>>& bcs1,
79 const std::vector<Eigen::Ref<
const Eigen::Matrix<T, Eigen::Dynamic, 1>>>&
83 fem::impl::apply_lifting(b, a, bcs1, x0, scale);
96 const std::function<
int(std::int32_t,
const std::int32_t*, std::int32_t,
97 const std::int32_t*,
const T*)>& mat_add,
107 std::vector<bool> dof_marker0, dof_marker1;
109 = map0->block_size() * (map0->size_local() + map0->num_ghosts());
111 = map1->block_size() * (map1->size_local() + map1->num_ghosts());
112 for (std::size_t k = 0; k < bcs.size(); ++k)
115 assert(bcs[k]->function_space());
118 dof_marker0.resize(dim0,
false);
119 bcs[k]->mark_dofs(dof_marker0);
123 dof_marker1.resize(dim1,
false);
124 bcs[k]->mark_dofs(dof_marker1);
129 impl::assemble_matrix(mat_add, a, dof_marker0, dof_marker1);
142 template <
typename T>
144 const std::function<
int(std::int32_t,
const std::int32_t*, std::int32_t,
145 const std::int32_t*,
const T*)>& mat_add,
146 const Form<T>& a,
const std::vector<bool>& dof_marker0,
147 const std::vector<bool>& dof_marker1)
150 impl::assemble_matrix(mat_add, a, dof_marker0, dof_marker1);
163 template <
typename T>
165 const std::function<
int(std::int32_t,
const std::int32_t*, std::int32_t,
166 const std::int32_t*,
const T*)>& mat_add,
167 const Eigen::Ref<
const Eigen::Array<std::int32_t, Eigen::Dynamic, 1>>& rows,
170 for (Eigen::Index i = 0; i < rows.size(); ++i)
172 const std::int32_t row = rows(i);
173 mat_add(1, &row, 1, &row, &diagonal);
192 template <
typename T>
194 const std::function<
int(std::int32_t,
const std::int32_t*, std::int32_t,
195 const std::int32_t*,
const T*)>& mat_add,
200 for (
const auto& bc : bcs)
203 if (V.
contains(*bc->function_space()))
204 add_diagonal<T>(mat_add, bc->dofs_owned().col(0), diagonal);
218 template <
typename T>
219 void set_bc(Eigen::Ref<Eigen::Matrix<T, Eigen::Dynamic, 1>> b,
221 const Eigen::Ref<
const Eigen::Matrix<T, Eigen::Dynamic, 1>>& x0,
224 if (b.rows() > x0.rows())
225 throw std::runtime_error(
"Size mismatch between b and x0 vectors.");
226 for (
const auto& bc : bcs)
229 bc->set(b, x0, scale);
236 template <
typename T>
237 void set_bc(Eigen::Ref<Eigen::Matrix<T, Eigen::Dynamic, 1>> b,
241 for (
const auto& bc : bcs)
258 template <
typename T>
259 std::vector<std::vector<std::shared_ptr<const fem::DirichletBC<T>>>>
264 std::vector<std::vector<std::shared_ptr<const fem::DirichletBC<T>>>> bcs0(
266 for (std::size_t i = 0; i < L.size(); ++i)
268 if (L[i]->function_space(0)->contains(*bc->function_space()))
269 bcs0[i].push_back(bc);
283 template <
typename T>
285 std::vector<std::vector<std::shared_ptr<const fem::DirichletBC<T>>>>>
291 std::vector<std::vector<std::shared_ptr<const fem::DirichletBC<T>>>>>
293 for (std::size_t i = 0; i < a.size(); ++i)
295 for (std::size_t j = 0; j < a[i].size(); ++j)
297 bcs1[i].resize(a[j].size());
303 if (a[i][j]->function_space(1)->contains(*bc->function_space()))
304 bcs1[i][j].push_back(bc);