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
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,7 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fanFvPatchField.H"
|
||||
#include "IOmanip.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -36,7 +35,7 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
|
||||
)
|
||||
:
|
||||
fixedJumpFvPatchField<Type>(p, iF),
|
||||
f_(0)
|
||||
jumpTable_(0)
|
||||
{}
|
||||
|
||||
|
||||
@ -50,7 +49,7 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
|
||||
)
|
||||
:
|
||||
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),
|
||||
f_()
|
||||
{
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
jumpTable_(DataEntry<Type>::New("jumpTable", dict))
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
@ -95,7 +74,7 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
|
||||
:
|
||||
cyclicLduInterfaceField(),
|
||||
fixedJumpFvPatchField<Type>(ptf),
|
||||
f_(ptf.f_)
|
||||
jumpTable_(ptf.jumpTable_().clone().ptr())
|
||||
{}
|
||||
|
||||
|
||||
@ -107,7 +86,7 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
|
||||
)
|
||||
:
|
||||
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);
|
||||
|
||||
IOstream::streamFormat fmt0 = os.format(IOstream::ASCII);
|
||||
os.writeKeyword("f") << f_ << token::END_STATEMENT << nl;
|
||||
os.format(fmt0);
|
||||
|
||||
if (this->cyclicPatch().owner())
|
||||
{
|
||||
jumpTable_->writeData(os);
|
||||
}
|
||||
this->writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,43 @@ Class
|
||||
Foam::fanFvPatchField
|
||||
|
||||
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
|
||||
fanFvPatchField.C
|
||||
@ -36,6 +72,7 @@ SourceFiles
|
||||
#define fanFvPatchField_H
|
||||
|
||||
#include "fixedJumpFvPatchField.H"
|
||||
#include "DataEntry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -53,8 +90,8 @@ class fanFvPatchField
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Fan pressure rise polynomial coefficients
|
||||
List<scalar> f_;
|
||||
//- Interpolation table
|
||||
autoPtr<DataEntry<Type> > jumpTable_;
|
||||
|
||||
|
||||
public:
|
||||
@ -126,15 +163,6 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the polynomial coefficients
|
||||
const List<scalar>& f() const
|
||||
{
|
||||
return f_;
|
||||
}
|
||||
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
@ -148,6 +176,13 @@ public:
|
||||
|
||||
//- Specialisation of the jump-condition for the pressure
|
||||
template<>
|
||||
fanFvPatchField<scalar>::fanFvPatchField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
template<>
|
||||
void fanFvPatchField<scalar>::updateCoeffs();
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,6 +27,8 @@ License
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "Tuple2.H"
|
||||
#include "polynomial.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -41,24 +43,87 @@ makeTemplatePatchTypeField
|
||||
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 * * * * * * * * * * * * * //
|
||||
|
||||
//- Specialisation of the jump-condition for the pressure
|
||||
template<>
|
||||
void Foam::fanFvPatchField<Foam::scalar>::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
if (this->updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Note that the neighbour side jump_ data is never actually used; the
|
||||
// jump() function just calls the owner side jump().
|
||||
|
||||
// Constant
|
||||
jump_ = f_[0];
|
||||
|
||||
if (f_.size() > 1)
|
||||
if (this->cyclicPatch().owner())
|
||||
{
|
||||
const surfaceScalarField& phi =
|
||||
db().lookupObject<surfaceScalarField>("phi");
|
||||
@ -73,12 +138,7 @@ void Foam::fanFvPatchField<Foam::scalar>::updateCoeffs()
|
||||
Un /= patch().lookupPatchField<volScalarField, scalar>("rho");
|
||||
}
|
||||
|
||||
for (label i=1; i<f_.size(); i++)
|
||||
{
|
||||
jump_ += f_[i]*pow(Un, i);
|
||||
}
|
||||
|
||||
jump_ = max(jump_, scalar(0));
|
||||
jump_ = jumpTable_->value(Un);
|
||||
}
|
||||
|
||||
fixedJumpFvPatchField<scalar>::updateCoeffs();
|
||||
|
||||
Reference in New Issue
Block a user