commit 7995e2dd023e4a70bc29f0fad44def77512adf70
parent fb1c0e5e16934119e56ea9c56817852ab5e8c287
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Tue, 13 Jul 2021 14:32:34 +0200
small syntax fixes
Diffstat:
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/src/contact_search.jl b/src/contact_search.jl
@@ -78,15 +78,15 @@ function findContactsAllToAll!(simulation::Simulation)
         simulation.ocean.bc_east > 1 ||
         simulation.ocean.bc_north > 1 ||
         simulation.ocean.bc_south > 1
-        error("Ocean boundary conditions to not work with all-to-all " *
-              "contact search")
+        println("Ocean boundary conditions do not work with all-to-all " *
+                "contact search")
     end
     if simulation.atmosphere.bc_west > 1 ||
         simulation.atmosphere.bc_east > 1 ||
         simulation.atmosphere.bc_north > 1 ||
         simulation.atmosphere.bc_south > 1
-        error("Atmopshere boundary conditions to not work with " *
-              "all-to-all contact search")
+        println("Atmopshere boundary conditions do not work with " *
+                "all-to-all contact search")
     end
 
     @inbounds for i = 1:length(simulation.grains)
diff --git a/src/packing.jl b/src/packing.jl
@@ -210,22 +210,25 @@ function irregularPacking!(simulation::Simulation;
         push!(active_list, 1)
     else
         for idx=1:length(simulation.grains)
-            simulation.grains[idx].color=1
+            simulation.grains[idx].color = 1
             push!(active_list, idx)
         end
     end
 
     # Step 2: While the active list is not empty, choose a random index `i` from
     # it.  Generate up to `sample_limit` points chosen uniformly from the
-    # distance `(r_i+r_j)` around `x_i`.
+    # distance `(r_i + r_j)` around `x_i`.
     # For each point in turn, check if it is within distance r of existing
     # samples (using the background grid to only test nearby samples). If a
     # point is adequately far from existing samples, emit it as the next sample
     # and add it to the active list. If after `sample_limit` attempts no such
     # point is found, instead remove `i` from the active list.
-    j = 0;
-    x_active = zeros(3); x_candidate = zeros(3);
-    r_active = 0.; r_candidate = 0.; T = 0.
+    j = 0
+    x_active = zeros(3)
+    x_candidate = zeros(3)
+    r_active = 0.0
+    r_candidate = 0.0
+    T = 0.0
     n = 0
     neighbor_found = false
     i_last_active = 0
@@ -245,7 +248,7 @@ function irregularPacking!(simulation::Simulation;
         # Did the algoritm find a neighbor to the current active grain `i`?
         neighbor_found = false
 
-        for j=1:sample_limit
+        for j = 1:sample_limit
 
             # Generate a candidate point
             if binary_radius_search
@@ -279,6 +282,7 @@ function irregularPacking!(simulation::Simulation;
 
             # If the binary_radius_search is selected, try to adjust the radius
             # to a value as large as possible
+			sortGrainsInGrid!(simulation, grid)
             if binary_radius_search
 
                 # first test the maximum radius. If unsuccessful, iteratively
@@ -317,8 +321,9 @@ function irregularPacking!(simulation::Simulation;
 
             # if the grain candidate doesn't overlap with any other grains,
             # add it and mark it as active
+			sortGrainsInGrid!(simulation, grid)
             if checkForContacts(simulation, grid, x_candidate, r_candidate,
-                               return_when_overlap_found=true)
+                                return_when_overlap_found=true)
                 #println("Added grain from parent $i")
                 addGrainCylindrical!(simulation, x_candidate, r_candidate,
                                      thickness, color=1, verbose=false)