ENH: store sorted mesh pointers for vtkWrite, areaWrite

- replaces HashTable of pointers
This commit is contained in:
Mark Olesen
2023-07-18 16:23:00 +02:00
parent 945e3e41b1
commit 4dfafc3c36
5 changed files with 24 additions and 28 deletions

View File

@ -289,8 +289,9 @@ bool Foam::functionObjects::vtkWrite::write()
Info<< name() << " output Time: " << time_.timeName() << nl;
label regioni = 0;
for (const word& regionName : meshes_.sortedToc())
for (const fvMesh& mesh : meshes_)
{
const word& regionName = mesh.name();
const word& regionDir = polyMesh::regionName(regionName);
auto& meshProxy = meshSubsets_[regioni];

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2022 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -213,8 +213,8 @@ class vtkWrite
//- Dictionary of volume selections
dictionary selection_;
//- Pointers to the requested mesh regions
HashTable<const fvMesh*> meshes_;
//- Pointers to the requested mesh regions (sorted)
UPtrList<const fvMesh> meshes_;
//- Subsetting for meshes.
// Access index according to sorted mesh names.

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -98,10 +98,8 @@ bool Foam::functionObjects::vtkWrite::update()
vtuMappings_.resize(meshes_.size());
label regioni = 0;
for (const word& regionName : meshes_.sortedToc())
for (const fvMesh& mesh : meshes_)
{
const fvMesh& mesh = *(meshes_[regionName]);
if (meshSubsets_.set(regioni))
{
meshSubsets_[regioni].clear();
@ -149,29 +147,27 @@ bool Foam::functionObjects::vtkWrite::readSelection(const dictionary& dict)
{
meshSubsets_.clear();
vtuMappings_.clear();
meshes_.clear();
meshState_ = polyMesh::TOPO_CHANGE;
// All possible meshes
meshes_ = time_.lookupClass<fvMesh>();
selectRegions_.clear();
dict.readIfPresent("regions", selectRegions_);
if (selectRegions_.empty())
{
selectRegions_.resize(1);
selectRegions_.first() =
selectRegions_.front() =
dict.getOrDefault<word>("region", polyMesh::defaultRegion);
}
// Restrict to specified meshes
meshes_.filterKeys(selectRegions_);
meshes_ = time_.csorted<fvMesh>(selectRegions_);
if (meshes_.empty())
{
WarningInFunction
<< "No mesh regions selected for function object " << name()
<< nl;
<< "No mesh regions selected for function object "
<< name() << nl;
}
selectPatches_.clear();