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:
parent
264c09c365
commit
cc47a37ed1
@ -629,12 +629,10 @@ void Foam::PDRobstacle::generateVtk
|
||||
{
|
||||
label pieceId = 0;
|
||||
|
||||
meshedSurf::emptySurface dummy;
|
||||
|
||||
vtk::surfaceWriter surfWriter
|
||||
(
|
||||
dummy.points(),
|
||||
dummy.faces(),
|
||||
pointField::null(),
|
||||
faceList::null(),
|
||||
// vtk::formatType::INLINE_ASCII,
|
||||
(outputDir / "Obstacles"),
|
||||
false // serial only
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -147,41 +147,21 @@ bool Foam::blockMesh::readPointTransforms(const dictionary& dict)
|
||||
{
|
||||
transformType_ = transformTypes::NO_TRANSFORM;
|
||||
|
||||
const dictionary* dictptr;
|
||||
|
||||
// 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);
|
||||
|
||||
constexpr scalar tol = VSMALL;
|
||||
|
||||
// Check for non-zero origin
|
||||
const vector& o = transform_.origin();
|
||||
if
|
||||
(
|
||||
(mag(o.x()) > tol)
|
||||
|| (mag(o.y()) > tol)
|
||||
|| (mag(o.z()) > tol)
|
||||
)
|
||||
// Non-zero origin?
|
||||
if (magSqr(transform_.origin()) > ROOTVSMALL)
|
||||
{
|
||||
transformType_ |= transformTypes::TRANSLATION;
|
||||
}
|
||||
|
||||
// Check for non-identity rotation
|
||||
const tensor& r = transform_.R();
|
||||
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)
|
||||
)
|
||||
// Non-identity rotation?
|
||||
if (!transform_.R().is_identity(ROOTVSMALL))
|
||||
{
|
||||
transformType_ |= transformTypes::ROTATION;
|
||||
}
|
||||
|
@ -105,21 +105,6 @@ static bool isCollocatedPatch(const coupledPolyPatch& pp)
|
||||
|
||||
// * * * * * * * * * * * * * 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
|
||||
(
|
||||
const coupledPolyPatch& pp
|
||||
|
@ -124,9 +124,6 @@ class isoSurfacePoint
|
||||
|
||||
// Point synchronisation
|
||||
|
||||
//- Does tensor differ (to within mergeTolerance) from identity
|
||||
bool noTransform(const tensor& tt) const;
|
||||
|
||||
//- Per face whether is collocated
|
||||
static bitSet collocatedFaces(const coupledPolyPatch& cpp);
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,8 +31,8 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef meshedSurf_H
|
||||
#define meshedSurf_H
|
||||
#ifndef Foam_meshedSurf_H
|
||||
#define Foam_meshedSurf_H
|
||||
|
||||
#include "pointField.H"
|
||||
#include "faceList.H"
|
||||
@ -51,7 +51,7 @@ class meshedSurf
|
||||
{
|
||||
public:
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class emptySurface;
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,14 +27,19 @@ Class
|
||||
Foam::meshedSurfRef
|
||||
|
||||
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
|
||||
#define meshedSurfRef_H
|
||||
#ifndef Foam_meshedSurfRef_H
|
||||
#define Foam_meshedSurfRef_H
|
||||
|
||||
#include "meshedSurf.H"
|
||||
#include "refPtr.H"
|
||||
#include <functional>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -50,10 +55,19 @@ class meshedSurfRef
|
||||
:
|
||||
public meshedSurf
|
||||
{
|
||||
std::reference_wrapper<const pointField> points_;
|
||||
std::reference_wrapper<const faceList> faces_;
|
||||
std::reference_wrapper<const labelList> zoneIds_;
|
||||
std::reference_wrapper<const labelList> faceIds_;
|
||||
// Private Data
|
||||
|
||||
//- An external surface reference
|
||||
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:
|
||||
@ -69,20 +83,27 @@ public:
|
||||
faceIds_(std::cref<labelList>(labelList::null()))
|
||||
{}
|
||||
|
||||
//- Construct as reference to a meshedSurf
|
||||
explicit meshedSurfRef(const meshedSurf& s)
|
||||
:
|
||||
meshedSurfRef()
|
||||
{
|
||||
surf_.cref(s);
|
||||
}
|
||||
|
||||
//- Construct from components
|
||||
meshedSurfRef
|
||||
(
|
||||
const pointField& pointLst,
|
||||
const faceList& faceLst,
|
||||
const labelList& zoneIdLst = labelList::null(),
|
||||
const labelList& faceIdLst = labelList::null()
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const labelList& zoneIds = labelList::null(),
|
||||
const labelList& faceIds = labelList::null()
|
||||
)
|
||||
:
|
||||
points_(std::cref<pointField>(pointLst)),
|
||||
faces_(std::cref<faceList>(faceLst)),
|
||||
zoneIds_(std::cref<labelList>(zoneIdLst)),
|
||||
faceIds_(std::cref<labelList>(faceIdLst))
|
||||
points_(std::cref<pointField>(points)),
|
||||
faces_(std::cref<faceList>(faces)),
|
||||
zoneIds_(std::cref<labelList>(zoneIds)),
|
||||
faceIds_(std::cref<labelList>(faceIds))
|
||||
{}
|
||||
|
||||
|
||||
@ -92,52 +113,112 @@ public:
|
||||
|
||||
// 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
|
||||
virtual const pointField& points() const
|
||||
{
|
||||
return points_.get();
|
||||
return (newPoints_.empty() ? points0() : newPoints_);
|
||||
}
|
||||
|
||||
//- The faces used for the surface
|
||||
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
|
||||
{
|
||||
return zoneIds_.get();
|
||||
return (surf_ ? surf_.cref().zoneIds() : zoneIds_.get());
|
||||
}
|
||||
|
||||
//- Per-face identifier (eg, element Id)
|
||||
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()
|
||||
{
|
||||
surf_.reset();
|
||||
points_ = std::cref<pointField>(pointField::null());
|
||||
faces_ = std::cref<faceList>(faceList::null());
|
||||
zoneIds_ = 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
|
||||
void reset
|
||||
(
|
||||
const pointField& pointLst,
|
||||
const faceList& faceLst,
|
||||
const labelList& zoneIdLst = labelList::null(),
|
||||
const labelList& faceIdLst = labelList::null()
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const labelList& zoneIds = labelList::null(),
|
||||
const labelList& faceIds = labelList::null()
|
||||
)
|
||||
{
|
||||
points_ = std::cref<pointField>(pointLst);
|
||||
faces_ = std::cref<faceList>(faceLst);
|
||||
zoneIds_ = std::cref<labelList>(zoneIdLst);
|
||||
faceIds_ = std::cref<labelList>(faceIdLst);
|
||||
surf_.reset();
|
||||
points_ = std::cref<pointField>(points);
|
||||
faces_ = std::cref<faceList>(faces);
|
||||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user