ENH: cleanup/reorganize surfaceWriter and fileFormats

- remove unused surfaceWriter constructors, noexcept on methods

- relocate/rename writerCaching from surfMesh -> fileFormats

- changed from surfaceWriters::writerCaching to
  ensightOutput::writerCaching to permit reuse elsewhere

- relocate static output helpers to ensightCase

- refactor NAS coordinate writing
This commit is contained in:
Mark Olesen
2022-01-26 13:34:01 +01:00
parent 731e276e21
commit 295822daa6
56 changed files with 613 additions and 608 deletions

View File

@ -191,11 +191,11 @@ int main(int argc, char *argv[])
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 1);
// Default to binary output, unless otherwise specified
const IOstream::streamFormat format =
const IOstreamOption::streamFormat format =
(
args.found("ascii")
? IOstream::ASCII
: IOstream::BINARY
? IOstreamOption::ASCII
: IOstreamOption::BINARY
);
// Increase the precision of the points data

View File

@ -90,11 +90,11 @@ int main(int argc, char *argv[])
// Binary output, unless otherwise specified
const IOstream::streamFormat format =
const IOstreamOption::streamFormat format =
(
args.found("ascii")
? IOstream::ASCII
: IOstream::BINARY
? IOstreamOption::ASCII
: IOstreamOption::BINARY
);
// increase the precision of the points data

View File

@ -96,11 +96,11 @@ int main(int argc, char *argv[])
Time runTime(args.rootPath(), args.caseName());
// Binary output, unless otherwise specified
const IOstream::streamFormat format =
const IOstreamOption::streamFormat format =
(
args.found("ascii")
? IOstream::ASCII
: IOstream::BINARY
? IOstreamOption::ASCII
: IOstreamOption::BINARY
);
// Increase the precision of the points data

View File

@ -308,11 +308,11 @@ int main(int argc, char *argv[])
// Configuration
// Default to binary output, unless otherwise specified
const IOstream::streamFormat format =
const IOstreamOption::streamFormat format =
(
args.found("ascii")
? IOstream::ASCII
: IOstream::BINARY
? IOstreamOption::ASCII
: IOstreamOption::BINARY
);
const bool doBoundary = !args.found("no-boundary");

View File

