Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry
2012-02-09 10:37:31 +00:00
12 changed files with 446 additions and 202 deletions

View File

@ -31,8 +31,11 @@ License
namespace Foam
{
defineTypeNameAndDebug(polynomial, 0);
DataEntry<scalar>::adddictionaryConstructorToTable<polynomial>
addpolynomialConstructorToTable_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::polynomial::polynomial(const word& entryName, const dictionary& dict)
@ -48,7 +51,7 @@ Foam::polynomial::polynomial(const word& entryName, const dictionary& dict)
if (!coeffs_.size())
{
FatalErrorIn("Foam::polynomial::polynomial(const word&, Istream&)")
FatalErrorIn("Foam::polynomial::polynomial(const word&, dictionary&)")
<< "polynomial coefficients for entry " << this->name_
<< " are invalid (empty)" << nl << exit(FatalError);
}
@ -66,7 +69,7 @@ Foam::polynomial::polynomial(const word& entryName, const dictionary& dict)
{
if (!canIntegrate_)
{
WarningIn("Foam::polynomial::polynomial(const word&, Istream&)")
WarningIn("Foam::polynomial::polynomial(const word&, dictionary&)")
<< "Polynomial " << this->name_ << " cannot be integrated"
<< endl;
}
@ -74,6 +77,50 @@ Foam::polynomial::polynomial(const word& entryName, const dictionary& dict)
}
Foam::polynomial::polynomial
(
const word& entryName,
const List<Tuple2<scalar, scalar> >& coeffs
)
:
DataEntry<scalar>(entryName),
coeffs_(coeffs),
canIntegrate_(true)
{
if (!coeffs_.size())
{
FatalErrorIn
(
"Foam::polynomial::polynomial"
"(const word&, const List<Tuple2<scalar, scalar> >&&)"
) << "polynomial coefficients for entry " << this->name_
<< " are invalid (empty)" << nl << exit(FatalError);
}
forAll(coeffs_, i)
{
if (mag(coeffs_[i].second() + 1) < ROOTVSMALL)
{
canIntegrate_ = false;
break;
}
}
if (debug)
{
if (!canIntegrate_)
{
WarningIn
(
"Foam::polynomial::polynomial"
"(const word&, const List<Tuple2<scalar, scalar> >&&)"
) << "Polynomial " << this->name_ << " cannot be integrated"
<< endl;
}
}
}
Foam::polynomial::polynomial(const polynomial& poly)
:
DataEntry<scalar>(poly),

View File

@ -96,6 +96,9 @@ public:
polynomial(const word& entryName, const dictionary& dict);
//- Construct from components
polynomial(const word& entryName, const List<Tuple2<scalar, scalar> >&);
//- Copy constructor
polynomial(const polynomial& poly);

View File

@ -167,8 +167,10 @@ void Foam::basicSource::setCellSet()
Info<< indent << "- selecting inter region mapping" << endl;
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName_);
const boundBox primaryBB = mesh_.bounds();
const boundBox secondaryBB = secondaryMesh.bounds();
boundBox primaryBB(mesh_.points(), false);
boundBox secondaryBB(secondaryMesh.points(), false);
if (secondaryBB.overlaps(primaryBB))
{
// Dummy patches

View File

@ -137,100 +137,103 @@ void Foam::interRegionHeatTransferModel::addSup
const label fieldI
)
{
if (firstIter_)
if (secondaryToPrimaryInterpPtr_.valid())
{
check();
firstIter_ = false;
}
if (firstIter_)
{
check();
firstIter_ = false;
}
const volScalarField& h = eEqn.psi();
const volScalarField& h = eEqn.psi();
tmp<volScalarField> tTmapped
(
new volScalarField
tmp<volScalarField> tTmapped
(
IOobject
new volScalarField
(
"Tmapped" + mesh_.name(),
mesh_.time().timeName(),
IOobject
(
"Tmapped" + mesh_.name(),
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("T", dimTemperature, 0.0)
)
);
dimensionedScalar("T", dimTemperature, 0.0)
)
);
volScalarField& Tmapped = tTmapped();
volScalarField& Tmapped = tTmapped();
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName_);
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName_);
const volScalarField& Tsecondary =
secondaryMesh.lookupObject<volScalarField>("T");
const volScalarField& Tsecondary =
secondaryMesh.lookupObject<volScalarField>("T");
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
Tmapped,
Tsecondary,
meshToMesh::MAP,
eqOp<scalar>()
);
if (!master_)
{
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
htc_,
secIrht_->calculateHtc(),
meshToMesh::CELL_VOLUME_WEIGHT,
Tmapped,
Tsecondary,
meshToMesh::MAP,
eqOp<scalar>()
);
}
if (debug)
{
Info<< " Volumetric integral of htc : "
<< fvc::domainIntegrate(htc_).value()
<< endl;
}
//SAF: temporarily output
if (mesh_.time().outputTime())
{
Tmapped.write();
htc_.write();
}
if (h.dimensions() == dimEnergy/dimMass)
{
const basicThermo& primaryThermo =
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
eEqn += htc_*Tmapped - fvm::Sp(htc_/primaryThermo.Cp(), h);
if (!master_)
{
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
htc_,
secIrht_->calculateHtc(),
meshToMesh::CELL_VOLUME_WEIGHT,
eqOp<scalar>()
);
}
if (debug)
{
Info<< " Energy exchange from region " << secondaryMesh.name()
<< " To " << mesh_.name() << " : "
<< fvc::domainIntegrate
(
htc_*(h/primaryThermo.Cp() - Tmapped)
).value()
Info<< " Volumetric integral of htc : "
<< fvc::domainIntegrate(htc_).value()
<< endl;
}
}
else if(h.dimensions() == dimTemperature)
{
eEqn += htc_*Tmapped - fvm::Sp(htc_, h);
if (debug)
//SAF: temporarily output
if (mesh_.time().outputTime())
{
Info<< " Enegy exchange from region " << secondaryMesh.name()
<< " To " << mesh_.name() << " : "
<< fvc::domainIntegrate(htc_*(h - Tmapped)).value()
<< endl;
Tmapped.write();
htc_.write();
}
if (h.dimensions() == dimEnergy/dimMass)
{
const basicThermo& primaryThermo =
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
eEqn += htc_*Tmapped - fvm::Sp(htc_/primaryThermo.Cp(), h);
if (debug)
{
Info<< " Energy exchange from region " << secondaryMesh.name()
<< " To " << mesh_.name() << " : "
<< fvc::domainIntegrate
(
htc_*(h/primaryThermo.Cp() - Tmapped)
).value()
<< endl;
}
}
else if(h.dimensions() == dimTemperature)
{
eEqn += htc_*Tmapped - fvm::Sp(htc_, h);
if (debug)
{
Info<< " Enegy exchange from region " << secondaryMesh.name()
<< " To " << mesh_.name() << " : "
<< fvc::domainIntegrate(htc_*(h - Tmapped)).value()
<< endl;
}
}
}
}

View File

@ -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);
}

View File

@ -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();

View File

@ -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,85 @@ 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);
}
}
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 +136,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();

View File

@ -107,6 +107,11 @@ temperatureThermoBaffleFvPatchScalarField
<< exit(FatalError);
}
const mappedPatchBase& mpp =
refCast<const mappedPatchBase>(patch().patch());
const word nbrMesh = mpp.sampleRegion();
const fvMesh& thisMesh = patch().boundaryMesh().mesh();
typedef regionModels::thermoBaffleModels::thermoBaffleModel baffle;
@ -114,14 +119,15 @@ temperatureThermoBaffleFvPatchScalarField
if
(
thisMesh.name() == polyMesh::defaultRegion
&& !thisMesh.foundObject<baffle>("thermoBaffle")
&& !thisMesh.foundObject<baffle>(nbrMesh)
&& !owner_
)
{
Info << "Creating thermal baffle..." << endl;
Info << "Creating thermal baffle..." << nbrMesh << endl;
baffle_.reset(baffle::New(thisMesh, dict).ptr());
owner_ = true;
dict.lookup("thermoType") >> solidThermoType_;
baffle_->rename(nbrMesh);
}
}