19 if((argc < 3)||(argc > 4))
21 fprintf(stderr,
"Usage: ./Fld2Tecplot [-c] file.xml file.fld\n");
36 char **newargv =
new char*[newargc];
39 newargv[1] =
new char[31];
40 strcpy(newargv[1],
"--SetToOneSpaceDimension=false");
42 for(
int i = 1; i < argc; ++i)
44 newargv[i+1] = argv[i];
48 session = LibUtilities::SessionReader::CreateInstance(newargc, newargv);
51 bool CalcCharacteristicVariables =
false;
53 if(session->DefinesCmdLineArgument(
cvar))
55 CalcCharacteristicVariables =
true;
60 session->LoadSolverInfo(
"Driver", vDriverModule,
"Standard");
66 if(!(PulseWave = boost::dynamic_pointer_cast
69 ASSERTL0(
false,
"Failed to dynamically cast to PulseWaveSystemOutput");
72 std::string fname(argv[argc-1]);
75 int ndomains = PulseWave->GetNdomains();
77 PulseWave->ImportFldToMultiDomains(fname,Vessels = PulseWave->UpdateVessels(),
79 int fdot = fname.find_last_of(
'.');
81 if (fdot != std::string::npos)
83 string ending = fname.substr(fdot);
88 if (ending ==
".chk" || ending ==
".fld")
90 fname = fname.substr(0,fdot);
94 fname = fname +
".dat";
96 ofstream outfile(fname.c_str());
97 int nvariables = session->GetVariables().size();
100 for(j = 0; j < nvariables-1; ++j)
102 var += session->GetVariable(j) +
", ";
104 var += session->GetVariable(j);
106 if(CalcCharacteristicVariables)
108 var +=
", Char1, Char2";
111 Vessels[0]->WriteTecplotHeader(outfile,var);
113 for(
int n = 0; n < ndomains; ++n)
115 Vessels[n*nvariables]->WriteTecplotZone(outfile);
116 for(
int j = 0; j < nvariables; ++j)
118 Vessels[n*nvariables+j]->WriteTecplotField(outfile);
121 if(CalcCharacteristicVariables)
123 PulseWave->CalcCharacteristicVariables(n*nvariables);
125 for(
int j = 0; j < nvariables; ++j)
127 Vessels[n*nvariables+j]->WriteTecplotField(outfile);
130 Vessels[n*nvariables]->WriteTecplotConnectivity(outfile);
134 catch (
const std::runtime_error&)
138 catch (
const std::string& eStr)
140 cout <<
"Error: " << eStr << endl;
boost::shared_ptr< PulseWaveSystem > PulseWaveSystemSharedPtr
#define ASSERTL0(condition, msg)
boost::shared_ptr< Driver > DriverSharedPtr
A shared pointer to a Driver object.
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
boost::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
Base class for unsteady solvers.
DriverFactory & GetDriverFactory()