volume based velocity control - failed

This commit is contained in:
ignis 2018-09-13 14:56:37 +09:00
parent cf56850a5b
commit a659368959
3 changed files with 76 additions and 5 deletions

View file

@ -1,4 +1,5 @@
EXE_INC = \
-g \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \

View file

@ -27,6 +27,7 @@ License
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "fvPatchFieldMapper.H"
#include "fvcVolumeIntegrate.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -38,7 +39,9 @@ flameControllingVelocityFvPatchVectorField
)
:
fixedValueFvPatchVectorField(p, iF),
refValue_(p.size())
refValue_(p.size()),
Tref_(300.0),
startTime_(db().time().startTime().value())
{}
@ -51,7 +54,10 @@ flameControllingVelocityFvPatchVectorField
)
:
fixedValueFvPatchVectorField(p, iF),
refValue_("refValue", dict, p.size())
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());
}
@ -67,7 +73,9 @@ flameControllingVelocityFvPatchVectorField
)
:
fixedValueFvPatchVectorField(p, iF),
refValue_(ptf.refValue_, mapper)
refValue_(ptf.refValue_, mapper),
Tref_(ptf.Tref_),
startTime_(ptf.startTime_)
{
// Note: calculate product only on ptf to avoid multiplication on
// unset values in reconstructPar.
@ -89,7 +97,9 @@ flameControllingVelocityFvPatchVectorField
)
:
fixedValueFvPatchVectorField(pivpvf),
refValue_(pivpvf.refValue_)
refValue_(pivpvf.refValue_),
Tref_(pivpvf.Tref_),
startTime_(pivpvf.startTime_)
{}
@ -101,7 +111,9 @@ flameControllingVelocityFvPatchVectorField
)
:
fixedValueFvPatchVectorField(pivpvf, iF),
refValue_(pivpvf.refValue_)
refValue_(pivpvf.refValue_),
Tref_(pivpvf.Tref_),
startTime_(pivpvf.startTime_)
{}
@ -139,6 +151,53 @@ void Foam::flameControllingVelocityFvPatchVectorField::updateCoeffs()
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();
}
@ -148,6 +207,8 @@ 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());
}

View file

@ -81,6 +81,15 @@ class flameControllingVelocityFvPatchVectorField
scalarField refValue_;
// scalar fuelVolumeRatio;
scalar Tref_;
scalar startTime_;
scalar lastTime;
scalar lastVolume;
public: