diff --git a/applications/test/rawIOField/Make/files b/applications/test/rawIOField/Make/files new file mode 100644 index 0000000000..a37b434282 --- /dev/null +++ b/applications/test/rawIOField/Make/files @@ -0,0 +1,3 @@ +Test-rawIOField.C + +EXE = $(FOAM_USER_APPBIN)/Test-rawIOField diff --git a/applications/test/rawIOField/Make/options b/applications/test/rawIOField/Make/options new file mode 100644 index 0000000000..b6fa4bff16 --- /dev/null +++ b/applications/test/rawIOField/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/fileFormats/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lfileFormats \ + -lsurfMesh \ + -lmeshTools diff --git a/applications/test/rawIOField/Test-rawIOField.C b/applications/test/rawIOField/Test-rawIOField.C new file mode 100644 index 0000000000..43bd4979ce --- /dev/null +++ b/applications/test/rawIOField/Test-rawIOField.C @@ -0,0 +1,168 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 . + +Application + Test-rawIOField + +Description + Reading rawIOField from disk + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "Switch.H" +#include "primitiveFields.H" +#include "pointField.H" +#include "rawIOField.H" +#include "exprTraits.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +using namespace Foam; + +#undef USE_ROOT_CASE +//#define USE_ROOT_CASE + + +template +tmp> readRawField +( + const IOobject& io, + IOobjectOption::readOption withAverage +) +{ + rawIOField raw(io, withAverage); + + Info<< "File: " << io.objectPath() << nl + << "Read: " << raw.size() + << ' ' << pTraits::typeName << " entries" << nl + << "Average: " << Switch::name(raw.hasAverage()) + << " = " << raw.average() << endl; + + return tmp>::New(std::move(static_cast&>(raw))); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addNote + ( + "Test behaviour of rawIOField reading (writing?)" + ); + + argList::noCheckProcessorDirectories(); + + argList::addBoolOption("scalar", "Read scalar field"); + argList::addBoolOption("vector", "Read vector field"); + argList::addBoolOption("point", "Read point field"); + argList::addBoolOption("average", "Require averaged value entry"); + argList::addBoolOption("try-average", "Optional averaged value entry"); + + argList::addArgument("fileName"); + + #ifdef USE_ROOT_CASE + #include "setRootCase.H" + #include "createTime.H" + #else + // Without root case, or time + argList args(argc, argv); + #endif + + fileName inputName = args.get(1); + + IOobjectOption::readOption withAverage = IOobjectOption::NO_READ; + + if (args.found("average")) + { + withAverage = IOobjectOption::MUST_READ; + } + else if (args.found("try-average")) + { + withAverage = IOobjectOption::READ_IF_PRESENT; + } + + Info<< "Using case: " << argList::envGlobalPath() << nl + << "Read file: " << inputName << nl + << "with average: " << int(withAverage) << nl + << endl; + + + refPtr