# mesh refinement

Submitted by mikekaff on Mon, 02/08/2016 - 11:59

Hello to everyone.
I have been trying to modify the twoSpheresGlowinski tutorial from CFDEM in order to simulate a coupled flow (sedimentation) of particles (~400μm diameter) into a non Newtonian fluid.
My main problem seams to be that no cells are selected to be refined and Courant number increases as the steps progress.
These is the log output of the 7th step where it cruses.

Selected 0 cells for refinement out of 8000.
Selected 0 split points out of a possible 0.
Courant Number mean: 1.78356e+41 max: 2.46448e+43

What do I have to change???

### Forums:

bnaar | Tue, 02/23/2016 - 12:41

### Decrease Courant number << 1

Dear,

The courant number (Co) defines the amount of cells, 1 cell can travel in 1 timestep. This must not be larger than 1 as this yields large errors in your final simulation. See: https://en.wikipedia.org/wiki/Courant%E2%80%93Friedrichs%E2%80%93Lewy_co....

Hence, your courant number should always be below 1. And for the mesh refinement to be activated you have to consider courant numbers on the order of 0.1 (or smaller). This decrease is caused by the size of the mesh refinement cells which locally decreases the size of the cell tremendously (Hence, Co increases locally).

Thus, decrease Co by increasing cell size or decreasing velocity or the time step.

If you are struggling with your timesteps becoming too small, consider a full implicit time scheme if that can work for your simulation.

Good luck!

alice | Tue, 02/23/2016 - 15:59

### Hello,

Hello,
from the provided information it's a little hard to tell... The huge Courant number just indicates that the calculation is instable.
Does each of your particles cover several mesh cells at a time?
Cheers,
Alice

heliana60 | Tue, 08/15/2017 - 01:50

### twpSpheresGlowinskiMPI cfdemSolverIB crashes

Hey there,

I have been using CFDEM for a while and I am very grateful for your great work. I used a version for at least a year CFDEM-3.0.x based on OF-3-0-x and worked really nice, I could adapt a viscoelastic solver that uses an Oldroyd-B model among others like it is already set up in OpenFOAM-ext for an IB (visco) solver. I really want to use these results in my PhD thesis :)
Anyways, I installed recently the "new" version in a new computer and problems arose ! After compilation maneuvers I tried to run cfdemSolverIB (which is a bit different from the previous one like some changes in the interFace definition etc, ) but when I run the twoSpheresGlowinskiMPI tutorial my calculation crashes when the particles touch. The Courant number goes really high together with the continuity errors . I have been trying modifying the solver, check the pisoControls, among others ideas, but this tutorial ran just fine in the previous set up and version I have installed (which was CFDEM-3.0x) .

The crash looks like this: (thank you for the fun messages every time it crashes! I must travel to Austria and try the delicious cake you suggest :P)

Time = 0.3363

Selected 3 cells for refinement out of 5876.
Refined from 5876 to 5897 cells.
Selected 0 split points out of a possible 223.
Courant Number mean: 0.0125061 max: 9.81054
- evolve()

timeStepFraction() = 2
Starting up LIGGGHTS
Executing command: 'run 10 '
run 10
Setting up run at Tue Aug 15 01:27:25 2017

Memory usage per processor = 53.8006 Mbytes
Step Atoms KinEng rke Volume
11201 2 0.11293174 11409.344 4
CFD Coupling established at step 11210
11211 2 0.43219689 182554.51 4
Loop time of 6.17504e-05 on 4 procs for 10 steps with 2 atoms, finish time Tue Aug 15 01:27:25 2017

Pair time (%) = 3.45707e-06 (5.59846)
Neigh time (%) = 0 (0)
Comm time (%) = 1.64509e-05 (26.6409)
Outpt time (%) = 8.58307e-06 (13.8996)
Other time (%) = 3.32594e-05 (53.861)

Nlocal: 0.5 ave 2 max 0 min
Histogram: 3 0 0 0 0 0 0 0 0 1
Nghost: 1.5 ave 2 max 0 min
Histogram: 1 0 0 0 0 0 0 0 0 3
Neighs: 0.25 ave 1 max 0 min
Histogram: 3 0 0 0 0 0 0 0 0 1

