From 83061c77b84c1cecc68008a82fe401e983c7acd4 Mon Sep 17 00:00:00 2001 From: heltai Date: Wed, 29 Jan 2014 11:54:27 +0000 Subject: [PATCH] Fixed normal_vector tests. git-svn-id: https://svn.dealii.org/branches/branch_manifold_id@32343 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/grid/tria_boundary_lib.cc | 5 +++-- tests/deal.II/normal_vector_01.cc | 10 +++++++--- tests/deal.II/normal_vector_01_2d.cc | 10 +++++++--- tests/deal.II/normal_vector_02.cc | 9 ++++++--- tests/deal.II/normal_vector_02_2d.cc | 10 +++++++--- tests/deal.II/normal_vector_03.cc | 12 ++++++++---- tests/deal.II/normal_vector_03_2d.cc | 12 ++++++++---- tests/deal.II/normals_at_vertices_01.cc | 8 ++++++-- tests/deal.II/normals_at_vertices_02.cc | 9 +++++++-- 9 files changed, 59 insertions(+), 26 deletions(-) diff --git a/deal.II/source/grid/tria_boundary_lib.cc b/deal.II/source/grid/tria_boundary_lib.cc index 77044ede78..d7357be4be 100644 --- a/deal.II/source/grid/tria_boundary_lib.cc +++ b/deal.II/source/grid/tria_boundary_lib.cc @@ -277,7 +277,8 @@ HyperBallBoundary:: normal_vector (const std::vector > & vertices, const Point &vertex) const { - return vertex-center; + Point n = vertex-center; + return n/n.norm(); } template @@ -348,7 +349,7 @@ normal_vector (const std::vector > & vertices, return normal; } else if(at_distance_R) - return vertex-this->center; + return HyperBallBoundary::normal_vector(vertices,vertex); else { Assert(false, diff --git a/tests/deal.II/normal_vector_01.cc b/tests/deal.II/normal_vector_01.cc index ad7783bbf3..c14c8091cd 100644 --- a/tests/deal.II/normal_vector_01.cc +++ b/tests/deal.II/normal_vector_01.cc @@ -69,7 +69,8 @@ int main () Triangulation<3> tria; StraightBoundary<3> boundary; - Boundary<3>::FaceVertexNormals normals; + std::vector > normals(GeometryInfo<3>::vertices_per_face); + for (unsigned int case_no=0; case_no<2; ++case_no) { deallog << "Case" << case_no << std::endl; @@ -79,9 +80,12 @@ int main () for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) { face=cell->face(face_no); - boundary.get_normals_at_vertices(face, normals); + std::vector > vs(GeometryInfo<3>::vertices_per_face); + for(unsigned int i=0; i::vertices_per_face; ++i) + vs[i] = face->vertex(i); + boundary.get_normals_at_points(vs, normals); for (unsigned int v=0; v::vertices_per_face; ++v) - Assert ((boundary.normal_vector (face, + Assert ((boundary.normal_vector (vs, face->vertex(v)) - normals[v] / normals[v].norm()).norm() diff --git a/tests/deal.II/normal_vector_01_2d.cc b/tests/deal.II/normal_vector_01_2d.cc index 65123e6e75..bb53f0b7fb 100644 --- a/tests/deal.II/normal_vector_01_2d.cc +++ b/tests/deal.II/normal_vector_01_2d.cc @@ -69,7 +69,8 @@ int main () Triangulation<2> tria; StraightBoundary<2> boundary; - Boundary<2>::FaceVertexNormals normals; + std::vector > normals(GeometryInfo<2>::vertices_per_face); + for (unsigned int case_no=0; case_no<2; ++case_no) { deallog << "Case" << case_no << std::endl; @@ -79,9 +80,12 @@ int main () for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) { face=cell->face(face_no); - boundary.get_normals_at_vertices(face, normals); + std::vector > vs(GeometryInfo<2>::vertices_per_face); + for(unsigned int i=0; i::vertices_per_face; ++i) + vs[i] = face->vertex(i); + boundary.get_normals_at_points(vs, normals); for (unsigned int v=0; v::vertices_per_face; ++v) - Assert ((boundary.normal_vector (face, + Assert ((boundary.normal_vector (vs, face->vertex(v)) - normals[v] / normals[v].norm()).norm() diff --git a/tests/deal.II/normal_vector_02.cc b/tests/deal.II/normal_vector_02.cc index 7d4c921860..0b695e92ed 100644 --- a/tests/deal.II/normal_vector_02.cc +++ b/tests/deal.II/normal_vector_02.cc @@ -43,7 +43,7 @@ int main () HyperBallBoundary<3> boundary (Point<3>(1,0,0)); Triangulation<3> tria; - Boundary<3>::FaceVertexNormals normals; + std::vector > normals(GeometryInfo<3>::vertices_per_face); GridGenerator::hyper_ball (tria, Point<3>(1,0,0), 3); @@ -54,9 +54,12 @@ int main () if (cell->at_boundary(face_no)) { Triangulation<3>::face_iterator face = cell->face(face_no); - boundary.get_normals_at_vertices(face, normals); + std::vector > vs(GeometryInfo<3>::vertices_per_face); + for(unsigned int i=0; i::vertices_per_face; ++i) + vs[i] = face->vertex(i); + boundary.get_normals_at_points(vs, normals); for (unsigned int v=0; v::vertices_per_face; ++v) - Assert ((boundary.normal_vector (face, + Assert ((boundary.normal_vector (vs, face->vertex(v)) - normals[v] / normals[v].norm()).norm() diff --git a/tests/deal.II/normal_vector_02_2d.cc b/tests/deal.II/normal_vector_02_2d.cc index 8e41a1ed42..99a55b6867 100644 --- a/tests/deal.II/normal_vector_02_2d.cc +++ b/tests/deal.II/normal_vector_02_2d.cc @@ -43,7 +43,7 @@ int main () HyperBallBoundary<2> boundary (Point<2>(1,0)); Triangulation<2> tria; - Boundary<2>::FaceVertexNormals normals; + std::vector > normals(GeometryInfo<2>::vertices_per_face); GridGenerator::hyper_ball (tria, Point<2>(1,0), 3); @@ -54,9 +54,13 @@ int main () if (cell->at_boundary(face_no)) { Triangulation<2>::face_iterator face = cell->face(face_no); - boundary.get_normals_at_vertices(face, normals); + std::vector > vs(GeometryInfo<2>::vertices_per_face); + for(unsigned int i=0; i::vertices_per_face; ++i) + vs[i] = face->vertex(i); + boundary.get_normals_at_points(vs, normals); + for (unsigned int v=0; v::vertices_per_face; ++v) - Assert ((boundary.normal_vector (face, + Assert ((boundary.normal_vector (vs, face->vertex(v)) - normals[v] / normals[v].norm()).norm() diff --git a/tests/deal.II/normal_vector_03.cc b/tests/deal.II/normal_vector_03.cc index 7d8c6fb9dc..999211d7d5 100644 --- a/tests/deal.II/normal_vector_03.cc +++ b/tests/deal.II/normal_vector_03.cc @@ -72,7 +72,8 @@ int main () Triangulation<3> tria; StraightBoundary<3> boundary; - Boundary<3>::FaceVertexNormals normals; + std::vector > normals(GeometryInfo<3>::vertices_per_face); + for (unsigned int case_no=0; case_no<2; ++case_no) { deallog << "Case" << case_no << std::endl; @@ -82,7 +83,10 @@ int main () for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) { face=cell->face(face_no); - boundary.get_normals_at_vertices(face, normals); + std::vector > vs(GeometryInfo<3>::vertices_per_face); + for(unsigned int i=0; i::vertices_per_face; ++i) + vs[i] = face->vertex(i); + boundary.get_normals_at_points(vs, normals); for (double xi=0; xi<=1; xi+=0.234) for (double eta=0; eta<=1; eta+=0.234) @@ -99,10 +103,10 @@ int main () normal /= normal.norm(); deallog << "p=" << p - << ", n=" << boundary.normal_vector (face, p) + << ", n=" << boundary.normal_vector (vs, p) << std::endl; - Assert ((boundary.normal_vector (face, p) + Assert ((boundary.normal_vector (vs, p) - normal).norm() < diff --git a/tests/deal.II/normal_vector_03_2d.cc b/tests/deal.II/normal_vector_03_2d.cc index f0ac17e2b2..7dc4d1d755 100644 --- a/tests/deal.II/normal_vector_03_2d.cc +++ b/tests/deal.II/normal_vector_03_2d.cc @@ -72,7 +72,8 @@ int main () Triangulation<2> tria; StraightBoundary<2> boundary; - Boundary<2>::FaceVertexNormals normals; + std::vector > normals(GeometryInfo<2>::vertices_per_face); + for (unsigned int case_no=0; case_no<2; ++case_no) { deallog << "Case" << case_no << std::endl; @@ -82,7 +83,10 @@ int main () for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) { face=cell->face(face_no); - boundary.get_normals_at_vertices(face, normals); + std::vector > vs(GeometryInfo<2>::vertices_per_face); + for(unsigned int i=0; i::vertices_per_face; ++i) + vs[i] = face->vertex(i); + boundary.get_normals_at_points(vs, normals); for (double xi=0; xi<=1; xi+=0.234) for (double eta=0; eta<=1; eta+=0.234) @@ -99,10 +103,10 @@ int main () normal /= normal.norm(); deallog << "p=" << p - << ", n=" << boundary.normal_vector (face, p) + << ", n=" << boundary.normal_vector (vs, p) << std::endl; - Assert ((boundary.normal_vector (face, p) + Assert ((boundary.normal_vector (vs, p) - normal).norm() < diff --git a/tests/deal.II/normals_at_vertices_01.cc b/tests/deal.II/normals_at_vertices_01.cc index f10d2f493b..fdcdc855ea 100644 --- a/tests/deal.II/normals_at_vertices_01.cc +++ b/tests/deal.II/normals_at_vertices_01.cc @@ -68,7 +68,8 @@ int main () Triangulation<3> tria; StraightBoundary<3> boundary; - Boundary<3>::FaceVertexNormals normals; + std::vector > normals(GeometryInfo<3>::vertices_per_face); + for (unsigned int case_no=0; case_no<2; ++case_no) { deallog << "Case" << case_no << std::endl; @@ -79,7 +80,10 @@ int main () { deallog << " Face" << face_no << std::endl; face=cell->face(face_no); - boundary.get_normals_at_vertices(face, normals); + std::vector > v(GeometryInfo<3>::vertices_per_face); + for(unsigned int i=0; i::vertices_per_face; ++i) + v[i] = face->vertex(i); + boundary.get_normals_at_points(v, normals); for (unsigned int v=0; v::vertices_per_face; ++v) { deallog << " vertex=" << face->vertex(v) diff --git a/tests/deal.II/normals_at_vertices_02.cc b/tests/deal.II/normals_at_vertices_02.cc index 0451f25eaa..cbfde8409d 100644 --- a/tests/deal.II/normals_at_vertices_02.cc +++ b/tests/deal.II/normals_at_vertices_02.cc @@ -43,7 +43,7 @@ int main () HyperBallBoundary<3> boundary (Point<3>(1,0,0)); Triangulation<3> tria; - Boundary<3>::FaceVertexNormals normals; + std::vector > normals(GeometryInfo<3>::vertices_per_face); GridGenerator::hyper_ball (tria, Point<3>(1,0,0), 3); @@ -55,7 +55,12 @@ int main () { deallog << " Face" << face_no << std::endl; Triangulation<3>::face_iterator face = cell->face(face_no); - boundary.get_normals_at_vertices(face, normals); + + std::vector > v(GeometryInfo<3>::vertices_per_face); + for(unsigned int i=0; i::vertices_per_face; ++i) + v[i] = face->vertex(i); + boundary.get_normals_at_points(v, normals); + for (unsigned int v=0; v::vertices_per_face; ++v) { deallog << " vertex=" << face->vertex(v) -- 2.39.5