FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

tetherPotentialList.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) 2008-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*----------------------------------------------------------------------------*/
00025 
00026 #include <potential/tetherPotentialList.H>
00027 
00028 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00029 
00030 void Foam::tetherPotentialList::readTetherPotentialDict
00031 (
00032     const List<word>& siteIdList,
00033     const dictionary& tetherPotentialDict,
00034     const List<word>& tetherSiteIdList
00035 )
00036 {
00037 
00038     Info<< nl << "Building tether potentials." << endl;
00039 
00040     idMap_ = List<label>(siteIdList.size(), -1);
00041 
00042     label tetherMapIndex = 0;
00043 
00044     forAll(tetherSiteIdList, t)
00045     {
00046         word tetherPotentialName = tetherSiteIdList[t];
00047 
00048         label tetherId = findIndex(siteIdList, tetherPotentialName);
00049 
00050         if (tetherId == -1)
00051         {
00052             FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
00053                 << nl << "No matching entry found in siteIdList for tether name "
00054                 << tetherPotentialName
00055                 << abort(FatalError);
00056         }
00057         else if (!tetherPotentialDict.found(tetherPotentialName))
00058         {
00059             FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
00060                 << nl << "tether potential specification subDict "
00061                 << tetherPotentialName << " not found"
00062                 << abort(FatalError);
00063         }
00064         else
00065         {
00066             this->set
00067             (
00068                 tetherMapIndex,
00069                 tetherPotential::New
00070                 (
00071                     tetherPotentialName,
00072                     tetherPotentialDict.subDict(tetherPotentialName)
00073                 )
00074             );
00075         }
00076 
00077         idMap_[tetherId] = tetherMapIndex;
00078 
00079         tetherMapIndex++;
00080     }
00081 }
00082 
00083 
00084 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00085 
00086 Foam::tetherPotentialList::tetherPotentialList()
00087 :
00088     PtrList<tetherPotential>(),
00089     idMap_()
00090 {}
00091 
00092 
00093 Foam::tetherPotentialList::tetherPotentialList
00094 (
00095     const List<word>& siteIdList,
00096     const dictionary& tetherPotentialDict,
00097     const List<word>& tetherSiteIdList
00098 )
00099 :
00100     PtrList<tetherPotential>(),
00101     idMap_()
00102 {
00103     buildPotentials(siteIdList, tetherPotentialDict, tetherSiteIdList);
00104 }
00105 
00106 
00107 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00108 
00109 Foam::tetherPotentialList::~tetherPotentialList()
00110 {}
00111 
00112 
00113 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00114 
00115 void Foam::tetherPotentialList::buildPotentials
00116 (
00117     const List<word>& siteIdList,
00118     const dictionary& tetherPotentialDict,
00119     const List<word>& tetherSiteIdList
00120 )
00121 {
00122     setSize(tetherSiteIdList.size());
00123 
00124     readTetherPotentialDict(siteIdList, tetherPotentialDict, tetherSiteIdList);
00125 }
00126 
00127 
00128 const Foam::tetherPotential& Foam::tetherPotentialList::tetherPotentialFunction
00129 (
00130     const label a
00131 ) const
00132 {
00133     return (*this)[tetherPotentialIndex(a)];
00134 }
00135 
00136 
00137 Foam::vector Foam::tetherPotentialList::force
00138 (
00139     const label a,
00140     const vector rIT
00141 ) const
00142 {
00143     return (*this)[tetherPotentialIndex(a)].force(rIT);
00144 }
00145 
00146 
00147 Foam::scalar Foam::tetherPotentialList::energy
00148 (
00149     const label a,
00150     const vector rIT
00151 ) const
00152 {
00153     return (*this)[tetherPotentialIndex(a)].energy(rIT);
00154 }
00155 
00156 
00157 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines