ENH: uniformFixedValue: point variants

This commit is contained in:
mattijs
2012-06-29 15:38:58 +01:00
parent 971e5fe30f
commit 20b28e38f9
4 changed files with 107 additions and 53 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -41,7 +41,7 @@ uniformFixedValuePointPatchField
) )
: :
fixedValuePointPatchField<Type>(p, iF), fixedValuePointPatchField<Type>(p, iF),
uniformValue_(pTraits<Type>::zero) uniformValue_()
{} {}
@ -54,10 +54,21 @@ uniformFixedValuePointPatchField
const dictionary& dict const dictionary& dict
) )
: :
fixedValuePointPatchField<Type>(p, iF, dict), fixedValuePointPatchField<Type>(p, iF, dict, false),
uniformValue_(pTraits<Type>(dict.lookup("uniformValue"))) uniformValue_(DataEntry<Type>::New("uniformValue", dict))
{ {
Field<Type>::operator=(uniformValue_); if (dict.found("value"))
{
fixedValuePointPatchField<Type>::operator==
(
Field<Type>("value", dict, p.size())
);
}
else
{
const scalar t = this->db().time().timeOutputValue();
fixedValuePointPatchField<Type>::operator=(uniformValue_->value(t));
}
} }
@ -72,8 +83,12 @@ uniformFixedValuePointPatchField
) )
: :
fixedValuePointPatchField<Type>(ptf, p, iF, mapper), fixedValuePointPatchField<Type>(ptf, p, iF, mapper),
uniformValue_(ptf.uniformValue_) uniformValue_(ptf.uniformValue_().clone().ptr())
{} {
// For safety re-evaluate
const scalar t = this->db().time().timeOutputValue();
fixedValuePointPatchField<Type>::operator=(uniformValue_->value(t));
}
template<class Type> template<class Type>
@ -84,7 +99,7 @@ uniformFixedValuePointPatchField
) )
: :
fixedValuePointPatchField<Type>(ptf), fixedValuePointPatchField<Type>(ptf),
uniformValue_(ptf.uniformValue_) uniformValue_(ptf.uniformValue_().clone().ptr())
{} {}
@ -97,19 +112,38 @@ uniformFixedValuePointPatchField
) )
: :
fixedValuePointPatchField<Type>(ptf, iF), fixedValuePointPatchField<Type>(ptf, iF),
uniformValue_(ptf.uniformValue_) uniformValue_(ptf.uniformValue_().clone().ptr())
{} {
// For safety re-evaluate
const scalar t = this->db().time().timeOutputValue();
fixedValuePointPatchField<Type>::operator==(uniformValue_->value(t));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void uniformFixedValuePointPatchField<Type>::updateCoeffs()
{
if (this->updated())
{
return;
}
const scalar t = this->db().time().timeOutputValue();
fixedValuePointPatchField<Type>::operator==(uniformValue_->value(t));
fixedValuePointPatchField<Type>::updateCoeffs();
}
template<class Type> template<class Type>
void uniformFixedValuePointPatchField<Type>:: void uniformFixedValuePointPatchField<Type>::
write(Ostream& os) const write(Ostream& os) const
{ {
pointPatchField<Type>::write(os); // Note: write value
os.writeKeyword("uniformValue") fixedValuePointPatchField<Type>::write(os);
<< uniformValue_ << token::END_STATEMENT << nl; uniformValue_->writeData(os);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,7 +25,20 @@ Class
Foam::uniformFixedValuePointPatchField Foam::uniformFixedValuePointPatchField
Description Description
Foam::uniformFixedValuePointPatchField Enables the specification of a uniform fixed value boundary condition.
Example of the boundary condition specification:
\verbatim
inlet
{
type uniformFixedValue;
uniformValue constant 0.2;
}
\endverbatim
The uniformValue entry is a DataEntry type, able to describe time
varying functions. The example above gives the usage for supplying a
constant value.
SourceFiles SourceFiles
uniformFixedValuePointPatchField.C uniformFixedValuePointPatchField.C
@ -36,6 +49,7 @@ SourceFiles
#define uniformFixedValuePointPatchField_H #define uniformFixedValuePointPatchField_H
#include "fixedValuePointPatchField.H" #include "fixedValuePointPatchField.H"
#include "DataEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -53,7 +67,7 @@ class uniformFixedValuePointPatchField
{ {
// Private data // Private data
Type uniformValue_; autoPtr<DataEntry<Type> > uniformValue_;
public: public:
@ -136,16 +150,15 @@ public:
// Access // Access
//- Return the fluctuation scale //- Return the fluctuation scale
const Type& uniformValue() const const DataEntry<Type>& uniformValue() const
{ {
return uniformValue_; return uniformValue_;
} }
//- Return reference to the fluctuation scale to allow adjustment // Evaluation functions
Type& uniformValue()
{ //- Update the coefficients associated with the patch field
return uniformValue_; virtual void updateCoeffs();
}
//- Write //- Write

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -44,18 +44,32 @@ uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
{} {}
template<class Type>
uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const Field<Type>& fld
)
:
fixedValueFvPatchField<Type>(p, iF, fld),
uniformValue_()
{}
template<class Type> template<class Type>
uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
( (
const uniformFixedValueFvPatchField<Type>& ptf, const uniformFixedValueFvPatchField<Type>& ptf,
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& const fvPatchFieldMapper& mapper
) )
: :
fixedValueFvPatchField<Type>(p, iF), fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
uniformValue_(ptf.uniformValue_().clone().ptr()) uniformValue_(ptf.uniformValue_().clone().ptr())
{ {
// For safety re-evaluate
const scalar t = this->db().time().timeOutputValue(); const scalar t = this->db().time().timeOutputValue();
fvPatchField<Type>::operator==(uniformValue_->value(t)); fvPatchField<Type>::operator==(uniformValue_->value(t));
} }
@ -72,8 +86,15 @@ uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
fixedValueFvPatchField<Type>(p, iF), fixedValueFvPatchField<Type>(p, iF),
uniformValue_(DataEntry<Type>::New("uniformValue", dict)) uniformValue_(DataEntry<Type>::New("uniformValue", dict))
{ {
const scalar t = this->db().time().timeOutputValue(); if (dict.found("value"))
fvPatchField<Type>::operator==(uniformValue_->value(t)); {
fvPatchField<Type>::operator==(Field<Type>("value", dict, p.size()));
}
else
{
const scalar t = this->db().time().timeOutputValue();
fvPatchField<Type>::operator==(uniformValue_->value(t));
}
} }
@ -85,10 +106,7 @@ uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
: :
fixedValueFvPatchField<Type>(ptf), fixedValueFvPatchField<Type>(ptf),
uniformValue_(ptf.uniformValue_().clone().ptr()) uniformValue_(ptf.uniformValue_().clone().ptr())
{ {}
const scalar t = this->db().time().timeOutputValue();
fvPatchField<Type>::operator==(uniformValue_->value(t));
}
template<class Type> template<class Type>
@ -101,6 +119,7 @@ uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
fixedValueFvPatchField<Type>(ptf, iF), fixedValueFvPatchField<Type>(ptf, iF),
uniformValue_(ptf.uniformValue_().clone().ptr()) uniformValue_(ptf.uniformValue_().clone().ptr())
{ {
// For safety re-evaluate
const scalar t = this->db().time().timeOutputValue(); const scalar t = this->db().time().timeOutputValue();
fvPatchField<Type>::operator==(uniformValue_->value(t)); fvPatchField<Type>::operator==(uniformValue_->value(t));
} }
@ -108,18 +127,6 @@ uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void uniformFixedValueFvPatchField<Type>::autoMap
(
const fvPatchFieldMapper& m
)
{
this->setSize(m.size());
const scalar t = this->db().time().timeOutputValue();
fvPatchField<Type>::operator==(uniformValue_->value(t));
}
template<class Type> template<class Type>
void uniformFixedValueFvPatchField<Type>::updateCoeffs() void uniformFixedValueFvPatchField<Type>::updateCoeffs()
{ {
@ -138,6 +145,7 @@ void uniformFixedValueFvPatchField<Type>::updateCoeffs()
template<class Type> template<class Type>
void uniformFixedValueFvPatchField<Type>::write(Ostream& os) const void uniformFixedValueFvPatchField<Type>::write(Ostream& os) const
{ {
// Note: do not write value
fvPatchField<Type>::write(os); fvPatchField<Type>::write(os);
uniformValue_->writeData(os); uniformValue_->writeData(os);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -49,7 +49,6 @@ SourceFiles
#ifndef uniformFixedValueFvPatchField_H #ifndef uniformFixedValueFvPatchField_H
#define uniformFixedValueFvPatchField_H #define uniformFixedValueFvPatchField_H
#include "Random.H"
#include "fixedValueFvPatchFields.H" #include "fixedValueFvPatchFields.H"
#include "DataEntry.H" #include "DataEntry.H"
@ -87,6 +86,14 @@ public:
const DimensionedField<Type, volMesh>& const DimensionedField<Type, volMesh>&
); );
//- Construct from patch and internal field and patch field
uniformFixedValueFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const Field<Type>& fld
);
//- Construct from patch, internal field and dictionary //- Construct from patch, internal field and dictionary
uniformFixedValueFvPatchField uniformFixedValueFvPatchField
( (
@ -142,14 +149,6 @@ public:
// Member functions // Member functions
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
// Evaluation functions // Evaluation functions