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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "tetherPotentialList.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 void Foam::tetherPotentialList::readTetherPotentialDict
33 (
34  const List<word>& siteIdList,
35  const dictionary& tetherPotentialDict,
36  const List<word>& tetherSiteIdList
37 )
38 {
39 
40  Info<< nl << "Building tether potentials." << endl;
41 
42  idMap_ = List<label>(siteIdList.size(), -1);
43 
44  label tetherMapIndex = 0;
45 
46  forAll(tetherSiteIdList, t)
47  {
48  word tetherPotentialName = tetherSiteIdList[t];
49 
50  label tetherId = siteIdList.find(tetherPotentialName);
51 
52  if (tetherId == -1)
53  {
55  << nl
56  << "No matching entry found in siteIdList for tether name "
57  << tetherPotentialName
58  << abort(FatalError);
59  }
60  else if (!tetherPotentialDict.found(tetherPotentialName))
61  {
63  << nl << "tether potential specification subDict "
64  << tetherPotentialName << " not found"
65  << abort(FatalError);
66  }
67  else
68  {
69  this->set
70  (
71  tetherMapIndex,
73  (
74  tetherPotentialName,
75  tetherPotentialDict.subDict(tetherPotentialName)
76  )
77  );
78  }
79 
80  idMap_[tetherId] = tetherMapIndex;
81 
82  tetherMapIndex++;
83  }
84 }
85 
86 
87 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
88 
90 :
92  idMap_()
93 {}
94 
95 
97 (
98  const List<word>& siteIdList,
99  const dictionary& tetherPotentialDict,
100  const List<word>& tetherSiteIdList
101 )
102 :
104  idMap_()
105 {
106  buildPotentials(siteIdList, tetherPotentialDict, tetherSiteIdList);
107 }
108 
109 
110 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
111 
113 {}
114 
115 
116 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117 
119 (
120  const List<word>& siteIdList,
121  const dictionary& tetherPotentialDict,
122  const List<word>& tetherSiteIdList
123 )
124 {
125  setSize(tetherSiteIdList.size());
126 
127  readTetherPotentialDict(siteIdList, tetherPotentialDict, tetherSiteIdList);
128 }
129 
130 
132 (
133  const label a
134 ) const
135 {
136  return (*this)[tetherPotentialIndex(a)];
137 }
138 
139 
141 (
142  const label a,
143  const vector rIT
144 ) const
145 {
146  return (*this)[tetherPotentialIndex(a)].force(rIT);
147 }
148 
149 
151 (
152  const label a,
153  const vector rIT
154 ) const
155 {
156  return (*this)[tetherPotentialIndex(a)].energy(rIT);
157 }
158 
159 
160 // ************************************************************************* //
Foam::tetherPotentialList::force
vector force(const label a, const vector rIT) const
Definition: tetherPotentialList.C:141
Foam::tetherPotential
Definition: tetherPotential.H:55
setSize
points setSize(newPointi)
Foam::tetherPotential::New
static autoPtr< tetherPotential > New(const word &name, const dictionary &tetherPotentialProperties)
Return a reference to the selected viscosity model.
Definition: tetherPotentialNew.C:34
Foam::tetherPotentialList::~tetherPotentialList
~tetherPotentialList()
Destructor.
Definition: tetherPotentialList.C:112
Foam::tetherPotentialList::energy
scalar energy(const label a, const vector rIT) const
Definition: tetherPotentialList.C:151
Foam::tetherPotentialList::buildPotentials
void buildPotentials(const List< word > &siteIdList, const dictionary &tetherPotentialDict, const List< word > &tetherSiteIdList)
Definition: tetherPotentialList.C:119
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::PtrList< tetherPotential >::set
const tetherPotential * set(const label i) const
Return const pointer to element (can be nullptr),.
Definition: PtrList.H:138
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::tetherPotentialList::tetherPotentialList
tetherPotentialList()
Definition: tetherPotentialList.C:89
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::tetherPotentialList::tetherPotentialFunction
const tetherPotential & tetherPotentialFunction(const label a) const
Definition: tetherPotentialList.C:132
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::Vector< scalar >
Foam::List< word >
tetherPotentialList.H