Dune Core Modules (2.9.0)

dgfidentitygrid.hh
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_DGFPARSER_DGFIDENTITYGRID_HH
6#define DUNE_DGFPARSER_DGFIDENTITYGRID_HH
7
9
11#include <dune/grid/io/file/dgfparser/dgfparser.hh>
12#include <dune/grid/utility/hostgridaccess.hh>
13
14namespace Dune
15{
16
17 // DGFGridFactory for IdentityGrid
18 // -------------------------------
19
20 template< class HostGrid >
21 struct DGFGridFactory< IdentityGrid< HostGrid > >
22 {
23 typedef IdentityGrid< HostGrid > Grid;
24
25 const static int dimension = Grid::dimension;
26 typedef MPIHelper::MPICommunicator MPICommunicator;
27 typedef typename Grid::template Codim<0>::Entity Element;
28 typedef typename Grid::template Codim<dimension>::Entity Vertex;
29
30 explicit DGFGridFactory ( std::istream &input,
31 MPICommunicator comm = MPIHelper::getCommunicator() )
32 : dgfHostFactory_( input, comm ),
33 grid_( 0 )
34 {
35 HostGrid *hostGrid = dgfHostFactory_.grid();
36 assert( hostGrid != 0 );
37 grid_ = new Grid( *hostGrid );
38 }
39
40 explicit DGFGridFactory ( const std::string &filename,
41 MPICommunicator comm = MPIHelper::getCommunicator() )
42 : dgfHostFactory_( filename, comm ),
43 grid_( 0 )
44 {
45 HostGrid *hostGrid = dgfHostFactory_.grid();
46 assert( hostGrid != 0 );
47 std::ifstream input( filename.c_str() );
48 grid_ = new Grid( *hostGrid );
49 }
50
51 Grid *grid () const
52 {
53 return grid_;
54 }
55
56 template< class Intersection >
57 bool wasInserted ( const Intersection &intersection ) const
58 {
59 return dgfHostFactory_.wasInserted( HostGridAccess< Grid >::hostIntersection( intersection ) );
60 }
61
62 template< class Intersection >
63 int boundaryId ( const Intersection &intersection ) const
64 {
65 return dgfHostFactory_.boundaryId( HostGridAccess< Grid >::hostIntersection( intersection ) );
66 }
67
68 template< int codim >
69 int numParameters () const
70 {
71 return dgfHostFactory_.template numParameters< codim >();
72 }
73
74 template< class Entity >
75 std::vector< double > &parameter ( const Entity &entity )
76 {
77 return dgfHostFactory_.parameter( HostGridAccess< Grid >::hostEntity( entity ) );
78 }
79
80 private:
81 DGFGridFactory< HostGrid > dgfHostFactory_;
82 Grid *grid_;
83 };
84
85
86
87 // DGFGridInfo for IdGrid
88 // ----------------------
89
90 template< class HostGrid >
91 struct DGFGridInfo< IdentityGrid< HostGrid > >
92 {
93 static int refineStepsForHalf ()
94 {
96 }
97
98 static double refineWeight ()
99 {
101 }
102 };
103
104}
105
106#endif // #ifndef DUNE_DGFPARSER_DGFIDENTITYGRID_HH
static constexpr int dimension
The dimension of the grid.
Definition: grid.hh:387
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition: mpihelper.hh:190
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:198
Traits for type conversions and type information.
The IdentityGrid class.
Dune namespace.
Definition: alignedallocator.hh:13
static double refineWeight()
static int refineStepsForHalf()
number of globalRefine steps needed to refuce h by 0.5
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)