[cig-commits] [commit] master: Added stress output to simulation (8fa518d)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Tue Dec 2 13:56:13 PST 2014
Repository : https://github.com/geodynamics/vq
On branch : master
Link : https://github.com/geodynamics/vq/compare/06902a05cf4d70bc94c85d1c195c073d4e74cdad...c935dfd33f870a081b6c01cce97a060ad1cbdbda
>---------------------------------------------------------------
commit 8fa518dbead95a987c37bf7966f7b836366cf0d2
Author: Eric Heien <emheien at ucdavis.edu>
Date: Wed Nov 26 19:29:32 2014 -0800
Added stress output to simulation
>---------------------------------------------------------------
8fa518dbead95a987c37bf7966f7b836366cf0d2
.gitignore | 2 ++
src/core/Simulation.cpp | 37 +++++++++++++++++++++++++++++++++++++
src/core/Simulation.h | 8 ++++++++
3 files changed, 47 insertions(+)
diff --git a/.gitignore b/.gitignore
index 538ec39..f6e93f7 100755
--- a/.gitignore
+++ b/.gitignore
@@ -183,4 +183,6 @@ doc/*.bbl
doc/*.blg
+*.h5
+
*.pyc
diff --git a/src/core/Simulation.cpp b/src/core/Simulation.cpp
index 403eb65..0a8eafe 100644
--- a/src/core/Simulation.cpp
+++ b/src/core/Simulation.cpp
@@ -68,6 +68,31 @@ Simulation::Simulation(int argc, char **argv) : SimFramework(argc, argv) {
}
}
+void Simulation::output_stress(quakelib::UIndex event_num, quakelib::UIndex sweep_num) {
+ quakelib::ModelStress stress;
+ quakelib::ModelStressState stress_state;
+
+ stress_state.setYear(getYear());
+ stress_state.setEventNum(event_num);
+ stress_state.setSweepNum(sweep_num);
+ stress_state.setStartEndRecNums(num_stress_recs, num_stress_recs+numGlobalBlocks());
+
+ // Store stress values
+ for (unsigned int i=0; i<numGlobalBlocks(); ++i) {
+ stress.add_stress_entry(i, shear_stress[i], normal_stress[i]);
+ }
+
+ num_stress_recs += numGlobalBlocks();
+
+ // Write the stress state details
+ stress_state.write_ascii(stress_state_outfile);
+ stress_state_outfile.flush();
+
+ // Write the stress details
+ stress.write_ascii(stress_outfile);
+ stress_outfile.flush();
+}
+
/*!
Finish the simulation by deallocating memory and freeing MPI related structures.
*/
@@ -96,6 +121,18 @@ void Simulation::init(void) {
num_mults = 0;
#endif
SimFramework::init();
+
+ stress_state_outfile.open("stress_state_outfile.txt");
+ stress_outfile.open("stress.txt");
+
+ if (!stress_state_outfile.good() || !stress_outfile.good()) {
+ errConsole() << "ERROR: Could not open output file " << std::endl;
+ exit(-1);
+ }
+
+ quakelib::ModelStressState::write_ascii_header(stress_state_outfile);
+ quakelib::ModelStress::write_ascii_header(stress_outfile);
+ num_stress_recs = 0;
}
/*!
diff --git a/src/core/Simulation.h b/src/core/Simulation.h
index 03828fd..9770ccf 100644
--- a/src/core/Simulation.h
+++ b/src/core/Simulation.h
@@ -238,6 +238,8 @@ class Simulation : public SimFramework, public VCParams, public VCSimData, publi
void partitionBlocks(void);
+ void output_stress(quakelib::UIndex event_num, quakelib::UIndex sweep_num);
+
private:
#ifdef DEBUG
int mult_timer;
@@ -252,6 +254,12 @@ class Simulation : public SimFramework, public VCParams, public VCSimData, publi
double *mult_buffer;
GREEN_VAL *decompress_buf;
+ //! Files to write stress records to
+ std::ofstream stress_state_outfile, stress_outfile;
+
+ //! Number of stress records written to files, used for keeping track of indices
+ unsigned int num_stress_recs;
+
//! Map of which blocks have which neighbors
std::map<BlockID, quakelib::ElementIDSet> neighbor_map;
};
More information about the CIG-COMMITS
mailing list