Pressure_Solver/obst_activation cases do not remain isothermal.
marcosvanella opened this issue · comments
Running either Presure_Solver/obst_activation_default.fds or Presure_Solver/obst_activation_ulmat.fds we see a divergence and temperature jump when obstacles that have a side in an interpolated boundary appear or disappear.
The culprit is that we change the type of boundary condition before computing mass advective fluxes, and use a different value of normal velocity for external wall cells that have changed from INTERPOLATED to SOLID and viceversa. In DENSITY we have for CORRECTOR:
WALL_LOOP_2: DO IW=1,N_EXTERNAL_WALL_CELLS
WC => WALL(IW)
IF (WC%BOUNDARY_TYPE/=INTERPOLATED_BOUNDARY) CYCLE WALL_LOOP_2
BC => BOUNDARY_COORD(WC%BC_INDEX)
SELECT CASE(BC%IOR)
CASE( 1); UU(BC%IIG-1,BC%JJG ,BC%KKG ) = UVW_SAVE(IW)
CASE(-1); UU(BC%IIG ,BC%JJG ,BC%KKG ) = UVW_SAVE(IW)
CASE( 2); VV(BC%IIG ,BC%JJG-1,BC%KKG ) = UVW_SAVE(IW)
CASE(-2); VV(BC%IIG ,BC%JJG ,BC%KKG ) = UVW_SAVE(IW)
CASE( 3); WW(BC%IIG ,BC%JJG ,BC%KKG-1) = UVW_SAVE(IW)
CASE(-3); WW(BC%IIG ,BC%JJG ,BC%KKG ) = UVW_SAVE(IW)
END SELECT
ENDDO WALL_LOOP_2
Here, we ended up at the end of the predictor with velocity US having and interpolated BC, but right after that we call CREATE_OR_REMOVE_OBSTRUCTIONS changing that WALL_CELL to SOLID. Therefore the value of UU we get is US, not the corrected value and mass advection is computed with a different velocity field for the cell next to the EWC.
I think we should use the same boundary condition from the end of previous substep velocity US, in the previous example INTERPOLATED.
To corroborate this add this line in type.f90, line 437 (after BOUNDARY_TYPE declaration for WALL_TYPE):
INTEGER :: BOUNDARY_TYPE_PREDICTOR=0 !< Descriptor: SOLID, MIRROR, OPEN, INTERPOLATED, etc
In func.f90 (PACK_WALL) add the following in line 1568, after the EQUATE call for WC%BOUNDARY_TYPE:
IC=IC+1 ; IF (.NOT.COUNT_ONLY) CALL EQUATE(OS%INTEGERS(IC),WC%BOUNDARY_TYPE_PREDICTOR,UNPACK_IT)
In main.f90 add declarations:
USE MESH_POINTERS
INTEGER :: IW
at the beginning and the following code in line ~786 (before the CREATE_OR_REMOVE_OBSTRUCTIONS call)
DO NM=LOWER_MESH_INDEX,UPPER_MESH_INDEX
CALL POINT_TO_MESH(NM)
DO IW=1,N_EXTERNAL_WALL_CELLS
WALL(IW)%BOUNDARY_TYPE_PREDICTOR=WALL(IW)%BOUNDARY_TYPE
ENDDO
ENDDO
Then in mass.f90 change BOUNDARY_TYPE by BOUNDARY_TYPE_PREDICTOR in line 412, CORRECTOR stage of density:
WALL_LOOP_2: DO IW=1,N_EXTERNAL_WALL_CELLS
WC => WALL(IW)
IF (WC%BOUNDARY_TYPE_PREDICTOR/=INTERPOLATED_BOUNDARY) CYCLE WALL_LOOP_2
BC => BOUNDARY_COORD(WC%BC_INDEX)
SELECT CASE(BC%IOR)
CASE( 1); UU(BC%IIG-1,BC%JJG ,BC%KKG ) = UVW_SAVE(IW)
CASE(-1); UU(BC%IIG ,BC%JJG ,BC%KKG ) = UVW_SAVE(IW)
CASE( 2); VV(BC%IIG ,BC%JJG-1,BC%KKG ) = UVW_SAVE(IW)
CASE(-2); VV(BC%IIG ,BC%JJG ,BC%KKG ) = UVW_SAVE(IW)
CASE( 3); WW(BC%IIG ,BC%JJG ,BC%KKG-1) = UVW_SAVE(IW)
CASE(-3); WW(BC%IIG ,BC%JJG ,BC%KKG ) = UVW_SAVE(IW)
END SELECT
ENDDO WALL_LOOP_2
This is what I see now:
This fix will require adding an integer for every WALL_CELL, there might be a more memory efficient way to deal with this.
I made some more progress on this issue. The latest commit prevents temperature fluctuations in a multi-species, isothermal flow when an obstruction that abuts a mesh interface is removed. There is a still a small change when an abutting obstruction is created at a mesh boundary.
I think this is fixed. If not, point me to the case that does not work.