52{
53 if ((argc < 3) || (argc > 4))
54 {
55 fprintf(stderr, "Usage: ./Fld2Tecplot [-c] file.xml file.fld\n");
56 exit(1);
57 }
58
61 string vDriverModule;
63
64 try
65 {
66
67
68 int newargc = argc + 1;
69 char **newargv = new char *[newargc];
70
71 newargv[0] = argv[0];
72 newargv[1] = new char[31];
73 strcpy(newargv[1], "--SetToOneSpaceDimension=false");
74
75 for (int i = 1; i < argc; ++i)
76 {
77 newargv[i + 1] = argv[i];
78 }
79
80
81 session = LibUtilities::SessionReader::CreateInstance(newargc, newargv);
82 graph = SpatialDomains::MeshGraph::Read(session);
83 delete[] newargv;
84
85
86 session->LoadSolverInfo("Driver", vDriverModule, "Standard");
88
90
92 if (!(PulseWave = std::dynamic_pointer_cast<PulseWaveSystem>(EqSys)))
93 {
95 "Failed to dynamically cast to PulseWaveSystemOutput");
96 }
97
98 std::string fname(argv[argc - 1]);
100
101 int ndomains = PulseWave->GetNdomains();
102
103 PulseWave->ImportFldToMultiDomains(
104 fname, Vessels = PulseWave->UpdateVessels(), ndomains);
105 int fdot = fname.find_last_of('.');
106
107 if (fdot != std::string::npos)
108 {
109 string ending = fname.substr(fdot);
110
111
112
113
114 if (ending == ".chk" || ending == ".fld")
115 {
116 fname = fname.substr(0, fdot);
117 }
118 }
119
120 fname += ".dat";
121
122 ofstream outfile(fname.c_str());
123 int nvariables = session->GetVariables().size();
124 std::string var = "";
125 int j;
126 for (j = 0; j < nvariables - 1; ++j)
127 {
128 var += session->GetVariable(j) + ", ";
129 }
130 var += session->GetVariable(j);
131
132 Vessels[0]->WriteTecplotHeader(outfile, var);
133
134 for (int n = 0; n < ndomains; ++n)
135 {
136 Vessels[n * nvariables]->WriteTecplotZone(outfile);
137 for (int j = 0; j < nvariables; ++j)
138 {
139 Vessels[n * nvariables + j]->WriteTecplotField(outfile);
140 }
141
142 Vessels[n * nvariables]->WriteTecplotConnectivity(outfile);
143 }
144 }
145
146 catch (const std::runtime_error &)
147 {
148 return 1;
149 }
150 catch (const std::string &eStr)
151 {
152 cout << "Error: " << eStr << endl;
153 }
154
155 return 0;
156}
#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