copy of flowRateInletVelocity BC
This commit is contained in:
commit
42158324e1
4 changed files with 448 additions and 0 deletions
3
Make/files
Normal file
3
Make/files
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
flowRateTiltedInletVelocityFvPatchVectorField.C
|
||||
|
||||
LIB = $(FOAM_USER_LIBBIN)/libSKGASBC
|
||||
9
Make/options
Normal file
9
Make/options
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/triSurface/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
|
||||
LIB_LIBS = \
|
||||
-lOpenFOAM \
|
||||
-ltriSurface \
|
||||
-lmeshTools
|
||||
222
flowRateTiltedInletVelocityFvPatchVectorField.C
Normal file
222
flowRateTiltedInletVelocityFvPatchVectorField.C
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "flowRateTiltedInletVelocityFvPatchVectorField.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::flowRateTiltedInletVelocityFvPatchVectorField::
|
||||
flowRateTiltedInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(p, iF),
|
||||
flowRate_(),
|
||||
volumetric_(false),
|
||||
rhoName_("rho"),
|
||||
rhoInlet_(0.0)
|
||||
{}
|
||||
|
||||
|
||||
Foam::flowRateTiltedInletVelocityFvPatchVectorField::
|
||||
flowRateTiltedInletVelocityFvPatchVectorField
|
||||
(
|
||||
const flowRateTiltedInletVelocityFvPatchVectorField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
|
||||
flowRate_(ptf.flowRate_().clone().ptr()),
|
||||
volumetric_(ptf.volumetric_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
rhoInlet_(ptf.rhoInlet_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::flowRateTiltedInletVelocityFvPatchVectorField::
|
||||
flowRateTiltedInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(p, iF),
|
||||
rhoInlet_(dict.lookupOrDefault<scalar>("rhoInlet", -VGREAT))
|
||||
{
|
||||
if (dict.found("volumetricFlowRate"))
|
||||
{
|
||||
volumetric_ = true;
|
||||
flowRate_ = DataEntry<scalar>::New("volumetricFlowRate", dict);
|
||||
rhoName_ = "rho";
|
||||
}
|
||||
else if (dict.found("massFlowRate"))
|
||||
{
|
||||
volumetric_ = false;
|
||||
flowRate_ = DataEntry<scalar>::New("massFlowRate", dict);
|
||||
rhoName_ = word(dict.lookupOrDefault<word>("rho", "rho"));
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"flowRateTiltedInletVelocityFvPatchVectorField::"
|
||||
"flowRateTiltedInletVelocityFvPatchVectorField"
|
||||
"(const fvPatch&, const DimensionedField<vector, volMesh>&,"
|
||||
" const dictionary&)",
|
||||
dict
|
||||
) << "Please supply either 'volumetricFlowRate' or"
|
||||
<< " 'massFlowRate' and 'rho'" << exit(FatalIOError);
|
||||
}
|
||||
|
||||
// Value field require if mass based
|
||||
if (dict.found("value"))
|
||||
{
|
||||
fvPatchField<vector>::operator=
|
||||
(
|
||||
vectorField("value", dict, p.size())
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
evaluate(Pstream::blocking);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::flowRateTiltedInletVelocityFvPatchVectorField::
|
||||
flowRateTiltedInletVelocityFvPatchVectorField
|
||||
(
|
||||
const flowRateTiltedInletVelocityFvPatchVectorField& ptf
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(ptf),
|
||||
flowRate_(ptf.flowRate_().clone().ptr()),
|
||||
volumetric_(ptf.volumetric_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
rhoInlet_(ptf.rhoInlet_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::flowRateTiltedInletVelocityFvPatchVectorField::
|
||||
flowRateTiltedInletVelocityFvPatchVectorField
|
||||
(
|
||||
const flowRateTiltedInletVelocityFvPatchVectorField& ptf,
|
||||
const DimensionedField<vector, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(ptf, iF),
|
||||
flowRate_(ptf.flowRate_().clone().ptr()),
|
||||
volumetric_(ptf.volumetric_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
rhoInlet_(ptf.rhoInlet_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::flowRateTiltedInletVelocityFvPatchVectorField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const scalar t = db().time().timeOutputValue();
|
||||
|
||||
// a simpler way of doing this would be nice
|
||||
const scalar avgU = -flowRate_->value(t)/gSum(patch().magSf());
|
||||
|
||||
tmp<vectorField> n = patch().nf();
|
||||
|
||||
if (volumetric_ || rhoName_ == "none")
|
||||
{
|
||||
// volumetric flow-rate or density not given
|
||||
operator==(n*avgU);
|
||||
}
|
||||
else
|
||||
{
|
||||
// mass flow-rate
|
||||
if (db().foundObject<volScalarField>(rhoName_))
|
||||
{
|
||||
const fvPatchField<scalar>& rhop =
|
||||
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
|
||||
|
||||
operator==(n*avgU/rhop);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use constant density
|
||||
if (rhoInlet_ < 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"flowRateTiltedInletVelocityFvPatchVectorField::updateCoeffs()"
|
||||
) << "Did not find registered density field " << rhoName_
|
||||
<< " and no constant density 'rhoInlet' specified"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
operator==(n*avgU/rhoInlet_);
|
||||
}
|
||||
}
|
||||
|
||||
fixedValueFvPatchVectorField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void Foam::flowRateTiltedInletVelocityFvPatchVectorField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchField<vector>::write(os);
|
||||
flowRate_->writeData(os);
|
||||
if (!volumetric_)
|
||||
{
|
||||
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
|
||||
writeEntryIfDifferent<scalar>(os, "rhoInlet", -VGREAT, rhoInlet_);
|
||||
}
|
||||
writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchVectorField,
|
||||
flowRateTiltedInletVelocityFvPatchVectorField
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
214
flowRateTiltedInletVelocityFvPatchVectorField.H
Normal file
214
flowRateTiltedInletVelocityFvPatchVectorField.H
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::flowRateTiltedInletVelocityFvPatchVectorField
|
||||
|
||||
Group
|
||||
grpInletBoundaryConditions
|
||||
|
||||
Description
|
||||
This boundary condition provides a velocity boundary condition, derived
|
||||
from the flux (volumetric or mass-based), whose direction is assumed
|
||||
to be normal to the patch.
|
||||
|
||||
For a mass-based flux:
|
||||
- the flow rate should be provided in kg/s
|
||||
- if \c rhoName is "none" the flow rate is in m3/s
|
||||
- otherwise \c rhoName should correspond to the name of the density field
|
||||
- if the density field cannot be found in the database, the user must
|
||||
specify the inlet density using the \c rhoInlet entry
|
||||
|
||||
For a volumetric-based flux:
|
||||
- the flow rate is in m3/s
|
||||
|
||||
\heading Patch usage
|
||||
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
massFlowRate | mass flow rate [kg/s] | no |
|
||||
volumetricFlowRate | volumetric flow rate [m3/s]| no |
|
||||
rhoInlet | inlet density | no |
|
||||
\endtable
|
||||
|
||||
Example of the boundary condition specification for a volumetric flow rate:
|
||||
\verbatim
|
||||
myPatch
|
||||
{
|
||||
type flowRateTiltedInletVelocity;
|
||||
volumetricFlowRate 0.2;
|
||||
value uniform (0 0 0); // placeholder
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Example of the boundary condition specification for a mass flow rate:
|
||||
\verbatim
|
||||
myPatch
|
||||
{
|
||||
type flowRateTiltedInletVelocity;
|
||||
massFlowRate 0.2;
|
||||
rho rho;
|
||||
rhoInlet 1.0;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
The \c flowRate entry is a \c DataEntry type, meaning that it can be
|
||||
specified as constant, a polynomial fuction of time, and ...
|
||||
|
||||
Note
|
||||
- \c rhoInlet is required for the case of a mass flow rate, where the
|
||||
density field is not available at start-up
|
||||
- the value is positive into the domain (as an inlet)
|
||||
- may not work correctly for transonic inlets
|
||||
- strange behaviour with potentialFoam since the U equation is not solved
|
||||
|
||||
SeeAlso
|
||||
Foam::DataEntry
|
||||
Foam::fixedValueFvPatchField
|
||||
|
||||
SourceFiles
|
||||
flowRateTiltedInletVelocityFvPatchVectorField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef flowRateTiltedInletVelocityFvPatchVectorField_H
|
||||
#define flowRateTiltedInletVelocityFvPatchVectorField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "DataEntry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class flowRateTiltedInletVelocityFvPatchVectorField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class flowRateTiltedInletVelocityFvPatchVectorField
|
||||
:
|
||||
public fixedValueFvPatchVectorField
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Inlet integral flow rate
|
||||
autoPtr<DataEntry<scalar> > flowRate_;
|
||||
|
||||
//- Is volumetric?
|
||||
bool volumetric_;
|
||||
|
||||
//- Name of the density field used to normalize the mass flux
|
||||
word rhoName_;
|
||||
|
||||
//- Rho initialisation value (for start; if value not supplied)
|
||||
scalar rhoInlet_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("flowRateTiltedInletVelocity");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
flowRateTiltedInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<vector, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
flowRateTiltedInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<vector, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given
|
||||
// flowRateTiltedInletVelocityFvPatchVectorField
|
||||
// onto a new patch
|
||||
flowRateTiltedInletVelocityFvPatchVectorField
|
||||
(
|
||||
const flowRateTiltedInletVelocityFvPatchVectorField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<vector, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
flowRateTiltedInletVelocityFvPatchVectorField
|
||||
(
|
||||
const flowRateTiltedInletVelocityFvPatchVectorField&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchVectorField> clone() const
|
||||
{
|
||||
return tmp<fvPatchVectorField>
|
||||
(
|
||||
new flowRateTiltedInletVelocityFvPatchVectorField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
flowRateTiltedInletVelocityFvPatchVectorField
|
||||
(
|
||||
const flowRateTiltedInletVelocityFvPatchVectorField&,
|
||||
const DimensionedField<vector, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchVectorField> clone
|
||||
(
|
||||
const DimensionedField<vector, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchVectorField>
|
||||
(
|
||||
new flowRateTiltedInletVelocityFvPatchVectorField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Loading…
Add table
Reference in a new issue