subsetting point fields

This commit is contained in:
mattijs
2008-05-23 11:06:43 +01:00
parent bc84848b6d
commit ffa939952c
23 changed files with 544 additions and 196 deletions

View File

@ -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
(

View File

@ -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
(

View File

@ -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

View File

@ -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_);

View File

@ -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;
}
}
};

View File

@ -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;
enum vtkTypes
{
VTK_TRIANGLE = 5,
VTK_POLYGON = 7,
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;
VTK_TETRA = 10,
VTK_PYRAMID = 14,
VTK_WEDGE = 13,
VTK_HEXAHEDRON = 12,
};
// Constructors