diff --git a/src/foam/Make/files b/src/foam/Make/files index 5989ae249..e6ad9b003 100644 --- a/src/foam/Make/files +++ b/src/foam/Make/files @@ -663,6 +663,8 @@ matrices/blockLduMatrix/BlockLduMatrix/symmTensorBlockLduMatrix.C matrices/blockLduMatrix/BlockLduMatrix/tensorBlockLduMatrix.C matrices/blockLduMatrix/BlockLduMatrix/blockVectorNMatrices.C matrices/blockLduMatrix/BlockLduMatrix/BlockConstraint/scalarBlockConstraint.C +matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrices.C +matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockVectorNMatrices.C BlockLduInterfaceField = matrices/blockLduMatrix/BlockLduMatrix/BlockLduInterfaceField $(BlockLduInterfaceField)/BlockLduInterfaceFields.C diff --git a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/blockLduMatrices.C b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/blockLduMatrices.C index 84e367a80..cb2121992 100644 --- a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/blockLduMatrices.C +++ b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/blockLduMatrices.C @@ -22,7 +22,7 @@ License along with foam-extend. If not, see . Description - Block matrix member static data members + Block matrix member static data members Author Hrvoje Jasak, Wikki Ltd. All rights reserved. diff --git a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/blockVectorNMatrices.C b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/blockVectorNMatrices.C index 0b65e4990..58c055294 100644 --- a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/blockVectorNMatrices.C +++ b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/blockVectorNMatrices.C @@ -22,7 +22,7 @@ License along with foam-extend. If not, see . Description - Block matrix member static data members + Block matrix member static data members Author Hrvoje Jasak, Wikki Ltd. All rights reserved. diff --git a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrices.C b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrices.C new file mode 100644 index 000000000..fa7f0cfaa --- /dev/null +++ b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrices.C @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | + \\ / A nd | For copyright notice see file Copyright + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Description + Extended block matrix static data members + +Author + Vuko Vukcevic, FMENA Zagreb. All rights reserved. + +\*---------------------------------------------------------------------------*/ + +#include "extendedBlockLduMatrices.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineNamedTemplateTypeNameAndDebug(extendedBlockScalarMatrix, 0); +defineNamedTemplateTypeNameAndDebug(extendedBlockVectorMatrix, 0); +defineNamedTemplateTypeNameAndDebug(extendedBlockSphericalTensorMatrix, 0); +defineNamedTemplateTypeNameAndDebug(extendedBlockSymmTensorMatrix, 0); +defineNamedTemplateTypeNameAndDebug(extendedBlockTensorMatrix, 0); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrices.H b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrices.H new file mode 100644 index 000000000..0a64ae2fc --- /dev/null +++ b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrices.H @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | + \\ / A nd | For copyright notice see file Copyright + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Class + extendedBlockLduMatrix + +Description + Typedefs for extended block matrices + +Author + Vuko Vukcevic, FMENA Zagreb. All rights reserved. + +\*---------------------------------------------------------------------------*/ + +#ifndef extendedBlockLduMatrices_H +#define extendedBlockLduMatrices_H + +#include "extendedBlockLduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +typedef extendedBlockLduMatrix extendedBlockScalarMatrix; +typedef extendedBlockLduMatrix extendedBlockVectorMatrix; +typedef extendedBlockLduMatrix + extendedBlockSphericalTensorMatrix; +typedef extendedBlockLduMatrix extendedBlockSymmTensorMatrix; +typedef extendedBlockLduMatrix extendedBlockTensorMatrix; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.C b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.C new file mode 100644 index 000000000..d35e240ef --- /dev/null +++ b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.C @@ -0,0 +1,259 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | + \\ / A nd | For copyright notice see file Copyright + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "extendedBlockLduMatrix.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::extendedBlockLduMatrix::extendedBlockLduMatrix +( + const blockLduMatrix& blockLdum, + const label extensionLevel, + const polyMesh& polyMesh +) +: + basicBlockLduMatrix_(blockLdum), + extLduAddr_ + ( + extendedLduAddressing::New + ( + polyMesh, + blockLdum.lduAddr(), + extensionLevel + ) + ), + extendedLowerPtr_(NULL), + extendedUpperPtr_(NULL) +{ + if (debug) + { + Info<< "extendedBlockLduMatrix(lduMatrix&, label, polyMesh&) :" + "Constructing extendedBlockLduMatrix." + << endl; + } + + if (blockLdum.diagonal()) + { + WarningIn("extendedBlockLduMatrix(lduMatrix&, label, polyMesh&)") + << "Attempted to create extended lower/upper coeffs for block " + << "matrix that is diagonal." + << nl << endl; + } + else if (blockLdum.symmetric()) + { + // Get reference to faceMap in extended addressing + const unallocLabelList& faceMap = extLduAddr_.faceMap(); + + // Avoid assuming it's upper if the matrix is symmetric + if (blockLdum.hasUpper()) + { + // Allocate extended upper only + extendedUpperPtr_ = new TypeCoeffField + ( + extLduAddr_.extendedUpperAddr().size(), + pTraits::zero + ); + TypeCoeffField& extUpper = *extendedUpperPtr_; + + // Get upper coeffs from underlying lduMatrix + const TypeCoeffField& upper = blockLdum.upper(); + + // Copy non-zero coeffs from basic lduMatrix into corresponding + // positions + forAll (upper, faceI) + { + extUpper[faceMap[faceI]] = upper[faceI]; + } + } + else + { + // Allocate extended lower only + extendedLowerPtr_ = new TypeCoeffField + ( + extLduAddr_.extendedLowerAddr().size(), + pTraits::zero + ); + TypeCoeffField& extLower = *extendedLowerPtr_; + + // Get lower coeffs from underlying lduMatrix + const TypeCoeffField& lower = blockLdum.lower(); + + // Copy non-zero coeffs from basic lduMatrix into corresponding + // positions + forAll (lower, faceI) + { + extLower[faceMap[faceI]] = lower[faceI]; + } + } + } + else + { + // Get reference to faceMap in extended addressing + const unallocLabelList& faceMap = extLduAddr_.faceMap(); + + // Get number of extended faces + const label nExtFaces = extLduAddr_.extendedUpperAddr().size(); + + // Allocate extended upper and lower + extendedUpperPtr_ = new TypeCoeffField(nExtFaces, pTraits::zero); + TypeCoeffField& extUpper = *extendedUpperPtr_; + + extendedLowerPtr_ = new TypeCoeffField(nExtFaces, pTraits::zero); + TypeCoeffField& extLower = *extendedLowerPtr_; + + // Get upper and lower coeffs from underlying lduMatrix + const TypeCoeffField& upper = blockLdum.upper(); + const TypeCoeffField& lower = blockLdum.lower(); + + // Copy non-zero coeffs from basic lduMatrix into corresponding + // positions + forAll (upper, faceI) + { + extUpper[faceMap[faceI]] = upper[faceI]; + extLower[faceMap[faceI]] = lower[faceI]; + } + } +} + + +// * * * * * * * * * * * * * * * * Destructor* * * * * * * * * * * * * * * * // + +template +Foam::extendedBlockLduMatrix::~extendedBlockLduMatrix() +{ + if (extendedLowerPtr_) + { + delete extendedLowerPtr_; + } + + if (extendedUpperPtr_) + { + delete extendedUpperPtr_; + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +typename Foam::extendedBlockLduMatrix::TypeCoeffField& +Foam::extendedBlockLduMatrix::extendedLower() +{ + if (!extendedLowerPtr_) + { + if (extendedUpperPtr_) + { + extendedLowerPtr_ = new TypeCoeffField(*extendedUpperPtr_); + } + else + { + extendedLowerPtr_ = new TypeCoeffField + ( + extLduAddr_.extendedLowerAddr().size(), + pTraits::zero + ); + } + } + + return *extendedLowerPtr_; +} + + +template +typename Foam::extendedBlockLduMatrix::TypeCoeffField& +Foam::extendedBlockLduMatrix::extendedUpper() +{ + if (!extendedUpperPtr_) + { + if (extendedLowerPtr_) + { + extendedUpperPtr_ = new TypeCoeffField(*extendedLowerPtr_); + } + else + { + extendedUpperPtr_ = new TypeCoeffField + ( + extLduAddr_.extendedUpperAddr().size(), + pTraits::zero + ); + } + } + + return *extendedUpperPtr_; +} + + +template +const typename Foam::extendedBlockLduMatrix::TypeCoeffField& +Foam::extendedBlockLduMatrix::extendedLower() const +{ + if (!extendedLowerPtr_ && !extendedUpperPtr_) + { + FatalErrorIn + ( + "const CoeffField& " + "extendedBlockLduMatrix::extendedLower() const" + ) << "extendedLowerPtr_ or extendedUpperPtr_ unallocated" + << abort(FatalError); + } + + if (extendedLowerPtr_) + { + return *extendedLowerPtr_; + } + else + { + return *extendedUpperPtr_; + } +} + + +template +const typename Foam::extendedBlockLduMatrix::TypeCoeffField& +Foam::extendedBlockLduMatrix::extendedUpper() const +{ + if (!extendedLowerPtr_ && !extendedUpperPtr_) + { + FatalErrorIn + ( + "const CoeffField& " + "extendedBlockLduMatrix::extendedLower() const" + ) << "extendedLowerPtr_ or extendedUpperPtr_ unallocated" + << abort(FatalError); + } + + if (extendedUpperPtr_) + { + return *extendedUpperPtr_; + } + else + { + return *extendedLowerPtr_; + } +} + + +// ************************************************************************* // diff --git a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.H b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.H new file mode 100644 index 000000000..3147d6209 --- /dev/null +++ b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.H @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | + \\ / A nd | For copyright notice see file Copyright + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Class + Foam::extendedBlockLduMatrix + +Description + Extension of lower and upper coeffs of BlockLduMatrix. Uses faceMap from + extendedLduAddressing to define extended lower and upper coeffs from + ordinary lower and upper coeffs given by ordinary BlockLduMatrix. Used in + ILUCp preconditioner. + +SourceFiles + extendedBlockLduMatrix.C + +\*---------------------------------------------------------------------------*/ + +#ifndef extendedBlockLduMatrix_H +#define extendedBlockLduMatrix_H + +#include "extendedLduAddressing.H" +#include "polyMesh.H" +#include "className.H" +#include "BlockLduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + + +/*---------------------------------------------------------------------------*\ + Class extendedBlockLduMatrix Declaration +\*---------------------------------------------------------------------------*/ + +template +class extendedBlockLduMatrix +{ + // Public data type + + typedef typename BlockLduMatrix::TypeCoeffField TypeCoeffField; + + +private: + + // Private data + + //- Reference to underlying BlockLduMatrix + const BlockLduMatrix& basicBlockLduMatrix_; + + //- Reference to extended ldu addressing + const extendedLduAddressing& extLduAddr_; + + //- Extended lower coeffs + CoeffField* extendedLowerPtr_; + + //- Extended upper coeffs + CoeffField* extendedUpperPtr_; + + + // Private member functions + + //- Disallow default bitwise copy construct + extendedBlockLduMatrix(const extendedBlockLduMatrix&); + + //- Disallow default bitwise assignement + void operator=(const extendedBlockLduMatrix&); + + +public: + + + ClassName("extendedBlockLduMatrix"); + + + // Constructors + + //- Construct given BlockduMatrix, extension level and polyMesh + extendedBlockLduMatrix + ( + const BlockLduMatrix&, + const label, + const polyMesh& + ); + + + // Destructor + + ~extendedBlockLduMatrix(); + + + // Member functions + + // Access + + //- Const access to underlying basic BlockLduMatrix + const lduMatrix& basicBlockLduMatrix() const + { + return basicBlockLduMatrix_; + }; + + //- Const access to extendedLduAddressing + const extendedLduAddressing& extendedLduAddr() const + { + return extLduAddr_; + }; + + //- Non-const access to extended lower coeffs + TypeCoeffField& extendedLower(); + + //- Non-const access to extended upper coeffs + TypeCoeffField& extendedUpper(); + + //- Const access to extended lower coeffs + const TypeCoeffField& extendedLower() const; + + //- Const access to extended upper coeffs + const TypeCoeffField& extendedUpper() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockVectorNMatrices.C b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockVectorNMatrices.C new file mode 100644 index 000000000..164bced12 --- /dev/null +++ b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockVectorNMatrices.C @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | + \\ / A nd | For copyright notice see file Copyright + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Description + Extended block matrix static data members + +Author + Vuko Vukcevic, FMENA Zagreb. All rights reserved. + +\*---------------------------------------------------------------------------*/ + +#include "coeffFields.H" +#include "extendedBlockVectorNMatrices.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +#define makeNamedTemplateTypeNameAndDebug(type, Type, args...) \ + defineNamedTemplateTypeNameAndDebug(block##Type##Matrix, 0); + +forAllVectorNTypes(makeNamedTemplateTypeNameAndDebug); + +#undef makeNamedTemplateTypeNameAndDebug + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockVectorNMatrices.H b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockVectorNMatrices.H new file mode 100644 index 000000000..68074e673 --- /dev/null +++ b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockVectorNMatrices.H @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | + \\ / A nd | For copyright notice see file Copyright + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Class + extendedBlockLduMatrix + +Description + Typedefs for extended block matrices + +Author + Vuko Vukcevic, FMENA Zagreb. All rights reserved. + +\*---------------------------------------------------------------------------*/ + +#ifndef blockVectorNMatrices_H +#define blockVectorNMatrices_H + +#include "extendedBlockLduMatrices.H" +#include "VectorTensorNFieldsFwd.H" +#include "ExpandTensorNField.H" +#include "VectorNFieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +#define makeTypedef(type, Type, args...) \ + typedef extendedBlockLduMatrix block##Type##Matrix; + +forAllVectorNTypes(makeTypedef) + +#undef makeTypedef + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //