externalFileSource.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) 2019-2021 OpenCFD Ltd.
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 "externalFileSource.H"
29#include "fam.H"
30#include "faScalarMatrix.H"
33
34// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
35
36namespace Foam
37{
38namespace fa
39{
42}
43}
44
45
46// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47
49(
50 const word& sourceName,
51 const word& modelType,
52 const dictionary& dict,
53 const fvPatch& p
54)
55:
56 fa::faceSetOption(sourceName, modelType, dict, p),
57 fieldName_(dict.get<word>("fieldName")),
58 tableName_(dict.get<word>("tableName")),
59 pExt_
60 (
62 (
63 "pExt",
64 mesh_.time().timeName(),
65 mesh_,
66 IOobject::NO_READ,
67 IOobject::NO_WRITE
68 ),
69 regionMesh(),
70 dimensionedScalar("pExt", dimPressure, Zero),
71 zeroGradientFaPatchScalarField::typeName
72 ),
73 value_
74 (
75 new PatchFunction1Types::MappedFile<scalar>
76 (
77 p.patch(),
78 "uniformValue",
79 dict,
80 tableName_, // field table name
81 true // face values
82 )
83 ),
84 curTimeIndex_(-1)
85{
86 fieldNames_.resize(1, fieldName_);
87
89
90 read(dict);
91}
92
93
94// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95
97(
98 const areaScalarField& solidMass,
100 const label fieldi
101)
102{
103 const scalar t = mesh().time().value();
104
105 if (isActive() && t > timeStart() && t < (timeStart() + duration()))
106 {
107 DebugInfo<< name() << ": applying source to " << eqn.psi().name()<<endl;
108
109 if (curTimeIndex_ != mesh().time().timeIndex())
110 {
111 pExt_.field() = value_->value(t);
112 eqn += pExt_/solidMass;
113 curTimeIndex_ = mesh().time().timeIndex();
114 }
115 }
116}
117
118
120{
122 {
123 return true;
124 }
125
126 return false;
127}
128
129
130// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
virtual bool read()
Re-read model coefficients if they have changed.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatrix.H:76
const GeometricField< Type, faPatchField, areaMesh > & psi() const
Definition: faMatrix.H:270
Applies sources on a specified field within a specified region by using an external table file for co...
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual void addSup(const areaScalarField &rho, faMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to compressible momentum equation.
Intermediate abstract class for handling face-set options for the derived faOptions.
Base abstract class for handling finite area options (i.e. faOption).
Definition: faOption.H:134
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: faOption.H:164
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: faOption.C:45
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
volScalarField & p
dynamicFvMesh & mesh
Namespace of functions to calculate implicit derivatives returning a matrix. Time derivatives are cal...
word timeName
Definition: getTimeIndex.H:3
#define DebugInfo
Report an information message using Foam::Info.
Namespace for OpenFOAM.
const dimensionSet dimPressure
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
label timeIndex
Definition: getTimeIndex.H:30
dictionary dict