Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions components/mpas-ocean/bld/build-namelist
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,9 @@ add_default($nl, 'config_coef_3rd_order');
add_default($nl, 'config_flux_limiter');
add_default($nl, 'config_remap_limiter');
add_default($nl, 'config_thickness_flux_type');
add_default($nl, 'config_use_spatially_variable_upwind');
add_default($nl, 'config_spatially_variable_upwind_hmin');
add_default($nl, 'config_spatially_variable_upwind_hmax');

###############################
# Namelist group: bottom_drag #
Expand Down
3 changes: 3 additions & 0 deletions components/mpas-ocean/bld/build-namelist-section
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ add_default($nl, 'config_coef_3rd_order');
add_default($nl, 'config_flux_limiter');
add_default($nl, 'config_remap_limiter');
add_default($nl, 'config_thickness_flux_type');
add_default($nl, 'config_use_spatially_variable_upwind');
add_default($nl, 'config_spatially_variable_upwind_hmin');
add_default($nl, 'config_spatially_variable_upwind_hmax');

###############################
# Namelist group: bottom_drag #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@
<config_flux_limiter>'monotonic'</config_flux_limiter>
<config_remap_limiter>'monotonic'</config_remap_limiter>
<config_thickness_flux_type>'centered'</config_thickness_flux_type>
<config_use_spatially_variable_upwind>.false.</config_use_spatially_variable_upwind>
<config_spatially_variable_upwind_hmin>5.0</config_spatially_variable_upwind_hmin>
<config_spatially_variable_upwind_hmax>10.0</config_spatially_variable_upwind_hmax>

<!-- bottom_drag -->
<config_bottom_drag_mode>'implicit'</config_bottom_drag_mode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,30 @@ Valid values: 'upwind', 'centered', 'constant'
Default: Defined in namelist_defaults.xml
</entry>

<entry id="config_use_spatially_variable_upwind" type="logical"
category="advection" group="advection">
If true, use upwindFactor to scale layerThickEdgeFlux by centered and upwind values.

Valid values: .true. or .false.
Default: Defined in namelist_defaults.xml
</entry>

<entry id="config_spatially_variable_upwind_hmin" type="real"
category="advection" group="advection">
Column thickness above which we start weighting upwind with centered advection.

Valid values: Any positive real
Default: Defined in namelist_defaults.xml
</entry>

<entry id="config_spatially_variable_upwind_hmax" type="real"
category="advection" group="advection">
Column thickness above which advection is no longer upwinded.

Valid values: Any positive real
Default: Defined in namelist_defaults.xml
</entry>


<!-- bottom_drag -->

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
config_time_integrator = 'split_explicit'
config_thickness_flux_type = 'upwind'
config_use_spatially_variable_upwind = .true.
config_spatially_variable_upwind_hmin = 10.0
config_spatially_variable_upwind_hmax = 50.0
19 changes: 19 additions & 0 deletions components/mpas-ocean/src/Registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,18 @@
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."
possible_values="'upwind', 'centered', 'constant'"
/>
<nml_option name="config_use_spatially_variable_upwind" type="logical" default_value=".false."
description="If true, use upwindFactor to scale layerThickEdgeFlux by centered and upwind values."
possible_values=".true. or .false."
/>
<nml_option name="config_spatially_variable_upwind_hmin" type="real" default_value="5.0"
description="Column thickness above which we start weighting upwind with centered advection."
possible_values="Any positive real"
/>
<nml_option name="config_spatially_variable_upwind_hmax" type="real" default_value="10.0"
description="Column thickness above which advection is no longer upwinded."
possible_values="Any positive real"
/>
</nml_record>
<nml_record name="bottom_drag" mode="forward">
<nml_option name="config_bottom_drag_mode" type="character" default_value="implicit"
Expand Down Expand Up @@ -1805,6 +1817,7 @@
<var name="fCell"/>
<var name="bed_elevation"/>
<var name="LTSRegion"/>
<var name="upwindFactor"/>
</stream>

<stream name="output_init"
Expand Down Expand Up @@ -1839,6 +1852,7 @@
<var name="landIceFloatingMask"/>
<var name="landIceFloatingFraction"/>
<var name="LTSRegion"/>
<var name="upwindFactor"/>
</stream>

<stream name="forcing_data_init"
Expand Down Expand Up @@ -3074,6 +3088,11 @@
missing_value="FILLVAL" missing_value_mask="vertexMask"
packages="forwardMode;analysisMode"
/>
<!-- Input fields from initial condition for spatially variable upwinding -->
<var name="upwindFactor" type="real" dimensions="nEdges Time" units="1"
description="The fraction of horizontal advection that is upwinded. Range from 0 (centered) to 1 (fully upwind)"
/>


