From aacb2a6ce323b7def36bb76139e91586bdb41dc9 Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 21 Feb 2003 15:06:22 +0000 Subject: [PATCH] GridIn::read_xda git-svn-id: https://svn.dealii.org/trunk@7208 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/grid_in.h | 12 +++++ deal.II/deal.II/source/grid/grid_in.cc | 69 ++++++++++++++++++++++++++ deal.II/doc/news/2002/c-3-4.html | 8 +++ 3 files changed, 89 insertions(+) diff --git a/deal.II/deal.II/include/grid/grid_in.h b/deal.II/deal.II/include/grid/grid_in.h index 7745df8ea6..4e2efeefa6 100644 --- a/deal.II/deal.II/include/grid/grid_in.h +++ b/deal.II/deal.II/include/grid/grid_in.h @@ -73,6 +73,11 @@ class SubCellData; * output since we don't know their meaning, but the data that is read * is enough to build up the mesh as intended by the mesh generator. * This format can be read by the @p{read_dbmesh} function. + * + * @item @p{XDA} format: this is a rather simple format used by the MGF + * code. We don't have an exact specification of the format, but the reader + * can read in several example files. If the reader does not grok your files, + * it should be fairly simple to extend it. * @end{itemize} * * @@ -159,6 +164,13 @@ class GridIn */ void read_dbmesh (std::istream &); + /** + * Read grid data from a file + * containing data in the XDA + * format. + */ + void read_xda (std::istream &); + /** * Exception */ diff --git a/deal.II/deal.II/source/grid/grid_in.cc b/deal.II/deal.II/source/grid/grid_in.cc index 93c75bdb7e..4a6485a96f 100644 --- a/deal.II/deal.II/source/grid/grid_in.cc +++ b/deal.II/deal.II/source/grid/grid_in.cc @@ -362,6 +362,75 @@ void GridIn::read_dbmesh (std::istream &in) +template +void GridIn::read_xda (std::istream &in) +{ + Assert (tria != 0, ExcNoTriangulationSelected()); + AssertThrow (in, ExcIO()); + + std::string line; + // skip comments at start of file + getline (in, line); + + + unsigned int n_vertices; + unsigned int n_cells; + + // read cells, throw away rest of line + in >> n_cells; + getline (in, line); + + in >> n_vertices; + getline (in, line); + + // ignore following 8 lines + for (unsigned int i=0; i<8; ++i) + getline (in, line); + + // set up array of cells + std::vector > cells (n_cells); + SubCellData subcelldata; + + for (unsigned int cell=0; cell::vertices_per_cell; ++i) + in >> cells[cell].vertices[i]; + }; + + + + // set up array of vertices + std::vector > vertices (n_vertices); + for (unsigned int vertex=0; vertex> x[0] >> x[1] >> x[2]; + + // store vertex + for (unsigned int d=0; d::reorder_cells (cells); + tria->create_triangulation (vertices, cells, subcelldata); +} + + + + template void GridIn::skip_empty_lines (std::istream &in) { diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index c2ba3e5b04..6bac839afa 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -739,6 +739,14 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

deal.II

    +
  1. + New: There is now a function GridIn::read_xda that allows reading + grids from a file in XDA format. +
    + (WB 2003/02/21) +

    +
  2. Changed: Some implementation details of the GridReordering class have been moved to a -- 2.39.5