[cig-commits] r13496 - cs/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Tue Dec 9 18:12:36 PST 2008
Author: luis
Date: 2008-12-09 18:12:36 -0800 (Tue, 09 Dec 2008)
New Revision: 13496
Added:
cs/cigma/trunk/src/core_readers.cpp
cs/cigma/trunk/src/core_readers.h
cs/cigma/trunk/src/core_writers.cpp
cs/cigma/trunk/src/core_writers.h
Log:
Added core_{readers,writers}.{h,cpp}
Added: cs/cigma/trunk/src/core_readers.cpp
===================================================================
--- cs/cigma/trunk/src/core_readers.cpp (rev 0)
+++ cs/cigma/trunk/src/core_readers.cpp 2008-12-10 02:12:36 UTC (rev 13496)
@@ -0,0 +1,169 @@
+#include "core_readers.h"
+#include "Exception.h"
+#include "io_file_reader.h"
+#include "nc_array.h"
+#include "eb_array.h"
+#include <string>
+#include "DataPath.h"
+
+using namespace std;
+using namespace cigma;
+using boost::shared_ptr;
+
+
+// ----------------------------------------------------------------------------
+
+/*
+ * Read a NodeCoordinates object on a given data path.
+ *
+ */
+shared_ptr<NodeCoordinates> cigma::ReadNodeCoordinates(const DataPath &nc_path)
+{
+ shared_ptr<NodeCoordinates> nc_ptr;
+
+ string filename = nc_path.filename();
+ string location = nc_path.location();
+ shared_ptr<FileReader> reader = FileReader::New(filename, "r");
+
+ /* dispatch on reader type */
+ const FileReader::ReaderType rt = reader->getReaderType();
+ if (rt == FileReader::HDF5_FILE_READER)
+ {
+ int status;
+ throw cigma::Exception("ReadNodeCoordinates", "Error in HDF5 reader");
+ }
+ else if (rt == FileReader::VTK_FILE_READER)
+ {
+ int status;
+ throw cigma::Exception("ReadNodeCoordinates", "Error in VTK reader");
+ }
+ else if (rt == FileReader::TEXT_FILE_READER)
+ {
+ shared_ptr<nc_array> nc(new nc_array);
+ int status = reader->getCoordinates(0, &(nc->coords), &(nc->nno), &(nc->nsd));
+ if (status < 0)
+ {
+ throw cigma::Exception("ReadNodeCoordinates", "error in text reader");
+ }
+ nc_ptr = nc;
+ }
+ else
+ {
+ throw cigma::Exception("ReadNodeCoordinates", "could not load data path");
+ }
+
+ return nc_ptr;
+}
+
+
+// ----------------------------------------------------------------------------
+
+
+shared_ptr<ElementBlock> cigma::ReadElementBlock(const DataPath& eb_path)
+{
+ shared_ptr<ElementBlock> eb_ptr;
+
+ string filename = eb_path.filename();
+ string location = eb_path.location();
+ shared_ptr<FileReader> reader = FileReader::New(filename, "r");
+
+ /* dispatch on reader type */
+ const FileReader::ReaderType rt = reader->getReaderType();
+ if (rt == FileReader::HDF5_FILE_READER)
+ {
+ int status;
+ throw cigma::Exception("ReadElementBlock", "Error in HDF5 reader");
+ }
+ else if (rt == FileReader::VTK_FILE_READER)
+ {
+ int status;
+ throw cigma::Exception("ReadElementBlock", "Error in VTK reader");
+ }
+ else if (rt == FileReader::TEXT_FILE_READER)
+ {
+ shared_ptr<eb_array> eb(new eb_array);
+ int status = reader->getConnectivity(0, &(eb->connect), &(eb->nel), &(eb->ndofs));
+ if (status < 0)
+ {
+ throw cigma::Exception("ReadElementBlock", "error in text reader");
+ }
+ eb_ptr = eb;
+ }
+
+ return eb_ptr;
+}
+
+
+// ----------------------------------------------------------------------------
+
+
+shared_ptr<DofHandler> cigma::ReadDofHandler(const DataPath& dofs_path)
+{
+ shared_ptr<DofHandler> dofs_ptr;
+
+ string filename = dofs_path.filename();
+ string location = dofs_path.location();
+ shared_ptr<FileReader> reader = FileReader::New(location, "r");
+
+ /* dispatch on reader type */
+ const FileReader::ReaderType rt = reader->getReaderType();
+ if (rt == FileReader::HDF5_FILE_READER)
+ {
+ int status;
+ throw cigma::Exception("ReadDofHandler", "Error in HDF5 reader");
+ }
+ else if (rt == FileReader::VTK_FILE_READER)
+ {
+ int status;
+ throw cigma::Exception("ReadDofHandler", "Error in VTK reader");
+ }
+ else if (rt == FileReader::TEXT_FILE_READER)
+ {
+ int status = reader->getDataset(0, &(dofs_ptr->dofs), &(dofs_ptr->nno), &(dofs_ptr->rank));
+ if (status < 0)
+ {
+ throw cigma::Exception("ReadDofHandler", "Error in text reader");
+ }
+ }
+
+ return dofs_ptr;
+}
+
+
+// ----------------------------------------------------------------------------
+
+
+/*
+shared_ptr<Quadrature> cigma::ReadQuadrature(const DataPath& quadrature, Cell::type cell)
+{
+ shared_ptr<Quadrature> q_ptr;
+ shared_ptr<FileReader> reader;
+ reader = FileReader::New(quadrature.filename(), "r");
+ return q_ptr;
+}
+
+shared_ptr<FE> cigma::ReadFE(const DataPath& fe)
+{
+ shared_ptr<FE> fe_ptr;
+ shared_ptr<FileReader> reader;
+ reader = FileReader::New(fe.filename(), "r");
+ return fe_ptr;
+}
+
+shared_ptr<MeshPart> cigma::ReadMeshPart(const DataPath& mesh)
+{
+ shared_ptr<MeshPart> mesh_ptr;
+ shared_ptr<FileReader> reader;
+ reader = FileReader::New(mesh.filename(), "r");
+ return mesh_ptr;
+}
+
+shared_ptr<Field> cigma::ReadField(const DataPath& field)
+{
+ shared_ptr<Field> field_ptr;
+ shared_ptr<FileReader> reader;
+ reader = FileReader::New(field.filename(), "r");
+ return field_ptr;
+}
+*/
+
Added: cs/cigma/trunk/src/core_readers.h
===================================================================
--- cs/cigma/trunk/src/core_readers.h (rev 0)
+++ cs/cigma/trunk/src/core_readers.h 2008-12-10 02:12:36 UTC (rev 13496)
@@ -0,0 +1,37 @@
+#ifndef __CIGMA_READERS_H__
+#define __CIGMA_READERS_H__
+
+#include <boost/shared_ptr.hpp>
+#include "NodeCoordinates.h"
+#include "ElementBlock.h"
+#include "MeshPart.h"
+#include "DofHandler.h"
+#include "Quadrature.h"
+#include "FE.h"
+#include "Field.h"
+#include "Cell.h"
+#include "DataPath.h"
+
+namespace cigma
+{
+ boost::shared_ptr<NodeCoordinates> ReadNodeCoordinates(const DataPath& nc_path);
+ boost::shared_ptr<ElementBlock> ReadElementBlock(const DataPath& eb_path);
+ boost::shared_ptr<DofHandler> ReadDofHandler(const DataPath& dofs_path);
+
+ /*
+ boost::shared_ptr<Quadrature> ReadQuadrature(const DataPath& quadrature, cigma::Cell::type cell);
+ boost::shared_ptr<FE> ReadFE(const DataPath& fe, cigma::Cell::type cell);
+
+ boost::shared_ptr<MeshPart> ReadMeshPart(const DataPath& mesh,
+ const DataPath& nc,
+ const DataPath& eb);
+
+ boost::shared_ptr<Field> ReadField(const DataPath& field,
+ const DataPath& dofs,
+ const DataPath& mesh,
+ const DataPath& nc,
+ const DataPath& eb);
+ */
+}
+
+#endif
Added: cs/cigma/trunk/src/core_writers.cpp
===================================================================
--- cs/cigma/trunk/src/core_writers.cpp (rev 0)
+++ cs/cigma/trunk/src/core_writers.cpp 2008-12-10 02:12:36 UTC (rev 13496)
@@ -0,0 +1,2 @@
+#include "core_writers.h"
+
Added: cs/cigma/trunk/src/core_writers.h
===================================================================
--- cs/cigma/trunk/src/core_writers.h (rev 0)
+++ cs/cigma/trunk/src/core_writers.h 2008-12-10 02:12:36 UTC (rev 13496)
@@ -0,0 +1,11 @@
+#ifndef __CIGMA_WRITERS_H__
+#define __CIGMA_WRITERS_H__
+
+#include <boost/shared_ptr.hpp>
+
+namespace cigma
+{
+ void WriteResiduals(boost::shared<Residuals> residuals, const DataPath& path);
+}
+
+#endif
More information about the CIG-COMMITS
mailing list