externalFileSource.H
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) 2019-2022 OpenCFD Ltd.
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 Class
27  Foam::fa::externalFileSource
28 
29 Group
30  grpFaOptionsSources
31 
32 Description
33  Applies sources on a specified field within a specified region
34  by using an external table file.
35 
36 Usage
37  Minimal example by using \c constant/faOptions:
38  \verbatim
39  externalFileSource1
40  {
41  // Mandatory entries (unmodifiable)
42  type externalFileSource;
43  fieldName <fieldName>;
44  tableName <tableFileName.dat>;
45 
46  // Mandatory/Optional (inherited) entries
47  ...
48  }
49  \endverbatim
50 
51  where the entries mean:
52  \table
53  Property | Description | Type | Reqd | Dflt
54  type | Type name: externalFileSource | word | yes | -
55  fieldName | Name of operand field | word | yes | -
56  tableName | Name of operand table file | word | yes | -
57  store | Register external field 'pExt' | bool | no | false
58  \endtable
59 
60  The inherited entries are elaborated in:
61  - \link faOption.H \endlink
62  - \link faceSetOption.H \endlink
63 
64 See also
65  - Foam::PatchFunction1Types
66 
67 SourceFiles
68  externalFileSource.C
69 
70 \*---------------------------------------------------------------------------*/
71 
72 #ifndef Foam_fa_externalFileSource_H
73 #define Foam_fa_externalFileSource_H
74 
75 #include "faOption.H"
76 #include "areaFields.H"
77 #include "faceSetOption.H"
78 #include "MappedFile.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 namespace fa
85 {
86 
87 /*---------------------------------------------------------------------------*\
88  Class externalFileSource Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 class externalFileSource
92 :
93  public fa::faceSetOption
94 {
95  // Private Data
96 
97  //- Name of the field to apply this source
98  word fieldName_;
99 
100  //- Name of the table
101  word tableName_;
102 
103  //- External pressure field
104  DimensionedField<scalar, areaMesh> pExt_;
105 
106  //- Current time index (used for updating)
107  label curTimeIndex_;
108 
109  //- Mapped data from file
110  PtrList<PatchFunction1Types::MappedFile<scalar>> mapping_;
111 
112 
113  // Private Member Functions
114 
115  //- Update the pExt_ mapping
116  void updateMapping();
117 
118 
119 public:
120 
121  //- Runtime type information
122  TypeName("externalFileSource");
123 
124 
125  // Constructors
126 
127  //- Construct from explicit source name and mesh
129  (
130  const word& sourceName,
131  const word& modelType,
132  const dictionary& dict,
133  const fvMesh& mesh
134  );
135 
136  //- No copy construct
137  externalFileSource(const externalFileSource&) = delete;
138 
139  //- No copy assignment
140  void operator=(const externalFileSource&) = delete;
141 
142 
143  //- Destructor
144  virtual ~externalFileSource() = default;
145 
146 
147  // Member Functions
148 
149  // Evaluation
150 
151  //- Add explicit contribution to compressible momentum equation
152  virtual void addSup
153  (
154  const areaScalarField& rho,
155  faMatrix<scalar>& eqn,
156  const label fieldi
157  );
158 
159 
160  // IO
161 
162  //- Read source dictionary
163  virtual bool read(const dictionary& dict);
164 };
165 
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace fa
170 } // End namespace Foam
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************************************************************* //
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: faOptionI.H:29
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
Applies sources on a specified field within a specified region by using an external table file...
virtual void addSup(const areaScalarField &rho, faMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to compressible momentum equation.
A class for handling words, derived from Foam::string.
Definition: word.H:63
void operator=(const externalFileSource &)=delete
No copy assignment.
TypeName("externalFileSource")
Runtime type information.
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual ~externalFileSource()=default
Destructor.
externalFileSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
A special matrix type and solver, designed for finite area solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: faMatricesFwd.H:37
Namespace for OpenFOAM.