[cig-commits] r9198 - cs/benchmark/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Wed Jan 30 16:18:55 PST 2008


Author: luis
Date: 2008-01-30 16:18:55 -0800 (Wed, 30 Jan 2008)
New Revision: 9198

Modified:
   cs/benchmark/cigma/trunk/src/CompareCmd.cpp
   cs/benchmark/cigma/trunk/src/CompareCmd.h
   cs/benchmark/cigma/trunk/src/Misc.cpp
   cs/benchmark/cigma/trunk/src/Misc.h
Log:
Moved input path parameters and loader functions into GenericIO subclasses


Modified: cs/benchmark/cigma/trunk/src/CompareCmd.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/CompareCmd.cpp	2008-01-31 00:18:53 UTC (rev 9197)
+++ cs/benchmark/cigma/trunk/src/CompareCmd.cpp	2008-01-31 00:18:55 UTC (rev 9198)
@@ -35,11 +35,11 @@
     residuals = 0; //XXX: create ResidualField class?
 
     // readers & writers
-    readerA = 0;
-    readerB = 0;
-    readerM = 0;
-    readerQ = 0;
-    writer = 0;
+    //readerA = 0;
+    //readerB = 0;
+    //readerM = 0;
+    //readerQ = 0;
+    //writer = 0;
 
     // parameters
     verbose = false;
@@ -101,13 +101,15 @@
     opt->setFlag("verbose");
 }
 
+
 void cigma::CompareCmd::configure(AnyOption *opt)
 {
     std::cout << "Calling cigma::CompareCmd::configure()" << std::endl;
 
-    std::string inputA, inputB;
-    std::string inputfileA, inputfileB;
-    std::string extA, extB;
+    //std::string inputA, inputB;
+    //std::string inputfileA, inputfileB;
+    //std::string extA, extB;
+
     std::string inputstr;
     char *in;
 
@@ -123,10 +125,10 @@
             exit(1);
         }
     }
-    inputA = in;
-    parse_dataset_path(inputA, locationA, inputfileA, extA);
-    load_reader(&readerA, extA);
-    readerA->open(inputfileA);
+    //inputA = in;
+    //parse_dataset_path(inputA, locationA, inputfileA, extA);
+    //load_reader(&readerA, extA);
+    //readerA->open(inputfileA);
 
 
     in = opt->getValue("second");
@@ -139,11 +141,13 @@
             exit(1);
         }
     }
-    inputB = in;
-    parse_dataset_path(inputB, locationB, inputfileB, extB);
-    load_reader(&readerB, extB);
-    readerB->open(inputfileB);
+    //inputB = in;
+    //parse_dataset_path(inputB, locationB, inputfileB, extB);
+    //load_reader(&readerB, extB);
+    //readerB->open(inputfileB);
 
+
+
     in = opt->getValue("output");
     if (in == 0)
     {
@@ -154,14 +158,15 @@
             exit(1);
         }
     }
-    string output_ext;
-    string output_fileroot;
-    output_filename = in;
-    path_splitext(output_filename, output_fileroot, output_ext);
-    load_writer(&writer, output_ext);
-    output_name = "epsilon";
+    //output_filename = in;
+    //string output_ext;
+    //string output_fileroot;
+    //path_splitext(output_filename, output_fileroot, output_ext);
+    //load_writer(&writer, output_ext);
+    //output_name = "epsilon";
 
 
+
     verbose = opt->getFlag("verbose");
 
     in = opt->getValue("output-frequency");
@@ -173,6 +178,7 @@
     string_to_int(inputstr, output_frequency);
 
 
+
     /*
      * Initialization order:
      *  Load Integration mesh
@@ -191,13 +197,15 @@
      *          Load Analytic Field
      */
 
+    mesh = 0;
 
 
     field_a = new FE_Field();
+    firstFieldIO.load(field_a);
     //load_field(inputfileA, locationA, readerA, field_a);
-    std::cout << "first field location = " << locationA << std::endl;
-    std::cout << "first field inputfile = " << inputfileA << std::endl;
-    std::cout << "first field extension = " << extA << std::endl;
+    //std::cout << "first field location = " << locationA << std::endl;
+    //std::cout << "first field inputfile = " << inputfileA << std::endl;
+    //std::cout << "first field extension = " << extA << std::endl;
     std::cout << "first field dimensions = "
               << field_a->meshPart->nel << " cells, "
               << field_a->meshPart->nno << " nodes, " 
@@ -205,17 +213,18 @@
               << field_a->n_rank() << std::endl;
 
     field_b = new FE_Field();
