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

luis at geodynamics.org luis at geodynamics.org
Wed Feb 20 09:08:37 PST 2008


Author: luis
Date: 2008-02-20 09:08:36 -0800 (Wed, 20 Feb 2008)
New Revision: 11203

Modified:
   cs/benchmark/cigma/trunk/src/ResidualField.cpp
   cs/benchmark/cigma/trunk/src/ResidualField.h
Log:
Moved global_error accumulator into cigma::ResidualField class


Modified: cs/benchmark/cigma/trunk/src/ResidualField.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/ResidualField.cpp	2008-02-20 17:08:34 UTC (rev 11202)
+++ cs/benchmark/cigma/trunk/src/ResidualField.cpp	2008-02-20 17:08:36 UTC (rev 11203)
@@ -1,5 +1,6 @@
 #include <iostream>
 #include <string>
+#include <cmath>
 #include "ResidualField.h"
 #include "VtkWriter.h"
 
@@ -31,6 +32,36 @@
 
 // ---------------------------------------------------------------------------
 
+void cigma::ResidualField::zero_out()
+{
+    assert(nel > 0);
+    assert(epsilon != 0);
+
+    global_error = 0.0;
+
+    for (int e = 0; e < nel; e++)
+    {
+        epsilon[e] = 0.0;
+    }
+}
+
+void cigma::ResidualField::update(int e, double cell_residual)
+{
+    // remember residual on this cell
+    epsilon[e] = cell_residual;
+
+    // XXX: this would generalize into global_error = norm_sum(global_error, cell_residual)
+    global_error += cell_residual;
+
+}
+
+double cigma::ResidualField::L2()
+{
+    return sqrt(global_error); // XXX: generalize to norm_pow(global_error)
+}
+
+// ---------------------------------------------------------------------------
+
 void cigma::ResidualField::write_vtk(const char *filename)
 {
     assert(meshPart != 0); // XXX: add support for dumping residuals w/o mesh

Modified: cs/benchmark/cigma/trunk/src/ResidualField.h
===================================================================
--- cs/benchmark/cigma/trunk/src/ResidualField.h	2008-02-20 17:08:34 UTC (rev 11202)
+++ cs/benchmark/cigma/trunk/src/ResidualField.h	2008-02-20 17:08:36 UTC (rev 11203)
@@ -22,11 +22,17 @@
     void set_mesh(MeshPart *meshPart);
 
 public:
+    void zero_out();
+    void update(int e, double cell_residual);
+    double L2();
+
+public:
     void write_vtk(const char *filename);
 
 public:
     int nel;
     double *epsilon;
+    double global_error;
     MeshPart *meshPart;
 };
 



More information about the cig-commits mailing list