1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM 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 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*----------------------------------------------------------------------------*/
27 #include "tetherPotentialList.H"
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 void Foam::tetherPotentialList::readTetherPotentialDict
33 const List<word>& siteIdList,
34 const dictionary& tetherPotentialDict,
35 const List<word>& tetherSiteIdList
39 Info<< nl << "Building tether potentials." << endl;
41 idMap_ = List<label>(siteIdList.size(), -1);
43 label tetherMapIndex = 0;
45 forAll(tetherSiteIdList, t)
47 word tetherPotentialName = tetherSiteIdList[t];
49 label tetherId = findIndex(siteIdList, tetherPotentialName);
53 FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
54 << nl << "No matching entry found in siteIdList for tether name "
55 << tetherPotentialName
58 else if (!tetherPotentialDict.found(tetherPotentialName))
60 FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
61 << nl << "tether potential specification subDict "
62 << tetherPotentialName << " not found"
73 tetherPotentialDict.subDict(tetherPotentialName)
78 idMap_[tetherId] = tetherMapIndex;
85 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
87 Foam::tetherPotentialList::tetherPotentialList()
89 PtrList<tetherPotential>(),
94 Foam::tetherPotentialList::tetherPotentialList
96 const List<word>& siteIdList,
97 const dictionary& tetherPotentialDict,
98 const List<word>& tetherSiteIdList
101 PtrList<tetherPotential>(),
104 buildPotentials(siteIdList, tetherPotentialDict, tetherSiteIdList);
108 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
110 Foam::tetherPotentialList::~tetherPotentialList()
114 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116 void Foam::tetherPotentialList::buildPotentials
118 const List<word>& siteIdList,
119 const dictionary& tetherPotentialDict,
120 const List<word>& tetherSiteIdList
123 setSize(tetherSiteIdList.size());
125 readTetherPotentialDict(siteIdList, tetherPotentialDict, tetherSiteIdList);
129 const Foam::tetherPotential& Foam::tetherPotentialList::tetherPotentialFunction
134 return (*this)[tetherPotentialIndex(a)];
138 Foam::vector Foam::tetherPotentialList::force
144 return (*this)[tetherPotentialIndex(a)].force(rIT);
148 Foam::scalar Foam::tetherPotentialList::energy
154 return (*this)[tetherPotentialIndex(a)].energy(rIT);
158 // ************************************************************************* //