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 "boxRefinement.H"
27 #include "addToRunTimeSelectionTable.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(boxRefinement, 0);
36 addToRunTimeSelectionTable(objectRefinement, boxRefinement, dictionary);
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 boxRefinement::boxRefinement()
52 boxRefinement::boxRefinement
55 const scalar cellSize,
60 //const scalar angleX,
61 //const scalar angleY,
75 setCellSize(cellSize);
78 boxRefinement::boxRefinement
81 const dictionary& dict
84 objectRefinement(name, dict)
86 this->operator=(dict);
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 bool boxRefinement::intersectsObject(const boundBox& bb) const
93 vector v(0.5*lengthX_, 0.5*lengthY_, 0.5*lengthZ_);
94 boundBox box(centre_ - v, centre_ + v);
96 if( box.overlaps(bb) )
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104 dictionary boxRefinement::dict(bool ignoreType) const
108 dict.add("cellSize", cellSize());
109 dict.add("type", type());
111 dict.add("centre", centre_);
112 dict.add("lengthX", lengthX_);
113 dict.add("lengthY", lengthY_);
114 dict.add("lengthZ", lengthZ_);
116 //dict.add("angleX", angleX_);
117 //dict.add("angleY", angleY_);
118 //dict.add("angleZ", angleZ_);
123 void boxRefinement::write(Ostream& os) const
125 os << " type: " << type()
126 << " centre: " << centre_
127 << " lengthX: " << lengthX_
128 << " lengthY: " << lengthY_
129 << " lengthZ: " << lengthZ_;
130 //<< " angleX: " << angleX_
131 //<< " angleY: " << angleY_
132 //<< " angleZ: " << angleZ_;
135 void boxRefinement::writeDict(Ostream& os, bool subDict) const
139 os << indent << token::BEGIN_BLOCK << incrIndent << nl;
142 os.writeKeyword("cellSize") << cellSize() << token::END_STATEMENT << nl;
144 // only write type for derived types
145 if( type() != typeName_() )
147 os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
150 os.writeKeyword("centre") << centre_ << token::END_STATEMENT << nl;
151 os.writeKeyword("lengthX") << lengthX_ << token::END_STATEMENT << nl;
152 os.writeKeyword("lengthY") << lengthY_ << token::END_STATEMENT << nl;
153 os.writeKeyword("lengthZ") << lengthZ_ << token::END_STATEMENT << nl;
154 //os.writeKeyword("angleX") << angleX_ << token::END_STATEMENT << nl;
155 //os.writeKeyword("angleY") << angleY_ << token::END_STATEMENT << nl;
156 //os.writeKeyword("angleZ") << angleZ_ << token::END_STATEMENT << nl;
160 os << decrIndent << indent << token::END_BLOCK << endl;
164 void boxRefinement::operator=(const dictionary& d)
166 // allow as embedded sub-dictionary "coordinateSystem"
167 const dictionary& dict =
170 ? d.subDict(typeName_())
174 // unspecified centre is (0 0 0)
175 if( dict.found("centre") )
177 dict.lookup("centre") >> centre_;
183 "void boxRefinement::operator=(const dictionary& d)"
184 ) << "Entry centre is not sopecified!" << exit(FatalError);
185 centre_ = vector::zero;
189 if( dict.found("lengthX") )
191 lengthX_ = readScalar(dict.lookup("lengthX"));
197 "void boxRefinement::operator=(const dictionary& d)"
198 ) << "Entry lengthX is not sopecified!" << exit(FatalError);
203 if( dict.found("lengthY") )
205 lengthY_ = readScalar(dict.lookup("lengthY"));
211 "void boxRefinement::operator=(const dictionary& d)"
212 ) << "Entry lengthY is not sopecified!" << exit(FatalError);
217 if( dict.found("lengthZ") )
219 lengthZ_ = readScalar(dict.lookup("lengthZ"));
225 "void boxRefinement::operator=(const dictionary& d)"
226 ) << "Entry lengthZ is not sopecified!" << exit(FatalError);
231 /* if( dict.found("angleX") )
233 angleX_ = readScalar(dict.lookup("angleX"));
241 if( dict.found("angleY") )
243 angleY_ = readScalar(dict.lookup("angleY"));
251 if( dict.found("angleZ") )
253 angleZ_ = readScalar(dict.lookup("angleZ"));
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 Ostream& boxRefinement::operator<<(Ostream& os) const
266 os << "name " << name() << nl;
267 os << "cell size " << cellSize() << nl;
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 } // End namespace Foam
276 // ************************************************************************* //