From 916a878ec7dab31f29d733ef470b895900595c97 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Fri, 27 Jan 2012 20:29:09 -0500 Subject: [PATCH] modified cmfd header file to include a constructor and destructor --- src/cmfd_header.F90 | 79 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/src/cmfd_header.F90 b/src/cmfd_header.F90 index fbeea17491..b4f9633ab5 100644 --- a/src/cmfd_header.F90 +++ b/src/cmfd_header.F90 @@ -1,13 +1,15 @@ module cmfd_header implicit none + private + public :: allocate_cmfd, deallocate_cmfd !=============================================================================== ! cmfd is used to store diffusion parameters and other information for CMFD ! analysis. !=============================================================================== - type cmfd_obj + type, public :: cmfd_obj ! array indices([1-x,2-y,3-z,4-g],upper bound) integer :: indices(4) @@ -50,9 +52,82 @@ module cmfd_header integer, allocatable :: coremap(:,:,:) integer :: mat_dim - ! eigenvector from cmfd run + ! eigenvector/eigenvalue from cmfd run real(8), allocatable :: phi(:) + real(8) :: keff end type cmfd_obj +contains + +!=============================================================================== +! ALLOCATE_CMFD allocates all of the space for the cmfd object based on tallies +!=============================================================================== + + subroutine allocate_cmfd(this) + + type(cmfd_obj) :: this + + integer :: nx ! number of mesh cells in x direction + integer :: ny ! number of mesh cells in y direction + integer :: nz ! number of mesh cells in z direction + integer :: ng ! number of energy groups + + ! extract spatial and energy indices from object + nx = this % indices(1) + ny = this % indices(2) + nz = this % indices(3) + ng = this % indices(4) + + ! allocate flux, cross sections and diffusion coefficient + if (.not. allocated(this % flux)) allocate(this % flux(ng,nx,ny,nz)) + if (.not. allocated(this % totalxs)) allocate(this % totalxs(ng,nx,ny,nz)) + if (.not. allocated(this % p1scattxs)) allocate(this % p1scattxs(ng,nx,ny,nz)) + if (.not. allocated(this % scattxs)) allocate(this % scattxs(ng,ng,nx,ny,nz)) + if (.not. allocated(this % nfissxs)) allocate(this % nfissxs(ng,ng,nx,ny,nz)) + if (.not. allocated(this % diffcof)) allocate(this % diffcof(ng,nx,ny,nz)) + + ! allocate dtilde and dhat + if (.not. allocated(this % dtilde)) allocate(this % dtilde(6,ng,nx,ny,nz)) + if (.not. allocated(this % dhat)) allocate(this % dhat(6,ng,nx,ny,nz)) + + ! allocate dimensions for each box (here for general case) + if (.not. allocated(this % hxyz)) allocate(this % hxyz(3,nx,ny,nz)) + + ! allocate this fission source pdf + !allocate( this % sourcepdf(ng,nx,ny,nz) ) + + ! allocate surface currents + if (.not. allocated(this % current)) allocate(this % current(12,ng,nx,ny,nz)) + + end subroutine allocate_cmfd + +!=============================================================================== +! DEALLOCATE_CMFD +!=============================================================================== + + subroutine deallocate_cmfd(this) + + type(cmfd_obj) :: this + + ! deallocate cmfd + if (allocated(this % totalxs)) deallocate(this % totalxs) + if (allocated(this % p1scattxs)) deallocate(this % p1scattxs) + if (allocated(this % scattxs)) deallocate(this % scattxs) + if (allocated(this % nfissxs)) deallocate(this % nfissxs) + if (allocated(this % diffcof)) deallocate(this % diffcof) + if (allocated(this % current)) deallocate(this % current) + if (allocated(this % flux)) deallocate(this % flux) + if (allocated(this % dtilde)) deallocate(this % dtilde) + if (allocated(this % dhat)) deallocate(this % dhat) + if (allocated(this % hxyz)) deallocate(this % hxyz) + if (allocated(this % coremap)) deallocate(this % coremap) + if (allocated(this % phi)) deallocate(this % phi) + if (allocated(this % sourcepdf)) deallocate(this % sourcepdf) + if (allocated(this % sourcecounts)) deallocate(this % sourcecounts) + if (allocated(this % weightfactors)) deallocate(this % weightfactors) + + + end subroutine deallocate_cmfd + end module cmfd_header