Commit fee05a23 authored by Andrew Heather's avatar Andrew Heather
Browse files
parents 422849b4 f0d9dbfb
......@@ -60,7 +60,7 @@ void subsetVolFields
Info<< "Subsetting field " << fieldName << endl;
GeometricField<Type, fvPatchField, volMesh> volField
GeometricField<Type, fvPatchField, volMesh> fld
(
IOobject
(
......@@ -73,7 +73,7 @@ void subsetVolFields
baseMesh
);
subFields.set(i, subsetter.interpolate(volField));
subFields.set(i, subsetter.interpolate(fld));
}
}
......@@ -94,7 +94,7 @@ void subsetSurfaceFields
Info<< "Subsetting field " << fieldName << endl;
GeometricField<Type, fvsPatchField, surfaceMesh> volField
GeometricField<Type, fvsPatchField, surfaceMesh> fld
(
IOobject
(
......@@ -107,7 +107,42 @@ void subsetSurfaceFields
baseMesh
);
subFields.set(i, subsetter.interpolate(volField));
subFields.set(i, subsetter.interpolate(fld));
}
}
template<class Type>
void subsetPointFields
(
const fvMeshSubset& subsetter,
const pointMesh& pMesh,
const wordList& fieldNames,
PtrList<GeometricField<Type, pointPatchField, pointMesh> >& subFields
)
{
const fvMesh& baseMesh = subsetter.baseMesh();
forAll(fieldNames, i)
{
const word& fieldName = fieldNames[i];
Info<< "Subsetting field " << fieldName << endl;
GeometricField<Type, pointPatchField, pointMesh> fld
(
IOobject
(
fieldName,
baseMesh.time().timeName(),
baseMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
pMesh
);
subFields.set(i, subsetter.interpolate(fld));
}
}
......@@ -163,7 +198,9 @@ int main(int argc, char *argv[])
IOobjectList objects(mesh, runTime.timeName());
// Read vol fields and subset.
// Read vol fields and subset
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
wordList scalarNames(objects.names(volScalarField::typeName));
PtrList<volScalarField> scalarFlds(scalarNames.size());
......@@ -191,7 +228,9 @@ int main(int argc, char *argv[])
PtrList<volTensorField> tensorFlds(tensorNames.size());
subsetVolFields(subsetter, tensorNames, tensorFlds);
// Read surface fields and subset.
// Read surface fields and subset
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wordList surfScalarNames(objects.names(surfaceScalarField::typeName));
PtrList<surfaceScalarField> surfScalarFlds(surfScalarNames.size());
......@@ -231,6 +270,59 @@ int main(int argc, char *argv[])
subsetSurfaceFields(subsetter, surfTensorNames, surfTensorFlds);
// Read point fields and subset
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pointMesh pMesh(mesh);
wordList pointScalarNames(objects.names(pointScalarField::typeName));
PtrList<pointScalarField> pointScalarFlds(pointScalarNames.size());
subsetPointFields(subsetter, pMesh, pointScalarNames, pointScalarFlds);
wordList pointVectorNames(objects.names(pointVectorField::typeName));
PtrList<pointVectorField> pointVectorFlds(pointVectorNames.size());
subsetPointFields(subsetter, pMesh, pointVectorNames, pointVectorFlds);
wordList pointSphericalTensorNames
(
objects.names(pointSphericalTensorField::typeName)
);
PtrList<pointSphericalTensorField> pointSphericalTensorFlds
(
pointSphericalTensorNames.size()
);
subsetPointFields
(
subsetter,
pMesh,
pointSphericalTensorNames,
pointSphericalTensorFlds
);
wordList pointSymmTensorNames
(
objects.names(pointSymmTensorField::typeName)
);
PtrList<pointSymmTensorField> pointSymmTensorFlds
(
pointSymmTensorNames.size()
);
subsetPointFields
(
subsetter,
pMesh,
pointSymmTensorNames,
pointSymmTensorFlds
);
wordList pointTensorNames(objects.names(pointTensorField::typeName));
PtrList<pointTensorField> pointTensorFlds(pointTensorNames.size());
subsetPointFields(subsetter, pMesh, pointTensorNames, pointTensorFlds);
// Write mesh and fields to new time
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
runTime++;
......@@ -252,6 +344,18 @@ int main(int argc, char *argv[])
vectorFlds[i].write();
}
forAll(sphericalTensorFlds, i)
{
sphericalTensorFlds[i].rename(sphericalTensorNames[i]);
sphericalTensorFlds[i].write();
}
forAll(symmTensorFlds, i)
{
symmTensorFlds[i].rename(symmTensorNames[i]);
symmTensorFlds[i].write();
}
forAll(tensorFlds, i)
{
tensorFlds[i].rename(tensorNames[i]);
......@@ -272,6 +376,18 @@ int main(int argc, char *argv[])
surfVectorFlds[i].write();
}
forAll(surfSphericalTensorFlds, i)
{
surfSphericalTensorFlds[i].rename(surfSphericalTensorNames[i]);
surfSphericalTensorFlds[i].write();
}
forAll(surfSymmTensorFlds, i)
{
surfSymmTensorFlds[i].rename(surfSymmTensorNames[i]);
surfSymmTensorFlds[i].write();
}
forAll(surfTensorNames, i)
{
surfTensorFlds[i].rename(surfTensorNames[i]);
......@@ -279,6 +395,39 @@ int main(int argc, char *argv[])
surfTensorFlds[i].write();
}
// Point ones
forAll(pointScalarFlds, i)
{
pointScalarFlds[i].rename(pointScalarNames[i]);
pointScalarFlds[i].write();
}
forAll(pointVectorFlds, i)
{
pointVectorFlds[i].rename(pointVectorNames[i]);
pointVectorFlds[i].write();
}
forAll(pointSphericalTensorFlds, i)
{
pointSphericalTensorFlds[i].rename(pointSphericalTensorNames[i]);
pointSphericalTensorFlds[i].write();
}
forAll(pointSymmTensorFlds, i)
{
pointSymmTensorFlds[i].rename(pointSymmTensorNames[i]);
pointSymmTensorFlds[i].write();
}
forAll(pointTensorNames, i)
{
pointTensorFlds[i].rename(pointTensorNames[i]);
pointTensorFlds[i].write();
}
Info << nl << "End" << endl;
return 0;
......
......@@ -469,7 +469,6 @@ int main(int argc, char *argv[])
// Construct pointMesh only if nessecary since constructs edge
// addressing (expensive on polyhedral meshes)
autoPtr<pointMesh> pMeshPtr(NULL);
if (noPointValues)
{
Info<< " pointScalarFields : switched off"
......@@ -477,10 +476,6 @@ int main(int argc, char *argv[])
Info<< " pointVectorFields : switched off"
<< " (\"-noPointValues\" option)\n";
}
else
{
pMeshPtr.reset(new pointMesh(mesh));
}
PtrList<pointScalarField> psf;
PtrList<pointVectorField> pvf;
......@@ -488,21 +483,56 @@ int main(int argc, char *argv[])
PtrList<pointSymmTensorField> pSymmtf;
PtrList<pointTensorField> ptf;
if (pMeshPtr.valid())
if (!noPointValues)
{
readFields(pMeshPtr(), objects, selectedFields, psf);
readFields
(
vMesh,
vMesh.basePointMesh(),
objects,
selectedFields,
psf
);
print(" pointScalarFields :", Info, psf);
readFields(pMeshPtr(), objects, selectedFields, pvf);
readFields
(
vMesh,
vMesh.basePointMesh(),
objects,
selectedFields,
pvf
);
print(" pointVectorFields :", Info, pvf);
readFields(pMeshPtr(), objects, selectedFields, pSpheretf);
readFields
(
vMesh,
vMesh.basePointMesh(),
objects,
selectedFields,
pSpheretf
);
print(" pointSphericalTensorFields :", Info, pSpheretf);
readFields(pMeshPtr(), objects, selectedFields, pSymmtf);
readFields
(
vMesh,
vMesh.basePointMesh(),
objects,
selectedFields,
pSymmtf
);
print(" pointSymmTensorFields :", Info, pSymmtf);
readFields(pMeshPtr(), objects, selectedFields, ptf);
readFields
(
vMesh,
vMesh.basePointMesh(),
objects,
selectedFields,
ptf
);
print(" pointTensorFields :", Info, ptf);
}
Info<< endl;
......@@ -550,7 +580,7 @@ int main(int argc, char *argv[])
writer.write(vSymmtf);
writer.write(vtf);
if (pMeshPtr.valid())
if (!noPointValues)
{
writeFuns::writePointDataHeader
(
......@@ -567,7 +597,7 @@ int main(int argc, char *argv[])
writer.write(ptf);
// Interpolated volFields
volPointInterpolation pInterp(mesh, pMeshPtr());
volPointInterpolation pInterp(mesh, vMesh.pMesh());
writer.write(pInterp, vsf);
writer.write(pInterp, vvf);
writer.write(pInterp, vSpheretf);
......@@ -705,7 +735,7 @@ int main(int argc, char *argv[])
writer.write(vSymmtf);
writer.write(vtf);
if (pMeshPtr.valid())
if (!noPointValues)
{
writeFuns::writePointDataHeader
(
......@@ -785,7 +815,7 @@ int main(int argc, char *argv[])
writer.write(vSymmtf);
writer.write(vtf);
if (pMeshPtr.valid())
if (!noPointValues)
{
writeFuns::writePointDataHeader
(
......
......@@ -34,50 +34,6 @@ namespace Foam
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
//template<class GeoField, class Mesh>
template<class GeoField>
void readFields
(
const typename GeoField::Mesh& mesh,
const IOobjectList& objects,
const HashSet<word>& selectedFields,
PtrList<GeoField>& fields
)
{
// Search list of objects for volScalarFields
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
// Construct the vol scalar fields
fields.setSize(fieldObjects.size());
label nFields = 0;
for
(
IOobjectList::iterator iter = fieldObjects.begin();
iter != fieldObjects.end();
++iter
)
{
if (!selectedFields.size() || selectedFields.found(iter()->name()))
{
fields.set
(
nFields,
new GeoField
(
*iter(),
mesh
)
);
nFields++;
}
}
fields.setSize(nFields);
}
template<class GeoField>
void readFields
(
......
......@@ -45,16 +45,6 @@ SourceFiles
namespace Foam
{
// Read the fields and put on the pointer list
template<class GeoField>
void readFields
(
const typename GeoField::Mesh& mesh,
const IOobjectList& objects,
const HashSet<word>& selectedFields,
PtrList<GeoField>& fields
);
// Read the fields and optionally subset and put on the pointer list
template<class GeoField>
void readFields
......
......@@ -45,8 +45,7 @@ Foam::vtkMesh::vtkMesh
:
baseMesh_(baseMesh),
subsetter_(baseMesh),
setName_(setName),
topoPtr_(NULL)
setName_(setName)
{
if (setName.size() > 0)
{
......@@ -59,14 +58,6 @@ Foam::vtkMesh::vtkMesh
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::vtkMesh::~vtkMesh()
{
deleteDemandDrivenData(topoPtr_);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate()
......@@ -78,11 +69,11 @@ Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate()
// Note: since fvMeshSubset has no movePoints() functionality reconstruct
// the subset even if only movement.
deleteDemandDrivenData(topoPtr_);
topoPtr_.clear();
if (setName_.size() > 0)
{
Pout<< "Subsetting mesh based on cellSet " << setName_ << endl;
Info<< "Subsetting mesh based on cellSet " << setName_ << endl;
// Read cellSet using whole mesh
cellSet currentSet(baseMesh_, setName_);
......
......@@ -39,6 +39,7 @@ SourceFiles
#include "vtkTopo.H"
#include "fvMeshSubset.H"
#include "pointMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -59,14 +60,17 @@ class vtkMesh
//- Reference to mesh
fvMesh& baseMesh_;
//- Subsetting engine
//- Demand driven pointMesh
mutable autoPtr<pointMesh> pointMeshPtr_;
//- Subsetting engine + sub-fvMesh
fvMeshSubset subsetter_;
//- Current cellSet (or empty)
const word setName_;
//- Current decomposition of topology
mutable vtkTopo* topoPtr_;
mutable autoPtr<vtkTopo> topoPtr_;
......@@ -87,11 +91,6 @@ public:
vtkMesh(fvMesh& baseMesh, const word& setName = "");
// Destructor
~vtkMesh();
// Member Functions
// Access
......@@ -102,6 +101,15 @@ public:
return baseMesh_;
}
const pointMesh& basePointMesh() const
{
if (!pointMeshPtr_.valid())
{
pointMeshPtr_.reset(new pointMesh(baseMesh_));
}
return pointMeshPtr_();
}
const fvMeshSubset& subsetter() const
{
return subsetter_;
......@@ -116,11 +124,11 @@ public:
//- topology
const vtkTopo& topo() const
{
if (!topoPtr_)
if (!topoPtr_.valid())
{
topoPtr_ = new vtkTopo(mesh());
topoPtr_.reset(new vtkTopo(mesh()));
}
return *topoPtr_;
return topoPtr_();
}
//- Access either mesh or submesh
......@@ -136,6 +144,19 @@ public:
}
}
//- Access either pointMesh of base or pointMesh of subset
const pointMesh& pMesh() const
{
if (useSubMesh())
{
return subsetter_.subPointMesh();
}
else
{
return basePointMesh();
}
}
//- Number of field cells
label nFieldCells() const
{
......@@ -145,7 +166,7 @@ public:
//- Number of field points
label nFieldPoints() const
{
return mesh().nPoints() + topo().addPointCellLabels().size();
return pMesh().size() + topo().addPointCellLabels().size();
}
......@@ -171,7 +192,6 @@ public:
return fld;
}
}
};
......
......@@ -81,14 +81,17 @@ public:
// Public static data
// this must be consistent with the enumeration in "vtkCell.H"
static const label VTK_TRIANGLE = 5;
static const label VTK_POLYGON = 7;
static const label VTK_QUAD = 9;
static const label VTK_TETRA = 10;
static const label VTK_PYRAMID = 14;
static const label VTK_WEDGE = 13;
static const label VTK_HEXAHEDRON = 12;
enum vtkTypes
{
VTK_TRIANGLE = 5,
VTK_POLYGON = 7,
VTK_QUAD = 9,
VTK_TETRA = 10,
VTK_PYRAMID = 14,
VTK_WEDGE = 13,
VTK_HEXAHEDRON = 12,
};
// Constructors
......
......@@ -66,7 +66,7 @@ basicSymmetryPointPatchField<Type>::basicSymmetryPointPatchField
const pointPatchFieldMapper&
)
:
pointPatchField<Type>(ptf, iF)
pointPatchField<Type>(p, iF)
{}
......
......@@ -72,7 +72,7 @@ calculatedPointPatchField<Type>::calculatedPointPatchField
const pointPatchFieldMapper&
)
:
pointPatchField<Type>(ptf, iF)
pointPatchField<Type>(p, iF)