mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add external surface handling to meshedSurfRef (#2505)
- previously just handled surface components - move/scale mesh points (copy) STYLE: pass in dummy faces/points to writer STYLE: use tensor is_identity()
This commit is contained in:
@ -629,12 +629,10 @@ void Foam::PDRobstacle::generateVtk
|
|||||||
{
|
{
|
||||||
label pieceId = 0;
|
label pieceId = 0;
|
||||||
|
|
||||||
meshedSurf::emptySurface dummy;
|
|
||||||
|
|
||||||
vtk::surfaceWriter surfWriter
|
vtk::surfaceWriter surfWriter
|
||||||
(
|
(
|
||||||
dummy.points(),
|
pointField::null(),
|
||||||
dummy.faces(),
|
faceList::null(),
|
||||||
// vtk::formatType::INLINE_ASCII,
|
// vtk::formatType::INLINE_ASCII,
|
||||||
(outputDir / "Obstacles"),
|
(outputDir / "Obstacles"),
|
||||||
false // serial only
|
false // serial only
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -147,41 +147,21 @@ bool Foam::blockMesh::readPointTransforms(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
transformType_ = transformTypes::NO_TRANSFORM;
|
transformType_ = transformTypes::NO_TRANSFORM;
|
||||||
|
|
||||||
|
const dictionary* dictptr;
|
||||||
|
|
||||||
// Optional cartesian coordinate system transform, since JUL-2021
|
// Optional cartesian coordinate system transform, since JUL-2021
|
||||||
if (const dictionary* dictptr = dict.findDict("transform"))
|
if ((dictptr = dict.findDict("transform", keyType::LITERAL)) != nullptr)
|
||||||
{
|
{
|
||||||
transform_ = coordSystem::cartesian(*dictptr);
|
transform_ = coordSystem::cartesian(*dictptr);
|
||||||
|
|
||||||
constexpr scalar tol = VSMALL;
|
// Non-zero origin?
|
||||||
|
if (magSqr(transform_.origin()) > ROOTVSMALL)
|
||||||
// Check for non-zero origin
|
|
||||||
const vector& o = transform_.origin();
|
|
||||||
if
|
|
||||||
(
|
|
||||||
(mag(o.x()) > tol)
|
|
||||||
|| (mag(o.y()) > tol)
|
|
||||||
|| (mag(o.z()) > tol)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
transformType_ |= transformTypes::TRANSLATION;
|
transformType_ |= transformTypes::TRANSLATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for non-identity rotation
|
// Non-identity rotation?
|
||||||
const tensor& r = transform_.R();
|
if (!transform_.R().is_identity(ROOTVSMALL))
|
||||||
if
|
|
||||||
(
|
|
||||||
(mag(r.xx() - 1) > tol)
|
|
||||||
|| (mag(r.xy()) > tol)
|
|
||||||
|| (mag(r.xz()) > tol)
|
|
||||||
|
|
||||||
|| (mag(r.yx()) > tol)
|
|
||||||
|| (mag(r.yy() - 1) > tol)
|
|
||||||
|| (mag(r.yz()) > tol)
|
|
||||||
|
|
||||||
|| (mag(r.zx()) > tol)
|
|
||||||
|| (mag(r.zy()) > tol)
|
|
||||||
|| (mag(r.zz() - 1) > tol)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
transformType_ |= transformTypes::ROTATION;
|
transformType_ |= transformTypes::ROTATION;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,21 +105,6 @@ static bool isCollocatedPatch(const coupledPolyPatch& pp)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::isoSurfacePoint::noTransform(const tensor& tt) const
|
|
||||||
{
|
|
||||||
return
|
|
||||||
(mag(tt.xx()-1) < mergeDistance_)
|
|
||||||
&& (mag(tt.yy()-1) < mergeDistance_)
|
|
||||||
&& (mag(tt.zz()-1) < mergeDistance_)
|
|
||||||
&& (mag(tt.xy()) < mergeDistance_)
|
|
||||||
&& (mag(tt.xz()) < mergeDistance_)
|
|
||||||
&& (mag(tt.yx()) < mergeDistance_)
|
|
||||||
&& (mag(tt.yz()) < mergeDistance_)
|
|
||||||
&& (mag(tt.zx()) < mergeDistance_)
|
|
||||||
&& (mag(tt.zy()) < mergeDistance_);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::bitSet Foam::isoSurfacePoint::collocatedFaces
|
Foam::bitSet Foam::isoSurfacePoint::collocatedFaces
|
||||||
(
|
(
|
||||||
const coupledPolyPatch& pp
|
const coupledPolyPatch& pp
|
||||||
|
|||||||
@ -124,9 +124,6 @@ class isoSurfacePoint
|
|||||||
|
|
||||||
// Point synchronisation
|
// Point synchronisation
|
||||||
|
|
||||||
//- Does tensor differ (to within mergeTolerance) from identity
|
|
||||||
bool noTransform(const tensor& tt) const;
|
|
||||||
|
|
||||||
//- Per face whether is collocated
|
//- Per face whether is collocated
|
||||||
static bitSet collocatedFaces(const coupledPolyPatch& cpp);
|
static bitSet collocatedFaces(const coupledPolyPatch& cpp);
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -31,8 +31,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef meshedSurf_H
|
#ifndef Foam_meshedSurf_H
|
||||||
#define meshedSurf_H
|
#define Foam_meshedSurf_H
|
||||||
|
|
||||||
#include "pointField.H"
|
#include "pointField.H"
|
||||||
#include "faceList.H"
|
#include "faceList.H"
|
||||||
@ -51,7 +51,7 @@ class meshedSurf
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Forward declarations
|
// Forward Declarations
|
||||||
class emptySurface;
|
class emptySurface;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,14 +27,19 @@ Class
|
|||||||
Foam::meshedSurfRef
|
Foam::meshedSurfRef
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Implements a meshed surface by referencing existing faces and points.
|
Implements a meshed surface by referencing another meshed surface
|
||||||
|
or faces/points components.
|
||||||
|
|
||||||
|
In addition to the referencing, supports simple moving/scaling
|
||||||
|
of points (uses a deep-copy).
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef meshedSurfRef_H
|
#ifndef Foam_meshedSurfRef_H
|
||||||
#define meshedSurfRef_H
|
#define Foam_meshedSurfRef_H
|
||||||
|
|
||||||
#include "meshedSurf.H"
|
#include "meshedSurf.H"
|
||||||
|
#include "refPtr.H"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -50,10 +55,19 @@ class meshedSurfRef
|
|||||||
:
|
:
|
||||||
public meshedSurf
|
public meshedSurf
|
||||||
{
|
{
|
||||||
std::reference_wrapper<const pointField> points_;
|
// Private Data
|
||||||
std::reference_wrapper<const faceList> faces_;
|
|
||||||
std::reference_wrapper<const labelList> zoneIds_;
|
//- An external surface reference
|
||||||
std::reference_wrapper<const labelList> faceIds_;
|
refPtr<meshedSurf> surf_;
|
||||||
|
|
||||||
|
//- Components
|
||||||
|
std::reference_wrapper<const pointField> points_;
|
||||||
|
std::reference_wrapper<const faceList> faces_;
|
||||||
|
std::reference_wrapper<const labelList> zoneIds_;
|
||||||
|
std::reference_wrapper<const labelList> faceIds_;
|
||||||
|
|
||||||
|
//- Locations of moved/scaled points (if any)
|
||||||
|
pointField newPoints_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -69,20 +83,27 @@ public:
|
|||||||
faceIds_(std::cref<labelList>(labelList::null()))
|
faceIds_(std::cref<labelList>(labelList::null()))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
//- Construct as reference to a meshedSurf
|
||||||
|
explicit meshedSurfRef(const meshedSurf& s)
|
||||||
|
:
|
||||||
|
meshedSurfRef()
|
||||||
|
{
|
||||||
|
surf_.cref(s);
|
||||||
|
}
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
meshedSurfRef
|
meshedSurfRef
|
||||||
(
|
(
|
||||||
const pointField& pointLst,
|
const pointField& points,
|
||||||
const faceList& faceLst,
|
const faceList& faces,
|
||||||
const labelList& zoneIdLst = labelList::null(),
|
const labelList& zoneIds = labelList::null(),
|
||||||
const labelList& faceIdLst = labelList::null()
|
const labelList& faceIds = labelList::null()
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
points_(std::cref<pointField>(pointLst)),
|
points_(std::cref<pointField>(points)),
|
||||||
faces_(std::cref<faceList>(faceLst)),
|
faces_(std::cref<faceList>(faces)),
|
||||||
zoneIds_(std::cref<labelList>(zoneIdLst)),
|
zoneIds_(std::cref<labelList>(zoneIds)),
|
||||||
faceIds_(std::cref<labelList>(faceIdLst))
|
faceIds_(std::cref<labelList>(faceIds))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -92,52 +113,112 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Contains a valid reference?
|
||||||
|
bool valid() const
|
||||||
|
{
|
||||||
|
return (surf_ || notNull(points_.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//- The original points used for the surface
|
||||||
|
const pointField& points0() const
|
||||||
|
{
|
||||||
|
return (surf_ ? surf_.cref().points() : points_.get());
|
||||||
|
}
|
||||||
|
|
||||||
//- The points used for the surface
|
//- The points used for the surface
|
||||||
virtual const pointField& points() const
|
virtual const pointField& points() const
|
||||||
{
|
{
|
||||||
return points_.get();
|
return (newPoints_.empty() ? points0() : newPoints_);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- The faces used for the surface
|
//- The faces used for the surface
|
||||||
virtual const faceList& faces() const
|
virtual const faceList& faces() const
|
||||||
{
|
{
|
||||||
return faces_.get();
|
return (surf_ ? surf_.cref().faces() : faces_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Per-face zone/region information.
|
//- Per-face zone/region information
|
||||||
virtual const labelList& zoneIds() const
|
virtual const labelList& zoneIds() const
|
||||||
{
|
{
|
||||||
return zoneIds_.get();
|
return (surf_ ? surf_.cref().zoneIds() : zoneIds_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Per-face identifier (eg, element Id)
|
//- Per-face identifier (eg, element Id)
|
||||||
virtual const labelList& faceIds() const
|
virtual const labelList& faceIds() const
|
||||||
{
|
{
|
||||||
return faceIds_.get();
|
return (surf_ ? surf_.cref().faceIds() : faceIds_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Remove all references by redirecting to null objects
|
//- Invalid by redirecting to null objects
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
|
surf_.reset();
|
||||||
points_ = std::cref<pointField>(pointField::null());
|
points_ = std::cref<pointField>(pointField::null());
|
||||||
faces_ = std::cref<faceList>(faceList::null());
|
faces_ = std::cref<faceList>(faceList::null());
|
||||||
zoneIds_ = std::cref<labelList>(labelList::null());
|
zoneIds_ = std::cref<labelList>(labelList::null());
|
||||||
faceIds_ = std::cref<labelList>(labelList::null());
|
faceIds_ = std::cref<labelList>(labelList::null());
|
||||||
|
newPoints_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Reset surface
|
||||||
|
void reset(const meshedSurf& s)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
surf_.cref(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Reset components
|
//- Reset components
|
||||||
void reset
|
void reset
|
||||||
(
|
(
|
||||||
const pointField& pointLst,
|
const pointField& points,
|
||||||
const faceList& faceLst,
|
const faceList& faces,
|
||||||
const labelList& zoneIdLst = labelList::null(),
|
const labelList& zoneIds = labelList::null(),
|
||||||
const labelList& faceIdLst = labelList::null()
|
const labelList& faceIds = labelList::null()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
points_ = std::cref<pointField>(pointLst);
|
surf_.reset();
|
||||||
faces_ = std::cref<faceList>(faceLst);
|
points_ = std::cref<pointField>(points);
|
||||||
zoneIds_ = std::cref<labelList>(zoneIdLst);
|
faces_ = std::cref<faceList>(faces);
|
||||||
faceIds_ = std::cref<labelList>(faceIdLst);
|
zoneIds_ = std::cref<labelList>(zoneIds);
|
||||||
|
faceIds_ = std::cref<labelList>(faceIds);
|
||||||
|
newPoints_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Reset changes in point positions
|
||||||
|
void resetPoints()
|
||||||
|
{
|
||||||
|
newPoints_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Change point positions
|
||||||
|
void movePoints(pointField&& pts)
|
||||||
|
{
|
||||||
|
newPoints_.transfer(pts);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Change point positions
|
||||||
|
void movePoints(const tmp<pointField>& tpts)
|
||||||
|
{
|
||||||
|
newPoints_.clear();
|
||||||
|
if (tpts)
|
||||||
|
{
|
||||||
|
newPoints_ = tpts;
|
||||||
|
}
|
||||||
|
tpts.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Scale points: ignore unity and non-positive factors
|
||||||
|
void scalePoints(const scalar scaleFactor)
|
||||||
|
{
|
||||||
|
if (scaleFactor > SMALL && !equal(scaleFactor, 1))
|
||||||
|
{
|
||||||
|
if (newPoints_.empty())
|
||||||
|
{
|
||||||
|
newPoints_ = points0();
|
||||||
|
}
|
||||||
|
newPoints_ *= scaleFactor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user