Skip to content

Commit

Permalink
fix: ibm variables are incorporated into one file.
Browse files Browse the repository at this point in the history
fix: state update is included.
  • Loading branch information
dreamer2368 committed Jan 2, 2023
1 parent cfe5d75 commit 024e3fb
Showing 1 changed file with 61 additions and 6 deletions.
67 changes: 61 additions & 6 deletions utils/rhs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ subroutine saveRhs(region, filename)
! <<< Derived types >>>
use Region_mod, only : t_Region
use Patch_mod, only : t_Patch
use ImmersedBoundaryPatch_mod, only : t_ImmersedBoundaryPatch

! <<< Enumerations >>>
use State_enum, only : QOI_DUMMY_FUNCTION
Expand All @@ -144,7 +145,7 @@ subroutine saveRhs(region, filename)
! <<< Local variables >>>
integer, parameter :: wp = SCALAR_KIND
integer, save :: nDimensions = 0
integer :: i, j, p, localPatchSize
integer :: i, j, p, localPatchSize, idx, nIBMvars
logical :: savePatch
character(len = STRING_LENGTH) :: patchFile
type :: t_RhsInternal
Expand Down Expand Up @@ -180,6 +181,10 @@ subroutine saveRhs(region, filename)
end do
end if

do i = 1, size(region%states) !... update state
call region%states(i)%update(region%grids(i), region%simulationFlags, region%solverOptions)
end do

call region%computeRhs(FORWARD, region%timestep, 1)

do i = 1, size(region%states)
Expand Down Expand Up @@ -227,21 +232,71 @@ subroutine saveRhs(region, filename)
end if

if (getOption("enable_immersed_boundary", .false.)) then
idx = 0
nIBMvars = 2 + 2 * region%grids(1)%nDimensions + 2 + region%solverOptions%nUnknowns

! resize the data buffer.
do i = 1, size(data_)
deallocate(data_(i)%buffer)
allocate(data_(i)%buffer(region%grids(i)%nGridPoints, 1 + 2 * region%grids(i)%nDimensions))
allocate(data_(i)%buffer(region%grids(i)%nGridPoints, nIBMvars))
end do

do j = 1, size(region%states)
data_(j)%buffer(:, idx + 1) = region%states(j)%levelset(:, 1)
end do
idx = idx + 1

do j = 1, size(region%states)
data_(j)%buffer(:, idx + 1) = 0.0_wp
end do
if (allocated(region%patchFactories)) then
do p = 1, size(region%patchFactories)
call region%patchFactories(p)%connect(patch)
if (.not. associated(patch)) cycle
do j = 1, size(region%states)
if (patch%gridIndex /= region%grids(j)%index) cycle
select type (patch)
class is (t_ImmersedBoundaryPatch)
call patch%computePenaltyWeight(region%grids(j), region%states(j), &
data_(j)%buffer(:, idx + 1))
end select
end do
end do
end if
idx = idx + 1

do j = 1, size(region%states)
data_(j)%buffer(:, idx+1 : idx+region%grids(j)%nDimensions) = region%states(j)%levelsetNormal
end do
idx = idx + region%grids(1)%nDimensions

do j = 1, size(region%states)
data_(j)%buffer(:, idx+1 : idx+region%grids(j)%nDimensions) = region%states(j)%objectVelocity
end do
idx = idx + region%grids(1)%nDimensions

do j = 1, size(region%states)
data_(j)%buffer(:, idx + 1) = region%states(j)%nDotGradRho(:, 1)
data_(j)%buffer(:, idx + 2) = region%states(j)%uDotGradRho(:, 1)
end do
idx = idx + 2

do j = 1, size(region%states)
data_(j)%buffer(:, idx+1 : idx+region%solverOptions%nUnknowns) = region%states(j)%ibmDissipation
end do
idx = idx + region%solverOptions%nUnknowns

do j = 1, size(region%states)
data_(j)%buffer(:, 1) = region%states(j)%levelset(:, 1)
data_(j)%buffer(:, 2:region%grids(j)%nDimensions + 1) = region%states(j)%levelsetNormal
data_(j)%buffer(:, region%grids(j)%nDimensions + 2 : 2 * region%grids(j)%nDimensions + 1) = region%states(j)%objectVelocity
region%states(j)%dummyFunction => data_(j)%buffer
end do

write(patchFile, '(A)') trim(filename) // ".levelset.f"
write(patchFile, '(A)') trim(filename) // ".ibm_variables.f"
call region%saveData(QOI_DUMMY_FUNCTION, patchFile)
end if

do i = 1, size(data_)
nullify(data_(i)%buffer)
end do
SAFE_DEALLOCATE(data_)

end subroutine saveRhs

0 comments on commit 024e3fb

Please sign in to comment.