GRINS-0.8.0
List of all members | Public Member Functions | Protected Attributes
GRINS::Visualization Class Referenceabstract

#include <visualization.h>

Inheritance diagram for GRINS::Visualization:
Inheritance graph
[legend]

Public Member Functions

 Visualization (const GetPot &input, const libMesh::Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD)
 
virtual ~Visualization ()
 
void output (SharedPtr< libMesh::EquationSystems > equation_system)
 
void output (SharedPtr< libMesh::EquationSystems > equation_system, const unsigned int time_step, const libMesh::Real time)
 
void output_residual (SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system)
 
virtual void output_residual (SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system, const unsigned int time_step, const libMesh::Real time)=0
 
void output_residual_sensitivities (SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system, const libMesh::ParameterVector &params)
 
virtual void output_residual_sensitivities (SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system, const libMesh::ParameterVector &params, const unsigned int time_step, const libMesh::Real time)=0
 
void output_adjoint (SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system)
 
virtual void output_adjoint (SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system, const unsigned int time_step, const libMesh::Real time)=0
 
void output_solution_sensitivities (SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system, const libMesh::ParameterVector &params)
 
virtual void output_solution_sensitivities (SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system, const libMesh::ParameterVector &params, const unsigned int time_step, const libMesh::Real time)=0
 
void dump_visualization (SharedPtr< libMesh::EquationSystems > equation_system, const std::string &filename_prefix, const libMesh::Real time)
 

Protected Attributes

std::string _vis_output_file_prefix
 
std::vector< std::string > _output_format
 

Detailed Description

Definition at line 51 of file visualization.h.

Constructor & Destructor Documentation

GRINS::Visualization::Visualization ( const GetPot &  input,
const libMesh::Parallel::Communicator &comm  LIBMESH_CAN_DEFAULT_TO_COMMWORLD 
)

Definition at line 50 of file visualization.C.

References _output_format.

52  : _vis_output_file_prefix( input("vis-options/vis_output_file_prefix", "unknown" ) )
53  {
54  unsigned int num_formats = input.vector_variable_size("vis-options/output_format");
55 
56  // If no format specified, default to ExodusII only
57  if( num_formats == 0 )
58  {
59  // Were we specifically asked to use a ParallelMesh or SerialMesh?
60  std::string mesh_class = input("mesh-options/mesh_class", "default");
61 
62  if (mesh_class == "parallel")
63  _output_format.push_back("Nemesis");
64  else if (mesh_class == "serial")
65  _output_format.push_back("ExodusII");
66  else if (mesh_class == "default")
67  {
68  // Is our default Mesh distributable?
69  libMesh::Mesh testdefault(comm);
70  testdefault.delete_remote_elements();
71  if (testdefault.is_serial())
72  _output_format.push_back("ExodusII");
73  else
74  _output_format.push_back("Nemesis");
75  }
76  else
77  {
78  std::cerr << " Visualization::Visualization:"
79  << " mesh-options/mesh_class had invalid value " << mesh_class
80  << std::endl;
81  libmesh_error();
82  }
83  }
84 
85  for( unsigned int i = 0; i < num_formats; i++ )
86  {
87  _output_format.push_back( input("vis-options/output_format", "DIE", i ) );
88  }
89 
90  return;
91  }
std::vector< std::string > _output_format
std::string _vis_output_file_prefix
GRINS::Visualization::~Visualization ( )
virtual

Definition at line 93 of file visualization.C.

94  {
95  return;
96  }

Member Function Documentation

void GRINS::Visualization::dump_visualization ( SharedPtr< libMesh::EquationSystems >  equation_system,
const std::string &  filename_prefix,
const libMesh::Real  time 
)

Definition at line 154 of file visualization.C.

Referenced by output(), GRINS::SteadyVisualization::output_adjoint(), and GRINS::SteadyVisualization::output_residual().

