@@ -59,24 +59,30 @@ class ALENavierStokes
5959
6060 void connect_to_signals () const
6161 {
62- // first of all we get the struct Signals from pidomus
6362 auto &signals = this ->get_signals ();
64- signals.end_run .connect (
65- [&]()
63+ auto &pcout = this ->get_pcout ();
64+
65+ signals.end_cycle .connect ([&]()
6666 {
6767 clean ();
6868 });
6969 }
7070
7171 void
72- clean () const ;
72+ clean () const
73+ {
74+ mapping = nullptr ;
75+ };
7376
7477 const Mapping<dim,spacedim>
7578 &get_default_mapping () const ;
7679
7780 const Mapping<dim,spacedim>
78- &get_fe_mapping () const ;
79-
81+ &get_fe_mapping () const
82+ {
83+ return StaticMappingQ1<dim,spacedim>::mapping;
84+ };
85+
8086private:
8187
8288// Physical parameter
@@ -87,7 +93,7 @@ class ALENavierStokes
8793 bool AMG_u_use_inverse_operator;
8894 bool AMG_d_use_inverse_operator;
8995 bool AMG_Ap_use_inverse_operator;
90-
96+
9197 /* *
9298 * AMG preconditioner for velocity-velocity matrix.
9399 */
@@ -102,7 +108,7 @@ class ALENavierStokes
102108 * AMG preconditioner for the pressure stifness matrix.
103109 */
104110 mutable ParsedAMGPreconditioner AMG_Ap;
105-
111+
106112 /* *
107113 * Jacobi preconditioner for the pressure mass matrix.
108114 */
@@ -143,21 +149,6 @@ set_matrix_couplings(std::vector<std::string> &couplings) const
143149 couplings[2 ] = " 0,0,0; 0,0,0; 0,0,1" ; // TODO: remove unused couplings
144150}
145151
146- template <int dim, int spacedim, typename LAC>
147- void ALENavierStokes<dim,spacedim,LAC>::
148- clean () const
149- {
150- mapping = nullptr ;
151- }
152-
153- template <int dim, int spacedim, typename LAC>
154- const Mapping<dim,spacedim> &
155- ALENavierStokes<dim,spacedim,LAC>::
156- get_fe_mapping () const
157- {
158- return StaticMappingQ1<dim,spacedim>::mapping;
159- }
160-
161152template <int dim, int spacedim, typename LAC>
162153const Mapping<dim,spacedim> &
163154ALENavierStokes<dim,spacedim,LAC>::
@@ -169,6 +160,7 @@ get_default_mapping() const
169160
170161 if (!mapping)
171162 {
163+ std::cout << " update mapping" << std::endl << std::flush;
172164 const unsigned int degree = this ->get_fe ().degree ;
173165 const DoFHandler<dim,spacedim> &dh = this ->get_dof_handler ();
174166 mapping = SP (new MappingQEulerian< dim, typename LAC::VectorType, spacedim >(degree, dh, solution));
@@ -209,10 +201,10 @@ declare_parameters (ParameterHandler &prm)
209201 Patterns::Bool (),
210202 " Enable the use of inverse operator for AMG u" );
211203
212- this ->add_parameter (prm, &AMG_Ap_use_inverse_operator,
213- " AMG Ap - use inverse operator" , " false" ,
214- Patterns::Bool (),
215- " Enable the use of inverse operator for AMG Ap" );
204+ this ->add_parameter (prm, &AMG_Ap_use_inverse_operator,
205+ " AMG Ap - use inverse operator" , " false" ,
206+ Patterns::Bool (),
207+ " Enable the use of inverse operator for AMG Ap" );
216208}
217209
218210template <int dim, int spacedim, typename LAC>
@@ -256,7 +248,7 @@ energies_and_residuals(const typename DoFHandler<dim,spacedim>::active_cell_iter
256248
257249// pressure:
258250 auto &ps = fe_cache.get_values ( " solution" , " p" , pressure, et);
259- auto &grad_ps = fe_cache.get_gradients ( " solution" , " grad_p" , pressure, et);
251+ auto &grad_ps = fe_cache.get_gradients ( " solution" , " grad_p" , pressure, et);
260252
261253// Jacobian:
262254 auto &JxW = fe_cache.get_JxW_values ();
@@ -267,7 +259,7 @@ auto &grad_ps = fe_cache.get_gradients( "solution", "grad_p", pressure, et);
267259
268260 ResidualType res_u = 0 ;
269261 ResidualType res_d = 0 ;
270-
262+
271263 for (unsigned int quad=0 ; quad<n_quad_points; ++quad)
272264 {
273265// variables:
@@ -290,7 +282,7 @@ auto &grad_ps = fe_cache.get_gradients( "solution", "grad_p", pressure, et);
290282// pressure:
291283 const ResidualType &p = ps[quad];
292284 const Tensor<1 , dim, ResidualType> &grad_p = grad_ps[quad];
293-
285+
294286// jacobian of ALE transformation:
295287 const double J_ale = SacadoTools::to_double (determinant (F));
296288
@@ -316,26 +308,26 @@ auto &grad_ps = fe_cache.get_gradients( "solution", "grad_p", pressure, et);
316308// pressure:
317309 auto p_test = fev[pressure].value (i,quad);
318310 auto grad_p_test = fev[pressure].gradient (i,quad);
319-
311+
320312 // Preconditioner:
321313 residual[1 ][i] +=
322314 (
323- p * p_test // * J_ale
315+ p * p_test * J_ale
324316 )*JxW[quad];
325317
326318 residual[2 ][i] +=
327319 (
328- grad_p * grad_p_test // * J_ale
320+ grad_p * grad_p_test * J_ale
329321 )*JxW[quad];
330-
322+
331323 // Navier Stokes:
332324 res_u =
333325// time derivative term
334326 rho*scalar_product ( u_dot , u_test )
335327//
336328 + scalar_product ( grad_u * ( F_inv * ( u_old - d_dot ) ) , u_test )
337329//
338- + scalar_product (sigma , grad_u_test * F_inv )
330+ + scalar_product (sigma * Ft_inv , grad_u_test )
339331// divergence free constriant
340332 - div_u * p_test;
341333
@@ -369,6 +361,7 @@ ALENavierStokes<dim,spacedim,LAC>::compute_system_operators(
369361
370362 AMG_d.initialize_preconditioner <dim, spacedim>( matrices[0 ]->block (0 ,0 ), fe, dh);
371363 AMG_u.initialize_preconditioner <dim, spacedim>( matrices[0 ]->block (1 ,1 ), fe, dh);
364+ AMG_Ap.initialize_preconditioner <dim, spacedim>( matrices[2 ]->block (2 ,2 ), fe, dh);
372365 jac_M.initialize_preconditioner <>(matrices[1 ]->block (2 ,2 ));
373366
374367// //////////////////////////////////////////////////////////////////////////
@@ -432,20 +425,20 @@ ALENavierStokes<dim,spacedim,LAC>::compute_system_operators(
432425 }
433426
434427 auto Ap = linear_operator< TrilinosWrappers::MPI::Vector >( matrices[2 ]->block (2 ,2 ) );
435- LinearOperator<BVEC> Ap_inv;
436- if (AMG_Ap_use_inverse_operator)
437- {
438- Ap_inv = inverse_operator (Ap,
439- solver_GMRES,
440- jac_M);
441- }
442- else
443- {
444- Ap_inv = linear_operator<BVEC>(matrices[2 ]->block (2 ,2 ),
445- AMG_Ap);
446- }
428+ LinearOperator<BVEC> Ap_inv;
429+ if (AMG_Ap_use_inverse_operator)
430+ {
431+ Ap_inv = inverse_operator (Ap,
432+ solver_GMRES,
433+ jac_M);
434+ }
435+ else
436+ {
437+ Ap_inv = linear_operator<BVEC>(matrices[2 ]->block (2 ,2 ),
438+ AMG_Ap);
439+ }
447440 auto alpha = this ->get_alpha ();
448- auto Schur_inv = nu * Mp_inv ;// + ( rho * alpha * Ap_inv) ;
441+ auto Schur_inv = 1 / nu * Mp_inv;// + rho * alpha * Ap_inv;
449442
450443 if (AMG_d_use_inverse_operator)
451444 {
0 commit comments