diff --git a/applications/test/extendedStencil/Test-ExtendedStencil.C b/applications/test/extendedStencil/Test-ExtendedStencil.C index 4a5ce855ef..72c1afb2c1 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 > stencilPoints(mesh.nCells()); addressing.collectData ( - mesh.Cf(), + mesh.C(), stencilPoints ); diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H index 563f1aadab..9aa6a77ab5 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,7 +38,11 @@ Description code #{ - operator==(min(10, 0.1*this->db().time().value())); + operator== + ( + vector(0,0,1) + *min(10, 0.1*this->db().time().value()) + ); #}; //codeInclude diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 3bf9c8747d..bd6bf3107c 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 0000000000..f6e7ee46e1 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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 0000000000..a8e6aac93a --- /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 . + +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, + public extendedCentredCellToCellStencil +{ + +public: + + TypeName("centredCECCellToCellStencil"); + + // Constructors + + //- Construct from uncompacted cell stencil + explicit centredCECCellToCellStencilObject + ( + const fvMesh& mesh + ) + : + MeshObject(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 0000000000..4852332c32 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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(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 0000000000..57e6b2c624 --- /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 . + +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 +// static void collectData +// ( +// const mapDistribute& map, +// const labelListList& stencil, +// const GeometricField& fld, +// List >& stencilFld +// ); +// + //- Sum surface field contributions to create cell values + template + static tmp > weightedSum + ( + const mapDistribute& map, + const labelListList& stencil, + const GeometricField& fld, + const List >& 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 0000000000..b9307adad7 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#include "extendedCellToCellStencil.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::tmp > +Foam::extendedCellToCellStencil::weightedSum +( + const mapDistribute& map, + const labelListList& stencil, + const GeometricField& fld, + const List >& stencilWeights +) +{ + const fvMesh& mesh = fld.mesh(); + + // Collect internal and boundary values + List > stencilFld; + collectData(map, stencil, fld, stencilFld); + + tmp > tsfCorr + ( + new GeometricField + ( + IOobject + ( + fld.name(), + mesh.time().timeName(), + mesh + ), + mesh, + dimensioned + ( + fld.name(), + fld.dimensions(), + pTraits::zero + ) + ) + ); + GeometricField& sf = tsfCorr(); + + // cells + forAll(sf, cellI) + { + const List& stField = stencilFld[cellI]; + const List& 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 0000000000..f1969f2af1 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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 > 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 0000000000..e2cc865ce4 --- /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 . + +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 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 + void collectData + ( + const GeometricField& fld, + List >& stencilFld + ) const + { + extendedCellToFaceStencil::collectData + ( + map(), + stencil(), + fld, + stencilFld + ); + } + + //- Sum vol field contributions to create cell values + template + tmp > weightedSum + ( + const GeometricField& fld, + const List >& stencilWeights + ) const + { + return weightedSum + ( + map(), + stencil(), + fld, + stencilWeights + ); + } + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //