Skip to content

Commit

Permalink
Merge pull request #324 from ludwig-cf/feature-323-cell-list
Browse files Browse the repository at this point in the history
Relax cell list constraint for ellipsoids
  • Loading branch information
kevinstratford authored Oct 21, 2024
2 parents 3d5f18e + 0d3c218 commit 517a3f0
Show file tree
Hide file tree
Showing 3 changed files with 280 additions and 15 deletions.
43 changes: 28 additions & 15 deletions src/colloids_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,17 +1202,26 @@ int angle_cosine_init(pe_t * pe, cs_t * cs, rt_t * rt, interact_t * interact) {
* 3) ncell >= 2 must have at least two cells to separate
* 'left-going' and 'right-going' communications.
*
* There are some edge cases where we can relax these constraints:
*
* a) A direction which is non-periodic (eg., has walls)
* and is not decomposed (mpisz == 1) will have no message passing.
* In such a case, (1) and (2) may be ignored, and (3) is relaxed to
* ncell >= 1. This may be useful for systems which are "narrow" (cf. a0).
*
*****************************************************************************/

int colloids_init_halo_range_check(pe_t * pe, cs_t * cs,
colloids_info_t * cinfo) {

int ifail = 0;
int ncolloid;
int ncell[3];
int nlocal[3];
int ncolloid = 0;
int ncell[3] = {0};
int nlocal[3] = {0};
int nhalo = 1; /* Always, for purpose of BBL. */

int nar[3] = {0}; /* See point (a) above */

double a0max = 0.0; /* Maximum colloid a0 present */
double lcell[3];

Expand All @@ -1228,23 +1237,27 @@ int colloids_init_halo_range_check(pe_t * pe, cs_t * cs,

colloids_info_a0max(cinfo, &a0max);

if (2.0*a0max >= 1.0*(nlocal[X] - nhalo)) ifail = 1;
if (2.0*a0max >= 1.0*(nlocal[Y] - nhalo)) ifail = 1;
if (2.0*a0max >= 1.0*(nlocal[Z] - nhalo)) ifail = 1;
if (cs->param->periodic[X] == 0 && cs->param->mpi_cartsz[X] == 1) nar[X] = 1;
if (cs->param->periodic[Y] == 0 && cs->param->mpi_cartsz[Y] == 1) nar[Y] = 1;
if (cs->param->periodic[Z] == 0 && cs->param->mpi_cartsz[Z] == 1) nar[Z] = 1;

if (nar[X] == 0 && (2.0*a0max >= 1.0*(nlocal[X] - nhalo))) ifail = 1;
if (nar[Y] == 0 && (2.0*a0max >= 1.0*(nlocal[Y] - nhalo))) ifail = 1;
if (nar[Z] == 0 && (2.0*a0max >= 1.0*(nlocal[Z] - nhalo))) ifail = 1;
if (ifail == 1) {
pe_fatal(pe, "Particle diameter larger than (nlocal - 1) domain size\n");
}

if (lcell[X] <= a0max) ifail = 1;
if (lcell[Y] <= a0max) ifail = 1;
if (lcell[Z] <= a0max) ifail = 1;
if (nar[X] == 0 && (lcell[X] <= a0max)) ifail = 1;
if (nar[Y] == 0 && (lcell[Y] <= a0max)) ifail = 1;
if (nar[Z] == 0 && (lcell[Z] <= a0max)) ifail = 1;
if (ifail == 1) {
pe_fatal(pe, "Particle a0 > cell width breaks BBL message passing\n");
}

if (ncell[X] < 2) ifail = 1;
if (ncell[Y] < 2) ifail = 1;
if (ncell[Z] < 2) ifail = 1;
if (ncell[X] < (2 - nar[X])) ifail = 1;
if (ncell[Y] < (2 - nar[Y])) ifail = 1;
if (ncell[Z] < (2 - nar[Z])) ifail = 1;

if (ifail == 1) {
pe_fatal(pe, "Must have two cells minimum\n");
Expand All @@ -1254,9 +1267,9 @@ int colloids_init_halo_range_check(pe_t * pe, cs_t * cs,

cs_nhalo(cs, &nhalo);

if (lcell[X] < (a0max + nhalo - 0.5)) ifail = 1;
if (lcell[Y] < (a0max + nhalo - 0.5)) ifail = 1;
if (lcell[Z] < (a0max + nhalo - 0.5)) ifail = 1;
if (nar[X] == 0 && (lcell[X] < (a0max + nhalo - 0.5))) ifail = 1;
if (nar[Y] == 0 && (lcell[Y] < (a0max + nhalo - 0.5))) ifail = 1;
if (nar[Z] == 0 && (lcell[Z] < (a0max + nhalo - 0.5))) ifail = 1;

if (ifail == 1) {
pe_fatal(pe, "Must have cell width > a0_max + nhalo\n");
Expand Down
94 changes: 94 additions & 0 deletions tests/regression/d3q27/serial-elip-s10.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
##############################################################################
#
# Colloid simple configuration output
#
##############################################################################

N_start 0
N_cycles 10

##############################################################################
#
# System and MPI
#
##############################################################################

size 128_18_18
periodicity 1_0_0

##############################################################################
#
# Fluid parameters
#
##############################################################################

viscosity 0.1
fluid_rho0 1.0

##############################################################################
#
# Free energy parameters
#
###############################################################################

free_energy none

###############################################################################
#
# Colloid parameters
#
###############################################################################

colloid_init input_one
colloid_one_shape ellipsoid
colloid_one_elabc 9.562082_4.996656_4.996656
colloid_one_euler 0.0_0.0_0.0
colloid_one_r 64.5_9.5_9.5

###############################################################################
#
# Colloid-colloid soft-sphere potential parameters
# The soft sphere is always needed
#
###############################################################################


colloid_gravity 0.005_0.0_0.0

###############################################################################
#
# Walls / boundaries
#
###############################################################################

boundary_walls 0_1_1

###############################################################################
#
# Output frequency and type
#
###############################################################################

default_io_mode mpiio
default_io_format binary
freq_statistics 10
config_at_end no

##############################################################################
#
# colloid i/o
#
##############################################################################

colloid_io_freq 1000
colloid_io_format_output ASCII

###############################################################################
#
# Miscellaneous
#
# random_seed +ve integer is the random number generator seed
#
###############################################################################

random_seed 8361435
158 changes: 158 additions & 0 deletions tests/regression/d3q27/serial-elip-s10.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
Welcome to: Ludwig v0.22.0 (Serial version running on 1 process)
Git commit: 9255199534dfc86c44c98ff14cfb3dfa09108af5

Start time: Tue Oct 1 10:00:36 2024

Compiler:
name: Gnu 14.1.0
version-string: 14.1.0
options: -O2 -g -Wall -Werror

Note assertions via standard C assert() are on.

Target thread model: OpenMP.
OpenMP threads: 1; maximum number of threads: 11.

Read 21 user parameters from input

No free energy selected

System details
--------------
System size: 128 18 18
Decomposition: 1 1 1
Local domain: 128 18 18
Periodic: 1 0 0
Halo nhalo: 1
Reorder: true
Initialised: 1

System properties
----------------
Mean fluid density: 1.00000e+00
Shear viscosity 1.00000e-01
Bulk viscosity 1.00000e-01
Temperature 0.00000e+00
External body force density 0.00000e+00 0.00000e+00 0.00000e+00
External E-field amplitude 0.00000e+00 0.00000e+00 0.00000e+00
External E-field frequency 0.00000e+00
External magnetic field 0.00000e+00 0.00000e+00 0.00000e+00

Lattice Boltzmann distributions
-------------------------------
Model: d3q27
SIMD vector len: 1
Number of sets: 1
Halo type: lb_halo_target (full halo)
Input format: binary
Output format: binary
I/O grid: 1 1 1

Lattice Boltzmann collision
---------------------------
Relaxation time scheme: M10
Hydrodynamic modes: on
Ghost modes: on
Isothermal fluctuations: off
Shear relaxation time: 8.00000e-01
Bulk relaxation time: 8.00000e-01
Ghost relaxation time: 1.00000e+00
[User ] Random number seed: 8361435

Hydrodynamics
-------------
Hydrodynamics: on

Boundary walls
--------------
Boundary walls: - Y Z
Boundary speed u_x (bottom): 0.0000000e+00
Boundary speed u_x (top): 0.0000000e+00
Boundary normal lubrication rc: 0.0000000e+00
Wall boundary links allocated: 81408
Memory (total, bytes): 1302528
Boundary shear initialise: 0

Colloid information
-------------------

Colloid I/O settings
--------------------
Decomposition: 1 1 1
Number of files: 1
Input format: ascii
Output format: ascii
Single file read flag: 0

Requested one colloid via input:
colloid_one ellipsoid
colloid_one_r 6.4500000e+01 9.5000000e+00 9.5000000e+00
colloid_one_elabc 9.5620820e+00 4.9966560e+00 4.9966560e+00
colloid_one_euler 0.0000000e+00 0.0000000e+00 0.0000000e+00

Initialised 1 colloid

Colloid cell list information
-----------------------------
Input radius maximum: 9.5620820e+00
Final cell list: 12 1 1
Final cell lengths: 1.0666667e+01 1.8000000e+01 1.8000000e+01

Sedimentation force on: yes
Sedimentation force: 5.0000000e-03 0.0000000e+00 0.0000000e+00

Initial conditions.

Scalars - total mean variance min max
[rho] 40464.00 1.00000000000 2.2204460e-16 1.00000000000 1.00000000000

Momentum - x y z
[total ] 0.0000000e+00 0.0000000e+00 0.0000000e+00
[fluid ] 0.0000000e+00 0.0000000e+00 0.0000000e+00
[colloids] 0.0000000e+00 0.0000000e+00 0.0000000e+00
[walls ] 0.0000000e+00 0.0000000e+00 0.0000000e+00

Starting time step loop.

Particle statistics:

Colloid velocities - x y z
[minimum ] 2.6153937e-05 -5.3604951e-18 1.8203251e-18
[maximum ] 2.6153937e-05 -5.3604951e-18 1.8203251e-18

Scalars - total mean variance min max
[rho] 40464.00 1.00000000000 7.4389384e-12 0.99997187102 1.00002812813

Momentum - x y z
[total ] 6.2665151e-14 8.8029209e-14 -3.2492556e-14
[fluid ] -1.9760295e-02 -1.1450476e-13 -4.4833668e-13
[colloids] 2.8251562e-02 -3.2562774e-15 2.3560458e-16
[walls ] -8.4912674e-03 2.0579025e-13 4.1560852e-13

Velocity - x y z
[minimum ] -1.9016983e-06 -9.0171214e-06 -9.0171214e-06
[maximum ] 2.4698222e-05 9.0171214e-06 9.0171214e-06

Completed cycle 10

Timer resolution: 1e-06 second

Timer statistics
Section: tmin tmax total
Total: 0.499 0.499 0.499 0.498647 (1 call)
Time step loop: 0.045 0.058 0.461 0.046146 (10 calls)
Propagation: 0.006 0.006 0.059 0.005870 (10 calls)
Propagtn (krnl) : 0.006 0.006 0.059 0.005869 (10 calls)
Collision: 0.029 0.030 0.293 0.029312 (10 calls)
Collision (krnl) : 0.029 0.030 0.293 0.029310 (10 calls)
Lattice halos: 0.001 0.002 0.026 0.001299 (20 calls)
phi gradients: 0.000 0.000 0.000 0.000000 (10 calls)
Forces: 0.000 0.000 0.001 0.000091 (10 calls)
Rebuild: 0.001 0.001 0.008 0.000846 (10 calls)
BBL: 0.006 0.006 0.056 0.005586 (10 calls)
Particle halos: 0.000 0.000 0.000 0.000003 (10 calls)
Force calculation: 0.000 0.000 0.000 0.000000 (10 calls)
phi update: 0.000 0.000 0.000 0.000000 (10 calls)
Diagnostics / output: 0.000 0.013 0.013 0.001299 (10 calls)
End time: Tue Oct 1 10:00:36 2024
Ludwig finished normally.

0 comments on commit 517a3f0

Please sign in to comment.