OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

blockDescriptor.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "error.H"
00030 
00031 #include "blockDescriptor.H"
00032 #include "scalarList.H"
00033 
00034 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038 
00039 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00040 
00041 void blockDescriptor::makeBlockEdges()
00042 {
00043     // for all edges check the list of curved edges. If the edge is curved,
00044     // add it to the list. If the edge is not found, create is as a line
00045 
00046     setEdge(0, 0, 1, n_.x());
00047     setEdge(1, 3, 2, n_.x());
00048     setEdge(2, 7, 6, n_.x());
00049     setEdge(3, 4, 5, n_.x());
00050 
00051     setEdge(4, 0, 3, n_.y());
00052     setEdge(5, 1, 2, n_.y());
00053     setEdge(6, 5, 6, n_.y());
00054     setEdge(7, 4, 7, n_.y());
00055 
00056     setEdge(8, 0, 4, n_.z());
00057     setEdge(9, 1, 5, n_.z());
00058     setEdge(10, 2, 6, n_.z());
00059     setEdge(11, 3, 7, n_.z());
00060 }
00061 
00062 
00063 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00064 
00065 // from components
00066 blockDescriptor::blockDescriptor
00067 (
00068     const cellShape& bshape,
00069     const pointField& blockMeshPoints,
00070     const curvedEdgeList& edges,
00071     const Vector<label>& n,
00072     const scalarList& expand,
00073     const word& zoneName
00074 )
00075 :
00076     blockMeshPoints_(blockMeshPoints),
00077     blockShape_(bshape),
00078     curvedEdges_(edges),
00079     edgePoints_(12),
00080     edgeWeights_(12),
00081     n_(n),
00082     expand_(expand),
00083     zoneName_(zoneName)
00084 {
00085     if (expand_.size() != 12)
00086     {
00087         FatalErrorIn
00088         (
00089             "blockDescriptor::blockDescriptor"
00090             "(const cellShape& bshape, const pointField& blockMeshPoints, "
00091             "const curvedEdgeList& edges, label xnum, label ynum, label znum, "
00092             "const scalarList& expand, const word& zoneName)"
00093         )   << "Unknown definition of expansion ratios"
00094             << exit(FatalError);
00095     }
00096 
00097     makeBlockEdges();
00098 }
00099 
00100 
00101 // from Istream
00102 blockDescriptor::blockDescriptor
00103 (
00104     const pointField& blockMeshPoints,
00105     const curvedEdgeList& edges,
00106     Istream& is
00107 )
00108 :
00109     blockMeshPoints_(blockMeshPoints),
00110     blockShape_(is),
00111     curvedEdges_(edges),
00112     edgePoints_(12),
00113     edgeWeights_(12),
00114     n_(),
00115     expand_(12),
00116     zoneName_()
00117 {
00118     // Look at first token
00119     token t(is);
00120     is.putBack(t);
00121 
00122     // Optional zone name
00123     if (t.isWord())
00124     {
00125         zoneName_ = t.wordToken();
00126 
00127         // Consume zoneName token
00128         is >> t;
00129 
00130         // New look-ahead
00131         is >> t;
00132         is.putBack(t);
00133     }
00134 
00135     if (t.isPunctuation())
00136     {
00137         if (t.pToken() == token::BEGIN_LIST)
00138         {
00139             is >> n_;
00140         }
00141         else
00142         {
00143             FatalIOErrorIn
00144             (
00145                 "blockDescriptor::blockDescriptor"
00146                 "(const pointField&, const curvedEdgeList&, Istream& is)",
00147                 is
00148             )   << "incorrect token while reading n, expected '(', found "
00149                 << t.info()
00150                 << exit(FatalIOError);
00151         }
00152     }
00153     else
00154     {
00155         is >> n_.x() >> n_.y() >> n_.z();
00156     }
00157 
00158     is >> t;
00159     if (!t.isWord())
00160     {
00161         is.putBack(t);
00162     }
00163 
00164     scalarList expRatios(is);
00165 
00166     if (expRatios.size() == 3)
00167     {
00168         expand_[0] = expRatios[0];
00169         expand_[1] = expRatios[0];
00170         expand_[2] = expRatios[0];
00171         expand_[3] = expRatios[0];
00172 
00173         expand_[4] = expRatios[1];
00174         expand_[5] = expRatios[1];
00175         expand_[6] = expRatios[1];
00176         expand_[7] = expRatios[1];
00177 
00178         expand_[8] = expRatios[2];
00179         expand_[9] = expRatios[2];
00180         expand_[10] = expRatios[2];
00181         expand_[11] = expRatios[2];
00182     }
00183     else if (expRatios.size() == 12)
00184     {
00185         expand_ = expRatios;
00186     }
00187     else
00188     {
00189         FatalErrorIn
00190         (
00191             "blockDescriptor::blockDescriptor"
00192             "(const pointField& blockMeshPoints, const curvedEdgeList& edges,"
00193             "Istream& is)"
00194         )   << "Unknown definition of expansion ratios"
00195             << exit(FatalError);
00196     }
00197 
00198     // create a list of edges
00199     makeBlockEdges();
00200 }
00201 
00202 
00203 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00204 
00205 const pointField& blockDescriptor::points() const
00206 {
00207     return blockMeshPoints_;
00208 }
00209 
00210 const cellShape& blockDescriptor::blockShape() const
00211 {
00212     return blockShape_;
00213 }
00214 
00215 const List<List<point> >& blockDescriptor::blockEdgePoints() const
00216 {
00217     return edgePoints_;
00218 }
00219 
00220 const scalarListList& blockDescriptor::blockEdgeWeights() const
00221 {
00222     return edgeWeights_;
00223 }
00224 
00225 const Vector<label>& blockDescriptor::n() const
00226 {
00227     return n_;
00228 }
00229 
00230 const word& blockDescriptor::zoneName() const
00231 {
00232     return zoneName_;
00233 }
00234 
00235 
00236 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00237 
00238 void blockDescriptor::operator=(const blockDescriptor&)
00239 {
00240     notImplemented("void blockDescriptor::operator=(const blockDescriptor&)");
00241 }
00242 
00243 
00244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00245 
00246 } // End namespace Foam
00247 
00248 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd