[cig-commits] r13149 - cs/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Wed Oct 29 15:10:52 PDT 2008
Author: luis
Date: 2008-10-29 15:10:51 -0700 (Wed, 29 Oct 2008)
New Revision: 13149
Modified:
cs/cigma/trunk/src/Quadrature.cpp
cs/cigma/trunk/src/Quadrature.h
cs/cigma/trunk/src/fe_hex8.cpp
cs/cigma/trunk/src/fe_quad4.cpp
cs/cigma/trunk/src/fe_tet4.cpp
cs/cigma/trunk/src/fe_tri3.cpp
Log:
Split the roles in &Quadrature::setData (allocation & copying).
To reallocate new space, use &Quadrature::reinit instead, or
use the appropriate constructor.
Modified: cs/cigma/trunk/src/Quadrature.cpp
===================================================================
--- cs/cigma/trunk/src/Quadrature.cpp 2008-10-29 22:10:48 UTC (rev 13148)
+++ cs/cigma/trunk/src/Quadrature.cpp 2008-10-29 22:10:51 UTC (rev 13149)
@@ -1,4 +1,5 @@
#include <iostream>
+#include <cassert>
#include "Quadrature.h"
using namespace cigma;
@@ -50,23 +51,30 @@
// ----------------------------------------------------------------------------
-void Quadrature::setData(int npts, int ndim, double *points, double *weights)
+void Quadrature::reinit(int npts, int ndim)
{
+ if (this->points) { delete [] this->points; }
+ if (this->weights) { delete [] this->weights; }
+
this->npts = npts;
this->ndim = ndim;
- if (this->points) { delete [] this->points; }
- if (this->weights) { delete [] this->weights; }
-
this->points = new double[npts * ndim];
this->weights = new double[npts];
+}
+void Quadrature::setData(double *points, double *weights)
+{
+ assert(this->points != 0);
+ assert(this->weights != 0);
+
for (int q = 0; q < npts; q++)
{
this->weights[q] = weights[q];
for (int j = 0; j < ndim; j++)
{
- this->points[q*ndim + j] = points[q*ndim + j];
+ const int n = q*ndim + j;
+ this->points[n] = points[n];
}
}
}
Modified: cs/cigma/trunk/src/Quadrature.h
===================================================================
--- cs/cigma/trunk/src/Quadrature.h 2008-10-29 22:10:48 UTC (rev 13148)
+++ cs/cigma/trunk/src/Quadrature.h 2008-10-29 22:10:51 UTC (rev 13149)
@@ -24,7 +24,8 @@
void setPoint(int q, int j, double val);
void setWeight(int q, double val);
- void setData(int npts, int ndim, double *points, double *weights);
+ void reinit(int npts, int ndim);
+ void setData(double *points, double *weights);
public:
int npts;
Modified: cs/cigma/trunk/src/fe_hex8.cpp
===================================================================
--- cs/cigma/trunk/src/fe_hex8.cpp 2008-10-29 22:10:48 UTC (rev 13148)
+++ cs/cigma/trunk/src/fe_hex8.cpp 2008-10-29 22:10:51 UTC (rev 13149)
@@ -99,8 +99,8 @@
};
double qwts[nno] = { 1., 1., 1., 1., 1., 1., 1., 1. };
- boost::shared_ptr<Quadrature> Q(new Quadrature());
- Q->setData(nno, celldim, qpts, qwts);
+ boost::shared_ptr<Quadrature> Q(new Quadrature(nno, celldim));
+ Q->setData(qpts, qwts);
return Q;
}
Modified: cs/cigma/trunk/src/fe_quad4.cpp
===================================================================
--- cs/cigma/trunk/src/fe_quad4.cpp 2008-10-29 22:10:48 UTC (rev 13148)
+++ cs/cigma/trunk/src/fe_quad4.cpp 2008-10-29 22:10:51 UTC (rev 13149)
@@ -80,8 +80,8 @@
0.4252933
};
- boost::shared_ptr<Quadrature> Q(new Quadrature());
- Q->setData(nno, celldim, qpts, qwts);
+ boost::shared_ptr<Quadrature> Q(new Quadrature(nno, celldim));
+ Q->setData(qpts, qwts);
return Q;
}
Modified: cs/cigma/trunk/src/fe_tet4.cpp
===================================================================
--- cs/cigma/trunk/src/fe_tet4.cpp 2008-10-29 22:10:48 UTC (rev 13148)
+++ cs/cigma/trunk/src/fe_tet4.cpp 2008-10-29 22:10:51 UTC (rev 13149)
@@ -90,8 +90,8 @@
qwts[i] *= 0.125;
}
- boost::shared_ptr<Quadrature> Q(new Quadrature());
- Q->setData(nno, celldim, qpts, qwts);
+ boost::shared_ptr<Quadrature> Q(new Quadrature(nno, celldim));
+ Q->setData(qpts, qwts);
return Q;
}
Modified: cs/cigma/trunk/src/fe_tri3.cpp
===================================================================
--- cs/cigma/trunk/src/fe_tri3.cpp 2008-10-29 22:10:48 UTC (rev 13148)
+++ cs/cigma/trunk/src/fe_tri3.cpp 2008-10-29 22:10:51 UTC (rev 13149)
@@ -67,8 +67,8 @@
0.12413685, 0.22325768, 0.25471234, 0.07758553
};
- boost::shared_ptr<Quadrature> Q(new Quadrature());
- Q->setData(nno, celldim, qpts, qwts);
+ boost::shared_ptr<Quadrature> Q(new Quadrature(nno, celldim));
+ Q->setData(qpts, qwts);
return Q;
}
More information about the CIG-COMMITS
mailing list