FreeFOAM The Cross-Platform CFD Toolkit
tetherPotentialList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*----------------------------------------------------------------------------*/
25 
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 void Foam::tetherPotentialList::readTetherPotentialDict
31 (
32  const List<word>& siteIdList,
33  const dictionary& tetherPotentialDict,
34  const List<word>& tetherSiteIdList
35 )
36 {
37 
38  Info<< nl << "Building tether potentials." << endl;
39 
40  idMap_ = List<label>(siteIdList.size(), -1);
41 
42  label tetherMapIndex = 0;
43 
44  forAll(tetherSiteIdList, t)
45  {
46  word tetherPotentialName = tetherSiteIdList[t];
47 
48  label tetherId = findIndex(siteIdList, tetherPotentialName);
49 
50  if (tetherId == -1)
51  {
52  FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
53  << nl << "No matching entry found in siteIdList for tether name "
54  << tetherPotentialName
55  << abort(FatalError);
56  }
57  else if (!tetherPotentialDict.found(tetherPotentialName))
58  {
59  FatalErrorIn("tetherPotentialList::readTetherPotentialDict")
60  << nl << "tether potential specification subDict "
61  << tetherPotentialName << " not found"
62  << abort(FatalError);
63  }
64  else
65  {
66  this->set
67  (
68  tetherMapIndex,
70  (
71  tetherPotentialName,
72  tetherPotentialDict.subDict(tetherPotentialName)
73  )
74  );
75  }
76 
77  idMap_[tetherId] = tetherMapIndex;
78 
79  tetherMapIndex++;
80  }
81 }
82 
83 
84 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
85 
87 :
89  idMap_()
90 {}
91 
92 
94 (
95  const List<word>& siteIdList,
96  const dictionary& tetherPotentialDict,
97  const List<word>& tetherSiteIdList
98 )
99 :
101  idMap_()
102 {
103  buildPotentials(siteIdList, tetherPotentialDict, tetherSiteIdList);
104 }
105 
106 
107 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
108 
110 {}
111 
112 
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 
116 (
117  const List<word>& siteIdList,
118  const dictionary& tetherPotentialDict,
119  const List<word>& tetherSiteIdList
120 )
121 {
122  setSize(tetherSiteIdList.size());
123 
124  readTetherPotentialDict(siteIdList, tetherPotentialDict, tetherSiteIdList);
125 }
126 
127 
129 (
130  const label a
131 ) const
132 {
133  return (*this)[tetherPotentialIndex(a)];
134 }
135 
136 
138 (
139  const label a,
140  const vector rIT
141 ) const
142 {
143  return (*this)[tetherPotentialIndex(a)].force(rIT);
144 }
145 
146 
148 (
149  const label a,
150  const vector rIT
151 ) const
152 {
153  return (*this)[tetherPotentialIndex(a)].energy(rIT);
154 }
155 
156 
157 // ************************ vim: set sw=4 sts=4 et: ************************ //