Skip to content

Commit 6707790

Browse files
arciyer123Krishnan Iyer
authored andcommitted
attempt fix for double precision with mpi support
1 parent 867a17f commit 6707790

File tree

5 files changed

+89
-86
lines changed

5 files changed

+89
-86
lines changed

src/common/m_phase_change.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ contains
247247

248248
! entropy
249249
sk(1:num_fluids) = cvs(1:num_fluids)*log((TS**gs_min(1:num_fluids)) &
250-
/((pS + ps_inf(1:num_fluids))**(gs_min(1:num_fluids) - 1.0_wp))) + qvps(1:num_fluids)
250+
/((pS + ps_inf(1:num_fluids))**(gs_min(1:num_fluids) - 1.0_wp))) + qvps(1:num_fluids)
251251

252252
! enthalpy
253253
hk(1:num_fluids) = gs_min(1:num_fluids)*cvs(1:num_fluids)*TS &

src/common/m_precision_select.f90

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
!>
2-
!! @file m_precision_select.f90
1+
!> @file m_precision_select.f90
32
!! @brief Contains module m_precision_select
43

54
!> @brief This file contains the definition of floating point used in MFC
@@ -10,14 +9,18 @@ module m_precision_select
109

1110
implicit none
1211

12+
! Define the available precision types
1313
integer, parameter :: single_precision = selected_real_kind(6, 37)
1414
integer, parameter :: double_precision = selected_real_kind(15, 307)
1515

16-
integer, parameter :: wp = double_precision
16+
! Set the working precision (wp) to single or double precision
17+
integer, parameter :: wp = double_precision ! Change to single_precision if needed
18+
1719
#ifdef MFC_MPI
18-
integer, parameter :: mpi_p = MPI_DOUBLE_PRECISION
20+
! Set mpi_p based on wp using the merge intrinsic function
21+
integer, parameter :: mpi_p = merge(MPI_DOUBLE_PRECISION, MPI_FLOAT, wp == double_precision)
1922
#else
20-
integer, parameter :: mpi_p = -100
23+
integer, parameter :: mpi_p = -100 ! Default value when MPI is not used
2124
#endif
2225

2326
end module m_precision_select

src/pre_process/m_patches.fpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ contains
663663
do j = 0, n
664664
do i = 0, m
665665
myr = sqrt((x_cc(i) - x_centroid)**2 &
666-
+ (y_cc(j) - y_centroid)**2)
666+
+ (y_cc(j) - y_centroid)**2)
667667

668668
if (myr <= radius + thickness/2._wp .and. &
669669
myr >= radius - thickness/2._wp .and. &
@@ -726,7 +726,7 @@ contains
726726
do j = 0, n
727727
do i = 0, m
728728
myr = sqrt((x_cc(i) - x_centroid)**2 &
729-
+ (y_cc(j) - y_centroid)**2)
729+
+ (y_cc(j) - y_centroid)**2)
730730

731731
if (myr <= radius + thickness/2._wp .and. &
732732
myr >= radius - thickness/2._wp .and. &
@@ -1054,8 +1054,8 @@ contains
10541054

10551055
if (patch_icpp(patch_id)%smoothen) then
10561056
eta = 5e-1_wp + 5e-1_wp*tanh(smooth_coeff/min(dx, dy) &
1057-
*(a*x_cc(i) + b*y_cc(j) + c) &
1058-
/sqrt(a**2 + b**2))
1057+
*(a*x_cc(i) + b*y_cc(j) + c) &
1058+
/sqrt(a**2 + b**2))
10591059
end if
10601060

10611061
if ((a*x_cc(i) + b*y_cc(j) + c >= 0._wp &
@@ -1949,10 +1949,10 @@ contains
19491949
19501950
if (patch_icpp(patch_id)%smoothen) then
19511951
eta = 5e-1_wp + 5e-1_wp*tanh(smooth_coeff/min(dx, dy, dz) &
1952-
*(a*x_cc(i) + &
1953-
b*cart_y + &
1954-
c*cart_z + d) &
1955-
/sqrt(a**2 + b**2 + c**2))
1952+
*(a*x_cc(i) + &
1953+
b*cart_y + &
1954+
c*cart_z + d) &
1955+
/sqrt(a**2 + b**2 + c**2))
19561956
end if
19571957
19581958
if ((a*x_cc(i) + b*cart_y + c*cart_z + d >= 0._wp &

src/simulation/m_bubbles.fpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ contains
140140
divu%sf(j, k, l) = 0._wp
141141
divu%sf(j, k, l) = &
142142
5e-1_wp/dx(j)*(q_prim_vf(contxe + idir)%sf(j + 1, k, l) - &
143-
q_prim_vf(contxe + idir)%sf(j - 1, k, l))
143+
q_prim_vf(contxe + idir)%sf(j - 1, k, l))
144144

145145
end do
146146
end do
@@ -155,7 +155,7 @@ contains
155155
do j = 0, m
156156
divu%sf(j, k, l) = divu%sf(j, k, l) + &
157157
5e-1_wp/dy(k)*(q_prim_vf(contxe + idir)%sf(j, k + 1, l) - &
158-
q_prim_vf(contxe + idir)%sf(j, k - 1, l))
158+
q_prim_vf(contxe + idir)%sf(j, k - 1, l))
159159

160160
end do
161161
end do
@@ -169,7 +169,7 @@ contains
169169
do j = 0, m
170170
divu%sf(j, k, l) = divu%sf(j, k, l) + &
171171
5e-1_wp/dz(l)*(q_prim_vf(contxe + idir)%sf(j, k, l + 1) - &
172-
q_prim_vf(contxe + idir)%sf(j, k, l - 1))
172+
q_prim_vf(contxe + idir)%sf(j, k, l - 1))
173173

174174
end do
175175
end do

0 commit comments

Comments
 (0)