[cig-commits] r14479 - in cs/cigma/trunk: . src
luis at geodynamics.org
luis at geodynamics.org
Fri Mar 27 06:04:09 PDT 2009
Author: luis
Date: 2009-03-27 06:04:08 -0700 (Fri, 27 Mar 2009)
New Revision: 14479
Added:
cs/cigma/trunk/src/fn_inclusion.cpp
cs/cigma/trunk/src/fn_inclusion.h
Removed:
cs/cigma/trunk/src/fn_gale2.cpp
cs/cigma/trunk/src/fn_gale2.h
Modified:
cs/cigma/trunk/Makefile.am
cs/cigma/trunk/src/FunctionRegistry.cpp
cs/cigma/trunk/src/cli_compare_cmd.cpp
cs/cigma/trunk/src/core_compare_op.cpp
cs/cigma/trunk/src/core_compare_op.h
cs/cigma/trunk/src/core_writers.cpp
Log:
Added benchmark::circular_inclusion::Velocity (testing it)
Also, global-error variables now become members in the
CompareOp command, and reporting only L2/sqrt(vol)
instead of L2/vol.
Modified: cs/cigma/trunk/Makefile.am
===================================================================
--- cs/cigma/trunk/Makefile.am 2009-03-27 12:16:21 UTC (rev 14478)
+++ cs/cigma/trunk/Makefile.am 2009-03-27 13:04:08 UTC (rev 14479)
@@ -301,8 +301,8 @@
# Finally, add other registered functions to libcigma.a
libcigma_la_sources += \
- src/fn_gale2.h \
- src/fn_gale2.cpp
+ src/fn_inclusion.h \
+ src/fn_inclusion.cpp
# }}}
Modified: cs/cigma/trunk/src/FunctionRegistry.cpp
===================================================================
--- cs/cigma/trunk/src/FunctionRegistry.cpp 2009-03-27 12:16:21 UTC (rev 14478)
+++ cs/cigma/trunk/src/FunctionRegistry.cpp 2009-03-27 13:04:08 UTC (rev 14479)
@@ -4,7 +4,7 @@
#include "fn_one.h"
#include "fn_test.h"
#include "fn_disloc3d.h"
-#include "fn_gale2.h"
+#include "fn_inclusion.h"
#include <cassert>
#include <iostream>
@@ -41,6 +41,10 @@
typedef benchmark::circular_inclusion::Pressure PressureFn1;
shared_ptr<PressureFn1> pressure1(new PressureFn1());
this->addFunction("bm.circular_inclusion.pressure", pressure1);
+
+ typedef benchmark::circular_inclusion::Velocity VelocityFn1;
+ shared_ptr<VelocityFn1> velocity1(new VelocityFn1());
+ this->addFunction("bm.circular_inclusion.velocity", velocity1);
}
// Destructor
Modified: cs/cigma/trunk/src/cli_compare_cmd.cpp
===================================================================
--- cs/cigma/trunk/src/cli_compare_cmd.cpp 2009-03-27 12:16:21 UTC (rev 14478)
+++ cs/cigma/trunk/src/cli_compare_cmd.cpp 2009-03-27 13:04:08 UTC (rev 14479)
@@ -283,11 +283,10 @@
int status = op.run();
/* gather results */
- double L2 = op.residuals->L2();
- double Linf = op.residuals->infinity_norm();
- double volume = op.residuals->mesh->getVolume();
- double L2_vol = L2/volume;
- double L2_sqrt_vol = L2/sqrt(volume);
+ double L2 = op.L2;
+ double Linf = op.Linf;
+ double volume = op.mesh_volume;
+ double L2_sqrt_vol = op.L2_sqrt_vol;
if (!vm.count("quiet"))
{
@@ -297,11 +296,10 @@
cout << endl;
cout << "Summary of comparison: " << endl;
- cout << indent << "L2 = " << L2 << endl;
- cout << indent << "Linf = " << Linf << endl;
- cout << indent << "volume = " << volume << endl;
- cout << indent << "L2/volume = " << L2_vol << endl;
- cout << indent << "L2/sqrt(volume) = " << L2_sqrt_vol << endl;
+ cout << indent << "L2 = " << op.L2 << endl;
+ cout << indent << "Linf = " << op.Linf << endl;
+ cout << indent << "volume = " << op.mesh_volume << endl;
+ cout << indent << "L2/sqrt(volume) = " << op.L2_sqrt_vol << endl;
if (h[1] > 0)
{
Modified: cs/cigma/trunk/src/core_compare_op.cpp
===================================================================
--- cs/cigma/trunk/src/core_compare_op.cpp 2009-03-27 12:16:21 UTC (rev 14478)
+++ cs/cigma/trunk/src/core_compare_op.cpp 2009-03-27 13:04:08 UTC (rev 14479)
@@ -7,6 +7,7 @@
#include <iostream>
#include <iomanip>
+#include <limits>
#include <cmath>
#include <cassert>
#include <string>
@@ -21,6 +22,11 @@
CompareOp::CompareOp()
{
+ double inf = std::numeric_limits<double>::infinity();
+ mesh_volume = inf;
+ L2 = inf;
+ L2_sqrt_vol = inf;
+ Linf = inf;
}
CompareOp::~CompareOp()
@@ -294,6 +300,13 @@
cout << timer.update(nel) << endl;
}
+ // summary
+ mesh_volume = mesh->getVolume();
+ Linf = residuals->infinity_norm();
+ L2 = residuals->L2();
+ L2_sqrt_vol = L2 / sqrt(mesh_volume);
+
+
delete [] vals1;
delete [] vals2;
delete [] qpts;
Modified: cs/cigma/trunk/src/core_compare_op.h
===================================================================
--- cs/cigma/trunk/src/core_compare_op.h 2009-03-27 12:16:21 UTC (rev 14478)
+++ cs/cigma/trunk/src/core_compare_op.h 2009-03-27 13:04:08 UTC (rev 14479)
@@ -36,6 +36,11 @@
boost::shared_ptr<Field> domain;
boost::shared_ptr<Residuals> residuals;
+ double mesh_volume;
+ double Linf;
+ double L2;
+ double L2_sqrt_vol;
+
};
#endif
Modified: cs/cigma/trunk/src/core_writers.cpp
===================================================================
--- cs/cigma/trunk/src/core_writers.cpp 2009-03-27 12:16:21 UTC (rev 14478)
+++ cs/cigma/trunk/src/core_writers.cpp 2009-03-27 13:04:08 UTC (rev 14479)
@@ -560,7 +560,6 @@
}
TRI_LOG(eps_loc);
- //int status = h5->writeDataset(eps_loc.c_str(), &(residuals->epsilon[0]), residuals->mesh->n_cells(), 1);
int status = h5->writeDataset(eps_loc.c_str(), &eps[0], eps.size(), 1);
TRI_LOG(status);
if (status < 0)
@@ -575,12 +574,10 @@
double volume = residuals->vol;
double Linf = residuals->infinity_norm();
double L2 = residuals->L2();
- //double L2_rel = residuals->relative_L2();
- double L2_vol = L2/volume;
+ double L2_sqrt_vol = L2/sqrt(volume);
status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "INFINITY_NORM", residuals->infinity_norm());
status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "L2_NORM", L2);
- //status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "L2_NORM_RELATIVE", L2_rel);
- status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "L2_NORM_BY_VOLUME", L2_vol);
+ status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "L2_NORM_BY_SQRT_VOLUME", L2_sqrt_vol);
status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "VOLUME", volume);
}
else if (wt == FileWriter::VTK_FILE_WRITER)
Deleted: cs/cigma/trunk/src/fn_gale2.cpp
===================================================================
--- cs/cigma/trunk/src/fn_gale2.cpp 2009-03-27 12:16:21 UTC (rev 14478)
+++ cs/cigma/trunk/src/fn_gale2.cpp 2009-03-27 13:04:08 UTC (rev 14479)
@@ -1,44 +0,0 @@
-#include "fn_gale2.h"
-//#include <iostream>
-//#include <typeinfo>
-#include <cmath>
-
-using namespace std;
-using namespace benchmark::circular_inclusion;
-
-Pressure::Pressure()
-{
- //cout << "Creating instance of class " << typeid(this).name() << endl;
-}
-
-Pressure::~Pressure()
-{
-}
-
-bool Pressure::eval(double *x, double *value)
-{
- const double R = 0.1;
- const double xc = 0.0;
- const double yc = 0.0;
-
- const double mu_m = 1;
- const double mu_i = 2;
- const double shear_mag = 1.0;
- const double C = 4 * shear_mag * (mu_m * (mu_i - mu_m) / (mu_i + mu_m)) * R * R;
-
- const double dx = x[0] - xc;
- const double dy = x[1] - yc;
- const double r2 = dx*dx + dy*dy;
-
- if (r2 < R*R)
- {
- value[0] = 0.0;
- }
- else
- {
- double theta = atan2(dy, dx);
- value[0] = (C/r2) * cos(2*theta);
- }
-
- return true;
-}
Deleted: cs/cigma/trunk/src/fn_gale2.h
===================================================================
--- cs/cigma/trunk/src/fn_gale2.h 2009-03-27 12:16:21 UTC (rev 14478)
+++ cs/cigma/trunk/src/fn_gale2.h 2009-03-27 13:04:08 UTC (rev 14479)
@@ -1,28 +0,0 @@
-#ifndef FN_GALE2_H
-#define FN_GALE2_H
-
-#include "Function.h"
-
-namespace benchmark
-{
- namespace circular_inclusion
- {
- class Pressure;
- }
-}
-
-class benchmark::circular_inclusion::Pressure : public cigma::Function
-{
-public:
- Pressure();
- ~Pressure();
-
- virtual int n_dim() const { return 2; }
- virtual int n_rank() const { return 1; }
- virtual bool eval(double *x, double *value);
-
- virtual void init() { }
- virtual FunctionType getType() const { return Function::GeneralType; }
-};
-
-#endif
Copied: cs/cigma/trunk/src/fn_inclusion.cpp (from rev 14473, cs/cigma/trunk/src/fn_gale2.cpp)
===================================================================
--- cs/cigma/trunk/src/fn_inclusion.cpp (rev 0)
+++ cs/cigma/trunk/src/fn_inclusion.cpp 2009-03-27 13:04:08 UTC (rev 14479)
@@ -0,0 +1,69 @@
+#include "fn_inclusion.h"
+//#include <iostream>
+//#include <typeinfo>
+#include <cmath>
+
+using namespace std;
+using namespace benchmark::circular_inclusion;
+
+bool Pressure::eval(double *x, double *value)
+{
+ const double R = 0.1;
+ const double xc = 0.0;
+ const double yc = 0.0;
+
+ const double mu_m = 1;
+ const double mu_i = 2;
+ const double mag_shear = 1.0;
+ const double C = 4 * mag_shear * (mu_m * (mu_i - mu_m) / (mu_i + mu_m)) * R * R;
+
+ const double dx = x[0] - xc;
+ const double dy = x[1] - yc;
+ const double r2 = dx*dx + dy*dy;
+
+ if (r2 < R*R)
+ {
+ value[0] = 0.0;
+ }
+ else
+ {
+ double theta = atan2(dy, dx);
+ value[0] = (C/r2) * cos(2*theta);
+ }
+
+ return true;
+}
+
+bool Velocity::eval(double *x, double *value)
+{
+ const double mu_m = 1;
+ const double mu_i = 2;
+ const double mag_shear = 1.0;
+ const double C = mag_shear * mu_m / (mu_m + mu_i);
+
+ value[0] = -2 * C * x[0];
+ value[1] = +2 * C * x[1];
+ value[3] = 0;
+
+ return true;
+}
+
+
+// ----------------------------------------------------------------------------
+
+Pressure::Pressure()
+{
+ //cout << "Creating instance of class " << typeid(this).name() << endl;
+}
+
+Pressure::~Pressure()
+{
+}
+
+Velocity::Velocity()
+{
+}
+
+Velocity::~Velocity()
+{
+}
Property changes on: cs/cigma/trunk/src/fn_inclusion.cpp
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cs/cigma/trunk/src/fn_inclusion.h (from rev 14473, cs/cigma/trunk/src/fn_gale2.h)
===================================================================
--- cs/cigma/trunk/src/fn_inclusion.h (rev 0)
+++ cs/cigma/trunk/src/fn_inclusion.h 2009-03-27 13:04:08 UTC (rev 14479)
@@ -0,0 +1,43 @@
+#ifndef FN_GALE2_H
+#define FN_GALE2_H
+
+#include "Function.h"
+
+namespace benchmark
+{
+ namespace circular_inclusion
+ {
+ class Pressure;
+ class Velocity;
+ }
+}
+
+class benchmark::circular_inclusion::Pressure : public cigma::Function
+{
+public:
+ Pressure();
+ ~Pressure();
+
+ virtual int n_dim() const { return 2; }
+ virtual int n_rank() const { return 1; }
+ virtual bool eval(double *x, double *value);
+
+ virtual void init() { }
+ virtual FunctionType getType() const { return Function::GeneralType; }
+};
+
+class benchmark::circular_inclusion::Velocity : public cigma::Function
+{
+public:
+ Velocity();
+ ~Velocity();
+
+ virtual int n_dim() const { return 2; }
+ virtual int n_rank() const { return 3; }
+ virtual bool eval(double *x, double *value);
+
+ virtual void init() { }
+ virtual FunctionType getType() const { return Function::GeneralType; }
+};
+
+#endif
Property changes on: cs/cigma/trunk/src/fn_inclusion.h
___________________________________________________________________
Name: svn:mergeinfo
+
More information about the CIG-COMMITS
mailing list