157  {
158  libMesh::MeshBase& mesh = equation_system->get_mesh();
159 
160  if( this->_vis_output_file_prefix == "unknown" )
161  {
162  // TODO: Need consisent way to print warning messages.
163  std::cout << " WARNING in Visualization::dump_visualization :"
164  << " using 'unknown' as file prefix since it was not set "
165  << std::endl;
166  }
167 
168  // If we're asked to put files in a subdirectory, let's make sure
169  // it exists
170  if (!mesh.comm().rank())
171  for (std::size_t pos = this->_vis_output_file_prefix.find('/');
172  pos != std::string::npos;
173  pos = this->_vis_output_file_prefix.find('/',++pos))
174  if (mkdir(this->_vis_output_file_prefix.substr(0,pos).c_str(),
175  0777) != 0 && errno != EEXIST)
176  libmesh_file_error(this->_vis_output_file_prefix.substr(0,pos));
177 
178  for( std::vector<std::string>::const_iterator format = _output_format.begin();
179  format != _output_format.end();
180  format ++ )
181  {
182  // The following is a modifed copy from the FIN-S code.
183  if ((*format) == "tecplot" ||
184  (*format) == "dat")
185  {
186  std::string filename = filename_prefix+".dat";
187  libMesh::TecplotIO(mesh,false).write_equation_systems( filename,
188  *equation_system );
189  }
190  else if ((*format) == "tecplot_binary" ||
191  (*format) == "plt")
192  {
193  std::string filename = filename_prefix+".plt";
194  libMesh::TecplotIO(mesh,true).write_equation_systems( filename,
195  *equation_system );
196  }
197  else if ((*format) == "gmv")
198  {
199  std::string filename = filename_prefix+".gmv";
200  libMesh::GMVIO(mesh).write_equation_systems( filename,
201  *equation_system );
202  }
203  else if ((*format) == "pvtu")
204  {
205  std::string filename = filename_prefix+".pvtu";
206  libMesh::VTKIO(mesh).write_equation_systems( filename,
207  *equation_system );
208  }
209  else if ((*format) == "ExodusII")
210  {
211  std::string filename = filename_prefix+".exo";
212 
213  // The "1" is hardcoded for the number of time steps because the ExodusII manual states that
214  // it should be the number of timesteps within the file. Here, we are explicitly only doing
215  // one timestep per file.
216  libMesh::ExodusII_IO(mesh).write_timestep
217  ( filename, *equation_system, 1, time );
218  }
219  else if ((*format) == "Nemesis")
220  {
221  std::string filename = filename_prefix+".nem";
222 
223  // The "1" is hardcoded for the number of time steps because the ExodusII manual states that
224  // it should be the number of timesteps within the file. Here, we are explicitly only doing
225  // one timestep per file.
226  libMesh::Nemesis_IO(mesh).write_timestep
227  ( filename, *equation_system, 1, time );
228  }
229  else if ((*format).find("xda") != std::string::npos ||
230  (*format).find("xdr") != std::string::npos)
231  {
232  std::string filename = filename_prefix+"."+(*format);
233  const bool binary = ((*format).find("xdr") != std::string::npos);
234  equation_system->write( filename,
235  binary ? GRINSEnums::ENCODE : GRINSEnums::WRITE,
236  libMesh::EquationSystems::WRITE_DATA |
237  libMesh::EquationSystems::WRITE_ADDITIONAL_DATA );
238  }
239  else if ((*format) == "mesh_only" )
240  {
241  std::string filename = filename_prefix+"_mesh.xda";
242  equation_system->get_mesh().write( filename );
243  }
244  else
245  {
246  // TODO: Do we want to use this to error throughout the code?
247  // TODO: (at least need to pass/print some message/string) - sahni
248  libmesh_error();
249  }
250  } // End loop over formats
251 
252  return;
253  }
std::vector< std::string > _output_format
std::string _vis_output_file_prefix
void GRINS::Visualization::output ( SharedPtr< libMesh::EquationSystems >  equation_system)

Definition at line 98 of file visualization.C.

References _vis_output_file_prefix, and dump_visualization().

