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

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