mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: vtk::seriesWriter to encapsulate writing file series (issue #926)
This commit is contained in:
3
applications/test/vtkSeriesWriter/Make/files
Normal file
3
applications/test/vtkSeriesWriter/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-vtkSeriesWriter.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/Test-vtkSeriesWriter
|
||||
5
applications/test/vtkSeriesWriter/Make/options
Normal file
5
applications/test/vtkSeriesWriter/Make/options
Normal file
@ -0,0 +1,5 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/fileFormats/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfileFormats
|
||||
118
applications/test/vtkSeriesWriter/Test-vtkSeriesWriter.C
Normal file
118
applications/test/vtkSeriesWriter/Test-vtkSeriesWriter.C
Normal file
@ -0,0 +1,118 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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-vtkSeriesWriter
|
||||
|
||||
Description
|
||||
Basic functionality tests for vtk::seriesWriter
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamVtkSeriesWriter.H"
|
||||
#include "argList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addBoolOption("sort", "Sort value / name");
|
||||
argList::addBoolOption("check", "Check for existence of files");
|
||||
argList::addOption("time", "value", "Filter based on given time");
|
||||
argList::addOption("scan", "series", "Scan directory to create series");
|
||||
|
||||
argList args(argc, argv, false, true);
|
||||
|
||||
const scalar currTime = args.lookupOrDefault<scalar>("time", GREAT);
|
||||
|
||||
Info<< "Using currTime = " << currTime << nl
|
||||
<< "when loading " << (args.size()-1) << " files" << nl << nl;
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
const auto& input = args[argi];
|
||||
|
||||
Info << "load from " << input << nl;
|
||||
|
||||
vtk::seriesWriter writer;
|
||||
writer.load(input);
|
||||
|
||||
writer.print(Info);
|
||||
Info<< nl << nl;
|
||||
|
||||
if (writer.removeNewer(currTime))
|
||||
{
|
||||
Info<< "removed entries with time >= " << currTime << nl;
|
||||
writer.print(Info);
|
||||
Info<< nl << nl;
|
||||
}
|
||||
|
||||
if (args.found("sort"))
|
||||
{
|
||||
writer.sort();
|
||||
|
||||
Info<< "sorted" << nl;
|
||||
writer.print(Info);
|
||||
Info<< nl << nl;
|
||||
}
|
||||
|
||||
if (args.found("check"))
|
||||
{
|
||||
writer.load(input, true);
|
||||
|
||||
Info<< "reload, checking the existance of files" << nl;
|
||||
writer.print(Info);
|
||||
Info<< nl << nl;
|
||||
}
|
||||
|
||||
if (writer.empty())
|
||||
{
|
||||
Info<< "No entries" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< writer.size() << " entries" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.found("scan"))
|
||||
{
|
||||
vtk::seriesWriter writer;
|
||||
|
||||
writer.scan(args.opt<fileName>("scan"));
|
||||
|
||||
Info<< "scanned for files" << nl;
|
||||
writer.print(Info);
|
||||
Info<< nl << nl;
|
||||
}
|
||||
|
||||
|
||||
Info<< "\nEnd\n" << nl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
4
applications/test/vtkSeriesWriter/file.vtm
Normal file
4
applications/test/vtkSeriesWriter/file.vtm
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version='1.0'?>
|
||||
<!-- case='abc' time='0' index='0' -->
|
||||
<VTKFile type='vtkMultiBlockDataSet' version='1.0' byte_order='LittleEndian' header_type='UInt64'>
|
||||
<vtkMultiBlockDataSet>
|
||||
4
applications/test/vtkSeriesWriter/file_00000679.vtm
Normal file
4
applications/test/vtkSeriesWriter/file_00000679.vtm
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version='1.0'?>
|
||||
<!-- case='abc' time='0.00125' index='679' -->
|
||||
<VTKFile type='vtkMultiBlockDataSet' version='1.0' byte_order='LittleEndian' header_type='UInt64'>
|
||||
<vtkMultiBlockDataSet>
|
||||
4
applications/test/vtkSeriesWriter/file_00001025.vtm
Normal file
4
applications/test/vtkSeriesWriter/file_00001025.vtm
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version='1.0'?>
|
||||
<!-- case='abc' time="0.5250" index='1025' -->
|
||||
<VTKFile type='vtkMultiBlockDataSet' version='1.0' byte_order='LittleEndian' header_type='UInt64'>
|
||||
<vtkMultiBlockDataSet>
|
||||
4
applications/test/vtkSeriesWriter/file_00001234.vtm
Normal file
4
applications/test/vtkSeriesWriter/file_00001234.vtm
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version='1.0'?>
|
||||
<!-- note="no time entry" -->
|
||||
<VTKFile type='vtkMultiBlockDataSet' version='1.0' byte_order='LittleEndian' header_type='UInt64'>
|
||||
<vtkMultiBlockDataSet>
|
||||
4
applications/test/vtkSeriesWriter/file_00005680.vtm
Normal file
4
applications/test/vtkSeriesWriter/file_00005680.vtm
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version='1.0'?>
|
||||
<!-- case='abc' time= index='1234' note="degenerate time entry" -->
|
||||
<VTKFile type='vtkMultiBlockDataSet' version='1.0' byte_order='LittleEndian' header_type='UInt64'>
|
||||
<vtkMultiBlockDataSet>
|
||||
4
applications/test/vtkSeriesWriter/file_23.vtm
Normal file
4
applications/test/vtkSeriesWriter/file_23.vtm
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version='1.0'?>
|
||||
<!-- case='abc' time=0.0145 index='1234' note="unquoted time entry" -->
|
||||
<VTKFile type='vtkMultiBlockDataSet' version='1.0' byte_order='LittleEndian' header_type='UInt64'>
|
||||
<vtkMultiBlockDataSet>
|
||||
20
applications/test/vtkSeriesWriter/test1.vtm.series
Normal file
20
applications/test/vtkSeriesWriter/test1.vtm.series
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"file-series-version" : "1.0",
|
||||
"files": [
|
||||
{ "name" : "file_00001742.vtm", "time" : 50 },
|
||||
{ "name" : "file_00001025.vtm", "time" : 30 },
|
||||
{
|
||||
"time" : 40,
|
||||
"name" : "file_00001380.vtm", ,,,,
|
||||
},
|
||||
{ "name" : "file_00000679.vtm", "time" : 20 },
|
||||
{ "name" : "file_00002110.vtm", "time" : 60 },
|
||||
{ "name" : "file_00001234.vtm", "time" : 60 },
|
||||
{ "name" : "file_00001742.vtm", "time" : 150 },
|
||||
{ "name" : "file_00001742.vtm", "time" : 5 },
|
||||
|
||||
{ "name" : "file_1000.vtm", "badTime" : 60 },
|
||||
{ "" : "", "" : 60, "" : false },
|
||||
{ "name" : "", "time" : 10 },
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user