Assemble the system matrix and rhs vector.
221 const DofMap & dof_map = system.get_dof_map();
223 FEType fe_type = dof_map.variable_type(0);
225 std::unique_ptr<FEBase> fe (FEBase::build(
dim, fe_type));
226 std::unique_ptr<FEBase> fe_elem_face (FEBase::build(
dim, fe_type));
227 std::unique_ptr<FEBase> fe_neighbor_face (FEBase::build(
dim, fe_type));
232 fe->attach_quadrature_rule (&qrule);
233 fe_elem_face->attach_quadrature_rule (&qface);
234 fe_neighbor_face->attach_quadrature_rule (&qface);
236 const std::vector<Real> & JxW = fe->get_JxW();
237 const std::vector<std::vector<Real>> & phi = fe->get_phi();
238 const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
240 const std::vector<Real> & JxW_face = fe_elem_face->get_JxW();
242 const std::vector<Point> & qface_points = fe_elem_face->get_xyz();
244 const std::vector<std::vector<Real>> & phi_face = fe_elem_face->get_phi();
245 const std::vector<std::vector<Real>> & phi_neighbor_face = fe_neighbor_face->get_phi();
255 std::vector<dof_id_type> dof_indices;
259 dof_map.dof_indices (elem, dof_indices);
260 const unsigned int n_dofs = dof_indices.size();
264 Ke.
resize (n_dofs, n_dofs);
268 for (
unsigned int qp=0; qp<qrule.n_points(); qp++)
269 for (
unsigned int i=0; i<n_dofs; i++)
270 for (
unsigned int j=0; j<n_dofs; j++)
271 Ke(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);
275 for (
auto side : elem->side_index_range())
276 if (elem->neighbor_ptr(side) ==
nullptr)
280 fe_elem_face->reinit(elem, side);
282 for (
unsigned int qp=0; qp<qface.n_points(); qp++)
283 for (std::size_t i=0; i<phi.size(); i++)
284 Fe(i) += JxW_face[qp] * phi_face[i][qp];
292 for (
auto side : elem->side_index_range())
293 if (elem->neighbor_ptr(side) ==
nullptr)
298 fe_elem_face->reinit(elem, side);
300 ElementSideMap::const_iterator ltu_it =
301 lower_to_upper.find(std::make_pair(elem, side));
304 const Elem * neighbor = ltu_it->second;
306 std::vector<Point> qface_neighbor_points;
307 FEMap::inverse_map (elem->dim(), neighbor,
309 qface_neighbor_points);
310 fe_neighbor_face->reinit(neighbor, &qface_neighbor_points);
312 std::vector<dof_id_type> neighbor_dof_indices;
313 dof_map.dof_indices (neighbor, neighbor_dof_indices);
314 const unsigned int n_neighbor_dofs = neighbor_dof_indices.size();
316 Kne.
resize (n_neighbor_dofs, n_dofs);
317 Ken.
resize (n_dofs, n_neighbor_dofs);
318 Kee.
resize (n_dofs, n_dofs);
319 Knn.
resize (n_neighbor_dofs, n_neighbor_dofs);
322 for (
unsigned int qp=0; qp<qface.n_points(); qp++)
323 for (
unsigned int i=0; i<n_dofs; i++)
324 for (
unsigned int j=0; j<n_dofs; j++)
325 Kee(i,j) -= JxW_face[qp] * (1./R)*(phi_face[i][qp] * phi_face[j][qp]);
328 for (
unsigned int qp=0; qp<qface.n_points(); qp++)
329 for (
unsigned int i=0; i<n_dofs; i++)
330 for (
unsigned int j=0; j<n_neighbor_dofs; j++)
331 Ken(i,j) += JxW_face[qp] * (1./R)*(phi_face[i][qp] * phi_neighbor_face[j][qp]);
334 for (
unsigned int qp=0; qp<qface.n_points(); qp++)
335 for (
unsigned int i=0; i<n_neighbor_dofs; i++)
336 for (
unsigned int j=0; j<n_neighbor_dofs; j++)
337 Knn(i,j) -= JxW_face[qp] * (1./R)*(phi_neighbor_face[i][qp] * phi_neighbor_face[j][qp]);
340 for (
unsigned int qp=0; qp<qface.n_points(); qp++)
341 for (
unsigned int i=0; i<n_neighbor_dofs; i++)
342 for (
unsigned int j=0; j<n_dofs; j++)
343 Kne(i,j) += JxW_face[qp] * (1./R)*(phi_neighbor_face[i][qp] * phi_face[j][qp]);
345 system.matrix->add_matrix(Kne, neighbor_dof_indices, dof_indices);
346 system.matrix->add_matrix(Ken, dof_indices, neighbor_dof_indices);
347 system.matrix->add_matrix(Kee, dof_indices);
348 system.matrix->add_matrix(Knn, neighbor_dof_indices);
353 dof_map.constrain_element_matrix_and_vector (Ke, Fe, dof_indices);
355 system.matrix->add_matrix (Ke, dof_indices);
356 system.rhs->add_vector (Fe, dof_indices);