diff --git a/src/OpenFOAM/meshes/polyMesh/polyDistributionMap/IOdistributionMap.C b/src/OpenFOAM/meshes/polyMesh/polyDistributionMap/IOdistributionMap.C new file mode 100644 index 0000000000..9efc758d7c --- /dev/null +++ b/src/OpenFOAM/meshes/polyMesh/polyDistributionMap/IOdistributionMap.C @@ -0,0 +1,158 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2014-2022 OpenFOAM Foundation + \\/ 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 . + +\*---------------------------------------------------------------------------*/ + +#include "IOdistributionMap.H" + +/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ + +namespace Foam +{ + defineTypeNameAndDebug(IOdistributionMap, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::IOdistributionMap::IOdistributionMap(const IOobject& io) +: + regIOobject(io) +{ + // Temporary warning + if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED) + { + WarningInFunction + << "IOdistributionMap " << name() + << " constructed with IOobject::MUST_READ_IF_MODIFIED" + " but IOdistributionMap does not support automatic rereading." + << endl; + } + + if + ( + ( + io.readOpt() == IOobject::MUST_READ + || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED + ) + || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + ) + { + readStream(typeName) >> *this; + close(); + } +} + + +Foam::IOdistributionMap::IOdistributionMap +( + const IOobject& io, + const distributionMap& map +) +: + regIOobject(io) +{ + // Temporary warning + if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED) + { + WarningInFunction + << "IOdistributionMap " << name() + << " constructed with IOobject::MUST_READ_IF_MODIFIED" + " but IOdistributionMap does not support automatic rereading." + << endl; + } + + if + ( + ( + io.readOpt() == IOobject::MUST_READ + || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED + ) + || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + ) + { + readStream(typeName) >> *this; + close(); + } + else + { + distributionMap::operator=(map); + } +} + + +Foam::IOdistributionMap::IOdistributionMap +( + const IOobject& io, + distributionMap&& map +) +: + regIOobject(io), + distributionMap(move(map)) +{ + // Temporary warning + if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED) + { + WarningInFunction + << "IOdistributionMap " << name() + << " constructed with IOobject::MUST_READ_IF_MODIFIED" + " but IOdistributionMap does not support automatic rereading." + << endl; + } + + if + ( + ( + io.readOpt() == IOobject::MUST_READ + || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED + ) + || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + ) + { + readStream(typeName) >> *this; + close(); + } +} + + +// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // + +Foam::IOdistributionMap::~IOdistributionMap() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::IOdistributionMap::readData(Istream& is) +{ + return (is >> *this).good(); +} + + +bool Foam::IOdistributionMap::writeData(Ostream& os) const +{ + return (os << *this).good(); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/polyDistributionMap/IOdistributionMap.H b/src/OpenFOAM/meshes/polyMesh/polyDistributionMap/IOdistributionMap.H new file mode 100644 index 0000000000..e78a31307e --- /dev/null +++ b/src/OpenFOAM/meshes/polyMesh/polyDistributionMap/IOdistributionMap.H @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2014-2022 OpenFOAM Foundation + \\/ 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 . + +Class + Foam::IOdistributionMap + +Description + IOdistributionMap is derived from distributionMap and + IOobject to give the distributionMap + automatic IO functionality via the objectRegistry. + +SourceFiles + IOdistributionMap.C + +\*---------------------------------------------------------------------------*/ + +#ifndef IOdistributionMap_H +#define IOdistributionMap_H + +#include "distributionMap.H" +#include "regIOobject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class IOdistributionMap Declaration +\*---------------------------------------------------------------------------*/ + +class IOdistributionMap +: + public regIOobject, + public distributionMap +{ + +public: + + //- Runtime type information + TypeName("distributionMap"); + + // Constructors + + //- Construct given an IOobject + IOdistributionMap(const IOobject&); + + //- Construct given an IOobject and distributionMap + IOdistributionMap(const IOobject&, const distributionMap&); + + //- Move constructor transferring the distributionMap contents + IOdistributionMap(const IOobject&, distributionMap&&); + + + //- Destructor + virtual ~IOdistributionMap(); + + + // Member Functions + + //- ReadData function required for regIOobject read operation + virtual bool readData(Istream&); + + //- WriteData function required for regIOobject write operation + virtual bool writeData(Ostream&) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/polyDistributionMap/distributionMap.C b/src/OpenFOAM/meshes/polyMesh/polyDistributionMap/distributionMap.C new file mode 100644 index 0000000000..21626cbaeb --- /dev/null +++ b/src/OpenFOAM/meshes/polyMesh/polyDistributionMap/distributionMap.C @@ -0,0 +1,556 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\/ 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 . + +\*---------------------------------------------------------------------------*/ + +#include "distributionMap.H" +#include "globalIndexAndTransform.H" +#include "transformField.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(distributionMap, 0); +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template<> +void Foam::distributionMap::transform::operator() +( + const transformer&, + const bool, + List