61void parseFieldNames(
const char * field_name_c_str, set<string> &field_names);
65 const set<string> & field_names,
int spaceDim);
68int main(
int argc,
char *argv[])
77 const char *coll_name = NULL;
79 int pad_digits_cycle = 6;
80 int pad_digits_rank = 6;
82 const char *field_name_c_str =
"ALL";
83 const char *pts_file_c_str =
"";
86 const char *out_file_c_str =
"";
89 args.
AddOption(&coll_name,
"-r",
"--root-file",
90 "Set the VisIt data collection root file prefix.",
true);
91 args.
AddOption(&cycle,
"-c",
"--cycle",
"Set the cycle index to read.");
92 args.
AddOption(&pad_digits_cycle,
"-pdc",
"--pad-digits-cycle",
93 "Number of digits in cycle.");
94 args.
AddOption(&pad_digits_rank,
"-pdr",
"--pad-digits-rank",
95 "Number of digits in MPI rank.");
96 args.
AddOption(&
pts,
"-p",
"--points",
"List of points.");
97 args.
AddOption(&field_name_c_str,
"-fn",
"--field-names",
98 "List of field names to get values from.");
99 args.
AddOption(&pts_file_c_str,
"-pf",
"--point-file",
100 "Filename containing a list of points.");
101 args.
AddOption(&out_file_c_str,
"-o",
"--output-file",
122 mfem::out <<
"Error loading VisIt data collection: " << coll_name << endl;
130 mfem::out <<
"Space Dimension: " << spaceDim << endl;
140 for (fields_t::const_iterator it = fields.begin(); it != fields.end(); ++it)
142 if (it != fields.begin()) {
mfem::out <<
", "; }
148 set<string> field_names;
153 for (set<string>::iterator it=field_names.begin();
154 it!=field_names.end(); it++)
161 int npts =
pts.Size() / spaceDim;
168 mfem::out <<
"Found " << nfound <<
" points." << endl;
171 if (strcmp(out_file_c_str,
"") != 0
177 ofs.open(out_file_c_str);
180 MFEM_ABORT(
"Failed to open output file: " << out_file_c_str <<
'\n');
189 mfem::out <<
"# Number of points\n" << nfound << endl;
191 for (
int e=0; e<elem_ids.
Size(); e++)
193 if (elem_ids[e] >= 0)
196 for (
int d=0; d<spaceDim; d++)
202 for (fields_t::const_iterator it = fields.begin();
203 it != fields.end(); ++it)
205 if (field_names.find(
"ALL") != field_names.end() ||
206 field_names.find(it->first) != field_names.end())
208 if (it->second->VectorDim() == 1)
210 mfem::out <<
' ' << it->second->GetValue(elem_ids[e], ip[e]);
215 it->second->GetVectorValue(elem_ids[e], ip[e], val);
216 for (
int d=0; d<it->second->VectorDim(); d++)
226 if (ofs) { ofs.close(); }
233 string field_name_str(field_name_c_str);
236 for (string::iterator it=field_name_str.begin();
237 it!=field_name_str.end(); it++)
242 field_name.push_back(*it);
246 if (!field_name.empty())
248 field_names.insert(field_name);
252 else if (it == field_name_str.end() - 1)
254 field_name.push_back(*it);
255 field_names.insert(field_name);
259 field_name.push_back(*it);
262 if (field_names.size() == 0)
264 field_names.insert(
"ALL");
270 if (strcmp(pts_file_c_str,
"") == 0) {
return; }
272 ifstream ifs(pts_file_c_str);
276 MFEM_ABORT(
"Failed to open point file: " << pts_file_c_str <<
'\n');
282 MFEM_VERIFY(
dim == spaceDim,
"Mismatch in mesh's space dimension "
283 "and point dimension.");
285 if (
pts.Size() > 0 &&
pts.Size() % spaceDim == 0)
287 int size =
pts.Size() + n *
dim;
289 for (
int i=0; i<
pts.Size(); i++)
302 for (
int i=0; i<n; i++)
304 for (
int d=0; d<
dim; d++)
306 ifs >>
pts[o + i *
dim + d];
314 const set<string> & field_names,
int spaceDim)
320 for (fields_t::const_iterator it = fields.begin();
321 it != fields.end(); ++it)
323 if (field_names.find(
"ALL") != field_names.end() ||
324 field_names.find(it->first) != field_names.end())
331 mfem::out <<
"# Number of fields" << endl << nfields << endl;
333 mfem::out <<
"# \"Index\" \"Location\":" << spaceDim;
334 for (fields_t::const_iterator it = fields.begin();
335 it != fields.end(); ++it)
337 if (field_names.find(
"ALL") != field_names.end() ||
338 field_names.find(it->first) != field_names.end())
340 mfem::out <<
" \"" << it->first <<
"\":" << it->second->VectorDim();
348 for (fields_t::const_iterator it = fields.begin();
349 it != fields.end(); ++it)
351 if (field_names.find(
"ALL") != field_names.end() ||
352 field_names.find(it->first) != field_names.end())
354 mfem::out <<
" " << it->second->VectorDim();
int Size() const
Return the logical size of the array.
const std::string & GetCollectionName() const
Get the name of the collection.
int GetCycle() const
Get time cycle (for time-dependent simulations)
virtual void SetPadDigitsRank(int digits)
Set the number of digits used for the MPI rank in filenames.
int Error() const
Get the current error state.
real_t GetTimeStep() const
Get the simulation time step (for time-dependent simulations)
const FieldMapType & GetFieldMap() const
Get a const reference to the internal field map.
Mesh * GetMesh()
Get a pointer to the mesh in the collection.
GFieldMap::MapType FieldMapType
virtual void SetPadDigitsCycle(int digits)
Set the number of digits used for the cycle.
real_t GetTime() const
Get physical time (for time-dependent simulations)
Data type dense matrix using column-major storage.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
int SpaceDimension() const
Dimension of the physical space containing the mesh.
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...
static bool Root()
Return true if the rank in MPI_COMM_WORLD is zero.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
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...
bool Good() const
Return true if the command line options were parsed successfully.
void SetStream(std::ostream &os)
Replace the rdbuf() and tie() of the OutStream with that of os, enabling output.
void Disable()
Disable output.
int Size() const
Returns the size of the vector.
Data collection with VisIt I/O routines.
virtual void Load(int cycle_=0) override
Load the collection based on its VisIt data (described in its root file)
void parsePoints(int spaceDim, const char *pts_file_c_str, Vector &pts)
void parseFieldNames(const char *field_name_c_str, set< string > &field_names)
void writeLegend(const DataCollection::FieldMapType &fields, const set< string > &field_names, int spaceDim)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
void pts(int iphi, int t, real_t x[])