{
if((argc < 3)||(argc > 4))
{
fprintf(stderr,"Usage: ./Fld2Tecplot [-c] file.xml file.fld\n");
exit(1);
}
string vDriverModule;
try
{
int newargc = argc+1;
char **newargv = new char*[newargc];
newargv[0] = argv[0];
newargv[1] = new char[30];
strcpy(newargv[1], "--SetToOneSpaceDimension=false");
for(int i = 1; i < argc; ++i)
{
newargv[i+1] = argv[i];
}
session = LibUtilities::SessionReader::CreateInstance(newargc, newargv);
delete[] newargv;
bool CalcCharacteristicVariables = false;
if(session->DefinesCmdLineArgument(
cvar))
{
CalcCharacteristicVariables = true;
}
session->LoadSolverInfo("Driver", vDriverModule, "Standard");
if(!(PulseWave = boost::dynamic_pointer_cast
{
ASSERTL0(
false,
"Failed to dynamically cast to PulseWaveSystemOutput");
}
std::string fname(argv[argc-1]);
Array<OneD, MultiRegions::ExpListSharedPtr> Vessels;
int ndomains = PulseWave->GetNdomains();
PulseWave->ImportFldToMultiDomains(fname,Vessels = PulseWave->UpdateVessels(),
ndomains);
int fdot = fname.find_last_of('.');
if (fdot != std::string::npos)
{
string ending = fname.substr(fdot);
if (ending == ".chk" || ending == ".fld")
{
fname = fname.substr(0,fdot);
}
}
fname = fname + ".dat";
ofstream outfile(fname.c_str());
int nvariables = session->GetVariables().size();
std::string var = "";
int j;
for(j = 0; j < nvariables-1; ++j)
{
var += session->GetVariable(j) + ", ";
}
var += session->GetVariable(j);
if(CalcCharacteristicVariables)
{
var += ", Char1, Char2";
}
Vessels[0]->WriteTecplotHeader(outfile,var);
for(int n = 0; n < ndomains; ++n)
{
Vessels[n*nvariables]->WriteTecplotZone(outfile);
for(int j = 0; j < nvariables; ++j)
{
Vessels[n*nvariables+j]->WriteTecplotField(outfile);
}
if(CalcCharacteristicVariables)
{
PulseWave->CalcCharacteristicVariables(n*nvariables);
for(int j = 0; j < nvariables; ++j)
{
Vessels[n*nvariables+j]->WriteTecplotField(outfile);
}
}
Vessels[n*nvariables]->WriteTecplotConnectivity(outfile);
}
}
catch (const std::runtime_error&)
{
return 1;
}
catch (const std::string& eStr)
{
cout << "Error: " << eStr << endl;
}
return 0;
}