341{
342
343
344 libmesh_assert_equal_to (system_name, "Navier-Stokes");
345
346#if LIBMESH_DIM > 1
347
349
350
352
353
356
357
358 const unsigned int u_var = navier_stokes_system.variable_number ("vel_x");
359 const unsigned int v_var = navier_stokes_system.variable_number ("vel_y");
360 const unsigned int p_var = navier_stokes_system.variable_number ("p");
361 const unsigned int alpha_var = navier_stokes_system.variable_number ("alpha");
362
363
364
365 FEType fe_vel_type = navier_stokes_system.variable_type(u_var);
366
367
368 FEType fe_pres_type = navier_stokes_system.variable_type(p_var);
369
370
371
373
374
375
377
378
379
381
382
383 fe_vel->attach_quadrature_rule (&qrule);
384 fe_pres->attach_quadrature_rule (&qrule);
385
386
387
388
389
390 const std::vector<Real> & JxW = fe_vel->get_JxW();
391
392
393 const std::vector<std::vector<Real>> & phi = fe_vel->get_phi();
394
395
396
397 const std::vector<std::vector<RealGradient>> & dphi = fe_vel->get_dphi();
398
399
400
401 const std::vector<std::vector<Real>> & psi = fe_pres->get_phi();
402
403
404
405
406
407
408
409
410 const DofMap & dof_map = navier_stokes_system.get_dof_map();
411
412
413
414
415
418
420 Kuu(Ke), Kuv(Ke), Kup(Ke),
421 Kvu(Ke), Kvv(Ke), Kvp(Ke),
422 Kpu(Ke), Kpv(Ke), Kpp(Ke);
424
426 Fu(Fe),
427 Fv(Fe),
428 Fp(Fe);
429
430
431
432
433 std::vector<dof_id_type> dof_indices;
434 std::vector<dof_id_type> dof_indices_u;
435 std::vector<dof_id_type> dof_indices_v;
436 std::vector<dof_id_type> dof_indices_p;
437 std::vector<dof_id_type> dof_indices_alpha;
438
439
441
442
443
444
445
446
447
448
449
450
451
453 const Real theta = 1.;
454
455
457
458
459
460
461
462
463 for (
const auto & elem :
mesh.active_local_element_ptr_range())
464 {
465
466
467
468
473 dof_map.
dof_indices (elem, dof_indices_alpha, alpha_var);
474
475 const unsigned int n_dofs = dof_indices.size();
476 const unsigned int n_u_dofs = dof_indices_u.size();
477 const unsigned int n_v_dofs = dof_indices_v.size();
478 const unsigned int n_p_dofs = dof_indices_p.size();
479
480
481
482
483
484 fe_vel->reinit (elem);
485 fe_pres->reinit (elem);
486
487
488
489
490
491
492
493 Ke.
resize (n_dofs, n_dofs);
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509 Kuu.reposition (u_var*n_u_dofs, u_var*n_u_dofs, n_u_dofs, n_u_dofs);
510 Kuv.reposition (u_var*n_u_dofs, v_var*n_u_dofs, n_u_dofs, n_v_dofs);
511 Kup.reposition (u_var*n_u_dofs, p_var*n_u_dofs, n_u_dofs, n_p_dofs);
512
513 Kvu.reposition (v_var*n_v_dofs, u_var*n_v_dofs, n_v_dofs, n_u_dofs);
514 Kvv.reposition (v_var*n_v_dofs, v_var*n_v_dofs, n_v_dofs, n_v_dofs);
515 Kvp.reposition (v_var*n_v_dofs, p_var*n_v_dofs, n_v_dofs, n_p_dofs);
516
517 Kpu.reposition (p_var*n_u_dofs, u_var*n_u_dofs, n_p_dofs, n_u_dofs);
518 Kpv.reposition (p_var*n_u_dofs, v_var*n_u_dofs, n_p_dofs, n_v_dofs);
519 Kpp.reposition (p_var*n_u_dofs, p_var*n_u_dofs, n_p_dofs, n_p_dofs);
520
521
522 Kp_alpha.reposition (p_var*n_u_dofs, p_var*n_u_dofs+n_p_dofs, n_p_dofs, 1);
523 Kalpha_p.reposition (p_var*n_u_dofs+n_p_dofs, p_var*n_u_dofs, 1, n_p_dofs);
524
525
526 Fu.reposition (u_var*n_u_dofs, n_u_dofs);
527 Fv.reposition (v_var*n_u_dofs, n_v_dofs);
528 Fp.reposition (p_var*n_u_dofs, n_p_dofs);
529
530
531
532
533
534
535
536 for (unsigned int qp=0; qp<qrule.n_points(); qp++)
537 {
538
539 Number u = 0., u_old = 0.;
540 Number v = 0., v_old = 0.;
544
545
546
547 for (unsigned int l=0; l<n_u_dofs; l++)
548 {
549
550 u_old += phi[l][qp]*navier_stokes_system.
old_solution (dof_indices_u[l]);
551 v_old += phi[l][qp]*navier_stokes_system.
old_solution (dof_indices_v[l]);
554
555
556 u += phi[l][qp]*navier_stokes_system.current_solution (dof_indices_u[l]);
557 v += phi[l][qp]*navier_stokes_system.current_solution (dof_indices_v[l]);
558 grad_u.
add_scaled (dphi[l][qp], navier_stokes_system.current_solution (dof_indices_u[l]));
559 grad_v.
add_scaled (dphi[l][qp], navier_stokes_system.current_solution (dof_indices_v[l]));
560 }
561
562
563 for (unsigned int l=0; l<n_p_dofs; l++)
564 p_old += psi[l][qp]*navier_stokes_system.
old_solution (dof_indices_p[l]);
565
566
567
570 const Number u_x = grad_u(0);
571 const Number u_y = grad_u(1);
572 const Number v_x = grad_v(0);
573 const Number v_y = grad_v(1);
574
575
576
577
578 for (unsigned int i=0; i<n_u_dofs; i++)
579 {
580 Fu(i) += JxW[qp]*(u_old*phi[i][qp] -
581 (1.-theta)*dt*(U_old*grad_u_old)*phi[i][qp] +
582 (1.-theta)*dt*p_old*dphi[i][qp](0) -
583 (1.-theta)*dt*nu*(grad_u_old*dphi[i][qp]) +
584 theta*dt*(U*grad_u)*phi[i][qp]);
585
586
587 Fv(i) += JxW[qp]*(v_old*phi[i][qp] -
588 (1.-theta)*dt*(U_old*grad_v_old)*phi[i][qp] +
589 (1.-theta)*dt*p_old*dphi[i][qp](1) -
590 (1.-theta)*dt*nu*(grad_v_old*dphi[i][qp]) +
591 theta*dt*(U*grad_v)*phi[i][qp]);
592
593
594
595
596
597
598 for (unsigned int j=0; j<n_u_dofs; j++)
599 {
600 Kuu(i,j) += JxW[qp]*(phi[i][qp]*phi[j][qp] +
601 theta*dt*nu*(dphi[i][qp]*dphi[j][qp]) +
602 theta*dt*(U*dphi[j][qp])*phi[i][qp] +
603 theta*dt*u_x*phi[i][qp]*phi[j][qp]);
604
605 Kuv(i,j) += JxW[qp]*theta*dt*u_y*phi[i][qp]*phi[j][qp];
606
607 Kvv(i,j) += JxW[qp]*(phi[i][qp]*phi[j][qp] +
608 theta*dt*nu*(dphi[i][qp]*dphi[j][qp]) +
609 theta*dt*(U*dphi[j][qp])*phi[i][qp] +
610 theta*dt*v_y*phi[i][qp]*phi[j][qp]);
611
612 Kvu(i,j) += JxW[qp]*theta*dt*v_x*phi[i][qp]*phi[j][qp];
613 }
614
615
616 for (unsigned int j=0; j<n_p_dofs; j++)
617 {
618 Kup(i,j) += JxW[qp]*(-theta*dt*psi[j][qp]*dphi[i][qp](0));
619 Kvp(i,j) += JxW[qp]*(-theta*dt*psi[j][qp]*dphi[i][qp](1));
620 }
621 }
622
623
624
625
626
627 for (unsigned int i=0; i<n_p_dofs; i++)
628 {
629 Kp_alpha(i,0) += JxW[qp]*psi[i][qp];
630 Kalpha_p(0,i) += JxW[qp]*psi[i][qp];
631 for (unsigned int j=0; j<n_u_dofs; j++)
632 {
633 Kpu(i,j) += JxW[qp]*psi[i][qp]*dphi[j][qp](0);
634 Kpv(i,j) += JxW[qp]*psi[i][qp]*dphi[j][qp](1);
635 }
636 }
637 }
638
639
640
641
643
644
645
646
647
649 navier_stokes_system.rhs->add_vector (Fe, dof_indices);
650 }
651
652
653
654 navier_stokes_system.rhs->add(navier_stokes_system.rhs->size()-1, 10.);
655#else
657#endif
658}
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 submatrix for use in Finite Element-type computations.
Defines a dense subvector for use in finite element computations.
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.
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
void heterogenously_constrain_element_matrix_and_vector(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true, int qoi_index=-1) const
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.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Order default_quadrature_order() const
This is the MeshBase class.
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.
Manages storage and variables for transient systems.
Number old_solution(const dof_id_type global_dof_number) const
void add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
void libmesh_ignore(const Args &...)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real