+    secondFieldIO.load(field_b);
     //load_field(inputfileB, locationB, readerB, field_b);
-    std::cout << "second field location = " << locationB << std::endl;
-    std::cout << "second field inputfile = " << inputfileB << std::endl;
-    std::cout << "second field extension = " << extB << std::endl;
+    //std::cout << "second field location = " << locationB << std::endl;
+    //std::cout << "second field inputfile = " << inputfileB << std::endl;
+    //std::cout << "second field extension = " << extB << std::endl;
     std::cout << "second field dimensions = "
               << field_b->meshPart->nel << " cells, "
               << field_b->meshPart->nno << " nodes, " 
               << field_b->fe->cell->n_nodes() << " dofs/cell, rank "
               << field_b->n_rank() << std::endl;
 
-    std::cout << "outputfile = " << output_filename << std::endl;
+    //std::cout << "outputfile = " << output_filename << std::endl;
 
 
     /* if no mesh specified, get it from fieldA
@@ -224,12 +233,13 @@
      * if fieldA still has no mesh, then produce error if no mesh
      * was specified to begin with.
      */
-    mesh = field_a->meshPart;
-    quadrature = field_a->fe->quadrature;
+    //mesh = field_a->meshPart;
+    //quadrature = field_a->fe->quadrature;
 
     return;
 }
 
+
 int cigma::CompareCmd::run()
 {
     std::cout << "Calling cigma::CompareCmd::run()" << std::endl;
@@ -239,7 +249,7 @@
     assert(field_b != 0);
     assert(field_a->n_dim() == field_a->n_dim());
     assert(field_a->n_rank() == field_b->n_rank());
-    assert(writer != 0);
+    //assert(writer != 0);
 
 
     Cell *cell_a = field_a->fe->cell;
@@ -367,9 +377,10 @@
         residuals->dofHandler->ndim = 1;
         residuals->dofHandler->dofs = epsilon;
 
-        writer->open(output_filename);
-        writer->write_field(residuals);
-        writer->close();
+        residualsIO.save(residuals);
+        //writer->open(output_filename);
+        //writer->write_field(residuals);
+        //writer->close();
     }
 
 
@@ -395,8 +406,10 @@
         //delete writer;
     } // */
 
+
     /* clean up */
     delete [] epsilon;
 
+
     return 0;
 }

Modified: cs/benchmark/cigma/trunk/src/CompareCmd.h
===================================================================
--- cs/benchmark/cigma/trunk/src/CompareCmd.h	2008-01-31 00:18:53 UTC (rev 9197)
+++ cs/benchmark/cigma/trunk/src/CompareCmd.h	2008-01-31 00:18:55 UTC (rev 9198)
@@ -7,6 +7,7 @@
 #include "FE_Field.h"
 #include "Writer.h"
 #include "Reader.h"
+#include "Misc.h"
 
 namespace cigma
 {
@@ -34,18 +35,27 @@
     FE_Field *field_a;
     FE_Field *field_b;
     FE_Field *residuals;
-    Reader *readerA;
-    Reader *readerB;
-    Reader *readerQ;
-    Reader *readerM;
-    Writer *writer;
 
 public:
-    std::string locationA;
-    std::string locationB;
-    std::string locationQ;
-    std::string locationM;
-    std::string output_filename, output_name;
+    MeshIO meshIO;
+    QuadratureIO quadratureIO;
+    FieldIO firstFieldIO;
+    FieldIO secondFieldIO;
+    FieldIO residualsIO;
+
+    //Reader *readerA;
+    //Reader *readerB;
+    //Reader *readerQ;
+    //Reader *readerM;
+    //Writer *writer;
+
+    //std::string locationA;
+    //std::string locationB;
+    //std::string locationQ;
+    //std::string locationM;
+    //std::string output_filename, output_name;
+
+public:
     bool verbose;
     int output_frequency;
 };

Modified: cs/benchmark/cigma/trunk/src/Misc.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/Misc.cpp	2008-01-31 00:18:53 UTC (rev 9197)
+++ cs/benchmark/cigma/trunk/src/Misc.cpp	2008-01-31 00:18:55 UTC (rev 9198)
@@ -84,14 +84,35 @@
 
 }
 
