Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plagprep.C File Reference

This utility code reads in the *.top file information and generates the initial particle solution by finding the injecting surfaces. More...

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
Include dependency graph for plagprep.C:

Go to the source code of this file.

Functions

void showUsage ()
 Displays usage information for this utility. More...
 
bool parseCmdParameters (int argc, char **argv)
 Parses the user-supplied parameters for this utility. More...
 
void searchTopFile ()
 Searches the prjname.top file for injecting boundary conditions. More...
 
int main (int argc, char **argv)
 Program main. More...
 

Variables

std::string prjname
 < More...
 
std::string outputfile
 The number of blocks, read from the *.top file. More...
 
int numberOfBlocks
 
int bndrycondition
 The boundary condition corresponding to an injecting surface. More...
 

Detailed Description

This utility code reads in the *.top file information and generates the initial particle solution by finding the injecting surfaces.

The injecting surface are identified by a user-supplied boundary condition that corresponds to the boundary condition used to indicate an injecting surface in the *.top file.

Date
Nov 12, 2009
Author
George Zagaris (gzaga.nosp@m.ris@.nosp@m.illin.nosp@m.ois..nosp@m.edu)

Definition in file plagprep.C.

Function Documentation

int main ( int  argc,
char **  argv 
)

Program main.

Parameters
argcthe argument counter.
argvthe argument vector.
Returns
rc the return code.
Note
rc != iff an error occured.

Definition at line 76 of file plagprep.C.

References bndrycondition, outputfile, parseCmdParameters(), prjname, searchTopFile(), and showUsage().

77 {
78  std::cout << __DATE__ << " Running program: " << argv[ 0 ] << std::endl;
79 
80  std::cout << "Parsing command line parameters...";
81  if( parseCmdParameters( argc, argv ) )
82  {
83  std::cout << "[DONE]\n";
84 
85  std::cout << "Searching " << prjname << ".top for BC=" << bndrycondition << "...";
86  searchTopFile( );
87  std::cout << "[DONE]\n";
88 
89  std::cout << "Output is saved at " << outputfile << "!\n";
90 
91  }
92  else
93  {
94  std::cout << "[DONE]\n";
95 
96  std::cerr << "Error parsing command line parameters!\n";
97  std::cerr << "File: " << __FILE__ << std::endl;
98  std::cerr << "Line: " << __LINE__ << std::endl;
99 
100  showUsage( );
101 
102  return(-1 );
103  }
104 
105  return( 0 );
106 
107 }
int bndrycondition
The boundary condition corresponding to an injecting surface.
Definition: plagprep.C:42
void searchTopFile()
Searches the prjname.top file for injecting boundary conditions.
Definition: plagprep.C:113
std::string outputfile
Output file to write the file.
Definition: hdf2pltV2.C:55
bool parseCmdParameters(int argc, char **argv)
Parses the user-supplied parameters for this utility.
Definition: plagprep.C:183
void showUsage()
Prints usage and examples to STDOUT.
Definition: hdf2plt.C:785
std::string prjname
&lt;
Definition: plagprep.C:29

Here is the call graph for this function:

bool parseCmdParameters ( int  argc,
char **  argv 
)

Parses the user-supplied parameters for this utility.

Parameters
argcthe argument counter.
argvthe argument vector.
Returns
status true if the command line parameters are parsed successfully, otherwise false.

Definition at line 183 of file plagprep.C.

References bndrycondition, i, numberOfBlocks, outputfile, prjname, and showUsage().

Referenced by main().

