1 #ifndef __EXAMPLE_PROGRAM_H__
8 #define __EXAMPLE_PROGRAM_H__
9 #ifdef _GRIDCONVERSION_PARALLEL_
16 namespace GridConversion {
40 namespace DriverProgram {
56 typedef IRAD::Global::GlobalObj<StackType,int,ProfilerType>
GlobalType;
57 #ifdef _GRIDCONVERSION_PARALLEL_
58 typedef IRAD::Comm::CommunicatorObject
CommType;
65 typedef IRAD::Global::ParallelGlobalObj<CommType,StackType,int,ProfilerType> PGlobalType;
79 : IRAD::Util::ComLineObject()
82 : IRAD::Util::ComLineObject(args)
91 AddOption(
'h',
"help");
93 AddOption(
'v',
"verbosity",1);
94 AddOption(
'o',
"output",2,
"filename");
95 AddArgument(
"grid input> <bc input",1);
96 AddHelp(
"help",
"Prints this long version of help.");
97 AddHelp(
"output",
"Specifies the name of the output file.");
98 std::ostringstream Ostr;
104 Ostr <<
"GridConversion requires two arguments in order:" << std::endl
106 <<
"su2 grid file> <bc file> where the su2 is a grid" << std::endl
108 <<
"analysis file output from Pointwise in Stanford format." << std::endl
110 <<
"The bc file indicates a Rocfrac boundary condition for "
111 <<
"each" << std::endl
112 <<
" domain." << std::endl
113 <<
" See the Grid Conversion User Manual for more "
114 <<
"information on" << std::endl
115 <<
" the formats of these two files" << std::endl;
116 AddArgHelp(
"grid input> <bc input",Ostr.str());
125 Ostr <<
"Main GridConversion program.";
126 _description.assign(Ostr.str());
142 #ifdef _GRIDCONVERSION_PARALLEL_
143 typedef IRAD::Global::Program<PGlobalType,ComLineType> ParallelProgramType;
238 std::vector< std::vector<unsigned int> >
domains;
245 std::vector< std::vector<int> >
edges;
269 int retval = SerialProgramType::Initialize();
270 if(!_command_line.GetOption(
"help").empty()){
271 std::ostringstream Ostr;
272 Ostr << _command_line.LongUsage() << std::endl;
277 std::ostringstream Ostr;
278 Ostr << _command_line.ErrorReport() << std::endl
279 << std::endl << _command_line.ShortUsage() << std::endl;
296 shapes[4] =
"quadrilateral";
297 shapes[5] =
"tetrahedron";
298 shapes[7] =
"triangular prism";
304 if(!_command_line.GetOption(
"quadratic").empty())
311 std::vector<std::string> args(_command_line.GetArgs());
316 std::string sverb(_command_line.GetOption(
"verbosity"));
317 if(sverb.empty() || sverb ==
".true.")
320 std::istringstream Vin(sverb);
328 std::ostringstream Ostr;
329 Ostr <<
"Configuration:" << std::endl
330 <<
"verbosity = " <<
verblevel << std::endl
331 <<
"input_name = " << input_name << std::endl
334 Ostr <<
"output file = " <<
output_name << std::endl;
351 SetOutStream(std::cout);
370 virtual int HigherOrderTets(SolverUtils::Mesh::Connectivity elemEdgeToElems,
384 #ifdef _GRIDCONVERSION_PARALLEL_
385 class ParallelProgram :
public ParallelProgramType
457 std::string output_name;
469 ParallelProgramType()
474 ParallelProgram(
int nargs,
char **args) :
475 ParallelProgramType(nargs,args)
482 this->_command_line.Copy(comline);
483 this->Init(_command_line.ProgramName(),incomm);
489 virtual int Initialize()
491 int retval = ParallelProgramType::Initialize();
493 if(!_command_line.GetOption(
"help").empty()){
494 std::ostringstream Ostr;
495 Ostr << _command_line.LongUsage() << std::endl;
500 std::ostringstream Ostr;
501 Ostr << _command_line.ErrorReport() << std::endl
502 << std::endl << _command_line.ShortUsage() << std::endl;
508 output_name = _command_line.GetOption(
"output");
511 std::vector<std::string> args(_command_line.GetArgs());
512 std::istringstream Istr(args[0]);
516 std::string sverb(_command_line.GetOption(
"verbosity"));
517 if(sverb.empty() || sverb ==
".true.")
520 std::istringstream Vin(sverb);
528 std::ostringstream Ostr;
529 Ostr <<
"Configuration:" << std::endl
530 <<
"verbosity = " << verblevel << std::endl
531 <<
"number of divisions = " << ndiv << std::endl;
532 if(!output_name.empty())
533 Ostr <<
"output file = " << output_name << std::endl;
543 int VerbLevel()
const {
return verblevel;};
547 virtual ~ParallelProgram() {
550 SetOutStream(std::cout);
571 template<
typename ProgramType>
578 MyProgram.ErrOut(
"Error in Program Initialization.\n");
584 MyProgram.StdOut(
"Calling RUN.\n");
586 MyProgram.ErrOut(
"Error in Program RUN method.\n");
590 std::ostringstream Ostr;
591 MyProgram.Report(Ostr);
592 MyProgram.StdOut(Ostr.str());
593 MyProgram.StdOut(
"Calling Finalize.\n");
595 if(MyProgram.Finalize()){
596 MyProgram.ErrOut(
"Error in Program Finalization.\n");
600 MyProgram.StdOut(
"All done.\n");
609 #ifdef _GRIDCONVERSION_PARALLEL_
610 inline double f(
double x)
622 return (4.0 / (1.0 + x*x));
627 typedef GridConversion::DriverProgram::ParallelProgram PEProgramType;
SerialProgram()
Default constructor.
IRAD::Profiler::ProfilerObj ProfilerType
Convenience type definition for Profiler object.
IRAD::Global::Program< GlobalType, ComLineType > SerialProgramType
Convenience type definition for the serial program.
virtual int WriteOutput()
This function writes the output grid file.
virtual int HigherOrderTets(SolverUtils::Mesh::Connectivity elemEdgeToElems, SolverUtils::Mesh::Connectivity nodesToDomains)
This function creates higher order tets from linear tets.
std::vector< std::vector< unsigned int > > domains
vector of vectors to hold the domains
int numDomains
number of domains in mesh
std::vector< std::vector< int > > elemBCs
vector to hold list of element bc values
void Initialize()
This is where the actual options and arguments are described.
virtual int ReadPatranInput()
This function parses a Patran format input file.
int numElemEdges
number of element edges in mesh
Implementation of the basic parts of the serial program example.
virtual int Initialize()
Initializes native data structures from commandline args.
virtual int Run()
This function implements the main function executed by the program.
virtual int ConnectivityMaps(SolverUtils::Mesh::Connectivity nodesToElems)
This function creates a few different connectivity maps that are needed.
std::vector< unsigned int > elemToElemEdges
map of elements to element edges
std::vector< unsigned int > elems
vector for holding element connectivies read from input
int numElems
number of elements in mesh
std::vector< std::vector< int > > edgeBCs
vector to hold list of edge bc flags
std::vector< std::vector< int > > elemsToDomains
vector to hold the domains for each element
DriverProgramComLine ComLineType
Convenience type definition for the Main comline object.
SerialProgram(int nargs, char **args)
Constructor designed to take the commandline args.
int verblevel
Verbosity level.
std::vector< std::vector< int > > nodeBCs
IRAD::Global::GlobalObj< StackType, int, ProfilerType > GlobalType
Convenience type definition for the serial global object.
int numNodesPerElemEdge
number of nodes per element edge
GridConversion::DriverProgram::SerialProgram SEProgramType
Convenience definition for serial program type.
std::string output_name
Name of file for output.
std::vector< std::string > shapes
vector to hold the element shapes (only used for Patran input format)
SolverUtils::Mesh::Connectivity nodesToDomains
std::ofstream Ouf
Outfile stream for output.
IRAD::Comm::CommunicatorObject CommType
Convenience typedef for CommunicatorObject.
The ComLineObject for the example programs.
int numNodesPerElem
number of nodes per element
std::vector< std::vector< int > > domainBCs
vector to hold list of domain bc flags
std::ifstream Inf
Infile stream for input.
virtual int ReadStanfordInput()
This function parses a Stanford format input file.
int Driver(int argc, char *argv[])
Unified driver for the example programs.
virtual ~SerialProgram()
Destructor.
std::vector< std::vector< int > > edges
vector of vectors to hold the edges
std::vector< std::vector< std::vector< double > > > domainBCValues
vector to hold list of domain bc values (these are different for each bc type - see the Rocfrac docum...
std::vector< std::vector< std::vector< double > > > edgeBCValues
vector to hold list of edge bc values (these are different for each bc type - see the Rocfrac documen...
std::vector< std::vector< unsigned int > > nodeToNode
vector for holding node to node map
int elemShape
integer to denote the shape of elements used in the mesh
std::vector< unsigned int > elemEdges
vector for holding element edges
int numNodes
number of nodes in mesh
std::string bc_input_name
Name of bc input file.
std::string input_name
Name of input file.
std::vector< double > nodes
vector for holding nodal coordinates read from input
std::string StackType
Convenience type definition for program stack.
DriverProgramComLine(const char *args[])
std::vector< std::vector< std::vector< double > > > elemBCValues
vector to hold list of element bc values (these are different for each bc type - see the Rocfrac docu...
int VerbLevel() const
Returns verbosity level.
std::vector< std::vector< std::vector< double > > > nodeBCValues
vector to hold list of node bc values (these are different for each bc type - see the Rocfrac documen...
bool quadratic
boolean for changing the elements to higher order