1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*----------------------------------------------------------------------------*/
26 #include "tetherPotentialList.H"
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 void Foam::tetherPotentialList::readTetherPotentialDict
32 const List<word>& siteIdList,
33 const dictionary& tetherPotentialDict,
34 const List<word>& tetherSiteIdList
38 Info<< nl << "Building tether potentials." << endl;
40 idMap_ = List<label>(siteIdList.size(), -1);
42 label tetherMapIndex = 0;
44 forAll(tetherSiteIdList, t)
46 word tetherPotentialName = tetherSiteIdList[t];
48 label tetherId = findIndex(siteIdList, tetherPotentialName);
52 FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
54 << "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 // ************************************************************************* //