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 -------------------------------------------------------------------------------
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 \*---------------------------------------------------------------------------*/
27 
28 #include "externalFileSource.H"
29 #include "fam.H"
30 #include "faScalarMatrix.H"
33 
34 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace fa
39 {
40  defineTypeNameAndDebug(externalFileSource, 0);
41  addToRunTimeSelectionTable(option, externalFileSource, dictionary);
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  (
61  IOobject
62  (
63  "pExt",
64  mesh_.time().timeName(),
65  mesh_,
66  IOobject::NO_READ,
67  IOobject::NO_WRITE
68  ),
69  regionMesh(),
71  zeroGradientFaPatchScalarField::typeName
72  ),
73  value_
74  (
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 
88  fa::option::resetApplied();
89 
90  read(dict);
91 }
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
97 (
98  const areaScalarField& solidMass,
99  faMatrix<scalar>& eqn,
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 {
121  if (fa::option::read(dict))
122  {
123  return true;
124  }
125 
126  return false;
127 }
128 
129 
130 // ************************************************************************* //
Foam::dimPressure
const dimensionSet dimPressure
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::faMatrix
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatricesFwd.H:43
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
fam.H
Namespace of functions to calculate implicit derivatives returning a matrix. Time derivatives are cal...
Foam::fa::faceSetOption
Intermediate abstract class for handling face-set options for the derived faOptions.
Definition: faceSetOption.H:134
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::fa::defineTypeNameAndDebug
defineTypeNameAndDebug(limitVelocity, 0)
Foam::blockMeshTools::read
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:57
Foam::fa::externalFileSource::addSup
virtual void addSup(const areaScalarField &rho, faMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to compressible momentum equation.
Definition: externalFileSource.C:97
Foam::fa::externalFileSource::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: externalFileSource.C:119
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fa::option::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: faOptionIO.C:54
zeroGradientFaPatchFields.H
Foam::PatchFunction1Types::MappedFile< scalar >
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
Foam::faMatrix::psi
const GeometricField< Type, faPatchField, areaMesh > & psi() const
Definition: faMatrix.H:255
Foam::fa::externalFileSource::externalFileSource
externalFileSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvPatch &patch)
Construct from explicit source name and mesh.
Definition: externalFileSource.C:49
faScalarMatrix.H
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fa::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, limitVelocity, dictionary)
externalFileSource.H
timeIndex
label timeIndex
Definition: getTimeIndex.H:30
Foam::GeometricField< scalar, faPatchField, areaMesh >