[cig-commits] r11517 - cs/benchmark/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Mon Mar 24 09:27:04 PDT 2008
Author: luis
Date: 2008-03-24 09:27:03 -0700 (Mon, 24 Mar 2008)
New Revision: 11517
Added:
cs/benchmark/cigma/trunk/src/ExtField.cpp
cs/benchmark/cigma/trunk/src/ExtField.h
cs/benchmark/cigma/trunk/src/Residuals.cpp
cs/benchmark/cigma/trunk/src/Residuals.h
Removed:
cs/benchmark/cigma/trunk/src/ExternalField.cpp
cs/benchmark/cigma/trunk/src/ExternalField.h
cs/benchmark/cigma/trunk/src/ResidualField.cpp
cs/benchmark/cigma/trunk/src/ResidualField.h
Log:
Renamed classes: ExternalField to ExtField, ResidualField to Residuals
Copied: cs/benchmark/cigma/trunk/src/ExtField.cpp (from rev 11516, cs/benchmark/cigma/trunk/src/ExternalField.cpp)
===================================================================
--- cs/benchmark/cigma/trunk/src/ExtField.cpp (rev 0)
+++ cs/benchmark/cigma/trunk/src/ExtField.cpp 2008-03-24 16:27:03 UTC (rev 11517)
@@ -0,0 +1,89 @@
+#include <iostream>
+#include <cstdlib>
+#include <dlfcn.h>
+#include <cassert>
+#include "ExternalField.h"
+
+// ---------------------------------------------------------------------------
+
+cigma::ExternalField::ExternalField()
+{
+ handle = 0;
+}
+
+cigma::ExternalField::~ExternalField()
+{
+ close_library();
+}
+
+// ---------------------------------------------------------------------------
+
+void cigma::ExternalField::load_library(std::string filename, std::string prefix)
+{
+ std::string function_name;
+ char *error;
+
+ //handle = dlopen(filename.c_str(), RTLD_LAZY);
+
+ handle = dlopen(filename.c_str(), RTLD_NOW);
+ error = dlerror();
+ if (!handle)
+ {
+ std::cerr << error << std::endl;
+ // XXX: throw exception
+ assert(false);
+ }
+
+ /* clear any existing error */
+ dlerror();
+
+ function_name = prefix + "_get_dim";
+ *(void **)(&ext_get_dim) = dlsym(handle, function_name.c_str());
+ error = dlerror();
+ if (error != NULL)
+ {
+ std::cerr << error << std::endl;
+ // XXX: throw exception
+ assert(false);
+ }
+
+ function_name = prefix + "_get_rank";
+ *(void **)(&ext_get_rank) = dlsym(handle, function_name.c_str());
+ error = dlerror();
+ if (error != NULL)
+ {
+ std::cerr << error << std::endl;
+ // XXX: throw exception
+ assert(false);
+ }
+
+ function_name = prefix + "_eval";
+ *(void **)(&ext_eval) = dlsym(handle, function_name.c_str());
+ error = dlerror();
+ if (error != NULL)
+ {
+ std::cerr << error << std::endl;
+ // XXX: throw exception
+ assert(false);
+ }
+
+ function_name = prefix + "_batch_eval";
+ *(void **)(&ext_batch_eval) = dlsym(handle, function_name.c_str());
+ error = dlerror();
+ if (error != NULL)
+ {
+ std::cerr << error << std::endl;
+ // XXX: throw exception
+ assert(false);
+ }
+}
+
+void cigma::ExternalField::close_library()
+{
+ if (handle != 0)
+ {
+ dlclose(handle);
+ }
+}
+
+// ---------------------------------------------------------------------------
Copied: cs/benchmark/cigma/trunk/src/ExtField.h (from rev 11516, cs/benchmark/cigma/trunk/src/ExternalField.h)
===================================================================
--- cs/benchmark/cigma/trunk/src/ExtField.h (rev 0)
+++ cs/benchmark/cigma/trunk/src/ExtField.h 2008-03-24 16:27:03 UTC (rev 11517)
@@ -0,0 +1,53 @@
+#ifndef __EXTERNAL_FIELD_H__
+#define __EXTERNAL_FIELD_H__
+
+#include <string>
+#include "Points.h"
+#include "Field.h"
+
+
+namespace cigma
+{
+ class ExternalField;
+}
+
+
+/**
+ * @brief External Field object
+ *
+ */
+class cigma::ExternalField : public Field
+{
+public:
+ typedef void (*get_int_fn)(int*);
+ typedef void (*eval_from_point_fn)(double*,double*);
+ typedef void (*eval_from_points_fn)(int,double*,double*);
+
+public:
+ ExternalField();
+ ~ExternalField();
+
+public:
+ int n_dim() { return dim; }
+ int n_rank() { return rank; }
+
+public:
+ void load_library(std::string filename, std::string prefix);
+ void close_library();
+
+public:
+ void eval(double *x, double *y);
+ void eval(Points &domain, Points &range);
+
+public:
+ int dim;
+ int rank;
+ void *handle;
+ get_int_fn ext_get_dim;
+ get_int_fn ext_get_rank;
+ eval_from_point_fn ext_eval;
+ eval_from_points_fn ext_batch_eval;
+};
+
+
+#endif
Deleted: cs/benchmark/cigma/trunk/src/ExternalField.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/ExternalField.cpp 2008-03-24 16:27:01 UTC (rev 11516)
+++ cs/benchmark/cigma/trunk/src/ExternalField.cpp 2008-03-24 16:27:03 UTC (rev 11517)
@@ -1,89 +0,0 @@
-#include <iostream>
-#include <cstdlib>
-#include <dlfcn.h>
-#include <cassert>
-#include "ExternalField.h"
-
-// ---------------------------------------------------------------------------
-
-cigma::ExternalField::ExternalField()
-{
- handle = 0;
-}
-
-cigma::ExternalField::~ExternalField()
-{
- close_library();
-}
-
-// ---------------------------------------------------------------------------
-
-void cigma::ExternalField::load_library(std::string filename, std::string prefix)
-{
- std::string function_name;
- char *error;
-
- //handle = dlopen(filename.c_str(), RTLD_LAZY);
-
- handle = dlopen(filename.c_str(), RTLD_NOW);
- error = dlerror();
- if (!handle)
- {
- std::cerr << error << std::endl;
- // XXX: throw exception
- assert(false);
- }
-
- /* clear any existing error */
- dlerror();
-
- function_name = prefix + "_get_dim";
- *(void **)(&ext_get_dim) = dlsym(handle, function_name.c_str());
- error = dlerror();
- if (error != NULL)
- {
- std::cerr << error << std::endl;
- // XXX: throw exception
- assert(false);
- }
-
- function_name = prefix + "_get_rank";
- *(void **)(&ext_get_rank) = dlsym(handle, function_name.c_str());
- error = dlerror();
- if (error != NULL)
- {
- std::cerr << error << std::endl;
- // XXX: throw exception
- assert(false);
- }
-
- function_name = prefix + "_eval";
- *(void **)(&ext_eval) = dlsym(handle, function_name.c_str());
- error = dlerror();
- if (error != NULL)
- {
- std::cerr << error << std::endl;
- // XXX: throw exception
- assert(false);
- }
-
- function_name = prefix + "_batch_eval";
- *(void **)(&ext_batch_eval) = dlsym(handle, function_name.c_str());
- error = dlerror();
- if (error != NULL)
- {
- std::cerr << error << std::endl;
- // XXX: throw exception
- assert(false);
- }
-}
-
-void cigma::ExternalField::close_library()
-{
- if (handle != 0)
- {
- dlclose(handle);
- }
-}
-
-// ---------------------------------------------------------------------------
Deleted: cs/benchmark/cigma/trunk/src/ExternalField.h
===================================================================
--- cs/benchmark/cigma/trunk/src/ExternalField.h 2008-03-24 16:27:01 UTC (rev 11516)
+++ cs/benchmark/cigma/trunk/src/ExternalField.h 2008-03-24 16:27:03 UTC (rev 11517)
@@ -1,53 +0,0 @@
-#ifndef __EXTERNAL_FIELD_H__
-#define __EXTERNAL_FIELD_H__
-
-#include <string>
-#include "Points.h"
-#include "Field.h"
-
-
-namespace cigma
-{
- class ExternalField;
-}
-
-
-/**
- * @brief External Field object
- *
- */
-class cigma::ExternalField : public Field
-{
-public:
- typedef void (*get_int_fn)(int*);
- typedef void (*eval_from_point_fn)(double*,double*);
- typedef void (*eval_from_points_fn)(int,double*,double*);
-
-public:
- ExternalField();
- ~ExternalField();
-
-public:
- int n_dim() { return dim; }
- int n_rank() { return rank; }
-
-public:
- void load_library(std::string filename, std::string prefix);
- void close_library();
-
-public:
- void eval(double *x, double *y);
- void eval(Points &domain, Points &range);
-
-public:
- int dim;
- int rank;
- void *handle;
- get_int_fn ext_get_dim;
- get_int_fn ext_get_rank;
- eval_from_point_fn ext_eval;
- eval_from_points_fn ext_batch_eval;
-};
-
-
-#endif
Deleted: cs/benchmark/cigma/trunk/src/ResidualField.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/ResidualField.cpp 2008-03-24 16:27:01 UTC (rev 11516)
+++ cs/benchmark/cigma/trunk/src/ResidualField.cpp 2008-03-24 16:27:03 UTC (rev 11517)
@@ -1,83 +0,0 @@
-#include <iostream>
-#include <string>
-#include <cmath>
-#include "ResidualField.h"
-#include "VtkWriter.h"
-
-using namespace std;
-
-// ---------------------------------------------------------------------------
-
-cigma::ResidualField::ResidualField()
-{
- nel = 0;
- epsilon = 0;
- meshPart = 0;
-}
-
-cigma::ResidualField::~ResidualField()
-{
- if (epsilon != 0) delete [] epsilon;
-}
-
-// ---------------------------------------------------------------------------
-
-void cigma::ResidualField::set_mesh(MeshPart *meshPart)
-{
- assert(meshPart != 0);
- this->meshPart = meshPart;
- this->nel = meshPart->nel;
- epsilon = new double[nel];
-}
-
-// ---------------------------------------------------------------------------
-
-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
- assert(meshPart->nel == nel);
-
- string output_filename = filename;
- cout << "Creating file " << output_filename << endl;
-
- VtkWriter writer;
- writer.open(output_filename); // XXX: change signature to 'const char *'
- writer.write_header();
- writer.write_points(meshPart->coords, meshPart->nno, meshPart->nsd);
- writer.write_cells(meshPart->connect, meshPart->nel, meshPart->ndofs);
- writer.write_cell_types(meshPart->nsd, meshPart->nel, meshPart->ndofs); // XXX: call from w/i write_cells()
- writer.write_cell_data("epsilon", epsilon, nel, 1);
- writer.close();
-}
-
-// ---------------------------------------------------------------------------
Deleted: cs/benchmark/cigma/trunk/src/ResidualField.h
===================================================================
--- cs/benchmark/cigma/trunk/src/ResidualField.h 2008-03-24 16:27:01 UTC (rev 11516)
+++ cs/benchmark/cigma/trunk/src/ResidualField.h 2008-03-24 16:27:03 UTC (rev 11517)
@@ -1,39 +0,0 @@
-#ifndef __RESIDUAL_FIELD_H__
-#define __RESIDUAL_FIELD_H__
-
-//#include "Field.h"
-#include "MeshPart.h"
-
-namespace cigma
-{
- class ResidualField;
-}
-
-//
-// XXX: do we need to derive from cigma::Field?
-//
-class cigma::ResidualField
-{
-public:
- ResidualField();
- ~ResidualField();
-
-public:
- 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;
-};
-
-#endif
Copied: cs/benchmark/cigma/trunk/src/Residuals.cpp (from rev 11516, cs/benchmark/cigma/trunk/src/ResidualField.cpp)
===================================================================
--- cs/benchmark/cigma/trunk/src/Residuals.cpp (rev 0)
+++ cs/benchmark/cigma/trunk/src/Residuals.cpp 2008-03-24 16:27:03 UTC (rev 11517)
@@ -0,0 +1,84 @@
+#include <iostream>
+#include <string>
+#include <cmath>
+#include "ResidualField.h"
+#include "VtkWriter.h"
+
+using namespace std;
+using namespace cigma;
+
+// ---------------------------------------------------------------------------
+
+ResidualField::ResidualField()
+{
+ nel = 0;
+ epsilon = 0;
+ meshPart = 0;
+}
+
+ResidualField::~ResidualField()
+{
+ if (epsilon != 0) delete [] epsilon;
+}
+
+// ---------------------------------------------------------------------------
+
+void ResidualField::set_mesh(MeshPart *meshPart)
+{
+ assert(meshPart != 0);
+ this->meshPart = meshPart;
+ this->nel = meshPart->nel;
+ epsilon = new double[nel];
+}
+
+// ---------------------------------------------------------------------------
+
+void 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 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 ResidualField::L2()
+{
+ return sqrt(global_error); // XXX: generalize to norm_pow(global_error)
+}
+
+// ---------------------------------------------------------------------------
+
+void ResidualField::write_vtk(const char *filename)
+{
+ assert(meshPart != 0); // XXX: add support for dumping residuals w/o mesh
+ assert(meshPart->nel == nel);
+
+ string output_filename = filename;
+ cout << "Creating file " << output_filename << endl;
+
+ VtkWriter writer;
+ writer.open(output_filename); // XXX: change signature to 'const char *'
+ //writer.write_header();
+ writer.write_points(meshPart->coords, meshPart->nno, meshPart->nsd);
+ writer.write_cells(meshPart->connect, meshPart->nel, meshPart->ndofs);
+ writer.write_cell_types(meshPart->nsd, meshPart->nel, meshPart->ndofs); // XXX: call from w/i write_cells()
+ writer.write_cell_data("epsilon", epsilon, nel, 1);
+ writer.close();
+}
+
+// ---------------------------------------------------------------------------
Copied: cs/benchmark/cigma/trunk/src/Residuals.h (from rev 11516, cs/benchmark/cigma/trunk/src/ResidualField.h)
===================================================================
--- cs/benchmark/cigma/trunk/src/Residuals.h (rev 0)
+++ cs/benchmark/cigma/trunk/src/Residuals.h 2008-03-24 16:27:03 UTC (rev 11517)
@@ -0,0 +1,36 @@
+#ifndef __RESIDUAL_FIELD_H__
+#define __RESIDUAL_FIELD_H__
+
+//#include "Field.h"
+#include "MeshPart.h"
+
+namespace cigma
+{
+ class ResidualField;
+}
+
+class cigma::ResidualField
+{
+public:
+ ResidualField();
+ ~ResidualField();
+
+public:
+ 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;
+};
+
+#endif
More information about the cig-commits
mailing list