ENH: freestream BC: allow inlet value to be specified by another patch
The freestreamFvPatchField previously employed a fixed value when supplying the inlet values. This commit extends the BC so that users can use another patch to supply the values via the new freestreamBC entry, e.g. to set the velocity to an atmospheric boundary layer profile: inlet { type freestream; freestreamBC { type atmBoundaryLayerInletVelocity; flowDir (1 0 0); zDir (0 0 1); Uref 20; Zref 20; z0 uniform 0.1; zGround uniform 935; } } The earlier specification is also maintained for backwards compatibility, e.g. inlet { type freestream; freestreamValue uniform (300 0 0); }
This commit is contained in:
parent
b8c257d6ad
commit
31a439dc99
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -34,7 +34,8 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
|
|||||||
const DimensionedField<Type, volMesh>& iF
|
const DimensionedField<Type, volMesh>& iF
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
inletOutletFvPatchField<Type>(p, iF)
|
inletOutletFvPatchField<Type>(p, iF),
|
||||||
|
freestreamBCPtr_()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -46,13 +47,17 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
|
|||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
inletOutletFvPatchField<Type>(p, iF)
|
inletOutletFvPatchField<Type>(p, iF),
|
||||||
|
freestreamBCPtr_()
|
||||||
{
|
{
|
||||||
this->patchType() = dict.lookupOrDefault<word>("patchType", word::null);
|
this->patchType() = dict.lookupOrDefault<word>("patchType", word::null);
|
||||||
|
|
||||||
this->phiName_ = dict.lookupOrDefault<word>("phi","phi");
|
this->phiName_ = dict.lookupOrDefault<word>("phi","phi");
|
||||||
|
|
||||||
freestreamValue() = Field<Type>("freestreamValue", dict, p.size());
|
if (dict.found("freestreamValue"))
|
||||||
|
{
|
||||||
|
freestreamValue() =
|
||||||
|
Field<Type>("freestreamValue", dict, p.size());
|
||||||
|
|
||||||
if (dict.found("value"))
|
if (dict.found("value"))
|
||||||
{
|
{
|
||||||
@ -66,6 +71,20 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
|
|||||||
fvPatchField<Type>::operator=(freestreamValue());
|
fvPatchField<Type>::operator=(freestreamValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Freestream value provided by another patch
|
||||||
|
freestreamBCPtr_ =
|
||||||
|
fvPatchField<Type>::New(p, iF, dict.subDict("freestreamBC"));
|
||||||
|
|
||||||
|
// Force user to supply an initial value
|
||||||
|
// - we do not know if the supplied BC has all dependencies available
|
||||||
|
fvPatchField<Type>::operator=
|
||||||
|
(
|
||||||
|
Field<Type>("value", dict, p.size())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -77,8 +96,15 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
|
|||||||
const fvPatchFieldMapper& mapper
|
const fvPatchFieldMapper& mapper
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
inletOutletFvPatchField<Type>(ptf, p, iF, mapper)
|
inletOutletFvPatchField<Type>(ptf, p, iF, mapper),
|
||||||
{}
|
freestreamBCPtr_()
|
||||||
|
{
|
||||||
|
if (ptf.freestreamBCPtr_.valid())
|
||||||
|
{
|
||||||
|
freestreamBCPtr_ =
|
||||||
|
fvPatchField<Type>::New(ptf.freestreamBCPtr_(), p, iF, mapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -87,8 +113,14 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
|
|||||||
const freestreamFvPatchField<Type>& ptf
|
const freestreamFvPatchField<Type>& ptf
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
inletOutletFvPatchField<Type>(ptf)
|
inletOutletFvPatchField<Type>(ptf),
|
||||||
{}
|
freestreamBCPtr_()
|
||||||
|
{
|
||||||
|
if (ptf.freestreamBCPtr_.valid())
|
||||||
|
{
|
||||||
|
freestreamBCPtr_ = ptf.freestreamBCPtr_->clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -98,18 +130,81 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
|
|||||||
const DimensionedField<Type, volMesh>& iF
|
const DimensionedField<Type, volMesh>& iF
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
inletOutletFvPatchField<Type>(ptf, iF)
|
inletOutletFvPatchField<Type>(ptf, iF),
|
||||||
{}
|
freestreamBCPtr_()
|
||||||
|
{
|
||||||
|
if (ptf.freestreamBCPtr_.valid())
|
||||||
|
{
|
||||||
|
freestreamBCPtr_ = ptf.freestreamBCPtr_->clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::freestreamFvPatchField<Type>::autoMap(const fvPatchFieldMapper& m)
|
||||||
|
{
|
||||||
|
inletOutletFvPatchField<Type>::autoMap(m);
|
||||||
|
if (freestreamBCPtr_.valid())
|
||||||
|
{
|
||||||
|
freestreamBCPtr_->autoMap(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::freestreamFvPatchField<Type>::rmap
|
||||||
|
(
|
||||||
|
const fvPatchField<Type>& ptf,
|
||||||
|
const labelList& addr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
inletOutletFvPatchField<Type>::rmap(ptf, addr);
|
||||||
|
|
||||||
|
const auto& fsptf = refCast<const freestreamFvPatchField<Type>>(ptf);
|
||||||
|
|
||||||
|
if (fsptf.freestreamBCPtr_.valid())
|
||||||
|
{
|
||||||
|
freestreamBCPtr_->rmap(fsptf.freestreamBCPtr_(), addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::freestreamFvPatchField<Type>::updateCoeffs()
|
||||||
|
{
|
||||||
|
if (this->updated())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (freestreamBCPtr_.valid())
|
||||||
|
{
|
||||||
|
freestreamBCPtr_->evaluate();
|
||||||
|
freestreamValue() = freestreamBCPtr_();
|
||||||
|
}
|
||||||
|
|
||||||
|
inletOutletFvPatchField<Type>::updateCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::freestreamFvPatchField<Type>::write(Ostream& os) const
|
void Foam::freestreamFvPatchField<Type>::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
fvPatchField<Type>::write(os);
|
fvPatchField<Type>::write(os);
|
||||||
os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_);
|
os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_);
|
||||||
|
|
||||||
|
if (freestreamBCPtr_.valid())
|
||||||
|
{
|
||||||
|
os.beginBlock("freestreamBC");
|
||||||
|
freestreamBCPtr_->write(os);
|
||||||
|
os.endBlock();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
freestreamValue().writeEntry("freestreamValue", os);
|
freestreamValue().writeEntry("freestreamValue", os);
|
||||||
|
}
|
||||||
this->writeEntry("value", os);
|
this->writeEntry("value", os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -36,11 +36,13 @@ Description
|
|||||||
Usage
|
Usage
|
||||||
\table
|
\table
|
||||||
Property | Description | Required | Default value
|
Property | Description | Required | Default value
|
||||||
freestreamValue | freestream velocity | yes |
|
freestreamValue | freestream velocity | no |
|
||||||
|
freestreamBC | patchField providing the inlet field | no |
|
||||||
phi | flux field name | no | phi
|
phi | flux field name | no | phi
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
Example of the boundary condition specification:
|
Example of the boundary condition specification using a fixed value
|
||||||
|
inlet condition:
|
||||||
\verbatim
|
\verbatim
|
||||||
<patchName>
|
<patchName>
|
||||||
{
|
{
|
||||||
@ -49,6 +51,26 @@ Usage
|
|||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
Example of the boundary condition specification using a separate condition
|
||||||
|
to proveide the inlet condition:
|
||||||
|
\verbatim
|
||||||
|
<patchName>
|
||||||
|
{
|
||||||
|
type freestream;
|
||||||
|
freestreamBC
|
||||||
|
{
|
||||||
|
type atmBoundaryLayerInletVelocity;
|
||||||
|
flowDir (1 0 0);
|
||||||
|
zDir (0 0 1);
|
||||||
|
Uref 20;
|
||||||
|
Zref 20;
|
||||||
|
z0 uniform 0.1;
|
||||||
|
zGround uniform 935;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
|
||||||
See also
|
See also
|
||||||
Foam::mixedFvPatchField
|
Foam::mixedFvPatchField
|
||||||
Foam::inletOutletFvPatchField
|
Foam::inletOutletFvPatchField
|
||||||
@ -77,6 +99,11 @@ class freestreamFvPatchField
|
|||||||
:
|
:
|
||||||
public inletOutletFvPatchField<Type>
|
public inletOutletFvPatchField<Type>
|
||||||
{
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- BC to supply the freestream value
|
||||||
|
tmp<fvPatchField<Type>> freestreamBCPtr_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -147,6 +174,22 @@ public:
|
|||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
|
|
||||||
|
// Mapping functions
|
||||||
|
|
||||||
|
//- Map (and resize as needed) from self given a mapping object
|
||||||
|
virtual void autoMap(const fvPatchFieldMapper& mapper);
|
||||||
|
|
||||||
|
//- Reverse map the given fvPatchField onto this fvPatchField
|
||||||
|
virtual void rmap
|
||||||
|
(
|
||||||
|
const fvPatchField<Type>& ptf,
|
||||||
|
const labelList& addr
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Update the coefficients associated with the patch field
|
||||||
|
virtual void updateCoeffs();
|
||||||
|
|
||||||
// Return defining fields
|
// Return defining fields
|
||||||
|
|
||||||
const Field<Type>& freestreamValue() const
|
const Field<Type>& freestreamValue() const
|
||||||
|
Loading…
Reference in New Issue
Block a user