[cig-commits] r8944 - cs/benchmark/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Wed Dec 19 12:06:25 PST 2007
Author: luis
Date: 2007-12-19 12:06:25 -0800 (Wed, 19 Dec 2007)
New Revision: 8944
Added:
cs/benchmark/cigma/trunk/src/Quadrature.cpp
cs/benchmark/cigma/trunk/src/Quadrature.h
Removed:
cs/benchmark/cigma/trunk/src/QuadratureRule.cpp
cs/benchmark/cigma/trunk/src/QuadratureRule.h
Log:
Quadrature class
Added: cs/benchmark/cigma/trunk/src/Quadrature.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/Quadrature.cpp 2007-12-19 20:06:18 UTC (rev 8943)
+++ cs/benchmark/cigma/trunk/src/Quadrature.cpp 2007-12-19 20:06:25 UTC (rev 8944)
@@ -0,0 +1,113 @@
+#include "Quadrature.h"
+
+// ---------------------------------------------------------------------------
+
+cigma::Quadrature::Quadrature()
+{
+ qdim = 0;
+ qpts = 0;
+ qwts = 0;
+}
+
+
+cigma::Quadrature::~Quadrature()
+{
+ if (data != 0) delete [] data;
+ if (qpts != 0) delete [] qpts;
+ if (qwts != 0) delete [] qwts;
+}
+
+
+// ---------------------------------------------------------------------------
+
+void cigma::Quadrature::set_data(Cell *cell, double *quadpts, double *quadwts, int npts)
+{
+ /* some basic assertions */
+ assert(cell != 0);
+ assert(quadpts != 0);
+ assert(quadwts != 0);
+ assert(npts > 0);
+
+ /* clear existing data */
+ if (data != 0) delete [] data;
+ if (qpts != 0) delete [] qpts;
+ if (qwts != 0) delete [] qwts;
+
+ /* set dimensions */
+ this->num = npts;
+ this->dim = cell->n_celldim();
+ this->qdim = cell->n_dim();
+
+ /* allocate new data arrays */
+ data = new double[npts * dim];
+ qpts = new double[npts * qdim];
+ qwts = new double[npts];
+
+ /* copy from quadpts & quadwts */
+ int i,j;
+ for (i = 0; i < npts; i++)
+ {
+ qwts[i] = quadwts[i];
+ for (j = 0; j < dim; j++)
+ {
+ int n = dim*i + j;
+ data[n] = quadpts[n];
+ }
+ for (j = 0; j < qdim; j++)
+ {
+ qpts[qdim*i + j] = 0.0;
+ }
+ }
+}
+
+void cigma::Quadrature::apply_refmap()
+{
+ assert(cell != 0);
+ for (int i = 0; i < num; i++)
+ {
+ cell->uvw2xyz(&data[dim*i], &qpts[qdim*i]);
+ }
+}
+
+
+/*
+void cigma::Quadrature::set_quadrature(double *points, double *weights, int npts, int nsd)
+{
+ nq = npts;
+ dim = nsd;
+
+ for (int i = 0; i < nq; i++)
+ {
+ qwts[i] = weights[i];
+
+ for (int j = 0; j < dim; j++)
+ {
+ qpts[dim*i + j] = points[dim*i + j];
+ }
+ }
+}
+
+
+void cigma::Quadrature::get_quadrature(double **points, double **weights, int *npts, int *nsd)
+{
+ double *pts = new double[nq*dim];
+ double *wts = new double[nq];
+
+ for (int i = 0; i < nq; i++)
+ {
+ wts[i] = qwts[i];
+
+ for (int j = 0; j < dim; j++)
+ {
+ pts[dim*i+j] = qpts[dim*i+j];
+ }
+ }
+
+ *points = pts;
+ *weights = wts;
+ *npts = nq;
+ *nsd = dim;
+}
+*/
+
+// ---------------------------------------------------------------------------
Added: cs/benchmark/cigma/trunk/src/Quadrature.h
===================================================================
--- cs/benchmark/cigma/trunk/src/Quadrature.h 2007-12-19 20:06:18 UTC (rev 8943)
+++ cs/benchmark/cigma/trunk/src/Quadrature.h 2007-12-19 20:06:25 UTC (rev 8944)
@@ -0,0 +1,69 @@
+#ifndef __QUADRATURE_H__
+#define __QUADRATURE_H__
+
+#include "Cell.h"
+#include "Points.h"
+
+namespace cigma
+{
+ class Quadrature;
+}
+
+/**
+ * @brief Quadrature scheme
+ *
+ */
+
+class cigma::Quadrature : public Points
+{
+public:
+ Quadrature();
+ ~Quadrature();
+
+public:
+ void set_data(Cell *cell, double *quadpts, double *quadwts, int npts);
+
+public:
+ void apply_refmap();
+
+public:
+ int n_refdim() const;
+ int n_globaldim() const;
+
+public:
+ int global_index(int i, int j) const;
+ double global_value(int i, int j) const;
+
+public:
+ Cell *cell;
+ int qdim;
+ double *qpts;
+ double *qwts;
+};
+
+// ---------------------------------------------------------------------------
+
+
+inline int cigma::Quadrature::n_refdim() const
+{
+ return dim;
+}
+
+inline int cigma::Quadrature::n_globaldim() const
+{
+ return qdim;
+}
+
+inline int cigma::Quadrature::global_index(int i, int j) const
+{
+ return qdim*i + j;
+}
+
+inline double cigma::Quadrature::global_value(int i, int j) const
+{
+ return qpts[global_index(i,j)];
+}
+
+// ---------------------------------------------------------------------------
+
+#endif
Deleted: cs/benchmark/cigma/trunk/src/QuadratureRule.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/QuadratureRule.cpp 2007-12-19 20:06:18 UTC (rev 8943)
+++ cs/benchmark/cigma/trunk/src/QuadratureRule.cpp 2007-12-19 20:06:25 UTC (rev 8944)
@@ -1,55 +0,0 @@
-#include "QuadratureRule.h"
-
-
-cigma::QuadratureRule::QuadratureRule()
-{
- nq = 0;
- dim = 0;
- qpts = 0;
- qwts = 0;
-}
-
-
-cigma::QuadratureRule::~QuadratureRule()
-{
-}
-
-
-void cigma::QuadratureRule::set_quadrature(double *points, double *weights, int npts, int nsd)
-{
- nq = npts;
- dim = nsd;
-
- for (int i = 0; i < nq; i++)
- {
- qwts[i] = weights[i];
-
- for (int j = 0; j < dim; j++)
- {
- qpts[dim*i + j] = points[dim*i + j];
- }
- }
-}
-
-
-void cigma::QuadratureRule::get_quadrature(double **points, double **weights, int *npts, int *nsd)
-{
- double *pts = new double[nq*dim];
- double *wts = new double[nq];
-
- for (int i = 0; i < nq; i++)
- {
- wts[i] = qwts[i];
-
- for (int j = 0; j < dim; j++)
- {
- pts[dim*i+j] = qpts[dim*i+j];
- }
- }
-
- *points = pts;
- *weights = wts;
- *npts = nq;
- *nsd = dim;
-}
-
Deleted: cs/benchmark/cigma/trunk/src/QuadratureRule.h
===================================================================
--- cs/benchmark/cigma/trunk/src/QuadratureRule.h 2007-12-19 20:06:18 UTC (rev 8943)
+++ cs/benchmark/cigma/trunk/src/QuadratureRule.h 2007-12-19 20:06:25 UTC (rev 8944)
@@ -1,31 +0,0 @@
-#ifndef __QUADRATURE_RULE_H__
-#define __QUADRATURE_RULE_H__
-
-namespace cigma
-{
- class QuadratureRule;
-}
-
-/**
- * @brief Base class for quadrature schemes
- *
- */
-
-class cigma::QuadratureRule
-{
-public:
- QuadratureRule();
- ~QuadratureRule();
-
-public:
- void set_quadrature(double *points, double *weights, int npts, int nsd);
- void get_quadrature(double **points, double **weights, int *npts, int *nsd);
-
-public:
- int nq;
- int dim;
- double *qpts;
- double *qwts;
-};
-
-#endif
More information about the cig-commits
mailing list