mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: propagate face area to sampling (issue #266)
- make top-level Sf(), magSf(), Cf() pure virtual since the sub-classes will always be providing the face/point storage, with either triSurface or MeshedSurface in the background
This commit is contained in:
@ -193,6 +193,25 @@ public:
|
||||
return facesPtr_;
|
||||
}
|
||||
|
||||
//- Face area vectors
|
||||
virtual const vectorField& Sf() const
|
||||
{
|
||||
return surface().Sf();
|
||||
}
|
||||
|
||||
//- Face area magnitudes
|
||||
virtual const scalarField& magSf() const
|
||||
{
|
||||
return surface().magSf();
|
||||
}
|
||||
|
||||
//- Face centres
|
||||
virtual const vectorField& Cf() const
|
||||
{
|
||||
return surface().Cf();
|
||||
}
|
||||
|
||||
|
||||
const triSurface& surface() const
|
||||
{
|
||||
if (cell_)
|
||||
|
||||
@ -158,6 +158,11 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
const isoSurface& surface() const
|
||||
{
|
||||
return surfPtr_();
|
||||
}
|
||||
|
||||
//- Does the surface need an update?
|
||||
virtual bool needsUpdate() const;
|
||||
|
||||
@ -194,16 +199,32 @@ public:
|
||||
return facesPtr_;
|
||||
}
|
||||
|
||||
|
||||
const isoSurface& surface() const
|
||||
//- Face area magnitudes
|
||||
virtual const vectorField& Sf() const
|
||||
{
|
||||
return surfPtr_();
|
||||
return surface().Sf();
|
||||
}
|
||||
|
||||
//- Lookup or read isoField. Sets volFieldPtr_ and pointFieldPtr_.
|
||||
//- Face area magnitudes
|
||||
virtual const scalarField& magSf() const
|
||||
{
|
||||
return surface().magSf();
|
||||
}
|
||||
|
||||
//- Face centres
|
||||
virtual const vectorField& Cf() const
|
||||
{
|
||||
return surface().Cf();
|
||||
}
|
||||
|
||||
|
||||
//- Lookup or read isoField.
|
||||
// Sets volFieldPtr_ and pointFieldPtr_.
|
||||
void getIsoField();
|
||||
|
||||
|
||||
// Sample
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
@ -235,6 +256,8 @@ public:
|
||||
) const;
|
||||
|
||||
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate field on surface
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
@ -265,6 +288,9 @@ public:
|
||||
const interpolation<tensor>&
|
||||
) const;
|
||||
|
||||
|
||||
// Output
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
};
|
||||
|
||||
@ -54,6 +54,9 @@ class sampledIsoSurfaceCell
|
||||
public sampledSurface,
|
||||
public triSurface
|
||||
{
|
||||
//- Private typedef for convenience
|
||||
typedef triSurface MeshStorage;
|
||||
|
||||
// Private data
|
||||
|
||||
//- Field to get isoSurface of
|
||||
@ -145,7 +148,7 @@ public:
|
||||
//- Points of surface
|
||||
virtual const pointField& points() const
|
||||
{
|
||||
return triSurface::points();
|
||||
return MeshStorage::points();
|
||||
}
|
||||
|
||||
//- Faces of surface
|
||||
@ -165,6 +168,24 @@ public:
|
||||
return facesPtr_;
|
||||
}
|
||||
|
||||
//- Face area magnitudes
|
||||
virtual const vectorField& Sf() const
|
||||
{
|
||||
return MeshStorage::Sf();
|
||||
}
|
||||
|
||||
//- Face area magnitudes
|
||||
virtual const scalarField& magSf() const
|
||||
{
|
||||
return MeshStorage::magSf();
|
||||
}
|
||||
|
||||
//- Face centres
|
||||
virtual const vectorField& Cf() const
|
||||
{
|
||||
return MeshStorage::Cf();
|
||||
}
|
||||
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<scalarField> sample
|
||||
|
||||
@ -141,6 +141,12 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//const isoSurfaceCell& surface() const
|
||||
const isoSurface& surface() const
|
||||
{
|
||||
return isoSurfPtr_();
|
||||
}
|
||||
|
||||
//- Does the surface need an update?
|
||||
virtual bool needsUpdate() const;
|
||||
|
||||
@ -176,13 +182,27 @@ public:
|
||||
return facesPtr_;
|
||||
}
|
||||
|
||||
|
||||
//const isoSurfaceCell& surface() const
|
||||
const isoSurface& surface() const
|
||||
//- Face area magnitudes
|
||||
virtual const vectorField& Sf() const
|
||||
{
|
||||
return isoSurfPtr_();
|
||||
return surface().Sf();
|
||||
}
|
||||
|
||||
//- Face area magnitudes
|
||||
virtual const scalarField& magSf() const
|
||||
{
|
||||
return surface().magSf();
|
||||
}
|
||||
|
||||
//- Face centres
|
||||
virtual const vectorField& Cf() const
|
||||
{
|
||||
return surface().Cf();
|
||||
}
|
||||
|
||||
|
||||
// Sample
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
@ -214,6 +234,8 @@ public:
|
||||
) const;
|
||||
|
||||
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate field on surface
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
@ -244,6 +266,9 @@ public:
|
||||
const interpolation<tensor>&
|
||||
) const;
|
||||
|
||||
|
||||
// Output
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
};
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -180,8 +180,27 @@ public:
|
||||
return MeshStorage::faces();
|
||||
}
|
||||
|
||||
//- Face area vectors
|
||||
virtual const vectorField& Sf() const
|
||||
{
|
||||
return MeshStorage::Sf();
|
||||
}
|
||||
|
||||
//- Face area magnitudes
|
||||
virtual const scalarField& magSf() const
|
||||
{
|
||||
return MeshStorage::magSf();
|
||||
}
|
||||
|
||||
//- Face centres
|
||||
virtual const vectorField& Cf() const
|
||||
{
|
||||
return MeshStorage::Cf();
|
||||
}
|
||||
|
||||
|
||||
// Sample
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -140,6 +140,25 @@ public:
|
||||
return cuttingPlane::faces();
|
||||
}
|
||||
|
||||
//- Face area magnitudes
|
||||
virtual const vectorField& Sf() const
|
||||
{
|
||||
return cuttingPlane::Sf();
|
||||
}
|
||||
|
||||
//- Face area magnitudes
|
||||
virtual const scalarField& magSf() const
|
||||
{
|
||||
return cuttingPlane::magSf();
|
||||
}
|
||||
|
||||
//- Face centres
|
||||
virtual const vectorField& Cf() const
|
||||
{
|
||||
return cuttingPlane::Cf();
|
||||
}
|
||||
|
||||
|
||||
//- For every face original cell in mesh
|
||||
const labelList& meshCells() const
|
||||
{
|
||||
|
||||
@ -41,76 +41,10 @@ namespace Foam
|
||||
|
||||
void Foam::sampledSurface::clearGeom() const
|
||||
{
|
||||
deleteDemandDrivenData(SfPtr_);
|
||||
deleteDemandDrivenData(magSfPtr_);
|
||||
deleteDemandDrivenData(CfPtr_);
|
||||
area_ = -1;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurface::makeSf() const
|
||||
{
|
||||
// It is an error to recalculate if the pointer is already set
|
||||
if (SfPtr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "face area vectors already exist"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const faceList& theFaces = faces();
|
||||
SfPtr_ = new vectorField(theFaces.size());
|
||||
|
||||
vectorField& values = *SfPtr_;
|
||||
forAll(theFaces, facei)
|
||||
{
|
||||
values[facei] = theFaces[facei].normal(points());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurface::makeMagSf() const
|
||||
{
|
||||
// It is an error to recalculate if the pointer is already set
|
||||
if (magSfPtr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "mag face areas already exist"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const faceList& theFaces = faces();
|
||||
magSfPtr_ = new scalarField(theFaces.size());
|
||||
|
||||
scalarField& values = *magSfPtr_;
|
||||
forAll(theFaces, facei)
|
||||
{
|
||||
values[facei] = theFaces[facei].mag(points());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurface::makeCf() const
|
||||
{
|
||||
// It is an error to recalculate if the pointer is already set
|
||||
if (CfPtr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "face centres already exist"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const faceList& theFaces = faces();
|
||||
CfPtr_ = new vectorField(theFaces.size());
|
||||
|
||||
vectorField& values = *CfPtr_;
|
||||
forAll(theFaces, facei)
|
||||
{
|
||||
values[facei] = theFaces[facei].centre(points());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::sampledSurface> Foam::sampledSurface::New
|
||||
@ -156,9 +90,6 @@ Foam::sampledSurface::sampledSurface
|
||||
name_(name),
|
||||
mesh_(mesh),
|
||||
interpolate_(interpolate),
|
||||
SfPtr_(nullptr),
|
||||
magSfPtr_(nullptr),
|
||||
CfPtr_(nullptr),
|
||||
area_(-1)
|
||||
{}
|
||||
|
||||
@ -173,9 +104,6 @@ Foam::sampledSurface::sampledSurface
|
||||
name_(name),
|
||||
mesh_(mesh),
|
||||
interpolate_(dict.lookupOrDefault("interpolate", false)),
|
||||
SfPtr_(nullptr),
|
||||
magSfPtr_(nullptr),
|
||||
CfPtr_(nullptr),
|
||||
area_(-1)
|
||||
{
|
||||
dict.readIfPresent("name", name_);
|
||||
@ -192,39 +120,6 @@ Foam::sampledSurface::~sampledSurface()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::vectorField& Foam::sampledSurface::Sf() const
|
||||
{
|
||||
if (!SfPtr_)
|
||||
{
|
||||
makeSf();
|
||||
}
|
||||
|
||||
return *SfPtr_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::scalarField& Foam::sampledSurface::magSf() const
|
||||
{
|
||||
if (!magSfPtr_)
|
||||
{
|
||||
makeMagSf();
|
||||
}
|
||||
|
||||
return *magSfPtr_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::vectorField& Foam::sampledSurface::Cf() const
|
||||
{
|
||||
if (!CfPtr_)
|
||||
{
|
||||
makeCf();
|
||||
}
|
||||
|
||||
return *CfPtr_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::sampledSurface::area() const
|
||||
{
|
||||
if (area_ < 0)
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -98,31 +98,10 @@ class sampledSurface
|
||||
|
||||
// Demand-driven data
|
||||
|
||||
//- Face area vectors
|
||||
mutable vectorField* SfPtr_;
|
||||
|
||||
//- Mag face area vectors
|
||||
mutable scalarField* magSfPtr_;
|
||||
|
||||
//- Face centres
|
||||
mutable vectorField* CfPtr_;
|
||||
|
||||
//- Total surface area
|
||||
mutable scalar area_;
|
||||
|
||||
|
||||
// Make geometric data
|
||||
|
||||
//- Make Sf
|
||||
void makeSf() const;
|
||||
|
||||
//- Make magSf
|
||||
void makeMagSf() const;
|
||||
|
||||
//- Make Cf
|
||||
void makeCf() const;
|
||||
|
||||
|
||||
// Service methods
|
||||
|
||||
//- Check field size matches surface size
|
||||
@ -284,18 +263,19 @@ public:
|
||||
//- Faces of surface
|
||||
virtual const faceList& faces() const = 0;
|
||||
|
||||
//- Return face area vectors
|
||||
virtual const vectorField& Sf() const;
|
||||
//- Face area vectors
|
||||
virtual const vectorField& Sf() const = 0;
|
||||
|
||||
//- Return face area magnitudes
|
||||
virtual const scalarField& magSf() const;
|
||||
//- Face area magnitudes
|
||||
virtual const scalarField& magSf() const = 0;
|
||||
|
||||
//- Return face centres as vectorField
|
||||
virtual const vectorField& Cf() const;
|
||||
//- Face centres
|
||||
virtual const vectorField& Cf() const = 0;
|
||||
|
||||
//- The total surface area
|
||||
scalar area() const;
|
||||
|
||||
|
||||
//- Integration of a field across the surface
|
||||
template<class Type>
|
||||
Type integrate(const Field<Type>&) const;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -216,6 +216,24 @@ public:
|
||||
return MeshStorage::faces();
|
||||
}
|
||||
|
||||
//- Face area vectors
|
||||
virtual const vectorField& Sf() const
|
||||
{
|
||||
return MeshStorage::Sf();
|
||||
}
|
||||
|
||||
//- Face area magnitudes
|
||||
virtual const scalarField& magSf() const
|
||||
{
|
||||
return MeshStorage::magSf();
|
||||
}
|
||||
|
||||
//- Face centres
|
||||
virtual const vectorField& Cf() const
|
||||
{
|
||||
return MeshStorage::Cf();
|
||||
}
|
||||
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<scalarField> sample
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -148,6 +148,25 @@ public:
|
||||
return MeshStorage::faces();
|
||||
}
|
||||
|
||||
//- Face area vectors (normals)
|
||||
virtual const vectorField& Sf() const
|
||||
{
|
||||
return MeshStorage::Sf();
|
||||
}
|
||||
|
||||
//- Face area magnitudes
|
||||
virtual const scalarField& magSf() const
|
||||
{
|
||||
return MeshStorage::magSf();
|
||||
}
|
||||
|
||||
//- Face centres
|
||||
virtual const vectorField& Cf() const
|
||||
{
|
||||
return MeshStorage::Cf();
|
||||
}
|
||||
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<scalarField> sample(const volScalarField&) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user