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_()
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// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
const tetherPotential * set(const label i) const
Definition: PtrList.H:138
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Base class for film (stress-based) force models.
Definition: force.H:59
scalar energy(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
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
points setSize(newPointi)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333