mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: vtk::vtmWriter for generating vtkMultiBlockDataSet (.vtm) (issue #926)
- Provides a means of accumulating file entries for generating vtm by accumulate blocks, datasets and writing them later. Only a single block depth is currently supported and the methods are kept fairly simple.
This commit is contained in:
3
applications/test/vtmWriter/Make/files
Normal file
3
applications/test/vtmWriter/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-vtmWriter.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/Test-vtmWriter
|
||||
5
applications/test/vtmWriter/Make/options
Normal file
5
applications/test/vtmWriter/Make/options
Normal file
@ -0,0 +1,5 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfileFormats
|
||||
159
applications/test/vtmWriter/Test-vtmWriter.C
Normal file
159
applications/test/vtmWriter/Test-vtmWriter.C
Normal file
@ -0,0 +1,159 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 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/>.
|
||||
|
||||
Application
|
||||
Test-vtmWriter
|
||||
|
||||
Description
|
||||
Basic functionality tests for vtk::vtmWriter
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamVtmWriter.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
vtk::vtmWriter writer1;
|
||||
{
|
||||
fileName base = "region1_0001";
|
||||
|
||||
writer1.beginBlock("internal");
|
||||
writer1.append_vtu
|
||||
(
|
||||
base/"internal"
|
||||
);
|
||||
writer1.endBlock("internal");
|
||||
|
||||
{
|
||||
writer1.beginBlock("boundary");
|
||||
writer1.append_vtp
|
||||
(
|
||||
base/"patch0"
|
||||
);
|
||||
writer1.append(""); // bad entry
|
||||
writer1.append_vtp
|
||||
(
|
||||
base/"patch1"
|
||||
);
|
||||
writer1.append_vtp
|
||||
(
|
||||
base/"patch2"
|
||||
);
|
||||
}
|
||||
|
||||
writer1.endBlock("boundary");
|
||||
|
||||
{
|
||||
writer1.beginBlock("empty");
|
||||
writer1.endBlock("empty");
|
||||
}
|
||||
{
|
||||
writer1.beginBlock("dangling1");
|
||||
writer1.beginBlock("dangling2");
|
||||
}
|
||||
}
|
||||
|
||||
Info<< nl << "vtm information" << nl;
|
||||
writer1.dump(Info),
|
||||
Info<< nl;
|
||||
|
||||
// writer1.repair();
|
||||
//
|
||||
// Info<< nl << "vtm information - after repair" << nl;
|
||||
// writer1.dump(Info),
|
||||
// Info<< nl;
|
||||
|
||||
writer1.repair(true);
|
||||
|
||||
// Info<< nl << "vtm information - after repair(collapse)" << nl;
|
||||
// writer1.dump(Info),
|
||||
// Info<< nl;
|
||||
//
|
||||
// Info<< nl << "vtm information - after repair(collapse)" << nl;
|
||||
// writer1.dump(Info),
|
||||
// Info<< nl;
|
||||
|
||||
Info<< nl << "Write to file" << nl;
|
||||
writer1.write("vtmWriter1.vtm");
|
||||
|
||||
|
||||
vtk::vtmWriter writer2;
|
||||
{
|
||||
fileName base = "region2_0001";
|
||||
|
||||
writer2.beginBlock("internal");
|
||||
writer2.append_vtu
|
||||
(
|
||||
base/"internal"
|
||||
);
|
||||
writer2.endBlock("internal");
|
||||
|
||||
{
|
||||
writer2.beginBlock("boundary");
|
||||
writer2.append_vtp
|
||||
(
|
||||
base/"patch0"
|
||||
);
|
||||
writer2.append(""); // bad entry
|
||||
writer2.append_vtp
|
||||
(
|
||||
base/"patch1"
|
||||
);
|
||||
writer2.append_vtp
|
||||
(
|
||||
base/"patch2"
|
||||
);
|
||||
}
|
||||
|
||||
writer2.endBlock("boundary");
|
||||
|
||||
// These should be automatically skiped
|
||||
writer2.endBlock();
|
||||
writer2.endBlock();
|
||||
writer2.endBlock();
|
||||
writer2.endBlock();
|
||||
}
|
||||
|
||||
Info<< nl << "vtm information" << nl;
|
||||
writer2.dump(Info);
|
||||
|
||||
writer2.repair(true);
|
||||
|
||||
|
||||
vtk::vtmWriter writer3;
|
||||
|
||||
writer3.add("some-region1", writer1);
|
||||
writer3.add("some-region2", writer2);
|
||||
|
||||
Info<< nl << "Combined:" << nl;
|
||||
writer3.dump(Info);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user