<var name="kineticEnergyCell" type="real" dimensions="nVertLevels nCells Time" units="m^2 s^-2"
description="kinetic energy of horizontal velocity on cells"
Expand Down
40 changes: 38 additions & 2 deletions components/mpas-ocean/src/shared/mpas_ocn_diagnostics.F
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ subroutine ocn_diagnostic_solve_layerThicknessEdge(normalVelocity, &
iEdge, k, &! edge and vertical loop indices
cell1, cell2, &! neighbor cell indices across an edge
kmin, kmax ! min,max active vertical levels

real(kind=RKIND) :: columnThickness
! End preamble
!-----------------------------------------------------------------
! Begin code
Expand Down Expand Up @@ -985,7 +985,43 @@ subroutine ocn_diagnostic_solve_layerThicknessEdge(normalVelocity, &
#endif

end if

if (config_use_spatially_variable_upwind) then
Copy link
Contributor

@sbrus89 sbrus89 Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should probably be a check to make sure in the init routine to require config_thickness_flux_type = 'upwind' with config_use_spatially_variable_upwind=.true.. I suppose there's no harm in leaving config_use_spatially_variable_upwind=.true. on for config_thickness_flux_type = 'centered', but right now it will silently do a needless interpolation between the same values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll add that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbrus89 This check is in case (thickEdgeFluxUpwind) so I don't think there is a needless interpolation. Let me know if you see something that I don't.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right; I missed that. Thanks!

#ifdef MPAS_OPENACC
!$acc parallel loop &
!$acc present(layerThickEdgeMean, layerThickEdgeFlux, &
!$acc minLevelEdgeBot, maxLevelEdgeTop, &
!$acc upwindFactor) &
!$acc private(k, kmin, kmax, columnThickness)
#else
!$omp parallel
!$omp do schedule(runtime) private(k, kmin, kmax, cell1, cell2, columnThickness)
#endif
do iEdge = 1, nEdgesAll
cell1 = cellsOnEdge(1,iEdge)
cell2 = cellsOnEdge(2,iEdge)
columnThickness = min(bottomDepth(cell1) + ssh(cell1), &
bottomDepth(cell2) + ssh(cell2))
if (columnThickness <= config_spatially_variable_upwind_hmin) then
upwindFactor(iEdge) = 1.0_RKIND
elseif (columnThickness >= config_spatially_variable_upwind_hmax) then
upwindFactor(iEdge) = 0.0_RKIND
else
upwindFactor(iEdge) = 1.0_RKIND - &
(columnThickness - config_spatially_variable_upwind_hmin) / &
(config_spatially_variable_upwind_hmax - config_spatially_variable_upwind_hmin)
end if
kmin = minLevelEdgeBot(iEdge)
kmax = maxLevelEdgeTop(iEdge)
do k = kmin,kmax
layerThickEdgeFlux(k,iEdge) = (1.0_RKIND - upwindFactor(iEdge)) * layerThickEdgeMean(k,iEdge) &
+ upwindFactor(iEdge)* layerThickEdgeFlux(k,iEdge)
end do
end do
#ifndef MPAS_OPENACC
!$omp end do
!$omp end parallel
#endif
endif
case (thickEdgeFluxConstant)
! Use linearized version H*u where H is constant in time

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module ocn_diagnostics_variables
real (kind=RKIND), dimension(:,:), pointer :: RiTopOfCell
real (kind=RKIND), dimension(:,:), pointer :: RiTopOfEdge

real (kind=RKIND), dimension(:), pointer :: upwindFactor
real (kind=RKIND), dimension(:), pointer :: gradSSH
real (kind=RKIND), dimension(:), pointer :: pressureAdjustedSSH
real (kind=RKIND), dimension(:), pointer :: pgf_sal
Expand Down Expand Up @@ -290,6 +291,10 @@ subroutine ocn_diagnostics_variables_init(domain, jenkinsOn, hollandJenkinsOn, e
call mpas_pool_get_array(diagnosticsPool, 'sshCellWetDry', &
sshCellWetDry)
end if
if (config_use_spatially_variable_upwind) then
call mpas_pool_get_array(diagnosticsPool, 'upwindFactor', &
upwindFactor)
end if

if (config_use_GM.or.config_use_Redi) then
call mpas_pool_get_array(diagnosticsPool, 'RediKappa', &
Expand Down Expand Up @@ -811,6 +816,7 @@ subroutine ocn_diagnostics_variables_init(domain, jenkinsOn, hollandJenkinsOn, e
!$acc GMStreamFuncX, &
!$acc GMStreamFuncY, &
!$acc GMStreamFuncZ, &
!$acc upwindFactor, &
!$acc layerThickEdgeDrag, &
!$acc layerThickEdgeFlux, &
!$acc layerThickEdgeMean, &
Expand Down Expand Up @@ -1072,6 +1078,7 @@ subroutine ocn_diagnostics_variables_destroy(err) !{{{
!$acc GMStreamFuncX, &
!$acc GMStreamFuncY, &
!$acc GMStreamFuncZ, &
!$acc upwindFactor, &
!$acc layerThickEdgeDrag, &
!$acc layerThickEdgeFlux, &
!$acc layerThickEdgeMean, &
Expand Down Expand Up @@ -1280,6 +1287,7 @@ subroutine ocn_diagnostics_variables_destroy(err) !{{{
GMStreamFuncX, &
GMStreamFuncY, &
GMStreamFuncZ, &
upwindFactor, &
layerThickEdgeDrag, &
layerThickEdgeFlux, &
layerThickEdgeMean, &
Expand Down