-void load_quadrature(Quadrature *quadrature,
-                     Cell *cell,
-                     Reader *reader,
-                     string arg_quadrature_path,
-                     string arg_points_loc,
-                     string arg_weights_loc,
-                     string arg_order)
+
+// ---------------------------------------------------------------------------
+
+void MeshIO::load(cigma::MeshPart *meshPart)
 {
+    assert(meshPart != 0);
+
+    switch (reader->getType())
+    {
+    case Reader::HDF_READER:
+        break;
+
+    case Reader::TXT_READER:
+        break;
+
+    case Reader::VTK_READER:
+        break;
+
+    default:
+        break;
+    }
+}
+
+
+
+// ---------------------------------------------------------------------------
+
+void QuadratureIO::load(cigma::Quadrature *quadrature, cigma::Cell *cell)
+{
     assert(quadrature != 0);
     assert(cell != 0);
 
@@ -223,39 +244,11 @@
     assert(quadrature->n_globaldim() > 0);
 }
 
-void load_mesh(MeshPart *meshPart,
-               Reader *reader,
-               string mesh_path,
-               string coords_loc,
-               string connect_loc)
-{
-    assert(meshPart != 0);
 
-    switch (reader->getType())
-    {
-    case Reader::HDF_READER:
-        break;
 
-    case Reader::TXT_READER:
-        break;
+// ---------------------------------------------------------------------------
 
-    case Reader::VTK_READER:
-        break;
-
-    default:
-        break;
-    }
-}
-
-
-void load_field(FE_Field *field,
-                MeshPart *meshPart,
-                Reader *fieldReader,
-                Reader *meshReader,
-                string field_path,
-                string mesh_path,
-                string coords_path,
-                string connect_path)
+void FieldIO::load(cigma::FE_Field *field)
 {
 
     int nno, nsd;
@@ -286,7 +279,7 @@
      * For detecting the filetype, one could rely only on the extension,
      * or possibly check for a magic number at the beginning of the file.
      */
-    switch (fieldReader->getType())
+    switch (reader->getType())
     {
     case Reader::HDF_READER:
         //XXX: cast to HdfReader
@@ -413,3 +406,12 @@
     return;
 }
 
+
+
+void FieldIO::save(cigma::FE_Field *field)
+{
+    assert(field != 0);
+}
+
+
+// ---------------------------------------------------------------------------

Modified: cs/benchmark/cigma/trunk/src/Misc.h
===================================================================
--- cs/benchmark/cigma/trunk/src/Misc.h	2008-01-31 00:18:53 UTC (rev 9197)
+++ cs/benchmark/cigma/trunk/src/Misc.h	2008-01-31 00:18:55 UTC (rev 9198)
@@ -16,12 +16,87 @@
 #include "FE_Field.h"
 #include "Reader.h"
 #include "Writer.h"
+#include "AnyOption.h"
 
 
+/*
+ * Misc Classes
+ *
+ */
+
+class GeneralIO
+{
+public:
+    cigma::Reader *reader;
+    cigma::Writer *writer;
+
+public:
+    GeneralIO()
+    {
+        reader = 0;
+        writer = 0;
+    }
+};
+
+class MeshIO : public GeneralIO
+{
+public:
+    std::string filename;
+    std::string mesh_path;
+    std::string coords_path;
+    std::string connect_path;
+
+public:
+    void load(cigma::MeshPart *meshPart);
+};
+
+
+class QuadratureIO : public GeneralIO
+{
+public:
+    std::string filename;
+    std::string quadrature_order;
+    std::string quadrature_path;
+    std::string points_path;
+    std::string weights_path;
+
+public:
+    void load(cigma::Quadrature *quadrature, cigma::Cell *cell);
+};
+
+
+
+class FieldIO : public GeneralIO
+{
+public:
+    std::string filename;
+    std::string dofs_path;
+
+public:
+    MeshIO meshIO;
+    QuadratureIO quadratureIO;
+
+public:
+    void load(cigma::FE_Field *field);
+    void save(cigma::FE_Field *field);
+};
+
+
+/* 
+ * Misc Methods
+ *
+ */
+
 double pick_from_interval(double a, double b);
 void bbox_random_point(double minpt[3], double maxpt[3], double x[3]);
 
 
+void load_reader(cigma::Reader **reader, std::string ext);
+void load_writer(cigma::Writer **writer, std::string ext);
+
+
+
+/*
 void load_mesh();
 void load_quadrature();
 void load_quadrature(cigma::Cell *cell, cigma::Quadrature *quadrature);
@@ -32,12 +107,9 @@
 
 
 
-void load_reader(cigma::Reader **reader, std::string ext);
-void load_writer(cigma::Writer **writer, std::string ext);
 
 
 
-
 void load_mesh(cigma::MeshPart *meshPart,
                cigma::Reader *reader,
                std::string mesh_path,
@@ -61,5 +133,6 @@
                 std::string mesh_path,
                 std::string coords_path,
                 std::string connect_path);
+*/
 
 #endif



More information about the cig-commits mailing list