KASKADE 7 development version
ioTools.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the library KASKADE 7 */
4/* https://www.zib.de/research/projects/kaskade7-finite-element-toolbox */
5/* */
6/* Copyright (C) 2002-2023 Zuse Institute Berlin */
7/* */
8/* KASKADE 7 is distributed under the terms of the ZIB Academic License. */
9/* see $KASKADE/academic.txt */
10/* */
11/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13#ifndef IO_TOOLS_HH
14#define IO_TOOLS_HH
15
16#if HAVE_UG
17#include <dune/grid/uggrid/uggridfactory.hh>
18#endif
19
20#if ENABLE_ALUGRID
21#include <dune/alugrid/3d/gridfactory.hh>
22#endif
23
24namespace Kaskade
25{
26 namespace IOTools
27 {
34 template <class Grid>
35 struct FactoryGenerator
36 {
37 using Factory = Dune::GridFactory<Grid>;
38
39 static Factory createFactory(unsigned int /* unused */ =0)
40 {
41 return Factory();
42 }
43 };
44
45 template <class Grid>
46 struct BoundarySegmentIndexWrapper
47 {
48 template <class Factory, class VertexVector, class BoundaryVector, class TmpIdVector, class IdVector>
49 static void readBoundarySegmentIndices(Grid const& grid, Factory const& factory, VertexVector const& vertices, BoundaryVector const& boundary, TmpIdVector const& boundaryIdsFromFile, IdVector& boundaryIds)
50 {
51 boundaryIds.resize(boundaryIdsFromFile.size());
52 for (auto const& cell : elements(grid.leafGridView()))
53 for (auto const& intersection : intersections(grid.leafGridView(), cell))
54 if (intersection.boundary())
55 boundaryIds[intersection.boundarySegmentIndex()]
56 = boundaryIdsFromFile[factory.insertionIndex(intersection)][0];
57 }
58 };
59
63 } // namespace IOTools
64} // namespace Kaskade
65
66#endif // IO_TOOLS_HH
A pluggable factory.
Definition: factory.hh:59