Total # of neighbors = 1
Ave neighs/atom = 0.5
Neighbor list builds = 0
Dangerous builds = 0
LIGGGHTS finished
nr particles = 2
evolve done.
DILUPBiCG: Solving for Ux, Initial residual = 0.339419, Final residual = 6.95945e-11, No Iterations 46
DILUPBiCG: Solving for Uy, Initial residual = 0.339655, Final residual = 5.60475e-11, No Iterations 46
DILUPBiCG: Solving for Uz, Initial residual = 0.447987, Final residual = 2.96608e-11, No Iterations 46
DICPCG: Solving for p, Initial residual = 0.711319, Final residual = 5.57775e-11, No Iterations 89
time step continuity errors : sum local = 7.63438e-13, global = 1.95612e-20, cumulative = -5.31281e-17
DICPCG: Solving for p, Initial residual = 0.260922, Final residual = 7.32849e-11, No Iterations 86
time step continuity errors : sum local = 1.41968e-12, global = 2.1224e-19, cumulative = -5.29158e-17
DICPCG: Solving for p, Initial residual = 0.295131, Final residual = 9.96896e-11, No Iterations 86
time step continuity errors : sum local = 2.12998e-12, global = 6.54588e-20, cumulative = -5.28504e-17
DICPCG: Solving for p, Initial residual = 0.290832, Final residual = 9.69267e-11, No Iterations 82
time step continuity errors : sum local = 2.6116e-12, global = 3.79371e-20, cumulative = -5.28124e-17
particleCloud.calcVelocityCorrection()
DICPCG: Solving for phiIB, Initial residual = 0.678288, Final residual = 8.95034e-11, No Iterations 71
ExecutionTime = 80.54 s ClockTime = 81 s

Time = 0.3366

Selected 4 cells for refinement out of 5897.
Refined from 5897 to 5925 cells.
Selected 0 split points out of a possible 227.
Courant Number mean: 0.0485593 max: 76.6674
- evolve()

timeStepFraction() = 2
Starting up LIGGGHTS
Executing command: 'run 10 '
run 10
Setting up run at Tue Aug 15 01:27:25 2017

Memory usage per processor = 53.8006 Mbytes
Step Atoms KinEng rke Volume
11211 2 0.43219689 182554.51 4
CFD Coupling established at step 11220
11221 2 4.9079002 2920892.1 4
Loop time of 5.96046e-05 on 4 procs for 10 steps with 2 atoms, finish time Tue Aug 15 01:27:25 2017

Pair time (%) = 2.74181e-06 (4.6)
Neigh time (%) = 0 (0)
Comm time (%) = 1.40667e-05 (23.6)
Outpt time (%) = 8.58307e-06 (14.4)
Other time (%) = 3.42131e-05 (57.4)

Nlocal: 0.5 ave 2 max 0 min
Histogram: 3 0 0 0 0 0 0 0 0 1
Nghost: 1.5 ave 2 max 0 min
Histogram: 1 0 0 0 0 0 0 0 0 3
Neighs: 0.25 ave 1 max 0 min
Histogram: 3 0 0 0 0 0 0 0 0 1

Total # of neighbors = 1
Ave neighs/atom = 0.5
Neighbor list builds = 0
Dangerous builds = 0
LIGGGHTS finished
nr particles = 2
evolve done.
DILUPBiCG: Solving for Ux, Initial residual = 0.789654, Final residual = 3.98729e-11, No Iterations 147
DILUPBiCG: Solving for Uy, Initial residual = 0.789299, Final residual = 8.63958e-11, No Iterations 141
DILUPBiCG: Solving for Uz, Initial residual = 0.755203, Final residual = 5.20985e-11, No Iterations 127
DICPCG: Solving for p, Initial residual = 0.700981, Final residual = 8.38121e-11, No Iterations 88
time step continuity errors : sum local = 3.69652e-12, global = 6.69686e-19, cumulative = -5.21427e-17
DICPCG: Solving for p, Initial residual = 0.483124, Final residual = 6.58846e-11, No Iterations 87
time step continuity errors : sum local = 4.91524e-12, global = 3.73669e-19, cumulative = -5.17691e-17
DICPCG: Solving for p, Initial residual = 0.77391, Final residual = 7.19757e-11, No Iterations 88
time step continuity errors : sum local = 1.98073e-11, global = -2.98613e-18, cumulative = -5.47552e-17
DICPCG: Solving for p, Initial residual = 0.866634, Final residual = 7.74208e-11, No Iterations 87
time step continuity errors : sum local = 1.40702e-10, global = -2.35664e-19, cumulative = -5.49909e-17
particleCloud.calcVelocityCorrection()
DICPCG: Solving for phiIB, Initial residual = 0.885582, Final residual = 6.1705e-11, No Iterations 72
ExecutionTime = 80.66 s ClockTime = 81 s

