[cig-commits] r13824 - cs/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Mon Jan 12 14:09:46 PST 2009


Author: luis
Date: 2009-01-12 14:09:46 -0800 (Mon, 12 Jan 2009)
New Revision: 13824

Modified:
   cs/cigma/trunk/src/Function.cpp
   cs/cigma/trunk/src/core_writers.cpp
Log:
Reminder to use the "FunctionType" attribute in the Function object factory

Also, corrected the value of the RELATIVE_L2 attribute in WriteResiduals
(fixed call to output the L2 norm, not its squared value)

Modified: cs/cigma/trunk/src/Function.cpp
===================================================================
--- cs/cigma/trunk/src/Function.cpp	2009-01-12 22:09:44 UTC (rev 13823)
+++ cs/cigma/trunk/src/Function.cpp	2009-01-12 22:09:46 UTC (rev 13824)
@@ -39,6 +39,12 @@
     }
     else if (fn_info.field_info)
     {
+        // XXX: For HDF5 datasets, read the FunctionType attribute
+        // from the object residing at field_info. Depending on whether
+        // FunctionType is 'field', or 'points', then create the
+        // appropriate Function subclass (Field or PointwiseFn)
+        // For now, assume FunctionType attribute is 'field'.
+        // Note that VTK files always reutrn a Field object.
         shared_ptr<Field> field = Field::NewField(fn_info.field_info);
         fn = field;
     }

Modified: cs/cigma/trunk/src/core_writers.cpp
===================================================================
--- cs/cigma/trunk/src/core_writers.cpp	2009-01-12 22:09:44 UTC (rev 13823)
+++ cs/cigma/trunk/src/core_writers.cpp	2009-01-12 22:09:46 UTC (rev 13824)
@@ -229,6 +229,7 @@
                    << std::ends;
             throw cigma::Exception("WriteQuadrature", stream.str());
         }
+
     }
     else if (wt == FileWriter::VTK_FILE_WRITER)
     {
@@ -290,9 +291,24 @@
         Q->weights = 0;
         throw e;
     }
-
     Q->points = 0;
     Q->weights = 0;
+
+    // 
+    // Attach the appropriate metadata to our dataset so we can
+    // instantiate a PointwiseFn object the next time we read it
+    //
+    if (path.is_hdf5_file())
+    {
+        shared_ptr<FileWriter> writer = FileWriter::New(path.filename(), "a");
+        HDF5_Writer *h5 = dynamic_cast<HDF5_Writer*>(&(*writer));
+        if (h5)
+        {
+            string fn_type = "pointwise";
+            int status = write_scalar_attribute<string>(h5->file, path.location().c_str(), "FunctionType", fn_type);
+        }
+    }
+
 }
 
 void cigma::WriteDofs(const DataPath& path, shared_ptr<DofHandler> dofs)
@@ -302,9 +318,23 @@
 
     // XXX: Forward appropriate request to WriteArray
     throw cigma::Exception("WriteDofs", "Need implementation");
+
+    //
+    // Attach the appropriate metadata to our dataset so we can
+    // instantiate a Field object the next time we read it
+    //
+    if (path.is_hdf5_file())
+    {
+        shared_ptr<FileWriter> writer = FileWriter::New(path.filename(), "a");
+        HDF5_Writer *h5 = dynamic_cast<HDF5_Writer*>(&(*writer));
+        if (h5)
+        {
+            string fn_type = "field";
+            int status = write_scalar_attribute<string>(h5->file, path.location().c_str(), "FunctionType", fn_type);
+        }
+    }
 }
 
-
 // XXX: move this elsewhere
 static int vtkcelltype(Cell::type cellType)
 {
@@ -366,7 +396,7 @@
         }
 
         status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "L2_NORM", residuals->norm_L2());
-        status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "RELATIVE_L2", residuals->relative_squared_norm_L2());
+        status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "RELATIVE_L2", residuals->relative_norm_L2());
         status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "VOLUME", residuals->total_volume);
         status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "LINF_NORM", residuals->norm_Linf());
         status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "MAX_CELL_DIAMETER", residuals->max_cell_diameter());



More information about the CIG-COMMITS mailing list