Dune Core Modules (unstable)

gridparameter.hh
1// SPDX-FileCopyrightText: Copyright © 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_DGF_GRIDPARAMETERBLOCK_HH
6#define DUNE_DGF_GRIDPARAMETERBLOCK_HH
7
8#include <iostream>
9#include <string>
10
11#include <dune/grid/io/file/dgfparser/blocks/basic.hh>
12
13
14namespace Dune
15{
16
17 namespace dgf
18 {
34 : public BasicBlock
35 {
36 public:
37 typedef unsigned int Flags;
38
39 static const Flags foundName = 1 << 0;
40 static const Flags foundDumpFileName = 1 << 1;
41 static const Flags foundLongestEdge = 1 << 5;
42 static const Flags foundCompatible = 1 << 13;
43
44 protected:
45 Flags foundFlags_; // supportFlags, this block was created with
46 std::string name_; // name of the grid
47 std::string dumpFileName_; // name of the grid
48 bool markLongestEdge_; // Mark longest edge for AlbertaGrid or ALUGrid
49 bool bisectionCompatibility_; // true if grid is compatible (bisection refinement works)
50
51 private:
52 // copy not implemented
54
55 public:
57 GridParameterBlock ( std::istream &in );
58
60 const std::string &name ( const std::string &defaultValue ) const
61 {
62 if( (foundFlags_ & foundName) == 0 )
63 {
64 dwarn << "GridParameterBlock: Parameter 'name' not specified, "
65 << "defaulting to '" << defaultValue << "'." << std::endl;
66 return defaultValue;
67 }
68 else
69 return name_;
70 }
71
72 const std::string &dumpFileName ( ) const
73 {
74 if( (foundFlags_ & foundDumpFileName) != 0 )
75 {
76 dwarn << "GridParameterBlock: found Parameter 'dumpfilename', "
77 << "dumping file to `" << dumpFileName_ << "'" << std::endl;
78 }
79 return dumpFileName_;
80 }
81
83 bool markLongestEdge () const
84 {
85 if( (foundFlags_ & foundLongestEdge) == 0 )
86 {
87 dwarn << "GridParameterBlock: Parameter 'refinementedge' not specified, "
88 << "defaulting to 'ARBITRARY'." << std::endl;
89 }
90 return markLongestEdge_;
91 }
92
95 {
96 if( (foundFlags_ & foundCompatible) == 0 )
97 {
98 dwarn << "GridParameterBlock: Parameter 'bisectioncompatibility' not specified, "
99 << "defaulting to '0' (false)." << std::endl;
100 }
101 return bisectionCompatibility_;
102 }
103
104 // some information
105 bool ok()
106 {
107 return true;
108 }
109 };
110
111
112 } // end namespace dgf
113
114} // end namespace Dune
115
116#endif
Common Grid parameters.
Definition: gridparameter.hh:35
GridParameterBlock(std::istream &in)
constructor: read common parameters
const std::string & name(const std::string &defaultValue) const
return the name of the grid
Definition: gridparameter.hh:60
bool bisectionCompatibility() const
returns true if grid is compatible for bisection refinement
Definition: gridparameter.hh:94
bool markLongestEdge() const
returns true if longest edge should be marked for AlbertaGrid
Definition: gridparameter.hh:83
DWarnType dwarn(std::cerr)
Stream for warnings indicating problems.
Definition: stdstreams.hh:162
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)