objectRefinement.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "IOstream.H"
27 #include "objectRefinement.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 :
42  name_(),
43  cellSize_(-1.0),
44  additionalRefLevel_(0),
45  refThickness_(0.0)
46 {}
47 
49 (
50  const word& name,
51  const dictionary& dict
52 )
53 :
54  name_(name),
55  cellSize_(-1.0),
56  additionalRefLevel_(0),
57  refThickness_(0.0)
58 {
59  if( dict.found("cellSize") )
60  {
61  cellSize_ = readScalar(dict.lookup("cellSize"));
62 
63  if( cellSize_ < 0.0 )
64  {
66  (
67  "objectRefinement::objectRefinement"
68  "(const word&, const dictionary&)"
69  ) << "Specified cell size for object " << name_
70  << " is negative" << exit(FatalError);
71  }
72  }
73  else if( dict.found("additionalRefinementLevels") )
74  {
75  additionalRefLevel_ =
76  readLabel(dict.lookup("additionalRefinementLevels"));
77 
78  if( additionalRefLevel_ < 0 )
79  {
81  (
82  "objectRefinement::objectRefinement"
83  "(const word&, const dictionary&)"
84  ) << "Specified additionalRefinementLevel for object " << name_
85  << " is negative" << exit(FatalError);
86  }
87  }
88 
89  if( dict.found("refinementThickness") )
90  refThickness_ = readScalar(dict.lookup("refinementThickness"));
91 }
92 
93 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
94 
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
102 {
103  os << obr.name() << nl;
104  obr.writeDict(os, true);
105  return os;
106 }
107 
108 void objectRefinement::calculateAdditionalRefLevels(const scalar globalCellSize)
109 {
110  if( cellSize_ < 0.0 || additionalRefLevel_ != 0 )
111  return;
112 
113  scalar s = globalCellSize;
114 
115  label nMarked;
116  do
117  {
118  nMarked = 0;
119 
120  if( cellSize_ <= s * (1.+SMALL) )
121  {
122  ++nMarked;
124  }
125 
126  s /= 2.0;
127 
128  } while( nMarked != 0 );
129 
130 }
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 } // End namespace Foam
135 
136 // ************************************************************************* //
Foam::objectRefinement::cellSize_
scalar cellSize_
cell size for this object
Definition: objectRefinement.H:64
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::objectRefinement::calculateAdditionalRefLevels
void calculateAdditionalRefLevels(const scalar globalCellSize)
calculate additional refinement levels from cell size
Definition: objectRefinement.C:108
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::objectRefinement::additionalRefLevel_
label additionalRefLevel_
refinement level applicable to this object
Definition: objectRefinement.H:67
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::nl
static const char nl
Definition: Ostream.H:260
IOstream.H
Foam::objectRefinement
Definition: objectRefinement.H:54
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::objectRefinement::writeDict
virtual void writeDict(Ostream &, bool subDict=true) const =0
Write dictionary.
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::objectRefinement::objectRefinement
objectRefinement()
Null construct.
Definition: objectRefinement.C:40
s
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::objectRefinement::~objectRefinement
virtual ~objectRefinement()
Definition: objectRefinement.C:95
Foam::readScalar
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
Foam::readLabel
label readLabel(Istream &is)
Definition: label.H:64
Foam::objectRefinement::name
const word & name() const
Return name.
Definition: objectRefinement.H:136
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
objectRefinement.H
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
objectRefinement
Base class for coordinate systems. All systems are defined by an origin and a coordinate rotation.