[cig-commits] r11558 - in cs/benchmark/cigma/trunk/src: . tests
luis at geodynamics.org
luis at geodynamics.org
Wed Mar 26 03:27:49 PDT 2008
Author: luis
Date: 2008-03-26 03:27:49 -0700 (Wed, 26 Mar 2008)
New Revision: 11558
Added:
cs/benchmark/cigma/trunk/src/tests/TestHex.cpp
cs/benchmark/cigma/trunk/src/tests/TestPoints.cpp
cs/benchmark/cigma/trunk/src/tests/TestQuad.cpp
cs/benchmark/cigma/trunk/src/tests/TestTet.cpp
cs/benchmark/cigma/trunk/src/tests/TestTri.cpp
Modified:
cs/benchmark/cigma/trunk/src/Cell.cpp
cs/benchmark/cigma/trunk/src/Quad.h
cs/benchmark/cigma/trunk/src/Tri.h
cs/benchmark/cigma/trunk/src/tests/Makefile
Log:
Make sure that the 2D cells pass their respective unit tests
Modified: cs/benchmark/cigma/trunk/src/Cell.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/Cell.cpp 2008-03-26 10:27:42 UTC (rev 11557)
+++ cs/benchmark/cigma/trunk/src/Cell.cpp 2008-03-26 10:27:49 UTC (rev 11558)
@@ -44,11 +44,10 @@
// copy data from vertices
for (i = 0; i < nno; i++)
{
- //*
for (j = 0; j < nsd; j++)
{
globverts[nsd*i + j] = 0.0;
- } // */
+ }
for (j = 0; j < celldim; j++)
{
int n = celldim*i + j;
Modified: cs/benchmark/cigma/trunk/src/Quad.h
===================================================================
--- cs/benchmark/cigma/trunk/src/Quad.h 2008-03-26 10:27:42 UTC (rev 11557)
+++ cs/benchmark/cigma/trunk/src/Quad.h 2008-03-26 10:27:49 UTC (rev 11558)
@@ -17,7 +17,7 @@
public:
int n_nodes() { return 4; }
int n_celldim() { return 2; }
- int n_dim() { return 2; } //XXX: how to handle embedding in 3d space?
+ int n_dim() { return 3; }
Geometry geometry() { return QUADRANGLE; }
public:
Modified: cs/benchmark/cigma/trunk/src/Tri.h
===================================================================
--- cs/benchmark/cigma/trunk/src/Tri.h 2008-03-26 10:27:42 UTC (rev 11557)
+++ cs/benchmark/cigma/trunk/src/Tri.h 2008-03-26 10:27:49 UTC (rev 11558)
@@ -17,7 +17,7 @@
public:
int n_nodes() { return 3; }
int n_celldim() { return 2; }
- int n_dim() { return 2; } // XXX: how to handle embedding in 3d space?
+ int n_dim() { return 3; }
Geometry geometry() { return TRIANGLE; }
public:
Modified: cs/benchmark/cigma/trunk/src/tests/Makefile
===================================================================
--- cs/benchmark/cigma/trunk/src/tests/Makefile 2008-03-26 10:27:42 UTC (rev 11557)
+++ cs/benchmark/cigma/trunk/src/tests/Makefile 2008-03-26 10:27:49 UTC (rev 11558)
@@ -17,6 +17,11 @@
CIGMALIB = ../libcigma.a
TESTOBJS = \
+ TestTri.o \
+ TestQuad.o \
+ TestTet.o \
+ TestHex.o \
+ TestPoints.o \
TestZeroField.o \
Added: cs/benchmark/cigma/trunk/src/tests/TestHex.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/tests/TestHex.cpp (rev 0)
+++ cs/benchmark/cigma/trunk/src/tests/TestHex.cpp 2008-03-26 10:27:49 UTC (rev 11558)
@@ -0,0 +1,130 @@
+#include <iostream>
+#include <cstdlib>
+#include <cassert>
+
+#include "../Hex.h"
+
+using namespace std;
+using namespace cigma;
+
+int main(void)
+{
+ Hex hexcell;
+
+ int ndofs = hexcell.n_nodes();
+ const int npts = 11;
+ const int nsd = 3;
+
+ double refpts[npts*3] = {
+ -1.0, -1.0, -1.0,
+ +1.0, -1.0, -1.0,
+ +1.0, +1.0, -1.0,
+ -1.0, +1.0, -1.0,
+ -1.0, -1.0, +1.0,
+ +1.0, -1.0, +1.0,
+ +1.0, +1.0, +1.0,
+ -1.0, +1.0, +1.0,
+ 0.0, 0.0, 0.0,
+ 0.5, 0.5, 0.5,
+ 2.0, 2.0, 3.0
+ };
+
+ double tab[npts*ndofs];
+ double tab_jet[npts*ndofs*3];
+ hexcell.shape(npts, refpts, tab);
+ hexcell.grad_shape(npts, refpts, tab_jet);
+
+ for (int i = 0; i < npts; i++)
+ {
+ double *pt = &refpts[nsd*i];
+ double u = pt[0];
+ double v = pt[1];
+ double w = pt[2];
+
+ cout << i << " : ";
+
+ cout << "x = ["
+ << u << ","
+ << v << ","
+ << w << "] ";
+
+
+ bool inside = hexcell.interior(u,v,w);
+ cout << "in = " << inside << " ";
+
+
+ double *phi = &tab[ndofs*i];
+ cout << "phi = ["
+ << phi[0] << ","
+ << phi[1] << ","
+ << phi[2] << ","
+ << phi[3] << ","
+ << phi[4] << ","
+ << phi[5] << ","
+ << phi[6] << ","
+ << phi[7] << "] ";
+
+
+ double *grad_phi = &tab_jet[i*ndofs*3];
+ cout << "grad_phi = ["
+ << "[" << grad_phi[3*0 + 0] << ","
+ << grad_phi[3*0 + 1] << ","
+ << grad_phi[3*0 + 2] << "],"
+
+ << "[" << grad_phi[3*1 + 0] << ","
+ << grad_phi[3*1 + 1] << ","
+ << grad_phi[3*1 + 2] << "],"
+
+ << "[" << grad_phi[3*2 + 0] << ","
+ << grad_phi[3*2 + 1] << ","
+ << grad_phi[3*2 + 2] << "],"
+
+ << "[" << grad_phi[3*3 + 0] << ","
+ << grad_phi[3*3 + 1] << ","
+ << grad_phi[3*3 + 2] << "],"
+
+ << "[" << grad_phi[3*4 + 0] << ","
+ << grad_phi[3*4 + 1] << ","
+ << grad_phi[3*4 + 2] << "],"
+
+ << "[" << grad_phi[3*5 + 0] << ","
+ << grad_phi[3*5 + 1] << ","
+ << grad_phi[3*5 + 2] << "],"
+
+ << "[" << grad_phi[3*6 + 0] << ","
+ << grad_phi[3*6 + 1] << ","
+ << grad_phi[3*6 + 2] << "],"
+
+ << "[" << grad_phi[3*7 + 0] << ","
+ << grad_phi[3*7 + 1] << ","
+ << grad_phi[3*7 + 2] << "]"
+ << "] ";
+
+
+ double J[3][3];
+ double detJ = hexcell.jacobian(u,v,w,J);
+ cout << "detJ = " << detJ;
+
+ double xyz[3] = {u,v,w};
+ double uvw[3];
+ hexcell.xyz2uvw(xyz,uvw);
+ cout << " xyz2uvw -> ["
+ << uvw[0] << ","
+ << uvw[1] << ","
+ << uvw[2] << "]";
+
+ cout << endl;
+ }
+
+
+
+
+ // -----------------------------------------------------------------------
+
+ //delete reader;
+
+ //writer->fp = NULL;
+ //delete writer;
+
+ return 0;
+}
Added: cs/benchmark/cigma/trunk/src/tests/TestPoints.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/tests/TestPoints.cpp (rev 0)
+++ cs/benchmark/cigma/trunk/src/tests/TestPoints.cpp 2008-03-26 10:27:49 UTC (rev 11558)
@@ -0,0 +1,37 @@
+#include <iostream>
+#include <iomanip>
+#include "../Points.h"
+
+using namespace std;
+using namespace cigma;
+
+int main()
+{
+
+ double coords[4*3] = {
+ -1, -1, -1,
+ +1, -1, -1,
+ -1, +1, -1,
+ -1, -1, +1
+ };
+
+ Points points;
+
+ points.set_data(coords, 4, 3);
+
+ cout << std::showpos
+ << std::fixed
+ << std::setprecision(1);
+
+ int i,j;
+ for (i = 0; i < points.n_points(); i++)
+ {
+ for (j = 0; j < points.n_dim(); j++)
+ {
+ cout << points(i,j) << " ";
+ }
+ cout << endl;
+ }
+
+ return 0;
+}
Added: cs/benchmark/cigma/trunk/src/tests/TestQuad.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/tests/TestQuad.cpp (rev 0)
+++ cs/benchmark/cigma/trunk/src/tests/TestQuad.cpp 2008-03-26 10:27:49 UTC (rev 11558)
@@ -0,0 +1,85 @@
+#include <iostream>
+#include <cstdlib>
+#include <cassert>
+
+#include "../Quad.h"
+
+using namespace cigma;
+using namespace std;
+
+int main(void)
+{
+ Quad quadcell;
+
+ int ndofs = quadcell.n_nodes();
+ const int npts = 7;
+ const int celldim = 2;
+ double refpts[npts * celldim] = {
+ -1.0, -1.0,
+ +1.0, -1.0,
+ +1.0, +1.0,
+ -1.0, +1.0,
+ 0.0, 0.0,
+ 0.5, 0.5,
+ 2.0, 2.0,
+ };
+
+ double tab[npts*ndofs];
+ double tab_jet[npts*ndofs*celldim];
+ quadcell.shape(npts, refpts, tab);
+ quadcell.grad_shape(npts, refpts, tab_jet);
+
+ for (int i = 0; i < npts; i++)
+ {
+ double *pt = &refpts[celldim*i];
+ double u = pt[0];
+ double v = pt[1];
+ double w = 0.0;
+
+ cout << i << " : ";
+ cout << "x = ["
+ << u << ","
+ << v << "] ";
+
+ bool inside = quadcell.interior(u, v, w);
+ cout << "in = " << inside << " ";
+
+ double *phi = &tab[ndofs*i];
+ cout << "phi = ["
+ << phi[0] << ","
+ << phi[1] << ","
+ << phi[2] << ","
+ << phi[3] << "] ";
+
+ double *grad_phi = &tab_jet[i*ndofs*celldim];
+ cout << "grad_phi = ["
+ << "[" << grad_phi[2*0 + 0] << ","
+ << grad_phi[2*0 + 1] << "],"
+
+ << "[" << grad_phi[2*1 + 0] << ","
+ << grad_phi[2*1 + 1] << "],"
+
+ << "[" << grad_phi[2*2 + 0] << ","
+ << grad_phi[2*2 + 1] << "],"
+
+ << "[" << grad_phi[2*3 + 0] << ","
+ << grad_phi[2*3 + 1] << "]"
+ << "] ";
+
+ double J[3][3];
+ double detJ = quadcell.jacobian(u,v,w,J);
+ cout << "detJ = " << detJ;
+
+ double xyz[3] = {u,v,w};
+ double uvw[3];
+ quadcell.xyz2uvw(xyz,uvw);
+ cout << " xyz2uvw -> ["
+ << uvw[0] << ","
+ << uvw[1] << ","
+ << uvw[2] << "]";
+
+ cout << endl;
+ }
+
+ return 0;
+}
Added: cs/benchmark/cigma/trunk/src/tests/TestTet.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/tests/TestTet.cpp (rev 0)
+++ cs/benchmark/cigma/trunk/src/tests/TestTet.cpp 2008-03-26 10:27:49 UTC (rev 11558)
@@ -0,0 +1,98 @@
+#include <iostream>
+#include <cstdlib>
+#include <cassert>
+
+#include "../Tet.h"
+
+using namespace std;
+using namespace cigma;
+
+int main(void)
+{
+ Tet tetcell;
+
+ int ndofs = tetcell.n_nodes();
+ const int npts = 5;
+ const int nsd = 3;
+
+ double refpts[npts*nsd] = {
+ 0.0, 0.0, 0.0,
+ 1.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.0, 0.0, 1.0,
+ 0.5, 0.5, 0.5
+ };
+
+ double tab[npts*ndofs];
+ double tab_jet[npts*ndofs*nsd];
+ tetcell.shape(npts, refpts, tab);
+ tetcell.grad_shape(npts, refpts, tab_jet);
+
+ for (int i = 0; i < npts; i++)
+ {
+ double *pt = &refpts[nsd*i];
+ double u = pt[0];
+ double v = pt[1];
+ double w = pt[2];
+
+ cout << i << " : ";
+
+ cout << "x = ["
+ << u << ","
+ << v << ","
+ << w << "] ";
+
+ bool inside = tetcell.interior(u,v,w);
+ cout << "in = " << inside << " ";
+
+ double *phi = &tab[ndofs*i];
+ cout << "phi = ["
+ << phi[0] << ","
+ << phi[1] << ","
+ << phi[2] << ","
+ << phi[3] << "] ";
+
+ double *grad_phi = &tab_jet[i*ndofs*3];
+ cout << "grad_phi = ["
+ << "[" << grad_phi[3*0 + 0] << ","
+ << grad_phi[3*0 + 1] << ","
+ << grad_phi[3*0 + 2] << "],"
+
+ << "[" << grad_phi[3*1 + 0] << ","
+ << grad_phi[3*1 + 1] << ","
+ << grad_phi[3*1 + 2] << "],"
+
+ << "[" << grad_phi[3*2 + 0] << ","
+ << grad_phi[3*2 + 1] << ","
+ << grad_phi[3*2 + 2] << "],"
+
+ << "[" << grad_phi[3*3 + 0] << ","
+ << grad_phi[3*3 + 1] << ","
+ << grad_phi[3*3 + 2] << "]"
+ << "] ";
+
+
+ double J[3][3];
+ double detJ = tetcell.jacobian(u,v,w,J);
+ cout << "detJ = " << detJ;
+
+ double xyz[3] = {u,v,w};
+ double uvw[3];
+ tetcell.xyz2uvw(xyz,uvw);
+ cout << " xyz2uvw -> ["
+ << uvw[0] << ","
+ << uvw[1] << ","
+ << uvw[2] << "]";
+
+ cout << endl;
+ }
+
+
+
+
+ // -----------------------------------------------------------------------
+
+ //delete reader;
+
+ return 0;
+}
Added: cs/benchmark/cigma/trunk/src/tests/TestTri.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/tests/TestTri.cpp (rev 0)
+++ cs/benchmark/cigma/trunk/src/tests/TestTri.cpp 2008-03-26 10:27:49 UTC (rev 11558)
@@ -0,0 +1,81 @@
+#include <iostream>
+#include <cstdlib>
+#include <cassert>
+
+#include "../Tri.h"
+
+using namespace cigma;
+using namespace std;
+
+int main(void)
+{
+ Tri tricell;
+
+ const int npts = 5;
+ const int celldim = 2;
+ const int ndofs = tricell.n_nodes();
+
+ double refpts[npts*celldim] = {
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 0.0, 1.0,
+ 0.5, 0.5,
+ 1.0, 1.0
+ };
+
+ double tab[npts*ndofs];
+ double tab_jet[npts*ndofs*celldim];
+ tricell.shape(npts, refpts, tab);
+ tricell.grad_shape(npts, refpts, tab_jet);
+
+ for (int i = 0; i < npts; i++)
+ {
+ double *pt = &refpts[celldim*i];
+ double u = pt[0];
+ double v = pt[1];
+ double w = 0.0;
+
+ cout << i << " : ";
+
+ cout << "x = ["
+ << u << ","
+ << v << "] ";
+
+ bool inside = tricell.interior(u,v,w);
+ cout << "in = " << inside << " ";
+
+ double *phi = &tab[ndofs*i];
+ cout << "phi = ["
+ << phi[0] << ","
+ << phi[1] << ","
+ << phi[2] << "] ";
+
+ double *grad_phi = &tab_jet[i*ndofs*celldim];
+ cout << "grad_phi = ["
+ << "[" << grad_phi[2*0 + 0] << ","
+ << grad_phi[2*0 + 1] << "],"
+
+ << "[" << grad_phi[2*1 + 0] << ","
+ << grad_phi[2*1 + 1] << "],"
+
+ << "[" << grad_phi[2*2 + 0] << ","
+ << grad_phi[2*2 + 1] << "]"
+ << "] ";
+
+ double J[3][3];
+ double detJ = tricell.jacobian(u,v,w,J);
+ cout << "detJ = " << detJ;
+
+ double xyz[3] = {u,v,w};
+ double uvw[3];
+ tricell.xyz2uvw(xyz,uvw);
+ cout << " xyz2uvw -> ["
+ << uvw[0] << ","
+ << uvw[1] << ","
+ << uvw[2] << "]";
+
+ cout << endl;
+ }
+
+ return 0;
+}
More information about the cig-commits
mailing list