Time = 0.3369

Selected 14 cells for refinement out of 5925.
Refined from 5925 to 6023 cells.
Selected 0 split points out of a possible 241.
Courant Number mean: 2.18693 max: 15038.4
- evolve()

timeStepFraction() = 2
Starting up LIGGGHTS
Executing command: 'run 10 '
run 10
Setting up run at Tue Aug 15 01:27:25 2017

Memory usage per processor = 53.8006 Mbytes
Step Atoms KinEng rke Volume
11221 2 4.9079002 2920892.1 4
CFD Coupling established at step 11230
11231 2 2.8633692 46734354 4
Loop time of 6.29425e-05 on 4 procs for 10 steps with 2 atoms, finish time Tue Aug 15 01:27:25 2017

Pair time (%) = 3.15905e-06 (5.01894)
Neigh time (%) = 0 (0)
Comm time (%) = 1.44243e-05 (22.9167)
Outpt time (%) = 9.35793e-06 (14.8674)
Other time (%) = 3.60012e-05 (57.197)

Nlocal: 0.5 ave 2 max 0 min
Histogram: 3 0 0 0 0 0 0 0 0 1
Nghost: 1.5 ave 2 max 0 min
Histogram: 1 0 0 0 0 0 0 0 0 3
Neighs: 0.25 ave 1 max 0 min
Histogram: 3 0 0 0 0 0 0 0 0 1

Total # of neighbors = 1
Ave neighs/atom = 0.5
Neighbor list builds = 0
Dangerous builds = 0
LIGGGHTS finished
nr particles = 2
evolve done.
DILUPBiCG: Solving for Ux, Initial residual = 0.962526, Final residual = 2.5239, No Iterations 1001
DILUPBiCG: Solving for Uy, Initial residual = 0.957169, Final residual = 5.09585, No Iterations 1001
DILUPBiCG: Solving for Uz, Initial residual = 0.990206, Final residual = 0.66619, No Iterations 1001
DICPCG: Solving for p, Initial residual = 0.993201, Final residual = 7.77396e-11, No Iterations 142
time step continuity errors : sum local = 1.37688e-08, global = -1.68675e-15, cumulative = -1.74174e-15
DICPCG: Solving for p, Initial residual = 0.999117, Final residual = 8.73312e-11, No Iterations 138
time step continuity errors : sum local = 1.71179e-05, global = 1.15841e-12, cumulative = 1.15667e-12
DICPCG: Solving for p, Initial residual = 0.999241, Final residual = 8.7411e-11, No Iterations 139
time step continuity errors : sum local = 0.0241391, global = 2.38806e-09, cumulative = 2.38922e-09
DICPCG: Solving for p, Initial residual = 0.999813, Final residual = 8.83391e-11, No Iterations 142
time step continuity errors : sum local = 35.5236, global = -2.54597e-06, cumulative = -2.54358e-06
particleCloud.calcVelocityCorrection()
DICPCG: Solving for phiIB, Initial residual = 1, Final residual = 6.73849e-11, No Iterations 75
ExecutionTime = 80.98 s ClockTime = 82 s

Time = 0.3372

Selected 3 cells for refinement out of 6023.
Refined from 6023 to 6044 cells.
Selected 0 split points out of a possible 244.
Courant Number mean: 6.198e+11 max: 1.13163e+16
- evolve()

timeStepFraction() = 2
Starting up LIGGGHTS
Executing command: 'run 10 '
run 10
Setting up run at Tue Aug 15 01:27:26 2017

Memory usage per processor = 53.8006 Mbytes
Step Atoms KinEng rke Volume
11231 2 2.8633692 46734354 4
CFD Coupling established at step 11240
11241 2 26481.031 7.4774998e+08 4
Loop time of 0.0180469 on 4 procs for 10 steps with 2 atoms, finish time Tue Aug 15 01:27:26 2017

Pair time (%) = 7.7486e-06 (0.042936)
Neigh time (%) = 0.0151043 (83.6949)
Comm time (%) = 5.44786e-05 (0.301873)
Outpt time (%) = 1.52588e-05 (0.084551)
Other time (%) = 0.00286508 (15.8758)

