eReactingFoam-4.x/flameControllingVelocity/flameControllingVelocityFvPatchVectorField.C
2018-09-13 14:56:37 +09:00

226 lines
6 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "flameControllingVelocityFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "fvPatchFieldMapper.H"
#include "fvcVolumeIntegrate.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::flameControllingVelocityFvPatchVectorField::
flameControllingVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(p, iF),
refValue_(p.size()),
Tref_(300.0),
startTime_(db().time().startTime().value())
{}
Foam::flameControllingVelocityFvPatchVectorField::
flameControllingVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchVectorField(p, iF),
refValue_("refValue", dict, p.size()),
Tref_(dict.lookupOrDefault<scalar>("Tref", 300.0)),
startTime_(dict.lookupOrDefault("startTime", db().time().startTime().value())),
lastVolume(-1)
{
fvPatchVectorField::operator=(refValue_*patch().nf());
}
Foam::flameControllingVelocityFvPatchVectorField::
flameControllingVelocityFvPatchVectorField
(
const flameControllingVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchVectorField(p, iF),
refValue_(ptf.refValue_, mapper),
Tref_(ptf.Tref_),
startTime_(ptf.startTime_)
{
// Note: calculate product only on ptf to avoid multiplication on
// unset values in reconstructPar.
fvPatchVectorField::operator=
(
vectorField
(
ptf.refValue_*ptf.patch().nf(),
mapper
)
);
}
Foam::flameControllingVelocityFvPatchVectorField::
flameControllingVelocityFvPatchVectorField
(
const flameControllingVelocityFvPatchVectorField& pivpvf
)
:
fixedValueFvPatchVectorField(pivpvf),
refValue_(pivpvf.refValue_),
Tref_(pivpvf.Tref_),
startTime_(pivpvf.startTime_)
{}
Foam::flameControllingVelocityFvPatchVectorField::
flameControllingVelocityFvPatchVectorField
(
const flameControllingVelocityFvPatchVectorField& pivpvf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(pivpvf, iF),
refValue_(pivpvf.refValue_),
Tref_(pivpvf.Tref_),
startTime_(pivpvf.startTime_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::flameControllingVelocityFvPatchVectorField::autoMap
(
const fvPatchFieldMapper& m
)
{
fixedValueFvPatchVectorField::autoMap(m);
refValue_.autoMap(m);
}
void Foam::flameControllingVelocityFvPatchVectorField::rmap
(
const fvPatchVectorField& ptf,
const labelList& addr
)
{
fixedValueFvPatchVectorField::rmap(ptf, addr);
const flameControllingVelocityFvPatchVectorField& tiptf =
refCast<const flameControllingVelocityFvPatchVectorField>(ptf);
refValue_.rmap(tiptf.refValue_, addr);
}
void Foam::flameControllingVelocityFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
scalar thisTime = db().time().timeOutputValue();
const volScalarField &T (db().lookupObject<volScalarField>("T"));
dimensionedScalar Tref("Tref", T.dimensions(), Tref_);
scalar lowTVolume = fvc::domainIntegrate(Foam::neg(T - Tref)).value();
if (thisTime - lastTime > 0.0 && startTime_ <= thisTime)
{
scalar domainVolume = gSum(patch().boundaryMesh().mesh().V());
Info << endl;
Info << "Volume calculation test" ;
Info << lowTVolume << token::END_STATEMENT
<< domainVolume << token::END_STATEMENT
<< lowTVolume / domainVolume;
Info << endl;
scalar dt = thisTime - lastTime;
if (lastVolume < 0)
{
lastVolume = lowTVolume;
}
scalar dTV = lowTVolume - lastVolume;
scalar patchArea = gSum(patch().magSf());
scalar dVel = (dTV / dt / patchArea);
Info << endl;
Info << "delta Velocity " ;
Info << dVel << token::END_STATEMENT;
Info << endl;
refValue_ += dVel;
}
lastTime = thisTime;
// lastVolume = lowTVolume;
fvPatchVectorField::operator=(refValue_*patch().nf());
fvPatchVectorField::updateCoeffs();
}
void Foam::flameControllingVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchVectorField::write(os);
refValue_.writeEntry("refValue", os);
writeEntryIfDifferent(os, "Tref", Tref_, 300.0);
writeEntryIfDifferent(os, "startTime", startTime_, db().time().startTime().value());
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchVectorField,
flameControllingVelocityFvPatchVectorField
);
}
// ************************************************************************* //