Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
32void 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_()
106 buildPotentials(siteIdList, tetherPotentialDict, tetherSiteIdList);
107}
108
109
110// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
113{}
114
115
116// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117
119(
120 const List<word>& siteIdList,
121 const dictionary& tetherPotentialDict,
122 const List<word>& tetherSiteIdList
123)
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// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
const tetherPotential * set(const label i) const
Definition PtrList.H:171
constexpr PtrList() noexcept
Definition PtrListI.H:29
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
scalar energy(const label a, const vector rIT) const
vector force(const label a, const vector rIT) const
void buildPotentials(const List< word > &siteIdList, const dictionary &tetherPotentialDict, const List< word > &tetherSiteIdList)
const tetherPotential & tetherPotentialFunction(const label a) const
static autoPtr< tetherPotential > New(const word &name, const dictionary &tetherPotentialProperties)
Return a reference to the selected viscosity model.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
Vector< scalar > vector
Definition vector.H:57
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
points setSize(newPointi)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299