[cig-commits] r9315 - cs/benchmark/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Wed Feb 13 12:23:10 PST 2008
Author: luis
Date: 2008-02-13 12:23:10 -0800 (Wed, 13 Feb 2008)
New Revision: 9315
Modified:
cs/benchmark/cigma/trunk/src/CompareCmd.cpp
cs/benchmark/cigma/trunk/src/FieldIO.cpp
cs/benchmark/cigma/trunk/src/FieldIO.h
Log:
Improvements to FieldIO
* Added field_option member (needed for error msgs)
* Setting field_option in load_args()
* Implemented validate_args()
* Outlined future changes to FieldIO::load()
Modified: cs/benchmark/cigma/trunk/src/CompareCmd.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/CompareCmd.cpp 2008-02-13 19:15:52 UTC (rev 9314)
+++ cs/benchmark/cigma/trunk/src/CompareCmd.cpp 2008-02-13 20:23:10 UTC (rev 9315)
@@ -139,30 +139,23 @@
if (opt->getFlag("debug"))
{
- // assign defaults if we're in debug mode
+ //
+ // assign defaults if we're in debug mode. this overrides
+ // the command line settings from load_args()
+ //
if (firstIO.field_path == "")
firstIO.field_path = "./tests/strikeslip_tet4_1000m_t0.vtk:displacements_t0";
+
if (secondIO.field_path == "")
secondIO.field_path = "./tests/strikeslip_hex8_1000m_t0.vtk:displacements_t0";
+
if (residualsIO.field_path == "")
residualsIO.field_path = "foo.vtk";
}
- if (residualsIO.field_path == "")
- {
- cerr << "compare: Please specify the option --output" << endl;
- exit(1);
- }
- if (firstIO.field_path == "")
- {
- cerr << "compare: Please specify the option --first" << endl;
- exit(1);
- }
- if (secondIO.field_path == "")
- {
- cerr << "compare: Please specify the option --second" << endl;
- exit(1);
- }
+ validate_args(&residualsIO, "compare");
+ validate_args(&firstIO, "compare");
+ validate_args(&secondIO, "compare");
validate_args(&meshIO, "compare");
validate_args(&quadratureIO, "compare");
@@ -240,7 +233,8 @@
if (output_frequency == 0)
{
- // XXX: emit warning?
+ // XXX: emit warning, or quit?
+ cerr << "compare: Warning: ignoring option --output-frequency" << endl;
verbose = false;
}
Modified: cs/benchmark/cigma/trunk/src/FieldIO.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/FieldIO.cpp 2008-02-13 19:15:52 UTC (rev 9314)
+++ cs/benchmark/cigma/trunk/src/FieldIO.cpp 2008-02-13 20:23:10 UTC (rev 9315)
@@ -16,10 +16,16 @@
assert(opt != 0);
assert(fieldIO != 0);
+ // remember the original option name
+ fieldIO->field_option = "--";
+ fieldIO->field_option += opt_prefix;
+
+ // deduce all implied command line options
char *in;
string field_name = opt_prefix;
string mesh_name = field_name + "-mesh";
+
in = opt->getValue(field_name.c_str());
if (in != 0)
{
@@ -30,7 +36,34 @@
}
+void validate_args(FieldIO *fieldIO, const char *cmd_name)
+{
+ assert(fieldIO != 0);
+ assert(fieldIO->field_option != "");
+ //
+ // Check for incompatible/inconsistent options
+ //
+
+ if (fieldIO->field_path == "")
+ {
+ cerr << cmd_name
+ << ": Please specify the option "
+ << fieldIO->field_option
+ << endl;
+ exit(1);
+ }
+
+ validate_args(&(fieldIO->meshIO), cmd_name);
+
+ // XXX: thinking about it...maybe Quadrature should be associated
+ // with a mesh, not with FE_Field. Of course, the field->fe object should
+ // only be initialized after we know which mesh to associate with
+ //validate_args(&(fieldIO->quadratureIO), cmd_name);
+
+
+}
+
// ---------------------------------------------------------------------------
@@ -63,6 +96,19 @@
if (field_path != "")
{
+ //
+ // XXX: How should one decide whether we need to instantiate
+ // FE_Field, PointField, or an ExternalField?
+ //
+
+
+ // XXX: for now, assume we are instantiating an FE_Field.
+ // note that we are also assuming that dofs_loc points to a dataset.
+ // if dofs_loc points to an HDF5 group, we'll need to read its metadata
+ // to determine how the data should be interpreted. even if dofs_loc
+ // is a dataset, we should check whether it has its mesh metadata
+ // properly set. lastly, the FunctionSpace attribute should always
+ // when reading from HDF5 files.
parse_dataset_path(field_path, dofs_loc, dofs_file, dofs_ext);
new_reader(&reader, dofs_ext);
reader->open(dofs_file);
@@ -72,6 +118,10 @@
if (meshIO.mesh_path == "")
{
+ // XXX: for now, assume that only --field-mesh is set,
+ // and that it points to a file...i think we also need to
+ // set coords_path and connect_path. lastly, don't forget
+ // about --field-mesh-coordinates and --field-mesh-connectivity.
meshIO.mesh_path = dofs_file;
}
Modified: cs/benchmark/cigma/trunk/src/FieldIO.h
===================================================================
--- cs/benchmark/cigma/trunk/src/FieldIO.h 2008-02-13 19:15:52 UTC (rev 9314)
+++ cs/benchmark/cigma/trunk/src/FieldIO.h 2008-02-13 20:23:10 UTC (rev 9315)
@@ -13,6 +13,7 @@
cigma::Writer *writer;
public:
+ std::string field_option;
std::string field_path;
cigma::FE_Field *field;
MeshIO meshIO;
@@ -27,6 +28,7 @@
void load_args(AnyOption *opt, FieldIO *fieldIO, const char *opt_prefix);
+void validate_args(FieldIO *fieldIO, const char *cmd_name);
#endif
More information about the cig-commits
mailing list