From 954ded09c574137c95830d8618a9bc9440ed293c Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Mon, 14 Mar 2005 22:49:58 +0000 Subject: [PATCH] new parallelogram grid in 2d git-svn-id: https://svn.dealii.org/trunk@10135 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/grid_generator.h | 28 ++++++++- deal.II/deal.II/source/grid/grid_generator.cc | 59 +++++++++++++++---- 2 files changed, 71 insertions(+), 16 deletions(-) diff --git a/deal.II/deal.II/include/grid/grid_generator.h b/deal.II/deal.II/include/grid/grid_generator.h index c45842f9af..9d6440d185 100644 --- a/deal.II/deal.II/include/grid/grid_generator.h +++ b/deal.II/deal.II/include/grid/grid_generator.h @@ -1,15 +1,15 @@ -//---------------------------- grid_generator.h --------------------------- +//--------------------------------------------------------------------------- // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors +// Copyright (C) 1998 - 2005 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer // to the file deal.II/doc/license.html for the text and // further information on this license. // -//---------------------------- grid_generator.h --------------------------- +//--------------------------------------------------------------------------- #ifndef __deal2__grid_generator_h #define __deal2__grid_generator_h @@ -256,6 +256,28 @@ class GridGenerator const Point &p2, const bool colorize=false); + /** + * A parallelogram. The first + * corner point is the + * origin. The dim + * adjacent points are the + * one-dimensional subtensors of + * the tensor provided and + * additional points will be sums + * of these two vectors. + * Colorizing is done according + * to hyper_rectangle(). + * + * @note This function is + * implemented in 2d only. + */ + template + static void + parallelogram(Triangulation& tria, + const Tensor<2,dim>& corners, + const bool colorize=false); + + /** * Hypercube with a layer of * hypercubes around it. The diff --git a/deal.II/deal.II/source/grid/grid_generator.cc b/deal.II/deal.II/source/grid/grid_generator.cc index d87aa11418..f1787843fb 100644 --- a/deal.II/deal.II/source/grid/grid_generator.cc +++ b/deal.II/deal.II/source/grid/grid_generator.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -159,6 +159,35 @@ void GridGenerator::hyper_cube (Triangulation &tria, } +template +void +GridGenerator::parallelogram ( + Triangulation& tria, + const Tensor<2,dim>& corners, + const bool colorize) +{ + Assert (dim==2, ExcNotImplemented()); + + std::vector > vertices (GeometryInfo::vertices_per_cell); + + vertices[1] = corners[0]; + vertices[3] = corners[1]; + vertices[2] = vertices[1]; + vertices[2] += vertices[3]; + // Prepare cell data + std::vector > cells (1); + for (unsigned int i=0;i::vertices_per_cell;++i) + cells[0].vertices[i] = i; + cells[0].material_id = 0; + + tria.create_triangulation (vertices, cells, SubCellData()); + + // Assign boundary indicators + if (colorize) + colorize_hyper_rectangle (tria); +} + + template void GridGenerator::subdivided_hyper_cube (Triangulation &tria, @@ -598,7 +627,7 @@ GridGenerator::hyper_cube_slit (Triangulation<2> &tria, } - +//TODO: Colorize edges as circumference, left and right radius void GridGenerator::hyper_L (Triangulation<2> &tria, const double a, @@ -765,6 +794,7 @@ GridGenerator::cylinder (Triangulation<2> &tria, +//TODO: Colorize edges as circumference and cut plane void GridGenerator::half_hyper_ball (Triangulation<2> &tria, const Point<2> &p, @@ -1377,20 +1407,23 @@ void GridGenerator::laplace_solve (const SparseMatrix &S, // explicit instantiations template void -GridGenerator::hyper_rectangle (Triangulation &, - const Point&, - const Point&, - const bool); +GridGenerator::hyper_rectangle ( + Triangulation &, + const Point&, const Point&, + const bool); +template void +GridGenerator::hyper_cube ( + Triangulation &, const double, const double); template void -GridGenerator::hyper_cube (Triangulation &, - const double, - const double); +GridGenerator::parallelogram ( + Triangulation &, + const Tensor<2,deal_II_dimension>&, + const bool); template void -GridGenerator::subdivided_hyper_cube (Triangulation &, - const unsigned int, - const double, - const double); +GridGenerator::subdivided_hyper_cube ( + Triangulation &, + const unsigned int, const double, const double); template void GridGenerator::subdivided_hyper_rectangle -- 2.39.5