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[])
75 const char *coll_name = NULL;
78 const char *field_name_c_str =
"ALL";
79 const char *pts_file_c_str =
"";
82 const char *out_file_c_str =
"";
85 args.
AddOption(&coll_name,
"-r",
"--root-file",
86 "Set the VisIt data collection root file prefix.",
true);
87 args.
AddOption(&cycle,
"-c",
"--cycle",
"Set the cycle index to read.");
88 args.
AddOption(&pts,
"-p",
"--points",
"List of points.");
89 args.
AddOption(&field_name_c_str,
"-fn",
"--field-names",
90 "List of field names to get values from.");
91 args.
AddOption(&pts_file_c_str,
"-pf",
"--point-file",
92 "Filename containing a list of points.");
93 args.
AddOption(&out_file_c_str,
"-o",
"--output-file",
110 if (dc.
Error() != DataCollection::NO_ERROR)
112 mfem::out <<
"Error loading VisIt data collection: " << coll_name << endl;
120 mfem::out <<
"Space Dimension: " << spaceDim << endl;
130 for (fields_t::const_iterator it = fields.begin(); it != fields.end(); ++it)
132 if (it != fields.begin()) {
mfem::out <<
", "; }
138 set<string> field_names;
143 for (set<string>::iterator it=field_names.begin();
144 it!=field_names.end(); it++)
151 int npts = pts.
Size() / spaceDim;
158 mfem::out <<
"Found " << nfound <<
" points." << endl;
161 if (strcmp(out_file_c_str,
"") != 0
167 ofs.open(out_file_c_str);
170 MFEM_ABORT(
"Failed to open output file: " << out_file_c_str <<
'\n');
179 mfem::out <<
"# Number of points\n" << nfound << endl;
181 for (
int e=0; e<elem_ids.Size(); e++)
183 if (elem_ids[e] >= 0)
186 for (
int d=0; d<spaceDim; d++)
192 for (fields_t::const_iterator it = fields.begin();
193 it != fields.end(); ++it)
195 if (field_names.find(
"ALL") != field_names.end() ||
196 field_names.find(it->first) != field_names.end())
198 if (it->second->VectorDim() == 1)
200 mfem::out <<
' ' << it->second->GetValue(elem_ids[e], ip[e]);
205 it->second->GetVectorValue(elem_ids[e], ip[e], val);
206 for (
int d=0; d<it->second->VectorDim(); d++)
216 if (ofs) { ofs.close(); }
223 string field_name_str(field_name_c_str);
226 for (string::iterator it=field_name_str.begin();
227 it!=field_name_str.end(); it++)
232 field_name.push_back(*it);
236 if (!field_name.empty())
238 field_names.insert(field_name);
242 else if (it == field_name_str.end() - 1)
244 field_name.push_back(*it);
245 field_names.insert(field_name);
249 field_name.push_back(*it);
252 if (field_names.size() == 0)
254 field_names.insert(
"ALL");
260 if (strcmp(pts_file_c_str,
"") == 0) {
return; }
262 ifstream ifs(pts_file_c_str);
266 MFEM_ABORT(
"Failed to open point file: " << pts_file_c_str <<
'\n');
272 MFEM_VERIFY(dim == spaceDim,
"Mismatch in mesh's space dimension "
273 "and point dimension.");
275 if (pts.
Size() > 0 && pts.
Size() % spaceDim == 0)
277 int size = pts.
Size() + n *
dim;
279 for (
int i=0; i<pts.
Size(); i++)
292 for (
int i=0; i<n; i++)
294 for (
int d=0; d<
dim; d++)
296 ifs >> pts[o + i * dim + d];
304 const set<string> & field_names,
int spaceDim)
310 for (fields_t::const_iterator it = fields.begin();
311 it != fields.end(); ++it)
313 if (field_names.find(
"ALL") != field_names.end() ||
314 field_names.find(it->first) != field_names.end())
321 mfem::out <<
"# Number of fields" << endl << nfields << endl;
323 mfem::out <<
"# \"Index\" \"Location\":" << spaceDim;
324 for (fields_t::const_iterator it = fields.begin();
325 it != fields.end(); ++it)
327 if (field_names.find(
"ALL") != field_names.end() ||
328 field_names.find(it->first) != field_names.end())
330 mfem::out <<
" \"" << it->first <<
"\":" << it->second->VectorDim();
338 for (fields_t::const_iterator it = fields.begin();
339 it != fields.end(); ++it)
341 if (field_names.find(
"ALL") != field_names.end() ||
342 field_names.find(it->first) != field_names.end())
344 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.
void SetStream(std::ostream &os)
Replace the rdbuf() and tie() of the OutStream with that of os, enabling output.
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)
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void Swap(Vector &other)
Swap the contents of two Vectors.
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)
void PrintUsage(std::ostream &out) const
Print the usage message.
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)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
void Disable()
Disable output.
GFieldMap::MapType FieldMapType
void PrintOptions(std::ostream &out) const
Print the options.
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...
bool Good() const
Return true if the command line options were parsed successfully.