[cig-commits] r11571 - cs/benchmark/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Wed Mar 26 08:02:25 PDT 2008
Author: luis
Date: 2008-03-26 08:02:25 -0700 (Wed, 26 Mar 2008)
New Revision: 11571
Modified:
cs/benchmark/cigma/trunk/src/Field.cpp
cs/benchmark/cigma/trunk/src/Field.h
Log:
Moved NewField() factory method into Field.{h,cpp}
Modified: cs/benchmark/cigma/trunk/src/Field.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/Field.cpp 2008-03-26 15:02:24 UTC (rev 11570)
+++ cs/benchmark/cigma/trunk/src/Field.cpp 2008-03-26 15:02:25 UTC (rev 11571)
@@ -1,10 +1,68 @@
+#include <string>
#include <cassert>
+
#include "Field.h"
-cigma::Field::~Field() {};
+#include "NullField.h"
+#include "FE_Field.h"
+#include "PointField.h"
-void cigma::Field::eval(Points &domain, Points &range)
+#include "StringUtils.h"
+#include "PathUtils.h"
+#include "HdfAttr.h"
+
+
+using namespace std;
+using namespace cigma;
+
+
+// ---------------------------------------------------------------------------
+
+Field *NewField(const char *src)
{
+ string fieldPath = src;
+ string fieldLoc, fieldFile, fieldExt;
+ parse_dataset_path(fieldPath, fieldLoc, fieldFile, fieldExt);
+
+ //
+ // At this point, we need to decide what kind of field object we'll be
+ // creating. For the most part, we will use a FE_Field, but we'll use
+ // metadata attributes in HDF5 files to instantiate other types of fields.
+ //
+ if (HdfExtension(fieldExt.c_str()))
+ {
+ // make sure that fieldFile is an HDF5 file (use IsHdfFile())
+ // read attribute from fieldLoc to distinguish between FE_Field and PointField
+ // (use HdfAttr::get_string())
+ return new FE_Field();
+ //return new PointField();
+ }
+
+ if (VtkExtension(fieldExt.c_str()))
+ {
+ // make sure that fieldFile is a VTK file (use IsVtkFile())
+ return new FE_Field();
+ }
+
+ if (TextExtension(fieldExt.c_str()))
+ {
+ // assume text file contains dofs for a FE_Field
+ return new FE_Field();
+ }
+
+ return new NullField();
+}
+
+
+// ---------------------------------------------------------------------------
+
+Field::~Field() {};
+
+
+// ---------------------------------------------------------------------------
+
+void Field::eval(Points &domain, Points &range)
+{
assert(domain.n_points() == range.n_points());
for (int i = 0; i < domain.n_points(); i++)
{
@@ -14,3 +72,4 @@
}
}
+// ---------------------------------------------------------------------------
Modified: cs/benchmark/cigma/trunk/src/Field.h
===================================================================
--- cs/benchmark/cigma/trunk/src/Field.h 2008-03-26 15:02:24 UTC (rev 11570)
+++ cs/benchmark/cigma/trunk/src/Field.h 2008-03-26 15:02:25 UTC (rev 11571)
@@ -35,5 +35,7 @@
virtual ~Field();
};
+cigma::Field *NewField(const char *src);
+
#endif
More information about the cig-commits
mailing list