initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / molecularDynamics / potential / tetherPotential / tetherPotentialList / tetherPotentialList.C
blob93498b8f711a2a8dc050e950e27eb51cc2ea1407
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
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 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
19     for more details.
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)
46     {
47         word tetherPotentialName = tetherSiteIdList[t];
49         label tetherId = findIndex(siteIdList, tetherPotentialName);
51         if (tetherId == -1)
52         {
53             FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
54                 << nl << "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 // ************************************************************************* //