Nlocal: 0.5 ave 1 max 0 min
Histogram: 2 0 0 0 0 0 0 0 0 2
Nghost: 1.5 ave 2 max 1 min
Histogram: 2 0 0 0 0 0 0 0 0 2
Neighs: 0.5 ave 1 max 0 min
Histogram: 2 0 0 0 0 0 0 0 0 2

Total # of neighbors = 2
Ave neighs/atom = 1
Neighbor list builds = 2
Dangerous builds = 0
LIGGGHTS finished
nr particles = 2
evolve done.
DILUPBiCG: Solving for Ux, Initial residual = 0.99986, Final residual = 1.05415, No Iterations 1001
DILUPBiCG: Solving for Uy, Initial residual = 0.999879, Final residual = 1.00308, No Iterations 1001
DILUPBiCG: Solving for Uz, Initial residual = 0.999966, Final residual = 4.47811, No Iterations 1001
DICPCG: Solving for p, Initial residual = 1, Final residual = 36.7754, No Iterations 1001
time step continuity errors : sum local = 1.60544e+23, global = 1.41734e+07, cumulative = 1.41734e+07
DICPCG: Solving for p, Initial residual = 1, Final residual = 2.78352, No Iterations 1001
time step continuity errors : sum local = 9.09426e+33, global = -9.73988e+17, cumulative = -9.73988e+17
DICPCG: Solving for p, Initial residual = 1, Final residual = 0.540189, No Iterations 1001
time step continuity errors : sum local = 3.81539e+44, global = -1.293e+28, cumulative = -1.293e+28
DICPCG: Solving for p, Initial residual = 1, Final residual = 6.62567, No Iterations 1001
time step continuity errors : sum local = 1.51226e+56, global = 2.09069e+40, cumulative = 2.09069e+40
particleCloud.calcVelocityCorrection()
DICPCG: Solving for phiIB, Initial residual = 1, Final residual = 7.06757e-11, No Iterations 72
ExecutionTime = 81.47 s ClockTime = 82 s

Time = 0.3375

Selected 141 cells for refinement out of 6044.
Refined from 6044 to 7031 cells.
Selected 236 split points out of a possible 382.
Unrefined from 7031 to 5379 cells.
Courant Number mean: 5.7953e+56 max: 8.04534e+59
- evolve()

timeStepFraction() = 2
Starting up LIGGGHTS
Executing command: 'run 10 '
run 10
Setting up run at Tue Aug 15 01:27:26 2017

Memory usage per processor = 53.8006 Mbytes
Step Atoms KinEng rke Volume
11241 2 26481.031 7.4774998e+08 4
CFD Coupling established at step 11250
11251 0 0 0 4
Loop time of 0.00748038 on 4 procs for 10 steps with 0 atoms, finish time Tue Aug 15 01:27:26 2017

Pair time (%) = 6.13928e-06 (0.0820717)
Neigh time (%) = 0.00731641 (97.808)
Comm time (%) = 2.59876e-05 (0.34741)
Outpt time (%) = 2.38419e-05 (0.318725)
Other time (%) = 0.000108004 (1.44382)

Nlocal: 0 ave 0 max 0 min
Histogram: 4 0 0 0 0 0 0 0 0 0
Nghost: 0 ave 0 max 0 min
Histogram: 4 0 0 0 0 0 0 0 0 0
Neighs: 0 ave 0 max 0 min
Histogram: 4 0 0 0 0 0 0 0 0 0

Total # of neighbors = 0
Neighbor list builds = 1
Dangerous builds = 1
LIGGGHTS finished
Foam::cfdemCloudIB::reAllocArrays()
nr particles = 0
evolve done.
DILUPBiCG: Solving for Ux, Initial residual = 0.946109, Final residual = 412355, No Iterations 1001
DILUPBiCG: Solving for Uy, Initial residual = 0.94914, Final residual = 3504.95, No Iterations 1001
DILUPBiCG: Solving for Uz, Initial residual = 0.967061, Final residual = 19384.3, No Iterations 1001
DICPCG: Solving for p, Initial residual = 1, Final residual = 8.53949e-17, No Iterations 8
time step continuity errors : sum local = 4.29397e+96, global = 0, cumulative = 2.09069e+40
DICPCG: Solving for p, Initial residual = 1, Final residual = 3.67459e-16, No Iterations 8
time step continuity errors : sum local = 4.6138e+104, global = 0, cumulative = 2.09069e+40
DICPCG: Solving for p, Initial residual = 1, Final residual = 9.95604e-11, No Iterations 8
time step continuity errors : sum local = 1.1523e+119, global = 0, cumulative = 2.09069e+40
DICPCG: Solving for p, Initial residual = 1, Final residual = 9.15517e-12, No Iterations 9
time step continuity errors : sum local = 3.85153e+128, global = 0, cumulative = 2.09069e+40
particleCloud.calcVelocityCorrection()
DICPCG: Solving for phiIB, Initial residual = 1, Final residual = 8.15061e-11, No Iterations 73
ExecutionTime = 81.87 s ClockTime = 83 s

