mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: fanFvPatchField: generic DataEntry form allowed
This commit is contained in:
@ -2,7 +2,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 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -24,7 +24,6 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "fanFvPatchField.H"
|
#include "fanFvPatchField.H"
|
||||||
#include "IOmanip.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
fixedJumpFvPatchField<Type>(p, iF),
|
fixedJumpFvPatchField<Type>(p, iF),
|
||||||
f_(0)
|
jumpTable_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -50,7 +49,7 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
fixedJumpFvPatchField<Type>(ptf, p, iF, mapper),
|
fixedJumpFvPatchField<Type>(ptf, p, iF, mapper),
|
||||||
f_(ptf.f_)
|
jumpTable_(ptf.jumpTable_().clone().ptr())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -63,28 +62,8 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
fixedJumpFvPatchField<Type>(p, iF),
|
fixedJumpFvPatchField<Type>(p, iF),
|
||||||
f_()
|
jumpTable_(DataEntry<Type>::New("jumpTable", dict))
|
||||||
{
|
{}
|
||||||
{
|
|
||||||
Istream& is = dict.lookup("f");
|
|
||||||
is.format(IOstream::ASCII);
|
|
||||||
is >> f_;
|
|
||||||
|
|
||||||
// Check that f_ table is same on both sides.?
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dict.found("value"))
|
|
||||||
{
|
|
||||||
fvPatchField<Type>::operator=
|
|
||||||
(
|
|
||||||
Field<Type>("value", dict, p.size())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->evaluate(Pstream::blocking);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -95,7 +74,7 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
|
|||||||
:
|
:
|
||||||
cyclicLduInterfaceField(),
|
cyclicLduInterfaceField(),
|
||||||
fixedJumpFvPatchField<Type>(ptf),
|
fixedJumpFvPatchField<Type>(ptf),
|
||||||
f_(ptf.f_)
|
jumpTable_(ptf.jumpTable_().clone().ptr())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -107,7 +86,7 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
fixedJumpFvPatchField<Type>(ptf, iF),
|
fixedJumpFvPatchField<Type>(ptf, iF),
|
||||||
f_(ptf.f_)
|
jumpTable_(ptf.jumpTable_().clone().ptr())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -119,11 +98,10 @@ void Foam::fanFvPatchField<Type>::write(Ostream& os) const
|
|||||||
{
|
{
|
||||||
|
|
||||||
fixedJumpFvPatchField<Type>::write(os);
|
fixedJumpFvPatchField<Type>::write(os);
|
||||||
|
if (this->cyclicPatch().owner())
|
||||||
IOstream::streamFormat fmt0 = os.format(IOstream::ASCII);
|
{
|
||||||
os.writeKeyword("f") << f_ << token::END_STATEMENT << nl;
|
jumpTable_->writeData(os);
|
||||||
os.format(fmt0);
|
}
|
||||||
|
|
||||||
this->writeEntry("value", os);
|
this->writeEntry("value", os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,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 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,7 +25,43 @@ Class
|
|||||||
Foam::fanFvPatchField
|
Foam::fanFvPatchField
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Foam::fanFvPatchField
|
Jump boundary condition. Operates on cyclic. Jump specified as a DataEntry.
|
||||||
|
(table, fileTable, csv etc.)
|
||||||
|
|
||||||
|
Example of the boundary condition specification:
|
||||||
|
\verbatim
|
||||||
|
fan_half0
|
||||||
|
{
|
||||||
|
type fan;
|
||||||
|
patchType cyclic;
|
||||||
|
jump uniform 0;
|
||||||
|
jumpTable csvFile;
|
||||||
|
csvFileCoeffs
|
||||||
|
{
|
||||||
|
hasHeaderLine 1;
|
||||||
|
refColumn 0;
|
||||||
|
componentColumns 1(1);
|
||||||
|
separator ",";
|
||||||
|
fileName "$FOAM_CASE/constant/pressureVsU";
|
||||||
|
}
|
||||||
|
value uniform 0;
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
|
||||||
|
Backwards compatibility: if the 'f' keyword is detected it assumes
|
||||||
|
it is a power of the flowrate.
|
||||||
|
|
||||||
|
\verbatim
|
||||||
|
fan_half0
|
||||||
|
{
|
||||||
|
type fan;
|
||||||
|
patchType cyclic;
|
||||||
|
jump uniform 0;
|
||||||
|
f 2(100 -0.1);
|
||||||
|
value uniform 0;
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
fanFvPatchField.C
|
fanFvPatchField.C
|
||||||
@ -36,6 +72,7 @@ SourceFiles
|
|||||||
#define fanFvPatchField_H
|
#define fanFvPatchField_H
|
||||||
|
|
||||||
#include "fixedJumpFvPatchField.H"
|
#include "fixedJumpFvPatchField.H"
|
||||||
|
#include "DataEntry.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -53,8 +90,8 @@ class fanFvPatchField
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Fan pressure rise polynomial coefficients
|
//- Interpolation table
|
||||||
List<scalar> f_;
|
autoPtr<DataEntry<Type> > jumpTable_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -126,15 +163,6 @@ public:
|
|||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
|
|
||||||
// Access
|
|
||||||
|
|
||||||
//- Return the polynomial coefficients
|
|
||||||
const List<scalar>& f() const
|
|
||||||
{
|
|
||||||
return f_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Evaluation functions
|
// Evaluation functions
|
||||||
|
|
||||||
//- Update the coefficients associated with the patch field
|
//- Update the coefficients associated with the patch field
|
||||||
@ -148,6 +176,13 @@ public:
|
|||||||
|
|
||||||
//- Specialisation of the jump-condition for the pressure
|
//- Specialisation of the jump-condition for the pressure
|
||||||
template<>
|
template<>
|
||||||
|
fanFvPatchField<scalar>::fanFvPatchField
|
||||||
|
(
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<scalar, volMesh>&,
|
||||||
|
const dictionary&
|
||||||
|
);
|
||||||
|
template<>
|
||||||
void fanFvPatchField<scalar>::updateCoeffs();
|
void fanFvPatchField<scalar>::updateCoeffs();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,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 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -27,6 +27,8 @@ License
|
|||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "surfaceFields.H"
|
#include "surfaceFields.H"
|
||||||
|
#include "Tuple2.H"
|
||||||
|
#include "polynomial.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -41,24 +43,87 @@ makeTemplatePatchTypeField
|
|||||||
fanFvPatchScalarField
|
fanFvPatchScalarField
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<>
|
||||||
|
Foam::fanFvPatchField<Foam::scalar>::fanFvPatchField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<scalar, volMesh>& iF,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedJumpFvPatchField<scalar>(p, iF),
|
||||||
|
jumpTable_(new DataEntry<scalar>("jumpTable"))
|
||||||
|
{
|
||||||
|
if (this->cyclicPatch().owner())
|
||||||
|
{
|
||||||
|
if (dict.found("f"))
|
||||||
|
{
|
||||||
|
// Backwards compatibility
|
||||||
|
Istream& is = dict.lookup("f");
|
||||||
|
is.format(IOstream::ASCII);
|
||||||
|
scalarList f(is);
|
||||||
|
|
||||||
|
label nPows = 0;
|
||||||
|
forAll(f, powI)
|
||||||
|
{
|
||||||
|
if (mag(f[powI]) > VSMALL)
|
||||||
|
{
|
||||||
|
nPows++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<Tuple2<scalar, scalar> > coeffs(nPows);
|
||||||
|
nPows = 0;
|
||||||
|
forAll(f, powI)
|
||||||
|
{
|
||||||
|
if (mag(f[powI]) > VSMALL)
|
||||||
|
{
|
||||||
|
coeffs[nPows++] = Tuple2<scalar, scalar>(f[powI], powI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Pout<< "** coeffss:" << coeffs << endl;
|
||||||
|
|
||||||
|
jumpTable_.reset
|
||||||
|
(
|
||||||
|
new polynomial("jumpTable", coeffs)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Generic input constructed from dictionary
|
||||||
|
jumpTable_ = DataEntry<scalar>::New("jumpTable", dict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (dict.found("value"))
|
||||||
|
{
|
||||||
|
fvPatchScalarField::operator=
|
||||||
|
(
|
||||||
|
scalarField("value", dict, p.size())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->evaluate(Pstream::blocking);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//- Specialisation of the jump-condition for the pressure
|
//- Specialisation of the jump-condition for the pressure
|
||||||
template<>
|
template<>
|
||||||
void Foam::fanFvPatchField<Foam::scalar>::updateCoeffs()
|
void Foam::fanFvPatchField<Foam::scalar>::updateCoeffs()
|
||||||
{
|
{
|
||||||
if (updated())
|
if (this->updated())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that the neighbour side jump_ data is never actually used; the
|
if (this->cyclicPatch().owner())
|
||||||
// jump() function just calls the owner side jump().
|
|
||||||
|
|
||||||
// Constant
|
|
||||||
jump_ = f_[0];
|
|
||||||
|
|
||||||
if (f_.size() > 1)
|
|
||||||
{
|
{
|
||||||
const surfaceScalarField& phi =
|
const surfaceScalarField& phi =
|
||||||
db().lookupObject<surfaceScalarField>("phi");
|
db().lookupObject<surfaceScalarField>("phi");
|
||||||
@ -73,12 +138,7 @@ void Foam::fanFvPatchField<Foam::scalar>::updateCoeffs()
|
|||||||
Un /= patch().lookupPatchField<volScalarField, scalar>("rho");
|
Un /= patch().lookupPatchField<volScalarField, scalar>("rho");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (label i=1; i<f_.size(); i++)
|
jump_ = jumpTable_->value(Un);
|
||||||
{
|
|
||||||
jump_ += f_[i]*pow(Un, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
jump_ = max(jump_, scalar(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fixedJumpFvPatchField<scalar>::updateCoeffs();
|
fixedJumpFvPatchField<scalar>::updateCoeffs();
|
||||||
|
|||||||
Reference in New Issue
Block a user