@ -6,6 +6,7 @@ ensight/file/ensightCase.C
ensight/file/ensightCaseOptions.C
ensight/file/ensightFile.C
ensight/file/ensightGeoFile.C
ensight/file/ensightWriterCaching.C
ensight/mesh/ensightMesh.C
ensight/mesh/ensightMeshOptions.C

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,6 +30,7 @@ License
#include "Time.H"
#include "cloud.H"
#include "IOmanip.H"
#include "OSstream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -37,6 +38,126 @@ const char* Foam::ensightCase::dataDirName = "data";
const char* Foam::ensightCase::geometryName = "geometry";
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
void Foam::ensightCase::printTimeset
(
OSstream& os,
const label ts,
const scalar timeValue
)
{
os
<< "time set: " << ts << nl
<< "number of steps: " << 1 << nl;
// Single value - starts at index 0
os << "filename start number: 0" << nl
<< "filename increment: 1" << nl
<< "time values:" << nl;
os << " " << timeValue
<< nl << nl;
}
void Foam::ensightCase::printTimeset
(
OSstream& os,
const label ts,
const UList<scalar>& values
)
{
label pos_(0);
os
<< "time set: " << ts << nl
<< "number of steps: " << values.size() << nl;
// Assume contiguous numbering - starts at index 0
os << "filename start number: 0" << nl
<< "filename increment: 1" << nl;
os << "time values:" << nl;
pos_ = 0;
for (const scalar val : values)
{
if (pos_ == 6)
{
os << nl;
pos_ = 0;
}
++pos_;
os << ' ' << setf(ios_base::right) << setw(12) << val;
}
os << nl << nl;
}
void Foam::ensightCase::printTimeset
(
OSstream& os,
const label ts,
const UList<scalar>& values,
const bitSet& indices
)
{
label pos_(0);
// Check if continuous numbering can be used
if
(
values.empty()
|| (indices.size() == values.size() && indices.all())
)
{
// Can simply emit as 0-based with increment
printTimeset(os, ts, values);
return;
}
// Generate time set
os
<< "time set: " << ts << nl
<< "number of steps: " << indices.count() << nl;
os << "filename numbers:" << nl;
pos_ = 0;
for (const label idx : indices)
{
if (pos_ == 6)
{
os << nl;
pos_ = 0;
}
++pos_;
os << ' ' << setf(ios_base::right) << setw(8) << idx;
}
os << nl;
os << "time values:" << nl;
pos_ = 0;
for (const label idx : indices)
{
if (pos_ == 6)
{
os << nl;
pos_ = 0;
}
++pos_;
os << ' ' << setf(ios_base::right) << setw(12) << values[idx];
}
os << nl << nl;
}
// * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * //
Foam::fileName Foam::ensightCase::dataDir() const
@ -73,7 +194,7 @@ void Foam::ensightCase::initialize()
mkDir(dataDir());
// The case file is always ASCII
os_.reset(new OFstream(ensightDir_/caseName_, IOstream::ASCII));
os_.reset(new OFstream(ensightDir_/caseName_, IOstreamOption::ASCII));
// Format options
os_->setf(ios_base::left);
@ -405,7 +526,7 @@ Foam::ensightCase::ensightCase
(
const fileName& ensightDir,
const word& caseName,
const IOstream::streamFormat format
const IOstreamOption::streamFormat format
)
:
options_(new options(format)),

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,15 +38,14 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef ensightCase_H
#define ensightCase_H
#ifndef Foam_ensightCase_H
#define Foam_ensightCase_H
#include "autoPtr.H"
#include "HashSet.H"
#include "InfoProxy.H"
#include "Map.H"
#include "HashSet.H"
#include "OSspecific.H"
#include "Pstream.H"
#include "ensightGeoFile.H"
#include <memory>
@ -57,8 +56,10 @@ namespace Foam
{
// Forward Declarations
class bitSet;
class ensightCase;
class instant;
class OSstream;
class Time;
/*---------------------------------------------------------------------------*\
@ -217,7 +218,7 @@ public:
(
const fileName& ensightDir,
const word& caseName,
const IOstream::streamFormat format = IOstream::BINARY
const IOstreamOption::streamFormat format = IOstreamOption::BINARY
);
@ -233,10 +234,10 @@ public:
inline const ensightCase::options& option() const;
//- The output file format (ascii/binary)
inline IOstream::streamFormat format() const;
inline IOstreamOption::streamFormat format() const;
//- The nominal path to the case file
inline const fileName& path() const;
inline const fileName& path() const noexcept;
//- The output '*' mask
inline const word& mask() const;
@ -322,16 +323,67 @@ public:
//- Print some general information.
Ostream& printInfo(Ostream& os) const;
// Output Helpers
//- Print time-set for ensight case file with a single time
static void printTimeset
(
OSstream& os,
const label ts,
const scalar timeValue
);
//- Print time-set for ensight case file, with N times and 0-based
//- file numbering
//
// \verbatim
// TIME
// time set: ts
// number of steps: ns
// filename start number: 0
// filename increment: 1
// time values: time_1 time_2 ... time_ns
// \endverbatim
static void printTimeset
(
OSstream& os,
const label ts,
const UList<scalar>& times
);
//- Print time-set for ensight case file, with N times, 0-based
//- file numbering but perhaps non-contiguous
//
// \verbatim
// TIME
// time set: ts
// number of steps: ns
// filename numbers: idx_1 idx_2 ... idx_ns
// time values: time_1 time_2 ... time_ns
// \endverbatim
static void printTimeset
(
OSstream& os,
const label ts,
const UList<scalar>& times,
const bitSet& indices
);
};
/*---------------------------------------------------------------------------*\
Class ensightCase::options Declaration
\*---------------------------------------------------------------------------*/
//- Configuration options for the ensightCase
class ensightCase::options
{
// Private Data
//- Ascii/Binary file output
IOstream::streamFormat format_;
IOstreamOption::streamFormat format_;
//- Remove existing directory and sub-directories on creation
bool overwrite_;
@ -357,7 +409,7 @@ public:
// Constructors
//- Construct with the specified format (default is binary)
options(IOstream::streamFormat format = IOstream::BINARY);
options(IOstreamOption::streamFormat format = IOstreamOption::BINARY);
// Member Functions
@ -365,22 +417,22 @@ public:
// Access
//- Ascii/Binary file output
IOstream::streamFormat format() const;
IOstreamOption::streamFormat format() const noexcept { return format_; }
//- The '*' mask appropriate for sub-directories
const word& mask() const;
const word& mask() const noexcept { return mask_; }
//- Consistent zero-padded integer value
word padded(const label i) const;
//- Return current width of mask and padded.
label width() const;
label width() const noexcept { return width_; }
//- Remove existing directory and sub-directories on creation
bool overwrite() const;
bool overwrite() const noexcept { return overwrite_; }
//- Write clouds into their own directory instead in "data" directory
bool separateCloud() const;
bool separateCloud() const noexcept { return separateCloud_; }
// Edit
@ -390,22 +442,22 @@ public:
void width(const label i);
//- Remove existing directory and sub-directories on creation
void overwrite(bool);
void overwrite(bool on) noexcept { overwrite_ = on; }
//- Write clouds into their own directory instead in "data" directory
void separateCloud(bool);
void separateCloud(bool on) noexcept { separateCloud_ = on; }
// Housekeeping
//- Force use of values per node instead of per element
bool nodeValues() const;
//- Forced use of values per node instead of per element
bool nodeValues() const noexcept { return nodeValues_; }
//- Force use of values per node instead of per element
// Deprecated(2020-02) - The newData() method with a second parameter
// is more flexible.
// \deprecated(2020-02) - newData() with second parameter
void nodeValues(bool);
void nodeValues(bool on) noexcept { nodeValues_ = on; }
};

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,13 +33,13 @@ inline const Foam::ensightCase::options& Foam::ensightCase::option() const
}
inline Foam::IOstream::streamFormat Foam::ensightCase::format() const
inline Foam::IOstreamOption::streamFormat Foam::ensightCase::format() const
{
return options_->format();
}
inline const Foam::fileName& Foam::ensightCase::path() const
inline const Foam::fileName& Foam::ensightCase::path() const noexcept
{
return ensightDir_;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,7 +29,7 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightCase::options::options(IOstream::streamFormat format)
Foam::ensightCase::options::options(IOstreamOption::streamFormat format)
:
format_(format),
overwrite_(false),
@ -45,18 +45,6 @@ Foam::ensightCase::options::options(IOstream::streamFormat format)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::IOstream::streamFormat Foam::ensightCase::options::format() const
{
return format_;
}
const Foam::word& Foam::ensightCase::options::mask() const
{
return mask_;
}
Foam::word Foam::ensightCase::options::padded(const label i) const
{
// As per word::printf(), but with fixed length
@ -70,12 +58,6 @@ Foam::word Foam::ensightCase::options::padded(const label i) const
}
Foam::label Foam::ensightCase::options::width() const
{
return width_;
}
void Foam::ensightCase::options::width(const label n)
{
// Enforce min/max sanity limits
@ -92,40 +74,4 @@ void Foam::ensightCase::options::width(const label n)
}
bool Foam::ensightCase::options::overwrite() const
{
return overwrite_;
}
void Foam::ensightCase::options::overwrite(bool b)
{
overwrite_ = b;
}
bool Foam::ensightCase::options::nodeValues() const
{
return nodeValues_;
}
void Foam::ensightCase::options::nodeValues(bool b)
{
nodeValues_ = b;
}
bool Foam::ensightCase::options::separateCloud() const
{
return separateCloud_;
}
void Foam::ensightCase::options::separateCloud(bool b)
{
separateCloud_ = b;
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -119,7 +119,7 @@ void Foam::ensightFile::initialize()
Foam::ensightFile::ensightFile
(
const fileName& pathname,
IOstream::streamFormat format
IOstreamOption::streamFormat format
)
:
OFstream(ensight::FileName(pathname), format)
@ -132,7 +132,7 @@ Foam::ensightFile::ensightFile
(
const fileName& path,
const fileName& name,
IOstream::streamFormat format
IOstreamOption::streamFormat format
)
:
OFstream(path/ensight::FileName(name), format)
@ -176,7 +176,7 @@ Foam::Ostream& Foam::ensightFile::writeString(const char* str)
char buf[80+1];
strncpy(buf, str, 80); // max 80 chars or padded with nul if smaller
if (format() == IOstream::BINARY)
if (format() == IOstreamOption::BINARY)
{
write(buf, 80);
}
@ -227,7 +227,7 @@ Foam::Ostream& Foam::ensightFile::write
Foam::Ostream& Foam::ensightFile::write(const int32_t val)
{
if (format() == IOstream::BINARY)
if (format() == IOstreamOption::BINARY)
{
write
(
@ -255,7 +255,7 @@ Foam::Ostream& Foam::ensightFile::write(const int64_t val)
Foam::Ostream& Foam::ensightFile::write(const floatScalar val)
{
if (format() == IOstream::BINARY)
if (format() == IOstreamOption::BINARY)
{
write
(
@ -287,7 +287,7 @@ Foam::Ostream& Foam::ensightFile::write
const label fieldWidth
)
{
if (format() == IOstream::BINARY)
if (format() == IOstreamOption::BINARY)
{
write(value);
}
@ -303,7 +303,7 @@ Foam::Ostream& Foam::ensightFile::write
void Foam::ensightFile::newline()
{
if (format() == IOstream::ASCII)
if (format() == IOstreamOption::ASCII)
{
stdStream() << nl;
}
@ -338,7 +338,7 @@ Foam::Ostream& Foam::ensightFile::writeKeyword(const keyType& key)
Foam::Ostream& Foam::ensightFile::writeBinaryHeader()
{
if (format() == IOstream::BINARY)
if (format() == IOstreamOption::BINARY)
{
writeString("C Binary");
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,8 +33,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef ensightFile_H
#define ensightFile_H
#ifndef Foam_ensightFile_H
#define Foam_ensightFile_H
#include "OFstream.H"
#include "ensightFileName.H"
@ -105,7 +105,7 @@ public:
explicit ensightFile
(
const fileName& pathname,
IOstream::streamFormat format=IOstream::BINARY
IOstreamOption::streamFormat format = IOstreamOption::BINARY
);
//- Construct from path and name.
@ -114,7 +114,7 @@ public:
(
const fileName& path,
const fileName& name,
IOstream::streamFormat format=IOstream::BINARY
IOstreamOption::streamFormat format = IOstreamOption::BINARY
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -56,7 +56,7 @@ void Foam::ensightGeoFile::initialize()
Foam::ensightGeoFile::ensightGeoFile
(
const fileName& pathname,
IOstream::streamFormat format
IOstreamOption::streamFormat format
)
:
ensightFile(pathname, format)
@ -69,7 +69,7 @@ Foam::ensightGeoFile::ensightGeoFile
(
const fileName& path,
const fileName& name,
IOstream::streamFormat format
IOstreamOption::streamFormat format
)
:
ensightFile(path, name, format)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,8 +32,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef ensightGeoFile_H
#define ensightGeoFile_H
#ifndef Foam_ensightGeoFile_H
#define Foam_ensightGeoFile_H
#include "ensightFile.H"
@ -80,7 +80,7 @@ public:
explicit ensightGeoFile
(
const fileName& pathname,
IOstream::streamFormat format=IOstream::BINARY
IOstreamOption::streamFormat format = IOstreamOption::BINARY
);
//- Construct from path and name.
@ -89,7 +89,7 @@ public:
(
const fileName& path,
const fileName& name,
IOstream::streamFormat format=IOstream::BINARY
IOstreamOption::streamFormat format = IOstreamOption::BINARY
);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,7 +25,7 @@ License
\*---------------------------------------------------------------------------*/
#include "surfaceWriterCaching.H"
#include "ensightWriterCaching.H"
#include "ListOps.H"
#include "Fstream.H"
@ -67,7 +67,7 @@ static label findTimeIndex(const UList<scalar>& list, const scalar val)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceWriters::writerCaching::writerCaching(const word& cacheFileName)
Foam::ensightOutput::writerCaching::writerCaching(const word& cacheFileName)
:
dictName_(cacheFileName)
{}
@ -75,7 +75,7 @@ Foam::surfaceWriters::writerCaching::writerCaching(const word& cacheFileName)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::dictionary& Foam::surfaceWriters::writerCaching::fieldsDict() const
const Foam::dictionary& Foam::ensightOutput::writerCaching::fieldsDict() const
{
const dictionary* dictptr = cache_.findDict("fields", keyType::LITERAL);
@ -88,7 +88,7 @@ const Foam::dictionary& Foam::surfaceWriters::writerCaching::fieldsDict() const
}
Foam::dictionary& Foam::surfaceWriters::writerCaching::fieldDict
Foam::dictionary& Foam::ensightOutput::writerCaching::fieldDict
(
const word& fieldName
)
@ -100,7 +100,7 @@ Foam::dictionary& Foam::surfaceWriters::writerCaching::fieldDict
}
bool Foam::surfaceWriters::writerCaching::remove(const word& fieldName)
bool Foam::ensightOutput::writerCaching::remove(const word& fieldName)
{
dictionary* dictptr = cache_.findDict("fields", keyType::LITERAL);
@ -113,7 +113,7 @@ bool Foam::surfaceWriters::writerCaching::remove(const word& fieldName)
}
void Foam::surfaceWriters::writerCaching::clear()
void Foam::ensightOutput::writerCaching::clear()
{
times_.clear();
geoms_.clear();
@ -123,7 +123,7 @@ void Foam::surfaceWriters::writerCaching::clear()
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::surfaceWriters::writerCaching::readPreviousTimes
Foam::label Foam::ensightOutput::writerCaching::readPreviousTimes
(
const fileName& dictFile,
const scalar timeValue
@ -184,9 +184,40 @@ Foam::label Foam::surfaceWriters::writerCaching::readPreviousTimes
}
Foam::label Foam::ensightOutput::writerCaching::latestTimeIndex() const
{
return max(0, times_.size()-1);
}
Foam::label Foam::ensightOutput::writerCaching::latestGeomIndex() const
{
return max(0, geoms_.find_last());
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
int Foam::ensightOutput::writerCaching::geometryTimeset() const
{
if (geoms_.count() <= 1)
{
// Static
return 0;
}
if (geoms_.size() == times_.size() && geoms_.all())
{
// Geometry changing is identical to fields changing
return 1;
}
// Geometry changing differently from fields
return 2;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::surfaceWriters::writerCaching::update
bool Foam::ensightOutput::writerCaching::update
(
const fileName& baseDir,
const scalar timeValue,
@ -262,7 +293,7 @@ bool Foam::surfaceWriters::writerCaching::update
if (stateChanged)
{
OFstream os(dictFile);
os << "// State file for surface writer output" << nl << nl;
os << "// State file for writer output" << nl << nl;
cache_.write(os, false);
os << nl << "// End" << nl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -24,22 +24,22 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::surfaceWriters::writerCaching
Foam::ensightOutput::writerCaching
Description
Information for surface writers with collated times.
State information for writers with collated times.
The class maintains an internal list of the known times
as well as a file-cached version with the field information.
The information is used for restarts.
SourceFiles
surfaceWriterCaching.C
ensightWriterCaching.C
\*---------------------------------------------------------------------------*/
#ifndef surfaceWriters_writerCaching_H
#define surfaceWriters_writerCaching_H
#ifndef Foam_ensightOutput_writerCaching_H
#define Foam_ensightOutput_writerCaching_H
#include "bitSet.H"
#include "dictionary.H"
@ -50,7 +50,7 @@ SourceFiles
namespace Foam
{
namespace surfaceWriters
namespace ensightOutput
{
/*---------------------------------------------------------------------------*\
@ -106,28 +106,30 @@ public:
// Member Functions
//- The output times for fields
const scalarList& times() const
const scalarList& times() const noexcept
{
return times_;
}
//- Indices in times() when geometry (mesh) has been written
const bitSet& geometries() const
const bitSet& geometries() const noexcept
{
return geoms_;
}
//- The most current time index
label latestTimeIndex() const
{
return max(0, times_.size()-1);
}
label latestTimeIndex() const;
//- The most current geometry index
label latestGeomIndex() const
{
return max(0, geoms_.find_last());
}
label latestGeomIndex() const;
//- Expected timeset for the geometry.
// Can be any of the following:
//
// 0: constant/static
// 1: moving, with the same frequency as the data
// 2: moving, with different frequency as the data
int geometryTimeset() const;
//- Get or create the 'fields' information dictionary.
const dictionary& fieldsDict() const;
@ -141,7 +143,7 @@ public:
// geometry change or a new time interval
bool update
(
const fileName& baseDir, //!< Directory containing the cache file
const fileName& baseDir, //!< Directory containing cache file
const scalar timeValue, //!< The current time value
const bool geomChanged, //!< Monitored geometry changed
const word& fieldName, //!< Name of field
@ -153,7 +155,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace surfaceWriters
} // End namespace ensightOutput
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -54,7 +54,7 @@ Foam::Istream& Foam::ensightReadFile::read
Foam::Istream& Foam::ensightReadFile::read(string& value)
{
if (format() == IOstream::BINARY)
if (format() == IOstreamOption::BINARY)
{
auto& iss = stdStream();
@ -101,7 +101,7 @@ Foam::Istream& Foam::ensightReadFile::read(label& value)
{
int ivalue;
if (format() == IOstream::BINARY)
if (format() == IOstreamOption::BINARY)
{
read
(
@ -123,7 +123,7 @@ Foam::Istream& Foam::ensightReadFile::read(scalar& value)
{
float fvalue;
if (format() == IOstream::BINARY)
if (format() == IOstreamOption::BINARY)
{
read
(
@ -151,7 +151,7 @@ Foam::Istream& Foam::ensightReadFile::readKeyword(string& key)
Foam::Istream& Foam::ensightReadFile::readBinaryHeader()
{
if (format() == IOstream::BINARY)
if (format() == IOstreamOption::BINARY)
{
string buffer;
read(buffer);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -55,6 +55,21 @@ Foam::fileFormats::NASCore::loadFormatNames
});
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
static inline void putValue(Ostream& os, const Type& value, const int width)
{
if (width) os << setw(width);
os << value;
}
} // End namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::scalar Foam::fileFormats::NASCore::readNasScalar(const std::string& str)
@ -133,10 +148,10 @@ void Foam::fileFormats::NASCore::setPrecision
const fieldFormat format
)
{
os.setf(ios_base::scientific);
os.setf(std::ios_base::scientific);
// Capitalise the E marker
os.setf(ios_base::uppercase);
os.setf(std::ios_base::uppercase);
const label offset = 7;
@ -168,7 +183,7 @@ Foam::Ostream& Foam::fileFormats::NASCore::writeKeyword
const fieldFormat format
)
{
os.setf(ios_base::left);
os.setf(std::ios_base::left);
switch (format)
{
@ -177,13 +192,11 @@ Foam::Ostream& Foam::fileFormats::NASCore::writeKeyword
os << setw(8) << keyword;
break;
}
case fieldFormat::LONG :
{
os << setw(8) << word(keyword + '*');
break;
}
case fieldFormat::FREE :
{
os << keyword;
@ -191,12 +204,78 @@ Foam::Ostream& Foam::fileFormats::NASCore::writeKeyword
}
}
os.unsetf(ios_base::left);
os.unsetf(std::ios_base::left);
return os;
}
void Foam::fileFormats::NASCore::writeCoord
(
Ostream& os,
const point& p,
const label pointId, // zero-based
const fieldFormat format
)
{
// Field width (SHORT, LONG formats)
const int width =
(
format == fieldFormat::SHORT ? 8
: format == fieldFormat::LONG ? 16
: 0
);
// Separator char (FREE format)
const char sep = (format == fieldFormat::FREE ? ',' : '\0');
// Fixed short/long formats:
// 1 GRID
// 2 ID : point ID - requires starting index of 1
// 3 CP : coordinate system ID (blank)
// 4 X1 : point x coordinate
// 5 X2 : point x coordinate
// 6 X3 : point x coordinate
// 7 CD : coordinate system for displacements (blank)
// 8 PS : single point constraints (blank)
// 9 SEID : super-element ID
writeKeyword(os, "GRID", format);
if (sep) os << sep;
os.setf(std::ios_base::right);
// Point ID (from 0-based to 1-based)
putValue(os, (pointId+1), width);
if (sep) os << sep;
// Coordinate system ID (blank)
putValue(os, "", width);
if (sep) os << sep;
putValue(os, p.x(), width);
if (sep) os << sep;
putValue(os, p.y(), width);
if (sep) os << sep;
if (format == fieldFormat::LONG)
{
// Continuation
os.unsetf(std::ios_base::right);
os << nl;
writeKeyword(os, "", format);
os.setf(std::ios_base::right);
}
putValue(os, p.z(), width);
os << nl;
os.unsetf(std::ios_base::right);
}
Foam::label Foam::fileFormats::NASCore::faceDecomposition
(
const UList<point>& points,

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef NASCore_H
#define NASCore_H
#ifndef Foam_fileFormats_NASCore_H
#define Foam_fileFormats_NASCore_H
#include "scalar.H"
#include "string.H"
@ -121,6 +121,15 @@ public:
const fieldFormat format
);
//- Write a GRID point
static void writeCoord
(
Ostream& os,
const point& p,
const label pointId, //!< 0-based Point Id
const fieldFormat format
);
//- Calculate face decomposition for non tri/quad faces
//
// \param points the surface points

View File

@ -381,8 +381,8 @@ bool Foam::functionObjects::vtkCloud::read(const dictionary& dict)
writeOpts_.ascii
(
IOstream::ASCII
== IOstream::formatEnum("format", dict, IOstream::BINARY)
IOstreamOption::ASCII
== IOstreamOption::formatEnum("format", dict, IOstreamOption::BINARY)
);
writeOpts_.append(false); // No append supported

View File

@ -183,8 +183,8 @@ bool Foam::functionObjects::vtkWrite::read(const dictionary& dict)
writeOpts_.ascii
(
IOstream::ASCII
== IOstream::formatEnum("format", dict, IOstream::BINARY)
IOstreamOption::ASCII
== IOstreamOption::formatEnum("format", dict, IOstreamOption::BINARY)
);
writeOpts_.legacy(dict.getOrDefault("legacy", false));

View File

@ -29,6 +29,7 @@ License
#include "ensightSetWriter.H"
#include "coordSet.H"
#include "IOmanip.H"
#include "ensightCase.H"
#include "ensightGeoFile.H"
#include "ensightPTraits.H"
#include "addToRunTimeSelectionTable.H"

View File

@ -76,24 +76,10 @@ void Foam::nastranSetWriter<Type>::write
forAll(points, pointi)
{
fileFormats::NASCore::writeKeyword(os, "GRID", fieldFormat::FREE);
const point& pt = points[pointi];
//os.setf(std::ios_base::right);
//os << setw(8) << pointi+1
// << setw(8) << ' '
// << setw(8) << float(pt.x())
// << setw(8) << float(pt.y())
// << setw(8) << float(pt.z())
// << nl;
//os.unsetf(std::ios_base::right);
os << ',' << pointi+1
<< ','
<< ',' << float(pt.x())
<< ',' << float(pt.y())
<< ',' << float(pt.z())
<< nl;
fileFormats::NASCore::writeCoord
(
os, points[pointi], pointi, fieldFormat::FREE
);
}
if (false)
@ -109,12 +95,15 @@ void Foam::nastranSetWriter<Type>::write
fieldFormat::FREE
);
// fieldFormat::SHORT
//os.setf(std::ios_base::right);
//os << setw(8) << edgei+1
// << setw(8) << edgei+1
// << setw(8) << edgei+2
// << nl;
//os.unsetf(std::ios_base::right);
// fieldFormat::FREE
os << ',' << edgei+1
<< ',' << edgei+1
<< ',' << edgei+2
@ -162,27 +151,16 @@ void Foam::nastranSetWriter<Type>::write
// nPoints += tracks[i].size();
// }
label globalPti = 0;
label globalPointi = 0;
for (const coordSet& points : tracks)
{
for (const point& pt : points)
for (const point& p : points)
{
fileFormats::NASCore::writeKeyword(os, "GRID", fieldFormat::FREE);
//os.setf(std::ios_base::right);
//os << setw(8) << globalPti++
// << setw(8) << ' '
// << setw(8) << float(pt.x())
// << setw(8) << float(pt.y())
// << setw(8) << float(pt.z())
// << nl;
//os.unsetf(std::ios_base::right);
os << ',' << globalPti++
<< ','
<< ',' << float(pt.x())
<< ',' << float(pt.y())
<< ',' << float(pt.z())
<< nl;
fileFormats::NASCore::writeCoord
(
os, p, globalPointi, fieldFormat::FREE
);
++globalPointi;
}
}
@ -203,6 +181,7 @@ void Foam::nastranSetWriter<Type>::write
fieldFormat::FREE
);
// fieldFormat::SHORT
//os.setf(std::ios_base::right);
//os << setw(8) << globalEdgei+1
// << setw(8) << globalPointi+1
@ -210,12 +189,14 @@ void Foam::nastranSetWriter<Type>::write
// << nl;
//os.unsetf(std::ios_base::right);
// fieldFormat::FREE
os << ',' << globalEdgei+1
<< ',' << globalPointi+1
<< ',' << globalPointi+2
<< nl;
globalEdgei++;
globalPointi++;
++globalEdgei;
++globalPointi;
}
}
}

View File

@ -59,10 +59,9 @@ triSurface/patches/surfacePatch.C
writers = writers
$(writers)/surfaceWriter.C
$(writers)/caching/surfaceWriterCaching.C
$(writers)/common/surfaceWriter.C
$(writers)/abaqus/abaqusSurfaceWriter.C
$(writers)/boundaryData/boundaryDataSurfaceWriter.C
$(writers)/boundary/boundaryDataSurfaceWriter.C
$(writers)/ensight/ensightSurfaceWriter.C
$(writers)/foam/foamSurfaceWriter.C
$(writers)/nastran/nastranSurfaceWriter.C

View File

@ -42,8 +42,8 @@ Foam::fileFormats::VTKsurfaceFormatCore::formatOptions
opts.ascii
(
IOstream::ASCII
== IOstream::formatEnum("format", dict, IOstream::ASCII)
IOstreamOption::ASCII
== IOstreamOption::formatEnum("format", dict, IOstreamOption::ASCII)
);
opts.precision

View File

@ -42,8 +42,8 @@ Foam::fileFormats::VTPsurfaceFormatCore::formatOptions
opts.ascii
(
IOstream::ASCII
== IOstream::formatEnum("format", dict, IOstream::BINARY)
IOstreamOption::ASCII
== IOstreamOption::formatEnum("format", dict, IOstreamOption::BINARY)
);
opts.precision

View File

@ -84,8 +84,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef abaqusSurfaceWriter_H
#define abaqusSurfaceWriter_H
#ifndef Foam_surfaceWriters_abaqusWriter_H
#define Foam_surfaceWriters_abaqusWriter_H
#include "surfaceWriter.H"
#include "ABAQUSCore.H"

View File

@ -25,8 +25,8 @@ License
\*---------------------------------------------------------------------------*/
#include "OFstream.H"
#include "IOmanip.H"
#include "OFstream.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

View File

@ -70,8 +70,8 @@ Foam::surfaceWriters::boundaryDataWriter::boundaryDataWriter
header_(options.getOrDefault("header", true)),
streamOpt_
(
IOstream::formatEnum("format", options, IOstream::ASCII),
IOstream::compressionEnum("compression", options)
IOstreamOption::formatEnum("format", options, IOstreamOption::ASCII),
IOstreamOption::compressionEnum("compression", options)
),
fieldScale_(options.subOrEmptyDict("fieldScale"))
{}
@ -303,6 +303,8 @@ Foam::fileName Foam::surfaceWriters::boundaryDataWriter::writeTemplate
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Field writing methods
defineSurfaceWriterWriteFields(Foam::surfaceWriters::boundaryDataWriter);

View File

@ -125,8 +125,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef boundaryDataSurfaceWriter_H
#define boundaryDataSurfaceWriter_H
#ifndef Foam_surfaceWriters_boundaryDataWriter_H
#define Foam_surfaceWriters_boundaryDataWriter_H
#include "surfaceWriter.H"

View File

@ -166,33 +166,6 @@ Foam::surfaceWriter::surfaceWriter(const dictionary& options)
}
Foam::surfaceWriter::surfaceWriter
(
const meshedSurf& surf,
bool parallel,
const dictionary& options
)
:
surfaceWriter(options)
{
setSurface(surf, parallel);
}
Foam::surfaceWriter::surfaceWriter
(
const pointField& points,
const faceList& faces,
bool parallel,
const dictionary& options
)
:
surfaceWriter(options)
{
setSurface(points, faces, parallel);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceWriter::~surfaceWriter()
@ -430,16 +403,14 @@ Foam::label Foam::surfaceWriter::size() const
}
bool Foam::surfaceWriter::checkOpen() const
void Foam::surfaceWriter::checkOpen() const
{
if (outputPath_.empty())
if (!is_open())
{
FatalErrorInFunction
<< type() << " : Attempted to write without a path" << nl
<< exit(FatalError);
}
return !outputPath_.empty();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,8 +68,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef surfaceWriter_H
#define surfaceWriter_H
#ifndef Foam_surfaceWriter_H
#define Foam_surfaceWriter_H
#include <functional>
#include "typeInfo.H"
@ -160,7 +160,7 @@ protected:
// Protected Member Functions
//- Verify that the outputPath_ has been set or FatalError
bool checkOpen() const;
void checkOpen() const;
//- Merge surfaces if they are not already upToDate (parallel)
//- or simply mark the surface as being up-to-date
@ -263,23 +263,6 @@ public:
//- Default construct with specified options
explicit surfaceWriter(const dictionary& options);
//- Construct from components
explicit surfaceWriter
(
const meshedSurf& surf,
bool parallel = Pstream::parRun(),
const dictionary& options = dictionary()
);
//- Construct from components
surfaceWriter
(
const pointField& points,
const faceList& faces,
bool parallel = Pstream::parRun(),
const dictionary& options = dictionary()
);
//- Destructor. Calls close()
virtual ~surfaceWriter();
@ -368,6 +351,9 @@ public:
// Queries, Access
//- Test if outputPath has been set
inline bool is_open() const noexcept;
//- Writer is associated with a surface
bool hasSurface() const;
@ -379,40 +365,40 @@ public:
//- The number of expected output fields.
// Currently only used by the legacy VTK format.
inline label nFields() const;
inline label nFields() const noexcept;
//- Set the number of expected output fields
// Currently only used by the legacy VTK format.
// \return old value
inline label nFields(const label n);
inline label nFields(const label n) noexcept;
//- Are the field data to be treated as point data?
inline bool isPointData() const;
inline bool isPointData() const noexcept;
//- Set handling of field data to face/point data
// \return old value
inline bool isPointData(const bool on);
inline bool isPointData(const bool on) noexcept;
//- Should a time directory be spliced into the output path?
inline bool useTimeDir() const;
inline bool useTimeDir() const noexcept;
//- Enable/disable use of spliced output path
// \return old value
inline bool useTimeDir(const bool on);
inline bool useTimeDir(const bool on) noexcept;
//- Get output verbosity
inline bool verbose() const;
inline bool verbose() const noexcept;
//- Enable/disable verbose output
// \return old value
inline bool verbose(const bool on);
inline bool verbose(const bool on) noexcept;
//- The current value of the point merge dimension (metre)
inline scalar mergeDim() const;
inline scalar mergeDim() const noexcept;
//- Change the point merge dimension (metre)
// \return old value
inline scalar mergeDim(const scalar dist);
inline scalar mergeDim(const scalar dist) noexcept;
// Time

View File

@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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, distributed under GPL-3.0-or-later.
Typedef
Foam::surfaceWriters::writerCaching
Description
Compatibility name. Replaced (JAN-2022) by
Foam::ensightOutput::writerCaching
\*---------------------------------------------------------------------------*/
#ifndef Foam_surfaceWriters_writerCaching_H
#define Foam_surfaceWriters_writerCaching_H
#include "ensightWriterCaching.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace surfaceWriters
{
typedef Foam::ensightOutput::writerCaching writerCaching;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace surfaceWriters
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,13 +27,19 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::label Foam::surfaceWriter::nFields() const
inline bool Foam::surfaceWriter::is_open() const noexcept
{
return !outputPath_.empty();
}
inline Foam::label Foam::surfaceWriter::nFields() const noexcept
{
return nFields_;
}
inline Foam::label Foam::surfaceWriter::nFields(const label n)
inline Foam::label Foam::surfaceWriter::nFields(const label n) noexcept
{
label old(nFields_);
nFields_ = n;
@ -41,13 +47,13 @@ inline Foam::label Foam::surfaceWriter::nFields(const label n)
}
inline bool Foam::surfaceWriter::isPointData() const
inline bool Foam::surfaceWriter::isPointData() const noexcept
{
return isPointData_;
}
inline bool Foam::surfaceWriter::isPointData(const bool on)
inline bool Foam::surfaceWriter::isPointData(const bool on) noexcept
{
bool old(isPointData_);
isPointData_ = on;
@ -55,13 +61,13 @@ inline bool Foam::surfaceWriter::isPointData(const bool on)
}
inline bool Foam::surfaceWriter::useTimeDir() const
inline bool Foam::surfaceWriter::useTimeDir() const noexcept
{
return useTimeDir_;
}
inline bool Foam::surfaceWriter::useTimeDir(const bool on)
inline bool Foam::surfaceWriter::useTimeDir(const bool on) noexcept
{
bool old(useTimeDir_);
useTimeDir_ = on;
@ -69,13 +75,13 @@ inline bool Foam::surfaceWriter::useTimeDir(const bool on)
}
inline bool Foam::surfaceWriter::verbose() const
inline bool Foam::surfaceWriter::verbose() const noexcept
{
return verbose_;
}
inline bool Foam::surfaceWriter::verbose(const bool on)
inline bool Foam::surfaceWriter::verbose(const bool on) noexcept
{
bool old(verbose_);
verbose_ = on;
@ -83,13 +89,13 @@ inline bool Foam::surfaceWriter::verbose(const bool on)
}
inline Foam::scalar Foam::surfaceWriter::mergeDim() const
inline Foam::scalar Foam::surfaceWriter::mergeDim() const noexcept
{
return mergeDim_;
}
inline Foam::scalar Foam::surfaceWriter::mergeDim(const scalar dist)
inline Foam::scalar Foam::surfaceWriter::mergeDim(const scalar dist) noexcept
{
scalar old(mergeDim_);
mergeDim_ = dist;

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef surfaceWriterMethods_H
#define surfaceWriterMethods_H
#ifndef Foam_surfaceWriterMethods_H
#define Foam_surfaceWriterMethods_H
namespace Foam
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -50,132 +50,12 @@ namespace surfaceWriters
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
void Foam::surfaceWriters::ensightWriter::printTimeset
(
OSstream& os,
const label ts,
const scalar timeValue
)
{
os
<< "time set: " << ts << nl
<< "number of steps: " << 1 << nl;
// Single value - starts at index 0
os << "filename start number: 0" << nl
<< "filename increment: 1" << nl
<< "time values:" << nl;
os << " " << timeValue
<< nl << nl;
}
void Foam::surfaceWriters::ensightWriter::printTimeset
(
OSstream& os,
const label ts,
const UList<scalar>& values
)
{
label pos_;
os
<< "time set: " << ts << nl
<< "number of steps: " << values.size() << nl;
// Assume contiguous numbering - starts at index 0
os << "filename start number: 0" << nl
<< "filename increment: 1" << nl;
os << "time values:" << nl;
pos_ = 0;
for (const scalar& val : values)
{
if (pos_ == 6)
{
os << nl;
pos_ = 0;
}
++pos_;
os << ' ' << setf(ios_base::right) << setw(12) << val;
}
os << nl << nl;
}
void Foam::surfaceWriters::ensightWriter::printTimeset
(
OSstream& os,
const label ts,
const UList<scalar>& values,
const bitSet& indices
)
{
label pos_;
// Check if continuous numbering can be used
if
(
values.empty()
|| (indices.size() == values.size() && indices.all())
)
{
// Can simply emit as 0-based with increment
printTimeset(os, ts, values);
return;
}
// Generate time set
os
<< "time set: " << ts << nl
<< "number of steps: " << indices.count() << nl;
os << "filename numbers:" << nl;
pos_ = 0;
for (const label& idx : indices)
{
if (pos_ == 6)
{
os << nl;
pos_ = 0;
}
++pos_;
os << ' ' << setf(ios_base::right) << setw(8) << idx;
}
os << nl;
os << "time values:" << nl;
pos_ = 0;
for (const label& idx : indices)
{
if (pos_ == 6)
{
os << nl;
pos_ = 0;
}
++pos_;
os << ' ' << setf(ios_base::right) << setw(12) << values[idx];
}
os << nl << nl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceWriters::ensightWriter::ensightWriter()
:
surfaceWriter(),
writeFormat_(IOstream::ASCII),
writeFormat_(IOstreamOption::ASCII),
collateTimes_(true),
caching_("fieldsDict") // Historic name
{}
@ -189,7 +69,7 @@ Foam::surfaceWriters::ensightWriter::ensightWriter
surfaceWriter(options),
writeFormat_
(
IOstreamOption::formatEnum("format", options, IOstream::ASCII)
IOstreamOption::formatEnum("format", options, IOstreamOption::ASCII)
),
collateTimes_(options.getOrDefault("collateTimes", true)),
caching_("fieldsDict") // Historic name

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,11 +57,11 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef ensightSurfaceWriter_H
#define ensightSurfaceWriter_H
#ifndef Foam_surfaceWriters_ensightWriter_H
#define Foam_surfaceWriters_ensightWriter_H
#include "surfaceWriter.H"
#include "surfaceWriterCaching.H"
#include "ensightWriterCaching.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -80,71 +80,18 @@ class ensightWriter
{
// Private Data
//- Output format option (default: IOstream::ASCII)
IOstream::streamFormat writeFormat_;
//- Output format option (default: ASCII)
IOstreamOption::streamFormat writeFormat_;
//- Collate times (default: true)
bool collateTimes_;
//- Cached information for times, geometry, fields (collated)
writerCaching caching_;
ensightOutput::writerCaching caching_;
// Private Member Functions
//- The geometry can be any of the following:
//
// 0: constant/static
// 1: moving, with the same frequency as the data
// 2: moving, with different frequency as the data
int geometryTimeset() const;
//- Print time-set for ensight case file with a single time
static void printTimeset
(
OSstream& os,
const label ts,
const scalar timeValue
);
//- Print time-set for ensight case file, with N times and 0-based
//- file numbering
//
// \verbatim
// TIME
// time set: ts
// number of steps: ns
// filename start number: 0
// filename increment: 1
// time values: time_1 time_2 ... time_ns
// \endverbatim
static void printTimeset
(
OSstream& os,
const label ts,
const UList<scalar>& times
);
//- Print time-set for ensight case file, with N times, 0-based
//- file numbering but perhaps non-contiguous
//
// \verbatim
// TIME
// time set: ts
// number of steps: ns
// filename numbers: idx_1 idx_2 ... idx_ns
// time values: time_1 time_2 ... time_ns
// \endverbatim
static void printTimeset
(
OSstream& os,
const label ts,
const UList<scalar>& times,
const bitSet& indices
);
//- Write geometry
fileName writeCollated();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,30 +26,6 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
int Foam::surfaceWriters::ensightWriter::geometryTimeset() const
{
const scalarList& times = caching_.times();
const bitSet& geoms = caching_.geometries();
if (geoms.count() <= 1)
{
// Static
return 0;
}
if (geoms.size() == times.size() && geoms.all())
{
// Geometry changing is the same as fields changing
return 1;
}
// Geometry changing differently from fields
return 2;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::surfaceWriters::ensightWriter::writeCollated()
@ -169,7 +145,7 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeCollated
// 1: moving, with the same frequency as the data
// 2: moving, with different frequency as the data
const label tsGeom = geometryTimeset();
const label tsGeom = caching_.geometryTimeset();
osCase
<< "FORMAT" << nl
@ -228,10 +204,10 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeCollated
<< nl
<< "TIME" << nl;
printTimeset(osCase, 1, caching_.times());
ensightCase::printTimeset(osCase, 1, caching_.times());
if (tsGeom == 2)
{
printTimeset
ensightCase::printTimeset
(
osCase,
tsGeom,

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,13 +32,13 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeUncollated()
{
checkOpen();
const ensight::FileName surfName(outputPath_.name());
const ensight::FileName baseName(outputPath_.name());
// Uncollated
// ==========
// CaseFile: rootdir/<TIME>/surfaceName.case
// Geometry: rootdir/<TIME>/surfaceName.00000000.mesh
// CaseFile: rootdir/<TIME>/NAME.case
// Geometry: rootdir/<TIME>/NAME.00000000.mesh
fileName outputDir;
if (useTimeDir() && !timeName().empty())
@ -51,7 +51,7 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeUncollated()
outputDir = outputPath_.path();
}
const fileName outputFile = outputDir / surfName + ".case";
const fileName outputFile = outputDir / baseName + ".case";
if (verbose_)
{
@ -72,7 +72,7 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeUncollated()
ensightGeoFile osGeom
(
outputDir,
surfName + ".00000000.mesh",
baseName + ".00000000.mesh",
writeFormat_
);
@ -85,7 +85,7 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeUncollated()
<< nl
<< "TIME" << nl;
printTimeset(osCase, 1, scalar(0));
ensightCase::printTimeset(osCase, 1, scalar(0));
ensightOutputSurface part
(
@ -110,24 +110,24 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeUncollated
{
checkOpen();
const ensight::FileName surfName(outputPath_.name());
const ensight::FileName baseName(outputPath_.name());
const ensight::VarName varName(fieldName);
// Uncollated
// ==========
// CaseFile: rootdir/time/<field>/surfaceName.case
// Geometry: rootdir/time/<field>/surfaceName.<index>.mesh
// Field: rootdir/time/<field>/surfaceName.<index>.<field>
// CaseFile: rootdir/time/<field>/NAME.case
// Geometry: rootdir/time/<field>/NAME.<index>.mesh
// Field: rootdir/time/<field>/NAME.<index>.<field>
// Variable name as sub-directory for results. Eg,
// - VAR1/SURF1.case
// - VAR1/SURF1.00000000.mesh
// - VAR1/SURF1.00000001.VAR1
// - VAR1/NAME1.case
// - VAR1/NAME1.00000000.mesh
// - VAR1/NAME1.00000001.VAR1
// and
// - VAR2/SURF1.case
// - VAR2/SURF1.00000000.mesh
// - VAR2/SURF1.00000001.VAR2
// - VAR2/NAME1.case
// - VAR2/NAME1.00000000.mesh
// - VAR2/NAME1.00000001.VAR2
fileName outputDir;
if (useTimeDir() && !timeName().empty())
@ -144,7 +144,7 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeUncollated
const word timeDir = timeName();
const scalar timeValue = currTime_.value();
const fileName outputFile = baseDir / surfName + ".case";
const fileName outputFile = baseDir / baseName + ".case";
if (verbose_)
{
@ -175,13 +175,13 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeUncollated
ensightGeoFile osGeom
(
baseDir,
surfName + ".00000000.mesh",
baseName + ".00000000.mesh",
writeFormat_
);
ensightFile osField
(
baseDir,
surfName + ".00000000." + varName,
baseName + ".00000000." + varName,
writeFormat_
);
@ -201,13 +201,13 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeUncollated
: " per element: 1 " // time-set 1
)
<< setw(15) << varName << ' '
<< surfName.c_str() << ".********." << varName << nl;
<< baseName.c_str() << ".********." << varName << nl;
osCase
<< nl
<< "TIME" << nl;
printTimeset(osCase, 1, timeValue);
ensightCase::printTimeset(osCase, 1, timeValue);
osCase << "# end" << nl;

View File

@ -63,8 +63,8 @@ Foam::surfaceWriters::foamWriter::foamWriter
surfaceWriter(options),
streamOpt_
(
IOstream::formatEnum("format", options, IOstream::ASCII),
IOstream::compressionEnum("compression", options)
IOstreamOption::formatEnum("format", options, IOstreamOption::ASCII),
IOstreamOption::compressionEnum("compression", options)
),
fieldScale_(options.subOrEmptyDict("fieldScale"))
{}
@ -235,6 +235,8 @@ Foam::fileName Foam::surfaceWriters::foamWriter::writeTemplate
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Field writing methods
defineSurfaceWriterWriteFields(Foam::surfaceWriters::foamWriter);

View File

@ -87,8 +87,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef foamSurfaceWriter_H
#define foamSurfaceWriter_H
#ifndef Foam_surfaceWriters_foamWriter_H
#define Foam_surfaceWriters_foamWriter_H
#include "surfaceWriter.H"
@ -109,7 +109,7 @@ class foamWriter
{
// Private Data
//- Output stream option (default: IOstream::ASCII, uncompressed)
//- Output stream option (default: ASCII, uncompressed)
IOstreamOption streamOpt_;
//- Output field scaling

View File

@ -70,58 +70,11 @@ Foam::Ostream& Foam::surfaceWriters::nastranWriter::writeKeyword
void Foam::surfaceWriters::nastranWriter::writeCoord
(
Ostream& os,
const point& pt,
const label pointI
const point& p,
const label pointId
) const
{
// Fixed short/long formats:
// 1 GRID
// 2 ID : point ID - requires starting index of 1
// 3 CP : coordinate system ID (blank)
// 4 X1 : point x coordinate
// 5 X2 : point x coordinate
// 6 X3 : point x coordinate
// 7 CD : coordinate system for displacements (blank)
// 8 PS : single point constraints (blank)
// 9 SEID : super-element ID
writeKeyword(os, "GRID") << separator_;
os.setf(std::ios_base::right);
writeValue(os, pointI+1) << separator_;
writeValue(os, "") << separator_;
writeValue(os, pt.x()) << separator_;
writeValue(os, pt.y()) << separator_;
switch (writeFormat_)
{
case fieldFormat::SHORT :
{
os << setw(8) << pt.z() << nl;
os.unsetf(std::ios_base::right);
break;
}
case fieldFormat::LONG :
{
os << nl;
os.unsetf(std::ios_base::right);
writeKeyword(os, "");
os.setf(std::ios_base::right);
writeValue(os, pt.z()) << nl;
break;
}
case fieldFormat::FREE :
{
writeValue(os, pt.z()) << nl;
break;
}
}
os.unsetf(std::ios_base::right);
fileFormats::NASCore::writeCoord(os, p, pointId, writeFormat_);
}
@ -360,7 +313,12 @@ Foam::surfaceWriters::nastranWriter::nastranWriter()
geometryScale_(1),
fieldScale_(),
separator_()
{}
{
// if (writeFormat_ == fieldFormat::FREE)
// {
// separator_ = ",";
// }
}
Foam::surfaceWriters::nastranWriter::nastranWriter

View File

@ -99,8 +99,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef nastranSurfaceWriter_H
#define nastranSurfaceWriter_H
#ifndef Foam_surfaceWriters_nastranWriter_H
#define Foam_surfaceWriters_nastranWriter_H
#include "surfaceWriter.H"
#include "NASCore.H"
@ -149,7 +149,7 @@ private:
//- Output field scaling
const dictionary fieldScale_;
//- Separator used for free format
//- Separator (used for free format)
word separator_;
@ -159,8 +159,8 @@ private:
void writeCoord
(
Ostream& os,
const point& pt,
const label pointI //!< 0-based Point Id
const point& p,
const label pointId //!< 0-based Point Id
) const;
//- Write a face element (CTRIA3 or CQUAD4)

View File

@ -26,9 +26,9 @@ License
\*---------------------------------------------------------------------------*/
#include "OFstream.H"
#include "IOmanip.H"
#include "ListOps.H"
#include "OFstream.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

View File

@ -129,6 +129,8 @@ Foam::fileName Foam::surfaceWriters::nullWriter::write()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Field writing methods
defineSurfaceWriterWriteFields(Foam::surfaceWriters::nullWriter);

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef nullSurfaceWriter_H
#define nullSurfaceWriter_H
#ifndef Foam_surfaceWriters_nullWriter_H
#define Foam_surfaceWriters_nullWriter_H
#include "surfaceWriter.H"

View File

@ -62,8 +62,8 @@ Foam::surfaceWriters::proxyWriter::proxyWriter
fileExtension_(fileExt),
streamOpt_
(
IOstream::formatEnum("format", options, IOstream::ASCII),
IOstream::compressionEnum("compression", options)
IOstreamOption::formatEnum("format", options, IOstreamOption::ASCII),
IOstreamOption::compressionEnum("compression", options)
),
options_(options)
{}
@ -148,6 +148,8 @@ Foam::fileName Foam::surfaceWriters::proxyWriter::write()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Field writing methods
defineSurfaceWriterWriteFields(Foam::surfaceWriters::proxyWriter);

View File

@ -59,8 +59,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef proxySurfaceWriter_H
#define proxySurfaceWriter_H
#ifndef Foam_surfaceWriters_proxyWriter_H
#define Foam_surfaceWriters_proxyWriter_H
#include "surfaceWriter.H"

View File

@ -75,8 +75,8 @@ Foam::surfaceWriters::rawWriter::rawWriter
surfaceWriter(options),
streamOpt_
(
IOstream::ASCII,
IOstream::compressionEnum("compression", options)
IOstreamOption::ASCII,
IOstreamOption::compressionEnum("compression", options)
),
precision_
(

View File

@ -84,8 +84,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef rawSurfaceWriter_H
#define rawSurfaceWriter_H
#ifndef Foam_surfaceWriters_rawWriter_H
#define Foam_surfaceWriters_rawWriter_H
#include "surfaceWriter.H"

View File

@ -26,9 +26,9 @@ License
\*---------------------------------------------------------------------------*/
#include "IOmanip.H"
#include "OFstream.H"
#include "OSspecific.H"
#include "IOmanip.H"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //

View File

@ -82,8 +82,8 @@ Foam::surfaceWriters::starcdWriter::starcdWriter
surfaceWriter(options),
streamOpt_
(
IOstream::ASCII,
IOstream::compressionEnum("compression", options)
IOstreamOption::ASCII,
IOstreamOption::compressionEnum("compression", options)
),
fieldScale_(options.subOrEmptyDict("fieldScale"))
{}
@ -274,6 +274,8 @@ Foam::fileName Foam::surfaceWriters::starcdWriter::writeTemplate
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Field writing methods
defineSurfaceWriterWriteFields(Foam::surfaceWriters::starcdWriter);

View File

@ -76,8 +76,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef starcdSurfaceWriter_H
#define starcdSurfaceWriter_H
#ifndef Foam_surfaceWriters_starcdWriter_H
#define Foam_surfaceWriters_starcdWriter_H
#include "surfaceWriter.H"

View File

@ -108,8 +108,8 @@ Foam::surfaceWriters::vtkWriter::vtkWriter
opts.ascii
(
IOstream::ASCII
== IOstream::formatEnum("format", options, IOstream::BINARY)
IOstreamOption::ASCII
== IOstreamOption::formatEnum("format", options, IOstreamOption::BINARY)
);
opts.legacy(options.getOrDefault("legacy", false));
@ -348,6 +348,8 @@ Foam::fileName Foam::surfaceWriters::vtkWriter::writeTemplate
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Field writing methods
defineSurfaceWriterWriteFields(Foam::surfaceWriters::vtkWriter);

View File

@ -74,8 +74,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef vtkSurfaceWriter_H
#define vtkSurfaceWriter_H
#ifndef Foam_surfaceWriters_vtkWriter_H
#define Foam_surfaceWriters_vtkWriter_H
#include "surfaceWriter.H"

View File

@ -120,8 +120,8 @@ Foam::surfaceWriters::x3dWriter::x3dWriter
surfaceWriter(options),
streamOpt_
(
IOstream::ASCII,
IOstream::compressionEnum("compression", options)
IOstreamOption::ASCII,
IOstreamOption::compressionEnum("compression", options)
),
range_(),
colourTablePtr_(nullptr)
@ -368,6 +368,8 @@ Foam::fileName Foam::surfaceWriters::x3dWriter::writeTemplate
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Field writing methods
defineSurfaceWriterWriteFields(Foam::surfaceWriters::x3dWriter);

View File

@ -62,8 +62,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef x3dSurfaceWriter_H
#define x3dSurfaceWriter_H
#ifndef Foam_surfaceWriters_x3dWriter_H
#define Foam_surfaceWriters_x3dWriter_H
#include "surfaceWriter.H"
#include "X3DsurfaceFormatCore.H"