184 {
185  prjname = "";
186  outputfile = "";
187  numberOfBlocks = 0;
188  bndrycondition = 91;
189 
190  for( int i=1; i < argc; ++i )
191  {
192  if( std::strcmp( argv[ i ], "-bc") == 0 )
193  {
194  bndrycondition = std::atoi( argv[ ++i ] );
195  }
196  else if( std::strcmp( argv[ i ], "-p") == 0 )
197  {
198  prjname = std::string( argv[ ++i ] );
199  outputfile = prjname + std::string( ".sola_0.00000E+00" );
200  }
201  else if( std::strcmp( argv[ i ], "-h") == 0 )
202  {
203  showUsage( );
204  exit( 0 );
205  }
206  }
207 
208  if( prjname == "" )
209  return false;
210 
211  return true;
212 }
int bndrycondition
The boundary condition corresponding to an injecting surface.
Definition: plagprep.C:42
std::string outputfile
Output file to write the file.
Definition: hdf2pltV2.C:55
blockLoc i
Definition: read.cpp:79
void showUsage()
Prints usage and examples to STDOUT.
Definition: hdf2plt.C:785
int numberOfBlocks
Definition: plagprep.C:35
std::string prjname
&lt;
Definition: plagprep.C:29

Here is the call graph for this function:

Here is the caller graph for this function:

void searchTopFile ( )

Searches the prjname.top file for injecting boundary conditions.

Postcondition
an prjname.plag_sola_0.00000E+00 is written.

Definition at line 113 of file plagprep.C.

References bndrycondition, i, j, numberOfBlocks, outputfile, and prjname.

Referenced by main().

114 {
115  std::string dummyline;
116 
117  std::ofstream ofs;
118  ofs.open( outputfile.c_str( ) );
119  if( !ofs.is_open( ) )
120  {
121  std::cerr << "\n Error: Cannot open output file " << outputfile << std::endl;
122  std::cerr << "File: " << __FILE__ << std::endl;
123  std::cerr << "Line: " << __LINE__ << std::endl;
124  }
125 
126  ofs << "0.00E+000\n";
127 
128  std::ifstream ifs;
129  ifs.open( ( prjname+std::string(".top") ).c_str( ) );
130  if( !ifs.is_open( ) )
131  {
132  std::cerr << "\n Error: Cannot open input file " << prjname+std::string(".top") << std::endl;
133  std::cerr << "File: " << __FILE__ << std::endl;
134  std::cerr << "Line: " << __LINE__ << std::endl;
135  }
136 
137  std::getline( ifs, dummyline );
138  std::getline( ifs, dummyline );
139 
140  ifs >> numberOfBlocks;
141  std::getline( ifs, dummyline );
142 
143  for( int i=1; i <= numberOfBlocks; ++i )
144  ofs << i << " 0 0\n";
145 
146  int blockidx,bc,npatches;
147  for( int i=0; i < numberOfBlocks; ++i )
148  {
149  ifs >> blockidx;
150  std::getline( ifs, dummyline );
151  ifs >> npatches;
152  std::getline( ifs, dummyline );
153 
154  for( int j=0; j < npatches; ++j )
155  {
156  ifs >> bc;
157  std::getline( ifs, dummyline );
158  if( bc == bndrycondition )
159  ofs << blockidx << " 0\n";
160  }
161  }
162 
163  ofs.close( );
164  ifs.close( );
165 
166 }
int bndrycondition
The boundary condition corresponding to an injecting surface.
Definition: plagprep.C:42
std::string outputfile
Output file to write the file.
Definition: hdf2pltV2.C:55
blockLoc i
Definition: read.cpp:79
int numberOfBlocks
Definition: plagprep.C:35
j indices j
Definition: Indexing.h:6
std::string prjname
&lt;
Definition: plagprep.C:29

Here is the caller graph for this function:

void showUsage ( )

Displays usage information for this utility.

Variable Documentation

int bndrycondition

The boundary condition corresponding to an injecting surface.

Supplied by the user and represents the boundary condition that will be searched in the prjname.top file.

Definition at line 42 of file plagprep.C.

Referenced by main(), parseCmdParameters(), and searchTopFile().

int numberOfBlocks

Definition at line 35 of file plagprep.C.

Referenced by parseCmdParameters(), and searchTopFile().

std::string outputfile

The number of blocks, read from the *.top file.

Definition at line 32 of file plagprep.C.

std::string prjname

<

The project name, supplied by the user. The output file, computed based on prjname.

Definition at line 29 of file plagprep.C.

Referenced by main(), parseCmdParameters(), and searchTopFile().