/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2023 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 . \*---------------------------------------------------------------------------*/ #include "abaqusCoordSetWriter.H" #include "coordSet.H" #include "IOmanip.H" #include "OFstream.H" #include "OSspecific.H" #include "stringOps.H" #include "coordSetWriterMethods.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace coordSetWriters { defineTypeName(abaqusWriter); addToRunTimeSelectionTable(coordSetWriter, abaqusWriter, word); addToRunTimeSelectionTable(coordSetWriter, abaqusWriter, wordDict); } } const Foam::Enum Foam::coordSetWriters::abaqusWriter::timeBaseNames_ ({ { timeBase::time, "time" }, { timeBase::iter, "iteration" }, }); // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // namespace Foam { template static inline void putValue(Ostream& os, const Type& value, const int width) { if (width) os << setw(width); os << value; } } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::string Foam::coordSetWriters::abaqusWriter::replaceUserEntries ( const string& str, const dictionary& vars ) const { string result = str; const bool allowEnv = true; const bool allowEmpty = false; stringOps::inplaceExpand(result, vars, allowEnv, allowEmpty); return result; } void Foam::coordSetWriters::abaqusWriter::appendTimeName ( const word& fieldName, fileName& fName ) const { if (useTimeDir()) { return; } switch (timeBase_) { case timeBase::time: { fName.ext(timeName()); break; } case timeBase::iter: { fName.ext(Foam::name(writeIndex_[fieldName])); break; } default: { FatalErrorInFunction << "Unhandled enumeration " << timeBaseNames_[timeBase_] << ". Available options: " << timeBaseNames_.sortedToc() << abort(FatalError); } } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::coordSetWriters::abaqusWriter::abaqusWriter() : coordSetWriter(), outputHeader_(), writeGeometry_(false), nullValue_(pTraits::min), useLocalTimeDir_(coordSetWriter::useTimeDir()), timeBase_(timeBase::time), writeIndex_(0) {} Foam::coordSetWriters::abaqusWriter::abaqusWriter(const dictionary& options) : coordSetWriter(options), outputHeader_(), writeGeometry_(false), nullValue_(pTraits::min), useLocalTimeDir_(coordSetWriter::useTimeDir()), timeBase_(timeBase::time), writeIndex_(0) { options.readIfPresent("header", outputHeader_); options.readIfPresent("useTimeDir", useLocalTimeDir_); if (!useLocalTimeDir_) { timeBaseNames_.readIfPresent("timeBase", options, timeBase_); options.readIfPresent("writeIndex", writeIndex_); } options.readIfPresent("writeGeometry", writeGeometry_); options.readIfPresent("nullValue", nullValue_); } Foam::coordSetWriters::abaqusWriter::abaqusWriter ( const coordSet& coords, const fileName& outputPath, const dictionary& options ) : abaqusWriter(options) { open(coords, outputPath); } Foam::coordSetWriters::abaqusWriter::abaqusWriter ( const UPtrList& tracks, const fileName& outputPath, const dictionary& options ) : abaqusWriter(options) { open(tracks, outputPath); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::coordSetWriters::abaqusWriter::~abaqusWriter() { close(); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::fileName Foam::coordSetWriters::abaqusWriter::path() const { // 1) rootdir/