[cig-commits] commit 2342 by bangerth to /var/svn/dealii/aspect
dealii.demon at gmail.com
dealii.demon at gmail.com
Sat Mar 22 04:35:26 PDT 2014
Revision 2342
Merge all output into a single file written by processor 0.
U trunk/aspect/source/postprocess/dynamic_topography.cc
http://www.dealii.org/websvn/revision.php?repname=Aspect+Repository&path=%2F&rev=2342&peg=2342
Diff:
Modified: trunk/aspect/source/postprocess/dynamic_topography.cc
===================================================================
--- trunk/aspect/source/postprocess/dynamic_topography.cc 2014-03-21 20:34:58 UTC (rev 2341)
+++ trunk/aspect/source/postprocess/dynamic_topography.cc 2014-03-22 11:35:24 UTC (rev 2342)
@@ -39,21 +39,19 @@
FEValues<dim> fe_values (this->get_mapping(),
this->get_fe(),
- quadrature_formula,
- update_values |
- update_gradients |
- update_q_points);
+ quadrature_formula,
+ update_values |
+ update_gradients |
+ update_q_points);
typename MaterialModel::Interface<dim>::MaterialModelInputs in(fe_values.n_quadrature_points, this->n_compositional_fields());
typename MaterialModel::Interface<dim>::MaterialModelOutputs out(fe_values.n_quadrature_points, this->n_compositional_fields());
std::vector<std::vector<double> > composition_values (this->n_compositional_fields(),std::vector<double> (quadrature_formula.size()));
- std::string filename = this->get_output_directory() +
- "surface_topography." +
- Utilities::int_to_string
- (this->get_triangulation().locally_owned_subdomain(), 4);
- std::ofstream output (filename.c_str());
+ // have a stream into which we write the data. the text stream is then
+ // later sent to processor 0
+ std::ostringstream output;
// loop over all of the surface cells and if one less than h/2 away from
// the top surface, evaluate the stress at its center
@@ -71,18 +69,18 @@
// get the various components of the solution, then
// evaluate the material properties there
fe_values[this->introspection().extractors.temperature]
- .get_function_values (this->get_solution(), in.temperature);
+ .get_function_values (this->get_solution(), in.temperature);
fe_values[this->introspection().extractors.pressure]
- .get_function_values (this->get_solution(), in.pressure);
+ .get_function_values (this->get_solution(), in.pressure);
fe_values[this->introspection().extractors.velocities]
- .get_function_symmetric_gradients (this->get_solution(), in.strain_rate);
+ .get_function_symmetric_gradients (this->get_solution(), in.strain_rate);
in.position = fe_values.get_quadrature_points();
for (unsigned int c=0; c<this->n_compositional_fields(); ++c)
fe_values[this->introspection().extractors.compositional_fields[c]]
- .get_function_values(this->get_solution(),
- composition_values[c]);
+ .get_function_values(this->get_solution(),
+ composition_values[c]);
for (unsigned int i=0; i<fe_values.n_quadrature_points; ++i)
{
for (unsigned int c=0; c<this->n_compositional_fields(); ++c)
@@ -110,15 +108,63 @@
const double dynamic_topography = sigma_rr / gravity.norm() / density;
output << location
- << ' '
- << dynamic_topography
- << std::endl;
+ << ' '
+ << dynamic_topography
+ << std::endl;
}
- }
+ }
- return std::pair<std::string,std::string>("Writing surface topography...",
+ const std::string filename = this->get_output_directory() +
+ "dynamic_topography." +
+ Utilities::int_to_string(this->get_timestep_number(), 5);
+
+ const unsigned int max_data_length = Utilities::MPI::max (output.str().size()+1,
+ this->get_mpi_communicator());
+ const unsigned int mpi_tag = 123;
+
+ // on processor 0, collect all of the data the individual processors send
+ // and concatenate them into one file
+ if (Utilities::MPI::this_mpi_process(this->get_mpi_communicator()) == 0)
+ {
+ std::ofstream file (filename.c_str());
+
+ // first write out the data we have created locally
+ file << output.str();
+
+ std::string tmp;
+ tmp.resize (max_data_length, '
More information about the CIG-COMMITS
mailing list