2323 * \f]
2424 * can be recoverd setting @p dynamic = false
2525 *
26- * Dynamic Stokes Equation:
27- * \f[
28- * \begin{cases}
29- * \partial_t u - \nu\textrm{div} \epsilon(u)
30- * + \frac{1}{\rho}\nabla p = f \\
31- * \textrm{div}u=0
32- * \end{cases}
33- * \f]
34- * can be recoverd setting @p convection = false
35- *
36- * Stokes Equation:
37- * \f[
38- * \begin{cases}
39- * - \nu\textrm{div} \epsilon(u)
40- * + \frac{1}{\rho}\nabla p = f \\
41- * \textrm{div}u=0
42- * \end{cases}
43- * \f]
44- * can be recoverd setting @p dynamic = false and @p convection = false
4526 *
4627 * In the code we adopt the following notations:
4728 * - Mp := block resulting from \f$ ( \partial_t p, q ) \f$
@@ -119,7 +100,7 @@ class NavierStokes
119100
120101public:
121102 ~NavierStokes () {};
122- NavierStokes (bool dynamic, bool convection );
103+ NavierStokes (bool dynamic);
123104
124105 void declare_parameters (ParameterHandler &prm);
125106 void parse_parameters_call_back ();
@@ -186,12 +167,6 @@ class NavierStokes
186167 */
187168 bool dynamic;
188169
189- /* *
190- * Enable convection term: \f$ (\nabla u)u \f$.
191- * This term introduce the non-linearity of Navier Stokes Equations.
192- */
193- bool convection;
194-
195170 /* *
196171 * TODO:
197172 */
@@ -282,7 +257,7 @@ class NavierStokes
282257
283258template <int dim, int spacedim, typename LAC>
284259NavierStokes<dim,spacedim, LAC>::
285- NavierStokes (bool dynamic, bool convection )
260+ NavierStokes (bool dynamic)
286261 :
287262 PDESystemInterface<dim,spacedim,NavierStokes<dim,spacedim,LAC>, LAC>(
288263 " Navier Stokes Interface" ,
@@ -295,7 +270,6 @@ NavierStokes(bool dynamic, bool convection)
295270 AMG_Ap(" AMG for Ap" ),
296271 jac_Mp(" Jacobi for Mp" , 1.4 ),
297272 dynamic(dynamic),
298- convection(convection),
299273 compute_Mp(false ),
300274 compute_Ap(false ),
301275 is_parallel(Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD) > 1)
@@ -333,10 +307,6 @@ declare_parameters (ParameterHandler &prm)
333307 " Enable dynamic term (\\ partial_t u)" , " true" ,
334308 Patterns::Bool (),
335309 " Enable the dynamic term of the equation." );
336- this ->add_parameter (prm, &convection,
337- " Enable convection term ((\\ nabla u)u)" , " true" ,
338- Patterns::Bool (),
339- " Enable the convection term of the equation. Set it false if you want to solve Stokes Equation." );
340310 this ->add_parameter (prm, &non_linear_term, " Non linear term" ," linear" ,
341311 Patterns::Selection (" fully_non_linear|linear|RHS" ),
342312 " Available options: \n "
@@ -415,8 +385,8 @@ solution_preprocessing(FEValuesCache<dim,spacedim> &fe_cache) const
415385 {
416386 this ->reinit (dummy, cell, face, fe_cache);
417387// Velocity:
418- auto &sym_grad_u_ = fe_cache.get_symmetric_gradients ( " explicit_solution" , " grad_u " , velocity, dummy);
419- auto &p_ = fe_cache.get_values ( " explicit_solution" , " p " , pressure, dummy);
388+ auto &sym_grad_u_ = fe_cache.get_symmetric_gradients ( " explicit_solution" , " f_grad_u " , velocity, dummy);
389+ auto &p_ = fe_cache.get_values ( " explicit_solution" , " f_p " , pressure, dummy);
420390
421391 auto &fev = fe_cache.get_current_fe_values ();
422392 auto &q_points = fe_cache.get_quadrature_points ();
@@ -565,14 +535,14 @@ energies_and_residuals(const typename DoFHandler<dim,spacedim>::active_cell_iter
565535 auto &grad_ps = fe_cache.get_gradients (" solution" , " grad_p" , pressure,et);
566536
567537 // Previous time step solution:
568- auto &u_olds = fe_cache.get_values (" explicit_solution" , " u " , velocity, dummy);
569- auto &grad_u_olds = fe_cache.get_gradients (" explicit_solution" , " grad_u " , velocity, dummy);
538+ auto &u_olds = fe_cache.get_values (" explicit_solution" , " ue " , velocity, dummy);
539+ auto &grad_u_olds = fe_cache.get_gradients (" explicit_solution" , " grad_ue " , velocity, dummy);
570540
571541 // Previous Jacobian step solution:
572542 fe_cache.cache_local_solution_vector (" prev_solution" ,
573543 this ->get_locally_relevant_solution (), dummy);
574- auto &u_prevs = fe_cache.get_values (" prev_solution" , " u " , velocity, dummy);
575- auto &grad_u_prevs = fe_cache.get_gradients (" prev_solution" , " grad_u " , velocity, dummy);
544+ auto &u_prevs = fe_cache.get_values (" prev_solution" , " up " , velocity, dummy);
545+ auto &grad_u_prevs = fe_cache.get_gradients (" prev_solution" , " grad_up " , velocity, dummy);
576546
577547 const unsigned int n_quad_points = us.size ();
578548 auto &JxW = fe_cache.get_JxW_values ();
@@ -620,42 +590,40 @@ energies_and_residuals(const typename DoFHandler<dim,spacedim>::active_cell_iter
620590 if (dynamic)
621591 res += rho * u_dot * v;
622592
623- // Convection:
624- if (convection)
593+ Tensor<2 , dim, ResidualType> gradoldu;
594+ Tensor<1 , dim, ResidualType> oldu;
595+
596+ if (linearize_in_time)
625597 {
626- Tensor<2 , dim, ResidualType> gradoldu;
627- Tensor<1 , dim, ResidualType> oldu;
628-
629- if (linearize_in_time)
630- {
631- gradoldu=grad_u_old;
632- oldu=u_old;
633- }
634- else
635- {
636- gradoldu=grad_u_prev;
637- oldu=u_prev;
638- }
639-
640- if (non_linear_term==" fully_non_linear" )
641- nl_u = grad_u * u;
642- else if (non_linear_term==" linear" )
643- nl_u = grad_u * oldu;
644- else if (non_linear_term==" RHS" )
645- nl_u = gradoldu * oldu;
646-
647- ResidualType non_linear_term = 0 ;
648-
649- if (use_skew_symmetric_advection)
650- res += 0.5 * ( scalar_product ( nl_u, v) + scalar_product (grad_v * oldu, u) );
651- else
652- res += scalar_product ( nl_u, v);
653-
654- double norm = std::sqrt (SacadoTools::to_double (oldu*oldu));
655-
656- if (norm > 0 && SUPG_alpha > 0 )
657- res += scalar_product ( nl_u, SUPG_alpha * (h/norm) * grad_v * oldu);
598+ gradoldu=grad_u_old;
599+ oldu=u_old;
658600 }
601+ else
602+ {
603+ gradoldu=grad_u_prev;
604+ oldu=u_prev;
605+ }
606+
607+ if (non_linear_term==" fully_non_linear" )
608+ nl_u = grad_u * u;
609+ else if (non_linear_term==" linear" )
610+ nl_u = grad_u * oldu;
611+ else if (non_linear_term==" RHS" )
612+ nl_u = gradoldu * oldu;
613+
614+ ResidualType non_linear_term = 0 ;
615+
616+ if (use_skew_symmetric_advection)
617+ res += 0.5 * ( scalar_product ( nl_u, v) + scalar_product (grad_v * oldu, u) );
618+ else
619+ res += scalar_product ( nl_u, v);
620+
621+ double norm = std::sqrt (SacadoTools::to_double (oldu*oldu));
622+
623+ if (norm > 0 && SUPG_alpha > 0 )
624+ res += scalar_product ( nl_u, SUPG_alpha * (h/norm) * grad_v * oldu);
625+
626+
659627 // grad-div stabilization term:
660628 if (gamma!=0.0 )
661629 res += gamma * div_u * div_v;
0 commit comments