ENH: surfMesh::setWriteOption to adjust the write option of all components

- otherwise difficult to avoid auto-write etc.

- propagate similar changes to MeshedSurfaceAllocator, where is makes
  the most sense.
This commit is contained in:
Mark Olesen
2016-12-01 15:07:16 +01:00
parent 7b450a2915
commit 46e396af49
4 changed files with 85 additions and 11 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -72,8 +72,32 @@ Foam::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::MeshedSurfaceIOAllocator::~MeshedSurfaceIOAllocator()
{
clear();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::MeshedSurfaceIOAllocator::setInstance(const fileName& inst)
{
points_.instance() = inst;
faces_.instance() = inst;
zones_.instance() = inst;
}
void Foam::MeshedSurfaceIOAllocator::setWriteOption(IOobject::writeOption w)
{
points_.writeOpt() = w;
faces_.writeOpt() = w;
zones_.writeOpt() = w;
}
void Foam::MeshedSurfaceIOAllocator::clear()
{
points_.clear();
@ -136,4 +160,20 @@ void Foam::MeshedSurfaceIOAllocator::reset
}
bool Foam::MeshedSurfaceIOAllocator::writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const
{
return
(
points_.writeObject(fmt, ver, cmp)
&& faces_.writeObject(fmt, ver, cmp)
&& zones_.writeObject(fmt, ver, cmp)
);
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -106,8 +106,21 @@ public:
);
//- Destructor
virtual ~MeshedSurfaceIOAllocator();
// Member Functions
// Database
//- Set the instance for mesh files
void setInstance(const fileName&);
//- Adjust the write option for all components
void setWriteOption(IOobject::writeOption);
// Access
//- Non-const access to the points
@ -177,6 +190,18 @@ public:
const Xfer<faceList>& faces,
const Xfer<surfZoneList>& zones
);
// Writing
//- Write using given format, version and compression
virtual bool writeObject
(
IOstream::streamFormat,
IOstream::versionNumber,
IOstream::compressionType
) const;
};

View File

@ -200,7 +200,14 @@ public:
const fileName& facesInstance() const;
//- Set the instance for mesh files
void setInstance(const fileName&);
void setInstance
(
const fileName&,
IOobject::writeOption = IOobject::AUTO_WRITE
);
//- Adjust the write option for all components
void setWriteOption(IOobject::writeOption);
// Access
@ -322,6 +329,7 @@ public:
//- Remove all files from mesh instance()
void removeFiles() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,7 +28,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfMesh::setInstance(const fileName& inst)
void Foam::surfMesh::setInstance(const fileName& inst, IOobject::writeOption w)
{
if (debug)
{
@ -36,15 +36,16 @@ void Foam::surfMesh::setInstance(const fileName& inst)
}
instance() = inst;
Allocator::setInstance(inst);
storedIOPoints().writeOpt() = IOobject::AUTO_WRITE;
storedIOPoints().instance() = inst;
setWriteOption(w);
}
storedIOFaces().writeOpt() = IOobject::AUTO_WRITE;
storedIOFaces().instance() = inst;
storedIOZones().writeOpt() = IOobject::AUTO_WRITE;
storedIOZones().instance() = inst;
void Foam::surfMesh::setWriteOption(IOobject::writeOption w)
{
writeOpt() = w;
Allocator::setWriteOption(w);
}