From: hartmann Date: Wed, 6 Jul 2005 16:36:22 +0000 (+0000) Subject: Move implementation of the 3d measure function to GridTools::cell_measure. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12c836bc0ef940e8ff03dafc7e2f20c641354679;p=dealii-svn.git Move implementation of the 3d measure function to GridTools::cell_measure. git-svn-id: https://svn.dealii.org/trunk@11079 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index 531fd171a6..e48390f285 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -1553,86 +1554,11 @@ Point<3> TriaObjectAccessor<3, 3>::barycenter () const template <> double TriaObjectAccessor<3, 3>::measure () const { -/* - Get the computation of the measure by the same little Maple script as above. -*/ - - const double x[8] = { vertex(0)(0), - vertex(1)(0), - vertex(2)(0), - vertex(3)(0), - vertex(4)(0), - vertex(5)(0), - vertex(6)(0), - vertex(7)(0) }; - const double y[8] = { vertex(0)(1), - vertex(1)(1), - vertex(2)(1), - vertex(3)(1), - vertex(4)(1), - vertex(5)(1), - vertex(6)(1), - vertex(7)(1) }; - const double z[8] = { vertex(0)(2), - vertex(1)(2), - vertex(2)(2), - vertex(3)(2), - vertex(4)(2), - vertex(5)(2), - vertex(6)(2), - vertex(7)(2) }; + static int vertex_indices[GeometryInfo<3>::vertices_per_cell]; + for (unsigned int i=0; i::vertices_per_cell; ++i) + vertex_indices[i]=vertex_index(i); - double s1, s2, s3; - - s3 = -x[2]*y[7]*z[3]/12.0+x[1]*y[4]*z[0]/12.0-x[0]*y[3]*z[7]/12.0-z[1]*x - [2]*y[0]/12.0+x[5]*y[4]*z[0]/12.0+x[1]*y[5]*z[0]/12.0-x[1]*y[2]*z[0]/12.0-y[2]* - x[3]*z[7]/12.0-x[1]*y[0]*z[4]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x[6]*y[2]*z[7]/12.0+z[5]*x[4]*y[0]/12.0-y[6]* - x[2]*z[7]/12.0+x[2]*y[6]*z[5]/12.0+y[6]*x[7]*z[2]/12.0-y[6]*x[3]*z[7]/12.0-x[7] - *y[4]*z[3]/12.0-x[6]*y[4]*z[7]/12.0-x[5]*y[1]*z[4]/12.0+x[6]*y[7]*z[4]/12.0+x - [7]*y[3]*z[4]/12.0-z[1]*x[5]*y[6]/12.0+x[3]*y[4]*z[7]/12.0+x[5]*y[6]*z[4]/12.0; - - // the vertices entered into the - // above field and the vertices - // used by the maple script use - // different orderings (i.e. one is - // the inside-out orientation of - // the other one). the measure is - // thus negative. Thus take the - // negative value of the result - return -(s3+x[5]*y[4]*z[1]/12.0-x[5]*y[4]*z[6]/12.0-x[3]*y[7]*z[4]/12.0+x[6]* - y[3]*z[7]/12.0-y[1]*x[6]*z[5]/12.0-z[5]*x[1]*y[4]/12.0+z[5]*x[6]*y[4]/12.0+z[5] - *x[4]*y[1]/12.0-z[5]*x[4]*y[6]/12.0-x[6]*y[7]*z[3]/12.0-x[4]*y[3]*z[7]/12.0+x - [4]*y[7]*z[3]/12.0-x[1]*y[5]*z[6]/12.0-y[6]*x[7]*z[4]/12.0-y[1]*x[2]*z[6]/12.0- - y[2]*x[3]*z[6]/12.0+s2+s1+x[2]*y[0]*z[3]/12.0); + return GridTools::cell_measure(tria->vertices, vertex_indices); } #endif