99  {
100  this->dump_visualization( equation_system, _vis_output_file_prefix, 0.0 );
101 
102  return;
103  }
void dump_visualization(SharedPtr< libMesh::EquationSystems > equation_system, const std::string &filename_prefix, const libMesh::Real time)
std::string _vis_output_file_prefix
void GRINS::Visualization::output ( SharedPtr< libMesh::EquationSystems >  equation_system,
const unsigned int  time_step,
const libMesh::Real  time 
)

Definition at line 106 of file visualization.C.

109  {
110  std::stringstream suffix;
111 
112  suffix << time_step;
113 
114  std::string filename = this->_vis_output_file_prefix;
115  filename+="."+suffix.str();
116 
117  this->dump_visualization( equation_system, filename, time );
118 
119  return;
120  }
void dump_visualization(SharedPtr< libMesh::EquationSystems > equation_system, const std::string &filename_prefix, const libMesh::Real time)
std::string _vis_output_file_prefix
void GRINS::Visualization::output_adjoint ( SharedPtr< libMesh::EquationSystems >  equation_system,
GRINS::MultiphysicsSystem system 
)

Definition at line 138 of file visualization.C.

140  {
141  this->output_adjoint( equation_system, system, 0, 0.0 );
142  }
void output_adjoint(SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system)
virtual void GRINS::Visualization::output_adjoint ( SharedPtr< libMesh::EquationSystems >  equation_system,
GRINS::MultiphysicsSystem system,
const unsigned int  time_step,
const libMesh::Real  time 
)
pure virtual
void GRINS::Visualization::output_residual ( SharedPtr< libMesh::EquationSystems >  equation_system,
GRINS::MultiphysicsSystem system 
)

Definition at line 122 of file visualization.C.

124  {
125  this->output_residual( equation_system, system, 0, 0.0 );
126  return;
127  }
void output_residual(SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system)
virtual void GRINS::Visualization::output_residual ( SharedPtr< libMesh::EquationSystems >  equation_system,
GRINS::MultiphysicsSystem system,
const unsigned int  time_step,
const libMesh::Real  time 
)
pure virtual
void GRINS::Visualization::output_residual_sensitivities ( SharedPtr< libMesh::EquationSystems >  equation_system,
GRINS::MultiphysicsSystem system,
const libMesh::ParameterVector &  params 
)

Definition at line 130 of file visualization.C.

133  {
135  ( equation_system, system, params, 0, 0.0 );
136  }
void output_residual_sensitivities(SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system, const libMesh::ParameterVector &params)
virtual void GRINS::Visualization::output_residual_sensitivities ( SharedPtr< libMesh::EquationSystems >  equation_system,
GRINS::MultiphysicsSystem system,
const libMesh::ParameterVector &  params,
const unsigned int  time_step,
const libMesh::Real  time 
)
pure virtual
void GRINS::Visualization::output_solution_sensitivities ( SharedPtr< libMesh::EquationSystems >  equation_system,
GRINS::MultiphysicsSystem system,
const libMesh::ParameterVector &  params 
)

Definition at line 145 of file visualization.C.

148  {
150  ( equation_system, system, params, 0, 0.0 );
151  }
void output_solution_sensitivities(SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system, const libMesh::ParameterVector &params)
virtual void GRINS::Visualization::output_solution_sensitivities ( SharedPtr< libMesh::EquationSystems >  equation_system,
GRINS::MultiphysicsSystem system,
const libMesh::ParameterVector &  params,
const unsigned int  time_step,
const libMesh::Real  time 
)
pure virtual

Member Data Documentation

std::vector<std::string> GRINS::Visualization::_output_format
protected

Definition at line 108 of file visualization.h.

Referenced by Visualization().

std::string GRINS::Visualization::_vis_output_file_prefix
protected

The documentation for this class was generated from the following files:

Generated on Tue Dec 19 2017 12:47:32 for GRINS-0.8.0 by  doxygen 1.8.9.1