Time = 0.3378

Selected 0 cells for refinement out of 5379.
Selected 191 split points out of a possible 191.
Unrefined from 5379 to 4042 cells.
Courant Number mean: 6.49306e+134 max: 9.80294e+136
- evolve()

timeStepFraction() = 2
Starting up LIGGGHTS
Executing command: 'run 10 '
run 10
Setting up run at Tue Aug 15 01:27:27 2017

ERROR: Atom sorting has bin size = 0.0 (../atom.cpp:1420)

Tip of the day: If coffee doesn't work, try chocolate. For this specific error, DCS Computing recommends Austria窶冱
most famous cake. Check https://www.sacher.com/enﾐ (../atom.cpp:1420)

I really dont know where this is coming from ???

Heliana

heliana60 | Fri, 08/18/2017 - 14:25

### Code crashes when particles touch

Dear Alice,

After running twoSpheresGlowinski tutorial when using the cfdemSolverIB the calculation crashes/stops/diverges(?) when particles touch. I am using the new CFDEM installation and I am not sure what the problem is or why this happens since I never encounter this crash in previous versions when running same cases when usually particles touch and tumble or the like. Do you have any idea why this could be?

I would really appreciate your help,

Heliana

alice | Tue, 08/22/2017 - 15:13

### Hello Heliana,

Hello Heliana,
after having a closer look onto the code, we figured that with the current release in July a small bug with a big effect sneaked in. It can easily be fixed and we'll take care of that soon. However, in the meanwhile the very short fix so you can proceed with you work:
Just remove or comment line 125 in the file src/lagrangian/cfdemParticle/derived/cfdemCloudIB/cfdemCloudIB.C:
dataExchangeM().getData("torque","vector-atom",DEMTorques_);
After re-compiling the sources again, the issue should be fixed.
Thanks for pointing that matter out and sorry for the inconveniences!
Cheers,
Alice

heliana60 | Tue, 08/22/2017 - 16:00

### Solved

Thank you Alice, it worked! I just commented that line and recompiled src and solvers and no crash :)
Heliana

Mahya | Wed, 09/11/2019 - 10:32

### Problem with Hexahedral Mesh

Hi Alice,
I am using the latest version, and there are still some problems with solver IB. Using hexahedral mesh (with mesh refinement), the solution diverges. As I turn off the mesh refinement option, the Courant number increases to >1 after few steps and remains so (1

Mahya | Wed, 09/11/2019 - 10:42

### Problem with Hexahedral Mesh

Hi Alice,
I am using the latest version, and there are still some problems with solver IB. Using hexahedral mesh (with mesh refinement), the solution diverges. As I turn off the mesh refinement option, the Courant number increases to >1 after few steps and remains so (co: 1-2). Decreasing delta t doesn't make it any better. However, there is no problem with tetrahedral mesh. Therefore, I guessed the problem would be solved with the refinement turned off, but it didn't work.
Sorry I posted this twice. My reply wasn't saved completely.
Thank you,
Mahya

Arghavani | Tue, 11/12/2019 - 13:05

### cfdemSolverIB

Hi everyone,

i am using cfdemSolverIB as its the tutorials and I have stl file in my physical domain therefore I used snappyhexmesh but the point is moving mesh is not working when the particles are moving. and I got the error Atom sorting has bin size = 0.0 .

kind regards,
Arghavan

Arghavani | Tue, 11/12/2019 - 13:23

### cfdemSolverIB

Hi everyone,

i am using cfdemSolverIB as its the tutorials and I have stl file in my physical domain therefore I used snappyhexmesh but the point is moving mesh is not working when the particles are moving. and I got the error Atom sorting has bin size = 0.0 .