53{
54 if ((argc < 3) || (argc > 4))
55 {
56 fprintf(stderr, "Usage: ./Fld2Tecplot [-c] file.xml file.fld\n");
57 exit(1);
58 }
59
62 string vDriverModule;
64
65 try
66 {
67
68
69 int newargc = argc + 1;
70 char **newargv = new char *[newargc];
71
72 newargv[0] = argv[0];
73 newargv[1] = new char[31];
74 strcpy(newargv[1], "--SetToOneSpaceDimension=false");
75
76 for (int i = 1; i < argc; ++i)
77 {
78 newargv[i + 1] = argv[i];
79 }
80
81
82 session = LibUtilities::SessionReader::CreateInstance(newargc, newargv);
83 graph = SpatialDomains::MeshGraphIO::Read(session);
84 delete[] newargv;
85
86
87 session->LoadSolverInfo("Driver", vDriverModule, "Standard");
89
91
93 if (!(PulseWave = std::dynamic_pointer_cast<PulseWaveSystem>(EqSys)))
94 {
96 "Failed to dynamically cast to PulseWaveSystemOutput");
97 }
98
99 std::string fname(argv[argc - 1]);
101
102 int ndomains = PulseWave->GetNdomains();
103
104 PulseWave->ImportFldToMultiDomains(
105 fname, Vessels = PulseWave->UpdateVessels(), ndomains);
106 int fdot = fname.find_last_of('.');
107
108 if (fdot != std::string::npos)
109 {
110 string ending = fname.substr(fdot);
111
112
113
114
115 if (ending == ".chk" || ending == ".fld")
116 {
117 fname = fname.substr(0, fdot);
118 }
119 }
120
121 fname += ".dat";
122
123 ofstream outfile(fname.c_str());
124 int nvariables = session->GetVariables().size();
125 std::string var = "";
126 int j;
127 for (j = 0; j < nvariables - 1; ++j)
128 {
129 var += session->GetVariable(j) + ", ";
130 }
131 var += session->GetVariable(j);
132
133 Vessels[0]->WriteTecplotHeader(outfile, var);
134
135 for (int n = 0; n < ndomains; ++n)
136 {
137 Vessels[n * nvariables]->WriteTecplotZone(outfile);
138 for (int j = 0; j < nvariables; ++j)
139 {
140 Vessels[n * nvariables + j]->WriteTecplotField(outfile);
141 }
142
143 Vessels[n * nvariables]->WriteTecplotConnectivity(outfile);
144 }
145 }
146
147 catch (const std::runtime_error &)
148 {
149 return 1;
150 }
151 catch (const std::string &eStr)
152 {
153 cout << "Error: " << eStr << endl;
154 }
155
156 return 0;
157}
#define ASSERTL0(condition, msg)
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Driver > DriverSharedPtr
A shared pointer to a Driver object.
DriverFactory & GetDriverFactory()
std::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< PulseWaveSystem > PulseWaveSystemSharedPtr