Skip to content

Commit

Permalink
LevelsetFactory: abstract interface for various levelsets.
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer2368 committed Dec 15, 2022
1 parent 2527828 commit ee7bcdc
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 147 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ set(magudiObj_SOURCES
${PROJECT_SOURCE_DIR}/include/ReverseMigrator.f90
${PROJECT_SOURCE_DIR}/src/ReverseMigratorImpl.f90
${PROJECT_SOURCE_DIR}/include/MappingFunction.f90
${PROJECT_SOURCE_DIR}/include/LevelsetFactory.f90

# Extended types.
${PROJECT_SOURCE_DIR}/include/RK4Integrator.f90
Expand Down Expand Up @@ -213,6 +214,8 @@ set(magudiObj_SOURCES
${PROJECT_SOURCE_DIR}/src/KolmogorovForcingPatchImpl.f90
${PROJECT_SOURCE_DIR}/include/ImmersedBoundaryPatch.f90
${PROJECT_SOURCE_DIR}/src/ImmersedBoundaryImpl.f90
${PROJECT_SOURCE_DIR}/include/SinusoidalWallLevelset.f90
${PROJECT_SOURCE_DIR}/src/SinusoidalWallLevelsetImpl.f90

# C source files.
${PROJECT_SOURCE_DIR}/src/PLOT3DFormat.c
Expand Down
8 changes: 0 additions & 8 deletions include/ImmersedBoundaryPatch.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module ImmersedBoundaryPatch_mod
procedure, pass :: cleanup => cleanupImmersedBoundaryPatch
procedure, pass :: verifyUsage => verifyImmersedBoundaryPatchUsage
procedure, pass :: updateRhs => addImmersedBoundaryPenalty
procedure, pass :: updateLevelset => addImmersedBoundaryLevelset
end type t_ImmersedBoundaryPatch

interface
Expand Down Expand Up @@ -77,11 +76,4 @@ subroutine addImmersedBoundaryPenalty(this, mode, simulationFlags, solverOptions
end subroutine addImmersedBoundaryPenalty
end interface

interface
subroutine addImmersedBoundaryLevelset(this)
import :: t_ImmersedBoundaryPatch
class(t_ImmersedBoundaryPatch) :: this
end subroutine addImmersedBoundaryLevelset
end interface

end module ImmersedBoundaryPatch_mod
64 changes: 64 additions & 0 deletions include/LevelsetFactory.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "config.h"

module LevelsetFactory_mod

implicit none

type, abstract, public :: t_LevelsetFactory

contains

procedure(setup), pass, deferred :: setup
procedure(cleanup), pass, deferred :: cleanup
procedure(updateLevelset), pass, deferred :: updateLevelset

end type t_LevelsetFactory

abstract interface

subroutine setup(this, grids, states)

use Grid_mod, only : t_Grid
use State_mod, only : t_State

import :: t_LevelsetFactory

class(t_LevelsetFactory) :: this
class(t_Grid), intent(in) :: grids(:)
class(t_State) :: states(:)

end subroutine setup

end interface

abstract interface

subroutine cleanup(this)

import :: t_LevelsetFactory

class(t_LevelsetFactory) :: this

end subroutine cleanup

end interface

abstract interface

subroutine updateLevelset(this, mode, grids, states)

use Grid_mod, only : t_Grid
use State_mod, only : t_State

import :: t_LevelsetFactory

class(t_LevelsetFactory) :: this
integer, intent(in) :: mode
class(t_Grid), intent(in) :: grids(:)
class(t_State) :: states(:)

end subroutine updateLevelset

end interface

end module LevelsetFactory_mod
16 changes: 16 additions & 0 deletions include/Region.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module Region_mod
use SolverOptions_mod, only : t_SolverOptions
use PatchDescriptor_mod, only : t_PatchDescriptor
use SimulationFlags_mod, only : t_SimulationFlags
use LevelsetFactory_mod, only : t_LevelsetFactory

implicit none

Expand All @@ -33,13 +34,15 @@ module Region_mod
type(t_SolverOptions) :: solverOptions
type(t_SimulationFlags) :: simulationFlags
type(t_PatchDescriptor), allocatable :: patchData(:)
class(t_LevelsetFactory), pointer :: levelsetFactory => null()
integer :: comm = MPI_COMM_NULL, commGridMasters = MPI_COMM_NULL, timestep = 0
integer, allocatable :: globalGridSizes(:,:), processDistributions(:,:), &
gridCommunicators(:), patchCommunicators(:), patchInterfaces(:), &
interfaceIndexReorderings(:,:), patchMasterRanks(:)
logical :: outputOn = .true.
SCALAR_TYPE :: initialXmomentum, oneOverVolume, momentumLossPerVolume, &
adjointMomentumLossPerVolume
character(len=STRING_LENGTH) :: levelsetType

contains

Expand All @@ -55,6 +58,7 @@ module Region_mod
procedure, pass :: saveSpongeStrength
procedure, pass :: resetProbes
procedure, pass :: saveProbeData
procedure, pass :: connectLevelsetFactory

end type t_Region

Expand Down Expand Up @@ -227,4 +231,16 @@ end subroutine saveProbeData

end interface

interface

subroutine connectLevelsetFactory(this)

import :: t_Region

class(t_Region) :: this

end subroutine connectLevelsetFactory

end interface

end module Region_mod
73 changes: 73 additions & 0 deletions include/SinusoidalWallLevelset.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "config.h"

module SinusoidalWallLevelset_mod

use LevelsetFactory_mod, only : t_LevelsetFactory

implicit none

type, private :: t_SWInternal
SCALAR_TYPE, allocatable :: buffer(:)
end type t_SWInternal

type, extends(t_LevelsetFactory), public :: t_SinusoidalWallLevelset

type(t_SWInternal), dimension(:), allocatable :: wallShapes
real(SCALAR_KIND) :: levelsetLoc, levelsetWidth, levelsetAmp, levelsetPeriod

contains

procedure, pass :: setup => setupSinusoidalWallLevelset
procedure, pass :: cleanup => cleanupSinusoidalWallLevelset
procedure, pass :: updateLevelset => updateSinusoidalWallLevelset

end type t_SinusoidalWallLevelset

interface

subroutine setupSinusoidalWallLevelset(this, grids, states)

use Grid_mod, only : t_Grid
use State_mod, only : t_State

import :: t_SinusoidalWallLevelset

class(t_SinusoidalWallLevelset) :: this
class(t_Grid), intent(in) :: grids(:)
class(t_State) :: states(:)

end subroutine setupSinusoidalWallLevelset

end interface

interface

subroutine cleanupSinusoidalWallLevelset(this)

import :: t_SinusoidalWallLevelset

class(t_SinusoidalWallLevelset) :: this

end subroutine cleanupSinusoidalWallLevelset

end interface

interface

subroutine updateSinusoidalWallLevelset(this, mode, grids, states)

use Grid_mod, only : t_Grid
use State_mod, only : t_State

import :: t_SinusoidalWallLevelset

class(t_SinusoidalWallLevelset) :: this
integer, intent(in) :: mode
class(t_Grid), intent(in) :: grids(:)
class(t_State) :: states(:)

end subroutine updateSinusoidalWallLevelset

end interface

end module SinusoidalWallLevelset_mod
23 changes: 1 addition & 22 deletions include/State.f90
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ end function getNumberOfScalars
! Variables for immersed boundary method.
real(SCALAR_KIND), dimension(:,:), allocatable :: levelset, levelsetNormal!, indicatorFunction, &
!primitiveGridNorm, levelsetCurvature
real(SCALAR_KIND), dimension(:), allocatable :: wallShape, objectSpeed
real(SCALAR_KIND), dimension(:,:), allocatable :: objectVelocity
real(SCALAR_KIND) :: levelsetLoc, levelsetWidth, levelsetAmp, levelsetPeriod
real(SCALAR_KIND), dimension(:,:), allocatable :: ibmDissipation, nDotGradRho, uDotGradRho

Expand All @@ -82,8 +82,6 @@ end function getNumberOfScalars
procedure, pass :: computeTimeStepSize => computeStateTimeStepSize
procedure, pass :: addSources
procedure, pass :: updateIBMVariables
procedure, pass :: setupLevelset
procedure, pass :: updateLevelset

end type t_State

Expand Down Expand Up @@ -275,23 +273,4 @@ subroutine updateIBMVariables(this, mode, grid, simulationFlags)
end subroutine updateIBMVariables
end interface

interface
subroutine setupLevelset(this, grid)
use Grid_mod, only : t_Grid
import :: t_State
class(t_State) :: this
class(t_Grid), intent(in) :: grid
end subroutine setupLevelset
end interface

interface
subroutine updateLevelset(this, mode, grid)
use Grid_mod, only : t_Grid
import :: t_State
class(t_State) :: this
integer, intent(in) :: mode
class(t_Grid), intent(in) :: grid
end subroutine updateLevelset
end interface

end module State_mod
Loading

0 comments on commit ee7bcdc

Please sign in to comment.