BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / lagrangian / molecularDynamics / potential / tetherPotential / tetherPotentialList / tetherPotentialList.C
blobe4c1b5df7ebc7cc237af374d06cbadcb0b12df38
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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)
45     {
46         word tetherPotentialName = tetherSiteIdList[t];
48         label tetherId = findIndex(siteIdList, tetherPotentialName);
50         if (tetherId == -1)
51         {
52             FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
53                 << nl
54                 << "No matching entry found in siteIdList for tether name "
55                 << tetherPotentialName
56                 << abort(FatalError);
57         }
58         else if (!tetherPotentialDict.found(tetherPotentialName))
59         {
60             FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
61                 << nl << "tether potential specification subDict "
62                 << tetherPotentialName << " not found"
63                 << abort(FatalError);
64         }
65         else
66         {
67             this->set
68             (
69                 tetherMapIndex,
70                 tetherPotential::New
71                 (
72                     tetherPotentialName,
73                     tetherPotentialDict.subDict(tetherPotentialName)
74                 )
75             );
76         }
78         idMap_[tetherId] = tetherMapIndex;
80         tetherMapIndex++;
81     }
85 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
87 Foam::tetherPotentialList::tetherPotentialList()
89     PtrList<tetherPotential>(),
90     idMap_()
94 Foam::tetherPotentialList::tetherPotentialList
96     const List<word>& siteIdList,
97     const dictionary& tetherPotentialDict,
98     const List<word>& tetherSiteIdList
101     PtrList<tetherPotential>(),
102     idMap_()
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
131     const label a
132 ) const
134     return (*this)[tetherPotentialIndex(a)];
138 Foam::vector Foam::tetherPotentialList::force
140     const label a,
141     const vector rIT
142 ) const
144     return (*this)[tetherPotentialIndex(a)].force(rIT);
148 Foam::scalar Foam::tetherPotentialList::energy
150     const label a,
151     const vector rIT
152 ) const
154     return (*this)[tetherPotentialIndex(a)].energy(rIT);
158 // ************************************************************************* //