/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2018-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 . Class Foam::IOField Description A primitive field of type \ with automated input and output. SourceFiles IOField.C \*---------------------------------------------------------------------------*/ #ifndef Foam_IOField_H #define Foam_IOField_H #include "Field.H" #include "regIOobject.H" #include "refPtr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ Class IOField Declaration \*---------------------------------------------------------------------------*/ template class IOField : public regIOobject, public Field { // Private Member Functions //- Read with optional 'on-proc' value void readFromStream(const bool readOnProc = true); //- Read if IOobject flags set. Return true if read. bool readContents(); public: //- The underlying content type typedef Field content_type; //- Runtime type information TypeName("Field"); // Constructors //- Default copy construct IOField(const IOField&) = default; //- Construct from IOobject explicit IOField(const IOobject& io); //- Construct from IOobject, with local processor conditional reading IOField(const IOobject& io, const bool readOnProc); //- Construct from IOobject and zero size (if not read) IOField(const IOobject& io, Foam::zero); //- Construct from IOobject and field size (if not read) IOField(const IOobject& io, const label len); //- Construct from IOobject and copy of List/Field content IOField(const IOobject& io, const UList& content); //- Construct by transferring the Field content IOField(const IOobject& io, Field&& content); //- Construct by copying/moving tmp content IOField(const IOobject& io, const tmp>& tfld); // Factory Methods //- Read and return contents. The IOobject will not be registered static Field readContents(const IOobject& io); //- Destructor virtual ~IOField() = default; // Member Functions //- The writeData method for regIOobject write operation virtual bool writeData(Ostream& os) const; // Member Operators //- Copy assignment of entries void operator=(const IOField& rhs); //- Copy or move assignment of entries using Field::operator=; }; /*---------------------------------------------------------------------------*\ Class IOFieldRef Declaration \*---------------------------------------------------------------------------*/ //- A IOField wrapper for writing external data. template class IOFieldRef : public regIOobject { // Private Data //- Reference to the external content refPtr> contentRef_; public: //- The underlying content type typedef Field content_type; //- Type is identical to IOField virtual const word& type() const { return IOField::typeName; } // Generated Methods //- No default construct IOFieldRef() = delete; //- No copy construct IOFieldRef(const IOFieldRef&) = delete; //- No copy assignment void operator=(const IOFieldRef&) = delete; // Constructors //- Construct from IOobject and const data reference IOFieldRef(const IOobject& io, const Field& content); //- Destructor virtual ~IOFieldRef() = default; // Member Functions //- Allow cast to const content // Fatal if content is not set operator const Field&() const { return contentRef_.cref(); } //- The writeData method for regIOobject write operation // Fatal if content is not set virtual bool writeData(Ostream& os) const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository #include "IOField.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* //