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) 2011-2015 OpenFOAM Foundation
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 
26 #include "tetherPotentialList.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
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  {
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  {
61  << nl << "tether potential specification subDict "
62  << tetherPotentialName << " not found"
63  << abort(FatalError);
64  }
65  else
66  {
67  this->set
68  (
69  tetherMapIndex,
71  (
72  tetherPotentialName,
73  tetherPotentialDict.subDict(tetherPotentialName)
74  )
75  );
76  }
77 
78  idMap_[tetherId] = tetherMapIndex;
79 
80  tetherMapIndex++;
81  }
82 }
83 
84 
85 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
86 
88 :
90  idMap_()
91 {}
92 
93 
95 (
96  const List<word>& siteIdList,
97  const dictionary& tetherPotentialDict,
98  const List<word>& tetherSiteIdList
99 )
100 :
102  idMap_()
103 {
104  buildPotentials(siteIdList, tetherPotentialDict, tetherSiteIdList);
105 }
106 
107 
108 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
109 
111 {}
112 
113 
114 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
115 
117 (
118  const List<word>& siteIdList,
119  const dictionary& tetherPotentialDict,
120  const List<word>& tetherSiteIdList
121 )
122 {
123  setSize(tetherSiteIdList.size());
124 
125  readTetherPotentialDict(siteIdList, tetherPotentialDict, tetherSiteIdList);
126 }
127 
128 
130 (
131  const label a
132 ) const
133 {
134  return (*this)[tetherPotentialIndex(a)];
135 }
136 
137 
139 (
140  const label a,
141  const vector rIT
142 ) const
143 {
144  return (*this)[tetherPotentialIndex(a)].force(rIT);
145 }
146 
147 
149 (
150  const label a,
151  const vector rIT
152 ) const
153 {
154  return (*this)[tetherPotentialIndex(a)].energy(rIT);
155 }
156 
157 
158 // ************************************************************************* //
Foam::tetherPotentialList::force
vector force(const label a, const vector rIT) const
Definition: tetherPotentialList.C:139
Foam::tetherPotential
Definition: tetherPotential.H:52
setSize
points setSize(newPointi)
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tetherPotentialList::~tetherPotentialList
~tetherPotentialList()
Destructor.
Definition: tetherPotentialList.C:110
Foam::findIndex
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
Foam::tetherPotentialList::energy
scalar energy(const label a, const vector rIT) const
Definition: tetherPotentialList.C:149
Foam::tetherPotentialList::buildPotentials
void buildPotentials(const List< word > &siteIdList, const dictionary &tetherPotentialDict, const List< word > &tetherSiteIdList)
Definition: tetherPotentialList.C:117
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
Foam::tetherPotentialList::tetherPotentialList
tetherPotentialList()
Definition: tetherPotentialList.C:87
Foam::tetherPotentialList::readTetherPotentialDict
void readTetherPotentialDict(const List< word > &siteIdList, const dictionary &tetherPotentialDict, const List< word > &tetherSiteIdList)
Definition: tetherPotentialList.C:31
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::tetherPotentialList::tetherPotentialFunction
const tetherPotential & tetherPotentialFunction(const label a) const
Definition: tetherPotentialList.C:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::Vector< scalar >
Foam::List< word >
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
tetherPotentialList.H
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631