sampledSurfaces : avoid crash with empty surfaces

This commit is contained in:
Mark Olesen 2008-05-16 17:00:34 +02:00
parent fb597a1062
commit e5e89deabd
3 changed files with 28 additions and 221 deletions

View File

@ -1,86 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "IOsampledSurfaces.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::IOsampledSurfaces::IOsampledSurfaces
(
const objectRegistry& obr,
const fileName& dictName,
const bool loadFromFiles
)
:
IOdictionary
(
IOobject
(
dictName,
obr.time().system(),
obr,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
sampledSurfaces(obr, *this, loadFromFiles)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::IOsampledSurfaces::~IOsampledSurfaces()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::IOsampledSurfaces::read()
{
if (regIOobject::read())
{
sampledSurfaces::read(*this);
return true;
}
else
{
return false;
}
}
void Foam::IOsampledSurfaces::write()
{
sampledSurfaces::write();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -1,115 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
IOsampledSurfaces
Description
Set of surfaces to sample.
Call surfaces.write() to sample and write files.
SourceFiles
surfaces.C
\*---------------------------------------------------------------------------*/
#ifndef IOsampledSurfaces_H
#define IOsampledSurfaces_H
#include "sampledSurfaces.H"
#include "IOdictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class IOsampledSurfaces Declaration
\*---------------------------------------------------------------------------*/
class IOsampledSurfaces
:
public IOdictionary,
public sampledSurfaces
{
// Private Member Functions
//- Disallow default bitwise copy construct and assignment
IOsampledSurfaces(const IOsampledSurfaces&);
void operator=(const IOsampledSurfaces&);
public:
// Constructors
//- Construct for given objectRegistry and dictionary
// allow the possibility to read from files
IOsampledSurfaces
(
const objectRegistry& obr,
const fileName& dictName = "sampleSurfaceDict",
const bool loadFromFiles = false
);
// Destructor
virtual ~IOsampledSurfaces();
// Member Functions
//- Read the surfaces
virtual bool read();
//- Write the surfaces
virtual void write();
//- Update for changes of mesh
void updateMesh(const mapPolyMesh&)
{
read();
sampledSurfaces::correct(true);
}
//- Update for changes of mesh
void movePoints(const pointField&)
{
read();
sampledSurfaces::correct(true);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -143,31 +143,39 @@ void Foam::sampledSurfaces::sampleAndWrite
}
// Write to time directory under outputPath_
formatter.write
(
outputPath_,
timeDir,
s.name(),
mergeList_[surfI].points,
mergeList_[surfI].faces,
fieldName,
allValues
);
// skip surface without faces (eg, a failed cut-plane)
if (mergeList_[surfI].faces.size())
{
formatter.write
(
outputPath_,
timeDir,
s.name(),
mergeList_[surfI].points,
mergeList_[surfI].faces,
fieldName,
allValues
);
}
}
}
else
{
// Write to time directory under outputPath_
formatter.write
(
outputPath_,
timeDir,
s.name(),
s.points(),
s.faces(),
fieldName,
values
);
// skip surface without faces (eg, a failed cut-plane)
if (s.faces().size())
{
formatter.write
(
outputPath_,
timeDir,
s.name(),
s.points(),
s.faces(),
fieldName,
values
);
}
}
}
}