Skip to content

Commit

Permalink
Add missing Matrix-free tests with velocity averaging (#1439)
Browse files Browse the repository at this point in the history
Description
PR #1436 fixed a bug related to the averaging velocity in the matrix-free solver. I had made a test for that but forgot to add it. This PR adds the missing test that was promised in that PR.
  • Loading branch information
blaisb authored and marineharel committed Mar 4, 2025
1 parent 0c14387 commit 135b24b
Show file tree
Hide file tree
Showing 3 changed files with 275 additions and 0 deletions.
2 changes: 2 additions & 0 deletions applications_tests/lethe-fluid-matrix-free/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ string(TOLOWER ${CMAKE_BUILD_TYPE} _build_type)

file(COPY cylinder_structured.msh DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/cylinder_kelly_estimator.${_build_type}")
file(COPY cylinder_close_outlet.msh DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/cylinder_outlet_bc.${_build_type}")
file(COPY cylinder_structured.msh DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/cylinder_transient_avg.${_build_type}")


file(COPY tgv_restart_bdf1/restart.pvdhandler DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/tgv_restart_bdf1.${_build_type}")
file(COPY tgv_restart_bdf1/restart.simulationcontrol DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/tgv_restart_bdf1.${_build_type}")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Running on 1 MPI rank(s)...
Number of active cells: 1167
Number of degrees of freedom: 3750
Volume of triangulation: 511.219

*******************************************************************************
Transient iteration: 1 Time: 0.1 Time step: 0.1 CFL: 0.386319
*******************************************************************************

+------------------------------------------+
| Force summary |
+------------------------------------------+
Boundary ID f_x f_y f_xv f_yv f_xp f_yp
0.000000e+00 8.357588e+00 -5.976121e-10 1.405395e-01 2.113518e-11 8.217049e+00 -6.187473e-10
1.000000e+00 -2.219106e+01 -5.977324e-14 -5.571335e-09 -5.977324e-14 -2.219106e+01 0.000000e+00
2.000000e+00 1.182117e-05 6.913181e-10 1.182117e-05 6.488809e-15 0.000000e+00 6.913130e-10
3.000000e+00 6.454205e-10 -6.204701e-16 -1.319457e-11 -6.204701e-16 6.586150e-10 0.000000e+00

*******************************************************************************
Transient iteration: 2 Time: 0.2 Time step: 0.1 CFL: 0.638256
*******************************************************************************
Number of active cells: 1209
Number of degrees of freedom: 3918
Volume of triangulation: 511.218

+------------------------------------------+
| Force summary |
+------------------------------------------+
Boundary ID f_x f_y f_xv f_yv f_xp f_yp
0.000000e+00 2.284631e+00 -8.252334e-11 1.300902e-01 1.467136e-11 2.154541e+00 -9.719471e-11
1.000000e+00 -3.749479e+00 -1.080358e-14 -8.366276e-09 -1.080358e-14 -3.749479e+00 0.000000e+00
2.000000e+00 1.452894e-05 -5.231430e-10 1.452894e-05 4.854319e-15 0.000000e+00 -5.231479e-10
3.000000e+00 1.239967e-10 -1.269927e-16 -7.725799e-12 -1.269927e-16 1.317225e-10 0.000000e+00

*******************************************************************************
Transient iteration: 3 Time: 0.3 Time step: 0.1 CFL: 1.38912
*******************************************************************************
Number of active cells: 1257
Number of degrees of freedom: 4086
Volume of triangulation: 511.218

+------------------------------------------+
| Force summary |
+------------------------------------------+
Boundary ID f_x f_y f_xv f_yv f_xp f_yp
0.000000e+00 1.134080e+00 -1.960789e-12 1.264174e-01 -1.043515e-11 1.007663e+00 8.474398e-12
1.000000e+00 -1.341294e+00 9.641220e-15 -7.086561e-09 9.641220e-15 -1.341294e+00 0.000000e+00
2.000000e+00 1.556155e-05 -2.411485e-10 1.556155e-05 4.507168e-15 0.000000e+00 -2.411529e-10
3.000000e+00 1.274938e-10 9.426837e-17 -5.691638e-12 9.426837e-17 1.331855e-10 0.000000e+00

*******************************************************************************
Transient iteration: 4 Time: 0.4 Time step: 0.1 CFL: 1.34949
*******************************************************************************
Number of active cells: 1317
Number of degrees of freedom: 4302
Volume of triangulation: 511.217

+------------------------------------------+
| Force summary |
+------------------------------------------+
Boundary ID f_x f_y f_xv f_yv f_xp f_yp
0.000000e+00 8.072556e-01 -3.144761e-11 1.234711e-01 -6.555069e-12 6.837844e-01 -2.489247e-11
1.000000e+00 -7.672064e-01 2.824802e-14 -1.233798e-08 2.824802e-14 -7.672063e-01 0.000000e+00
2.000000e+00 1.622908e-05 -2.944319e-10 1.622908e-05 4.167144e-15 0.000000e+00 -2.944361e-10
3.000000e+00 1.192630e-10 4.443926e-16 -4.840522e-12 4.443926e-16 1.241035e-10 0.000000e+00

*******************************************************************************
Transient iteration: 5 Time: 0.5 Time step: 0.1 CFL: 2.05672
*******************************************************************************
Number of active cells: 1413
Number of degrees of freedom: 4686
Volume of triangulation: 511.216

+------------------------------------------+
| Force summary |
+------------------------------------------+
Boundary ID f_x f_y f_xv f_yv f_xp f_yp
0.000000e+00 6.891491e-01 9.269635e-11 1.237051e-01 -1.370763e-11 5.654440e-01 1.064040e-10
1.000000e+00 -6.714467e-01 4.946966e-14 -2.037507e-08 4.946966e-14 -6.714467e-01 0.000000e+00
2.000000e+00 1.683079e-05 -2.934675e-10 1.683079e-05 3.963084e-15 0.000000e+00 -2.934714e-10
3.000000e+00 1.202764e-10 7.213421e-16 -4.351621e-12 7.213421e-16 1.246281e-10 0.000000e+00
192 changes: 192 additions & 0 deletions applications_tests/lethe-fluid-matrix-free/cylinder_transient_avg.prm
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 The Lethe Authors
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later

# This test case runs a transient flow simulation around a cylinder
# with time-averaging of the velocity field enabled. This test
# used to crash the matrix-free solver a the first mesh adaptation

# Listing of Parameters
#----------------------

set dimension = 2

#---------------------------------------------------
# Simulation Control
#---------------------------------------------------

subsection simulation control
set method = bdf1
set time end = 0.5
set time step = 0.1
set output frequency = 0
end

#---------------------------------------------------
# FEM
#---------------------------------------------------

subsection FEM
set velocity order = 1
set pressure order = 1
end

#---------------------------------------------------
# Timer
#---------------------------------------------------

subsection timer
set type = none
end

#---------------------------------------------------
# Force
#---------------------------------------------------

subsection forces
set verbosity = verbose
set calculate force = true
set calculate torque = false
set output precision = 10
set calculation frequency = 1
set output frequency = 1
end

#---------------------------------------------------
# Initial condition
#---------------------------------------------------

subsection initial conditions
set type = nodal
subsection uvwp
set Function expression = 1; 0; 0
end
end

#---------------------------------------------------
# Post-Processing
#---------------------------------------------------

subsection post-processing
set calculate average velocities = true
set initial time for average velocity = 0
end

#---------------------------------------------------
# Physical Properties
#---------------------------------------------------

subsection physical properties
subsection fluid 0
set kinematic viscosity = 0.01
end
end

#---------------------------------------------------
# Mesh
#---------------------------------------------------

subsection mesh
set type = gmsh
set file name = ../cylinder_structured.msh
end

#---------------------------------------------------
# Boundary Conditions
#---------------------------------------------------

subsection boundary conditions
set number = 4
subsection bc 0
set id = 0
set type = noslip
end
subsection bc 1
set id = 1
set type = function
subsection u
set Function expression = 1
end
subsection v
set Function expression = 0
end
subsection w
set Function expression = 0
end
end
subsection bc 2
set id = 2
set type = slip
end
subsection bc 3
set id = 3
set type = outlet
set beta = 1
end
end

#---------------------------------------------------
# Manifolds
#---------------------------------------------------

subsection manifolds
set number = 1
subsection manifold 0
set id = 0
set type = spherical
set point coordinates = 8, 8
end
end

#---------------------------------------------------
# Mesh Adaptation Control
#---------------------------------------------------

subsection mesh adaptation
set type = kelly
set variable = velocity
set fraction type = fraction
set max number elements = 70000
set max refinement level = 2
set min refinement level = 0
set frequency = 1
set fraction refinement = 0.2
set fraction coarsening = 0.05
end

#---------------------------------------------------
# Non-Linear Solver Control
#---------------------------------------------------

subsection non-linear solver
subsection fluid dynamics
set verbosity = quiet
set tolerance = 1e-4
set max iterations = 20
end
end

#---------------------------------------------------
# Linear Solver Control
#---------------------------------------------------

subsection linear solver
subsection fluid dynamics
set verbosity = quiet
set method = gmres
set max iters = 200
set max krylov vectors = 200
set relative residual = 1e-2
set minimum residual = 1e-6
set preconditioner = gcmg
set mg verbosity = quiet

# Smoother
set mg smoother iterations = 5
set mg smoother eig estimation = true

# Eigenvalue estimation parameters
set eig estimation smoothing range = 5
set eig estimation cg n iterations = 20
set eig estimation verbosity = quiet
end
end

0 comments on commit 135b24b

Please # to comment.