Assemble the system matrix and rhs vector.
204{
207
209
211
212 const DofMap & dof_map = system.get_dof_map();
213
214 FEType fe_type = dof_map.variable_type(0);
215
219
222
223 fe->attach_quadrature_rule (&qrule);
224 fe_elem_face->attach_quadrature_rule (&qface);
225 fe_neighbor_face->attach_quadrature_rule (&qface);
226
227 const std::vector<Real> & JxW = fe->get_JxW();
228 const std::vector<std::vector<Real>> & phi = fe->get_phi();
229 const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
230
231 const std::vector<Real> & JxW_face = fe_elem_face->get_JxW();
232
233 const std::vector<Point> & qface_points = fe_elem_face->get_xyz();
234
235 const std::vector<std::vector<Real>> & phi_face = fe_elem_face->get_phi();
236 const std::vector<std::vector<Real>> & phi_neighbor_face = fe_neighbor_face->get_phi();
237
240
245
246 std::vector<dof_id_type> dof_indices;
248
249 for (
const auto & elem :
mesh.active_local_element_ptr_range())
250 {
251 dof_map.dof_indices (elem, dof_indices);
252 const unsigned int n_dofs = dof_indices.size();
253
254 fe->reinit (elem);
255
256 Ke.
resize (n_dofs, n_dofs);
258
259
260 for (unsigned int qp=0; qp<qrule.n_points(); qp++)
261 for (unsigned int i=0; i<n_dofs; i++)
262 for (unsigned int j=0; j<n_dofs; j++)
263 Ke(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);
264
265
266 {
267 for (auto side : elem->side_index_range())
268 if (elem->neighbor_ptr(side) == nullptr)
269 {
271 {
272 fe_elem_face->reinit(elem, side);
273
274 for (unsigned int qp=0; qp<qface.n_points(); qp++)
275 for (std::size_t i=0; i<phi.size(); i++)
276 Fe(i) += JxW_face[qp] * phi_face[i][qp];
277 }
278
279 }
280 }
281
282
283 {
284 for (auto side : elem->side_index_range())
285 if (elem->neighbor_ptr(side) == nullptr)
286 {
287
289 {
290 fe_elem_face->reinit(elem, side);
291
292 ElementSideMap::const_iterator ltu_it =
293 lower_to_upper.find(std::make_pair(elem, side));
295
296 const Elem * neighbor = ltu_it->second;
297
298 std::vector<Point> qface_neighbor_points;
300 qface_points,
301 qface_neighbor_points);
302 fe_neighbor_face->reinit(neighbor, &qface_neighbor_points);
303
304 std::vector<dof_id_type> neighbor_dof_indices;
305 dof_map.dof_indices (neighbor, neighbor_dof_indices);
306 const unsigned int n_neighbor_dofs = neighbor_dof_indices.size();
307
308 Kne.
resize (n_neighbor_dofs, n_dofs);
309 Ken.
resize (n_dofs, n_neighbor_dofs);
310 Kee.
resize (n_dofs, n_dofs);
311 Knn.
resize (n_neighbor_dofs, n_neighbor_dofs);
312
313
314 for (unsigned int qp=0; qp<qface.n_points(); qp++)
315 for (unsigned int i=0; i<n_dofs; i++)
316 for (unsigned int j=0; j<n_dofs; j++)
317 Kee(i,j) -= JxW_face[qp] * (1./R)*(phi_face[i][qp] * phi_face[j][qp]);
318
319
320 for (unsigned int qp=0; qp<qface.n_points(); qp++)
321 for (unsigned int i=0; i<n_dofs; i++)
322 for (unsigned int j=0; j<n_neighbor_dofs; j++)
323 Ken(i,j) += JxW_face[qp] * (1./R)*(phi_face[i][qp] * phi_neighbor_face[j][qp]);
324
325
326 for (unsigned int qp=0; qp<qface.n_points(); qp++)
327 for (unsigned int i=0; i<n_neighbor_dofs; i++)
328 for (unsigned int j=0; j<n_neighbor_dofs; j++)
329 Knn(i,j) -= JxW_face[qp] * (1./R)*(phi_neighbor_face[i][qp] * phi_neighbor_face[j][qp]);
330
331
332 for (unsigned int qp=0; qp<qface.n_points(); qp++)
333 for (unsigned int i=0; i<n_neighbor_dofs; i++)
334 for (unsigned int j=0; j<n_dofs; j++)
335 Kne(i,j) += JxW_face[qp] * (1./R)*(phi_neighbor_face[i][qp] * phi_face[j][qp]);
336
337 matrix.
add_matrix(Kne, neighbor_dof_indices, dof_indices);
338 matrix.
add_matrix(Ken, dof_indices, neighbor_dof_indices);
341 }
342 }
343 }
344
345 dof_map.constrain_element_matrix_and_vector (Ke, Fe, dof_indices);
346
348 system.rhs->add_vector (Fe, dof_indices);
349 }
350}
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
Defines a dense matrix for use in Finite Element-type computations.
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
Defines a dense vector for use in Finite Element-type computations.
void resize(const unsigned int n)
Resize the vector.
This class handles the numbering of degrees of freedom on a mesh.
This is the base class from which all geometric element types are derived.
const MeshBase & get_mesh() const
Parameters parameters
Data structure holding arbitrary parameters.
const T_sys & get_system(std::string_view name) const
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Order default_quadrature_order() const
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
This is the MeshBase class.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
unsigned int mesh_dimension() const
const T & get(std::string_view) const
This class implements specific orders of Gauss quadrature.
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols)=0
Add the full matrix dm to the SparseMatrix.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real