mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: polyMeshFilter: Add topoSet manipulation. Remove zone manipulation.
This commit is contained in:
@ -32,7 +32,9 @@ License
|
||||
#include "polyTopoChange.H"
|
||||
#include "globalIndex.H"
|
||||
#include "PackedBoolList.H"
|
||||
#include "faceZone.H"
|
||||
#include "pointSet.H"
|
||||
#include "faceSet.H"
|
||||
#include "cellSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
@ -42,6 +44,26 @@ defineTypeNameAndDebug(polyMeshFilter, 0);
|
||||
}
|
||||
|
||||
|
||||
void Foam::polyMeshFilter::updateSets(const mapPolyMesh& map)
|
||||
{
|
||||
updateSets<pointSet>(map);
|
||||
updateSets<faceSet>(map);
|
||||
updateSets<cellSet>(map);
|
||||
}
|
||||
|
||||
|
||||
void Foam::polyMeshFilter::copySets
|
||||
(
|
||||
const polyMesh& oldMesh,
|
||||
const polyMesh& newMesh
|
||||
)
|
||||
{
|
||||
copySets<pointSet>(oldMesh, newMesh);
|
||||
copySets<faceSet>(oldMesh, newMesh);
|
||||
copySets<cellSet>(oldMesh, newMesh);
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::fvMesh> Foam::polyMeshFilter::copyMesh(const fvMesh& mesh)
|
||||
{
|
||||
polyTopoChange originalMeshToNewMesh(mesh);
|
||||
@ -72,6 +94,8 @@ Foam::autoPtr<Foam::fvMesh> Foam::polyMeshFilter::copyMesh(const fvMesh& mesh)
|
||||
meshCopy().movePoints(map.preMotionPoints());
|
||||
}
|
||||
|
||||
copySets(mesh, meshCopy());
|
||||
|
||||
return meshCopy;
|
||||
}
|
||||
|
||||
@ -359,6 +383,7 @@ Foam::label Foam::polyMeshFilter::filterFaces
|
||||
{
|
||||
newMesh.movePoints(newMap.preMotionPoints());
|
||||
}
|
||||
updateSets(newMap);
|
||||
|
||||
updatePointPriorities(newMesh, newMap.pointMap());
|
||||
|
||||
@ -475,6 +500,7 @@ Foam::label Foam::polyMeshFilter::filterEdges
|
||||
{
|
||||
newMesh.movePoints(newMap.preMotionPoints());
|
||||
}
|
||||
updateSets(newMap);
|
||||
|
||||
// Synchronise the factors
|
||||
mapOldMeshEdgeFieldToNewMesh
|
||||
@ -926,14 +952,14 @@ Foam::label Foam::polyMeshFilter::filter(const label nOriginalBadFaces)
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::polyMeshFilter::filter(const faceZone& fZone)
|
||||
Foam::label Foam::polyMeshFilter::filter(const faceSet& fSet)
|
||||
{
|
||||
minEdgeLen_.resize(mesh_.nEdges(), minLen());
|
||||
faceFilterFactor_.resize(mesh_.nFaces(), initialFaceLengthFactor());
|
||||
|
||||
forAll(faceFilterFactor_, fI)
|
||||
{
|
||||
if (fZone.whichFace(fI) == -1)
|
||||
if (!fSet.found(fI))
|
||||
{
|
||||
faceFilterFactor_[fI] = -1;
|
||||
}
|
||||
|
||||
@ -25,13 +25,14 @@ Class
|
||||
Foam::polyMeshFilter
|
||||
|
||||
Description
|
||||
Filter the edges and faces of a polyMesh whilst satisfying the given mesh
|
||||
Remove the edges and faces of a polyMesh whilst satisfying the given mesh
|
||||
quality criteria.
|
||||
|
||||
Works on a copy of the mesh.
|
||||
|
||||
SourceFiles
|
||||
polyMeshFilter.C
|
||||
polyMeshFilterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -53,7 +54,7 @@ namespace Foam
|
||||
class polyMesh;
|
||||
class fvMesh;
|
||||
class PackedBoolList;
|
||||
class faceZone;
|
||||
class faceSet;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class polyMeshFilter Declaration
|
||||
@ -71,8 +72,12 @@ class polyMeshFilter
|
||||
//- Copy of the original mesh to perform the filtering on
|
||||
autoPtr<fvMesh> newMeshPtr_;
|
||||
|
||||
//-
|
||||
//- Original point priorities. If a point has a higher priority than
|
||||
// another point then the edge between them collapses towards the
|
||||
// point with the higher priority. (e.g. 2 is a higher priority than 1)
|
||||
labelList originalPointPriority_;
|
||||
|
||||
//- Point priority associated with the new mesh
|
||||
autoPtr<labelList> pointPriority_;
|
||||
|
||||
//- The minimum edge length for each edge
|
||||
@ -84,6 +89,12 @@ class polyMeshFilter
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
template<typename T>
|
||||
static void updateSets(const mapPolyMesh& map);
|
||||
|
||||
template<typename T>
|
||||
static void copySets(const polyMesh& oldMesh, const polyMesh& newMesh);
|
||||
|
||||
label filterFacesLoop(const label nOriginalBadFaces);
|
||||
|
||||
label filterFaces
|
||||
@ -209,6 +220,7 @@ public:
|
||||
// mesh has actually been filtered.
|
||||
const autoPtr<fvMesh>& filteredMesh() const;
|
||||
|
||||
//- Return the new pointPriority list.
|
||||
const autoPtr<labelList>& pointPriority() const;
|
||||
|
||||
|
||||
@ -217,11 +229,21 @@ public:
|
||||
//- Return a copy of an fvMesh
|
||||
static autoPtr<fvMesh> copyMesh(const fvMesh& mesh);
|
||||
|
||||
//- Copy loaded topoSets from the old mesh to the new mesh
|
||||
static void copySets
|
||||
(
|
||||
const polyMesh& oldMesh,
|
||||
const polyMesh& newMesh
|
||||
);
|
||||
|
||||
//- Update the loaded topoSets
|
||||
static void updateSets(const mapPolyMesh& map);
|
||||
|
||||
//- Filter edges and faces
|
||||
label filter(const label nOriginalBadFaces);
|
||||
|
||||
//- Filter all faces that are in the face zone indirectPatchFaces
|
||||
label filter(const faceZone& fZone);
|
||||
//- Filter all faces that are in the face set
|
||||
label filter(const faceSet& fSet);
|
||||
|
||||
//- Filter edges only.
|
||||
label filterEdges(const label nOriginalBadFaces);
|
||||
@ -234,6 +256,12 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "polyMeshFilterTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -29,6 +29,7 @@ Description
|
||||
|
||||
SourceFiles
|
||||
polyMeshFilterSettings.C
|
||||
polyMeshFilterSettingsI.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
105
src/dynamicMesh/polyMeshFilter/polyMeshFilterTemplates.C
Normal file
105
src/dynamicMesh/polyMeshFilter/polyMeshFilterTemplates.C
Normal file
@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "polyMeshFilter.H"
|
||||
#include "polyMesh.H"
|
||||
#include "mapPolyMesh.H"
|
||||
#include "IOobjectList.H"
|
||||
|
||||
// * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<typename SetType>
|
||||
void Foam::polyMeshFilter::updateSets(const mapPolyMesh& map)
|
||||
{
|
||||
HashTable<const SetType*> sets =
|
||||
map.mesh().objectRegistry::lookupClass<const SetType>();
|
||||
|
||||
forAllIter(typename HashTable<const SetType*>, sets, iter)
|
||||
{
|
||||
SetType& set = const_cast<SetType&>(*iter());
|
||||
set.updateMesh(map);
|
||||
set.sync(map.mesh());
|
||||
}
|
||||
|
||||
IOobjectList Objects
|
||||
(
|
||||
map.mesh().time(),
|
||||
map.mesh().facesInstance(),
|
||||
"polyMesh/sets"
|
||||
);
|
||||
|
||||
IOobjectList fileSets(Objects.lookupClass(SetType::typeName));
|
||||
|
||||
forAllConstIter(IOobjectList, fileSets, iter)
|
||||
{
|
||||
if (!sets.found(iter.key()))
|
||||
{
|
||||
// Not in memory. Load it.
|
||||
SetType set(*iter());
|
||||
set.updateMesh(map);
|
||||
|
||||
set.write();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename SetType>
|
||||
void Foam::polyMeshFilter::copySets
|
||||
(
|
||||
const polyMesh& oldMesh,
|
||||
const polyMesh& newMesh
|
||||
)
|
||||
{
|
||||
HashTable<const SetType*> sets =
|
||||
oldMesh.objectRegistry::lookupClass<const SetType>();
|
||||
|
||||
forAllConstIter(typename HashTable<const SetType*>, sets, iter)
|
||||
{
|
||||
const SetType& set = *iter();
|
||||
|
||||
if (newMesh.objectRegistry::foundObject<SetType>(set.name()))
|
||||
{
|
||||
const SetType& origSet =
|
||||
newMesh.objectRegistry::lookupObject<SetType>(set.name());
|
||||
|
||||
const_cast<SetType&>(origSet) = set;
|
||||
const_cast<SetType&>(origSet).sync(newMesh);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetType* newSet
|
||||
(
|
||||
new SetType(newMesh, set.name(), set, set.writeOpt())
|
||||
);
|
||||
|
||||
newSet->store();
|
||||
newSet->sync(newMesh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user