Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
656510b
Neutral positions by discontinuous PPM
May 17, 2017
a3ff5b9
Additional changes to make sure that code compiles. Development of the
May 18, 2017
338eed0
Merge branch 'dev/master' of https://github.com/NOAA-GFDL/MOM6 into n…
Jun 20, 2017
edb24ec
Some initial changes for the neutral surface positions found using a …
Jun 22, 2017
b107012
Discontinuous T/S reconstruction still does not work correctly because
Jun 23, 2017
7cb8d91
Make changes based on python prototyping of the discontinuous version of
Jun 28, 2017
25655dd
Fixed which pressure array is supposed to be used
Jun 28, 2017
7af4a78
Discontinuous reconstruction of neutral diffusion is working better, but
Jun 29, 2017
2e9d5b5
Updated the discontinuous reconstruction, but not working as expected…
Jul 11, 2017
fc5cf60
Newer algorithm works away from top and bottom boundaries
Jul 13, 2017
411f15d
Fixed conflict with upstream
Jul 13, 2017
fb6a978
Neutral surface discontinuous reconstuction with no boundary extrap
Jul 13, 2017
c7bfe51
Merge branch 'dev/gfdl' of https://github.com/NOAA-GFDL/MOM6 into ndi…
Jul 13, 2017
4788577
Change module name variable from mod to mdl
Jul 13, 2017
9463983
Replace column reconstruction with functions from PPM_routines.F90
Jul 17, 2017
dbe3dd0
Replace more routines with those from MOM_remapping.F90
Jul 17, 2017
baf6f34
Continue to replace discontinuous reconstruction with MOM_remapping
Jul 18, 2017
60bcfd0
Need to figure out why some kind of spurious perfectly horizontal dif…
Jul 19, 2017
c72a503
Working as expected in z* (not rho) coordinate mode. However, do need to
Jul 20, 2017
a49373c
Replace the linear interpolation used to calculate temperature gradients
Jul 20, 2017
848739f
Included new functions to calculate the second derivatives of density…
Jul 22, 2017
9f647ef
Begin to add a rootfinder to solve for the position of a nuetral surface
Jul 22, 2017
5aef6c5
Add scalar version of routines for higher order density derivatives
Jul 22, 2017
09e50cc
Finished at least the original code for the refinement of neutral pos…
Jul 22, 2017
a9fa212
Add an extractor routine for the remapping control structure
Jul 23, 2017
0fd0732
Refinement of neutral surface position routine is ready to be tested
Jul 23, 2017
823efe0
Root-finding algorithm works as expected. Need to replace the current
Jul 26, 2017
23cfeb9
Added options to choose (exclusively) between bisection, Newton's, or
Jul 27, 2017
449b247
Update MOM_EOS and MOM_EOS_Wright to include calculation of second
Jul 31, 2017
cc698ea
Update neutral diffusion with the following:
Jul 31, 2017
85373d6
Fixed some bugs in refine_nondim_position
Jul 31, 2017
362c876
Realized that same_direction should be false if reached_bottom is true.
Aug 3, 2017
7ca30aa
Write unit tests for refine_nondim_position. Next up is the discontin…
Aug 3, 2017
23b4f77
-Adds unit tests for discontinuous routines
Aug 7, 2017
fd43de3
Make convergence criteria runtime parameters as opposed to hardcoded
Aug 7, 2017
972fa8c
Merge branch 'dev/gfdl' of https://github.com/NOAA-GFDL/MOM6 into ndi…
Aug 7, 2017
b9f7820
Undo an unnecessary change in MOM_remapping.F90
Aug 7, 2017
e00744e
Allow runtime option for verbose output in neutral diffusion
Aug 8, 2017
acffea3
Rewrite logic. Only unit test failing now is two unstable mixed layers
Aug 9, 2017
2030906
Whew, finally figured out logic that passes all unit tests.
Aug 10, 2017
d977fd5
Logic has been updated to be more consistent with the original code and
Aug 11, 2017
0b82c20
Cleanup some of the code and prepare for pull request
Aug 11, 2017
4121196
Accidentally had changed the bounds of a do-loop in the continuous case
Aug 11, 2017
8dd0ee3
Create procedures for array and scalar inputs to EOS functions
Aug 15, 2017
cfe2612
Make logic explicit to avoid out-of-bounds error
Aug 15, 2017
ede2d22
Undo changes to continuous code that lead to answer-changes
Aug 15, 2017
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
65 changes: 41 additions & 24 deletions src/ALE/MOM_remapping.F90
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ module MOM_remapping

! The following routines are visible to the outside world
public remapping_core_h, remapping_core_w
public initialize_remapping, end_remapping, remapping_set_param
public remapping_unit_tests
public initialize_remapping, end_remapping, remapping_set_param, extract_member_remapping_CS
public remapping_unit_tests, build_reconstructions_1d, average_value_ppoly
public dzFromH1H2

! The following are private parameter constants
Expand Down Expand Up @@ -109,6 +109,26 @@ subroutine remapping_set_param(CS, remapping_scheme, boundary_extrapolation, &
endif
end subroutine remapping_set_param

subroutine extract_member_remapping_CS(CS, remapping_scheme, degree, boundary_extrapolation, check_reconstruction, &
check_remapping, force_bounds_in_subcell)
type(remapping_CS), intent(in) :: CS !< Control structure for remapping module
integer, optional, intent(out) :: remapping_scheme !< Determines which reconstruction scheme to use
integer, optional, intent(out) :: degree !< Degree of polynomial reconstruction
logical, optional, intent(out) :: boundary_extrapolation !< If true, extrapolate boundaries
logical, optional, intent(out) :: check_reconstruction !< If true, reconstructions are checked for consistency.
logical, optional, intent(out) :: check_remapping !< If true, the result of remapping are checked
!! for conservation and bounds.
logical, optional, intent(out) :: force_bounds_in_subcell !< If true, the intermediate values used in
!! remapping are forced to be bounded.

if (present(remapping_scheme)) remapping_scheme = CS%remapping_scheme
if (present(degree)) degree = CS%degree
if (present(boundary_extrapolation)) boundary_extrapolation = CS%boundary_extrapolation
if (present(check_reconstruction)) check_reconstruction = CS%check_reconstruction
if (present(check_remapping)) check_remapping = CS%check_remapping
if (present(force_bounds_in_subcell)) force_bounds_in_subcell = CS%force_bounds_in_subcell

end subroutine extract_member_remapping_CS
!> Calculate edge coordinate x from cell width h
subroutine buildGridFromH(nz, h, x)
integer, intent(in) :: nz !< Number of cells
Expand Down Expand Up @@ -175,8 +195,7 @@ subroutine remapping_core_h(CS, n0, h0, u0, n1, h1, u1)
integer :: k
real :: eps, h0tot, h0err, h1tot, h1err, u0tot, u0err, u0min, u0max, u1tot, u1err, u1min, u1max, uh_err

call build_reconstructions_1d( n0, h0, u0, CS%remapping_scheme, CS%degree, CS%boundary_extrapolation, &
ppoly_r_coefficients, ppoly_r_E, ppoly_r_S, iMethod )
call build_reconstructions_1d( CS, n0, h0, u0, ppoly_r_coefficients, ppoly_r_E, ppoly_r_S, iMethod )

if (CS%check_reconstruction) call check_reconstructions_1d(n0, h0, u0, CS%degree, &
CS%boundary_extrapolation, ppoly_r_coefficients, ppoly_r_E, ppoly_r_S)
Expand Down Expand Up @@ -243,8 +262,7 @@ subroutine remapping_core_w( CS, n0, h0, u0, n1, dx, u1 )
real :: u0tot, u0err, u0min, u0max, u1tot, u1err, u1min, u1max, uh_err
real, dimension(n1) :: h1 !< Cell widths on target grid

call build_reconstructions_1d( n0, h0, u0, CS%remapping_scheme, CS%degree, CS%boundary_extrapolation, &
ppoly_r_coefficients, ppoly_r_E, ppoly_r_S, iMethod )
call build_reconstructions_1d( CS, n0, h0, u0, ppoly_r_coefficients, ppoly_r_E, ppoly_r_S, iMethod )

if (CS%check_reconstruction) call check_reconstructions_1d(n0, h0, u0, CS%degree, &
CS%boundary_extrapolation, ppoly_r_coefficients, ppoly_r_E, ppoly_r_S)
Expand Down Expand Up @@ -301,28 +319,27 @@ subroutine remapping_core_w( CS, n0, h0, u0, n1, dx, u1 )
end subroutine remapping_core_w

!> Creates polynomial reconstructions of u0 on the source grid h0.
subroutine build_reconstructions_1d( n0, h0, u0, remapping_scheme, deg, boundary_extrapolation, &
ppoly_r_coefficients, ppoly_r_E, ppoly_r_S, iMethod )
integer, intent(in) :: n0 !< Number of cells on source grid
real, dimension(n0), intent(in) :: h0 !< Cell widths on source grid
real, dimension(n0), intent(in) :: u0 !< Cell averages on source grid
integer, intent(in) :: remapping_scheme !< Remapping scheme
integer, intent(in) :: deg !< Degree of polynomial reconstruction
logical, intent(in) :: boundary_extrapolation !< Extrapolate at boundaries if true
real, dimension(n0,deg+1),intent(out) :: ppoly_r_coefficients !< Coefficients of polynomial
real, dimension(n0,2), intent(out) :: ppoly_r_E !< Edge value of polynomial
real, dimension(n0,2), intent(out) :: ppoly_r_S !< Edge slope of polynomial
integer, intent(out) :: iMethod !< Integration method
subroutine build_reconstructions_1d( CS, n0, h0, u0, ppoly_r_coefficients, ppoly_r_E, ppoly_r_S, iMethod )
type(remapping_CS), intent(in) :: CS
integer, intent(in) :: n0 !< Number of cells on source grid
real, dimension(n0), intent(in) :: h0 !< Cell widths on source grid
real, dimension(n0), intent(in) :: u0 !< Cell averages on source grid
real, dimension(n0,CS%degree+1), intent(out) :: ppoly_r_coefficients !< Coefficients of polynomial
real, dimension(n0,2), intent(out) :: ppoly_r_E !< Edge value of polynomial
real, dimension(n0,2), intent(out) :: ppoly_r_S !< Edge slope of polynomial
integer, intent(out) :: iMethod !< Integration method
! Local variables
integer :: local_remapping_scheme
integer :: remapping_scheme !< Remapping scheme
logical :: boundary_extrapolation !< Extrapolate at boundaries if true

! Reset polynomial
ppoly_r_E(:,:) = 0.0
ppoly_r_S(:,:) = 0.0
ppoly_r_coefficients(:,:) = 0.0
iMethod = -999

local_remapping_scheme = remapping_scheme
local_remapping_scheme = CS%remapping_scheme
if (n0<=1) then
local_remapping_scheme = REMAPPING_PCM
elseif (n0<=3) then
Expand All @@ -336,37 +353,37 @@ subroutine build_reconstructions_1d( n0, h0, u0, remapping_scheme, deg, boundary
iMethod = INTEGRATION_PCM
case ( REMAPPING_PLM )
call PLM_reconstruction( n0, h0, u0, ppoly_r_E, ppoly_r_coefficients )
if ( boundary_extrapolation) then
if ( CS%boundary_extrapolation ) then
call PLM_boundary_extrapolation( n0, h0, u0, ppoly_r_E, ppoly_r_coefficients)
end if
iMethod = INTEGRATION_PLM
case ( REMAPPING_PPM_H4 )
call edge_values_explicit_h4( n0, h0, u0, ppoly_r_E )
call PPM_reconstruction( n0, h0, u0, ppoly_r_E, ppoly_r_coefficients )
if ( boundary_extrapolation) then
if ( CS%boundary_extrapolation ) then
call PPM_boundary_extrapolation( n0, h0, u0, ppoly_r_E, ppoly_r_coefficients )
end if
iMethod = INTEGRATION_PPM
case ( REMAPPING_PPM_IH4 )
call edge_values_implicit_h4( n0, h0, u0, ppoly_r_E )
call PPM_reconstruction( n0, h0, u0, ppoly_r_E, ppoly_r_coefficients )
if ( boundary_extrapolation) then
if ( CS%boundary_extrapolation ) then
call PPM_boundary_extrapolation( n0, h0, u0, ppoly_r_E, ppoly_r_coefficients )
end if
iMethod = INTEGRATION_PPM
case ( REMAPPING_PQM_IH4IH3 )
call edge_values_implicit_h4( n0, h0, u0, ppoly_r_E )
call edge_slopes_implicit_h3( n0, h0, u0, ppoly_r_S )
call PQM_reconstruction( n0, h0, u0, ppoly_r_E, ppoly_r_S, ppoly_r_coefficients )
if ( boundary_extrapolation) then
if ( CS%boundary_extrapolation ) then
call PQM_boundary_extrapolation_v1( n0, h0, u0, ppoly_r_E, ppoly_r_S, ppoly_r_coefficients )
end if
iMethod = INTEGRATION_PQM
case ( REMAPPING_PQM_IH6IH5 )
call edge_values_implicit_h6( n0, h0, u0, ppoly_r_E )
call edge_slopes_implicit_h5( n0, h0, u0, ppoly_r_S )
call PQM_reconstruction( n0, h0, u0, ppoly_r_E, ppoly_r_S, ppoly_r_coefficients )
if ( boundary_extrapolation) then
if ( CS%boundary_extrapolation ) then
call PQM_boundary_extrapolation_v1( n0, h0, u0, ppoly_r_E, ppoly_r_S, ppoly_r_coefficients )
end if
iMethod = INTEGRATION_PQM
Expand Down
33 changes: 32 additions & 1 deletion src/ALE/polynomial_functions.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module polynomial_functions

implicit none ; private

public :: evaluation_polynomial, integration_polynomial
public :: evaluation_polynomial, integration_polynomial, first_derivative_polynomial

! -----------------------------------------------------------------------------
! This module contains the following routines
Expand Down Expand Up @@ -51,6 +51,37 @@ real function evaluation_polynomial( coefficients, nb_coefficients, x )

end function evaluation_polynomial

!> Calculates the first derivative of a polynomial with coefficients as above
!! evaluated at a point x
real function first_derivative_polynomial( coefficients, nb_coefficients, x )
! -----------------------------------------------------------------------------
! The polynomial is defined by the coefficients contained in the
! array of the same name, as follows: C(1) + C(2)x + C(3)x^2 + C(4)x^3 + ...
! where C refers to the array 'coefficients'.
! The number of coefficients is given by nb_coefficients and x
! is the coordinate where the polynomial's derivative is to be evaluated.
!
! The function returns the value of the polynomial at x.
! -----------------------------------------------------------------------------

! Arguments
real, dimension(:), intent(in) :: coefficients
integer, intent(in) :: nb_coefficients
real, intent(in) :: x

! Local variables
integer :: k
real :: f ! value of polynomial at x

f = 0.0
do k = 2,nb_coefficients
f = f + REAL(k-1)*coefficients(k) * ( x**(k-2) )
end do

first_derivative_polynomial = f

end function first_derivative_polynomial

! -----------------------------------------------------------------------------
! Exact integration of polynomial of degree n
! -----------------------------------------------------------------------------
Expand Down
Loading