From 0ef5b1cbfbf2c9dabaafd4bbd06954561790e8b7 Mon Sep 17 00:00:00 2001 From: andy <andy> Date: Mon, 29 Oct 2012 12:22:04 +0000 Subject: [PATCH] ENH: Further updates to fan and jump BCs --- .../jumpCyclic/jumpCyclicFvPatchField.C | 52 +++++------------- .../jumpCyclic/jumpCyclicFvPatchField.H | 11 ++++ .../jumpCyclic/jumpCyclicFvPatchFields.C | 54 ++++++++++++++++++- .../jumpCyclicAMI/jumpCyclicAMIFvPatchField.C | 49 ++++++----------- .../jumpCyclicAMI/jumpCyclicAMIFvPatchField.H | 12 +++++ .../jumpCyclicAMIFvPatchFields.C | 44 +++++++++++++++ .../derived/fan/fanFvPatchField.C | 7 --- .../derived/fan/fanFvPatchField.H | 11 +--- .../derived/fan/fanFvPatchFields.C | 5 -- .../uniformJump/uniformJumpFvPatchField.C | 2 +- 10 files changed, 153 insertions(+), 94 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C index db6849d2674..2287477bdfd 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C @@ -142,43 +142,17 @@ void jumpCyclicFvPatchField<Type>::updateInterfaceMatrix const Pstream::commsTypes ) const { - scalarField pnf(this->size()); - - const labelUList& nbrFaceCells = - this->cyclicPatch().neighbFvPatch().faceCells(); - - // for AMG solve - only apply jump to finest level - if (psiInternal.size() == this->internalField().size()) - { - Field<scalar> jf(this->jump()().component(cmpt)); - - if (!this->cyclicPatch().owner()) - { - jf *= -1.0; - } - - forAll(*this, facei) - { - pnf[facei] = psiInternal[nbrFaceCells[facei]] - jf[facei]; - } - } - else - { - forAll(*this, facei) - { - pnf[facei] = psiInternal[nbrFaceCells[facei]]; - } - } - - // Transform according to the transformation tensors - this->transformCoupleField(pnf, cmpt); - - // Multiply the field by coefficients and add into the result - const labelUList& faceCells = this->cyclicPatch().faceCells(); - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + notImplemented + ( + "void jumpCyclicFvPatchField<Type>::updateInterfaceMatrix" + "(" + "scalarField&, " + "const scalarField&, " + "const scalarField&, " + "const direction, " + "const Pstream::commsTypes" + ") const" + ); } @@ -196,8 +170,8 @@ void jumpCyclicFvPatchField<Type>::updateInterfaceMatrix const labelUList& nbrFaceCells = this->cyclicPatch().neighbFvPatch().faceCells(); - // for AMG solve - only apply jump to finest level - if (psiInternal.size() == this->internalField().size()) + // only apply jump to original field + if (&psiInternal == &this->internalField()) { Field<Type> jf(this->jump()); diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H index a5fd2343bfb..42d0c1805f8 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H @@ -144,6 +144,17 @@ public: ) const; }; +//- Update result field based on interface functionality +template<> +void jumpCyclicFvPatchField<scalar>::updateInterfaceMatrix +( + scalarField& result, + const scalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes commsType +) const; + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchFields.C index 02e25e31da7..adfc1326ffe 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchFields.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,6 +36,58 @@ namespace Foam makePatchFieldsTypeName(jumpCyclic); +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<> +void jumpCyclicFvPatchField<scalar>::updateInterfaceMatrix +( + scalarField& result, + const scalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes +) const +{ + scalarField pnf(this->size()); + + const labelUList& nbrFaceCells = + this->cyclicPatch().neighbFvPatch().faceCells(); + + // only apply jump to original field + if (&psiInternal == &this->internalField()) + { + Field<scalar> jf(this->jump()); + + if (!this->cyclicPatch().owner()) + { + jf *= -1.0; + } + + forAll(*this, facei) + { + pnf[facei] = psiInternal[nbrFaceCells[facei]] - jf[facei]; + } + } + else + { + forAll(*this, facei) + { + pnf[facei] = psiInternal[nbrFaceCells[facei]]; + } + } + + // Transform according to the transformation tensors + this->transformCoupleField(pnf, cmpt); + + // Multiply the field by coefficients and add into the result + const labelUList& faceCells = this->cyclicPatch().faceCells(); + forAll(faceCells, elemI) + { + result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; + } +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.C index 87d7c20efd5..ff36ee9797c 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.C @@ -129,33 +129,17 @@ void Foam::jumpCyclicAMIFvPatchField<Type>::updateInterfaceMatrix const Pstream::commsTypes ) const { - const labelUList& nbrFaceCells = - this->cyclicAMIPatch().cyclicAMIPatch().neighbPatch().faceCells(); - - scalarField pnf(psiInternal, nbrFaceCells); - - pnf = this->cyclicAMIPatch().interpolate(pnf); - - // for AMG solve - only apply jump to finest level - if (psiInternal.size() == this->internalField().size()) - { - tmp<Field<scalar> > tjf = jump()().component(cmpt); - if (!this->cyclicAMIPatch().owner()) - { - tjf = -tjf; - } - pnf -= tjf; - } - - // Transform according to the transformation tensors - this->transformCoupleField(pnf, cmpt); - - // Multiply the field by coefficients and add into the result - const labelUList& faceCells = this->cyclicAMIPatch().faceCells(); - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + notImplemented + ( + "void Foam::jumpCyclicAMIFvPatchField<Type>::updateInterfaceMatrix" + "(" + "scalarField&, " + "const scalarField&, " + "const scalarField& coeffs," + "const direction, " + "const Pstream::commsTypes" + ") const" + ); } @@ -175,15 +159,16 @@ void Foam::jumpCyclicAMIFvPatchField<Type>::updateInterfaceMatrix pnf = this->cyclicAMIPatch().interpolate(pnf); - // for AMG solve - only apply jump to finest level - if (psiInternal.size() == this->internalField().size()) + // only apply jump to original field + if (&psiInternal == &this->internalField()) { - tmp<Field<Type> > tjf = jump(); + Field<Type> jf(this->jump()); if (!this->cyclicAMIPatch().owner()) { - tjf = -tjf; + jf *= -1.0; } - pnf -= tjf; + + pnf -= jf; } // Transform according to the transformation tensors diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.H index 6759b09a36c..a2e77f0396e 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.H @@ -148,6 +148,18 @@ public: }; +//- Update result field based on interface functionality +template<> +void jumpCyclicAMIFvPatchField<scalar>::updateInterfaceMatrix +( + scalarField& result, + const scalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes commsType +) const; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchFields.C index 323f460d9f7..b7349812dab 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchFields.C @@ -36,6 +36,50 @@ namespace Foam makePatchFieldsTypeName(jumpCyclicAMI); +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<> +void Foam::jumpCyclicAMIFvPatchField<scalar>::updateInterfaceMatrix +( + scalarField& result, + const scalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes +) const +{ + const labelUList& nbrFaceCells = + this->cyclicAMIPatch().cyclicAMIPatch().neighbPatch().faceCells(); + + scalarField pnf(psiInternal, nbrFaceCells); + + pnf = this->cyclicAMIPatch().interpolate(pnf); + + // only apply jump to original field + if (&psiInternal == &this->internalField()) + { + Field<scalar> jf(this->jump()); + + if (!this->cyclicAMIPatch().owner()) + { + jf *= -1.0; + } + + pnf -= jf; + } + + // Transform according to the transformation tensors + this->transformCoupleField(pnf, cmpt); + + // Multiply the field by coefficients and add into the result + const labelUList& faceCells = this->cyclicAMIPatch().faceCells(); + forAll(faceCells, elemI) + { + result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; + } +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C index d397dbbc5e0..775c0f1ced5 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C @@ -98,13 +98,6 @@ Foam::fanFvPatchField<Type>::fanFvPatchField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class Type> -Foam::tmp<Foam::Field<Type> > Foam::fanFvPatchField<Type>::jump() const -{ - return this->jump_; -} - - template<class Type> void Foam::fanFvPatchField<Type>::updateCoeffs() { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H index a38a5d9cf80..218b4b18626 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H @@ -39,7 +39,6 @@ Description \table Property | Description | Required | Default value patchType | underlying patch type should be \c cyclic| yes | - jump | current jump value | yes | jumpTable | jump data, e.g. \c csvFile | yes | \endtable @@ -49,7 +48,6 @@ Description { type fan; patchType cyclic; - jump uniform 0; jumpTable csvFile; csvFileCoeffs { @@ -176,13 +174,8 @@ public: // Member functions - // Evaluation functions - - //- Return the "jump" across the patch - tmp<Field<Type> > jump() const; - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C index 5d99097dc16..8535c571279 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C @@ -116,11 +116,6 @@ Foam::fanFvPatchField<Foam::scalar>::fanFvPatchField this->jumpTable_ = DataEntry<scalar>::New("jumpTable", dict); } } - else - { - // Dummy jump table - this->jumpTable_.reset(new DataEntry<scalar>("jumpTable")); - } if (dict.found("value")) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C index 1647c3b257e..250442dad05 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C @@ -35,7 +35,7 @@ Foam::uniformJumpFvPatchField<Type>::uniformJumpFvPatchField ) : fixedJumpFvPatchField<Type>(p, iF), - jumpTable_(0) + jumpTable_(new DataEntry<Type>("jumpTable")) {} -- GitLab