mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add face area support into PrimitivePatch (issue #266)
This commit is contained in:
@ -58,6 +58,8 @@ PrimitivePatch
|
|||||||
localPointsPtr_(nullptr),
|
localPointsPtr_(nullptr),
|
||||||
localPointOrderPtr_(nullptr),
|
localPointOrderPtr_(nullptr),
|
||||||
faceCentresPtr_(nullptr),
|
faceCentresPtr_(nullptr),
|
||||||
|
faceAreasPtr_(nullptr),
|
||||||
|
magFaceAreasPtr_(nullptr),
|
||||||
faceNormalsPtr_(nullptr),
|
faceNormalsPtr_(nullptr),
|
||||||
pointNormalsPtr_(nullptr)
|
pointNormalsPtr_(nullptr)
|
||||||
{}
|
{}
|
||||||
@ -94,6 +96,8 @@ PrimitivePatch
|
|||||||
localPointsPtr_(nullptr),
|
localPointsPtr_(nullptr),
|
||||||
localPointOrderPtr_(nullptr),
|
localPointOrderPtr_(nullptr),
|
||||||
faceCentresPtr_(nullptr),
|
faceCentresPtr_(nullptr),
|
||||||
|
faceAreasPtr_(nullptr),
|
||||||
|
magFaceAreasPtr_(nullptr),
|
||||||
faceNormalsPtr_(nullptr),
|
faceNormalsPtr_(nullptr),
|
||||||
pointNormalsPtr_(nullptr)
|
pointNormalsPtr_(nullptr)
|
||||||
{}
|
{}
|
||||||
@ -131,6 +135,8 @@ PrimitivePatch
|
|||||||
localPointsPtr_(nullptr),
|
localPointsPtr_(nullptr),
|
||||||
localPointOrderPtr_(nullptr),
|
localPointOrderPtr_(nullptr),
|
||||||
faceCentresPtr_(nullptr),
|
faceCentresPtr_(nullptr),
|
||||||
|
faceAreasPtr_(nullptr),
|
||||||
|
magFaceAreasPtr_(nullptr),
|
||||||
faceNormalsPtr_(nullptr),
|
faceNormalsPtr_(nullptr),
|
||||||
pointNormalsPtr_(nullptr)
|
pointNormalsPtr_(nullptr)
|
||||||
{}
|
{}
|
||||||
@ -167,6 +173,8 @@ PrimitivePatch
|
|||||||
localPointsPtr_(nullptr),
|
localPointsPtr_(nullptr),
|
||||||
localPointOrderPtr_(nullptr),
|
localPointOrderPtr_(nullptr),
|
||||||
faceCentresPtr_(nullptr),
|
faceCentresPtr_(nullptr),
|
||||||
|
faceAreasPtr_(nullptr),
|
||||||
|
magFaceAreasPtr_(nullptr),
|
||||||
faceNormalsPtr_(nullptr),
|
faceNormalsPtr_(nullptr),
|
||||||
pointNormalsPtr_(nullptr)
|
pointNormalsPtr_(nullptr)
|
||||||
{}
|
{}
|
||||||
@ -524,6 +532,46 @@ faceCentres() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
const Foam::Field<PointType>&
|
||||||
|
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
faceAreas() const
|
||||||
|
{
|
||||||
|
if (!faceAreasPtr_)
|
||||||
|
{
|
||||||
|
calcFaceAreas();
|
||||||
|
}
|
||||||
|
|
||||||
|
return *faceAreasPtr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
const Foam::Field<Foam::scalar>&
|
||||||
|
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
magFaceAreas() const
|
||||||
|
{
|
||||||
|
if (!magFaceAreasPtr_)
|
||||||
|
{
|
||||||
|
calcMagFaceAreas();
|
||||||
|
}
|
||||||
|
|
||||||
|
return *magFaceAreasPtr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template
|
template
|
||||||
<
|
<
|
||||||
class Face,
|
class Face,
|
||||||
|
|||||||
@ -168,6 +168,12 @@ private:
|
|||||||
//- Face centres
|
//- Face centres
|
||||||
mutable Field<PointType>* faceCentresPtr_;
|
mutable Field<PointType>* faceCentresPtr_;
|
||||||
|
|
||||||
|
//- Face area vectors
|
||||||
|
mutable Field<PointType>* faceAreasPtr_;
|
||||||
|
|
||||||
|
//- Mag face area
|
||||||
|
mutable Field<scalar>* magFaceAreasPtr_;
|
||||||
|
|
||||||
//- Face unit normals
|
//- Face unit normals
|
||||||
mutable Field<PointType>* faceNormalsPtr_;
|
mutable Field<PointType>* faceNormalsPtr_;
|
||||||
|
|
||||||
@ -210,6 +216,12 @@ private:
|
|||||||
//- Calculate face centres
|
//- Calculate face centres
|
||||||
void calcFaceCentres() const;
|
void calcFaceCentres() const;
|
||||||
|
|
||||||
|
//- Calculate face area vectors
|
||||||
|
void calcFaceAreas() const;
|
||||||
|
|
||||||
|
//- Calculate face area magnitudes
|
||||||
|
void calcMagFaceAreas() const;
|
||||||
|
|
||||||
//- Calculate unit face normals
|
//- Calculate unit face normals
|
||||||
void calcFaceNormals() const;
|
void calcFaceNormals() const;
|
||||||
|
|
||||||
@ -381,7 +393,13 @@ public:
|
|||||||
//- Return face centres for patch
|
//- Return face centres for patch
|
||||||
const Field<PointType>& faceCentres() const;
|
const Field<PointType>& faceCentres() const;
|
||||||
|
|
||||||
//- Return face normals for patch
|
//- Return face area vectors for patch
|
||||||
|
const Field<PointType>& faceAreas() const;
|
||||||
|
|
||||||
|
//- Return face area magnitudes for patch
|
||||||
|
const Field<scalar>& magFaceAreas() const;
|
||||||
|
|
||||||
|
//- Return face unit normals for patch
|
||||||
const Field<PointType>& faceNormals() const;
|
const Field<PointType>& faceNormals() const;
|
||||||
|
|
||||||
//- Return point normals for patch
|
//- Return point normals for patch
|
||||||
|
|||||||
@ -47,6 +47,8 @@ clearGeom()
|
|||||||
|
|
||||||
deleteDemandDrivenData(localPointsPtr_);
|
deleteDemandDrivenData(localPointsPtr_);
|
||||||
deleteDemandDrivenData(faceCentresPtr_);
|
deleteDemandDrivenData(faceCentresPtr_);
|
||||||
|
deleteDemandDrivenData(faceAreasPtr_);
|
||||||
|
deleteDemandDrivenData(magFaceAreasPtr_);
|
||||||
deleteDemandDrivenData(faceNormalsPtr_);
|
deleteDemandDrivenData(faceNormalsPtr_);
|
||||||
deleteDemandDrivenData(pointNormalsPtr_);
|
deleteDemandDrivenData(pointNormalsPtr_);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -52,7 +52,7 @@ calcMeshData() const
|
|||||||
if (meshPointsPtr_ || localFacesPtr_)
|
if (meshPointsPtr_ || localFacesPtr_)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "meshPointsPtr_ or localFacesPtr_already allocated"
|
<< "meshPointsPtr_ or localFacesPtr_ already allocated"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ calcLocalPoints() const
|
|||||||
if (localPointsPtr_)
|
if (localPointsPtr_)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "localPointsPtr_already allocated"
|
<< "localPointsPtr_ already allocated"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ calcPointNormals() const
|
|||||||
if (pointNormalsPtr_)
|
if (pointNormalsPtr_)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "pointNormalsPtr_already allocated"
|
<< "pointNormalsPtr_ already allocated"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ calcFaceCentres() const
|
|||||||
if (faceCentresPtr_)
|
if (faceCentresPtr_)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "faceCentresPtr_already allocated"
|
<< "faceCentresPtr_ already allocated"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,6 +346,98 @@ calcFaceCentres() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
void
|
||||||
|
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
calcMagFaceAreas() const
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
|
||||||
|
"calcMagFaceAreas() : "
|
||||||
|
"calculating magFaceAreas in PrimitivePatch"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is an error to calculate these more than once.
|
||||||
|
if (magFaceAreasPtr_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "magFaceAreasPtr_ already allocated"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
magFaceAreasPtr_ = new Field<scalar>(this->size());
|
||||||
|
Field<scalar>& a = *magFaceAreasPtr_;
|
||||||
|
|
||||||
|
forAll(a, facei)
|
||||||
|
{
|
||||||
|
a[facei] = this->operator[](facei).mag(points_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
|
||||||
|
"calcMagFaceAreas() : "
|
||||||
|
"finished calculating magFaceAreas in PrimitivePatch"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
void
|
||||||
|
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||||
|
calcFaceAreas() const
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
|
||||||
|
"calcFaceAreas() : "
|
||||||
|
"calculating faceAreas in PrimitivePatch"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is considered an error to attempt to recalculate faceNormals
|
||||||
|
// if they have already been calculated.
|
||||||
|
if (faceAreasPtr_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "faceAreasPtr_ already allocated"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
faceAreasPtr_ = new Field<PointType>(this->size());
|
||||||
|
|
||||||
|
Field<PointType>& n = *faceAreasPtr_;
|
||||||
|
|
||||||
|
forAll(n, facei)
|
||||||
|
{
|
||||||
|
n[facei] = this->operator[](facei).normal(points_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
|
||||||
|
"calcFaceAreas() : "
|
||||||
|
"finished calculating faceAreas in PrimitivePatch"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template
|
template
|
||||||
<
|
<
|
||||||
class Face,
|
class Face,
|
||||||
@ -370,7 +462,7 @@ calcFaceNormals() const
|
|||||||
if (faceNormalsPtr_)
|
if (faceNormalsPtr_)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "faceNormalsPtr_already allocated"
|
<< "faceNormalsPtr_ already allocated"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user