Dune Core Modules (2.9.1)

structuredyaspgridfactory.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_GRID_YASPGRID_STRUCTUREDYASPGRIDFACTORY_HH
6#define DUNE_GRID_YASPGRID_STRUCTUREDYASPGRIDFACTORY_HH
7
8#include <memory>
9
11
16namespace Dune
17{
27 template<class ctype, int dim>
29 {
31 static const int dimworld = GridType::dimensionworld;
32
33 public:
44 static std::unique_ptr<GridType>
46 const FieldVector<ctype,dimworld>& upperRight,
47 const std::array<unsigned int,dim>& elements)
48 {
49 using std::abs;
50 for(int d = 0; d < dimworld; ++d)
51 if(abs(lowerLeft[d]) > abs(upperRight[d])*1e-10)
52 DUNE_THROW(GridError, className<StructuredGridFactory>()
53 << "::createCubeGrid(): You have to use Yaspgrid<dim"
54 ", EquidistantOffsetCoordinates<ctype,dim> > as your"
55 "grid type for non-trivial origin." );
56
57 // construct array of ints instead of unsigned ints
58 std::array<int, dim> elem;
59 std::copy(elements.begin(), elements.end(), elem.begin());
60
61 return std::make_unique<GridType>(upperRight, elem,
62 std::bitset<dim>(), 1); // default constructor of bitset sets to zero
63 }
64
70 static std::unique_ptr<GridType>
72 const FieldVector<ctype,dimworld>& upperRight,
73 const std::array<unsigned int,dim>& elements)
74 {
75 DUNE_THROW(GridError, className<StructuredGridFactory>()
76 << "::createSimplexGrid(): Simplices are not supported "
77 "by YaspGrid.");
78 }
79
80 };
81
89 template<class ctype, int dim>
92 static const int dimworld = GridType::dimensionworld;
93
94 public:
101 static std::unique_ptr<GridType>
103 const FieldVector<ctype,dimworld>& upperRight,
104 const std::array<unsigned int,dim>& elements)
105 {
106 // construct array of ints instead of unsigned ints
107 std::array<int, dim> elem;
108 std::copy(elements.begin(), elements.end(), elem.begin());
109
110 return std::make_unique<GridType>(lowerLeft, upperRight, elem,
111 std::bitset<dim>(), 1); // default constructor of bitset sets to zero
112 }
113
119 static std::unique_ptr<GridType>
121 const FieldVector<ctype,dimworld>& upperRight,
122 const std::array<unsigned int,dim>& elements)
123 {
124 DUNE_THROW(GridError, className<StructuredGridFactory>()
125 << "::createSimplexGrid(): Simplices are not supported "
126 "by YaspGrid.");
127 }
128
129 };
130
131} // namespace Dune
132#endif
Container for equidistant coordinates in a YaspGrid.
Definition: coordinates.hh:29
Container for equidistant coordinates in a YaspGrid with non-trivial origin.
Definition: coordinates.hh:131
vector space out of a tensor product of fields.
Definition: fvector.hh:95
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:20
static std::unique_ptr< GridType > createCubeGrid(const FieldVector< ctype, dimworld > &lowerLeft, const FieldVector< ctype, dimworld > &upperRight, const std::array< unsigned int, dim > &elements)
Create a structured cube grid.
Definition: structuredyaspgridfactory.hh:45
static std::unique_ptr< GridType > createSimplexGrid(const FieldVector< ctype, dimworld > &lowerLeft, const FieldVector< ctype, dimworld > &upperRight, const std::array< unsigned int, dim > &elements)
Create a structured simplex grid.
Definition: structuredyaspgridfactory.hh:71
static std::unique_ptr< GridType > createCubeGrid(const FieldVector< ctype, dimworld > &lowerLeft, const FieldVector< ctype, dimworld > &upperRight, const std::array< unsigned int, dim > &elements)
Create a structured cube grid.
Definition: structuredyaspgridfactory.hh:102
static std::unique_ptr< GridType > createSimplexGrid(const FieldVector< ctype, dimworld > &lowerLeft, const FieldVector< ctype, dimworld > &upperRight, const std::array< unsigned int, dim > &elements)
Create a structured simplex grid.
Definition: structuredyaspgridfactory.hh:120
Construct structured cube and simplex grids in unstructured grid managers.
Definition: structuredgridfactory.hh:31
[ provides Dune::Grid ]
Definition: yaspgrid.hh:163
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
A class to construct structured cube and simplex grids using the grid factory.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)