ENH: Added variants of updateCoeffs and manipulateMatrix to receive weight field

This commit is contained in:
andy
2013-05-31 14:39:23 +01:00
parent 5ed7767054
commit fa2ed51f6b
2 changed files with 64 additions and 5 deletions

View File

@ -42,6 +42,7 @@ Foam::fvPatchField<Type>::fvPatchField
patch_(p), patch_(p),
internalField_(iF), internalField_(iF),
updated_(false), updated_(false),
manipulatedMatrix_(false),
patchType_(word::null) patchType_(word::null)
{} {}
@ -58,6 +59,7 @@ Foam::fvPatchField<Type>::fvPatchField
patch_(p), patch_(p),
internalField_(iF), internalField_(iF),
updated_(false), updated_(false),
manipulatedMatrix_(false),
patchType_(word::null) patchType_(word::null)
{} {}
@ -75,6 +77,7 @@ Foam::fvPatchField<Type>::fvPatchField
patch_(p), patch_(p),
internalField_(iF), internalField_(iF),
updated_(false), updated_(false),
manipulatedMatrix_(false),
patchType_(ptf.patchType_) patchType_(ptf.patchType_)
{} {}
@ -92,6 +95,7 @@ Foam::fvPatchField<Type>::fvPatchField
patch_(p), patch_(p),
internalField_(iF), internalField_(iF),
updated_(false), updated_(false),
manipulatedMatrix_(false),
patchType_(dict.lookupOrDefault<word>("patchType", word::null)) patchType_(dict.lookupOrDefault<word>("patchType", word::null))
{ {
if (dict.found("value")) if (dict.found("value"))
@ -133,6 +137,7 @@ Foam::fvPatchField<Type>::fvPatchField
patch_(ptf.patch_), patch_(ptf.patch_),
internalField_(ptf.internalField_), internalField_(ptf.internalField_),
updated_(false), updated_(false),
manipulatedMatrix_(false),
patchType_(ptf.patchType_) patchType_(ptf.patchType_)
{} {}
@ -148,6 +153,7 @@ Foam::fvPatchField<Type>::fvPatchField
patch_(ptf.patch_), patch_(ptf.patch_),
internalField_(iF), internalField_(iF),
updated_(false), updated_(false),
manipulatedMatrix_(false),
patchType_(ptf.patchType_) patchType_(ptf.patchType_)
{} {}
@ -267,6 +273,28 @@ void Foam::fvPatchField<Type>::rmap
} }
template<class Type>
void Foam::fvPatchField<Type>::updateCoeffs()
{
updated_ = true;
}
template<class Type>
void Foam::fvPatchField<Type>::updateCoeffs(const scalarField& weights)
{
if (!updated_)
{
updateCoeffs();
Field<Type>& fld = *this;
fld *= weights;
updated_ = true;
}
}
template<class Type> template<class Type>
void Foam::fvPatchField<Type>::evaluate(const Pstream::commsTypes) void Foam::fvPatchField<Type>::evaluate(const Pstream::commsTypes)
{ {
@ -276,13 +304,25 @@ void Foam::fvPatchField<Type>::evaluate(const Pstream::commsTypes)
} }
updated_ = false; updated_ = false;
manipulatedMatrix_ = false;
} }
template<class Type> template<class Type>
void Foam::fvPatchField<Type>::manipulateMatrix(fvMatrix<Type>& matrix) void Foam::fvPatchField<Type>::manipulateMatrix(fvMatrix<Type>& matrix)
{ {
// do nothing manipulatedMatrix_ = true;
}
template<class Type>
void Foam::fvPatchField<Type>::manipulateMatrix
(
fvMatrix<Type>& matrix,
const scalarField& weights
)
{
manipulatedMatrix_ = true;
} }

View File

@ -93,6 +93,10 @@ class fvPatchField
// the construction of the matrix // the construction of the matrix
bool updated_; bool updated_;
//- Update index used so that manipulateMatrix is called only once
// during the construction of the matrix
bool manipulatedMatrix_;
//- Optional patch type, used to allow specified boundary conditions //- Optional patch type, used to allow specified boundary conditions
// to be applied to constraint patches by providing the constraint // to be applied to constraint patches by providing the constraint
// patch type as 'patchType' // patch type as 'patchType'
@ -327,6 +331,12 @@ public:
return updated_; return updated_;
} }
//- Return true if the matrix has already been manipulated
bool manipulatedMatrix() const
{
return manipulatedMatrix_;
}
// Mapping functions // Mapping functions
@ -365,10 +375,12 @@ public:
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
// Sets Updated to true // Sets Updated to true
virtual void updateCoeffs() virtual void updateCoeffs();
{
updated_ = true; //- Update the coefficients associated with the patch field
} // and apply weight field
// Sets Updated to true
virtual void updateCoeffs(const scalarField& weights);
//- Return internal field next to patch as patch field //- Return internal field next to patch as patch field
virtual tmp<Field<Type> > patchInternalField() const; virtual tmp<Field<Type> > patchInternalField() const;
@ -479,6 +491,13 @@ public:
//- Manipulate matrix //- Manipulate matrix
virtual void manipulateMatrix(fvMatrix<Type>& matrix); virtual void manipulateMatrix(fvMatrix<Type>& matrix);
//- Manipulate matrix with given weights
virtual void manipulateMatrix
(
fvMatrix<Type>& matrix,
const scalarField& weights
);
// I-O // I-O