mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Adding surfaceFields sampling to sampledPatch
This commit is contained in:
@ -28,6 +28,7 @@ License
|
|||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
#include "polyPatch.H"
|
#include "polyPatch.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
|
#include "surfaceFields.H"
|
||||||
|
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
@ -274,6 +275,49 @@ Foam::tmp<Foam::tensorField> Foam::sampledPatch::sample
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::scalarField> Foam::sampledPatch::sample
|
||||||
|
(
|
||||||
|
const surfaceScalarField& sField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return sampleField(sField);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::vectorField> Foam::sampledPatch::sample
|
||||||
|
(
|
||||||
|
const surfaceVectorField& sField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return sampleField(sField);
|
||||||
|
}
|
||||||
|
|
||||||
|
Foam::tmp<Foam::sphericalTensorField> Foam::sampledPatch::sample
|
||||||
|
(
|
||||||
|
const surfaceSphericalTensorField& sField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return sampleField(sField);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::symmTensorField> Foam::sampledPatch::sample
|
||||||
|
(
|
||||||
|
const surfaceSymmTensorField& sField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return sampleField(sField);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::tensorField> Foam::sampledPatch::sample
|
||||||
|
(
|
||||||
|
const surfaceTensorField& sField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return sampleField(sField);
|
||||||
|
}
|
||||||
|
|
||||||
Foam::tmp<Foam::scalarField> Foam::sampledPatch::interpolate
|
Foam::tmp<Foam::scalarField> Foam::sampledPatch::interpolate
|
||||||
(
|
(
|
||||||
const interpolation<scalar>& interpolator
|
const interpolation<scalar>& interpolator
|
||||||
|
|||||||
@ -87,6 +87,13 @@ class sampledPatch
|
|||||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
//- sample surface field on faces
|
||||||
|
template <class Type>
|
||||||
|
tmp<Field<Type> > sampleField
|
||||||
|
(
|
||||||
|
const GeometricField<Type, fvsPatchField, surfaceMesh>& sField
|
||||||
|
) const;
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
tmp<Field<Type> >
|
tmp<Field<Type> >
|
||||||
interpolateField(const interpolation<Type>&) const;
|
interpolateField(const interpolation<Type>&) const;
|
||||||
@ -203,6 +210,35 @@ public:
|
|||||||
const volTensorField&
|
const volTensorField&
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
//- Surface sample field on surface
|
||||||
|
virtual tmp<scalarField> sample
|
||||||
|
(
|
||||||
|
const surfaceScalarField&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Surface Sample field on surface
|
||||||
|
virtual tmp<vectorField> sample
|
||||||
|
(
|
||||||
|
const surfaceVectorField&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Surface sample field on surface
|
||||||
|
virtual tmp<sphericalTensorField> sample
|
||||||
|
(
|
||||||
|
const surfaceSphericalTensorField&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Surface sample field on surface
|
||||||
|
virtual tmp<symmTensorField> sample
|
||||||
|
(
|
||||||
|
const surfaceSymmTensorField&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Surface sample field on surface
|
||||||
|
virtual tmp<tensorField> sample
|
||||||
|
(
|
||||||
|
const surfaceTensorField&
|
||||||
|
) const;
|
||||||
|
|
||||||
//- interpolate field on surface
|
//- interpolate field on surface
|
||||||
virtual tmp<scalarField> interpolate
|
virtual tmp<scalarField> interpolate
|
||||||
|
|||||||
@ -48,6 +48,27 @@ Foam::sampledPatch::sampleField
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Type>
|
||||||
|
Foam::tmp<Foam::Field<Type> >
|
||||||
|
Foam::sampledPatch::sampleField
|
||||||
|
(
|
||||||
|
const GeometricField<Type, fvsPatchField, surfaceMesh>& sField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// One value per face
|
||||||
|
tmp<Field<Type> > tvalues(new Field<Type>(patchFaceLabels_.size()));
|
||||||
|
Field<Type>& values = tvalues();
|
||||||
|
|
||||||
|
forAll(patchFaceLabels_, i)
|
||||||
|
{
|
||||||
|
label patchI = patchIDs_[patchIndex_[i]];
|
||||||
|
values[i] = sField.boundaryField()[patchI][patchFaceLabels_[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return tvalues;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
Foam::tmp<Foam::Field<Type> >
|
Foam::tmp<Foam::Field<Type> >
|
||||||
Foam::sampledPatch::interpolateField
|
Foam::sampledPatch::interpolateField
|
||||||
|
|||||||
@ -240,6 +240,55 @@ Foam::scalar Foam::sampledSurface::area() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::scalarField> Foam::sampledSurface::sample
|
||||||
|
(
|
||||||
|
const surfaceScalarField& sField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
notImplemented("tmp<Foam::scalarField> sampledSurface::sample");
|
||||||
|
return tmp<scalarField>(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::vectorField> Foam::sampledSurface::sample
|
||||||
|
(
|
||||||
|
const surfaceVectorField& sField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
notImplemented("tmp<Foam::vectorField> sampledSurface::sample");
|
||||||
|
return tmp<vectorField>(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
Foam::tmp<Foam::sphericalTensorField> Foam::sampledSurface::sample
|
||||||
|
(
|
||||||
|
const surfaceSphericalTensorField& sField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
notImplemented("tmp<Foam::sphericalTensorField> sampledSurface::sample");
|
||||||
|
return tmp<sphericalTensorField>(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::symmTensorField> Foam::sampledSurface::sample
|
||||||
|
(
|
||||||
|
const surfaceSymmTensorField& sField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
notImplemented("tmp<Foam::symmTensorField> sampledSurface::sample");
|
||||||
|
return tmp<symmTensorField>(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::tensorField> Foam::sampledSurface::sample
|
||||||
|
(
|
||||||
|
const surfaceTensorField& sField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
notImplemented("tmp<Foam::tensorField> sampledSurface::sample");
|
||||||
|
return tmp<tensorField>(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::tmp<Foam::Field<Foam::scalar> >
|
Foam::tmp<Foam::Field<Foam::scalar> >
|
||||||
Foam::sampledSurface::project(const Field<scalar>& field) const
|
Foam::sampledSurface::project(const Field<scalar>& field) const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -57,6 +57,8 @@ SourceFiles
|
|||||||
#include "runTimeSelectionTables.H"
|
#include "runTimeSelectionTables.H"
|
||||||
#include "autoPtr.H"
|
#include "autoPtr.H"
|
||||||
#include "volFieldsFwd.H"
|
#include "volFieldsFwd.H"
|
||||||
|
#include "surfaceFieldsFwd.H"
|
||||||
|
#include "surfaceMesh.H"
|
||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
#include "coordinateSystems.H"
|
#include "coordinateSystems.H"
|
||||||
#include "interpolation.H"
|
#include "interpolation.H"
|
||||||
@ -352,6 +354,35 @@ public:
|
|||||||
const volTensorField&
|
const volTensorField&
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
|
//- Surface sample field on surface
|
||||||
|
virtual tmp<scalarField> sample
|
||||||
|
(
|
||||||
|
const surfaceScalarField&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Surface Sample field on surface
|
||||||
|
virtual tmp<vectorField> sample
|
||||||
|
(
|
||||||
|
const surfaceVectorField&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Surface sample field on surface
|
||||||
|
virtual tmp<sphericalTensorField> sample
|
||||||
|
(
|
||||||
|
const surfaceSphericalTensorField&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Surface sample field on surface
|
||||||
|
virtual tmp<symmTensorField> sample
|
||||||
|
(
|
||||||
|
const surfaceSymmTensorField&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Surface sample field on surface
|
||||||
|
virtual tmp<tensorField> sample
|
||||||
|
(
|
||||||
|
const surfaceTensorField&
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Interpolate field on surface
|
//- Interpolate field on surface
|
||||||
virtual tmp<scalarField> interpolate
|
virtual tmp<scalarField> interpolate
|
||||||
|
|||||||
@ -95,12 +95,7 @@ Foam::sampledSurfaces::sampledSurfaces
|
|||||||
fieldSelection_(),
|
fieldSelection_(),
|
||||||
interpolationScheme_(word::null),
|
interpolationScheme_(word::null),
|
||||||
mergeList_(),
|
mergeList_(),
|
||||||
formatter_(NULL),
|
formatter_(NULL)
|
||||||
scalarFields_(),
|
|
||||||
vectorFields_(),
|
|
||||||
sphericalTensorFields_(),
|
|
||||||
symmTensorFields_(),
|
|
||||||
tensorFields_()
|
|
||||||
{
|
{
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
@ -154,13 +149,6 @@ void Foam::sampledSurfaces::write()
|
|||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "timeName = " << mesh_.time().timeName() << nl
|
|
||||||
<< "scalarFields " << scalarFields_ << nl
|
|
||||||
<< "vectorFields " << vectorFields_ << nl
|
|
||||||
<< "sphTensorFields " << sphericalTensorFields_ << nl
|
|
||||||
<< "symTensorFields " << symmTensorFields_ <<nl
|
|
||||||
<< "tensorFields " << tensorFields_ <<nl;
|
|
||||||
|
|
||||||
Pout<< "Creating directory "
|
Pout<< "Creating directory "
|
||||||
<< outputPath_/mesh_.time().timeName() << nl << endl;
|
<< outputPath_/mesh_.time().timeName() << nl << endl;
|
||||||
|
|
||||||
@ -176,11 +164,19 @@ void Foam::sampledSurfaces::write()
|
|||||||
writeGeometry();
|
writeGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleAndWrite(scalarFields_);
|
const IOobjectList objects(mesh_, mesh_.time().timeName());
|
||||||
sampleAndWrite(vectorFields_);
|
|
||||||
sampleAndWrite(sphericalTensorFields_);
|
sampleAndWrite<volScalarField>(objects);
|
||||||
sampleAndWrite(symmTensorFields_);
|
sampleAndWrite<volVectorField>(objects);
|
||||||
sampleAndWrite(tensorFields_);
|
sampleAndWrite<volSphericalTensorField>(objects);
|
||||||
|
sampleAndWrite<volSymmTensorField>(objects);
|
||||||
|
sampleAndWrite<volTensorField>(objects);
|
||||||
|
|
||||||
|
sampleAndWrite<surfaceScalarField>(objects);
|
||||||
|
sampleAndWrite<surfaceVectorField>(objects);
|
||||||
|
sampleAndWrite<surfaceSphericalTensorField>(objects);
|
||||||
|
sampleAndWrite<surfaceSymmTensorField>(objects);
|
||||||
|
sampleAndWrite<surfaceTensorField>(objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,9 @@ SourceFiles
|
|||||||
#include "sampledSurface.H"
|
#include "sampledSurface.H"
|
||||||
#include "surfaceWriter.H"
|
#include "surfaceWriter.H"
|
||||||
#include "volFieldsFwd.H"
|
#include "volFieldsFwd.H"
|
||||||
|
#include "surfaceFieldsFwd.H"
|
||||||
#include "wordReList.H"
|
#include "wordReList.H"
|
||||||
|
#include "IOobjectList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -60,21 +62,6 @@ class sampledSurfaces
|
|||||||
{
|
{
|
||||||
// Private classes
|
// Private classes
|
||||||
|
|
||||||
//- Class used for grouping field types
|
|
||||||
template<class Type>
|
|
||||||
class fieldGroup
|
|
||||||
:
|
|
||||||
public DynamicList<word>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
//- Construct null
|
|
||||||
fieldGroup()
|
|
||||||
:
|
|
||||||
DynamicList<word>(0)
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//- Class used for surface merging information
|
//- Class used for surface merging information
|
||||||
class mergeInfo
|
class mergeInfo
|
||||||
@ -137,13 +124,6 @@ class sampledSurfaces
|
|||||||
//- Surface formatter
|
//- Surface formatter
|
||||||
autoPtr<surfaceWriter> formatter_;
|
autoPtr<surfaceWriter> formatter_;
|
||||||
|
|
||||||
//- Categorized scalar/vector/tensor fields
|
|
||||||
fieldGroup<scalar> scalarFields_;
|
|
||||||
fieldGroup<vector> vectorFields_;
|
|
||||||
fieldGroup<sphericalTensor> sphericalTensorFields_;
|
|
||||||
fieldGroup<symmTensor> symmTensorFields_;
|
|
||||||
fieldGroup<tensor> tensorFields_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -159,13 +139,33 @@ class sampledSurfaces
|
|||||||
//- Write geometry only
|
//- Write geometry only
|
||||||
void writeGeometry() const;
|
void writeGeometry() const;
|
||||||
|
|
||||||
|
//- Write sampled fieldName on surface and on outputDir path
|
||||||
|
template<class Type>
|
||||||
|
void writeSurface
|
||||||
|
(
|
||||||
|
const Field<Type>& values,
|
||||||
|
const label surfI,
|
||||||
|
const word& fieldName,
|
||||||
|
const fileName& outputDir
|
||||||
|
);
|
||||||
|
|
||||||
//- Sample and write a particular volume field
|
//- Sample and write a particular volume field
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void sampleAndWrite(const GeometricField<Type, fvPatchField, volMesh>&);
|
void sampleAndWrite
|
||||||
|
(
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Sample and write a particular surface field
|
||||||
|
template<class Type>
|
||||||
|
void sampleAndWrite
|
||||||
|
(
|
||||||
|
const GeometricField<Type, fvsPatchField, surfaceMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Sample and write all the fields of the given type
|
//- Sample and write all the fields of the given type
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void sampleAndWrite(fieldGroup<Type>&);
|
void sampleAndWrite(const IOobjectList& allObjects);
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct and assignment
|
//- Disallow default bitwise copy construct and assignment
|
||||||
sampledSurfaces(const sampledSurfaces&);
|
sampledSurfaces(const sampledSurfaces&);
|
||||||
|
|||||||
@ -30,94 +30,22 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::sampledSurfaces::clearFieldGroups()
|
|
||||||
{
|
|
||||||
scalarFields_.clear();
|
|
||||||
vectorFields_.clear();
|
|
||||||
sphericalTensorFields_.clear();
|
|
||||||
symmTensorFields_.clear();
|
|
||||||
tensorFields_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::sampledSurfaces::appendFieldGroup
|
|
||||||
(
|
|
||||||
const word& fieldName,
|
|
||||||
const word& fieldType
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (fieldType == volScalarField::typeName)
|
|
||||||
{
|
|
||||||
scalarFields_.append(fieldName);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (fieldType == volVectorField::typeName)
|
|
||||||
{
|
|
||||||
vectorFields_.append(fieldName);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (fieldType == volSphericalTensorField::typeName)
|
|
||||||
{
|
|
||||||
sphericalTensorFields_.append(fieldName);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (fieldType == volSymmTensorField::typeName)
|
|
||||||
{
|
|
||||||
symmTensorFields_.append(fieldName);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (fieldType == volTensorField::typeName)
|
|
||||||
{
|
|
||||||
tensorFields_.append(fieldName);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::sampledSurfaces::classifyFields()
|
Foam::label Foam::sampledSurfaces::classifyFields()
|
||||||
{
|
{
|
||||||
label nFields = 0;
|
|
||||||
clearFieldGroups();
|
|
||||||
|
|
||||||
// check files for a particular time
|
// check files for a particular time
|
||||||
if (loadFromFiles_)
|
if (loadFromFiles_)
|
||||||
{
|
{
|
||||||
IOobjectList objects(mesh_, mesh_.time().timeName());
|
IOobjectList objects(mesh_, mesh_.time().timeName());
|
||||||
wordList allFields = objects.sortedNames();
|
wordList allFields = objects.sortedNames();
|
||||||
|
|
||||||
labelList indices = findStrings(fieldSelection_, allFields);
|
labelList indices = findStrings(fieldSelection_, allFields);
|
||||||
|
return indices.size();
|
||||||
forAll(indices, fieldI)
|
|
||||||
{
|
|
||||||
const word& fieldName = allFields[indices[fieldI]];
|
|
||||||
|
|
||||||
nFields += appendFieldGroup
|
|
||||||
(
|
|
||||||
fieldName,
|
|
||||||
objects.find(fieldName)()->headerClassName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wordList allFields = mesh_.sortedNames();
|
wordList allFields = mesh_.sortedNames();
|
||||||
labelList indices = findStrings(fieldSelection_, allFields);
|
labelList indices = findStrings(fieldSelection_, allFields);
|
||||||
|
return indices.size();
|
||||||
forAll(indices, fieldI)
|
|
||||||
{
|
|
||||||
const word& fieldName = allFields[indices[fieldI]];
|
|
||||||
|
|
||||||
nFields += appendFieldGroup
|
|
||||||
(
|
|
||||||
fieldName,
|
|
||||||
mesh_.find(fieldName)()->type()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return nFields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -25,46 +25,22 @@ License
|
|||||||
|
|
||||||
#include "sampledSurfaces.H"
|
#include "sampledSurfaces.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
|
#include "surfaceFields.H"
|
||||||
#include "ListListOps.H"
|
#include "ListListOps.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::sampledSurfaces::sampleAndWrite
|
void Foam::sampledSurfaces::writeSurface
|
||||||
(
|
(
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
const Field<Type>& values,
|
||||||
|
const label surfI,
|
||||||
|
const word& fieldName,
|
||||||
|
const fileName& outputDir
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// interpolator for this field
|
|
||||||
autoPtr< interpolation<Type> > interpolator;
|
|
||||||
|
|
||||||
const word& fieldName = vField.name();
|
|
||||||
const fileName outputDir = outputPath_/vField.time().timeName();
|
|
||||||
|
|
||||||
forAll(*this, surfI)
|
|
||||||
{
|
|
||||||
const sampledSurface& s = operator[](surfI);
|
const sampledSurface& s = operator[](surfI);
|
||||||
|
|
||||||
Field<Type> values;
|
|
||||||
|
|
||||||
if (s.interpolate())
|
|
||||||
{
|
|
||||||
if (interpolator.empty())
|
|
||||||
{
|
|
||||||
interpolator = interpolation<Type>::New
|
|
||||||
(
|
|
||||||
interpolationScheme_,
|
|
||||||
vField
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
values = s.interpolate(interpolator());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
values = s.sample(vField);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Collect values from all processors
|
// Collect values from all processors
|
||||||
@ -126,63 +102,102 @@ void Foam::sampledSurfaces::sampleAndWrite
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::sampledSurfaces::sampleAndWrite
|
void Foam::sampledSurfaces::sampleAndWrite
|
||||||
(
|
(
|
||||||
fieldGroup<Type>& fields
|
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (fields.size())
|
// interpolator for this field
|
||||||
|
autoPtr< interpolation<Type> > interpolator;
|
||||||
|
|
||||||
|
const word& fieldName = vField.name();
|
||||||
|
const fileName outputDir = outputPath_/vField.time().timeName();
|
||||||
|
|
||||||
|
forAll(*this, surfI)
|
||||||
{
|
{
|
||||||
forAll(fields, fieldI)
|
const sampledSurface& s = operator[](surfI);
|
||||||
|
|
||||||
|
Field<Type> values;
|
||||||
|
|
||||||
|
if (s.interpolate())
|
||||||
|
{
|
||||||
|
if (interpolator.empty())
|
||||||
|
{
|
||||||
|
interpolator = interpolation<Type>::New
|
||||||
|
(
|
||||||
|
interpolationScheme_,
|
||||||
|
vField
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
values = s.interpolate(interpolator());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
values = s.sample(vField);
|
||||||
|
}
|
||||||
|
|
||||||
|
writeSurface<Type>(values, surfI, fieldName, outputDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::sampledSurfaces::sampleAndWrite
|
||||||
|
(
|
||||||
|
const GeometricField<Type, fvsPatchField, surfaceMesh>& sField
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const word& fieldName = sField.name();
|
||||||
|
const fileName outputDir = outputPath_/sField.time().timeName();
|
||||||
|
|
||||||
|
forAll(*this, surfI)
|
||||||
|
{
|
||||||
|
const sampledSurface& s = operator[](surfI);
|
||||||
|
Field<Type> values = s.sample(sField);
|
||||||
|
writeSurface<Type>(values, surfI, fieldName, outputDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class GeoField>
|
||||||
|
void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& allObjects)
|
||||||
|
{
|
||||||
|
IOobjectList fields = allObjects.lookupClass(GeoField::typeName);
|
||||||
|
forAllConstIter(IOobjectList, fields, fieldIter)
|
||||||
|
{
|
||||||
|
forAll (fieldSelection_, fieldI)
|
||||||
|
{
|
||||||
|
const wordRe field = fieldSelection_[fieldI];
|
||||||
|
if (field.match(fieldIter()->name()))
|
||||||
{
|
{
|
||||||
if (Pstream::master() && verbose_)
|
if (Pstream::master() && verbose_)
|
||||||
{
|
{
|
||||||
Pout<< "sampleAndWrite: " << fields[fieldI] << endl;
|
Pout<< "sampleAndWrite: " << field << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadFromFiles_)
|
if (loadFromFiles_)
|
||||||
{
|
{
|
||||||
|
fieldIter()->readOpt() = IOobject::MUST_READ;
|
||||||
sampleAndWrite
|
sampleAndWrite
|
||||||
(
|
(
|
||||||
GeometricField<Type, fvPatchField, volMesh>
|
GeoField
|
||||||
(
|
(
|
||||||
IOobject
|
*fieldIter(),
|
||||||
(
|
|
||||||
fields[fieldI],
|
|
||||||
mesh_.time().timeName(),
|
|
||||||
mesh_,
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
false
|
|
||||||
),
|
|
||||||
mesh_
|
mesh_
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
objectRegistry::const_iterator iter =
|
|
||||||
mesh_.find(fields[fieldI]);
|
|
||||||
|
|
||||||
if
|
|
||||||
(
|
|
||||||
iter != objectRegistry::end()
|
|
||||||
&& iter()->type()
|
|
||||||
== GeometricField<Type, fvPatchField, volMesh>::typeName
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
sampleAndWrite
|
sampleAndWrite
|
||||||
(
|
(
|
||||||
mesh_.lookupObject
|
mesh_.lookupObject<GeoField>(fieldIter()->name())
|
||||||
<GeometricField<Type, fvPatchField, volMesh> >
|
|
||||||
(
|
|
||||||
fields[fieldI]
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user