diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C index aaca4f087c..6d05af02a4 100644 --- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C +++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -259,6 +259,7 @@ Foam::tmp Foam::sampledSurface::sample return tmp(NULL); } + Foam::tmp Foam::sampledSurface::sample ( const surfaceSphericalTensorField& sField diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index f756c97fc7..34d5bd5b96 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -171,17 +171,19 @@ void Foam::sampledSurfaces::write() writeGeometry(); } - sampleAndWrite(); - sampleAndWrite(); - sampleAndWrite(); - sampleAndWrite(); - sampleAndWrite(); + const IOobjectList objects(mesh_, mesh_.time().timeName()); - sampleAndWrite(); - sampleAndWrite(); - sampleAndWrite(); - sampleAndWrite(); - sampleAndWrite(); + sampleAndWrite(objects); + sampleAndWrite(objects); + sampleAndWrite(objects); + sampleAndWrite(objects); + sampleAndWrite(objects); + + sampleAndWrite(objects); + sampleAndWrite(objects); + sampleAndWrite(objects); + sampleAndWrite(objects); + sampleAndWrite(objects); } } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H index 09feb8cb6c..050b2b6e38 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H @@ -89,6 +89,7 @@ class sampledSurfaces //- Tolerance for merging points (fraction of mesh bounding box) static scalar mergeTol_; + // Private data //- Name of this set of surfaces, @@ -113,6 +114,7 @@ class sampledSurfaces //- Interpolation scheme to use word interpolationScheme_; + // surfaces //- Information for merging surfaces @@ -159,7 +161,7 @@ class sampledSurfaces ); //- Sample and write all sampled fields - template void sampleAndWrite(); + template void sampleAndWrite(const IOobjectList& objects); //- Disallow default bitwise copy construct and assignment sampledSurfaces(const sampledSurfaces&); @@ -233,7 +235,6 @@ public: //- Update for changes of mesh due to readUpdate - expires the surfaces virtual void readUpdate(const polyMesh::readUpdateState state); - }; diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C index ca0b4428bf..da612afa44 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C @@ -166,36 +166,26 @@ void Foam::sampledSurfaces::sampleAndWrite template -void Foam::sampledSurfaces::sampleAndWrite() +void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& objects) { - DynamicList fields; - bool found = false; - forAll (fieldSelection_, fieldI) + if (loadFromFiles_) { - const wordRe field = fieldSelection_[fieldI]; - if (mesh_.thisDb().foundObject(field)) - { - found = true; - fields.append(field); - } - } - if (fields.size() && found) - { - forAll (fields, fieldI) - { - const wordRe field = fields[fieldI]; - if ((Pstream::master()) && verbose_) - { - Pout<< "sampleAndWrite: " << field << endl; - } + IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName)); - if (loadFromFiles_) + forAll(fieldSelection_, fieldI) + { + const wordRe fieldNameRe = fieldSelection_[fieldI]; + IOobjectList fieldIO = fieldObjects.lookupRe(fieldNameRe); + + forAllConstIter(IOobjectList, fieldIO, iter) { - const GeoField geoField + const word& fieldName = iter()->name(); + + const GeoField fld ( IOobject ( - field, + fieldName, mesh_.time().timeName(), mesh_, IOobject::MUST_READ @@ -203,13 +193,38 @@ void Foam::sampledSurfaces::sampleAndWrite() mesh_ ); - sampleAndWrite(geoField); + if ((Pstream::master()) && verbose_) + { + Pout<< "sampleAndWrite: " << fieldName << endl; + } + + sampleAndWrite(fld); } - else + } + } + else + { + forAll(fieldSelection_, fieldI) + { + const wordRe& fieldNameRe = fieldSelection_[fieldI]; + + const wordList dbFields + ( + mesh_.thisDb().foundObjectRe(fieldNameRe) + ); + + forAll(dbFields, i) { + const word& fieldName = dbFields[i]; + + if ((Pstream::master()) && verbose_) + { + Pout<< "sampleAndWrite: " << fieldName << endl; + } + sampleAndWrite ( - mesh_.thisDb().lookupObject(field) + mesh_.thisDb().lookupObject(fieldName) ); } }