Skip to content
Snippets Groups Projects
Commit e34b84ec authored by Henry Weller's avatar Henry Weller
Browse files

fixedMeanFvPatchField: Added support for time-varying mean-value

parent 798f13d8
Branches
Tags
1 merge request!33Merge foundation
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -36,34 +36,34 @@ Foam::fixedMeanFvPatchField<Type>::fixedMeanFvPatchField
)
:
fixedValueFvPatchField<Type>(p, iF),
meanValue_(pTraits<Type>::zero)
meanValue_()
{}
template<class Type>
Foam::fixedMeanFvPatchField<Type>::fixedMeanFvPatchField
(
const fixedMeanFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
const dictionary& dict
)
:
fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
meanValue_(ptf.meanValue_)
fixedValueFvPatchField<Type>(p, iF, dict),
meanValue_(Function1<Type>::New(dict.lookup("meanValue"), dict))
{}
template<class Type>
Foam::fixedMeanFvPatchField<Type>::fixedMeanFvPatchField
(
const fixedMeanFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchField<Type>(p, iF, dict),
meanValue_(pTraits<Type>(dict.lookup("meanValue")))
fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
meanValue_(ptf.meanValue_, false)
{}
......@@ -74,7 +74,7 @@ Foam::fixedMeanFvPatchField<Type>::fixedMeanFvPatchField
)
:
fixedValueFvPatchField<Type>(ptf),
meanValue_(ptf.meanValue_)
meanValue_(ptf.meanValue_, false)
{}
......@@ -86,7 +86,7 @@ Foam::fixedMeanFvPatchField<Type>::fixedMeanFvPatchField
)
:
fixedValueFvPatchField<Type>(ptf, iF),
meanValue_(ptf.meanValue_)
meanValue_(ptf.meanValue_, false)
{}
......@@ -100,19 +100,22 @@ void Foam::fixedMeanFvPatchField<Type>::updateCoeffs()
return;
}
const scalar t = this->db().time().timeOutputValue();
Type meanValue = meanValue_->value(t);
Field<Type> newValues(this->patchInternalField());
Type meanValuePsi =
gSum(this->patch().magSf()*newValues)
/gSum(this->patch().magSf());
if (mag(meanValue_) > SMALL && mag(meanValuePsi)/mag(meanValue_) > 0.5)
if (mag(meanValue) > SMALL && mag(meanValuePsi)/mag(meanValue) > 0.5)
{
newValues *= mag(meanValue_)/mag(meanValuePsi);
newValues *= mag(meanValue)/mag(meanValuePsi);
}
else
{
newValues += (meanValue_ - meanValuePsi);
newValues += (meanValue - meanValuePsi);
}
this->operator==(newValues);
......@@ -125,7 +128,7 @@ template<class Type>
void Foam::fixedMeanFvPatchField<Type>::write(Ostream& os) const
{
fvPatchField<Type>::write(os);
os.writeKeyword("meanValue") << meanValue_ << token::END_STATEMENT << nl;
meanValue_->writeData(os);
this->writeEntry("value", os);
}
......
......@@ -29,13 +29,14 @@ Group
Description
This boundary condition extrapolates field to the patch using the near-cell
values and adjusts the distribution to match the specified mean value.
values and adjusts the distribution to match the specified, optionally
time-varying, mean value.
\heading Patch usage
\table
Property | Description | Required | Default value
meanValue | mean value | yes |
meanValue | mean value Function1 | yes |
\endtable
Example of the boundary condition specification:
......@@ -49,6 +50,7 @@ Description
SeeAlso
Foam::fixedValueFvPatchField
Foam::Function1Types
SourceFiles
fixedMeanFvPatchField.C
......@@ -59,6 +61,7 @@ SourceFiles
#define fixedMeanFvPatchField_H
#include "fixedValueFvPatchFields.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -74,13 +77,10 @@ class fixedMeanFvPatchField
:
public fixedValueFvPatchField<Type>
{
protected:
// Protected data
// Private data
//- MeanValue value the field is adjusted to maintain
Type meanValue_;
autoPtr<Function1<Type>> meanValue_;
public:
......@@ -153,10 +153,8 @@ public:
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment