[cig-commits] r13576 - in cs/cigma/trunk: src tests/libcigma
luis at geodynamics.org
luis at geodynamics.org
Tue Dec 9 18:14:53 PST 2008
Author: luis
Date: 2008-12-09 18:14:53 -0800 (Tue, 09 Dec 2008)
New Revision: 13576
Modified:
cs/cigma/trunk/src/Quadrature.cpp
cs/cigma/trunk/src/Quadrature.h
cs/cigma/trunk/tests/libcigma/QuadratureTest.cpp
Log:
Added method Quadrature::points_in_cell()
Modified: cs/cigma/trunk/src/Quadrature.cpp
===================================================================
--- cs/cigma/trunk/src/Quadrature.cpp 2008-12-10 02:14:52 UTC (rev 13575)
+++ cs/cigma/trunk/src/Quadrature.cpp 2008-12-10 02:14:53 UTC (rev 13576)
@@ -360,3 +360,29 @@
}
// ----------------------------------------------------------------------------
+
+bool Quadrature::points_in_cell() const
+{
+ int i,j;
+ if (cell_type == Cell::NONE) { return false; }
+
+ shared_ptr<Cell> cell = Cell::New(cell_type);
+ if (!cell) { return false; }
+
+ for (i = 0; i < npts; i++)
+ {
+ double refpt[3] = {0,0,0};
+ for (j = 0; j < ndim; j++)
+ {
+ refpt[j] = this->getPoint(i,j);
+ }
+ if (!cell->interior(refpt[0], refpt[1], refpt[2]))
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+// ----------------------------------------------------------------------------
Modified: cs/cigma/trunk/src/Quadrature.h
===================================================================
--- cs/cigma/trunk/src/Quadrature.h 2008-12-10 02:14:52 UTC (rev 13575)
+++ cs/cigma/trunk/src/Quadrature.h 2008-12-10 02:14:53 UTC (rev 13576)
@@ -30,6 +30,7 @@
double getPoint(int q, int j) const;
double getWeight(int q) const;
Cell::type getCellType() const;
+ bool points_in_cell() const;
void reinit(int npts, int ndim);
void setData(double *points, double *weights); // XXX: rename to init(double*,double*)
Modified: cs/cigma/trunk/tests/libcigma/QuadratureTest.cpp
===================================================================
--- cs/cigma/trunk/tests/libcigma/QuadratureTest.cpp 2008-12-10 02:14:52 UTC (rev 13575)
+++ cs/cigma/trunk/tests/libcigma/QuadratureTest.cpp 2008-12-10 02:14:53 UTC (rev 13576)
@@ -66,5 +66,6 @@
CPPUNIT_ASSERT_EQUAL(8, Q->n_points());
CPPUNIT_ASSERT_EQUAL(3, Q->n_dim());
CPPUNIT_ASSERT_EQUAL(Cell::HEX8, Q->getCellType());
+ CPPUNIT_ASSERT_EQUAL(true, Q->points_in_cell());
}
More information about the CIG-COMMITS
mailing list