Skip to content

Commit 08eb889

Browse files
Visualization Tutorial (#49)
1 parent 9f04c0f commit 08eb889

File tree

29 files changed

+738
-81
lines changed

29 files changed

+738
-81
lines changed

.github/workflows/mac.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
self:
1010
name: Mac Runner
1111
runs-on: macos-latest
12+
if: github.repository == 'Comp-Physics/RBC3D'
1213
continue-on-error: true
1314
steps:
1415
- name: Checkout

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ packages*
1616
traction
1717
build
1818
*.sbatch
19+
*/*/*/restart*
20+
examples/*/*.py

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ brew install gcc mpich gfortran pkg-config wget cmake
3030
./rbc.sh install-mac
3131
```
3232

33-
and then set these environment variables in your `~/.zshrc` or `~/.bashrc`. Note that `$HOME` will need to be replaced with the folder you cloned RBC3D in.
33+
and then from the RBC3D root directory, run these commands but replace `.zshrc` with where you store environment variables:
3434

3535
```shell
36-
export PETSC_DIR=$HOME/RBC3D/packages/petsc-3.19.6
37-
export PETSC_ARCH=arch-darwin-c-opt
36+
rootdir=`pwd`
37+
echo -e "export PETSC_DIR=$rootdir/packages/petsc-3.21.3 \nexport PETSC_ARCH=arch-darwin-c-opt" >> ~/.zshrc
3838
```
3939

4040
Then to execute and run a case, you can:
@@ -56,8 +56,7 @@ mpiexec -n 1 ../../build/case/minit
5656
mpiexec -n 2 ../../build/case/mtube
5757
```
5858

59-
To run a case with more cells and nodes, you should use a supercomputing cluster. Instructions on how to build RBC3D on a cluster are [available here](https://github.com/comp-physics/RBC3D/blob/master/install/readme.md).
60-
59+
To run a case with more cells and nodes, you should use a supercomputing cluster. Instructions on how to build RBC3D on a cluster are [available here](https://github.com/comp-physics/RBC3D/blob/master/docs/clusters.md).
6160

6261
### Papers that use RBC3D
6362

common/ModConf.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,11 @@ subroutine ReadConfig(fn)
249249
print *, 'refRad = ', refRadIN(1:nCellTypes)
250250

251251
read (funit, *) Deflate; print *, 'Deflate = ', Deflate
252-
!print *, 'before error'
252+
! print *, 'before error'
253253
read (funit, *) pGradTar(1); print *, 'pGradTar = ', pGradTar(1)
254254
read (funit, *) pGradTar(2); print *, 'pGradTar = ', pGradTar(2)
255255
read (funit, *) pGradTar(3); print *, 'pGradTar = ', pGradTar(3)
256-
!print *, 'after error'
256+
! print *, 'after error'
257257
read (funit, *) Nt; print *, 'Nt = ', Nt
258258
read (funit, *) Ts; print *, 'Ts = ', Ts
259259

common/ModDataStruct.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ module ModDataStruct
9292
!
9393
!======================================================================
9494
! Cell type
95-
! celltype -- 1 red cell ; 2 leukocyte ; 3 platelet
95+
! celltype -- 1 red cell ; 2 leukocyte ; 3 platelet
9696
!
9797
!======================================================================
9898
! Solid body modes

common/ModIO.F90

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,6 @@ subroutine ReadWallMesh(fn, wall)
553553
integer, allocatable :: connect(:, :)
554554
character(*), parameter :: func_name = "ReadWallMesh"
555555

556-
print *, "fn: ", trim(fn)
557-
558556
! Check whether the file exists
559557
ierr = NF90_OPEN(trim(fn), NF90_NOWRITE, ncid)
560558
if (ierr .ne. 0) then
@@ -806,20 +804,13 @@ subroutine ReadRestart(fn)
806804
! global parameters
807805
if (rootWorld) then
808806
write (*, *) 'Read restart file ', TRIM(fn)
809-
print *, 'error 0'
810807
open (restart_unit, file=trim(fn), form='unformatted', action='read')
811808

812-
print *, 'error 1'
813809
read (restart_unit) Lb
814810
iLb = 1./Lb
815-
print *, 'error 2'
816-
print *, 'z'
817811
read (restart_unit) Nt0
818-
print *, 'a'
819812
read (restart_unit) time0
820-
print *, 'b'
821813
read (restart_unit) vBkg
822-
print *, '0'
823814
write (*, *) 'Lb = ', Lb
824815
write (*, *) 'Nt0 = ', Nt0
825816
write (*, *) 'time0 = ', time0

common/ModPostProcess.F90

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ function CellFlowRate() result(flowrate)
103103
zc = 0.5*(minval(rbc%x(:, :, 3)) + maxval(rbc%x(:, :, 3)))
104104

105105
do ilon = 1, rbc%nlon
106-
do ilat = 1, rbc%nlat
107-
ds = rbc%detJ(ilat, ilon)*rbc%w(ilat)
108-
vn = dot_product(rbc%g(ilat, ilon, :), rbc%a3(ilat, ilon, :))
109-
flowrate = flowrate + (rbc%x(ilat, ilon, 3) - zc)*vn*ds
110-
end do ! ilat
106+
do ilat = 1, rbc%nlat
107+
ds = rbc%detJ(ilat, ilon)*rbc%w(ilat)
108+
vn = dot_product(rbc%g(ilat, ilon, :), rbc%a3(ilat, ilon, :))
109+
flowrate = flowrate + (rbc%x(ilat, ilon, 3) - zc)*vn*ds
110+
end do ! ilat
111111
end do ! ilon
112112
end do ! irbc
113113

@@ -134,12 +134,12 @@ subroutine ComputeParticleStress(tau)
134134
end do ! ii
135135

136136
do ilon = 1, rbc%nlon
137-
do ilat = 1, rbc%nlat
138-
x = rbc%x(ilat, ilon, :) - xc
139-
f = rbc%f(ilat, ilon, :)
140-
dS = rbc%w(ilat)*rbc%detJ(ilat, ilon)
141-
forall (ii=1:3, jj=1:3) tau(ii, jj) = tau(ii, jj) - dS*f(ii)*x(jj)
142-
end do ! ilat
137+
do ilat = 1, rbc%nlat
138+
x = rbc%x(ilat, ilon, :) - xc
139+
f = rbc%f(ilat, ilon, :)
140+
dS = rbc%w(ilat)*rbc%detJ(ilat, ilon)
141+
forall (ii=1:3, jj=1:3) tau(ii, jj) = tau(ii, jj) - dS*f(ii)*x(jj)
142+
end do ! ilat
143143
end do ! ilon
144144
end do ! irbc
145145

common/ModRbc.F90

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -423,38 +423,38 @@ subroutine RBC_ComputeGeometry(cell)
423423

424424
! Surface tangential and normals
425425
do ilon = 1, nlon
426-
do ilat = 1, nlat
427-
a1 = cell%a1(ilat, ilon, :)
428-
a2 = cell%a2(ilat, ilon, :)
426+
do ilat = 1, nlat
427+
a1 = cell%a1(ilat, ilon, :)
428+
a2 = cell%a2(ilat, ilon, :)
429429

430-
a(1, 1) = dot_product(a1, a1)
431-
a(1, 2) = dot_product(a1, a2)
432-
a(2, 1) = a(1, 2)
433-
a(2, 2) = dot_product(a2, a2)
430+
a(1, 1) = dot_product(a1, a1)
431+
a(1, 2) = dot_product(a1, a2)
432+
a(2, 1) = a(1, 2)
433+
a(2, 2) = dot_product(a2, a2)
434434

435-
detA = a(1, 1)*a(2, 2) - a(1, 2)*a(2, 1)
436-
iDetA = 1./detA
435+
detA = a(1, 1)*a(2, 2) - a(1, 2)*a(2, 1)
436+
iDetA = 1./detA
437437

438-
a_rcp(1, 1) = iDeta*a(2, 2)
439-
a_rcp(1, 2) = -iDeta*a(1, 2)
440-
a_rcp(2, 1) = -iDeta*a(2, 1)
441-
a_rcp(2, 2) = iDeta*a(1, 1)
438+
a_rcp(1, 1) = iDeta*a(2, 2)
439+
a_rcp(1, 2) = -iDeta*a(1, 2)
440+
a_rcp(2, 1) = -iDeta*a(2, 1)
441+
a_rcp(2, 2) = iDeta*a(1, 1)
442442

443-
a1_rcp = a_rcp(1, 1)*a1 + a_rcp(1, 2)*a2
444-
a2_rcp = a_rcp(2, 1)*a1 + a_rcp(2, 2)*a2
443+
a1_rcp = a_rcp(1, 1)*a1 + a_rcp(1, 2)*a2
444+
a2_rcp = a_rcp(2, 1)*a1 + a_rcp(2, 2)*a2
445445

446-
! Store results
447-
cell%a1_rcp(ilat, ilon, :) = a1_rcp
448-
cell%a2_rcp(ilat, ilon, :) = a2_rcp
446+
! Store results
447+
cell%a1_rcp(ilat, ilon, :) = a1_rcp
448+
cell%a2_rcp(ilat, ilon, :) = a2_rcp
449449

450-
cell%a(ilat, ilon, :, :) = a
451-
cell%a_rcp(ilat, ilon, :, :) = a_rcp
450+
cell%a(ilat, ilon, :, :) = a
451+
cell%a_rcp(ilat, ilon, :, :) = a_rcp
452452

453-
cell%detj(ilat, ilon) = sqrt(detA)/sin(cell%th(ilat))
453+
cell%detj(ilat, ilon) = sqrt(detA)/sin(cell%th(ilat))
454454

455-
a3 = CrossProd(a1, a2)
456-
cell%a3(ilat, ilon, :) = a3/NORM2(a3)
457-
end do ! ilat
455+
a3 = CrossProd(a1, a2)
456+
cell%a3(ilat, ilon, :) = a3/norm2(a3)
457+
end do ! ilat
458458
end do ! ilon
459459

460460
! Compute curvature tensor
@@ -920,22 +920,22 @@ subroutine Shell_ElasStrs(cell, cellRef, tau)
920920
nlon = cell%nlon
921921

922922
do ilat = 1, nlat
923-
do ilon = 1, nlon
924-
! V2 is the stretch tensor
925-
V2 = matmul(cell%a(ilat, ilon, :, :), cellRef%a_rcp(ilat, ilon, :, :))
923+
do ilon = 1, nlon
924+
! V2 is the stretch tensor
925+
V2 = matmul(cell%a(ilat, ilon, :, :), cellRef%a_rcp(ilat, ilon, :, :))
926926

927-
lbd1 = V2(1, 1) + V2(2, 2) - 2.0
928-
lbd2 = V2(1, 1)*V2(2, 2) - V2(1, 2)*V2(2, 1) - 1.0
929-
JS = sqrt(V2(1, 1)*V2(2, 2) - V2(1, 2)*V2(2, 1))
927+
lbd1 = V2(1, 1) + V2(2, 2) - 2.0
928+
lbd2 = V2(1, 1)*V2(2, 2) - V2(1, 2)*V2(2, 1) - 1.0
929+
JS = sqrt(V2(1, 1)*V2(2, 2) - V2(1, 2)*V2(2, 1))
930930

931-
! Take the covariant form of V2
932-
V2 = cellRef%a_rcp(ilat, ilon, :, :)
931+
! Take the covariant form of V2
932+
V2 = cellRef%a_rcp(ilat, ilon, :, :)
933933

934-
tau_tmp = 0.5*ES/JS*(lbd1 + 1.0)*V2 &
935-
+ 0.5*JS*(ED*lbd2 - ES)*cell%a_rcp(ilat, ilon, :, :)
934+
tau_tmp = 0.5*ES/JS*(lbd1 + 1.0)*V2 &
935+
+ 0.5*JS*(ED*lbd2 - ES)*cell%a_rcp(ilat, ilon, :, :)
936936

937-
tau(ilat, ilon, :, :) = tau_tmp
938-
end do ! ilon
937+
tau(ilat, ilon, :, :) = tau_tmp
938+
end do ! ilon
939939
end do ! ilat
940940

941941
end subroutine Shell_ElasStrs
@@ -957,12 +957,12 @@ subroutine Shell_Bend(cell, cellRef, bnd)
957957
nlon = cell%nlon
958958

959959
do ilat = 1, nlat
960-
do ilon = 1, nlon
961-
b = matmul(cell%a_rcp(ilat, ilon, :, :), cell%b(ilat, ilon, :, :))
962-
bref = matmul(cellRef%a_rcp(ilat, ilon, :, :), cellRef%b(ilat, ilon, :, :))
960+
do ilon = 1, nlon
961+
b = matmul(cell%a_rcp(ilat, ilon, :, :), cell%b(ilat, ilon, :, :))
962+
bref = matmul(cellRef%a_rcp(ilat, ilon, :, :), cellRef%b(ilat, ilon, :, :))
963963

964-
bnd(ilat, ilon, :, :) = -cell%EB*matmul(b - bref, cell%a_rcp(ilat, ilon, :, :))
965-
end do ! ilon
964+
bnd(ilat, ilon, :, :) = -cell%EB*matmul(b - bref, cell%a_rcp(ilat, ilon, :, :))
965+
end do ! ilon
966966
end do ! ilat
967967

968968
end subroutine Shell_Bend

common/ModVelSolver.F90

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ subroutine Solve_RBC_Vel(v)
7878
call MatShellSetOperation(mat_lhs, MATOP_MULT, MyMatMult, ierr)
7979

8080
call KSPCreate(PETSC_COMM_SELF, ksp_lhs, ierr)
81-
! call KSPSetOperators(ksp_lhs, mat_lhs, mat_lhs, SAME_NONZERO_PATTERN, ierr)
82-
call KSPSetOperators(ksp_lhs, mat_lhs, mat_lhs, ierr)
81+
call KSPSetOperators(ksp_lhs, mat_lhs, mat_lhs, ierr) ! call KSPSetOperators(ksp_lhs, mat_lhs, mat_lhs, SAME_NONZERO_PATTERN, ierr)
8382
call KSPSetType(ksp_lhs, KSPGMRES, ierr)
8483
call KSPGetPC(ksp_lhs, pc_lhs, ierr)
8584
call KSPSetInitialGuessNonzero(ksp_lhs, PETSC_TRUE, ierr) ! TRIAL

install/clusters.md renamed to docs/clusters.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ module load gcc/12.3.0 mvapich2/2.3.7-1 netcdf-c hdf5/1.14.1-2-mva2 intel-oneapi
3636
./rbc.sh install-ice
3737
```
3838

39-
Before you can run cmake, you must set these environment variables. You can place them in your `~/.bashrc`. If you didn't place `RBC3D` in your `$HOME` directory, then replace it with where you placed `RBC3D`.
39+
## Environment Variables
40+
41+
Before you can run cmake, you must set `PETSC_DIR` and `PETSC_ARCH` environment variables. You can place them in your `~/.bashrc`. This path depends on where you placed RBC3D. To get the path to where you placed it you can run this from your RBC3D root directory:
4042

4143
```shell
42-
export PETSC_DIR=$HOME/RBC3D/packages/petsc-3.19.6
43-
export PETSC_ARCH=arch-linux-c-opt
44+
rootdir=`pwd`
45+
echo -e "export PETSC_DIR=$rootdir/packages/petsc-3.21.3 \nexport PETSC_ARCH=arch-linux-c-opt" >> ~/.bashrc
4446
```
4547

48+
## Running an Example Case
49+
4650
Then to execute and run a case, you can:
4751
```shell
4852
mkdir build

0 commit comments

Comments
 (0)