[cig-commits] [commit] master: Make element resizing an option (bed3d9a)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Mon Jan 5 10:55:35 PST 2015


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

On branch  : master
Link       : https://github.com/geodynamics/vq/compare/a77e0124f38a909b20a374ec686149d65dbca5b1...f26b7fa26e56a9309aa9658f7441dfd63922dee6

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

commit bed3d9a5e7d6985053a30e1f23c441c54f89a6a4
Author: Eric Heien <emheien at ucdavis.edu>
Date:   Fri Jan 2 11:51:46 2015 -0800

    Make element resizing an option


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

bed3d9a5e7d6985053a30e1f23c441c54f89a6a4
 quakelib/src/QuakeLibIO.cpp | 12 +++++++++---
 quakelib/src/QuakeLibIO.h   |  5 +++--
 src/mesher.cpp              | 16 ++++++++++++----
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/quakelib/src/QuakeLibIO.cpp b/quakelib/src/QuakeLibIO.cpp
index 93aeb60..53954ef 100644
--- a/quakelib/src/QuakeLibIO.cpp
+++ b/quakelib/src/QuakeLibIO.cpp
@@ -442,7 +442,7 @@ class TraceSpline {
         };
 };
 
-void quakelib::ModelWorld::create_section(std::vector<unsigned int> &unused_trace_segments, const std::vector<FaultTracePoint> &trace, const LatLonDepth &base_coord, const UIndex &fault_id, const float &element_size, const std::string &section_name, const std::string &taper_method) {
+void quakelib::ModelWorld::create_section(std::vector<unsigned int> &unused_trace_segments, const std::vector<FaultTracePoint> &trace, const LatLonDepth &base_coord, const UIndex &fault_id, const float &element_size, const std::string &section_name, const std::string &taper_method, const bool resize_trace_elements) {
     Vec<3>              cur_trace_point, next_trace_point, element_end, element_step_vec, vert_step;
     std::vector<UIndex> elem_ids;
     std::set<unsigned int> unused_trace_pts;
@@ -497,6 +497,12 @@ void quakelib::ModelWorld::create_section(std::vector<unsigned int> &unused_trac
             }
         }
 
+        // If we used a fixed element size, one time through is enough
+        if (!resize_trace_elements) {
+            best_step = cur_elem_size_guess;
+            best_elem_count = elem_count;
+            break;
+        }
         // Record which element size got us closest to the end of the trace
         if (cur_t > best_t) {
             best_t = cur_t;
@@ -793,7 +799,7 @@ int quakelib::ModelWorld::read_file_ascii(const std::string &file_name) {
     return 0;
 }
 
-int quakelib::ModelWorld::read_file_trace_latlon(std::vector<unsigned int> &unused_trace_segments, const std::string &file_name, const float &elem_size, const std::string &taper_method) {
+int quakelib::ModelWorld::read_file_trace_latlon(std::vector<unsigned int> &unused_trace_segments, const std::string &file_name, const float &elem_size, const std::string &taper_method, const bool resize_trace_elements) {
     std::ifstream                   in_file;
     std::vector<FaultTracePoint>    trace_pts;
     std::string                     cur_section_name;
@@ -830,7 +836,7 @@ int quakelib::ModelWorld::read_file_trace_latlon(std::vector<unsigned int> &unus
             min_lon = fmin(min_lon, new_trace_pt.pos().lon());
         }
 
-        new_world.create_section(unused_trace_segments, trace_pts, LatLonDepth(min_lat, min_lon), fault_id, elem_size, cur_section_name, taper_method);
+        new_world.create_section(unused_trace_segments, trace_pts, LatLonDepth(min_lat, min_lon), fault_id, elem_size, cur_section_name, taper_method, resize_trace_elements);
         this->insert(new_world);
     }
 
diff --git a/quakelib/src/QuakeLibIO.h b/quakelib/src/QuakeLibIO.h
index f3860d6..00dd9af 100644
--- a/quakelib/src/QuakeLibIO.h
+++ b/quakelib/src/QuakeLibIO.h
@@ -572,12 +572,13 @@ namespace quakelib {
                                 const UIndex &fault_id,
                                 const float &element_size,
                                 const std::string &section_name,
-                                const std::string &taper_method);
+                                const std::string &taper_method,
+                                const bool resize_trace_elements);
 
             int read_file_ascii(const std::string &file_name);
             int write_file_ascii(const std::string &file_name) const;
 
-            int read_file_trace_latlon(std::vector<unsigned int> &unused_trace_segments, const std::string &file_name, const float &elem_size, const std::string &taper_method);
+            int read_file_trace_latlon(std::vector<unsigned int> &unused_trace_segments, const std::string &file_name, const float &elem_size, const std::string &taper_method, const bool resize_trace_elements);
             int write_file_trace_latlon(const std::string &file_name, const float &depth_along_dip);
 
             int read_file_hdf5(const std::string &file_name);
diff --git a/src/mesher.cpp b/src/mesher.cpp
index 0f2064c..54df00e 100644
--- a/src/mesher.cpp
+++ b/src/mesher.cpp
@@ -152,6 +152,9 @@ void print_usage(int argc, char **argv) {
     std::cerr << "\tMerge duplicate vertices after importing files." << std::endl;
     std::cerr << "-d, --delete_unused" << std::endl;
     std::cerr << "\tDelete unused vertices after importing files." << std::endl;
+    std::cerr << "-r, --resize_trace_elements" << std::endl;
+    std::cerr << "\tResize elements generated on traces to better match fault length." << std::endl;
+    std::cerr << "\tThis will only decrease and at most halve the element size." << std::endl;
 
     std::cerr << std::endl;
     std::cerr << "FILE IMPORT" << std::endl;
@@ -186,7 +189,8 @@ void print_usage(int argc, char **argv) {
 
 int main (int argc, char **argv) {
     quakelib::ModelWorld        world;
-    bool                        delete_unused, merge_duplicate_vertices, arg_error, failed;
+    bool                        delete_unused, merge_duplicate_vertices, resize_trace_elements;
+    bool                        arg_error, failed;
     std::string                 names[2] = {"import", "export"};
     std::string                 eqsim_geom_in_file, eqsim_fric_in_file, eqsim_cond_in_file;
     std::string                 eqsim_geom_out_file, eqsim_fric_out_file, eqsim_cond_out_file;
@@ -197,11 +201,11 @@ int main (int argc, char **argv) {
     int                         ch, res;
     unsigned int                i, n, j, num_trace_files;
 
-    arg_error = delete_unused = merge_duplicate_vertices = false;
+    arg_error = delete_unused = merge_duplicate_vertices = resize_trace_elements = false;
     eqsim_geom_in_file = eqsim_fric_in_file = eqsim_cond_in_file = "";
     eqsim_geom_out_file = eqsim_fric_out_file = eqsim_cond_out_file = "";
 
-    while ((ch = getopt_long(argc, argv, "mds:D:R:M:C:F:G:i:j:e:f:l:t:", longopts, NULL)) != -1) {
+    while ((ch = getopt_long(argc, argv, "mdrs:D:R:M:C:F:G:i:j:e:f:l:t:", longopts, NULL)) != -1) {
         switch (ch) {
             case 'd':
                 delete_unused = true;
@@ -211,6 +215,10 @@ int main (int argc, char **argv) {
                 merge_duplicate_vertices = true;
                 break;
 
+            case 'r':
+                resize_trace_elements = true;
+                break;
+                
             case 's':
                 stat_out_file = optarg;
                 break;
@@ -350,7 +358,7 @@ int main (int argc, char **argv) {
         } else if (types[0][n] == "hdf5") {
             res = new_world.read_file_hdf5(files[0][n]);
         } else if (types[0][n] == "trace") {
-            res = new_world.read_file_trace_latlon(unused_trace_segments, files[0][n], trace_element_sizes.at(j), taper_fault_methods.at(j));
+            res = new_world.read_file_trace_latlon(unused_trace_segments, files[0][n], trace_element_sizes.at(j), taper_fault_methods.at(j), resize_trace_elements);
             ++j;
         }
 



More information about the CIG-COMMITS mailing list