mesh_output.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 // Local includes
21 #include "libmesh/mesh_output.h"
22 #include "libmesh/parallel.h"
23 #include "libmesh/parallel_mesh.h"
25 
26 namespace libMesh
27 {
28 
29 template <class MT>
32  std::vector<Number>& soln,
33  std::vector<std::string>& names,
34  const std::set<std::string>* system_names)
35 {
36  if(!_is_parallel_format)
37  {
38  // We need a serial mesh for MeshOutput for now
39  const_cast<EquationSystems&>(es).allgather();
40  }
41 
42  es.build_variable_names (names, NULL, system_names);
43  es.build_solution_vector (soln, system_names);
44 
45  // For now, if we're doing a parallel format we're going to broadcast the vector from processor 0
46  // to all of the processors to mimic what build_solution_vector used to do.
47  // this is TERRIBLE and WASTEFUL but it's only temporary until we redesign the output of build_solution_vector
48  // and the inputs to the I/O... both of which should actually be NumericVectors....
49  if(_is_parallel_format)
50  {
51  size_t size = soln.size();
52  _obj->comm().broadcast(size);
53 
54  if(_obj->comm().rank())
55  soln.resize(size);
56 
57  _obj->comm().broadcast(soln);
58  }
59 }
60 
61 
62 
63 // Instantiate for our Mesh types. If this becomes too cumbersome later,
64 // move any functions in this file to the header file instead.
65 template class MeshOutput<MeshBase>;
66 template class MeshOutput<UnstructuredMesh>;
67 template class MeshOutput<ParallelMesh>;
68 
69 } // namespace libMesh

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:06 UTC

Hosted By:
SourceForge.net Logo