61 void parseFieldNames(
const char * field_name_c_str, set<string> &field_names);
64 const set<string> & field_names,
int spaceDim);
66 int main(
int argc,
char *argv[])
74 const char *coll_name = NULL;
77 const char *field_name_c_str =
"ALL";
78 const char *pts_file_c_str =
"";
81 const char *out_file_c_str =
"";
84 args.
AddOption(&coll_name,
"-r",
"--root-file",
85 "Set the VisIt data collection root file prefix.",
true);
86 args.
AddOption(&cycle,
"-c",
"--cycle",
"Set the cycle index to read.");
87 args.
AddOption(&pts,
"-p",
"--points",
"List of points.");
88 args.
AddOption(&field_name_c_str,
"-fn",
"--field-names",
89 "List of field names to get values from.");
90 args.
AddOption(&pts_file_c_str,
"-pf",
"--point-file",
91 "Filename containing a list of points.");
92 args.
AddOption(&out_file_c_str,
"-o",
"--output-file",
109 if (dc.
Error() != DataCollection::NO_ERROR)
111 mfem::out <<
"Error loading VisIt data collection: " << coll_name << endl;
119 mfem::out <<
"Space Dimension: " << spaceDim << endl;
129 for (fields_t::const_iterator it = fields.begin(); it != fields.end(); ++it)
131 if (it != fields.begin()) {
mfem::out <<
", "; }
137 set<string> field_names;
142 for (set<string>::iterator it=field_names.begin();
143 it!=field_names.end(); it++)
150 int npts = pts.
Size() / spaceDim;
157 mfem::out <<
"Found " << nfound <<
" points." << endl;
160 if (strcmp(out_file_c_str,
"") != 0
166 ofs.open(out_file_c_str);
169 MFEM_ABORT(
"Failed to open output file: " << out_file_c_str <<
'\n');
178 mfem::out <<
"# Number of points\n" << nfound << endl;
180 for (
int e=0; e<elem_ids.Size(); e++)
182 if (elem_ids[e] >= 0)
185 for (
int d=0; d<spaceDim; d++)
191 for (fields_t::const_iterator it = fields.begin();
192 it != fields.end(); ++it)
194 if (field_names.find(
"ALL") != field_names.end() ||
195 field_names.find(it->first) != field_names.end())
197 if (it->second->VectorDim() == 1)
199 mfem::out <<
' ' << it->second->GetValue(elem_ids[e], ip[e]);
204 it->second->GetVectorValue(elem_ids[e], ip[e], val);
205 for (
int d=0; d<it->second->VectorDim(); d++)
215 if (ofs) { ofs.close(); }
222 string field_name_str(field_name_c_str);
225 for (string::iterator it=field_name_str.begin();
226 it!=field_name_str.end(); it++)
231 field_name.push_back(*it);
235 if (!field_name.empty())
237 field_names.insert(field_name);
241 else if (it == field_name_str.end() - 1)
243 field_name.push_back(*it);
244 field_names.insert(field_name);
248 field_name.push_back(*it);
251 if (field_names.size() == 0)
253 field_names.insert(
"ALL");
259 if (strcmp(pts_file_c_str,
"") == 0) {
return; }
261 ifstream ifs(pts_file_c_str);
265 MFEM_ABORT(
"Failed to open point file: " << pts_file_c_str <<
'\n');
271 MFEM_VERIFY(dim == spaceDim,
"Mismatch in mesh's space dimension "
272 "and point dimension.");
274 if (pts.
Size() > 0 && pts.
Size() % spaceDim == 0)
276 int size = pts.
Size() + n *
dim;
278 for (
int i=0; i<pts.
Size(); i++)
291 for (
int i=0; i<n; i++)
293 for (
int d=0; d<
dim; d++)
295 ifs >> pts[o + i * dim + d];
303 const set<string> & field_names,
int spaceDim)
309 for (fields_t::const_iterator it = fields.begin();
310 it != fields.end(); ++it)
312 if (field_names.find(
"ALL") != field_names.end() ||
313 field_names.find(it->first) != field_names.end())
320 mfem::out <<
"# Number of fields" << endl << nfields << endl;
322 mfem::out <<
"# \"Index\" \"Location\":" << spaceDim;
323 for (fields_t::const_iterator it = fields.begin();
324 it != fields.end(); ++it)
326 if (field_names.find(
"ALL") != field_names.end() ||
327 field_names.find(it->first) != field_names.end())
329 mfem::out <<
" \"" << it->first <<
"\":" << it->second->VectorDim();
337 for (fields_t::const_iterator it = fields.begin();
338 it != fields.end(); ++it)
340 if (field_names.find(
"ALL") != field_names.end() ||
341 field_names.find(it->first) != field_names.end())
343 mfem::out <<
" " << it->second->VectorDim();
void writeLegend(const DataCollection::FieldMapType &fields, const set< string > &field_names, int spaceDim)
double GetTime() const
Get physical time (for time-dependent simulations)
void SetSize(int s)
Resize the vector to size s.
const std::string & GetCollectionName() const
Get the name of the collection.
void parsePoints(int spaceDim, const char *pts_file_c_str, Vector &pts)
Data type dense matrix using column-major storage.
int Size() const
Returns the size of the vector.
int Error() const
Get the current error state.
int main(int argc, char *argv[])
double * GetData() const
Return a pointer to the beginning of the Vector data.
double GetTimeStep() const
Get the simulation time step (for time-dependent simulations)
A simple convenience class that calls MPI_Init() at construction and MPI_Finalize() at destruction...
void Swap(Vector &other)
Swap the contents of two Vectors.
void SetStream(std::ostream &out)
Replace the rdbuf() and tie() of the OutStream with that of out, enabling output. ...
const FieldMapType & GetFieldMap() const
Get a const reference to the internal field map.
int GetCycle() const
Get time cycle (for time-dependent simulations)
Data collection with VisIt I/O routines.
void parseFieldNames(const char *field_name_c_str, set< string > &field_names)
bool Root() const
Return true if WorldRank() == 0.
void PrintUsage(std::ostream &out) const
virtual void Load(int cycle_=0)
Load the collection based on its VisIt data (described in its root file)
int SpaceDimension() const
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
void Disable()
Disable output.
GFieldMap::MapType FieldMapType
void PrintOptions(std::ostream &out) const
Mesh * GetMesh()
Get a pointer to the mesh in the collection.
virtual int FindPoints(DenseMatrix &point_mat, Array< int > &elem_ids, Array< IntegrationPoint > &ips, bool warn=true, InverseElementTransformation *inv_trans=NULL)
Find the ids of the elements that contain the given points, and their corresponding reference coordin...
void pts(int iphi, int t, double x[])
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...