ENH: Only read set and surface sampling fields if specified

This commit is contained in:
andy
2011-03-17 10:33:16 +00:00
parent a9109f3e30
commit 8f351e2776
2 changed files with 84 additions and 50 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -231,28 +231,43 @@ void Foam::sampledSets::write()
void Foam::sampledSets::read(const dictionary& dict) void Foam::sampledSets::read(const dictionary& dict)
{ {
dict_ = dict; dict_ = dict;
dict_.lookup("fields") >> fieldSelection_;
clearFieldGroups();
dict.lookup("interpolationScheme") >> interpolationScheme_; bool setsFound = dict_.found("sets");
dict.lookup("setFormat") >> writeFormat_; if (setsFound)
{
dict_.lookup("fields") >> fieldSelection_;
clearFieldGroups();
PtrList<sampledSet> newList dict.lookup("interpolationScheme") >> interpolationScheme_;
( dict.lookup("setFormat") >> writeFormat_;
dict_.lookup("sets"),
sampledSet::iNew(mesh_, searchEngine_) PtrList<sampledSet> newList
); (
transfer(newList); dict_.lookup("sets"),
combineSampledSets(masterSampledSets_, indexSets_); sampledSet::iNew(mesh_, searchEngine_)
);
transfer(newList);
combineSampledSets(masterSampledSets_, indexSets_);
if (this->size())
{
Info<< "Reading set description:" << nl;
forAll(*this, setI)
{
Info<< " " << operator[](setI).name() << nl;
}
Info<< endl;
}
}
if (Pstream::master() && debug) if (Pstream::master() && debug)
{ {
Pout<< "sample fields:" << fieldSelection_ << nl Pout<< "sample fields:" << fieldSelection_ << nl
<< "sample sets:" << nl << "(" << nl; << "sample sets:" << nl << "(" << nl;
forAll(*this, si) forAll(*this, setI)
{ {
Pout<< " " << operator[](si) << endl; Pout<< " " << operator[](setI) << endl;
} }
Pout<< ")" << endl; Pout<< ")" << endl;
} }
@ -261,19 +276,23 @@ void Foam::sampledSets::read(const dictionary& dict)
void Foam::sampledSets::correct() void Foam::sampledSets::correct()
{ {
// reset interpolation bool setsFound = dict_.found("sets");
pointMesh::Delete(mesh_); if (setsFound)
volPointInterpolation::Delete(mesh_); {
// reset interpolation
pointMesh::Delete(mesh_);
volPointInterpolation::Delete(mesh_);
searchEngine_.correct(); searchEngine_.correct();
PtrList<sampledSet> newList PtrList<sampledSet> newList
( (
dict_.lookup("sets"), dict_.lookup("sets"),
sampledSet::iNew(mesh_, searchEngine_) sampledSet::iNew(mesh_, searchEngine_)
); );
transfer(newList); transfer(newList);
combineSampledSets(masterSampledSets_, indexSets_); combineSampledSets(masterSampledSets_, indexSets_);
}
} }

View File

@ -216,34 +216,49 @@ void Foam::sampledSurfaces::write()
void Foam::sampledSurfaces::read(const dictionary& dict) void Foam::sampledSurfaces::read(const dictionary& dict)
{ {
dict.lookup("fields") >> fieldSelection_; bool surfacesFound = dict.found("surfaces");
clearFieldGroups();
dict.lookup("interpolationScheme") >> interpolationScheme_; if (surfacesFound)
const word writeType(dict.lookup("surfaceFormat"));
// define the surface formatter
// optionally defined extra controls for the output formats
formatter_ = surfaceWriter::New
(
writeType,
dict.subOrEmptyDict("formatOptions").subOrEmptyDict(writeType)
);
PtrList<sampledSurface> newList
(
dict.lookup("surfaces"),
sampledSurface::iNew(mesh_)
);
transfer(newList);
if (Pstream::parRun())
{ {
mergeList_.setSize(size()); dict.lookup("fields") >> fieldSelection_;
} clearFieldGroups();
// ensure all surfaces and merge information are expired dict.lookup("interpolationScheme") >> interpolationScheme_;
expire(); const word writeType(dict.lookup("surfaceFormat"));
// define the surface formatter
// optionally defined extra controls for the output formats
formatter_ = surfaceWriter::New
(
writeType,
dict.subOrEmptyDict("formatOptions").subOrEmptyDict(writeType)
);
PtrList<sampledSurface> newList
(
dict.lookup("surfaces"),
sampledSurface::iNew(mesh_)
);
transfer(newList);
if (Pstream::parRun())
{
mergeList_.setSize(size());
}
// ensure all surfaces and merge information are expired
expire();
if (this->size())
{
Info<< "Reading surface description:" << nl;
forAll(*this, surfI)
{
Info<< " " << operator[](surfI).name() << nl;
}
Info<< endl;
}
}
if (Pstream::master() && debug) if (Pstream::master() && debug)
{ {