diff --git a/applications/test/extendedStencil/Test-ExtendedStencil.C b/applications/test/extendedStencil/Test-ExtendedStencil.C index 4a5ce855ef3a25904611c656adef574320ed25e9..72c1afb2c11b96322b9266c35c93ed9d58e34cb7 100644 --- a/applications/test/extendedStencil/Test-ExtendedStencil.C +++ b/applications/test/extendedStencil/Test-ExtendedStencil.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-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -53,7 +53,9 @@ Description //#include "upwindCECCellToFaceStencilObject.H" //#include "upwindCFCCellToFaceStencilObject.H" -#include "centredCFCFaceToCellStencilObject.H" +//#include "centredCFCFaceToCellStencilObject.H" + +#include "centredCECCellToCellStencilObject.H" using namespace Foam; @@ -437,20 +439,20 @@ int main(int argc, char *argv[]) // ~~~~~~~~~~~~~~~~~~~~~ { - const extendedCentredFaceToCellStencil& addressing = - centredCFCFaceToCellStencilObject::New + const extendedCentredCellToCellStencil& addressing = + centredCECCellToCellStencilObject::New ( mesh ); - Info<< "cellFaceCell:" << endl; + Info<< "cellCellCell:" << endl; writeStencilStats(addressing.stencil()); - // Collect stencil face centres + // Collect stencil cell centres List<List<point> > stencilPoints(mesh.nCells()); addressing.collectData ( - mesh.Cf(), + mesh.C(), stencilPoints ); diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 3bf9c8747d6ba37b46ca7e71634897d868d79eb1..bd6bf3107c6199f1132c3344a26c2bebd77c20d5 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -53,10 +53,13 @@ $(fvMeshMapper)/fvSurfaceMapper.C extendedStencil = fvMesh/extendedStencil cellToCell = $(extendedStencil)/cellToCell +$(cellToCell)/extendedCellToCellStencil.C +$(cellToCell)/extendedCentredCellToCellStencil.C $(cellToCell)/fullStencils/cellToCellStencil.C $(cellToCell)/fullStencils/CFCCellToCellStencil.C $(cellToCell)/fullStencils/CPCCellToCellStencil.C $(cellToCell)/fullStencils/CECCellToCellStencil.C +$(cellToCell)/MeshObjects/centredCECCellToCellStencilObject.C cellToFace = $(extendedStencil)/cellToFace $(cellToFace)/fullStencils/cellToFaceStencil.C diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToCell/MeshObjects/centredCECCellToCellStencilObject.C b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/MeshObjects/centredCECCellToCellStencilObject.C new file mode 100644 index 0000000000000000000000000000000000000000..f6e7ee46e1f960198c147bc27332b930b4987e3f --- /dev/null +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/MeshObjects/centredCECCellToCellStencilObject.C @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 "centredCECCellToCellStencilObject.H" + + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(centredCECCellToCellStencilObject, 0); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToCell/MeshObjects/centredCECCellToCellStencilObject.H b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/MeshObjects/centredCECCellToCellStencilObject.H new file mode 100644 index 0000000000000000000000000000000000000000..a8e6aac93aa62dd52dff484bbe5814febf85acf0 --- /dev/null +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/MeshObjects/centredCECCellToCellStencilObject.H @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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/>. + +Class + Foam::centredCECCellToCellStencilObject + +Description + +SourceFiles + +\*---------------------------------------------------------------------------*/ + +#ifndef centredCECCellToCellStencilObject_H +#define centredCECCellToCellStencilObject_H + +#include "extendedCentredCellToCellStencil.H" +#include "CECCellToCellStencil.H" +#include "MeshObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class centredCECCellToCellStencilObject Declaration +\*---------------------------------------------------------------------------*/ + +class centredCECCellToCellStencilObject +: + public MeshObject<fvMesh, centredCECCellToCellStencilObject>, + public extendedCentredCellToCellStencil +{ + +public: + + TypeName("centredCECCellToCellStencil"); + + // Constructors + + //- Construct from uncompacted cell stencil + explicit centredCECCellToCellStencilObject + ( + const fvMesh& mesh + ) + : + MeshObject<fvMesh, centredCECCellToCellStencilObject>(mesh), + extendedCentredCellToCellStencil(CECCellToCellStencil(mesh)) + {} + + + //- Destructor + virtual ~centredCECCellToCellStencilObject() + {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCellToCellStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCellToCellStencil.C new file mode 100644 index 0000000000000000000000000000000000000000..4852332c32054e69c5f4b5fbb2442a1247c44560 --- /dev/null +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCellToCellStencil.C @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 "extendedCellToCellStencil.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::extendedCellToCellStencil::extendedCellToCellStencil(const polyMesh& mesh) +: + mesh_(mesh) +{ + // Check for transformation - not supported. + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + forAll(patches, patchI) + { + if (patches[patchI].coupled()) + { + const coupledPolyPatch& cpp = + refCast<const coupledPolyPatch>(patches[patchI]); + + if (!cpp.parallel() || cpp.separated()) + { + FatalErrorIn + ( + "extendedCellToCellStencil::extendedCellToCellStencil" + "(const polyMesh&)" + ) << "Coupled patches with transformations not supported." + << endl + << "Problematic patch " << cpp.name() << exit(FatalError); + } + } + } +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCellToCellStencil.H b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCellToCellStencil.H new file mode 100644 index 0000000000000000000000000000000000000000..57e6b2c6245941ca965e88335c4d5a227d0feaa8 --- /dev/null +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCellToCellStencil.H @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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/>. + +Class + Foam::extendedCellToCellStencil + +Description + Baseclass for cell-to-cell stencils + +SourceFiles + extendedCellToCellStencil.C + extendedCellToCellStencilTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef extendedCellToCellStencil_H +#define extendedCellToCellStencil_H + +#include "mapDistribute.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class globalIndex; + +/*---------------------------------------------------------------------------*\ + Class extendedCellToCellStencil Declaration +\*---------------------------------------------------------------------------*/ + +class extendedCellToCellStencil +{ +protected: + + // Protected data + + const polyMesh& mesh_; + +public: + + // Constructors + + //- Construct from mesh + explicit extendedCellToCellStencil(const polyMesh&); + + + // Member Functions + +// //- Use map to get the data into stencil order +// template<class T> +// static void collectData +// ( +// const mapDistribute& map, +// const labelListList& stencil, +// const GeometricField<T, fvsPatchField, surfaceMesh>& fld, +// List<List<T> >& stencilFld +// ); +// + //- Sum surface field contributions to create cell values + template<class Type> + static tmp<GeometricField<Type, fvPatchField, volMesh> > weightedSum + ( + const mapDistribute& map, + const labelListList& stencil, + const GeometricField<Type, fvPatchField, volMesh>& fld, + const List<List<scalar> >& stencilWeights + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "extendedCellToCellStencilTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCellToCellStencilTemplates.C b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCellToCellStencilTemplates.C new file mode 100644 index 0000000000000000000000000000000000000000..b9307adad700b629d36cbc3b322c577fd9108f3a --- /dev/null +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCellToCellStencilTemplates.C @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 "extendedCellToCellStencil.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> > +Foam::extendedCellToCellStencil::weightedSum +( + const mapDistribute& map, + const labelListList& stencil, + const GeometricField<Type, fvPatchField, volMesh>& fld, + const List<List<scalar> >& stencilWeights +) +{ + const fvMesh& mesh = fld.mesh(); + + // Collect internal and boundary values + List<List<Type> > stencilFld; + collectData(map, stencil, fld, stencilFld); + + tmp<GeometricField<Type, fvPatchField, volMesh> > tsfCorr + ( + new GeometricField<Type, fvPatchField, volMesh> + ( + IOobject + ( + fld.name(), + mesh.time().timeName(), + mesh + ), + mesh, + dimensioned<Type> + ( + fld.name(), + fld.dimensions(), + pTraits<Type>::zero + ) + ) + ); + GeometricField<Type, fvPatchField, volMesh>& sf = tsfCorr(); + + // cells + forAll(sf, cellI) + { + const List<Type>& stField = stencilFld[cellI]; + const List<scalar>& stWeight = stencilWeights[cellI]; + + forAll(stField, i) + { + sf[cellI] += stField[i]*stWeight[i]; + } + } + + // Boundaries values? + + return tsfCorr; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCentredCellToCellStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCentredCellToCellStencil.C new file mode 100644 index 0000000000000000000000000000000000000000..f1969f2af18e3c3ca0a1472cd5850d63323f1600 --- /dev/null +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCentredCellToCellStencil.C @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 "extendedCentredCellToCellStencil.H" +#include "mapDistribute.H" +#include "cellToCellStencil.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::extendedCentredCellToCellStencil::extendedCentredCellToCellStencil +( + const cellToCellStencil& stencil +) +: + extendedCellToCellStencil(stencil.mesh()), + stencil_(stencil) +{ + // Calculate distribute map (also renumbers elements in stencil) + List<Map<label> > compactMap(Pstream::nProcs()); + mapPtr_.reset + ( + new mapDistribute + ( + stencil.globalNumbering(), + stencil_, + compactMap + ) + ); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// Per cell which elements of the stencil to keep. +void Foam::extendedCentredCellToCellStencil::compact() +{ + boolList isInStencil(map().constructSize(), false); + + forAll(stencil_, cellI) + { + const labelList& stencilCells = stencil_[cellI]; + + forAll(stencilCells, i) + { + isInStencil[stencilCells[i]] = true; + } + } + + mapPtr_().compact(isInStencil, Pstream::msgType()); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCentredCellToCellStencil.H b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCentredCellToCellStencil.H new file mode 100644 index 0000000000000000000000000000000000000000..e2cc865ce463a2d64992f7b63fc47adc9554fd70 --- /dev/null +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/extendedCentredCellToCellStencil.H @@ -0,0 +1,146 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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/>. + +Class + Foam::extendedCentredCellToCellStencil + +Description + +SourceFiles + extendedCentredCellToCellStencil.C + +\*---------------------------------------------------------------------------*/ + +#ifndef extendedCentredCellToCellStencil_H +#define extendedCentredCellToCellStencil_H + +#include "extendedCellToCellStencil.H" +#include "extendedCellToFaceStencil.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class cellToCellStencil; + +/*---------------------------------------------------------------------------*\ + Class extendedCentredCellToCellStencil Declaration +\*---------------------------------------------------------------------------*/ + +class extendedCentredCellToCellStencil +: + public extendedCellToCellStencil +{ + // Private data + + //- Swap map for getting neigbouring data + autoPtr<mapDistribute> mapPtr_; + + //- Per cell the stencil. + labelListList stencil_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + extendedCentredCellToCellStencil + ( + const extendedCentredCellToCellStencil& + ); + + //- Disallow default bitwise assignment + void operator=(const extendedCentredCellToCellStencil&); + + +public: + + // Constructors + + //- Construct from uncompacted cell stencil + explicit extendedCentredCellToCellStencil(const cellToCellStencil&); + + + // Member Functions + + //- Return reference to the parallel distribution map + const mapDistribute& map() const + { + return mapPtr_(); + } + + //- Return reference to the stencil + const labelListList& stencil() const + { + return stencil_; + } + + //- After removing elements from the stencil adapt the schedule (map). + void compact(); + + //- Use map to get the data into stencil order + template<class Type> + void collectData + ( + const GeometricField<Type, fvPatchField, volMesh>& fld, + List<List<Type> >& stencilFld + ) const + { + extendedCellToFaceStencil::collectData + ( + map(), + stencil(), + fld, + stencilFld + ); + } + + //- Sum vol field contributions to create cell values + template<class Type> + tmp<GeometricField<Type, fvPatchField, volMesh> > weightedSum + ( + const GeometricField<Type, fvPatchField, volMesh>& fld, + const List<List<scalar> >& stencilWeights + ) const + { + return weightedSum + ( + map(), + stencil(), + fld, + stencilWeights + ); + } + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //