[cig-commits] [commit] master: Fix sweep collection function (dcf9835)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Oct 8 17:05:28 PDT 2014


Repository : https://github.com/geodynamics/vc

On branch  : master
Link       : https://github.com/geodynamics/vc/compare/23464fca3efa2b6ad7ee0ce8f60c225b18b49741...e4325192ad1118379f46ba66899cb98143d09e04

>---------------------------------------------------------------

commit dcf9835fa75c297f8f77bc313525ee701b8eaea2
Author: Eric Heien <emheien at ucdavis.edu>
Date:   Wed Sep 24 16:20:58 2014 -0700

    Fix sweep collection function


>---------------------------------------------------------------

dcf9835fa75c297f8f77bc313525ee701b8eaea2
 src/core/VCSimulation.cpp | 95 +++++++++++++++++++++++++----------------------
 src/core/VCSimulation.h   |  2 +-
 2 files changed, 51 insertions(+), 46 deletions(-)

diff --git a/src/core/VCSimulation.cpp b/src/core/VCSimulation.cpp
index edfcd04..97daddf 100644
--- a/src/core/VCSimulation.cpp
+++ b/src/core/VCSimulation.cpp
@@ -141,7 +141,7 @@ void VCSimulation::printTimers(void) {
 
 void VCSimulation::determineBlockNeighbors(void) {
     BlockList::iterator     bit, iit;
-    quakelib::ElementIDSet  all_blocks;
+    quakelib::ElementIDSet  all_sweeps;
     double                  block_size;
 
     for (bit=begin(); bit!=end(); ++bit) {
@@ -597,81 +597,86 @@ void VCSimulation::distributeBlocks(const quakelib::ElementIDSet &local_id_list,
  Collect the individual event sweeps spread through all nodes
  on to the root node in a single sweep.
  */
-void VCSimulation::collectEventSweep(VCEventSweep &cur_sweep) {
+void VCSimulation::collectEventSweep(quakelib::ModelSweeps &sweeps) {
 #ifdef MPI_C_FOUND
-    int                             *block_counts, *block_offsets;
-    int                             num_blocks, i, total_block_count;
-    VCEventSweep::const_iterator    it;
-    BlockSweepVals                  *sweep_blocks, *all_blocks;
+    int                             *sweep_counts, *sweep_offsets;
+    int                             num_local_sweeps, i, total_sweep_count;
+    BlockSweepVals                  *sweep_vals, *all_sweeps;
+    quakelib::ModelSweeps::const_iterator    it;
 
 #ifdef DEBUG
     startTimer(sweep_comm_timer);
 #endif
 
-    // Gather the number of blocks per node at the root
-    num_blocks = cur_sweep.size();
+    // Gather the number of sweeps per node at the root
+    num_local_sweeps = sweeps.size();
 
     if (isRootNode()) {
-        block_counts = new int[world_size];
-        block_offsets = new int[world_size];
+        sweep_counts = new int[world_size];
+        sweep_offsets = new int[world_size];
     } else {
-        block_counts = block_offsets = NULL;
+        sweep_counts = sweep_offsets = NULL;
     }
 
-    MPI_Gather(&num_blocks, 1, MPI_INT, block_counts, 1, MPI_INT, ROOT_NODE_RANK, MPI_COMM_WORLD);
+    MPI_Gather(&num_local_sweeps, 1, MPI_INT, sweep_counts, 1, MPI_INT, ROOT_NODE_RANK, MPI_COMM_WORLD);
 
     // Record the number of blocks the root will receive from each node
     if (isRootNode()) {
-        total_block_count = 0;
+        total_sweep_count = 0;
 
         for (i=0; i<world_size; ++i) {
-            block_offsets[i] = total_block_count;
-            total_block_count += block_counts[i];
+            sweep_offsets[i] = total_sweep_count;
+            total_sweep_count += sweep_counts[i];
         }
     }
 
+    // TODO: Change BlockSweepVals to use the Quakelib data structure
     // Record the values of each block in this sweep
-    sweep_blocks = new BlockSweepVals[num_blocks];
-
-    if (isRootNode()) all_blocks = new BlockSweepVals[total_block_count];
-
-    for (i=0,it=cur_sweep.begin(); it!=cur_sweep.end(); ++it,++i) {
-        sweep_blocks[i].block_id = it->first;
-        sweep_blocks[i].slip = it->second.slip;
-        sweep_blocks[i].init_shear = it->second.shear_init;
-        sweep_blocks[i].init_normal = it->second.normal_init;
-        sweep_blocks[i].final_shear = it->second.shear_final;
-        sweep_blocks[i].final_normal = it->second.normal_final;
+    sweep_vals = new BlockSweepVals[num_local_sweeps];
+
+    if (isRootNode()) all_sweeps = new BlockSweepVals[total_sweep_count];
+
+    for (i=0,it=sweeps.begin(); it!=sweeps.end(); ++it,++i) {
+        sweep_vals[i].element_id = it->_element_id;
+        sweep_vals[i].sweep_num = it->_sweep_number;
+        sweep_vals[i].slip = it->_slip;
+        sweep_vals[i].init_shear = it->_shear_init;
+        sweep_vals[i].init_normal = it->_normal_init;
+        sweep_vals[i].final_shear = it->_shear_final;
+        sweep_vals[i].final_normal = it->_normal_final;
     }
 
     // Gather the sweep info at the root node
-    MPI_Gatherv(sweep_blocks, num_blocks, block_sweep_type,
-                all_blocks, block_counts, block_offsets, block_sweep_type,
+    MPI_Gatherv(sweep_vals, num_local_sweeps, element_sweep_type,
+                all_sweeps, sweep_counts, sweep_offsets, element_sweep_type,
                 ROOT_NODE_RANK, MPI_COMM_WORLD);
 
     // Record the received blocks into the current sweep on the root node
     if (isRootNode()) {
-        for (i=0; i<total_block_count; ++i) {
-            BlockID     bid;
-            bid = all_blocks[i].block_id;
-            cur_sweep.setSlipAndArea(bid,
-                                     all_blocks[i].slip,
-                                     getBlock(bid).area(),
-                                     getBlock(bid).lame_mu());
-            cur_sweep.setInitStresses(bid,
-                                      all_blocks[i].init_shear,
-                                      all_blocks[i].init_normal);
-            cur_sweep.setFinalStresses(bid,
-                                       all_blocks[i].final_shear,
-                                       all_blocks[i].final_normal);
+        for (i=0; i<total_sweep_count; ++i) {
+            BlockID         bid = all_sweeps[i].element_id;
+            unsigned int    sweep_num = all_sweeps[i].sweep_num;
+            sweeps.setSlipAndArea(bid,
+                                  sweep_num,
+                                  all_sweeps[i].slip,
+                                  getBlock(bid).area(),
+                                  getBlock(bid).lame_mu());
+            sweeps.setInitStresses(bid,
+                                   sweep_num,
+                                   all_sweeps[i].init_shear,
+                                   all_sweeps[i].init_normal);
+            sweeps.setFinalStresses(bid,
+                                    sweep_num,
+                                    all_sweeps[i].final_shear,
+                                    all_sweeps[i].final_normal);
         }
 
-        delete block_counts;
-        delete block_offsets;
-        delete all_blocks;
+        delete sweep_counts;
+        delete sweep_offsets;
+        delete all_sweeps;
     }
 
-    delete sweep_blocks;
+    delete sweep_vals;
 
 #ifdef DEBUG
     stopTimer(sweep_comm_timer);
diff --git a/src/core/VCSimulation.h b/src/core/VCSimulation.h
index 68a2b33..7b2d45b 100644
--- a/src/core/VCSimulation.h
+++ b/src/core/VCSimulation.h
@@ -123,7 +123,7 @@ class VCSimulation : public SimFramework, public VCParams, public VCSimData, pub
         void multiplyRow(double *c, const double *b, const GREEN_VAL *a, const int n);
         void distributeUpdateField(void);
         void distributeBlocks(const quakelib::ElementIDSet &local_id_list, BlockIDProcMapping &global_id_list);
-        void collectEventSweep(VCEventSweep &cur_sweep);
+        void collectEventSweep(quakelib::ModelSweeps &sweeps);
 
         std::pair<quakelib::ElementIDSet::const_iterator, quakelib::ElementIDSet::const_iterator> getNeighbors(const BlockID &bid) const;
         void printTimers(void);



More information about the CIG-COMMITS mailing list