1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
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.
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
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "sphereRefinement.H"
27 #include "addToRunTimeSelectionTable.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(sphereRefinement, 0);
36 addToRunTimeSelectionTable(objectRefinement, sphereRefinement, dictionary);
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 sphereRefinement::sphereRefinement()
47 sphereRefinement::sphereRefinement
50 const scalar cellSize,
60 setCellSize(cellSize);
63 sphereRefinement::sphereRefinement
66 const dictionary& dict
69 objectRefinement(name, dict)
71 this->operator=(dict);
74 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 bool sphereRefinement::intersectsObject(const boundBox& bb) const
78 const point& c = (bb.max() + bb.min()) / 2.0;
80 if( magSqr(c - centre_) < sqr(radius_) )
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 dictionary sphereRefinement::dict(bool ignoreType) const
92 dict.add("cellSize", cellSize());
93 dict.add("type", type());
95 dict.add("centre", centre_);
96 dict.add("radius", radius_);
101 void sphereRefinement::write(Ostream& os) const
103 os << " type: " << type()
104 << " centre: " << centre_
105 << " radius: " << radius_;
108 void sphereRefinement::writeDict(Ostream& os, bool subDict) const
112 os << indent << token::BEGIN_BLOCK << incrIndent << nl;
115 os.writeKeyword("cellSize") << cellSize() << token::END_STATEMENT << nl;
117 // only write type for derived types
118 if( type() != typeName_() )
120 os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
123 os.writeKeyword("centre") << centre_ << token::END_STATEMENT << nl;
124 os.writeKeyword("radius") << radius_ << token::END_STATEMENT << nl;
128 os << decrIndent << indent << token::END_BLOCK << endl;
132 void sphereRefinement::operator=(const dictionary& d)
134 // allow as embedded sub-dictionary "coordinateSystem"
135 const dictionary& dict =
138 ? d.subDict(typeName_())
142 // unspecified centre is (0 0 0)
143 if( dict.found("centre") )
145 dict.lookup("centre") >> centre_;
151 "void sphereRefinement::operator=(const dictionary& d)"
152 ) << "Entry centre is not specified!" << exit(FatalError);
153 centre_ = vector::zero;
157 if( dict.found("radius") )
159 radius_ = readScalar(dict.lookup("radius"));
165 "void sphereRefinement::operator=(const dictionary& d)"
166 ) << "Entry radius is not specified!" << exit(FatalError);
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 Ostream& sphereRefinement::operator<<(Ostream& os) const
175 os << "name " << name() << nl;
176 os << "cell size " << cellSize() << nl;
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 } // End namespace Foam
185 // ************************************************************************* //