Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
commit
bde3edacd3
@ -32,6 +32,7 @@ Description
|
||||
#include "volFields.H"
|
||||
#include "PatchEdgeFaceWave.H"
|
||||
#include "patchEdgeFaceInfo.H"
|
||||
#include "patchDist.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -49,80 +50,115 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Get name of patch
|
||||
const word patchName = args[1];
|
||||
|
||||
const polyPatch& patch = patches[patchName];
|
||||
|
||||
// Data on all edges and faces
|
||||
List<patchEdgeFaceInfo> allEdgeInfo(patch.nEdges());
|
||||
List<patchEdgeFaceInfo> allFaceInfo(patch.size());
|
||||
|
||||
// Initial seed
|
||||
DynamicList<label> initialEdges;
|
||||
DynamicList<patchEdgeFaceInfo> initialEdgesInfo;
|
||||
|
||||
|
||||
// Just set an edge on the master
|
||||
if (Pstream::master())
|
||||
// 1. Walk from a single edge
|
||||
{
|
||||
label edgeI = 0;
|
||||
Info<< "Starting walk on edge " << edgeI << endl;
|
||||
// Data on all edges and faces
|
||||
List<patchEdgeFaceInfo> allEdgeInfo(patch.nEdges());
|
||||
List<patchEdgeFaceInfo> allFaceInfo(patch.size());
|
||||
|
||||
initialEdges.append(edgeI);
|
||||
const edge& e = patch.edges()[edgeI];
|
||||
initialEdgesInfo.append
|
||||
(
|
||||
patchEdgeFaceInfo
|
||||
// Initial seed
|
||||
DynamicList<label> initialEdges;
|
||||
DynamicList<patchEdgeFaceInfo> initialEdgesInfo;
|
||||
|
||||
|
||||
// Just set an edge on the master
|
||||
if (Pstream::master())
|
||||
{
|
||||
label edgeI = 0;
|
||||
Info<< "Starting walk on edge " << edgeI << endl;
|
||||
|
||||
initialEdges.append(edgeI);
|
||||
const edge& e = patch.edges()[edgeI];
|
||||
initialEdgesInfo.append
|
||||
(
|
||||
e.centre(patch.localPoints()),
|
||||
0.0
|
||||
)
|
||||
);
|
||||
}
|
||||
patchEdgeFaceInfo
|
||||
(
|
||||
e.centre(patch.localPoints()),
|
||||
0.0
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Walk
|
||||
PatchEdgeFaceWave
|
||||
<
|
||||
primitivePatch,
|
||||
patchEdgeFaceInfo
|
||||
> calc
|
||||
(
|
||||
mesh,
|
||||
patch,
|
||||
initialEdges,
|
||||
initialEdgesInfo,
|
||||
allEdgeInfo,
|
||||
allFaceInfo,
|
||||
returnReduce(patch.nEdges(), sumOp<label>())
|
||||
);
|
||||
|
||||
|
||||
// Extract as patchField
|
||||
volScalarField vsf
|
||||
(
|
||||
IOobject
|
||||
// Walk
|
||||
PatchEdgeFaceWave
|
||||
<
|
||||
primitivePatch,
|
||||
patchEdgeFaceInfo
|
||||
> calc
|
||||
(
|
||||
"patchDist",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("patchDist", dimLength, 0.0)
|
||||
);
|
||||
scalarField pf(vsf.boundaryField()[patch.index()].size());
|
||||
forAll(pf, faceI)
|
||||
{
|
||||
pf[faceI] = Foam::sqrt(allFaceInfo[faceI].distSqr());
|
||||
patch,
|
||||
initialEdges,
|
||||
initialEdgesInfo,
|
||||
allEdgeInfo,
|
||||
allFaceInfo,
|
||||
returnReduce(patch.nEdges(), sumOp<label>())
|
||||
);
|
||||
|
||||
|
||||
// Extract as patchField
|
||||
volScalarField vsf
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"patchDist",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("patchDist", dimLength, 0.0)
|
||||
);
|
||||
scalarField pf(vsf.boundaryField()[patch.index()].size());
|
||||
forAll(pf, faceI)
|
||||
{
|
||||
pf[faceI] = Foam::sqrt(allFaceInfo[faceI].distSqr());
|
||||
}
|
||||
vsf.boundaryField()[patch.index()] = pf;
|
||||
|
||||
Info<< "Writing patchDist volScalarField to " << runTime.value()
|
||||
<< endl;
|
||||
|
||||
vsf.write();
|
||||
}
|
||||
vsf.boundaryField()[patch.index()] = pf;
|
||||
|
||||
Info<< "Writing patchDist volScalarField to " << runTime.value()
|
||||
<< endl;
|
||||
|
||||
vsf.write();
|
||||
// 2. Use a wrapper to walk from all boundary edges on selected patches
|
||||
{
|
||||
labelHashSet otherPatchIDs(identity(mesh.boundaryMesh().size()));
|
||||
otherPatchIDs.erase(patch.index());
|
||||
|
||||
Info<< "Walking on patch " << patch.index()
|
||||
<< " from edges shared with patches " << otherPatchIDs
|
||||
<< endl;
|
||||
|
||||
patchDist pwd(patch, otherPatchIDs);
|
||||
|
||||
// Extract as patchField
|
||||
volScalarField vsf
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"otherPatchDist",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("otherPatchDist", dimLength, 0.0)
|
||||
);
|
||||
vsf.boundaryField()[patch.index()] = pwd;
|
||||
|
||||
Info<< "Writing otherPatchDist volScalarField to " << runTime.value()
|
||||
<< endl;
|
||||
|
||||
vsf.write();
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
return 0;
|
||||
|
@ -459,6 +459,11 @@ autoPtr<mapPolyMesh> reorderMesh
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addNote
|
||||
(
|
||||
"Renumber mesh to minimise bandwidth"
|
||||
);
|
||||
|
||||
argList::addOption
|
||||
(
|
||||
"blockSize",
|
||||
@ -479,6 +484,11 @@ int main(int argc, char *argv[])
|
||||
# include "addRegionOption.H"
|
||||
# include "addOverwriteOption.H"
|
||||
# include "addTimeOptions.H"
|
||||
argList::addBoolOption
|
||||
(
|
||||
"dict",
|
||||
"renumber according to system/renumberMeshDict"
|
||||
);
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
@ -495,6 +505,9 @@ int main(int argc, char *argv[])
|
||||
# include "createNamedMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
const bool readDict = args.optionFound("dict");
|
||||
|
||||
|
||||
label blockSize = 0;
|
||||
args.optionReadIfPresent("blockSize", blockSize, 0);
|
||||
|
||||
@ -539,28 +552,29 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
// Construct renumberMethod
|
||||
IOobject io
|
||||
(
|
||||
"renumberMeshDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
autoPtr<renumberMethod> renumberPtr;
|
||||
|
||||
if (io.headerOk())
|
||||
if (readDict)
|
||||
{
|
||||
Info<< "Detected local " << runTime.system()/io.name() << "." << nl
|
||||
<< "Using this to select renumberMethod." << nl << endl;
|
||||
renumberPtr = renumberMethod::New(IOdictionary(io));
|
||||
Info<< "Renumber according to renumberMeshDict." << nl << endl;
|
||||
|
||||
IOdictionary renumberDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"renumberMeshDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
renumberPtr = renumberMethod::New(renumberDict);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "No local " << runTime.system()/io.name()
|
||||
<< " dictionary found. Using default renumberMethod." << nl
|
||||
<< endl;
|
||||
Info<< "Using default renumberMethod." << nl << endl;
|
||||
dictionary renumberDict;
|
||||
renumberPtr.reset(new CuthillMcKeeRenumber(renumberDict));
|
||||
}
|
||||
|
@ -211,7 +211,8 @@ FoamFile
|
||||
// source patchToFace;
|
||||
// sourceInfo
|
||||
// {
|
||||
// name ".*Wall"; // Name of patch, regular expressions allowed
|
||||
// name ".*Wall"; // Name of patch or patch group,
|
||||
// // (regular expressions allowed)
|
||||
// }
|
||||
//
|
||||
// // All faces of faceZone
|
||||
|
@ -20,6 +20,7 @@ FoamFile
|
||||
// gnuplot
|
||||
// raw
|
||||
// vtk
|
||||
// ensight
|
||||
// csv
|
||||
setFormat raw;
|
||||
|
||||
|
@ -59,6 +59,8 @@ License
|
||||
#include "upwindFECCellToFaceStencilObject.H"
|
||||
|
||||
#include "centredCFCFaceToCellStencilObject.H"
|
||||
#include "meshSearchMeshObject.H"
|
||||
#include "meshSearchFACECENTRETETSMeshObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -99,6 +101,11 @@ void Foam::fvMesh::clearGeom()
|
||||
CentredFitData<quadraticLinearFitPolynomial>::Delete(*this);
|
||||
skewCorrectionVectors::Delete(*this);
|
||||
//quadraticFitSnGradData::Delete(*this);
|
||||
|
||||
// Note: should be in polyMesh::clearGeom but meshSearch not in OpenFOAM
|
||||
// library
|
||||
meshSearchMeshObject::Delete(*this);
|
||||
meshSearchFACECENTRETETSMeshObject::Delete(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -128,6 +135,11 @@ void Foam::fvMesh::clearAddressing()
|
||||
upwindFECCellToFaceStencilObject::Delete(*this);
|
||||
|
||||
centredCFCFaceToCellStencilObject::Delete(*this);
|
||||
|
||||
// Note: should be in polyMesh::clearGeom but meshSearch not in OpenFOAM
|
||||
// library
|
||||
meshSearchMeshObject::Delete(*this);
|
||||
meshSearchFACECENTRETETSMeshObject::Delete(*this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,6 +27,8 @@ polyMeshZipUpCells/polyMeshZipUpCells.C
|
||||
primitiveMeshGeometry/primitiveMeshGeometry.C
|
||||
|
||||
meshSearch/meshSearch.C
|
||||
meshSearch/meshSearchFACECENTRETETSMeshObject.C
|
||||
meshSearch/meshSearchMeshObject.C
|
||||
|
||||
meshTools/meshTools.C
|
||||
|
||||
@ -39,6 +41,7 @@ $(pWave)/pointEdgePoint.C
|
||||
patchWave = $(algorithms)/PatchEdgeFaceWave
|
||||
$(patchWave)/PatchEdgeFaceWaveName.C
|
||||
$(patchWave)/patchEdgeFaceInfo.C
|
||||
$(patchWave)/patchDist.C
|
||||
|
||||
meshWave = $(algorithms)/MeshWave
|
||||
$(meshWave)/MeshWaveName.C
|
||||
|
173
src/meshTools/algorithms/PatchEdgeFaceWave/patchDist.C
Normal file
173
src/meshTools/algorithms/PatchEdgeFaceWave/patchDist.C
Normal file
@ -0,0 +1,173 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "patchDist.H"
|
||||
#include "PatchEdgeFaceWave.H"
|
||||
#include "syncTools.H"
|
||||
#include "polyMesh.H"
|
||||
#include "patchEdgeFaceInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::patchDist::patchDist
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const labelHashSet& nbrPatchIDs
|
||||
)
|
||||
:
|
||||
patch_(patch),
|
||||
nbrPatchIDs_(nbrPatchIDs),
|
||||
nUnset_(0)
|
||||
{
|
||||
patchDist::correct();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::patchDist::~patchDist()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::patchDist::correct()
|
||||
{
|
||||
// Mark all edge connected to a nbrPatch.
|
||||
label nBnd = 0;
|
||||
forAllConstIter(labelHashSet, nbrPatchIDs_, iter)
|
||||
{
|
||||
label nbrPatchI = iter.key();
|
||||
const polyPatch& nbrPatch = patch_.boundaryMesh()[nbrPatchI];
|
||||
nBnd += nbrPatch.nEdges()-nbrPatch.nInternalEdges();
|
||||
}
|
||||
|
||||
// Mark all edges. Note: should use HashSet but have no syncTools
|
||||
// functionality for these.
|
||||
EdgeMap<label> nbrEdges(2*nBnd);
|
||||
|
||||
forAllConstIter(labelHashSet, nbrPatchIDs_, iter)
|
||||
{
|
||||
label nbrPatchI = iter.key();
|
||||
const polyPatch& nbrPatch = patch_.boundaryMesh()[nbrPatchI];
|
||||
const labelList& nbrMp = nbrPatch.meshPoints();
|
||||
|
||||
for
|
||||
(
|
||||
label edgeI = nbrPatch.nInternalEdges();
|
||||
edgeI < nbrPatch.nEdges();
|
||||
edgeI++
|
||||
)
|
||||
{
|
||||
const edge& e = nbrPatch.edges()[edgeI];
|
||||
const edge meshE = edge(nbrMp[e[0]], nbrMp[e[1]]);
|
||||
nbrEdges.insert(meshE, nbrPatchI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Make sure these boundary edges are marked everywhere.
|
||||
syncTools::syncEdgeMap
|
||||
(
|
||||
patch_.boundaryMesh().mesh(),
|
||||
nbrEdges,
|
||||
maxEqOp<label>()
|
||||
);
|
||||
|
||||
|
||||
// Data on all edges and faces
|
||||
List<patchEdgeFaceInfo> allEdgeInfo(patch_.nEdges());
|
||||
List<patchEdgeFaceInfo> allFaceInfo(patch_.size());
|
||||
|
||||
// Initial seed
|
||||
label nBndEdges = patch_.nEdges() - patch_.nInternalEdges();
|
||||
DynamicList<label> initialEdges(2*nBndEdges);
|
||||
DynamicList<patchEdgeFaceInfo> initialEdgesInfo(2*nBndEdges);
|
||||
|
||||
|
||||
// Seed all my edges that are also nbrEdges
|
||||
|
||||
const labelList& mp = patch_.meshPoints();
|
||||
|
||||
for
|
||||
(
|
||||
label edgeI = patch_.nInternalEdges();
|
||||
edgeI < patch_.nEdges();
|
||||
edgeI++
|
||||
)
|
||||
{
|
||||
const edge& e = patch_.edges()[edgeI];
|
||||
const edge meshE = edge(mp[e[0]], mp[e[1]]);
|
||||
EdgeMap<label>::const_iterator edgeFnd = nbrEdges.find(meshE);
|
||||
if (edgeFnd != nbrEdges.end())
|
||||
{
|
||||
initialEdges.append(edgeI);
|
||||
initialEdgesInfo.append
|
||||
(
|
||||
patchEdgeFaceInfo
|
||||
(
|
||||
e.centre(patch_.localPoints()),
|
||||
0.0
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Walk
|
||||
PatchEdgeFaceWave
|
||||
<
|
||||
primitivePatch,
|
||||
patchEdgeFaceInfo
|
||||
> calc
|
||||
(
|
||||
patch_.boundaryMesh().mesh(),
|
||||
patch_,
|
||||
initialEdges,
|
||||
initialEdgesInfo,
|
||||
allEdgeInfo,
|
||||
allFaceInfo,
|
||||
returnReduce(patch_.nEdges(), sumOp<label>())
|
||||
);
|
||||
|
||||
|
||||
// Extract into *this
|
||||
setSize(patch_.size());
|
||||
nUnset_ = 0;
|
||||
forAll(allFaceInfo, faceI)
|
||||
{
|
||||
if (allFaceInfo[faceI].valid(calc.data()))
|
||||
{
|
||||
operator[](faceI) = Foam::sqrt(allFaceInfo[faceI].distSqr());
|
||||
}
|
||||
else
|
||||
{
|
||||
nUnset_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
114
src/meshTools/algorithms/PatchEdgeFaceWave/patchDist.H
Normal file
114
src/meshTools/algorithms/PatchEdgeFaceWave/patchDist.H
Normal file
@ -0,0 +1,114 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::patchDist
|
||||
|
||||
Description
|
||||
Like wallDist but calculates on patch distance to nearest neighbouring
|
||||
patches. Uses PatchEdgeFaceWave to do actual calculation.
|
||||
|
||||
SourceFiles
|
||||
patchDist.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef patchDist_H
|
||||
#define patchDist_H
|
||||
|
||||
#include "scalarField.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
//class polyMesh;
|
||||
class polyPatch;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class patchDist Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class patchDist
|
||||
:
|
||||
public scalarField
|
||||
{
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Data
|
||||
|
||||
//- Patch to operate on
|
||||
const polyPatch& patch_;
|
||||
|
||||
//- Patches to determine the distance to
|
||||
const labelHashSet nbrPatchIDs_;
|
||||
|
||||
//- Number of unset faces.
|
||||
label nUnset_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and neighbour patches.
|
||||
patchDist
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const labelHashSet& nbrPatchIDs
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~patchDist();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
const scalarField& y() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
label nUnset() const
|
||||
{
|
||||
return nUnset_;
|
||||
}
|
||||
|
||||
//- Correct for mesh geom/topo changes
|
||||
virtual void correct();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
@ -26,7 +26,7 @@ License
|
||||
#include "mappedPatchBase.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "ListListOps.H"
|
||||
#include "meshSearch.H"
|
||||
#include "meshSearchMeshObject.H"
|
||||
#include "meshTools.H"
|
||||
#include "OFstream.H"
|
||||
#include "Random.H"
|
||||
@ -37,6 +37,7 @@ License
|
||||
#include "Time.H"
|
||||
#include "mapDistribute.H"
|
||||
#include "SubField.H"
|
||||
#include "triPointRef.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -80,64 +81,99 @@ const Foam::NamedEnum<Foam::mappedPatchBase::offsetMode, 3>
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::pointField> Foam::mappedPatchBase::facePoints
|
||||
(
|
||||
const polyPatch& pp
|
||||
) const
|
||||
{
|
||||
const polyMesh& mesh = pp.boundaryMesh().mesh();
|
||||
|
||||
// Force construction of min-tet decomp
|
||||
(void)mesh.tetBasePtIs();
|
||||
|
||||
// Initialise to face-centre
|
||||
tmp<pointField> tfacePoints(new pointField(patch_.size()));
|
||||
pointField& facePoints = tfacePoints();
|
||||
|
||||
forAll(pp, faceI)
|
||||
{
|
||||
facePoints[faceI] = facePoint
|
||||
(
|
||||
mesh,
|
||||
pp.start()+faceI,
|
||||
polyMesh::FACEDIAGTETS
|
||||
).rawPoint();
|
||||
}
|
||||
|
||||
return tfacePoints;
|
||||
}
|
||||
|
||||
|
||||
void Foam::mappedPatchBase::collectSamples
|
||||
(
|
||||
const pointField& facePoints,
|
||||
pointField& samples,
|
||||
labelList& patchFaceProcs,
|
||||
labelList& patchFaces,
|
||||
pointField& patchFc
|
||||
) const
|
||||
{
|
||||
|
||||
// Collect all sample points and the faces they come from.
|
||||
List<pointField> globalFc(Pstream::nProcs());
|
||||
List<pointField> globalSamples(Pstream::nProcs());
|
||||
labelListList globalFaces(Pstream::nProcs());
|
||||
{
|
||||
List<pointField> globalFc(Pstream::nProcs());
|
||||
globalFc[Pstream::myProcNo()] = facePoints;
|
||||
Pstream::gatherList(globalFc);
|
||||
Pstream::scatterList(globalFc);
|
||||
// Rework into straight list
|
||||
patchFc = ListListOps::combine<pointField>
|
||||
(
|
||||
globalFc,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
}
|
||||
|
||||
globalFc[Pstream::myProcNo()] = patch_.faceCentres();
|
||||
globalSamples[Pstream::myProcNo()] = samplePoints();
|
||||
globalFaces[Pstream::myProcNo()] = identity(patch_.size());
|
||||
{
|
||||
List<pointField> globalSamples(Pstream::nProcs());
|
||||
globalSamples[Pstream::myProcNo()] = samplePoints(facePoints);
|
||||
Pstream::gatherList(globalSamples);
|
||||
Pstream::scatterList(globalSamples);
|
||||
// Rework into straight list
|
||||
samples = ListListOps::combine<pointField>
|
||||
(
|
||||
globalSamples,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
}
|
||||
|
||||
// Distribute to all processors
|
||||
Pstream::gatherList(globalSamples);
|
||||
Pstream::scatterList(globalSamples);
|
||||
Pstream::gatherList(globalFaces);
|
||||
Pstream::scatterList(globalFaces);
|
||||
Pstream::gatherList(globalFc);
|
||||
Pstream::scatterList(globalFc);
|
||||
{
|
||||
labelListList globalFaces(Pstream::nProcs());
|
||||
globalFaces[Pstream::myProcNo()] = identity(patch_.size());
|
||||
// Distribute to all processors
|
||||
Pstream::gatherList(globalFaces);
|
||||
Pstream::scatterList(globalFaces);
|
||||
|
||||
// Rework into straight list
|
||||
samples = ListListOps::combine<pointField>
|
||||
(
|
||||
globalSamples,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
patchFaces = ListListOps::combine<labelList>
|
||||
(
|
||||
globalFaces,
|
||||
accessOp<labelList>()
|
||||
);
|
||||
patchFc = ListListOps::combine<pointField>
|
||||
(
|
||||
globalFc,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
|
||||
patchFaceProcs.setSize(patchFaces.size());
|
||||
labelList nPerProc
|
||||
(
|
||||
ListListOps::subSizes
|
||||
patchFaces = ListListOps::combine<labelList>
|
||||
(
|
||||
globalFaces,
|
||||
accessOp<labelList>()
|
||||
)
|
||||
);
|
||||
label sampleI = 0;
|
||||
forAll(nPerProc, procI)
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
for (label i = 0; i < nPerProc[procI]; i++)
|
||||
labelList nPerProc(Pstream::nProcs());
|
||||
nPerProc[Pstream::myProcNo()] = patch_.size();
|
||||
Pstream::gatherList(nPerProc);
|
||||
Pstream::scatterList(nPerProc);
|
||||
|
||||
patchFaceProcs.setSize(patchFaces.size());
|
||||
|
||||
label sampleI = 0;
|
||||
forAll(nPerProc, procI)
|
||||
{
|
||||
patchFaceProcs[sampleI++] = procI;
|
||||
for (label i = 0; i < nPerProc[procI]; i++)
|
||||
{
|
||||
patchFaceProcs[sampleI++] = procI;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -173,8 +209,9 @@ void Foam::mappedPatchBase::findSamples
|
||||
<< sampleModeNames_[mode_] << " mode." << exit(FatalError);
|
||||
}
|
||||
|
||||
// Octree based search engine
|
||||
meshSearch meshSearchEngine(mesh);
|
||||
//- Note: face-diagonal decomposition
|
||||
const meshSearchMeshObject& meshSearchEngine =
|
||||
meshSearchMeshObject::New(mesh);
|
||||
|
||||
forAll(samples, sampleI)
|
||||
{
|
||||
@ -290,8 +327,9 @@ void Foam::mappedPatchBase::findSamples
|
||||
<< sampleModeNames_[mode_] << " mode." << exit(FatalError);
|
||||
}
|
||||
|
||||
// Octree based search engine
|
||||
meshSearch meshSearchEngine(mesh);
|
||||
//- Note: face-diagonal decomposition
|
||||
const meshSearchMeshObject& meshSearchEngine =
|
||||
meshSearchMeshObject::New(mesh);
|
||||
|
||||
forAll(samples, sampleI)
|
||||
{
|
||||
@ -355,23 +393,6 @@ void Foam::mappedPatchBase::findSamples
|
||||
}
|
||||
}
|
||||
|
||||
// Check for samples not being found
|
||||
forAll(nearest, sampleI)
|
||||
{
|
||||
if (!nearest[sampleI].first().hit())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"mappedPatchBase::findSamples"
|
||||
"(const pointField&, labelList&"
|
||||
", labelList&, pointField&)"
|
||||
) << "Did not find sample " << samples[sampleI]
|
||||
<< " on any processor of region " << sampleRegion_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Convert back into proc+local index
|
||||
sampleProcs.setSize(samples.size());
|
||||
sampleIndices.setSize(samples.size());
|
||||
@ -379,21 +400,40 @@ void Foam::mappedPatchBase::findSamples
|
||||
|
||||
forAll(nearest, sampleI)
|
||||
{
|
||||
sampleProcs[sampleI] = nearest[sampleI].second().second();
|
||||
sampleIndices[sampleI] = nearest[sampleI].first().index();
|
||||
sampleLocations[sampleI] = nearest[sampleI].first().hitPoint();
|
||||
if (!nearest[sampleI].first().hit())
|
||||
{
|
||||
sampleProcs[sampleI] = -1;
|
||||
sampleIndices[sampleI] = -1;
|
||||
sampleLocations[sampleI] = vector::max;
|
||||
}
|
||||
else
|
||||
{
|
||||
sampleProcs[sampleI] = nearest[sampleI].second().second();
|
||||
sampleIndices[sampleI] = nearest[sampleI].first().index();
|
||||
sampleLocations[sampleI] = nearest[sampleI].first().hitPoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::mappedPatchBase::calcMapping() const
|
||||
{
|
||||
static bool hasWarned = false;
|
||||
|
||||
if (mapPtr_.valid())
|
||||
{
|
||||
FatalErrorIn("mappedPatchBase::calcMapping() const")
|
||||
<< "Mapping already calculated" << exit(FatalError);
|
||||
}
|
||||
|
||||
// Get points on face (since cannot use face-centres - might be off
|
||||
// face-diagonal decomposed tets.
|
||||
tmp<pointField> patchPoints(facePoints(patch_));
|
||||
|
||||
// Get offsetted points
|
||||
const pointField offsettedPoints = samplePoints(patchPoints());
|
||||
|
||||
|
||||
// Do a sanity check
|
||||
// Am I sampling my own patch? This only makes sense for a non-zero
|
||||
// offset.
|
||||
@ -405,8 +445,10 @@ void Foam::mappedPatchBase::calcMapping() const
|
||||
);
|
||||
|
||||
// Check offset
|
||||
vectorField d(samplePoints()-patch_.faceCentres());
|
||||
if (sampleMyself && gAverage(mag(d)) <= ROOTVSMALL)
|
||||
vectorField d(offsettedPoints-patchPoints());
|
||||
bool coincident = (gAverage(mag(d)) <= ROOTVSMALL);
|
||||
|
||||
if (sampleMyself && coincident)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
@ -438,7 +480,15 @@ void Foam::mappedPatchBase::calcMapping() const
|
||||
labelList patchFaceProcs;
|
||||
labelList patchFaces;
|
||||
pointField patchFc;
|
||||
collectSamples(samples, patchFaceProcs, patchFaces, patchFc);
|
||||
collectSamples
|
||||
(
|
||||
patchPoints,
|
||||
samples,
|
||||
patchFaceProcs,
|
||||
patchFaces,
|
||||
patchFc
|
||||
);
|
||||
|
||||
|
||||
// Find processor and cell/face samples are in and actual location.
|
||||
labelList sampleProcs;
|
||||
@ -446,6 +496,77 @@ void Foam::mappedPatchBase::calcMapping() const
|
||||
pointField sampleLocations;
|
||||
findSamples(samples, sampleProcs, sampleIndices, sampleLocations);
|
||||
|
||||
// Check for samples that were not found. This will only happen for
|
||||
// NEARESTCELL since finds cell containing a location
|
||||
if (mode_ == NEARESTCELL)
|
||||
{
|
||||
label nNotFound = 0;
|
||||
forAll(sampleProcs, sampleI)
|
||||
{
|
||||
if (sampleProcs[sampleI] == -1)
|
||||
{
|
||||
nNotFound++;
|
||||
}
|
||||
}
|
||||
reduce(nNotFound, sumOp<label>());
|
||||
|
||||
if (nNotFound > 0)
|
||||
{
|
||||
if (!hasWarned)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"mappedPatchBase::mappedPatchBase\n"
|
||||
"(\n"
|
||||
" const polyPatch& pp,\n"
|
||||
" const word& sampleRegion,\n"
|
||||
" const sampleMode mode,\n"
|
||||
" const word& samplePatch,\n"
|
||||
" const vector& offset\n"
|
||||
")\n"
|
||||
) << "Did not find " << nNotFound
|
||||
<< " out of " << sampleProcs.size() << " total samples."
|
||||
<< " Sampling these on owner cell centre instead." << endl
|
||||
<< "On patch " << patch_.name()
|
||||
<< " on region " << sampleRegion_
|
||||
<< " in mode " << sampleModeNames_[mode_] << endl
|
||||
<< "whilst sampling patch " << samplePatch_ << endl
|
||||
<< " with offset mode " << offsetModeNames_[offsetMode_]
|
||||
<< endl
|
||||
<< "Suppressing further warnings from " << type() << endl;
|
||||
|
||||
hasWarned = true;
|
||||
}
|
||||
|
||||
// Reset the samples that cannot be found to the cell centres.
|
||||
pointField patchCc;
|
||||
{
|
||||
List<pointField> globalCc(Pstream::nProcs());
|
||||
globalCc[Pstream::myProcNo()] = patch_.faceCellCentres();
|
||||
Pstream::gatherList(globalCc);
|
||||
Pstream::scatterList(globalCc);
|
||||
patchCc = ListListOps::combine<pointField>
|
||||
(
|
||||
globalCc,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
}
|
||||
|
||||
forAll(sampleProcs, sampleI)
|
||||
{
|
||||
if (sampleProcs[sampleI] == -1)
|
||||
{
|
||||
// Reset to cell centres
|
||||
samples[sampleI] = patchCc[sampleI];
|
||||
}
|
||||
}
|
||||
|
||||
// And re-search. Note: could be optimised to only search missing
|
||||
// points.
|
||||
findSamples(samples, sampleProcs, sampleIndices, sampleLocations);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now we have all the data we need:
|
||||
// - where sample originates from (so destination when mapping):
|
||||
@ -613,7 +734,7 @@ void Foam::mappedPatchBase::calcAMI() const
|
||||
/*
|
||||
const polyPatch& nbr = samplePolyPatch();
|
||||
|
||||
// pointField nbrPoints(samplePoints());
|
||||
// pointField nbrPoints(offsettedPoints());
|
||||
pointField nbrPoints(nbr.localPoints());
|
||||
|
||||
if (debug)
|
||||
@ -932,9 +1053,12 @@ const Foam::polyPatch& Foam::mappedPatchBase::samplePolyPatch() const
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::pointField> Foam::mappedPatchBase::samplePoints() const
|
||||
Foam::tmp<Foam::pointField> Foam::mappedPatchBase::samplePoints
|
||||
(
|
||||
const pointField& fc
|
||||
) const
|
||||
{
|
||||
tmp<pointField> tfld(new pointField(patch_.faceCentres()));
|
||||
tmp<pointField> tfld(new pointField(fc));
|
||||
pointField& fld = tfld();
|
||||
|
||||
switch (offsetMode_)
|
||||
@ -964,6 +1088,93 @@ Foam::tmp<Foam::pointField> Foam::mappedPatchBase::samplePoints() const
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::pointField> Foam::mappedPatchBase::samplePoints() const
|
||||
{
|
||||
return samplePoints(facePoints(patch_));
|
||||
}
|
||||
|
||||
|
||||
Foam::pointIndexHit Foam::mappedPatchBase::facePoint
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label faceI,
|
||||
const polyMesh::cellRepresentation decompMode
|
||||
)
|
||||
{
|
||||
const point& fc = mesh.faceCentres()[faceI];
|
||||
|
||||
switch (decompMode)
|
||||
{
|
||||
case polyMesh::FACEPLANES:
|
||||
case polyMesh::FACECENTRETETS:
|
||||
{
|
||||
// For both decompositions the face centre is guaranteed to be
|
||||
// on the face
|
||||
return pointIndexHit(true, fc, faceI);
|
||||
}
|
||||
break;
|
||||
|
||||
case polyMesh::FACEDIAGTETS:
|
||||
{
|
||||
// Find the intersection of a ray from face centre to cell
|
||||
// centre
|
||||
// Find intersection of (face-centre-decomposition) centre to
|
||||
// cell-centre with face-diagonal-decomposition triangles.
|
||||
|
||||
const pointField& p = mesh.points();
|
||||
const face& f = mesh.faces()[faceI];
|
||||
|
||||
if (f.size() <= 3)
|
||||
{
|
||||
// Return centre of triangle.
|
||||
return pointIndexHit(true, fc, 0);
|
||||
}
|
||||
|
||||
label cellI = mesh.faceOwner()[faceI];
|
||||
const point& cc = mesh.cellCentres()[cellI];
|
||||
vector d = fc-cc;
|
||||
|
||||
const label fp0 = mesh.tetBasePtIs()[faceI];
|
||||
const point& basePoint = p[f[fp0]];
|
||||
|
||||
label fp = f.fcIndex(fp0);
|
||||
for (label i = 2; i < f.size(); i++)
|
||||
{
|
||||
const point& thisPoint = p[f[fp]];
|
||||
label nextFp = f.fcIndex(fp);
|
||||
const point& nextPoint = p[f[nextFp]];
|
||||
|
||||
const triPointRef tri(basePoint, thisPoint, nextPoint);
|
||||
pointHit hitInfo = tri.intersection
|
||||
(
|
||||
cc,
|
||||
d,
|
||||
intersection::HALF_RAY
|
||||
);
|
||||
|
||||
if (hitInfo.hit() && hitInfo.distance() > 0)
|
||||
{
|
||||
return pointIndexHit(true, hitInfo.hitPoint(), i-2);
|
||||
}
|
||||
|
||||
fp = nextFp;
|
||||
}
|
||||
|
||||
// Fall-back
|
||||
return pointIndexHit(false, fc, -1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
FatalErrorIn("mappedPatchBase::facePoint()")
|
||||
<< "problem" << abort(FatalError);
|
||||
return pointIndexHit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::mappedPatchBase::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("sampleMode") << sampleModeNames_[mode_]
|
||||
|
@ -33,7 +33,7 @@ Description
|
||||
sampleRegion region0;
|
||||
|
||||
// What to sample:
|
||||
// - nearestCell : sample nearest cell
|
||||
// - nearestCell : sample cell containing point
|
||||
// - nearestPatchFace : nearest face on selected patch
|
||||
// - nearestPatchFaceAMI : nearest face on selected patch
|
||||
- patches need not conform
|
||||
@ -204,9 +204,14 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Get the points from face-centre-decomposition face centres
|
||||
// and project them onto the face-diagonal-decomposition triangles.
|
||||
tmp<pointField> facePoints(const polyPatch&) const;
|
||||
|
||||
//- Collect single list of samples and originating processor+face.
|
||||
void collectSamples
|
||||
(
|
||||
const pointField& facePoints,
|
||||
pointField&,
|
||||
labelList& patchFaceProcs,
|
||||
labelList& patchFaces,
|
||||
@ -222,6 +227,9 @@ protected:
|
||||
pointField& sampleLocations // actual representative location
|
||||
) const;
|
||||
|
||||
//- Get the sample points given the face points
|
||||
tmp<pointField> samplePoints(const pointField&) const;
|
||||
|
||||
//- Calculate mapping
|
||||
void calcMapping() const;
|
||||
|
||||
@ -331,9 +339,24 @@ public:
|
||||
//- Get the patch on the region
|
||||
const polyPatch& samplePolyPatch() const;
|
||||
|
||||
// Helpers
|
||||
|
||||
//- Get the sample points
|
||||
tmp<pointField> samplePoints() const;
|
||||
|
||||
//- Get a point on the face given a face decomposition method:
|
||||
// face-centre-tet : face centre. Returns index of face.
|
||||
// face-planes : face centre. Returns index of face.
|
||||
// face-diagonal : intersection of ray from cellcentre to
|
||||
// facecentre with any of the triangles.
|
||||
// Returns index (0..size-2) of triangle.
|
||||
static pointIndexHit facePoint
|
||||
(
|
||||
const polyMesh&,
|
||||
const label faceI,
|
||||
const polyMesh::cellRepresentation
|
||||
);
|
||||
|
||||
|
||||
// Distribute
|
||||
|
||||
|
@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "meshSearchFACECENTRETETSMeshObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(meshSearchFACECENTRETETSMeshObject, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::meshSearchFACECENTRETETSMeshObject::meshSearchFACECENTRETETSMeshObject
|
||||
(
|
||||
const polyMesh& mesh
|
||||
)
|
||||
:
|
||||
MeshObject<polyMesh, meshSearchFACECENTRETETSMeshObject>(mesh),
|
||||
meshSearch(mesh, polyMesh::FACECENTRETETS)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,92 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::meshSearchFACECENTRETETSMeshObject
|
||||
|
||||
Description
|
||||
MeshObject wrapper around meshSearch(mesh, polyMesh::FACECENTRETETS).
|
||||
|
||||
SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef meshSearchFACECENTRETETSMeshObject_H
|
||||
#define meshSearchFACECENTRETETSMeshObject_H
|
||||
|
||||
#include "MeshObject.H"
|
||||
#include "meshSearch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class meshSearchFACECENTRETETSMeshObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class meshSearchFACECENTRETETSMeshObject
|
||||
:
|
||||
public MeshObject<polyMesh, meshSearchFACECENTRETETSMeshObject>,
|
||||
public meshSearch
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Declare name of the class and its debug switch
|
||||
TypeName("meshSearchFACECENTRETETSMeshObject");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Constructor given polyMesh
|
||||
explicit meshSearchFACECENTRETETSMeshObject(const polyMesh& mesh);
|
||||
|
||||
//- Destructor
|
||||
virtual ~meshSearchFACECENTRETETSMeshObject()
|
||||
{}
|
||||
|
||||
//
|
||||
// // Member functions
|
||||
//
|
||||
// // Edit
|
||||
//
|
||||
// //- Update mesh topology using the morph engine
|
||||
// void updateMesh();
|
||||
//
|
||||
// //- Correct weighting factors for moving mesh.
|
||||
// bool movePoints();
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
45
src/meshTools/meshSearch/meshSearchMeshObject.C
Normal file
45
src/meshTools/meshSearch/meshSearchMeshObject.C
Normal file
@ -0,0 +1,45 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "meshSearchMeshObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(meshSearchMeshObject, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::meshSearchMeshObject::meshSearchMeshObject(const polyMesh& mesh)
|
||||
:
|
||||
MeshObject<polyMesh, meshSearchMeshObject>(mesh),
|
||||
meshSearch(mesh)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
92
src/meshTools/meshSearch/meshSearchMeshObject.H
Normal file
92
src/meshTools/meshSearch/meshSearchMeshObject.H
Normal file
@ -0,0 +1,92 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::meshSearchMeshObject
|
||||
|
||||
Description
|
||||
MeshObject wrapper around meshSearch(mesh).
|
||||
|
||||
SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef meshSearchMeshObject_H
|
||||
#define meshSearchMeshObject_H
|
||||
|
||||
#include "MeshObject.H"
|
||||
#include "meshSearch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class meshSearchMeshObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class meshSearchMeshObject
|
||||
:
|
||||
public MeshObject<polyMesh, meshSearchMeshObject>,
|
||||
public meshSearch
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Declare name of the class and its debug switch
|
||||
TypeName("meshSearchMeshObject");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Constructor given polyMesh
|
||||
explicit meshSearchMeshObject(const polyMesh& mesh);
|
||||
|
||||
//- Destructor
|
||||
virtual ~meshSearchMeshObject()
|
||||
{}
|
||||
|
||||
//
|
||||
// // Member functions
|
||||
//
|
||||
// // Edit
|
||||
//
|
||||
// //- Update mesh topology using the morph engine
|
||||
// void updateMesh();
|
||||
//
|
||||
// //- Correct weighting factors for moving mesh.
|
||||
// bool movePoints();
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
@ -247,6 +247,35 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection
|
||||
transform_.setSize(surfI);
|
||||
subGeom_.setSize(surfI);
|
||||
indexOffset_.setSize(surfI+1);
|
||||
|
||||
// Bounds is the overall bounds
|
||||
bounds() = boundBox(point::max, point::min);
|
||||
|
||||
forAll(subGeom_, surfI)
|
||||
{
|
||||
const boundBox& surfBb = subGeom_[surfI].bounds();
|
||||
|
||||
// Transform back to global coordinate sys.
|
||||
const point surfBbMin = transform_[surfI].globalPosition
|
||||
(
|
||||
cmptMultiply
|
||||
(
|
||||
surfBb.min(),
|
||||
scale_[surfI]
|
||||
)
|
||||
);
|
||||
const point surfBbMax = transform_[surfI].globalPosition
|
||||
(
|
||||
cmptMultiply
|
||||
(
|
||||
surfBb.max(),
|
||||
scale_[surfI]
|
||||
)
|
||||
);
|
||||
|
||||
bounds().min() = min(bounds().min(), surfBbMin);
|
||||
bounds().max() = max(bounds().max(), surfBbMax);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -579,6 +608,9 @@ void Foam::searchableSurfaceCollection::getNormal
|
||||
vectorField surfNormal;
|
||||
subGeom_[surfI].getNormal(surfInfo[surfI], surfNormal);
|
||||
|
||||
// Transform back to global coordinate sys.
|
||||
surfNormal = transform_[surfI].globalVector(surfNormal);
|
||||
|
||||
const labelList& map = infoMap[surfI];
|
||||
forAll(map, i)
|
||||
{
|
||||
|
@ -187,6 +187,8 @@ Foam::searchableSurfaceWithGaps::searchableSurfaceWithGaps
|
||||
io.db().lookupObject<searchableSurface>(subGeomName);
|
||||
|
||||
subGeom_.set(0, &const_cast<searchableSurface&>(s));
|
||||
|
||||
bounds() = subGeom_[0].bounds();
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,33 +54,34 @@ Foam::topoSetSource::addToUsageTable Foam::patchToFace::usage_
|
||||
|
||||
void Foam::patchToFace::combine(topoSet& set, const bool add) const
|
||||
{
|
||||
bool hasMatched = false;
|
||||
labelHashSet patchIDs = mesh_.boundaryMesh().patchSet
|
||||
(
|
||||
List<wordRe>(1, patchName_),
|
||||
true, // warn if not found
|
||||
true // use patch groups if available
|
||||
);
|
||||
|
||||
forAll(mesh_.boundaryMesh(), patchI)
|
||||
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||
{
|
||||
label patchI = iter.key();
|
||||
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[patchI];
|
||||
|
||||
if (patchName_.match(pp.name()))
|
||||
Info<< " Found matching patch " << pp.name()
|
||||
<< " with " << pp.size() << " faces." << endl;
|
||||
|
||||
for
|
||||
(
|
||||
label faceI = pp.start();
|
||||
faceI < pp.start() + pp.size();
|
||||
faceI++
|
||||
)
|
||||
{
|
||||
Info<< " Found matching patch " << pp.name()
|
||||
<< " with " << pp.size() << " faces." << endl;
|
||||
|
||||
hasMatched = true;
|
||||
|
||||
|
||||
for
|
||||
(
|
||||
label faceI = pp.start();
|
||||
faceI < pp.start() + pp.size();
|
||||
faceI++
|
||||
)
|
||||
{
|
||||
addOrDelete(set, faceI, add);
|
||||
}
|
||||
addOrDelete(set, faceI, add);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasMatched)
|
||||
if (patchIDs.empty())
|
||||
{
|
||||
WarningIn("patchToFace::combine(topoSet&, const bool)")
|
||||
<< "Cannot find any patch named " << patchName_ << endl
|
||||
|
@ -70,13 +70,23 @@ Foam::nearWallFields::nearWallFields
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::nearWallFields::~nearWallFields()
|
||||
{}
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "nearWallFields::~nearWallFields()" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::nearWallFields::read(const dictionary& dict)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "nearWallFields::read(const dictionary&)" << endl;
|
||||
}
|
||||
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
@ -122,6 +132,11 @@ void Foam::nearWallFields::read(const dictionary& dict)
|
||||
|
||||
void Foam::nearWallFields::execute()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "nearWallFields:execute()" << endl;
|
||||
}
|
||||
|
||||
if (active_)
|
||||
{
|
||||
sampleFields(vsf_);
|
||||
@ -135,12 +150,22 @@ void Foam::nearWallFields::execute()
|
||||
|
||||
void Foam::nearWallFields::end()
|
||||
{
|
||||
// Do nothing
|
||||
if (debug)
|
||||
{
|
||||
Info<< "nearWallFields:end()" << endl;
|
||||
}
|
||||
// Update fields
|
||||
execute();
|
||||
}
|
||||
|
||||
|
||||
void Foam::nearWallFields::write()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "nearWallFields:write()" << endl;
|
||||
}
|
||||
|
||||
// Do nothing
|
||||
if (active_)
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ sampledSet/polyLine/polyLineSet.C
|
||||
sampledSet/face/faceOnlySet.C
|
||||
sampledSet/midPoint/midPointSet.C
|
||||
sampledSet/midPointAndFace/midPointAndFaceSet.C
|
||||
/* sampledSet/patchSeed/patchSeedSet.C */
|
||||
sampledSet/sampledSet/sampledSet.C
|
||||
sampledSet/sampledSets/sampledSets.C
|
||||
sampledSet/sampledSets/sampledSetsGrouping.C
|
||||
@ -21,6 +22,7 @@ sampledSet/uniform/uniformSet.C
|
||||
setWriters = sampledSet/writers
|
||||
|
||||
$(setWriters)/writers.C
|
||||
$(setWriters)/ensight/ensightSetWriterRunTime.C
|
||||
$(setWriters)/gnuplot/gnuplotSetWriterRunTime.C
|
||||
$(setWriters)/jplot/jplotSetWriterRunTime.C
|
||||
$(setWriters)/raw/rawSetWriterRunTime.C
|
||||
|
315
src/sampling/sampledSet/writers/ensight/ensightSetWriter.C
Normal file
315
src/sampling/sampledSet/writers/ensight/ensightSetWriter.C
Normal file
@ -0,0 +1,315 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ensightSetWriter.H"
|
||||
#include "coordSet.H"
|
||||
#include "OFstream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "IOmanip.H"
|
||||
#include "foamVersion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::ensightSetWriter<Type>::ensightSetWriter()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::ensightSetWriter<Type>::~ensightSetWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::ensightSetWriter<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return
|
||||
this->getBaseName(points, valueSetNames)
|
||||
//+ '_'
|
||||
//+ pTraits<Type>::typeName
|
||||
+ ".case";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::ensightSetWriter<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
const fileName base(os.name().lessExt());
|
||||
const fileName meshFile(base + ".mesh");
|
||||
|
||||
// Write .case file
|
||||
os << "FORMAT" << nl
|
||||
<< "type: ensight gold" << nl
|
||||
<< nl
|
||||
<< "GEOMETRY" << nl
|
||||
<< "model: 1 " << meshFile.name().c_str() << nl
|
||||
<< nl
|
||||
<< "VARIABLE"
|
||||
<< nl;
|
||||
forAll(valueSetNames, setI)
|
||||
{
|
||||
fileName dataFile(base + ".***." + valueSetNames[setI]);
|
||||
|
||||
os.setf(ios_base::left);
|
||||
os << pTraits<Type>::typeName
|
||||
<< " per node: 1 "
|
||||
<< setw(15) << valueSetNames[setI]
|
||||
<< " " << dataFile.name().c_str()
|
||||
<< nl;
|
||||
}
|
||||
os << nl
|
||||
<< "TIME" << nl
|
||||
<< "time set: 1" << nl
|
||||
<< "number of steps: 1" << nl
|
||||
<< "filename start number: 0" << nl
|
||||
<< "filename increment: 1" << nl
|
||||
<< "time values:" << nl
|
||||
<< "0.00000e+00" << nl;
|
||||
|
||||
// Write .mesh file
|
||||
{
|
||||
string desc = string("written by OpenFOAM-") + Foam::FOAMversion;
|
||||
OFstream os(meshFile);
|
||||
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||
os.precision(5);
|
||||
|
||||
os << "EnSight Geometry File" << nl
|
||||
<< desc.c_str() << nl
|
||||
<< "node id assign" << nl
|
||||
<< "element id assign" << nl
|
||||
<< "part" << nl
|
||||
<< setw(10) << 1 << nl
|
||||
<< "internalMesh" << nl
|
||||
<< "coordinates" << nl
|
||||
<< setw(10) << points.size() << nl;
|
||||
|
||||
for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++)
|
||||
{
|
||||
forAll(points, pointI)
|
||||
{
|
||||
const scalar comp = points[pointI][cmpt];
|
||||
if (mag(comp) >= scalar(floatScalarVSMALL))
|
||||
{
|
||||
os << setw(12) << comp << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << setw(12) << scalar(0) << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
os << "point" << nl
|
||||
<< setw(10) << points.size() << nl;
|
||||
forAll(points, pointI)
|
||||
{
|
||||
os << setw(10) << pointI+1 << nl;
|
||||
}
|
||||
}
|
||||
|
||||
// Write data files
|
||||
forAll(valueSetNames, setI)
|
||||
{
|
||||
fileName dataFile(base + ".000." + valueSetNames[setI]);
|
||||
OFstream os(dataFile);
|
||||
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||
os.precision(5);
|
||||
{
|
||||
os << pTraits<Type>::typeName << nl
|
||||
<< "part" << nl
|
||||
<< setw(10) << 1 << nl
|
||||
<< "coordinates" << nl;
|
||||
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
const scalarField fld = valueSets[setI]->component(cmpt);
|
||||
forAll(fld, i)
|
||||
{
|
||||
if (mag(fld[i]) >= scalar(floatScalarVSMALL))
|
||||
{
|
||||
os << setw(12) << fld[i] << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << setw(12) << scalar(0) << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::ensightSetWriter<Type>::write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>& tracks,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
const fileName base(os.name().lessExt());
|
||||
const fileName meshFile(base + ".mesh");
|
||||
|
||||
// Write .case file
|
||||
os << "FORMAT" << nl
|
||||
<< "type: ensight gold" << nl
|
||||
<< nl
|
||||
<< "GEOMETRY" << nl
|
||||
<< "model: 1 " << meshFile.name().c_str() << nl
|
||||
<< nl
|
||||
<< "VARIABLE"
|
||||
<< nl;
|
||||
forAll(valueSetNames, setI)
|
||||
{
|
||||
fileName dataFile(base + ".***." + valueSetNames[setI]);
|
||||
|
||||
os.setf(ios_base::left);
|
||||
os << pTraits<Type>::typeName
|
||||
<< " per node: 1 "
|
||||
<< setw(15) << valueSetNames[setI]
|
||||
<< " " << dataFile.name().c_str()
|
||||
<< nl;
|
||||
}
|
||||
os << nl
|
||||
<< "TIME" << nl
|
||||
<< "time set: 1" << nl
|
||||
<< "number of steps: 1" << nl
|
||||
<< "filename start number: 0" << nl
|
||||
<< "filename increment: 1" << nl
|
||||
<< "time values:" << nl
|
||||
<< "0.00000e+00" << nl;
|
||||
|
||||
// Write .mesh file
|
||||
{
|
||||
string desc = string("written by OpenFOAM-") + Foam::FOAMversion;
|
||||
OFstream os(meshFile);
|
||||
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||
os.precision(5);
|
||||
os << "EnSight Geometry File" << nl
|
||||
<< desc.c_str() << nl
|
||||
<< "node id assign" << nl
|
||||
<< "element id assign" << nl;
|
||||
|
||||
forAll(tracks, trackI)
|
||||
{
|
||||
const coordSet& points = tracks[trackI];
|
||||
|
||||
os << "part" << nl
|
||||
<< setw(10) << trackI+1 << nl
|
||||
<< "internalMesh" << nl
|
||||
<< "coordinates" << nl
|
||||
<< setw(10) << points.size() << nl;
|
||||
|
||||
for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++)
|
||||
{
|
||||
forAll(points, pointI)
|
||||
{
|
||||
const scalar comp = points[pointI][cmpt];
|
||||
if (mag(comp) >= scalar(floatScalarVSMALL))
|
||||
{
|
||||
os << setw(12) << comp << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << setw(12) << scalar(0) << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (writeTracks)
|
||||
{
|
||||
os << "bar2" << nl
|
||||
<< setw(10) << points.size()-1 << nl;
|
||||
for (label i = 0; i < points.size()-1; i++)
|
||||
{
|
||||
os << setw(10) << i+1
|
||||
<< setw(10) << i+2
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write data files
|
||||
forAll(valueSetNames, setI)
|
||||
{
|
||||
fileName dataFile(base + ".000." + valueSetNames[setI]);
|
||||
OFstream os(dataFile);
|
||||
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||
os.precision(5);
|
||||
{
|
||||
os << pTraits<Type>::typeName << nl;
|
||||
|
||||
const List<Field<Type> >& fieldVals = valueSets[setI];
|
||||
forAll(fieldVals, trackI)
|
||||
{
|
||||
os << "part" << nl
|
||||
<< setw(10) << trackI+1 << nl
|
||||
<< "coordinates" << nl;
|
||||
|
||||
for
|
||||
(
|
||||
direction cmpt = 0;
|
||||
cmpt < pTraits<Type>::nComponents;
|
||||
cmpt++
|
||||
)
|
||||
{
|
||||
const scalarField fld = fieldVals[trackI].component(cmpt);
|
||||
forAll(fld, i)
|
||||
{
|
||||
if (mag(fld[i]) >= scalar(floatScalarVSMALL))
|
||||
{
|
||||
os << setw(12) << fld[i] << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << setw(12) << scalar(0) << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
111
src/sampling/sampledSet/writers/ensight/ensightSetWriter.H
Normal file
111
src/sampling/sampledSet/writers/ensight/ensightSetWriter.H
Normal file
@ -0,0 +1,111 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::ensightSetWriter
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
ensightSetWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightSetWriter_H
|
||||
#define ensightSetWriter_H
|
||||
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ensightSetWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class ensightSetWriter
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("ensight");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
ensightSetWriter();
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ensightSetWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>&,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >&,
|
||||
Ostream&
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "ensightSetWriter.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ensightSetWriter.H"
|
||||
#include "writers.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeSetWriters(ensightSetWriter);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
@ -14,7 +14,7 @@ streamLines
|
||||
outputControl outputTime;
|
||||
// outputInterval 10;
|
||||
|
||||
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot;
|
||||
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot; //csv; //ensight;
|
||||
|
||||
// Velocity field to use for tracking.
|
||||
U U;
|
||||
|
@ -14,7 +14,7 @@ streamLines
|
||||
outputControl outputTime;
|
||||
// outputInterval 10;
|
||||
|
||||
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot;
|
||||
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot; //csv; //ensight;
|
||||
|
||||
// Velocity field to use for tracking.
|
||||
UName U;
|
||||
|
@ -58,7 +58,7 @@ functions
|
||||
outputControl outputTime;
|
||||
// outputInterval 10;
|
||||
|
||||
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot;
|
||||
setFormat vtk; //gnuplot;//xmgr;//raw;//jplot;//csv;//ensight;
|
||||
|
||||
// Velocity field to use for tracking.
|
||||
UName U;
|
||||
|
@ -58,7 +58,7 @@ functions
|
||||
outputControl outputTime;
|
||||
// outputInterval 10;
|
||||
|
||||
setFormat vtk; //gnuplot; //xmgr; //raw; //jplot;
|
||||
setFormat vtk; //gnuplot;//xmgr;//raw;//jplot;//csv;//ensight;
|
||||
|
||||
// Velocity field to use for tracking.
|
||||
UName U;
|
||||
|
Loading…
Reference in New Issue
Block a user