Skip to content

Commit 6ab7b18

Browse files
committed
Merge branch 'cbegeman/ocn/use-horiz-field-for-upwinding' into next (PR #7371)
New spatially-variable horizontal upwind capability Here we add a new capability to transition between centered and upwinded horizontal thickness advection as a function of column thickness. Formerly, either thickness advection was centered or upwinded everywhere. With this PR, when config_use_spatially_variable_upwinding is .true., advection is fully upwinded when the column thickness is less than config_spatially_variable_upwind_hmin and fully centered when column thickness is greater than config_spatially_variable_upwind_hmax. Between these values, there is a linear transition layerThickEdgeFlux [NML] [BFB] stealth feature
2 parents dace033 + 2fec412 commit 6ab7b18

File tree

8 files changed

+102
-2
lines changed

8 files changed

+102
-2
lines changed

components/mpas-ocean/bld/build-namelist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,9 @@ add_default($nl, 'config_coef_3rd_order');
888888
add_default($nl, 'config_flux_limiter');
889889
add_default($nl, 'config_remap_limiter');
890890
add_default($nl, 'config_thickness_flux_type');
891+
add_default($nl, 'config_use_spatially_variable_upwind');
892+
add_default($nl, 'config_spatially_variable_upwind_hmin');
893+
add_default($nl, 'config_spatially_variable_upwind_hmax');
891894

892895
###############################
893896
# Namelist group: bottom_drag #

components/mpas-ocean/bld/build-namelist-section

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ add_default($nl, 'config_coef_3rd_order');
345345
add_default($nl, 'config_flux_limiter');
346346
add_default($nl, 'config_remap_limiter');
347347
add_default($nl, 'config_thickness_flux_type');
348+
add_default($nl, 'config_use_spatially_variable_upwind');
349+
add_default($nl, 'config_spatially_variable_upwind_hmin');
350+
add_default($nl, 'config_spatially_variable_upwind_hmax');
348351

349352
###############################
350353
# Namelist group: bottom_drag #

components/mpas-ocean/bld/namelist_files/namelist_defaults_mpaso.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,9 @@
523523
<config_flux_limiter>'monotonic'</config_flux_limiter>
524524
<config_remap_limiter>'monotonic'</config_remap_limiter>
525525
<config_thickness_flux_type>'centered'</config_thickness_flux_type>
526+
<config_use_spatially_variable_upwind>.false.</config_use_spatially_variable_upwind>
527+
<config_spatially_variable_upwind_hmin>5.0</config_spatially_variable_upwind_hmin>
528+
<config_spatially_variable_upwind_hmax>10.0</config_spatially_variable_upwind_hmax>
526529

527530
<!-- bottom_drag -->
528531
<config_bottom_drag_mode>'implicit'</config_bottom_drag_mode>

components/mpas-ocean/bld/namelist_files/namelist_definition_mpaso.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,30 @@ Valid values: 'upwind', 'centered', 'constant'
18601860
Default: Defined in namelist_defaults.xml
18611861
</entry>
18621862

1863+
<entry id="config_use_spatially_variable_upwind" type="logical"
1864+
category="advection" group="advection">
1865+
If true, use upwindFactor to scale layerThickEdgeFlux by centered and upwind values.
1866+
1867+
Valid values: .true. or .false.
1868+
Default: Defined in namelist_defaults.xml
1869+
</entry>
1870+
1871+
<entry id="config_spatially_variable_upwind_hmin" type="real"
1872+
category="advection" group="advection">
1873+
Column thickness above which we start weighting upwind with centered advection.
1874+
1875+
Valid values: Any positive real
1876+
Default: Defined in namelist_defaults.xml
1877+
</entry>
1878+
1879+
<entry id="config_spatially_variable_upwind_hmax" type="real"
1880+
category="advection" group="advection">
1881+
Column thickness above which advection is no longer upwinded.
1882+
1883+
Valid values: Any positive real
1884+
Default: Defined in namelist_defaults.xml
1885+
</entry>
1886+
18631887

18641888
<!-- bottom_drag -->
18651889

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
config_time_integrator = 'split_explicit'
12
config_thickness_flux_type = 'upwind'
3+
config_use_spatially_variable_upwind = .true.
4+
config_spatially_variable_upwind_hmin = 10.0
5+
config_spatially_variable_upwind_hmax = 50.0

components/mpas-ocean/src/Registry.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,18 @@
11581158
description="If 'upwind', use upwind to evaluate the edge-value for layerThickness, i.e., layerThickEdgeFlux. The standard MPAS-O approach is 'centered'. For 'constant', uses constant thickness in time from restingThickness, for linear test problems. Note that these two flags are set together for linearized test cases: config_thickness_flux_type = 'constant' linearizes the thickness equation, and config_disable_vel_hadv = .true. linearizes the momentum equation if there is no assumed mean background velocity."
11591159
possible_values="'upwind', 'centered', 'constant'"
11601160
/>
1161+
<nml_option name="config_use_spatially_variable_upwind" type="logical" default_value=".false."
1162+
description="If true, use upwindFactor to scale layerThickEdgeFlux by centered and upwind values."
1163+
possible_values=".true. or .false."
1164+
/>
1165+
<nml_option name="config_spatially_variable_upwind_hmin" type="real" default_value="5.0"
1166+
description="Column thickness above which we start weighting upwind with centered advection."
1167+
possible_values="Any positive real"
1168+
/>
1169+
<nml_option name="config_spatially_variable_upwind_hmax" type="real" default_value="10.0"
1170+
description="Column thickness above which advection is no longer upwinded."
1171+
possible_values="Any positive real"
1172+
/>
11611173
</nml_record>
11621174
<nml_record name="bottom_drag" mode="forward">
11631175
<nml_option name="config_bottom_drag_mode" type="character" default_value="implicit"
@@ -1815,6 +1827,7 @@
18151827
<var name="fCell"/>
18161828
<var name="bed_elevation"/>
18171829
<var name="LTSRegion"/>
1830+
<var name="upwindFactor"/>
18181831
</stream>
18191832

18201833
<stream name="output_init"
@@ -1849,6 +1862,7 @@
18491862
<var name="landIceFloatingMask"/>
18501863
<var name="landIceFloatingFraction"/>
18511864
<var name="LTSRegion"/>
1865+
<var name="upwindFactor"/>
18521866
</stream>
18531867

18541868
<stream name="forcing_data_init"
@@ -3084,6 +3098,11 @@
30843098
missing_value="FILLVAL" missing_value_mask="vertexMask"
30853099
packages="forwardMode;analysisMode"
30863100
/>
3101+
<!-- Input fields from initial condition for spatially variable upwinding -->
3102+
<var name="upwindFactor" type="real" dimensions="nEdges Time" units="1"
3103+
description="The fraction of horizontal advection that is upwinded. Range from 0 (centered) to 1 (fully upwind)"
3104+
/>
3105+
30873106

30883107
<var name="kineticEnergyCell" type="real" dimensions="nVertLevels nCells Time" units="m^2 s^-2"
30893108
description="kinetic energy of horizontal velocity on cells"

components/mpas-ocean/src/shared/mpas_ocn_diagnostics.F

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ subroutine ocn_diagnostic_solve_layerThicknessEdge(normalVelocity, &
863863
iEdge, k, &! edge and vertical loop indices
864864
cell1, cell2, &! neighbor cell indices across an edge
865865
kmin, kmax ! min,max active vertical levels
866-
866+
real(kind=RKIND) :: columnThickness
867867
! End preamble
868868
!-----------------------------------------------------------------
869869
! Begin code
@@ -991,7 +991,43 @@ subroutine ocn_diagnostic_solve_layerThicknessEdge(normalVelocity, &
991991
#endif
992992

993993
end if
994-
994+
if (config_use_spatially_variable_upwind) then
995+
#ifdef MPAS_OPENACC
996+
!$acc parallel loop &
997+
!$acc present(layerThickEdgeMean, layerThickEdgeFlux, &
998+
!$acc minLevelEdgeBot, maxLevelEdgeTop, &
999+
!$acc upwindFactor) &
1000+
!$acc private(k, kmin, kmax, columnThickness)
1001+
#else
1002+
!$omp parallel
1003+
!$omp do schedule(runtime) private(k, kmin, kmax, cell1, cell2, columnThickness)
1004+
#endif
1005+
do iEdge = 1, nEdgesAll
1006+
cell1 = cellsOnEdge(1,iEdge)
1007+
cell2 = cellsOnEdge(2,iEdge)
1008+
columnThickness = min(bottomDepth(cell1) + ssh(cell1), &
1009+
bottomDepth(cell2) + ssh(cell2))
1010+
if (columnThickness <= config_spatially_variable_upwind_hmin) then
1011+
upwindFactor(iEdge) = 1.0_RKIND
1012+
elseif (columnThickness >= config_spatially_variable_upwind_hmax) then
1013+
upwindFactor(iEdge) = 0.0_RKIND
1014+
else
1015+
upwindFactor(iEdge) = 1.0_RKIND - &
1016+
(columnThickness - config_spatially_variable_upwind_hmin) / &
1017+
(config_spatially_variable_upwind_hmax - config_spatially_variable_upwind_hmin)
1018+
end if
1019+
kmin = minLevelEdgeBot(iEdge)
1020+
kmax = maxLevelEdgeTop(iEdge)
1021+
do k = kmin,kmax
1022+
layerThickEdgeFlux(k,iEdge) = (1.0_RKIND - upwindFactor(iEdge)) * layerThickEdgeMean(k,iEdge) &
1023+
+ upwindFactor(iEdge)* layerThickEdgeFlux(k,iEdge)
1024+
end do
1025+
end do
1026+
#ifndef MPAS_OPENACC
1027+
!$omp end do
1028+
!$omp end parallel
1029+
#endif
1030+
endif
9951031
case (thickEdgeFluxConstant)
9961032
! Use linearized version H*u where H is constant in time
9971033

components/mpas-ocean/src/shared/mpas_ocn_diagnostics_variables.F

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ module ocn_diagnostics_variables
7070
real (kind=RKIND), dimension(:,:), pointer :: RiTopOfCell
7171
real (kind=RKIND), dimension(:,:), pointer :: RiTopOfEdge
7272

73+
real (kind=RKIND), dimension(:), pointer :: upwindFactor
7374
real (kind=RKIND), dimension(:), pointer :: gradSSH
7475
real (kind=RKIND), dimension(:), pointer :: pressureAdjustedSSH
7576
real (kind=RKIND), dimension(:), pointer :: pgf_sal
@@ -291,6 +292,10 @@ subroutine ocn_diagnostics_variables_init(domain, jenkinsOn, hollandJenkinsOn, e
291292
call mpas_pool_get_array(diagnosticsPool, 'sshCellWetDry', &
292293
sshCellWetDry)
293294
end if
295+
if (config_use_spatially_variable_upwind) then
296+
call mpas_pool_get_array(diagnosticsPool, 'upwindFactor', &
297+
upwindFactor)
298+
end if
294299

295300
if (config_use_GM.or.config_use_Redi) then
296301
call mpas_pool_get_array(diagnosticsPool, 'RediKappa', &
@@ -814,6 +819,7 @@ subroutine ocn_diagnostics_variables_init(domain, jenkinsOn, hollandJenkinsOn, e
814819
!$acc GMStreamFuncX, &
815820
!$acc GMStreamFuncY, &
816821
!$acc GMStreamFuncZ, &
822+
!$acc upwindFactor, &
817823
!$acc layerThickEdgeDrag, &
818824
!$acc layerThickEdgeFlux, &
819825
!$acc layerThickEdgeMean, &
@@ -1076,6 +1082,7 @@ subroutine ocn_diagnostics_variables_destroy(err) !{{{
10761082
!$acc GMStreamFuncX, &
10771083
!$acc GMStreamFuncY, &
10781084
!$acc GMStreamFuncZ, &
1085+
!$acc upwindFactor, &
10791086
!$acc layerThickEdgeDrag, &
10801087
!$acc layerThickEdgeFlux, &
10811088
!$acc layerThickEdgeMean, &
@@ -1285,6 +1292,7 @@ subroutine ocn_diagnostics_variables_destroy(err) !{{{
12851292
GMStreamFuncX, &
12861293
GMStreamFuncY, &
12871294
GMStreamFuncZ, &
1295+
upwindFactor, &
12881296
layerThickEdgeDrag, &
12891297
layerThickEdgeFlux, &
12901298
layerThickEdgeMean, &

0 commit comments

Comments
 (0)