ENH: add fvPatch::start() method to simplify some expressions

This commit is contained in:
Mark Olesen
2010-04-13 16:06:57 +02:00
parent 6148d8c428
commit af039f0eb7
2 changed files with 31 additions and 32 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,21 +31,18 @@ License
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(fvPatch, 0);
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineRunTimeSelectionTable(fvPatch, polyPatch);
addToRunTimeSelectionTable(fvPatch, fvPatch, polyPatch);
defineTypeNameAndDebug(fvPatch, 0); }
defineRunTimeSelectionTable(fvPatch, polyPatch);
addToRunTimeSelectionTable(fvPatch, fvPatch, polyPatch);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
fvPatch::fvPatch(const polyPatch& p, const fvBoundaryMesh& bm) Foam::fvPatch::fvPatch(const polyPatch& p, const fvBoundaryMesh& bm)
: :
polyPatch_(p), polyPatch_(p),
boundaryMesh_(bm) boundaryMesh_(bm)
@ -54,19 +51,19 @@ fvPatch::fvPatch(const polyPatch& p, const fvBoundaryMesh& bm)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
fvPatch::~fvPatch() Foam::fvPatch::~fvPatch()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool fvPatch::constraintType(const word& pt) bool Foam::fvPatch::constraintType(const word& pt)
{ {
return fvPatchField<scalar>::patchConstructorTablePtr_->found(pt); return fvPatchField<scalar>::patchConstructorTablePtr_->found(pt);
} }
wordList fvPatch::constraintTypes() Foam::wordList Foam::fvPatch::constraintTypes()
{ {
wordList cTypes(polyPatchConstructorTablePtr_->size()); wordList cTypes(polyPatchConstructorTablePtr_->size());
@ -92,19 +89,19 @@ wordList fvPatch::constraintTypes()
} }
const unallocLabelList& fvPatch::faceCells() const const Foam::unallocLabelList& Foam::fvPatch::faceCells() const
{ {
return polyPatch_.faceCells(); return polyPatch_.faceCells();
} }
const vectorField& fvPatch::Cf() const const Foam::vectorField& Foam::fvPatch::Cf() const
{ {
return boundaryMesh().mesh().Cf().boundaryField()[index()]; return boundaryMesh().mesh().Cf().boundaryField()[index()];
} }
tmp<vectorField> fvPatch::Cn() const Foam::tmp<Foam::vectorField> Foam::fvPatch::Cn() const
{ {
tmp<vectorField> tcc(new vectorField(size())); tmp<vectorField> tcc(new vectorField(size()));
vectorField& cc = tcc(); vectorField& cc = tcc();
@ -123,64 +120,60 @@ tmp<vectorField> fvPatch::Cn() const
} }
tmp<vectorField> fvPatch::nf() const Foam::tmp<Foam::vectorField> Foam::fvPatch::nf() const
{ {
return Sf()/magSf(); return Sf()/magSf();
} }
const vectorField& fvPatch::Sf() const const Foam::vectorField& Foam::fvPatch::Sf() const
{ {
return boundaryMesh().mesh().Sf().boundaryField()[index()]; return boundaryMesh().mesh().Sf().boundaryField()[index()];
} }
const scalarField& fvPatch::magSf() const const Foam::scalarField& Foam::fvPatch::magSf() const
{ {
return boundaryMesh().mesh().magSf().boundaryField()[index()]; return boundaryMesh().mesh().magSf().boundaryField()[index()];
} }
tmp<vectorField> fvPatch::delta() const Foam::tmp<Foam::vectorField> Foam::fvPatch::delta() const
{ {
return Cf() - Cn(); return Cf() - Cn();
} }
void fvPatch::makeWeights(scalarField& w) const void Foam::fvPatch::makeWeights(scalarField& w) const
{ {
w = 1.0; w = 1.0;
} }
void fvPatch::makeDeltaCoeffs(scalarField& dc) const void Foam::fvPatch::makeDeltaCoeffs(scalarField& dc) const
{ {
dc = 1.0/(nf() & delta()); dc = 1.0/(nf() & delta());
} }
void fvPatch::initMovePoints() void Foam::fvPatch::initMovePoints()
{} {}
void fvPatch::movePoints() void Foam::fvPatch::movePoints()
{} {}
const scalarField& fvPatch::deltaCoeffs() const const Foam::scalarField& Foam::fvPatch::deltaCoeffs() const
{ {
return boundaryMesh().mesh().deltaCoeffs().boundaryField()[index()]; return boundaryMesh().mesh().deltaCoeffs().boundaryField()[index()];
} }
const scalarField& fvPatch::weights() const const Foam::scalarField& Foam::fvPatch::weights() const
{ {
return boundaryMesh().mesh().weights().boundaryField()[index()]; return boundaryMesh().mesh().weights().boundaryField()[index()];
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -151,6 +151,12 @@ public:
return polyPatch_.name(); return polyPatch_.name();
} }
//- Return start label of this patch in the polyMesh face list
label start() const
{
return polyPatch_.start();
}
//- Return size //- Return size
virtual label size() const virtual label size() const
{ {
@ -185,7 +191,7 @@ public:
template<class T> template<class T>
const typename List<T>::subList patchSlice(const List<T>& l) const const typename List<T>::subList patchSlice(const List<T>& l) const
{ {
return typename List<T>::subList(l, size(), polyPatch_.start()); return typename List<T>::subList(l, size(), start());
} }
//- Return faceCells //- Return faceCells