Skip to content

Commit

Permalink
initrefine, basic tests ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
pbosler committed Jan 21, 2014
1 parent 522ee6a commit f50b86a
Show file tree
Hide file tree
Showing 4 changed files with 802 additions and 0 deletions.
162 changes: 162 additions & 0 deletions BVEVorticity.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
module BVESetupModule
!******************************************************************************
! Peter A. Bosler
! Department of Mathematics
! University of Michigan
! [email protected]
!
!******************************************************************************
!
! Defines the RK4 data structure used by SphereMesh.
!
! Bosler, P.A., "Particle Methods for Geophysical Flow on the Sphere," PhD Thesis; the University of Michigan, 2013.
!
!----------------
! USAGE : This module provides methods for integrating the barotropic vorticity equation on the sphere.
!----------------
use NumberKindsModule
use LoggerModule
use SphereGeomModule
use ParticlesModule
use EdgesModule
use PanelsModule
use SphereMeshModule

implicit none

include 'mpif.h'

private
public BVESetup
public New, Delete
public InitSolidBodyRotation, SetSolidBodyRotationOnMesh
public SOLID_BODY_NINT, SOLID_BODY_NREAL

!
!----------------
! Types and module constants
!----------------
!
type BVESetup
integer(kint), pointer :: integers(:) => null() ! integers required by test case definitions
real(kreal), pointer :: reals(:) => null() ! real numbers required by test case definitions
end type

integer(kint), parameter :: SOLID_BODY_NINT = 0, SOLID_BODY_NREAL = 1

!
!----------------
! Logging
!----------------
!
logical(klog), save :: logInit = .FALSE.
type(Logger) :: log
character(len=28), save :: logKey = 'BVESetup'
integer(kint), parameter :: logLevel = DEBUG_LOGGING_LEVEL
character(len=128) :: logString
character(len=24) :: formatString
!
!----------------
! Interfaces
!----------------
!
contains
!
!----------------
! Standard methods : Constructor / Destructor
!----------------
!
subroutine NewPrivate(self, nInt, nReal)
type(BVESetup), intent(out) :: self
integer(kint), intent(in) :: nINt, nReal

if (.NOT. logInit) call InitLogger(log,procRank)

if ( nInt > 0 ) then
allocate(self%integers(nInt))
self%integers = 0
else
nullify(self%integers)
endif
if ( nReal > 0 ) then
allocate(self%reals(nReal))
self%reals = 0.0_kreal
else
nullify(self%reals)
endif
end subroutine

subroutine DeletePrivate(self)
type(BVESetup), intent(inout) :: self
if (associated(self%integers)) deallocate(self%integers)
if (associated(self%reals)) deallocate(self%reals)
call Delete(log)
logInit = .FALSE.
end subroutine

!
!----------------
! Public functions
!----------------
!
subroutine InitSolidBodyRotation(solidBody, rotRate)
type(BVESetup), intent(inout) :: solidBody
real(kreal), intent(in) :: rotRate

if ( size(solidBody%reals) /= 1) then
call LogMessage(log, ERROR_LOGGING_LEVEL,'BVESetup ERROR : ',' real array size incorrect')
return
endif

solidBody%reals(1) = rotRate
end subroutine

subroutine SetSolidBodyRotationOnMesh(aMesh, solidBody)
! sets absolute and relative vorticity for solid body test case
! NOTE : the role of absolute and relative vorticity is reversed for this test case only.
type(SphereMesh), intent(inout) :: aMesh
type(BVESetup), intent(in) :: solidBody
integer(kint) :: j
type(Particles), pointer :: aParticles
type(Panels), pointer :: aPanels

aParticles => aMesh%particles
aPanels => aMesh%panels

do j=1,aParticles%N
aParticles%relVort(j) = SolidBodyX(aParticles%x0(:,j), solidBody%reals(1))
enddo
do j=1,aPanels%N
if ( .NOT. aPanels%hasChildren(j) ) then
aPanels%relVort(j) = SOlidBOdyX(aPanels%x0(:,j), solidBody%reals(1))
else
aPanels%relVort(j) = 0.0_kreal
endif
enddo

end subroutine

!
!----------------
! Module methods : module- or type-specific private functions
!----------------
!

function SolidBodyX(xyz,rotationRate)
! Outputs vorticity associated with solid body rotation with angular velocity = rotation rate
! at position xyz.
real(kreal) :: SolidBodyX
real(kreal), intent(in) :: xyz(3), rotationRate
SolidBodyX = 2.0_kreal*rotationRate*xyz(3)
end function


subroutine InitLogger(aLog,rank)
type(Logger), intent(inout) :: aLog
integer(kint), intent(in) :: rank
write(logKey,'(A,A,I0.2,A)') trim(logKey),'_',rank,' : '
call New(aLog,logLevel)
logInit = .TRUE.
end subroutine

end module
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ stripack.o: stripack.f
STRIPACKInterface2.o: STRIPACKInterface2.f90 $(BASE_OBJS) $(MESH_OBJS) stripack.o
SSRFPACKInterface2.o: SSRFPACKInterface2.f90 $(BASE_OBJS) $(MESH_OBJS) STRIPACKInterface2.o ssrfpack.o
VTKOutput.o: VTKOutput.f90 $(BASE_OBJS) $(MESH_OBJS)
RefineRemesh2.o: RefineRemesh2.f90 $(BASE_OBJS) $(MESH_OBJS) $(INTERP_OBJS) Tracers.o BVEVorticity.o
Tracers.o: Tracers.f90 $(BASE_OBJS) $(MESH_OBJS)
BVEVorticity.o: BVEVorticity.f90 $(BASE_OBJS) $(MESH_OBJS)

#############################################################
## VTK EXECUTABLES
Expand Down
Loading

0 comments on commit f50b86a

Please sign in to comment.