322{
323
324
325 libmesh_assert_equal_to (system_name, "Poisson");
326
327
328
329
330
331 PerfLog perf_log (
"Matrix Assembly");
332
333
335
336
338
339
341
342
343
344
345
347
348
349
350 FEType fe_type = dof_map.variable_type(0);
351
352
353
354
355
357
358
360
361
362 fe->attach_quadrature_rule (&qrule);
363
364
365
367
368
369
370
372
373
374
375 fe_face->attach_quadrature_rule (&qface);
376
377
378
379
380
381 const std::vector<Real> & JxW = fe->get_JxW();
382
383
384
385
386 const std::vector<Point> & q_point = fe->get_xyz();
387
388
389 const std::vector<std::vector<Real>> & phi = fe->get_phi();
390
391
392
393 const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
394
395
396
397
398
401
402
403
404
405 std::vector<dof_id_type> dof_indices;
406
407
409
410
411
412
413
414 for (
const auto & elem :
mesh.active_local_element_ptr_range())
415 {
416
417
418 if (elem->subdomain_id()==1)
419 {
420
421
422
423 perf_log.push("elem init");
424
425
426
427
428
429 dof_map.dof_indices (elem, dof_indices);
430
431
432
433
434
435 fe->reinit (elem);
436
437
438
439
440
441
442
443 Ke.
resize (dof_indices.size(),
444 dof_indices.size());
445
446 Fe.
resize (dof_indices.size());
447
448
449
450
451 perf_log.pop("elem init");
452
453
454
455
456
457
458
459
460
461
462 perf_log.push ("Ke");
463
464 for (unsigned int qp=0; qp<qrule.n_points(); qp++)
465 for (std::size_t i=0; i<phi.size(); i++)
466 for (std::size_t j=0; j<phi.size(); j++)
467 Ke(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);
468
469
470
471 perf_log.pop ("Ke");
472
473
474
475
476
477
478 perf_log.push ("Fe");
479
480 for (unsigned int qp=0; qp<qrule.n_points(); qp++)
481 {
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496 const Real x = q_point[qp](0);
497#if LIBMESH_DIM > 1
498 const Real y = q_point[qp](1);
499#else
501#endif
502#if LIBMESH_DIM > 2
503 const Real z = q_point[qp](2);
504#else
506#endif
507 const Real eps = 1.e-3;
508
512
516
520
523 {
524
525
527 fxy = (0.25*
pi*
pi)*sin(.5*
pi*x);
528 }
529 else
530 {
531 fxy = - (uxx + uyy + ((
dim==2) ? 0. : uzz));
532 }
533
534
535 for (std::size_t i=0; i<phi.size(); i++)
536 Fe(i) += JxW[qp]*fxy*phi[i][qp];
537 }
538
539
540 perf_log.pop ("Fe");
541
542
543
544
545
546
547
548 {
549
550
551 LOG_SCOPE_WITH("BCs", "", perf_log);
552
553
554
555
556
557
558
559 for (auto side : elem->side_index_range())
560 if ((elem->neighbor_ptr(side) == nullptr) ||
561 (elem->neighbor_ptr(side)->subdomain_id()!=1))
562 {
563
564
565
566 const Real penalty = 1.e10;
567
568
569
570 const std::vector<std::vector<Real>> & phi_face = fe_face->get_phi();
571
572
573
574 const std::vector<Real> & JxW_face = fe_face->get_JxW();
575
576
577
578
579 const std::vector<Point> & qface_point = fe_face->get_xyz();
580
581
582
583 fe_face->reinit(elem, side);
584
585
586 for (unsigned int qp=0; qp<qface.n_points(); qp++)
587 {
588
589
590 const Real xf = qface_point[qp](0);
591#if LIBMESH_DIM > 1
592 const Real yf = qface_point[qp](1);
593#else
595#endif
596#if LIBMESH_DIM > 2
597 const Real zf = qface_point[qp](2);
598#else
600#endif
601
602
603
605
606
607 for (std::size_t i=0; i<phi_face.size(); i++)
608 for (std::size_t j=0; j<phi_face.size(); j++)
609 Ke(i,j) += JxW_face[qp]*penalty*phi_face[i][qp]*phi_face[j][qp];
610
611
612
613 for (std::size_t i=0; i<phi_face.size(); i++)
614 Fe(i) += JxW_face[qp]*penalty*
value*phi_face[i][qp];
615 }
616 }
617 }
618
619
620
621 dof_map.constrain_element_matrix_and_vector (Ke, Fe, dof_indices);
622
623
624
625
626
627
628
629 LOG_SCOPE_WITH("matrix insertion", "", perf_log);
630
633 }
634 }
635
636
637
638
639}
Number(* exact_solution)(const Point &p, const Parameters &, const std::string &, const std::string &)
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.
const MeshBase & get_mesh() const
const T_sys & get_system(std::string_view name) const
NumericVector< Number > * rhs
The system matrix.
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
const SparseMatrix< Number > & get_system_matrix() const
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
This is the MeshBase class.
unsigned int mesh_dimension() const
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i].
The PerfLog class allows monitoring of specific events.
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.
const DofMap & get_dof_map() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real