Skip to content
Snippets Groups Projects
Commit 58541c5f authored by mattijs's avatar mattijs
Browse files

ENH: cellToCell extended stencils

parent baee4f38
Branches
Tags
No related merge requests found
Showing
with 607 additions and 7 deletions
......@@ -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
);
......
......@@ -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
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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);
}
}
}
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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());
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment