13 static std::string
cvar = LibUtilities::SessionReader::RegisterCmdLineFlag(
14 "CharateristicVariables",
"c",
"Output characteristic variables");
16 static std::string
SetToOneD = LibUtilities::SessionReader::RegisterCmdLineArgument(
"SetToOneSpaceDimension",
"1",
"Redefine mesh to be aligned to x-axis");
18 int main(
int argc,
char *argv[])
20 if((argc < 3)||(argc > 4))
22 fprintf(stderr,
"Usage: ./Fld2Tecplot [-c] file.xml file.fld\n");
38 char **newargv =
new char*[newargc];
41 newargv[1] =
new char[31];
42 strcpy(newargv[1],
"--SetToOneSpaceDimension=false");
44 for(
int i = 1; i < argc; ++i)
46 newargv[i+1] = argv[i];
50 session = LibUtilities::SessionReader::CreateInstance(newargc, newargv);
51 graph = SpatialDomains::MeshGraph::Read(session);
54 bool CalcCharacteristicVariables =
false;
56 if(session->DefinesCmdLineArgument(
cvar))
58 CalcCharacteristicVariables =
true;
63 session->LoadSolverInfo(
"Driver", vDriverModule,
"Standard");
69 if(!(PulseWave = std::dynamic_pointer_cast
72 ASSERTL0(
false,
"Failed to dynamically cast to PulseWaveSystemOutput");
75 std::string fname(argv[argc-1]);
78 int ndomains = PulseWave->GetNdomains();
80 PulseWave->ImportFldToMultiDomains(fname,Vessels = PulseWave->UpdateVessels(),
82 int fdot = fname.find_last_of(
'.');
84 if (fdot != std::string::npos)
86 string ending = fname.substr(fdot);
91 if (ending ==
".chk" || ending ==
".fld")
93 fname = fname.substr(0,fdot);
97 fname = fname +
".dat";
99 ofstream outfile(fname.c_str());
100 int nvariables = session->GetVariables().size();
101 std::string var =
"";
103 for(j = 0; j < nvariables-1; ++j)
105 var += session->GetVariable(j) +
", ";
107 var += session->GetVariable(j);
109 if(CalcCharacteristicVariables)
111 var +=
", Char1, Char2";
114 Vessels[0]->WriteTecplotHeader(outfile,var);
116 for(
int n = 0; n < ndomains; ++n)
118 Vessels[n*nvariables]->WriteTecplotZone(outfile);
119 for(
int j = 0; j < nvariables; ++j)
121 Vessels[n*nvariables+j]->WriteTecplotField(outfile);
124 if(CalcCharacteristicVariables)
126 PulseWave->CalcCharacteristicVariables(n*nvariables);
128 for(
int j = 0; j < nvariables; ++j)
130 Vessels[n*nvariables+j]->WriteTecplotField(outfile);
133 Vessels[n*nvariables]->WriteTecplotConnectivity(outfile);
137 catch (
const std::runtime_error&)
141 catch (
const std::string& eStr)
143 cout <<
"Error: " << eStr << endl;
#define ASSERTL0(condition, msg)
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< Driver > DriverSharedPtr
A shared pointer to a Driver object.
Base class for unsteady solvers.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
static std::string SetToOneD
std::shared_ptr< PulseWaveSystem > PulseWaveSystemSharedPtr
DriverFactory & GetDriverFactory()
int main(int argc, char *argv[])
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.