mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: topoSet: clear sets upon writing modified mesh. Fixes #129.
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,6 +28,7 @@ License
|
||||
#include "polyMesh.H"
|
||||
#include "Time.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "mapDistributePolyMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -228,6 +229,37 @@ void cellSet::updateMesh(const mapPolyMesh& morphMap)
|
||||
}
|
||||
|
||||
|
||||
void cellSet::distribute(const mapDistributePolyMesh& map)
|
||||
{
|
||||
boolList inSet(map.nOldCells());
|
||||
forAllConstIter(cellSet, *this, iter)
|
||||
{
|
||||
inSet[iter.key()] = true;
|
||||
}
|
||||
map.distributeCellData(inSet);
|
||||
|
||||
// Count
|
||||
label n = 0;
|
||||
forAll(inSet, celli)
|
||||
{
|
||||
if (inSet[celli])
|
||||
{
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
clear();
|
||||
resize(n);
|
||||
forAll(inSet, celli)
|
||||
{
|
||||
if (inSet[celli])
|
||||
{
|
||||
insert(celli);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellSet::writeDebug
|
||||
(
|
||||
Ostream& os,
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -147,9 +147,12 @@ public:
|
||||
//- Return max index+1.
|
||||
virtual label maxSize(const polyMesh& mesh) const;
|
||||
|
||||
//- Update any stored data for new labels
|
||||
//- Update any stored data for new labels.
|
||||
virtual void updateMesh(const mapPolyMesh& morphMap);
|
||||
|
||||
//- Update any stored data for mesh redistribution.
|
||||
virtual void distribute(const mapDistributePolyMesh&);
|
||||
|
||||
//- Write maxLen items with label and coordinates.
|
||||
virtual void writeDebug
|
||||
(
|
||||
|
||||
@ -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.
|
||||
@ -27,6 +27,7 @@ License
|
||||
#include "mapPolyMesh.H"
|
||||
#include "polyMesh.H"
|
||||
#include "syncTools.H"
|
||||
#include "mapDistributePolyMesh.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
@ -161,6 +162,37 @@ void faceSet::updateMesh(const mapPolyMesh& morphMap)
|
||||
}
|
||||
|
||||
|
||||
void faceSet::distribute(const mapDistributePolyMesh& map)
|
||||
{
|
||||
boolList inSet(map.nOldFaces());
|
||||
forAllConstIter(faceSet, *this, iter)
|
||||
{
|
||||
inSet[iter.key()] = true;
|
||||
}
|
||||
map.distributeFaceData(inSet);
|
||||
|
||||
// Count
|
||||
label n = 0;
|
||||
forAll(inSet, facei)
|
||||
{
|
||||
if (inSet[facei])
|
||||
{
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
clear();
|
||||
resize(n);
|
||||
forAll(inSet, facei)
|
||||
{
|
||||
if (inSet[facei])
|
||||
{
|
||||
insert(facei);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void faceSet::writeDebug
|
||||
(
|
||||
Ostream& os,
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -116,6 +116,9 @@ public:
|
||||
//- Update any stored data for new labels
|
||||
virtual void updateMesh(const mapPolyMesh& morphMap);
|
||||
|
||||
//- Update any stored data for mesh redistribution.
|
||||
virtual void distribute(const mapDistributePolyMesh&);
|
||||
|
||||
//- Write maxLen items with label and coordinates.
|
||||
virtual void writeDebug
|
||||
(
|
||||
|
||||
@ -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.
|
||||
@ -27,6 +27,7 @@ License
|
||||
#include "mapPolyMesh.H"
|
||||
#include "polyMesh.H"
|
||||
#include "syncTools.H"
|
||||
#include "mapDistributePolyMesh.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
@ -156,6 +157,37 @@ void pointSet::updateMesh(const mapPolyMesh& morphMap)
|
||||
}
|
||||
|
||||
|
||||
void pointSet::distribute(const mapDistributePolyMesh& map)
|
||||
{
|
||||
boolList inSet(map.nOldPoints());
|
||||
forAllConstIter(pointSet, *this, iter)
|
||||
{
|
||||
inSet[iter.key()] = true;
|
||||
}
|
||||
map.distributePointData(inSet);
|
||||
|
||||
// Count
|
||||
label n = 0;
|
||||
forAll(inSet, pointi)
|
||||
{
|
||||
if (inSet[pointi])
|
||||
{
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
clear();
|
||||
resize(n);
|
||||
forAll(inSet, pointi)
|
||||
{
|
||||
if (inSet[pointi])
|
||||
{
|
||||
insert(pointi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void pointSet::writeDebug
|
||||
(
|
||||
Ostream& os,
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -119,6 +119,9 @@ public:
|
||||
//- Update any stored data for new labels
|
||||
//virtual void updateMesh(const polyTopoChange& meshMod);
|
||||
|
||||
//- Update any stored data for mesh redistribution.
|
||||
virtual void distribute(const mapDistributePolyMesh&);
|
||||
|
||||
//- Write maxLen items with label and coordinates.
|
||||
virtual void writeDebug
|
||||
(
|
||||
|
||||
@ -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.
|
||||
@ -550,6 +550,26 @@ void Foam::topoSet::updateMesh(const mapPolyMesh&)
|
||||
}
|
||||
|
||||
|
||||
void Foam::topoSet::removeFiles(const polyMesh& mesh)
|
||||
{
|
||||
IOobject io
|
||||
(
|
||||
"dummy",
|
||||
mesh.facesInstance(),
|
||||
mesh.meshSubDir/"sets",
|
||||
mesh
|
||||
);
|
||||
fileName setsDir(io.path());
|
||||
|
||||
if (debug) DebugVar(setsDir);
|
||||
|
||||
if (isDir(setsDir))
|
||||
{
|
||||
rmDir(setsDir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::topoSet::operator=(const topoSet& rhs)
|
||||
|
||||
@ -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.
|
||||
@ -32,6 +32,7 @@ Description
|
||||
|
||||
SourceFiles
|
||||
topoSet.C
|
||||
topoSetTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -54,6 +55,7 @@ namespace Foam
|
||||
class mapPolyMesh;
|
||||
class polyMesh;
|
||||
class primitiveMesh;
|
||||
class mapDistributePolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class topoSet Declaration
|
||||
@ -297,9 +299,28 @@ public:
|
||||
//- Update any stored data for new labels. Not implemented.
|
||||
virtual void updateMesh(const mapPolyMesh& morphMap);
|
||||
|
||||
//- Update any stored data for mesh redistribution.
|
||||
virtual void distribute(const mapDistributePolyMesh&) = 0;
|
||||
|
||||
//- Return max allowable index (+1). Not implemented.
|
||||
virtual label maxSize(const polyMesh& mesh) const = 0;
|
||||
|
||||
//- Helper: call updateMesh on all sets in container (and
|
||||
// updates instance)
|
||||
template<class Container>
|
||||
static void updateMesh
|
||||
(
|
||||
const fileName& instance,
|
||||
const mapPolyMesh&,
|
||||
Container&
|
||||
);
|
||||
|
||||
//- Helper: set instance on all sets in container
|
||||
template<class Container>
|
||||
static void setInstance(const fileName& instance, Container&);
|
||||
|
||||
//- Helper: remove all sets files from mesh instance
|
||||
static void removeFiles(const polyMesh&);
|
||||
|
||||
|
||||
// Member operators
|
||||
@ -316,6 +337,12 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "topoSetTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
59
src/meshTools/sets/topoSets/topoSetTemplates.C
Normal file
59
src/meshTools/sets/topoSets/topoSetTemplates.C
Normal file
@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Container>
|
||||
void Foam::topoSet::setInstance
|
||||
(
|
||||
const fileName& instance,
|
||||
Container& lst
|
||||
)
|
||||
{
|
||||
forAll(lst, i)
|
||||
{
|
||||
lst[i].instance() = instance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Container>
|
||||
void Foam::topoSet::updateMesh
|
||||
(
|
||||
const fileName& instance,
|
||||
const mapPolyMesh& map,
|
||||
Container& lst
|
||||
)
|
||||
{
|
||||
forAll(lst, i)
|
||||
{
|
||||
lst[i].instance() = instance;
|
||||
lst[i].updateMesh(map);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user