3#ifndef DUNE_STARCD_READER_HH 
    4#define DUNE_STARCD_READER_HH 
   47  template <
class Gr
idType>
 
   57    static GridType* 
read(
const std::string& fileName, 
bool verbose = 
true)
 
   60      const int dim = GridType::dimension;
 
   65                   "Reading Star-CD format is not implemented for dimension " << dim);
 
   71      std::string vertexFileName = fileName + 
".vrt";
 
   74      std::ifstream vertexFile(vertexFileName.c_str());
 
   80      int numberOfVertices = 0;
 
   81      while (vertexFile >> dummyIdx) {
 
   86        for (
int k = 0; k < dim; k++)
 
   87          vertexFile >> position[k];
 
   92        std::cout << numberOfVertices << 
" vertices read." << std::endl;
 
   95      std::string elementFileName = fileName + 
".cel";
 
   98      std::ifstream elementFile(elementFileName.c_str());
 
  103      int numberOfElements = 0;
 
  104      int numberOfSimplices = 0;
 
  105      int numberOfPyramids = 0;
 
  106      int numberOfPrisms = 0;
 
  107      int numberOfCubes = 0;;
 
  108      int maxNumberOfVertices = (int)pow(2, dim);
 
  110      while (elementFile >> dummyIdx) {
 
  111        std::vector<unsigned int> vertices(maxNumberOfVertices);
 
  112        for (
int k = 0; k < maxNumberOfVertices; k++)
 
  113          elementFile >> vertices[k];
 
  116        elementFile >> boundaryId;
 
  118        int volumeOrSurface[2];
 
  119        elementFile >> volumeOrSurface[0] >> volumeOrSurface[1];
 
  121        if (volumeOrSurface[0] == isVolume) {
 
  124          if (vertices[2] == vertices[3]) {           
 
  125            if (vertices[4] == vertices[5]) {             
 
  127              std::vector<unsigned int> simplexVertices(4);
 
  128              for (
int k = 0; k < 3; k++)
 
  129                simplexVertices[k] = vertices[k] - 1;
 
  130              simplexVertices[3] = vertices[4] - 1;
 
  135              std::vector<unsigned int> prismVertices(6);
 
  136              for (
int k = 0; k < 3; k++)
 
  137                prismVertices[k] = vertices[k] - 1;
 
  138              for (
int k = 3; k < 6; k++)
 
  139                prismVertices[k] = vertices[k+1] - 1;
 
  144            if (vertices[4] == vertices[5]) {             
 
  146              std::vector<unsigned int> pyramidVertices(5);
 
  147              for (
int k = 0; k < 5; k++)
 
  148                pyramidVertices[k] = vertices[k] - 1;
 
  153              std::vector<unsigned int> cubeVertices(8);
 
  154              for (
int k = 0; k < 8; k++)
 
  155                cubeVertices[k] = vertices[k] - 1;
 
  156              std::swap(cubeVertices[2], cubeVertices[3]);
 
  157              std::swap(cubeVertices[6], cubeVertices[7]);
 
  164        std::cout << numberOfElements << 
" elements read: " 
  165                  << numberOfSimplices << 
" simplices, " << numberOfPyramids << 
" pyramids, " 
  166                  << numberOfPrisms << 
" prisms, " << numberOfCubes << 
" cubes." << std::endl;
 
  170        std::cout << 
"Starting createGrid() ... " << std::flush;
 
vector space out of a tensor product of fields.
Definition: fvector.hh:94
 
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
 
@ cube
Cube element in any nonnegative dimension.
Definition: type.hh:31
 
@ simplex
Simplicial element in any nonnegative dimension.
Definition: type.hh:30
 
@ pyramid
Four sided pyramid in three dimensions.
Definition: type.hh:32
 
@ prism
Prism element in three dimensions.
Definition: type.hh:33
 
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:263
 
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)
Insert an element into the coarse grid.
Definition: gridfactory.hh:290
 
virtual GridType * createGrid()
Finalize grid creation and hand over the grid.
Definition: gridfactory.hh:316
 
virtual void insertVertex(const FieldVector< ctype, dimworld > &pos)
Insert a vertex into the coarse grid.
Definition: gridfactory.hh:279
 
Default exception class for I/O errors.
Definition: exceptions.hh:256
 
Default exception for dummy implementations.
Definition: exceptions.hh:288
 
File reader for the Star-CD format.
Definition: starcdreader.hh:48
 
static GridType * read(const std::string &fileName, bool verbose=true)
Read grid from a Star-CD file.
Definition: starcdreader.hh:57
 
Provide a generic factory class for unstructured grids.
 
A few common exception classes.
 
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
 
Dune namespace.
Definition: alignment.hh:10
 
A unique label for each type of element that can occur in a grid.