diff --git a/src/finiteArea/Make/files b/src/finiteArea/Make/files index 2badfb337dbc4ba0167c44651b5a20094e979729..d4a6837b1d5f54bbdaf1e770a917ed38d2ae3ee8 100644 --- a/src/finiteArea/Make/files +++ b/src/finiteArea/Make/files @@ -44,7 +44,6 @@ $(basicFaPatchFields)/transform/transformFaPatchScalarField.C constraintFaPatchFields = $(faPatchFields)/constraint $(constraintFaPatchFields)/empty/emptyFaPatchFields.C $(constraintFaPatchFields)/processor/processorFaPatchFields.C -$(constraintFaPatchFields)/processor/processorFaPatchScalarField.C $(constraintFaPatchFields)/wedge/wedgeFaPatchFields.C $(constraintFaPatchFields)/wedge/wedgeFaPatchScalarField.C $(constraintFaPatchFields)/cyclic/cyclicFaPatchFields.C diff --git a/src/finiteArea/fields/faPatchFields/basic/coupled/coupledFaPatchField.H b/src/finiteArea/fields/faPatchFields/basic/coupled/coupledFaPatchField.H index 8f6a2db48ecd1e0afc5354c61ef7d532bc9cc8ce..8a861d454995777bb04e9ceb1ea79a2f9171dfb2 100644 --- a/src/finiteArea/fields/faPatchFields/basic/coupled/coupledFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/basic/coupled/coupledFaPatchField.H @@ -181,13 +181,6 @@ public: // Coupled interface functionality - //- Transform given patch component field - virtual void transformCoupleField - ( - solveScalarField& f, - const direction cmpt - ) const = 0; - //- Update result field based on interface functionality virtual void updateInterfaceMatrix ( diff --git a/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchFieldsFwd.H b/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchFieldsFwd.H deleted file mode 100644 index 3b9a128c73a9e070c76cdc33735502a7969fc3f0..0000000000000000000000000000000000000000 --- a/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchFieldsFwd.H +++ /dev/null @@ -1,58 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2016-2017 Wikki Ltd -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#ifndef transformFaPatchFieldsFwd_H -#define transformFaPatchFieldsFwd_H - -#include "fieldTypes.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<class Type> class transformFaPatchField; - -// typedef transformFaPatchField<scalar> transformFaPatchScalarField; -// typedef transformFaPatchField<vector> transformFaPatchVectorField; -// typedef transformFaPatchField<tensor> transformFaPatchTensorField; - -// template<class Type> class transformFaPatchField; - -makeFaPatchTypeFieldTypedefs(transform) - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C index 30039b895f2bfb55c0a4e3f93a082a19a1ecb5dd..be981c5518bd763a61092d47c7d869f0750e8904 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -187,20 +187,7 @@ void Foam::cyclicFaPatchField<Type>::updateInterfaceMatrix transformCoupleField(pnf, cmpt); // Multiply the field by coefficients and add into the result - if (add) - { - forAll(faceCells, elemI) - { - result[faceCells[elemI]] += coeffs[elemI]*pnf[elemI]; - } - } - else - { - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } - } + this->addToInternalField(result, !add, faceCells, coeffs, pnf); } @@ -227,21 +214,11 @@ void Foam::cyclicFaPatchField<Type>::updateInterfaceMatrix pnf[facei + sizeby2] = psiInternal[faceCells[facei]]; } + // Transform according to the transformation tensors + transformCoupleField(pnf); + // Multiply the field by coefficients and add into the result - if (add) - { - forAll(faceCells, elemI) - { - result[faceCells[elemI]] += coeffs[elemI]*pnf[elemI]; - } - } - else - { - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } - } + this->addToInternalField(result, !add, faceCells, coeffs, pnf); } diff --git a/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.H b/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.H index 63da81ed3864314bb2569e812463408f2d7a3ec8..23800ce0515e4c0018bcd748e8b9c00d9ff2c9a7 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.H @@ -164,16 +164,6 @@ public: // Coupled interface functionality - //- Transform neighbour field - virtual void transformCoupleField - ( - solveScalarField& f, - const direction cmpt - ) const - { - cyclicLduInterfaceField::transformCoupleField(f, cmpt); - } - //- Update result field based on interface functionality virtual void updateInterfaceMatrix ( diff --git a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.C index 5c24cc8a1fc56c472eb4f0b7851295bc18ee3645..d7f4e90cd32382c396f671a9efdbd78202dea38c 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.C @@ -132,13 +132,6 @@ Foam::processorFaPatchField<Type>::processorFaPatchField {} -// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // - -template<class Type> -Foam::processorFaPatchField<Type>::~processorFaPatchField() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> @@ -205,6 +198,8 @@ void Foam::processorFaPatchField<Type>::initInterfaceMatrixUpdate commsType, this->patch().patchInternalField(psiInternal)() ); + + const_cast<processorFaPatchField<Type>&>(*this).updatedMatrix() = false; } @@ -221,32 +216,28 @@ void Foam::processorFaPatchField<Type>::updateInterfaceMatrix const Pstream::commsTypes commsType ) const { + if (this->updatedMatrix()) + { + return; + } + + const labelUList& faceCells = this->patch().edgeFaces(); + solveScalarField pnf ( - procPatch_.receive<solveScalar>(commsType, this->size())() + procPatch_.receive<solveScalar>(commsType, this->size()) ); - // Transform according to the transformation tensor - transformCoupleField(pnf, cmpt); + if (!std::is_arithmetic<Type>::value) + { + // Transform non-scalar data according to the transformation tensor + transformCoupleField(pnf, cmpt); + } // Multiply the field by coefficients and add into the result + this->addToInternalField(result, !add, faceCells, coeffs, pnf); - const labelUList& edgeFaces = this->patch().edgeFaces(); - - if (add) - { - forAll(edgeFaces, elemI) - { - result[edgeFaces[elemI]] += coeffs[elemI]*pnf[elemI]; - } - } - else - { - forAll(edgeFaces, elemI) - { - result[edgeFaces[elemI]] -= coeffs[elemI]*pnf[elemI]; - } - } + const_cast<processorFaPatchField<Type>&>(*this).updatedMatrix() = true; } @@ -267,6 +258,8 @@ void Foam::processorFaPatchField<Type>::initInterfaceMatrixUpdate commsType, this->patch().patchInternalField(psiInternal)() ); + + const_cast<processorFaPatchField<Type>&>(*this).updatedMatrix() = false; } @@ -282,29 +275,25 @@ void Foam::processorFaPatchField<Type>::updateInterfaceMatrix const Pstream::commsTypes commsType ) const { + if (this->updatedMatrix()) + { + return; + } + + const labelUList& faceCells = this->patch().edgeFaces(); + Field<Type> pnf ( - procPatch_.receive<Type>(commsType, this->size())() + procPatch_.receive<Type>(commsType, this->size()) ); - // Multiply the field by coefficients and add into the result + // Transform according to the transformation tensor + transformCoupleField(pnf); - const labelUList& edgeFaces = this->patch().edgeFaces(); + // Multiply the field by coefficients and add into the result + this->addToInternalField(result, !add, faceCells, coeffs, pnf); - if (add) - { - forAll(edgeFaces, elemI) - { - result[edgeFaces[elemI]] += coeffs[elemI]*pnf[elemI]; - } - } - else - { - forAll(edgeFaces, elemI) - { - result[edgeFaces[elemI]] -= coeffs[elemI]*pnf[elemI]; - } - } + const_cast<processorFaPatchField<Type>&>(*this).updatedMatrix() = true; } diff --git a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.H b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.H index dcd279dabf9a5a597aa8f67aa4fbd5f3db0aeec0..6e1007480373f8ac97a3308b8fae833394779997 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,8 +38,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef processorFaPatchField_H -#define processorFaPatchField_H +#ifndef Foam_processorFaPatchField_H +#define Foam_processorFaPatchField_H #include "coupledFaPatchField.H" #include "processorLduInterfaceField.H" @@ -139,9 +139,8 @@ public: } - // Destructor - - ~processorFaPatchField(); + //- Destructor + ~processorFaPatchField() = default; // Member functions @@ -176,17 +175,8 @@ public: //- Return patch-normal gradient virtual tmp<Field<Type>> snGrad() const; - // Coupled interface functionality - //- Transform neighbour field - virtual void transformCoupleField - ( - solveScalarField& f, - const direction cmpt - ) const - { - processorLduInterfaceField::transformCoupleField(f, cmpt); - } + // Coupled interface functionality //- Initialise neighbour matrix update virtual void initInterfaceMatrixUpdate diff --git a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchFields.H b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchFields.H index 3ac8610d4bf54343e9be2a5fe2af2445508c5d0a..7b3fe7ca539bf177c96fae1df559320557ec7267 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchFields.H +++ b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchFields.H @@ -25,10 +25,10 @@ License \*---------------------------------------------------------------------------*/ -#ifndef processorFaPatchFields_H -#define processorFaPatchFields_H +#ifndef Foam_processorFaPatchFields_H +#define Foam_processorFaPatchFields_H -#include "processorFaPatchScalarField.H" +#include "processorFaPatchField.H" #include "fieldTypes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchFieldsFwd.H b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchFieldsFwd.H deleted file mode 100644 index 05670667a2eda526f446beee5c0755b1c177eab3..0000000000000000000000000000000000000000 --- a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchFieldsFwd.H +++ /dev/null @@ -1,52 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2016-2017 Wikki Ltd -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#ifndef processorFaPatchFieldsFwd_H -#define processorFaPatchFieldsFwd_H - -#include "fieldTypes.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<class Type> class processorFaPatchField; - -makeFaPatchTypeFieldTypedefs(processor) - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchScalarField.C b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchScalarField.C deleted file mode 100644 index b06e2d7736566fe446483dfd7f198906468c8a0b..0000000000000000000000000000000000000000 --- a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchScalarField.C +++ /dev/null @@ -1,100 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "processorFaPatchScalarField.H" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template<> -void Foam::processorFaPatchField<Foam::scalar>::transformCoupleField -( - solveScalarField& f, - const direction cmpt -) const -{} - - -template<> -void Foam::processorFaPatchField<Foam::scalar>::initInterfaceMatrixUpdate -( - solveScalarField& result, - const bool add, - const lduAddressing& lduAddr, - const label patchId, - const solveScalarField& psiInternal, - const scalarField& coeffs, - const direction, - const Pstream::commsTypes commsType -) const -{ - procPatch_.send - ( - commsType, - patch().patchInternalField(psiInternal)() - ); -} - - -template<> -void Foam::processorFaPatchField<Foam::scalar>::updateInterfaceMatrix -( - solveScalarField& result, - const bool add, - const lduAddressing& lduAddr, - const label patchId, - const solveScalarField&, - const scalarField& coeffs, - const direction, - const Pstream::commsTypes commsType -) const -{ - solveScalarField pnf - ( - procPatch_.receive<solveScalar>(commsType, this->size())() - ); - - const labelUList& edgeFaces = patch().edgeFaces(); - - if (add) - { - forAll(edgeFaces, facei) - { - result[edgeFaces[facei]] -= coeffs[facei]*pnf[facei]; - } - } - else - { - forAll(edgeFaces, facei) - { - result[edgeFaces[facei]] -= coeffs[facei]*pnf[facei]; - } - } -} - - -// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchScalarField.H b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchScalarField.H deleted file mode 100644 index a7227f5de2b215c2d174add38df60d1fbe2a5738..0000000000000000000000000000000000000000 --- a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchScalarField.H +++ /dev/null @@ -1,86 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#ifndef processorFaPatchScalarField_H -#define processorFaPatchScalarField_H - -#include "processorFaPatchField.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template<> -void processorFaPatchField<scalar>::transformCoupleField -( - solveScalarField& f, - const direction cmpt -) const; - - -template<> -void processorFaPatchField<scalar>::initInterfaceMatrixUpdate -( - solveScalarField& result, - const bool add, - const lduAddressing& lduAddr, - const label patchId, - const solveScalarField&, - const scalarField& coeffs, - const direction, - const Pstream::commsTypes commsType -) const; - - -template<> -void processorFaPatchField<scalar>::updateInterfaceMatrix -( - solveScalarField& result, - const bool add, - const lduAddressing& lduAddr, - const label patchId, - const solveScalarField&, - const scalarField& coeffs, - const direction, - const Pstream::commsTypes commsType -) const; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* //