forceList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 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 "forceList.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 namespace regionModels
33 {
34 namespace surfaceFilmModels
35 {
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
40 :
41  PtrList<force>()
42 {}
43 
44 
46 (
48  const dictionary& dict
49 )
50 :
52 {
53  Info<< " Selecting film force models" << endl;
54 
55  if (dict.isDict("forces"))
56  {
57  const dictionary& forcesDict(dict.subDict("forces"));
58  this->setSize(forcesDict.size());
59 
60  label i = 0;
61  forAllConstIter(dictionary, forcesDict, iter)
62  {
63  set
64  (
65  i++,
67  (
68  film,
69  forcesDict.isDict(iter().keyword())
70  ? forcesDict.subDict(iter().keyword())
72  iter().keyword()
73  )
74  );
75  }
76  }
77  else if (dict.found("forces"))
78  {
79  const wordList models(dict.lookup("forces"));
80  this->setSize(models.size());
81 
82  forAll(models, i)
83  {
84  set(i, force::New(film, dict, models[i]));
85  }
86  }
87 
88  if (!size())
89  {
90  Info<< " none" << endl;
91  }
92 }
93 
94 
95 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
96 
98 {}
99 
100 
101 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
102 
104 {
105  tmp<fvVectorMatrix> tResult
106  (
107  new fvVectorMatrix(U, dimForce)
108  );
109  fvVectorMatrix& result = tResult.ref();
110 
111  forAll(*this, i)
112  {
113  result += this->operator[](i).correct(U);
114  }
115 
116  return tResult;
117 }
118 
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 } // End namespace surfaceFilmModels
123 } // End namespace regionModels
124 } // End namespace Foam
125 
126 // ************************************************************************* //
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:663
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
U
Definition: pEqn.H:72
Base class for film (stress-based) force models.
Definition: force.H:55
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
const T & operator[](const label) const
Return element const reference.
Definition: UPtrListI.H:96
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
bool isDict(const word &) const
Check if entry is a sub-dictionary.
Definition: dictionary.C:956
tmp< fvVectorMatrix > correct(volVectorField &U)
Return (net) force system.
Definition: forceList.C:103
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:1002
static const dictionary null
Null dictionary.
Definition: dictionary.H:242
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
const dimensionSet dimForce
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
Definition: PtrList.C:131
static autoPtr< force > New(surfaceFilmRegionModel &film, const dictionary &dict, const word &modelType)
Return a reference to the selected force model.
Definition: forceNew.C:40
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
forceList(surfaceFilmRegionModel &film)
Construct null.
Definition: forceList.C:39
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45
messageStream Info
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864