Repository navigation
Description
First-cell strain rate differs between a wall on the mesh boundary and the same wall as an OBST
Summary
In the first gas cell at a wall, COMPUTE_STRAIN_RATE and the near-wall loop of COMPUTE_VISCOSITY form the
velocity gradient with a central difference that reads the velocity array one cell behind the wall.
- At a wall on the exterior boundary of the mesh, that element holds the ghost value written by
VELOCITY_BC. - Behind the face of an OBST it holds a value near zero (NO_FLUX drives it towards zero; 7.7e-5 m/s in the LES example below), because
VELOCITY_BCwrites the ghost value intoUU,VV,WWonly at the edge of the computational domain, andNO_FLUXdrives the face inside the obstruction towards zero.
So the same wall with the same flow next to it gets two different first-cell strain rates. For a no-slip wall and a
linear profile the mesh-boundary value is the exact slope and the OBST value is 3/4 of it. With Van Driest damping,
the first-cell eddy viscosity at the OBST face in the example below is 0.65 of the one at the mesh boundary.
The wall stress and the edge vorticity are not affected: they use VEL_GHOST directly, at OBST edges too. Only the
cell-centred first-cell strain differs, and what is built on it.
A second, separate point is at the end: the output quantity STRAIN RATE prints a third value in the first cell at
a mesh boundary.
Line numbers are those of master at 8e4c2c4.
What happens, with the lines
For a wall below the cell, both first-cell loops use this line (velo.f90:333 in the WALE branch of the near-wall
loop of COMPUTE_VISCOSITY, velo.f90:472 in the wall loop of COMPUTE_STRAIN_RATE):
DUDZ = 0.25_EB*RDZ(KKG)*(UU(IIG,JJG,KKG+1)-UU(IIG,JJG,KKG-1)+UU(IIG-1,JJG,KKG+1)-UU(IIG-1,JJG,KKG-1))
What UU(IIG,JJG,KKG-1) holds depends on how the wall is defined.
Wall on the mesh boundary. VELOCITY_BC (velo.f90:1799-2612) computes VEL_GHOST: 2*VEL_T - VEL_GAS for no
slip (2358), VEL_T + SLIP_COEF*(VEL_GAS-VEL_T) for the wall model (2378). The block "Set ghost cell values at edge
of computational domain" (2516-2555) stores it in the array, for example at 2534:
IF (KK==0 .AND. IOR== 3) UU(II,JJ,KK) = VEL_GHOST
For a wall at rest with no slip the first-cell gradient is then (u2 + u1)/(2 dz).
Wall that is the face of an OBST. VELOCITY_BC computes VEL_GHOST at OBST edges as well and uses it for the
edge's velocity gradient, vorticity and stress, so the momentum flux at the OBST wall is right. But the store into
the arrays is guarded by II==0, II==IBAR, JJ==0, ... with the matching IOR: it happens only on the mesh
boundary. UU(IIG,JJG,KKG-1) is then a face between two solid cells, which NO_FLUX (velo.f90:1348-1563) drives
towards zero (comment at 1402, loop 1404-1459). The first-cell gradient is u2/(2 dz).
For a linear profile u = g z with u1 = g dz/2 and u2 = 3 g dz/2, DUDZ is g at the mesh boundary and
3g/4 at the OBST face. The OBST value is the one of a ghost velocity of zero ("half slip"), whatever the boundary
condition and the wall model say.
Example
A laminar channel between two walls 1 m apart, periodic in x, driven by FORCE_VECTOR(1), run to 100 s (steady).
Each case is run twice: with the walls as ZMIN/ZMAX of the mesh, and with the walls as the faces of two OBSTs
two cells thick. Four decks in DNS mode (16 and 32 cells across), two in LES mode (16 cells, constant Smagorinsky
with Van Driest damping, chosen so that the first-cell eddy viscosity is the strain rate times a known factor).
ext16.fds, walls on the mesh boundary (the TITLE strings are shortened in the two listings):
&HEAD CHID='ext16', TITLE='Poiseuille flow, 16 cells; the walls are the exterior boundaries of the mesh' /
&MESH IJK=4,1,16, XB=0,1,-.125,.125,0,1 /
&TIME T_END=100. /
&DUMP NFRAMES=100, SIG_FIGS=9, SIG_FIGS_EXP=4 /
&MISC SIMULATION_MODE='DNS', NOISE=.FALSE. /
&WIND STRATIFICATION=.FALSE., FORCE_VECTOR(1)=1 /
&SPEC ID='LJ AIR', VISCOSITY=0.025, BACKGROUND=.TRUE. /
&VENT MB='XMIN', SURF_ID='PERIODIC' /
&VENT MB='XMAX', SURF_ID='PERIODIC' /
&DEVC XYZ=0.5,0,0.031250, QUANTITY='U-VELOCITY', ID='u1' /
&DEVC XYZ=0.5,0,0.093750, QUANTITY='U-VELOCITY', ID='u2' /
&DEVC XYZ=0.5,0,0.156250, QUANTITY='U-VELOCITY', ID='u3' /
&DEVC XYZ=0.5,0,0.031250, QUANTITY='STRAIN RATE', ID='S1' /
&DEVC XYZ=0.5,0,0.093750, QUANTITY='STRAIN RATE', ID='S2' /
&DEVC XYZ=0.5,0,0.031250, QUANTITY='VISCOSITY', ID='mu' /
&DEVC XYZ=0.5,0,0.031250, QUANTITY='DENSITY', ID='rho' /
&TAIL /
obst16.fds, walls as OBST faces: the same (with its own CHID and TITLE), the MESH line replaced by
&MESH IJK=4,1,20, XB=0,1,-.125,.125,-0.125000,1.125000 /
&OBST XB=0,1,-.125,.125,-0.125000,0 /
&OBST XB=0,1,-.125,.125,1,1.125000 /
ext32.fds and obst32.fds: IJK=4,1,32, and IJK=4,1,36 with XB=0,1,-.125,.125,-0.0625,1.0625 and OBSTs
0.0625 m thick; the devices at z = 0.015625, 0.046875 and 0.078125.
les_ext16.fds, LES mode, walls on the mesh boundary:
&HEAD CHID='les_ext16', TITLE='Laminar channel in LES mode, Van Driest; the walls are exterior boundaries' /
&MESH IJK=16,1,16, XB=0,1,-.03125,.03125,0,1 /
&TIME T_END=100. /
&DUMP NFRAMES=100, SIG_FIGS=10, SIG_FIGS_EXP=4 /
&MISC SIMULATION_MODE='LES', TURBULENCE_MODEL='CONSTANT SMAGORINSKY', NOISE=.FALSE. /
&WIND STRATIFICATION=.FALSE., FORCE_VECTOR(1)=10 /
&SPEC ID='LJ AIR', VISCOSITY=0.025, BACKGROUND=.TRUE. /
&SURF ID='W', NEAR_WALL_TURBULENCE_MODEL='VAN DRIEST', DEFAULT=.TRUE. /
&VENT MB='XMIN', SURF_ID='PERIODIC' /
&VENT MB='XMAX', SURF_ID='PERIODIC' /
&DEVC XYZ=0.53125,0,0.031250, QUANTITY='U-VELOCITY', ID='u1' /
&DEVC XYZ=0.53125,0,0.093750, QUANTITY='U-VELOCITY', ID='u2' /
&DEVC XYZ=0.53125,0,0.156250, QUANTITY='U-VELOCITY', ID='u3' /
&DEVC XYZ=0.53125,0,0.031250, QUANTITY='STRAIN RATE', ID='S1out' /
&DEVC XYZ=0.53125,0,0.093750, QUANTITY='STRAIN RATE', ID='S2out' /
&DEVC XYZ=0.53125,0,0.031250, QUANTITY='VISCOSITY', ID='mu1' /
&DEVC XYZ=0.53125,0,0.093750, QUANTITY='VISCOSITY', ID='mu2' /
&DEVC XYZ=0.53125,0,0.156250, QUANTITY='VISCOSITY', ID='mu3' /
&DEVC XYZ=0.53125,0,0.031250, QUANTITY='DENSITY', ID='rho' /
&DEVC XYZ=0.53125,0,0, IOR=3, QUANTITY='VISCOUS WALL UNITS', ID='yplus' /
&DEVC XYZ=0.53125,0,0, IOR=3, QUANTITY='FRICTION VELOCITY', ID='utau' /
&TAIL /
les_obst16.fds: the same (with its own CHID and TITLE), the MESH line replaced by
&MESH IJK=16,1,20, XB=0,1,-.03125,.03125,-0.125000,1.125000 /
&OBST XB=0,1,-.03125,.03125,-0.125000,0 /
&OBST XB=0,1,-.03125,.03125,1,1.125000 /
A debug patch that prints what the loops read
The patch adds WRITE lines to the two first-cell loops of velo.f90. For the floor wall cell at IIG = IBAR/2+1
whose wall is at z = 0 (KKG = 1 in the ext decks, KKG = 3 in the obst decks: the same place in the flow),
during the last 0.1 s of the run, they print the time, the stage (est=F predictor, est=T corrector), the cell
indices, UU(IIG,JJG,KKG-1), UU(IIG,JJG,KKG), UU(IIG,JJG,KKG+1), DUDZ, STRAIN_RATE(IIG,JJG,KKG) and, from
the near-wall loop, MU, MU_DNS and the eddy viscosity (MU-MU_DNS)/RHO. It has no context lines: apply it
at 8e4c2c4 with patch -p1 < first_cell_strain_debug.patch (or git apply --unidiff-zero).
--- a/Source/velo.f90
+++ b/Source/velo.f90
@@ -17,0 +18,2 @@
+REAL(EB) :: DBG_T=0._EB ! DEBUG: time T of the current step at the next COMPUTE_VISCOSITY
+
@@ -350,0 +353,6 @@
+ ! DEBUG: same cell as in COMPUTE_STRAIN_RATE; eddy viscosity = (MU-MU_DNS)/RHO
+ IF (BC%IOR==3 .AND. IIG==IBAR/2+1 .AND. ABS(Z(KKG-1))<1.E-4_EB .AND. DBG_T>=T_END-0.1_EB) &
+ WRITE(LU_ERR,'(A,L2,A,F9.4,A,3I4,A,3ES15.7)') 'DBG VISC est=',&
+ APPLY_TO_ESTIMATED_VARIABLES,' T=',DBG_T,' IIG,JJG,KKG=',IIG,JJG,KKG,&
+ ' | MU,MU_DNS,NU_EDDY:',MU(IIG,JJG,KKG),MU_DNS(IIG,JJG,KKG),&
+ (MU(IIG,JJG,KKG)-MU_DNS(IIG,JJG,KKG))/RHOP(IIG,JJG,KKG)
@@ -482,0 +491,7 @@
+ ! DEBUG: floor wall cell at x-index IBAR/2+1 whose floor is at z=0, last 0.1 s of the run
+ IF (IOR==3 .AND. IIG==IBAR/2+1 .AND. ABS(Z(KKG-1))<1.E-4_EB .AND. DBG_T>=T_END-0.1_EB) &
+ WRITE(LU_ERR,'(A,L2,A,F9.4,A,3I4,A,6ES15.7)') 'DBG STRAIN est=',&
+ APPLY_TO_ESTIMATED_VARIABLES,' T=',DBG_T,' IIG,JJG,KKG=',IIG,JJG,KKG,&
+ ' | U(k-1),U(k),U(k+1),DUDZ,SR,U(i-1,k-1):',&
+ UU(IIG,JJG,KKG-1),UU(IIG,JJG,KKG),UU(IIG,JJG,KKG+1),DUDZ,&
+ STRAIN_RATE(IIG,JJG,KKG),UU(IIG-1,JJG,KKG-1)
@@ -580,0 +596,2 @@
+
+DBG_T = T ; IF (.NOT.APPLY_TO_ESTIMATED_VARIABLES) DBG_T = T+DT ! DEBUGWhat to expect, and what the patched build prints
Last corrector-stage lines (t = 100 s); velocities in m/s, DUDZ and STRAIN_RATE in 1/s.
| deck | KKG |
UU(KKG-1) expected |
UU(KKG-1) printed |
UU(KKG) |
UU(KKG+1) |
DUDZ |
STRAIN_RATE |
|---|---|---|---|---|---|---|---|
| ext16 | 1 | -UU(KKG) (no slip) |
-0.6250000 | 0.6250000 | 1.7187500 | 18.750 | 18.750 |
| obst16 | 3 | 0 | -5.5e-13 | 0.6250000 | 1.7187500 | 13.750 | 13.750 |
| ext32 | 1 | -UU(KKG) |
-0.3125000 | 0.3125000 | 0.8984375 | 19.375 | 19.375 |
| obst32 | 3 | 0 | 5.5e-14 | 0.3125000 | 0.8984375 | 14.375 | 14.375 |
| les_ext16 | 1 | -UU(KKG) |
-6.3609722 | 6.3609722 | 14.264480 | 165.006 | 164.996 |
| les_obst16 | 3 | 0 | 7.7e-5 | 6.1355830 | 13.804773 | 110.437 | 110.434 |
- DNS decks. The velocity profile is the same with either kind of wall (u1 and u2 agree to eight digits), as it
should be: the wall stress is right in both. The first-cell strain rate is not. At the mesh boundary it is the
exact slope of the Poiseuille profile at the first-cell centre,20 (1 - dz)= 18.75 and 19.375 1/s. At the OBST
face it is 13.75 and 14.375 1/s: 0.733 and 0.742 of it, tending to 3/4 with refinement. - LES decks. In the exterior deck the wall model is in its viscous branch (y+ = 3.1), so its ghost value is the
no-slip one. Behind the OBST face the value is not exactly zero (7.7e-5 m/s beside a first-cell velocity of 6.1
m/s):NO_FLUXholds it near zero.STRAIN_RATEdiffers fromDUDZin the fifth digit because the other
components of the tensor enter it.
The raw lines of the last corrector-stage call, as printed (each printed line is broken into several here):
ext16:
DBG STRAIN est= T T= 100.0000 IIG,JJG,KKG= 3 1 1 |
U(k-1),U(k),U(k+1),DUDZ,SR,U(i-1,k-1):
-6.2500000E-01 6.2500000E-01 1.7187500E+00
1.8750000E+01 1.8750000E+01 -6.2500000E-01
DBG VISC est= T T= 100.0000 IIG,JJG,KKG= 3 1 1 |
MU,MU_DNS,NU_EDDY:
2.5000000E-02 2.5000000E-02 0.0000000E+00
obst16:
DBG STRAIN est= T T= 100.0000 IIG,JJG,KKG= 3 1 3 |
U(k-1),U(k),U(k+1),DUDZ,SR,U(i-1,k-1):
-5.5123998E-13 6.2500000E-01 1.7187500E+00
1.3750000E+01 1.3750000E+01 3.5463559E-15
DBG VISC est= T T= 100.0000 IIG,JJG,KKG= 3 1 3 |
MU,MU_DNS,NU_EDDY:
2.5000000E-02 2.5000000E-02 0.0000000E+00
ext32:
DBG STRAIN est= T T= 100.0000 IIG,JJG,KKG= 3 1 1 |
U(k-1),U(k),U(k+1),DUDZ,SR,U(i-1,k-1):
-3.1250000E-01 3.1250000E-01 8.9843750E-01
1.9375000E+01 1.9375000E+01 -3.1250000E-01
DBG VISC est= T T= 100.0000 IIG,JJG,KKG= 3 1 1 |
MU,MU_DNS,NU_EDDY:
2.5000000E-02 2.5000000E-02 0.0000000E+00
obst32:
DBG STRAIN est= T T= 100.0000 IIG,JJG,KKG= 3 1 3 |
U(k-1),U(k),U(k+1),DUDZ,SR,U(i-1,k-1):
5.5165774E-14 3.1250000E-01 8.9843750E-01
1.4375000E+01 1.4375000E+01 4.0558811E-17
DBG VISC est= T T= 100.0000 IIG,JJG,KKG= 3 1 3 |
MU,MU_DNS,NU_EDDY:
2.5000000E-02 2.5000000E-02 0.0000000E+00
les_ext16:
DBG STRAIN est= T T= 100.0000 IIG,JJG,KKG= 9 1 1 |
U(k-1),U(k),U(k+1),DUDZ,SR,U(i-1,k-1):
-6.3609722E+00 6.3609722E+00 1.4264480E+01
1.6500565E+02 1.6499636E+02 -6.3610699E+00
DBG VISC est= T T= 100.0000 IIG,JJG,KKG= 9 1 1 |
MU,MU_DNS,NU_EDDY:
2.5387988E-02 2.5000000E-02 3.2340608E-04
les_obst16:
DBG STRAIN est= T T= 100.0000 IIG,JJG,KKG= 9 1 3 |
U(k-1),U(k),U(k+1),DUDZ,SR,U(i-1,k-1):
7.7145098E-05 6.1355830E+00 1.3804773E+01
1.1043678E+02 1.1043362E+02 -1.7309457E-06
DBG VISC est= T T= 100.0000 IIG,JJG,KKG= 9 1 3 |
MU,MU_DNS,NU_EDDY:
2.5251057E-02 2.5000000E-02 2.0926271E-04
The same without the patch: device output at t = 100 s
| deck | u1 | u2 | STRAIN RATE device, first cell |
viscosity mu1 |
eddy viscosity (mu1 - 0.025)/rho |
|---|---|---|---|---|---|
| ext16 | 0.6250000 | 1.7187500 | 8.7500 (see the second point) | ||
| obst16 | 0.6250000 | 1.7187500 | 13.7500 | ||
| ext32 | 0.3125000 | 0.8984375 | 9.3750 (see the second point) | ||
| obst32 | 0.3125000 | 0.8984375 | 14.3750 | ||
| les_ext16 | 6.362097 | 14.266929 | 63.2386 (see the second point) | 0.02538816 | 3.2355e-4 m2/s |
| les_obst16 | 6.136823 | 13.805993 | 110.4479 | 0.02525111 | 2.0931e-4 m2/s |
With Van Driest damping the first-cell eddy viscosity is (VDF*C_SMAGORINSKY*DELTA)**2*STRAIN_RATE (velo.f90:326),
so it follows the strain rate: at the OBST face it is 0.65 of the value at the mesh boundary. The velocities of the
two LES runs differ by 3.5 per cent in the first cell, which is the effect of that eddy viscosity on a flow that is
otherwise the same.
Where else the value is used
Readers of the cell-centred STRAIN_RATE array at 8e4c2c4:
velo.f90:118: constant and dynamic Smagorinsky, all cells (the first-cell viscosity is then replaced by the
near-wall loop);velo.f90:326: the Van Driest near-wall model (the example above);turb.f90:530: the test filter of the dynamic Smagorinsky model;fire.f90:813:K_SGSfor the mixing time, withTEST_NEW_KSGS_MODEL;dump.f90:7720: theSUBGRID KINETIC ENERGYoutput, with the same switch.
The default near-wall model, WALE (read.f90:8662-8663), does not go through the array: it forms the tensor itself
at velo.f90:328-340 with the same stencil, so it reads the same element behind the wall. In a pure shear WALE
returns zero with either value, so the channel above cannot show a difference; with other velocity gradients in the
first cell the two tensors differ.
Not measured: the WALE, dynamic Smagorinsky and K_SGS paths in a case where they differ. Not examined: whether
the Deardorff branch needs the same attention.
One possible fix (untested)
In the two first-cell wall loops, for a wall cell that is not on the mesh boundary, use the wall's ghost value in
place of the element read behind the wall: the value VELOCITY_BC forms for that wall (2*VEL_T - VEL_GAS for no
slip, VEL_T + SLIP_COEF*(VEL_GAS-VEL_T) under the wall model). The mesh-boundary result would not change.
Storing ghost values into UU, VV, WW behind OBST faces looks simpler but is probably not safe: a face inside
an obstruction one cell thick lies behind two walls, and NO_FLUX works on the same faces.
Neither has been tried.
Second, separate point: the STRAIN RATE output quantity
The output quantity STRAIN RATE (dump.f90:7844-7870) does not print the model's array. It forms the tensor
again from U, V, W with clamped indices (dump.f90:7845-7853), for example
KKM1 = MAX(1,KK-1)
at 7850, used in DUDZ at 7862. In the first cell at a mesh boundary KKM1 = KK, so the output prints
(u2 - u1)/(2 dz) where the array holds (u2 + u1)/(2 dz):
| deck | STRAIN RATE device, first cell |
STRAIN_RATE array (patched build) |
|---|---|---|
| ext16 | 8.750 | 18.750 |
| ext32 | 9.375 | 19.375 |
| les_ext16 | 63.24 | 165.00 |
At an OBST face KK-1 is a real index, and the output agrees with the array (13.75, 14.375, 110.45). So the output
is consistent with the model at OBST faces and not at mesh boundaries. KOLMOGOROV LENGTH SCALE (dump.f90:7871)
is built on the same output. A fix would be to print STRAIN_RATE(II,JJ,KK) for gas cells.
Version and how to reproduce
Upstream master at 8e4c2c4, target impi_intel_linux, one MPI process.
cd Build/impi_intel_linux && ./make_fds.sh
mpirun -np 1 fds_impi_intel_linux ext16.fds # and the other five decks; device output in *_devc.csv
patch -p1 < first_cell_strain_debug.patch # in the repository root; then rebuild
mpirun -np 1 fds_impi_intel_linux ext16.fds 2> ext16.err
grep DBG ext16.err | tail -n 4
The DNS decks take seconds. The LES decks take about 2.5 minutes each (68,000 steps).
Activity
[-]Strain Rate next to OBSTS is not using the right velocity BC (0 vel component inside OBST).[/-][+]Strain Rate next to OBSTS is not using the right velocity BC (always sets vel component to 0 inside OBST).[/+]