[cig-commits] r9297 - cs/benchmark/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Wed Feb 13 01:51:19 PST 2008
Author: luis
Date: 2008-02-13 01:51:19 -0800 (Wed, 13 Feb 2008)
New Revision: 9297
Added:
cs/benchmark/cigma/trunk/src/FieldIO.cpp
cs/benchmark/cigma/trunk/src/FieldIO.h
Log:
Moved FieldIO out of Misc.{h,cpp}
Added: cs/benchmark/cigma/trunk/src/FieldIO.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/FieldIO.cpp (rev 0)
+++ cs/benchmark/cigma/trunk/src/FieldIO.cpp 2008-02-13 09:51:19 UTC (rev 9297)
@@ -0,0 +1,117 @@
+#include <iostream>
+#include "FieldIO.h"
+#include "AnnLocator.h"
+#include "StringUtils.h"
+#include "Misc.h"
+
+using namespace std;
+using namespace cigma;
+
+
+// ---------------------------------------------------------------------------
+
+
+void configure_field(AnyOption *opt, FieldIO *fieldIO, const char *opt_prefix)
+{
+ assert(opt != 0);
+ assert(fieldIO != 0);
+
+ char *in;
+ string field_name = opt_prefix;
+ string mesh_name = field_name + "-mesh";
+
+ in = opt->getValue(field_name.c_str());
+ if (in != 0)
+ {
+ fieldIO->field_path = in;
+ }
+
+ configure_mesh(opt, &(fieldIO->meshIO), mesh_name.c_str());
+
+}
+
+
+// ---------------------------------------------------------------------------
+
+
+FieldIO::FieldIO()
+{
+ field = 0;
+}
+
+
+FieldIO::~FieldIO()
+{
+ if (field != 0)
+ {
+ // XXX: traverse field structure and delete everything
+ }
+}
+
+
+// ---------------------------------------------------------------------------
+
+
+void FieldIO::load()
+{
+ cout << "Calling FieldIO::load()" << endl;
+
+ int dofs_nno, dofs_valdim;
+ double *dofs;
+
+ string dofs_loc, dofs_file, dofs_ext;
+
+ if (field_path != "")
+ {
+ parse_dataset_path(field_path, dofs_loc, dofs_file, dofs_ext);
+ new_reader(&reader, dofs_ext);
+ reader->open(dofs_file);
+ reader->get_dataset(dofs_loc.c_str(), &dofs, &dofs_nno, &dofs_valdim);
+ //reader->close();
+
+
+ if (meshIO.mesh_path == "")
+ {
+ meshIO.mesh_path = dofs_file;
+ }
+
+ meshIO.load();
+ assert(meshIO.meshPart != 0);
+
+
+ field = new FE_Field();
+
+ field->dim = meshIO.meshPart->nsd;
+ field->rank = dofs_valdim;
+
+ field->meshPart = meshIO.meshPart;
+ field->meshPart->set_cell();
+ assert(field->meshPart->cell != 0);
+
+ // XXX: Instantiate Locator only when necessary!
+ // XXX: Decide threshold based on number of elements?
+ if (field->meshPart->nel > 1000)
+ {
+ AnnLocator *locator = new AnnLocator();
+ field->meshPart->set_locator(locator);
+ }
+
+ field->dofHandler = new DofHandler();
+ field->dofHandler->set_data(dofs, dofs_nno, dofs_valdim);
+ }
+
+ return;
+}
+
+
+// ---------------------------------------------------------------------------
+
+
+void FieldIO::save()
+{
+ cout << "Calling FieldIO::save()" << endl;
+ assert(field != 0);
+ assert(false);
+}
+
+// ---------------------------------------------------------------------------
Added: cs/benchmark/cigma/trunk/src/FieldIO.h
===================================================================
--- cs/benchmark/cigma/trunk/src/FieldIO.h (rev 0)
+++ cs/benchmark/cigma/trunk/src/FieldIO.h 2008-02-13 09:51:19 UTC (rev 9297)
@@ -0,0 +1,32 @@
+#ifndef __FIELD_IO_H__
+#define __FIELD_IO_H__
+
+#include <string>
+#include "MeshIO.h"
+#include "QuadratureIO.h"
+#include "FE_Field.h"
+
+class FieldIO
+{
+public:
+ cigma::Reader *reader;
+ cigma::Writer *writer;
+
+public:
+ std::string field_path;
+ cigma::FE_Field *field;
+ MeshIO meshIO;
+ QuadratureIO quadratureIO;
+
+public:
+ FieldIO();
+ ~FieldIO();
+ void load();
+ void save();
+};
+
+
+void configure_field(AnyOption *opt, FieldIO *fieldIO, const char *opt_prefix);
+
+
+#endif
More information about the cig-commits
mailing list