Commit 1fc2a732 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: use meshedSurf API for surface writers (issue #104)

- Allows passing of additional information (per-face zone ids) or possibly
  other things, while reducing the number of arguments to pass.

- In sampledTriSurfaceMesh, preserve the region information that was
  read in, passing it onwards via the UnsortedMeshSurface content.

  The Nastran surface writer is currently the only writer making use
  of this per-face zone information.
  Passing it through as a PSHELL attribute, which should retain the
  distinction for parts. (issue #204)
parent eee0dd02
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -289,8 +289,11 @@ Foam::tmp<Foam::triSurfacePointScalarField> Foam::automatic::load()
(
surface_.searchableSurface::time().constant()/"triSurface",
surfaceName_.lessExt().name(),
surface_.points(),
faces,
meshedSurfRef
(
surface_.points(),
faces
),
"cellSize",
pointCellSize,
true,
......
......@@ -9,5 +9,4 @@ EXE_INC = \
EXE_LIBS = \
-lmeshTools \
-lsampling \
-lsurfMesh \
-ldynamicMesh
......@@ -1019,8 +1019,11 @@ Foam::label Foam::checkGeometry
(
"postProcessing",
"src_" + tmName,
mergedPoints,
mergedFaces,
meshedSurfRef
(
mergedPoints,
mergedFaces
),
"weightsSum",
mergedWeights,
false
......@@ -1066,8 +1069,11 @@ Foam::label Foam::checkGeometry
(
"postProcessing",
"tgt_" + tmName,
mergedPoints,
mergedFaces,
meshedSurfRef
(
mergedPoints,
mergedFaces
),
"weightsSum",
mergedWeights,
false
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -42,6 +42,7 @@ License
#include "globalIndex.H"
#include "PatchTools.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
{
......@@ -238,7 +239,16 @@ void Foam::mergeAndWrite
// Write
if (Pstream::master())
{
writer.write(outputDir, name, mergedPoints, mergedFaces);
writer.write
(
outputDir,
name,
meshedSurfRef
(
mergedPoints,
mergedFaces
)
);
}
}
else
......@@ -247,8 +257,11 @@ void Foam::mergeAndWrite
(
outputDir,
name,
setPatch.localPoints(),
setPatch.localFaces()
meshedSurfRef
(
setPatch.localPoints(),
setPatch.localFaces()
)
);
}
}
......
......@@ -2,6 +2,7 @@ EXE_INC = \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -95,8 +95,11 @@ void writeWeights
(
directory,
prefix + "_" + timeName,
mergedPoints,
mergedFaces,
meshedSurfRef
(
mergedPoints,
mergedFaces
),
"weightsSum",
mergedWeights,
false
......
......@@ -7,5 +7,4 @@ EXE_INC = \
EXE_LIBS = \
-lsampling \
-ltriSurface \
-lsurfMesh \
-lmeshTools
......@@ -228,8 +228,11 @@ void writeZoning
(
surfFilePath,
surfFileNameBase,
surf.points(),
faces,
meshedSurfRef
(
surf.points(),
faces
),
fieldName,
scalarFaceZone,
false // face based data
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -1643,8 +1643,11 @@ int main(int argc, char *argv[])
(
runTime.constantPath()/"triSurface",// outputDir
sFeatFileName, // surfaceName
surf.points(),
faces,
meshedSurfRef
(
surf.points(),
faces
),
"internalCloseness", // fieldName
internalCloseness,
false, // isNodeValues
......@@ -1655,8 +1658,11 @@ int main(int argc, char *argv[])
(
runTime.constantPath()/"triSurface",// outputDir
sFeatFileName, // surfaceName
surf.points(),
faces,
meshedSurfRef
(
surf.points(),
faces
),
"externalCloseness", // fieldName
externalCloseness,
false, // isNodeValues
......@@ -1691,8 +1697,11 @@ int main(int argc, char *argv[])
(
runTime.constantPath()/"triSurface",// outputDir
sFeatFileName, // surfaceName
surf.points(),
faces,
meshedSurfRef
(
surf.points(),
faces
),
"curvature", // fieldName
k,
true, // isNodeValues
......@@ -1769,8 +1778,11 @@ int main(int argc, char *argv[])
(
runTime.constantPath()/"triSurface",// outputDir
sFeatFileName, // surfaceName
surf.points(),
faces,
meshedSurfRef
(
surf.points(),
faces
),
"featureProximity", // fieldName
featureProximity,
false, // isNodeValues
......
......@@ -328,8 +328,11 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
(
outputDir(),
regionTypeNames_[regionType_] + ("_" + regionName_),
points,
faces,
meshedSurfRef
(
points,
faces
),
fieldName,
allValues,
false
......
......@@ -17,6 +17,7 @@ EXE_INC = \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -204,8 +204,7 @@ void Foam::FacePostProcessing<CloudType>::write()
(
this->writeTimeDir(),
fZone.name(),
allPoints,
allFaces,
meshedSurfRef(allPoints, allFaces),
"massTotal",
zoneMassTotal[zoneI],
false
......@@ -215,8 +214,7 @@ void Foam::FacePostProcessing<CloudType>::write()
(
this->writeTimeDir(),
fZone.name(),
allPoints,
allFaces,
meshedSurfRef(allPoints, allFaces),
"massFlowRate",
zoneMassFlowRate[zoneI],
false
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -409,10 +409,10 @@ void Foam::ParticleCollector<CloudType>::write()
Info<< type() << " output:" << nl;
Field<scalar> faceMassTotal(mass_.size(), 0.0);
Field<scalar> faceMassTotal(mass_.size(), Zero);
this->getModelProperty("massTotal", faceMassTotal);
Field<scalar> faceMassFlowRate(massFlowRate_.size(), 0.0);
Field<scalar> faceMassFlowRate(massFlowRate_.size(), Zero);
this->getModelProperty("massFlowRate", faceMassFlowRate);
......@@ -467,8 +467,7 @@ void Foam::ParticleCollector<CloudType>::write()
(
this->writeTimeDir(),
"collector",
points_,
faces_,
meshedSurfRef(points_, faces_),
"massTotal",
faceMassTotal,
false
......@@ -478,8 +477,7 @@ void Foam::ParticleCollector<CloudType>::write()
(
this->writeTimeDir(),
"collector",
points_,
faces_,
meshedSurfRef(points_, faces_),
"massFlowRate",
faceMassFlowRate,
false
......@@ -490,7 +488,7 @@ void Foam::ParticleCollector<CloudType>::write()
if (resetOnWrite_)
{
Field<scalar> dummy(faceMassTotal.size(), 0.0);
Field<scalar> dummy(faceMassTotal.size(), Zero);
this->setModelProperty("massTotal", dummy);
this->setModelProperty("massFlowRate", dummy);
......
......@@ -22,6 +22,7 @@ EXE_INC = \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
......
......@@ -290,12 +290,16 @@ Foam::scalar surfaceNoise::writeSurfaceData
}
}
// could also have meshedSurface implement meshedSurf
fileName outFileName = writerPtr_->write
(
outDir,
fName,
surf.points(),
surf.surfFaces(),
meshedSurfRef
(
surf.points(),
surf.surfFaces()
),
title,
allData,
false
......@@ -313,12 +317,16 @@ Foam::scalar surfaceNoise::writeSurfaceData
{
const meshedSurface& surf = readerPtr_->geometry();
// could also have meshedSurface implement meshedSurf
writerPtr_->write
(
outDir,
fName,
surf.points(),
surf.surfFaces(),
meshedSurfRef
(
surf.points(),
surf.surfFaces()
),
title,
data,
false
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -193,6 +193,12 @@ public:
return facesPtr_;
}
//- Const access to per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
}
//- Face area vectors
virtual const vectorField& Sf() const
{
......@@ -212,6 +218,7 @@ public:
}
//- The underlying surface
const triSurface& surface() const
{
if (cell_)
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -199,6 +199,12 @@ public:
return facesPtr_;
}
//- Const access to per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
}
//- Face area magnitudes
virtual const vectorField& Sf() const
{
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -168,6 +168,12 @@ public:
return facesPtr_;
}
//- Const access to per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
}
//- Face area magnitudes
virtual const vectorField& Sf() const
{
......
......@@ -333,7 +333,7 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
Info<< "binary" << endl;
}
}
ensightReadFile is(baseDir_/meshFileName_, streamFormat_);
......@@ -343,7 +343,7 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
}
readGeometryHeader(is);
label nPoints;
is.read(nPoints);
......
......@@ -88,7 +88,7 @@ Foam::tmp<Foam::Field<Type> > Foam::ensightSurfaceReader::readField
const word indexStr = oss.str();
fieldFileName.replace(maskStr, indexStr);
ensightReadFile is(baseDir_/fieldFileName, streamFormat_);
if (!is.good())
......@@ -102,7 +102,7 @@ Foam::tmp<Foam::Field<Type> > Foam::ensightSurfaceReader::readField
// Check that data type is as expected
string primitiveType;
is.read(primitiveType);
if (debug)
{
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -182,6 +182,12 @@ public:
return facesPtr_;
}
//- Const access to per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
}
//- Face area magnitudes
virtual const vectorField& Sf() const
{
......
......@@ -180,6 +180,12 @@ public:
return MeshStorage::surfFaces();
}
//- Const access to per-face zone/region information
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
}
//- Face area vectors
virtual const vectorField& Sf() const
{
......
......@@ -140,6 +140,13 @@ public:
return cuttingPlane::surfFaces();
}
//- Const access to per-face zone/region information
// Could instead return meshCells or cellZoneId of the meshCells.
virtual const labelList& zoneIds() const
{
return Foam::emptyLabelList;
}
//- Face area magnitudes
virtual const vectorField& Sf() const
{
......
......@@ -52,7 +52,7 @@ SourceFiles
#ifndef sampledSurface_H
#define sampledSurface_H
#include "pointField.H"
#include "meshedSurf.H"
#include "word.H"
#include "labelList.H"
#include "faceList.H"
......@@ -83,6 +83,8 @@ Ostream& operator<<(Ostream&, const sampledSurface&);
\*---------------------------------------------------------------------------*/
class sampledSurface
:
public meshedSurf
{
// Private data
......
......@@ -72,20 +72,17 @@ void Foam::sampledSurfaces::writeGeometry() const
(
outputDir,
s.name(),
mergeList_[surfI].points,
mergeList_[surfI].faces
meshedSurfRef
(
mergeList_[surfI].points,
mergeList_[surfI].faces
)
);
}
}
else if (s.faces().size())
{
formatter_->write
(
outputDir,
s.name(),
s.points(),
s.faces()
);
formatter_->write(outputDir, s.name(), s);
}
}