Global controlDict pre-merge.
This commit is contained in:
parent
a2300be5f9
commit
e054cad9be
61 changed files with 1770 additions and 3353 deletions
|
@ -1,166 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Creates surface patches from surface subsets
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "triSurf.H"
|
||||
#include "triSurfaceCopyParts.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void exportFeatureEdges
|
||||
(
|
||||
const triSurf& origSurf,
|
||||
const fileName& edgeFileName
|
||||
)
|
||||
{
|
||||
OFstream file(edgeFileName);
|
||||
|
||||
const pointField& points = origSurf.points();
|
||||
labelList newPointLabel(points.size(), -1);
|
||||
label nPoints(0);
|
||||
|
||||
const edgeLongList& featureEdges = origSurf.featureEdges();
|
||||
forAll(featureEdges, feI)
|
||||
{
|
||||
const edge& e = featureEdges[feI];
|
||||
|
||||
if( newPointLabel[e[0]] == -1 )
|
||||
newPointLabel[e[0]] = nPoints++;
|
||||
if( newPointLabel[e[1]] == -1 )
|
||||
newPointLabel[e[1]] = nPoints++;
|
||||
}
|
||||
|
||||
pointField pCopy(nPoints);
|
||||
forAll(newPointLabel, pI)
|
||||
{
|
||||
if( newPointLabel[pI] < 0 )
|
||||
continue;
|
||||
|
||||
pCopy[newPointLabel[pI]] = points[pI];
|
||||
}
|
||||
|
||||
//- write the header
|
||||
file << "# vtk DataFile Version 3.0\n";
|
||||
file << "vtk output\n";
|
||||
file << "ASCII\n";
|
||||
file << "DATASET POLYDATA\n";
|
||||
|
||||
//- write points
|
||||
file << "POINTS " << pCopy.size() << " float\n";
|
||||
forAll(pCopy, pI)
|
||||
{
|
||||
const point& p = pCopy[pI];
|
||||
file << p.x() << ' ' << p.y() << ' ' << p.z() << '\n';
|
||||
}
|
||||
|
||||
file << "\nLINES " << featureEdges.size()
|
||||
<< ' ' << 3*featureEdges.size() << nl;
|
||||
forAll(featureEdges, edgeI)
|
||||
{
|
||||
const edge& e = featureEdges[edgeI];
|
||||
file << "2 " << newPointLabel[e[0]]
|
||||
<< token::SPACE << newPointLabel[e[1]] << nl;
|
||||
}
|
||||
file << nl;
|
||||
|
||||
if( !file )
|
||||
FatalErrorIn
|
||||
(
|
||||
"void exportFeatureEdges(const triSurf&, const fileName&)"
|
||||
) << "Writting of feature edges failed!" << exit(FatalError);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("output surface file");
|
||||
argList::validOptions.insert("exportSubsets", "");
|
||||
argList::validOptions.insert("exportFeatureEdges", "");
|
||||
argList args(argc, argv);
|
||||
|
||||
fileName inFileName(args.args()[1]);
|
||||
fileName outFileName(args.args()[2]);
|
||||
|
||||
fileName outFileNoExt = outFileName.lessExt();
|
||||
fileName outExtension = outFileName.ext();
|
||||
|
||||
Info << "Out file no ext " << outFileNoExt << endl;
|
||||
Info << "Extension " << outExtension << endl;
|
||||
|
||||
//- read the inout surface
|
||||
triSurf origSurf(inFileName);
|
||||
|
||||
//- write the surface in the requated format
|
||||
origSurf.writeSurface(outFileName);
|
||||
|
||||
//- export surface subsets as separate surface meshes
|
||||
if( args.options().found("exportSubsets") )
|
||||
{
|
||||
DynList<label> subsetIDs;
|
||||
origSurf.facetSubsetIndices(subsetIDs);
|
||||
|
||||
triSurfaceCopyParts copyParts(origSurf);
|
||||
|
||||
forAll(subsetIDs, subsetI)
|
||||
{
|
||||
//- get the name of the subset
|
||||
triSurf copySurf;
|
||||
wordList subsetName(1);
|
||||
subsetName[0] = origSurf.facetSubsetName(subsetIDs[subsetI]);
|
||||
|
||||
//- create a surface mesh corresponding to the subset
|
||||
copyParts.copySurface(subsetName, copySurf);
|
||||
|
||||
//- write the mesh on disk
|
||||
fileName fName = outFileNoExt+"_facetSubset_"+subsetName[0];
|
||||
fName += '.'+outExtension;
|
||||
|
||||
copySurf.writeSurface(fName);
|
||||
}
|
||||
}
|
||||
|
||||
if( args.options().found("exportFeatureEdges") )
|
||||
{
|
||||
fileName fName = outFileNoExt+"_featureEdges";
|
||||
fName += ".vtk";
|
||||
exportFeatureEdges(origSurf, fName);
|
||||
}
|
||||
|
||||
Info << "End\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
FMSToSurface.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/FMSToSurface
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(FOAM_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||
-I$(FOAM_SRC)/triSurface/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-ltriSurface \
|
||||
-lmeshTools \
|
||||
-lmeshLibrary
|
|
@ -1,545 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
cfMesh utility to convert a surface file to VTK multiblock dataset
|
||||
format, including the patches, feature edges and surface features.
|
||||
|
||||
Author
|
||||
Ivor Clifford <ivor.clifford@psi.ch>
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "autoPtr.H"
|
||||
#include "OFstream.H"
|
||||
#include "triSurf.H"
|
||||
#include "triSurfModifier.H"
|
||||
#include "xmlTag.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Write the supplied pointList in serial vtkPolyData format
|
||||
void writePointsToVTK
|
||||
(
|
||||
const fileName& fn,
|
||||
const string& title,
|
||||
const UList<point>& points
|
||||
)
|
||||
{
|
||||
xmlTag xmlRoot("VTKFile");
|
||||
xmlRoot.addAttribute("type", "PolyData");
|
||||
|
||||
xmlTag& xmlPolyData = xmlRoot.addChild("PolyData");
|
||||
|
||||
xmlTag& xmlPiece = xmlPolyData.addChild("Piece");
|
||||
xmlPiece.addAttribute("NumberOfPoints", points.size());
|
||||
|
||||
xmlTag& xmlPoints = xmlPiece.addChild("Points");
|
||||
|
||||
xmlTag& xmlPointData = xmlPoints.addChild("DataArray");
|
||||
xmlPointData.addAttribute("type", "Float32");
|
||||
xmlPointData.addAttribute("NumberOfComponents", 3);
|
||||
xmlPointData.addAttribute("format", "ascii");
|
||||
xmlPointData << points;
|
||||
|
||||
OFstream os(fn);
|
||||
os << xmlRoot << endl;
|
||||
|
||||
Info << "Created " << fn << endl;
|
||||
}
|
||||
|
||||
|
||||
//- Write the supplied addressed pointList in serial vtkPolyData format
|
||||
void writePointsToVTK
|
||||
(
|
||||
const fileName& fn,
|
||||
const string& title,
|
||||
const UList<point>& points,
|
||||
unallocLabelList& addr
|
||||
)
|
||||
{
|
||||
// Create subaddressed points
|
||||
pointField newPoints(addr.size());
|
||||
|
||||
forAll(addr, i)
|
||||
{
|
||||
newPoints[i] = points[addr[i]];
|
||||
}
|
||||
|
||||
writePointsToVTK
|
||||
(
|
||||
fn,
|
||||
title,
|
||||
newPoints
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Write the supplied edgeList in serial vtkPolyData format
|
||||
void writeEdgesToVTK
|
||||
(
|
||||
const fileName& fn,
|
||||
const string& title,
|
||||
const UList<point>& points,
|
||||
const LongList<edge>& edges
|
||||
)
|
||||
{
|
||||
labelList connectivity(edges.size());
|
||||
|
||||
forAll(edges, edgeI)
|
||||
{
|
||||
connectivity[edgeI] = 2*(edgeI+1);
|
||||
}
|
||||
|
||||
xmlTag xmlRoot("VTKFile");
|
||||
xmlRoot.addAttribute("type", "PolyData");
|
||||
|
||||
xmlTag& xmlPolyData = xmlRoot.addChild("PolyData");
|
||||
|
||||
xmlTag& xmlPiece = xmlPolyData.addChild("Piece");
|
||||
xmlPiece.addAttribute("NumberOfPoints", points.size());
|
||||
xmlPiece.addAttribute("NumberOfLines", edges.size());
|
||||
|
||||
xmlTag& xmlPoints = xmlPiece.addChild("Points");
|
||||
|
||||
xmlTag& xmlPointData = xmlPoints.addChild("DataArray");
|
||||
xmlPointData.addAttribute("type", "Float32");
|
||||
xmlPointData.addAttribute("NumberOfComponents", 3);
|
||||
xmlPointData.addAttribute("format", "ascii");
|
||||
xmlPointData << points;
|
||||
|
||||
xmlTag& xmlEdges = xmlPiece.addChild("Lines");
|
||||
|
||||
xmlTag& xmlEdgeData = xmlEdges.addChild("DataArray");
|
||||
xmlEdgeData.addAttribute("type", "Int32");
|
||||
xmlEdgeData.addAttribute("Name", "connectivity");
|
||||
xmlEdgeData.addAttribute("format", "ascii");
|
||||
xmlEdgeData << edges;
|
||||
|
||||
xmlTag& xmlConnectData = xmlEdges.addChild("DataArray");
|
||||
xmlConnectData.addAttribute("type", "Int32");
|
||||
xmlConnectData.addAttribute("Name", "offsets");
|
||||
xmlConnectData.addAttribute("format", "ascii");
|
||||
xmlConnectData << connectivity;
|
||||
|
||||
OFstream os(fn);
|
||||
os << xmlRoot << endl;
|
||||
|
||||
Info << "Created " << fn << endl;
|
||||
}
|
||||
|
||||
//- Write the supplied edgeList subset in serial vtkPolyData format
|
||||
void writeEdgesToVTK
|
||||
(
|
||||
const fileName& fn,
|
||||
const string& title,
|
||||
const UList<point>& points,
|
||||
const LongList<edge>& edges,
|
||||
const unallocLabelList& addr
|
||||
)
|
||||
{
|
||||
// Remove unused points and create subaddressed edges
|
||||
DynamicList<point> newPoints;
|
||||
labelList newPointAddr(points.size(), -1);
|
||||
LongList<edge> newEdges(addr.size());
|
||||
|
||||
forAll(addr, addrI)
|
||||
{
|
||||
label edgeI = addr[addrI];
|
||||
|
||||
const edge& curEdge = edges[edgeI];
|
||||
edge& newEdge = newEdges[addrI];
|
||||
|
||||
forAll(curEdge, i)
|
||||
{
|
||||
label pointId = curEdge[i];
|
||||
|
||||
if (newPointAddr[pointId] == -1)
|
||||
{
|
||||
newPoints.append(points[pointId]);
|
||||
newPointAddr[pointId] = newPoints.size()-1;
|
||||
}
|
||||
|
||||
newEdge[i] = newPointAddr[pointId];
|
||||
}
|
||||
}
|
||||
|
||||
writeEdgesToVTK
|
||||
(
|
||||
fn,
|
||||
title,
|
||||
newPoints,
|
||||
newEdges
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Write the supplied facet list in serial vtkPolyData format
|
||||
void writeFacetsToVTK
|
||||
(
|
||||
const fileName& fn,
|
||||
const string& title,
|
||||
const UList<point>& points,
|
||||
const LongList<labelledTri>& facets
|
||||
)
|
||||
{
|
||||
labelList connectivity(facets.size());
|
||||
|
||||
forAll(facets, faceI)
|
||||
{
|
||||
connectivity[faceI] = 3*(faceI+1);
|
||||
}
|
||||
|
||||
labelList regionData(facets.size());
|
||||
|
||||
forAll(facets, faceI)
|
||||
{
|
||||
regionData[faceI] = facets[faceI].region();
|
||||
}
|
||||
|
||||
xmlTag xmlRoot("VTKFile");
|
||||
xmlRoot.addAttribute("type", "PolyData");
|
||||
|
||||
xmlTag& xmlPolyData = xmlRoot.addChild("PolyData");
|
||||
|
||||
xmlTag& xmlPiece = xmlPolyData.addChild("Piece");
|
||||
xmlPiece.addAttribute("NumberOfPoints", points.size());
|
||||
xmlPiece.addAttribute("NumberOfPolys", facets.size());
|
||||
|
||||
xmlTag& xmlPoints = xmlPiece.addChild("Points");
|
||||
|
||||
xmlTag& xmlPointData = xmlPoints.addChild("DataArray");
|
||||
xmlPointData.addAttribute("type", "Float32");
|
||||
xmlPointData.addAttribute("NumberOfComponents", 3);
|
||||
xmlPointData.addAttribute("format", "ascii");
|
||||
xmlPointData << points;
|
||||
|
||||
xmlTag& xmlPolys = xmlPiece.addChild("Polys");
|
||||
|
||||
xmlTag& xmlPolyDataArray = xmlPolys.addChild("DataArray");
|
||||
xmlPolyDataArray.addAttribute("type", "Int32");
|
||||
xmlPolyDataArray.addAttribute("Name", "connectivity");
|
||||
xmlPolyDataArray.addAttribute("format", "ascii");
|
||||
xmlPolyDataArray << facets;
|
||||
|
||||
xmlTag& xmlConnectData = xmlPolys.addChild("DataArray");
|
||||
xmlConnectData.addAttribute("type", "Int32");
|
||||
xmlConnectData.addAttribute("Name", "offsets");
|
||||
xmlConnectData.addAttribute("format", "ascii");
|
||||
xmlConnectData << connectivity;
|
||||
|
||||
xmlTag& xmlCellData = xmlPiece.addChild("CellData");
|
||||
|
||||
xmlTag& xmlCellDataArray = xmlCellData.addChild("DataArray");
|
||||
xmlCellDataArray.addAttribute("type", "Int32");
|
||||
xmlCellDataArray.addAttribute("Name", "region");
|
||||
xmlCellDataArray.addAttribute("format", "ascii");
|
||||
xmlCellDataArray << regionData;
|
||||
|
||||
OFstream os(fn);
|
||||
os << xmlRoot << endl;
|
||||
|
||||
Info << "Created " << fn << endl;
|
||||
}
|
||||
|
||||
|
||||
//- Write an addressed subset of the supplied facet list
|
||||
//- in serial vtkPolyData format
|
||||
void writeFacetsToVTK
|
||||
(
|
||||
const fileName& fn,
|
||||
const string& title,
|
||||
const pointField& points,
|
||||
const LongList<labelledTri>& facets,
|
||||
const unallocLabelList& addr
|
||||
)
|
||||
{
|
||||
// Remove unused points and create subaddressed facets
|
||||
DynamicList<point> newPoints;
|
||||
labelList newPointAddr(points.size(), -1);
|
||||
LongList<labelledTri> newFacets(addr.size());
|
||||
|
||||
forAll(addr, addrI)
|
||||
{
|
||||
label faceI = addr[addrI];
|
||||
|
||||
const labelledTri& facet = facets[faceI];
|
||||
const FixedList<label, 3>& pointIds = facet;
|
||||
FixedList<label, 3> newPointIds;
|
||||
|
||||
forAll(pointIds, i)
|
||||
{
|
||||
label pointId = pointIds[i];
|
||||
|
||||
if (newPointAddr[pointId] == -1)
|
||||
{
|
||||
newPoints.append(points[pointId]);
|
||||
newPointAddr[pointId] = newPoints.size()-1;
|
||||
}
|
||||
|
||||
newPointIds[i] = newPointAddr[pointId];
|
||||
}
|
||||
|
||||
newFacets[addrI] = labelledTri
|
||||
(
|
||||
newPointIds[0],
|
||||
newPointIds[1],
|
||||
newPointIds[2],
|
||||
facet.region()
|
||||
);
|
||||
}
|
||||
|
||||
writeFacetsToVTK
|
||||
(
|
||||
fn,
|
||||
title,
|
||||
newPoints,
|
||||
newFacets
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("output prefix");
|
||||
argList args(argc, argv);
|
||||
|
||||
// Process commandline arguments
|
||||
fileName inFileName(args.args()[1]);
|
||||
fileName outPrefix(args.args()[2]);
|
||||
|
||||
// Read original surface
|
||||
triSurf origSurf(inFileName);
|
||||
|
||||
const pointField& points = origSurf.points();
|
||||
const LongList<labelledTri>& facets = origSurf.facets();
|
||||
const LongList<edge>& edges = origSurf.featureEdges();
|
||||
const geometricSurfacePatchList& patches = origSurf.patches();
|
||||
|
||||
label index = 0;
|
||||
|
||||
// Create file structure for multiblock dataset
|
||||
mkDir(outPrefix);
|
||||
mkDir(outPrefix + "/patches");
|
||||
mkDir(outPrefix + "/pointSubsets");
|
||||
mkDir(outPrefix + "/edgeSubsets");
|
||||
mkDir(outPrefix + "/faceSubsets");
|
||||
|
||||
// Create VTK multiblock dataset file
|
||||
xmlTag xmlRoot("VTKFile");
|
||||
xmlRoot.addAttribute("type", "vtkMultiBlockDataSet");
|
||||
xmlRoot.addAttribute("version", "1.0");
|
||||
xmlRoot.addAttribute("byte_order", "LittleEndian");
|
||||
|
||||
xmlTag& xmlDataSet = xmlRoot.addChild("vtkMultiBlockDataSet");
|
||||
|
||||
// Write faces and feature edges
|
||||
{
|
||||
fileName fn = outPrefix / "facets.vtp";
|
||||
|
||||
writeFacetsToVTK
|
||||
(
|
||||
outPrefix / "facets.vtp",
|
||||
outPrefix,
|
||||
points,
|
||||
facets
|
||||
);
|
||||
|
||||
xmlTag& tag = xmlDataSet.addChild("DataSet");
|
||||
tag.addAttribute("index", Foam::name(index++));
|
||||
tag.addAttribute("name", "facets");
|
||||
tag.addAttribute("file", fn);
|
||||
}
|
||||
|
||||
{
|
||||
fileName fn = outPrefix / "featureEdges.vtp";
|
||||
|
||||
writeEdgesToVTK
|
||||
(
|
||||
outPrefix / "featureEdges.vtp",
|
||||
"featureEdges",
|
||||
points,
|
||||
edges
|
||||
);
|
||||
|
||||
xmlTag& tag = xmlDataSet.addChild("DataSet");
|
||||
tag.addAttribute("index", Foam::name(index++));
|
||||
tag.addAttribute("name", "featureEdges");
|
||||
tag.addAttribute("file", fn);
|
||||
}
|
||||
|
||||
// Write patches
|
||||
// Create patch addressing
|
||||
List<DynamicList<label> > patchAddr(patches.size());
|
||||
|
||||
forAll(facets, faceI)
|
||||
{
|
||||
patchAddr[facets[faceI].region()].append(faceI);
|
||||
}
|
||||
|
||||
{
|
||||
xmlTag& xmlBlock = xmlDataSet.addChild("Block");
|
||||
xmlBlock.addAttribute("index", Foam::name(index++));
|
||||
xmlBlock.addAttribute("name", "patches");
|
||||
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
word patchName = patches[patchI].name();
|
||||
|
||||
fileName fn = outPrefix / "patches" / patchName + ".vtp";
|
||||
|
||||
writeFacetsToVTK
|
||||
(
|
||||
fn,
|
||||
patchName,
|
||||
points,
|
||||
facets,
|
||||
patchAddr[patchI]
|
||||
);
|
||||
|
||||
xmlTag& tag = xmlBlock.addChild("DataSet");
|
||||
tag.addAttribute("index", Foam::name(patchI));
|
||||
tag.addAttribute("name", patchName);
|
||||
tag.addAttribute("file", fn);
|
||||
}
|
||||
}
|
||||
|
||||
// Write point subsets
|
||||
{
|
||||
xmlTag& xmlBlock = xmlDataSet.addChild("Block");
|
||||
xmlBlock.addAttribute("index", Foam::name(index++));
|
||||
xmlBlock.addAttribute("name", "pointSubsets");
|
||||
|
||||
DynList<label> subsetIndices;
|
||||
labelList subsetAddr;
|
||||
|
||||
origSurf.pointSubsetIndices(subsetIndices);
|
||||
|
||||
forAll(subsetIndices, id)
|
||||
{
|
||||
word subsetName = origSurf.pointSubsetName(id);
|
||||
origSurf.pointsInSubset(id, subsetAddr);
|
||||
|
||||
fileName fn = outPrefix / "pointSubsets" / subsetName + ".vtp";
|
||||
|
||||
writePointsToVTK
|
||||
(
|
||||
fn,
|
||||
subsetName,
|
||||
points,
|
||||
subsetAddr
|
||||
);
|
||||
|
||||
xmlTag& tag = xmlBlock.addChild("DataSet");
|
||||
tag.addAttribute("index", Foam::name(id));
|
||||
tag.addAttribute("name", subsetName);
|
||||
tag.addAttribute("file", fn);
|
||||
}
|
||||
}
|
||||
|
||||
// Write edge subsets
|
||||
{
|
||||
xmlTag& xmlBlock = xmlDataSet.addChild("Block");
|
||||
xmlBlock.addAttribute("index", Foam::name(index++));
|
||||
xmlBlock.addAttribute("name", "edgeSubsets");
|
||||
|
||||
DynList<label> subsetIndices;
|
||||
labelList subsetAddr;
|
||||
|
||||
origSurf.edgeSubsetIndices(subsetIndices);
|
||||
|
||||
forAll(subsetIndices, id)
|
||||
{
|
||||
word subsetName = origSurf.edgeSubsetName(id);
|
||||
origSurf.edgesInSubset(id, subsetAddr);
|
||||
|
||||
fileName fn = outPrefix / "edgeSubsets" / subsetName + ".vtp";
|
||||
|
||||
writeEdgesToVTK
|
||||
(
|
||||
fn,
|
||||
subsetName,
|
||||
points,
|
||||
edges,
|
||||
subsetAddr
|
||||
);
|
||||
|
||||
xmlTag& tag = xmlBlock.addChild("DataSet");
|
||||
tag.addAttribute("index", Foam::name(id));
|
||||
tag.addAttribute("name", subsetName);
|
||||
tag.addAttribute("file", fn);
|
||||
}
|
||||
}
|
||||
|
||||
// Write facet subsets
|
||||
{
|
||||
xmlTag& xmlBlock = xmlDataSet.addChild("Block");
|
||||
xmlBlock.addAttribute("index", Foam::name(index++));
|
||||
xmlBlock.addAttribute("name", "faceSubsets");
|
||||
|
||||
DynList<label> subsetIndices;
|
||||
labelList subsetAddr;
|
||||
|
||||
origSurf.facetSubsetIndices(subsetIndices);
|
||||
|
||||
forAll(subsetIndices, id)
|
||||
{
|
||||
word subsetName = origSurf.facetSubsetName(id);
|
||||
origSurf.facetsInSubset(id, subsetAddr);
|
||||
|
||||
fileName fn = outPrefix / "faceSubsets" / subsetName + ".vtp";
|
||||
|
||||
writeFacetsToVTK
|
||||
(
|
||||
fn,
|
||||
subsetName,
|
||||
points,
|
||||
facets,
|
||||
subsetAddr
|
||||
);
|
||||
|
||||
xmlTag& tag = xmlBlock.addChild("DataSet");
|
||||
tag.addAttribute("index", Foam::name(id));
|
||||
tag.addAttribute("name", subsetName);
|
||||
tag.addAttribute("file", fn);
|
||||
}
|
||||
}
|
||||
|
||||
OFstream os(outPrefix + ".vtm");
|
||||
os << xmlRoot << endl;
|
||||
|
||||
Info << "Created " << outPrefix + ".vtm" << endl;
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
FMSToVTK.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/FMSToVTK
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(FOAM_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||
-I$(FOAM_SRC)/triSurface/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-ltriSurface \
|
||||
-lmeshLibrary \
|
||||
-lmeshTools
|
|
@ -1,297 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | foam-extend: Open Source CFD
|
||||
\\ / O peration |
|
||||
\\ / A nd | For copyright notice see file Copyright
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of foam-extend.
|
||||
|
||||
foam-extend 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.
|
||||
|
||||
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::xmlTag
|
||||
|
||||
Description
|
||||
Simple XML tag class allowing child tags and attributes. Specialized
|
||||
output stream operators are provided to display or write the XML
|
||||
structure.
|
||||
|
||||
Author
|
||||
Ivor Clifford <ivor.clifford@psi.ch>
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef XMLtag_H
|
||||
#define XMLtag_H
|
||||
|
||||
#include "OStringStream.H"
|
||||
#include "HashTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class xmlTag Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class xmlTag
|
||||
:
|
||||
public OStringStream
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Tag name
|
||||
word name_;
|
||||
|
||||
//- Attributes
|
||||
HashTable<string> attributes_;
|
||||
|
||||
//- Child tags
|
||||
DynamicList<xmlTag> children_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor
|
||||
xmlTag()
|
||||
:
|
||||
OStringStream(),
|
||||
name_("unknown"),
|
||||
attributes_(),
|
||||
children_()
|
||||
{}
|
||||
|
||||
//- Construct given tag name
|
||||
xmlTag(const word& name)
|
||||
:
|
||||
OStringStream(),
|
||||
name_(name),
|
||||
attributes_(),
|
||||
children_()
|
||||
{}
|
||||
|
||||
//- Construct as copy
|
||||
xmlTag(const xmlTag& tag)
|
||||
:
|
||||
OStringStream(tag),
|
||||
name_(tag.name_),
|
||||
attributes_(tag.attributes_),
|
||||
children_(tag.children_)
|
||||
{}
|
||||
|
||||
//- Destructor
|
||||
~xmlTag()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Add an attribute
|
||||
template<class T>
|
||||
void addAttribute(const keyType& key, const T& value)
|
||||
{
|
||||
OStringStream os;
|
||||
os << value;
|
||||
attributes_.insert(key, os.str());
|
||||
};
|
||||
|
||||
//- Add a fileName attribute
|
||||
void addAttribute(const keyType& key, const fileName& value)
|
||||
{
|
||||
attributes_.insert(key, value);
|
||||
};
|
||||
|
||||
//- Add a string attribute
|
||||
void addAttribute(const keyType& key, const string& value)
|
||||
{
|
||||
attributes_.insert(key, value);
|
||||
};
|
||||
|
||||
//- Add a word attribute
|
||||
void addAttribute(const keyType& key, const word& value)
|
||||
{
|
||||
attributes_.insert(key, value);
|
||||
};
|
||||
|
||||
//- Add a child
|
||||
xmlTag& addChild(const xmlTag& tag)
|
||||
{
|
||||
children_.append(tag);
|
||||
|
||||
return children_[children_.size()-1];
|
||||
};
|
||||
|
||||
//- Create and add a new child
|
||||
xmlTag& addChild(const word& name)
|
||||
{
|
||||
return addChild(xmlTag(name));
|
||||
}
|
||||
|
||||
// Member Operators
|
||||
|
||||
void operator=(const xmlTag& tag)
|
||||
{
|
||||
name_ = tag.name_;
|
||||
attributes_ = tag.attributes_;
|
||||
children_ = tag.children_;
|
||||
OStringStream::rewind();
|
||||
Foam::operator<<(*this, tag.str().c_str());
|
||||
};
|
||||
|
||||
// Friend IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const xmlTag&);
|
||||
|
||||
template<class Form, class Cmpt, int nCmpt>
|
||||
friend xmlTag& operator<<(xmlTag&, const VectorSpace<Form, Cmpt, nCmpt>&);
|
||||
|
||||
friend xmlTag& operator<<(xmlTag&, const labelledTri&);
|
||||
|
||||
template<class T, unsigned Size>
|
||||
friend xmlTag& operator<<(xmlTag&, const FixedList<T, Size>&);
|
||||
|
||||
template<class T>
|
||||
friend xmlTag& operator<<(xmlTag&, const LongList<T>&);
|
||||
|
||||
template<class T>
|
||||
friend xmlTag& operator<<(xmlTag&, const UList<T>&);
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Write the tag in XML format to the supplied output stream
|
||||
Ostream& operator<<(Ostream& os, const xmlTag& tag)
|
||||
{
|
||||
// Tag name
|
||||
os << indent << '<' << tag.name_;
|
||||
|
||||
// Attributes and text
|
||||
for
|
||||
(
|
||||
HashTable<string>::const_iterator iter = tag.attributes_.cbegin();
|
||||
iter != tag.attributes_.cend();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
os << token::SPACE << iter.key() << '=' << iter();
|
||||
}
|
||||
|
||||
if (tag.str().size() || tag.children_.size())
|
||||
{
|
||||
os << '>' << nl;
|
||||
|
||||
// Children
|
||||
os.incrIndent();
|
||||
|
||||
forAll(tag.children_, i)
|
||||
{
|
||||
os << tag.children_[i];
|
||||
}
|
||||
|
||||
os.decrIndent();
|
||||
|
||||
// Tag text
|
||||
os << tag.str().c_str();
|
||||
|
||||
// Close tag
|
||||
os << indent << "</" << tag.name_ << '>' << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Empty element tag
|
||||
os << "/>" << endl;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
//- Append the supplied data to the tag text
|
||||
template<class T>
|
||||
xmlTag& operator<<(xmlTag& tag, const UList<T>& data)
|
||||
{
|
||||
forAll(data, i)
|
||||
{
|
||||
tag << data[i] << token::SPACE;
|
||||
}
|
||||
|
||||
tag << nl;
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
//- Append the supplied data to the tag text
|
||||
template<class T>
|
||||
xmlTag& operator<<(xmlTag& tag, const LongList<T>& data)
|
||||
{
|
||||
forAll(data, i)
|
||||
{
|
||||
tag << data[i] << token::SPACE;
|
||||
}
|
||||
|
||||
tag << nl;
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
//- Append the supplied data to the tag text
|
||||
template<class Form, class Cmpt, int nCmpt>
|
||||
xmlTag& operator<<(xmlTag& tag, const VectorSpace<Form, Cmpt, nCmpt>& data)
|
||||
{
|
||||
forAll(data, i)
|
||||
{
|
||||
tag << data[i] << token::SPACE;
|
||||
}
|
||||
|
||||
tag << nl;
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
//- Append the supplied data to the tag text
|
||||
template<class T, unsigned Size>
|
||||
xmlTag& operator<<(xmlTag& tag, const FixedList<T, Size>& data)
|
||||
{
|
||||
forAll(data, i)
|
||||
{
|
||||
tag << data[i] << token::SPACE;
|
||||
}
|
||||
|
||||
tag << nl;
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
//- Append the supplied data to the tag text
|
||||
xmlTag& operator<<(xmlTag& tag, const labelledTri& data)
|
||||
{
|
||||
const triFace& tFace = data;
|
||||
|
||||
return tag << tFace;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
importSurfaceAsSubset.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/importSurfaceAsSubset
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(FOAM_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
|
||||
-I$(LIB_SRC)/triSurface/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-ltriSurface \
|
||||
-lmeshLibrary \
|
||||
-lmeshTools
|
|
@ -1,84 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Finds feature edges and corners of a triangulated surface
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "IFstream.H"
|
||||
#include "fileName.H"
|
||||
#include "triSurf.H"
|
||||
#include "OFstream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include "triSurfaceImportSurfaceAsSubset.H"
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
argList::validArgs.append("master surface file");
|
||||
argList::validArgs.append("import surface file");
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
fileName inFileName(args.args()[1]);
|
||||
fileName importFileName(args.args()[2]);
|
||||
|
||||
triSurf originalSurface(inFileName);
|
||||
|
||||
triSurf importedSurface(importFileName);
|
||||
|
||||
triSurfaceImportSurfaceAsSubset importSurf(originalSurface);
|
||||
|
||||
importSurf.addSurfaceAsSubset(importedSurface, importFileName.lessExt());
|
||||
|
||||
if( inFileName.ext() == "fms" )
|
||||
{
|
||||
originalSurface.writeSurface(inFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName newName = inFileName.lessExt();
|
||||
newName.append(".fms");
|
||||
Warning << "Writting surface as " << newName
|
||||
<< " to preserve the subset!!" << endl;
|
||||
|
||||
originalSurface.writeSurface(newName);
|
||||
}
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
improveSymmetryPlanes.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/improveSymmetryPlanes
|
|
@ -1,7 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(FOAM_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-lmeshLibrary
|
|
@ -1,57 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Ensures that all mesh points belonging to a symmetryPlane are
|
||||
in a plane.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "polyMeshGenModifier.H"
|
||||
#include "symmetryPlaneOptimisation.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
polyMeshGen pmg(runTime);
|
||||
pmg.read();
|
||||
|
||||
Info << "Starting optimisation of symmetry planes" << endl;
|
||||
symmetryPlaneOptimisation(pmg).optimizeSymmetryPlanes();
|
||||
|
||||
Info << "Writing mesh" << endl;
|
||||
pmg.write();
|
||||
|
||||
Info << "End\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,3 +0,0 @@
|
|||
mergeSurfacePatches.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/mergeSurfacePatches
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(FOAM_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
|
||||
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||
-I$(FOAM_SRC)/triSurface/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-ltriSurface \
|
||||
-lmeshLibrary \
|
||||
-lmeshTools
|
|
@ -1,403 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
cfMesh utility to merge the supplied list of patches onto a single
|
||||
patch.
|
||||
|
||||
Author
|
||||
Ivor Clifford <ivor.clifford@psi.ch>
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "autoPtr.H"
|
||||
#include "Time.H"
|
||||
#include "triSurf.H"
|
||||
#include "triSurfModifier.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include "Pair.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Find the supplied list of patch names and return a list of patch Ids
|
||||
void getPatchIds
|
||||
(
|
||||
const triSurf& origSurf,
|
||||
const wordList& patchNames,
|
||||
DynamicList<label>& patchIds
|
||||
)
|
||||
{
|
||||
const geometricSurfacePatchList& origPatches = origSurf.patches();
|
||||
|
||||
// Create patch name map
|
||||
HashSet<word> patchNameHash(patchNames);
|
||||
|
||||
// Find selected patches
|
||||
label nFound = 0;
|
||||
forAll(origPatches, patchI)
|
||||
{
|
||||
if (patchNameHash.found(origPatches[patchI].name()))
|
||||
{
|
||||
patchIds.append(patchI);
|
||||
nFound++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nFound != patchNames.size())
|
||||
{
|
||||
WarningIn("getPatchIds")
|
||||
<< "Not all supplied patch names were found on the surface mesh" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Copy all face subsets from one triSurf to another
|
||||
void copyFaceSubsets
|
||||
(
|
||||
const triSurf& origSurf,
|
||||
triSurf& newSurf
|
||||
)
|
||||
{
|
||||
DynList<label> subsetIds;
|
||||
origSurf.facetSubsetIndices(subsetIds);
|
||||
|
||||
forAll(subsetIds, subsetI)
|
||||
{
|
||||
label newSubsetId = newSurf.addFacetSubset
|
||||
(
|
||||
origSurf.facetSubsetName(subsetI)
|
||||
);
|
||||
|
||||
labelList origFaces;
|
||||
origSurf.facetsInSubset(subsetI, origFaces);
|
||||
|
||||
forAll(origFaces, faceI)
|
||||
{
|
||||
newSurf.addFacetToSubset
|
||||
(
|
||||
newSubsetId,
|
||||
origFaces[faceI]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Copy all edge subsets from one triSurf to another
|
||||
void copyEdgeSubsets
|
||||
(
|
||||
const triSurf& origSurf,
|
||||
triSurf& newSurf
|
||||
)
|
||||
{
|
||||
DynList<label> subsetIds;
|
||||
origSurf.edgeSubsetIndices(subsetIds);
|
||||
|
||||
forAll(subsetIds, subsetI)
|
||||
{
|
||||
label newSubsetId = newSurf.addEdgeSubset
|
||||
(
|
||||
origSurf.edgeSubsetName(subsetI)
|
||||
);
|
||||
|
||||
labelList origEdges;
|
||||
origSurf.edgesInSubset(subsetI, origEdges);
|
||||
|
||||
forAll(origEdges, faceI)
|
||||
{
|
||||
newSurf.addEdgeToSubset
|
||||
(
|
||||
newSubsetId,
|
||||
origEdges[faceI]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Copy all point subsets from one triSurf to another
|
||||
void copyPointSubsets
|
||||
(
|
||||
const triSurf& origSurf,
|
||||
triSurf& newSurf
|
||||
)
|
||||
{
|
||||
DynList<label> subsetIds;
|
||||
origSurf.pointSubsetIndices(subsetIds);
|
||||
|
||||
forAll(subsetIds, subsetI)
|
||||
{
|
||||
label newSubsetId = newSurf.addPointSubset
|
||||
(
|
||||
origSurf.pointSubsetName(subsetI)
|
||||
);
|
||||
|
||||
labelList origPoints;
|
||||
origSurf.pointsInSubset(subsetI, origPoints);
|
||||
|
||||
forAll(origPoints, faceI)
|
||||
{
|
||||
newSurf.addPointToSubset
|
||||
(
|
||||
newSubsetId,
|
||||
origPoints[faceI]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Merge the supplied list of patchIds onto a new patch
|
||||
autoPtr<triSurf> mergeSurfacePatches
|
||||
(
|
||||
const triSurf& origSurf, // Surface
|
||||
const UList<label>& patchIds, // Ids of patches to merge
|
||||
const word& newPatchName, // Name of new (merged) patch
|
||||
bool keepPatches // Keep the original patches - they will be emptied
|
||||
)
|
||||
{
|
||||
const geometricSurfacePatchList& origPatches = origSurf.patches();
|
||||
const LongList<labelledTri>& origFacets = origSurf.facets();
|
||||
|
||||
label newPatchId = origPatches.size();
|
||||
|
||||
// Determine new patch type
|
||||
word newPatchType = origPatches[patchIds[0]].geometricType();
|
||||
|
||||
// Create patch addressing
|
||||
List<DynamicList<label> > patchAddr(origPatches.size()+1);
|
||||
|
||||
forAll(origFacets, faceI)
|
||||
{
|
||||
patchAddr[origFacets[faceI].region()].append(faceI);
|
||||
}
|
||||
|
||||
// Move selected patches to new patch
|
||||
forAll(patchIds, patchI)
|
||||
{
|
||||
patchAddr[newPatchId].append(patchAddr[patchIds[patchI]]);
|
||||
patchAddr[patchIds[patchI]].clear();
|
||||
}
|
||||
|
||||
// Create new facets list
|
||||
LongList<labelledTri> newFacets(origFacets.size());
|
||||
labelList newFaceAddr(origFacets.size(), -1);
|
||||
|
||||
label patchCount = 0;
|
||||
label faceI = 0;
|
||||
forAll(patchAddr, patchI)
|
||||
{
|
||||
const unallocLabelList& addr = patchAddr[patchI];
|
||||
|
||||
if(addr.size())
|
||||
{
|
||||
forAll(addr, i)
|
||||
{
|
||||
newFacets[faceI] = origFacets[addr[i]];
|
||||
newFacets[faceI].region() = patchCount;
|
||||
|
||||
newFaceAddr[addr[i]] = faceI;
|
||||
|
||||
faceI++;
|
||||
}
|
||||
}
|
||||
|
||||
if(addr.size() || keepPatches)
|
||||
{
|
||||
patchCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new patch list
|
||||
geometricSurfacePatchList newPatches(patchCount);
|
||||
|
||||
patchCount = 0;
|
||||
forAll(origPatches, patchI)
|
||||
{
|
||||
// Only add patches if they contain faces
|
||||
if(patchAddr[patchI].size())
|
||||
{
|
||||
newPatches[patchCount] = origPatches[patchI];
|
||||
newPatches[patchCount].index() = patchCount;
|
||||
}
|
||||
|
||||
if(patchAddr[patchI].size() || keepPatches)
|
||||
{
|
||||
patchCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Add new patch if it contains faces
|
||||
if(patchAddr[patchAddr.size()-1].size())
|
||||
{
|
||||
newPatches[patchCount] = geometricSurfacePatch
|
||||
(
|
||||
newPatchType,
|
||||
newPatchName,
|
||||
patchCount
|
||||
);
|
||||
}
|
||||
if(patchAddr[patchAddr.size()-1].size() || keepPatches)
|
||||
{
|
||||
patchCount++;
|
||||
}
|
||||
|
||||
// Create new surface
|
||||
autoPtr<triSurf> newSurf
|
||||
(
|
||||
new triSurf
|
||||
(
|
||||
newFacets,
|
||||
newPatches,
|
||||
origSurf.featureEdges(),
|
||||
origSurf.points()
|
||||
)
|
||||
);
|
||||
|
||||
// Transfer face subsets
|
||||
copyFaceSubsets(origSurf, newSurf());
|
||||
newSurf->updateFacetsSubsets(newFaceAddr);
|
||||
|
||||
// Transfer feature edge subsets
|
||||
copyEdgeSubsets(origSurf, newSurf());
|
||||
|
||||
// Transfer point subsets
|
||||
copyPointSubsets(origSurf, newSurf());
|
||||
|
||||
// Done
|
||||
return newSurf;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
|
||||
argList::validArgs.append("input surface file");
|
||||
argList::validArgs.append("new patch");
|
||||
argList::validOptions.insert("patchNames", "list of names");
|
||||
argList::validOptions.insert("patchIds", "list of patchIds");
|
||||
argList::validOptions.insert("patchIdRange", "( start end )");
|
||||
argList::validOptions.insert("output", "file name (default overwrite)");
|
||||
argList::validOptions.insert("keep", "");
|
||||
argList args(argc, argv);
|
||||
|
||||
// Process commandline arguments
|
||||
fileName inFileName(args.args()[1]);
|
||||
|
||||
word newPatchName(args.args()[2]);
|
||||
|
||||
fileName outFileName(inFileName);
|
||||
|
||||
if( args.options().found("output") )
|
||||
{
|
||||
outFileName = args.options()["output"];
|
||||
}
|
||||
|
||||
bool keepPatches = false;
|
||||
|
||||
if( args.options().found("keep") )
|
||||
{
|
||||
keepPatches = true;
|
||||
}
|
||||
|
||||
// Read original surface
|
||||
triSurf origSurf(inFileName);
|
||||
|
||||
// Get patch ids
|
||||
DynamicList<label> patchIds;
|
||||
|
||||
if (args.options().found("patchNames"))
|
||||
{
|
||||
if (args.options().found("patchIds"))
|
||||
{
|
||||
FatalError() << "Cannot specify both patch names and ids"
|
||||
<< Foam::abort(FatalError);
|
||||
}
|
||||
|
||||
IStringStream is(args.options()["patchNames"]);
|
||||
wordList patchNames(is);
|
||||
|
||||
getPatchIds
|
||||
(
|
||||
origSurf,
|
||||
patchNames,
|
||||
patchIds
|
||||
);
|
||||
}
|
||||
if (args.options().found("patchIds"))
|
||||
{
|
||||
IStringStream is(args.options()["patchIds"]);
|
||||
|
||||
patchIds = labelList(is);
|
||||
}
|
||||
if (args.options().found("patchIds"))
|
||||
{
|
||||
IStringStream is(args.options()["patchIds"]);
|
||||
|
||||
patchIds.append(labelList(is));
|
||||
}
|
||||
if (args.options().found("patchIdRange"))
|
||||
{
|
||||
IStringStream is(args.options()["patchIdRange"]);
|
||||
|
||||
Pair<label> idRange(is);
|
||||
|
||||
for(label id = idRange.first(); id <= idRange.second(); id++)
|
||||
{
|
||||
patchIds.append(id);
|
||||
}
|
||||
}
|
||||
if (!patchIds.size())
|
||||
{
|
||||
FatalError() << "No patches specified"
|
||||
<< Foam::abort(FatalError);
|
||||
}
|
||||
|
||||
// Merge patches
|
||||
autoPtr<triSurf> newSurf = mergeSurfacePatches
|
||||
(
|
||||
origSurf,
|
||||
patchIds,
|
||||
newPatchName,
|
||||
keepPatches
|
||||
);
|
||||
|
||||
// Write new surface mesh
|
||||
newSurf->writeSurface(outFileName);
|
||||
|
||||
Info << "Original surface patches: " << origSurf.patches().size() << endl;
|
||||
Info << "Final surface patches: " << newSurf->patches().size() << endl;
|
||||
Info << "Surface written to " << outFileName << endl;
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -1,131 +0,0 @@
|
|||
#!python
|
||||
# =============================================================================
|
||||
# Salome GEOM script to extract the feature edges from a body and add them
|
||||
# to the group named 'featureEdges'.
|
||||
# Tested on Salome 7.4.0 and python 2.7 on 64-bit Windows
|
||||
#
|
||||
# Author: Ivor Clifford <ivor.clifford@psi.ch>
|
||||
#
|
||||
# =============================================================================
|
||||
|
||||
def extractFeatureEdges(body, minFeatureAngle = 5):
|
||||
'''
|
||||
Find all feature edges on the supplied body and return them as a list
|
||||
of edge ids.
|
||||
|
||||
body - A Salome solid, compound, shell or face object to find all
|
||||
feature edges on.
|
||||
minFeatureAngle - the angle (in degrees) between adjacent surfaces
|
||||
above which the edge will be considered a feature angle.
|
||||
'''
|
||||
import salome
|
||||
salome.salome_init()
|
||||
|
||||
import GEOM
|
||||
from salome.geom import geomBuilder
|
||||
geompy = geomBuilder.New(salome.myStudy)
|
||||
|
||||
# Check the body type
|
||||
if not (body.GetShapeType() in [GEOM.SHELL, GEOM.SOLID, GEOM.FACE, GEOM.COMPOUND]):
|
||||
raise RuntimeError('Supplied object is not a solid, shell or face.')
|
||||
|
||||
print 'Extracting edges of %s with feature angle > %g.' % (body.GetName(), minFeatureAngle)
|
||||
|
||||
# Extract basic info
|
||||
faces = geompy.SubShapeAll(body, geompy.ShapeType["FACE"])
|
||||
curves = geompy.SubShapeAll(body, geompy.ShapeType["EDGE"])
|
||||
points = geompy.SubShapeAll(body, geompy.ShapeType["VERTEX"])
|
||||
|
||||
faceIds = geompy.GetSubShapesIDs(body, faces)
|
||||
curveIds = geompy.GetSubShapesIDs(body, curves)
|
||||
nodeIds = geompy.GetSubShapesIDs(body, points)
|
||||
|
||||
maxFaceId = max(faceIds)
|
||||
maxCurveId = max(curveIds)
|
||||
maxNodeId = max(nodeIds)
|
||||
|
||||
# Reverse mapping from curve id to local curve arrays
|
||||
faceMap = [-1 for i in xrange(maxFaceId+1)]
|
||||
for localId, id in enumerate(faceIds):
|
||||
faceMap[id] = localId
|
||||
|
||||
curveMap = [-1 for i in xrange(maxCurveId+1)]
|
||||
for localId, id in enumerate(curveIds):
|
||||
curveMap[id] = localId
|
||||
|
||||
nodeMap = [-1 for i in xrange(maxNodeId+1)]
|
||||
for localId, id in enumerate(nodeIds):
|
||||
nodeMap[id] = localId
|
||||
|
||||
|
||||
# Get curves on each face
|
||||
faceCurveIds = [[curveMap[id] for id in geompy.GetSubShapesIDs(
|
||||
body,
|
||||
geompy.SubShapeAll(face, geompy.ShapeType["EDGE"])
|
||||
)] for face in faces]
|
||||
|
||||
# Get faces attached to each curve
|
||||
curveFaceIds = [[] for id in curveIds]
|
||||
|
||||
for faceI, ids in enumerate(faceCurveIds):
|
||||
for id in ids:
|
||||
curveFaceIds[id].append(faceI)
|
||||
|
||||
# Now that we have the connectivity for curves and faces find the
|
||||
# feature edges
|
||||
featureEdgeIds = []
|
||||
for curveId, curve, adjFaceIds in zip(curveIds, curves, curveFaceIds):
|
||||
if len(adjFaceIds) == 2:
|
||||
# Curve with 2 adjacent faces - Test feature angle
|
||||
# Determine break angle at each curve
|
||||
# If greater than the feature edge angle, add the curve to group featureEdges
|
||||
face1 = faces[adjFaceIds[0]]
|
||||
face2 = faces[adjFaceIds[1]]
|
||||
point = geompy.GetFirstVertex(curve) # Test at the first vertex
|
||||
n1 = geompy.GetNormal(face1, point)
|
||||
n2 = geompy.GetNormal(face2, point)
|
||||
angle = geompy.GetAngle(n1, n2)
|
||||
if angle > minFeatureAngle:
|
||||
featureEdgeIds.append(curveId)
|
||||
|
||||
elif len(adjFaceIds) == 1:
|
||||
# Curve on standalone face - Add by default
|
||||
featureEdgeIds.append(curveId)
|
||||
|
||||
elif len(adjFaceIds) == 0:
|
||||
# Standalone curve - Ignore
|
||||
None
|
||||
|
||||
else:
|
||||
raise RuntimeError('Curve found sharing %d faces. This is unexpected for fully enclosed bodies.' % len(adjFaceIds))
|
||||
|
||||
# Done
|
||||
print "%d feature edges found" % len(featureEdgeIds)
|
||||
|
||||
return featureEdgeIds
|
||||
|
||||
|
||||
# If run as a standalone script, use the current Salome GUI selection
|
||||
# and add the feature edges to group named 'featureEdges'
|
||||
if __name__ == '__main__':
|
||||
import salome
|
||||
salome.salome_init()
|
||||
|
||||
import GEOM
|
||||
from salome.geom import geomBuilder
|
||||
geompy = geomBuilder.New(salome.myStudy)
|
||||
|
||||
# Get current GUI selection
|
||||
selected = salome.sg.getAllSelected()
|
||||
if len(selected) != 1:
|
||||
raise RuntimeError('A single solid, shell or face object must be selected.')
|
||||
|
||||
body = salome.myStudy.FindObjectID(selected[0]).GetObject()
|
||||
|
||||
# Get feature edges and add to the group 'featureEdges'
|
||||
featureEdges = geompy.CreateGroup(body, geompy.ShapeType["EDGE"])
|
||||
geompy.UnionIDs(featureEdges, extractFeatureEdges(body))
|
||||
geompy.addToStudyInFather(body, featureEdges, 'featureEdges')
|
||||
|
||||
if salome.sg.hasDesktop():
|
||||
salome.sg.updateObjBrowser(1)
|
|
@ -1,363 +0,0 @@
|
|||
#!python
|
||||
# =============================================================================
|
||||
# Python module for writing OpenFOAM feature edge and triSurface files from
|
||||
# within Salome platform.
|
||||
# Tested on Salome 7.4.0 and python 2.7 on 64-bit Windows
|
||||
#
|
||||
# Author: Ivor Clifford <ivor.clifford@psi.ch>
|
||||
#
|
||||
# =============================================================================
|
||||
|
||||
def foamHeader(className, objectName):
|
||||
'''
|
||||
Return the OpenFOAM file header block as a string.
|
||||
'''
|
||||
return '''/*--------------------------------*- C++ -*----------------------------------*\\
|
||||
| ========= | |
|
||||
| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\\\ / O peration | Version: 2.2.1 |
|
||||
| \\\\ / A nd | Web: www.OpenFOAM.org |
|
||||
| \\\\/ M anipulation | |
|
||||
\\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class %s;
|
||||
object %s;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
''' % (className, objectName)
|
||||
|
||||
|
||||
class triSurf:
|
||||
def __init__(self, object = None, allEdges = False):
|
||||
'''
|
||||
Construct from the supplied Salome mesh.
|
||||
|
||||
object - the mesh object (must be a triangular surface mesh). If no
|
||||
object is supplied, the current Salome selection is used.
|
||||
allEdges - If true, all edges on the mesh are included as feature
|
||||
edges, otherwise only edges contained in groups are included
|
||||
|
||||
NOTE: All face groups are assumed to represent patches. No face subsets
|
||||
are written. All edge groups are added as feature edge subsets. All point
|
||||
groups are added as point subsets.
|
||||
'''
|
||||
# =============================================================================
|
||||
# Initialize salome
|
||||
import salome
|
||||
import SMESH, SALOMEDS
|
||||
from salome.smesh import smeshBuilder
|
||||
from operator import itemgetter
|
||||
from collections import OrderedDict
|
||||
|
||||
import SMESH, SALOMEDS
|
||||
|
||||
# =============================================================================
|
||||
# Get the Salome mesh object
|
||||
if object is None:
|
||||
selected = salome.sg.getAllSelected()
|
||||
if len(selected) != 1:
|
||||
raise RuntimeError('A single Salome mesh object must be selected.')
|
||||
|
||||
object = salome.myStudy.FindObjectID(selected[0]).GetObject()
|
||||
|
||||
try:
|
||||
object.GetMesh()
|
||||
except:
|
||||
raise RuntimeError('Supplied object is not a Salome SMESH mesh.')
|
||||
|
||||
smesh = smeshBuilder.New(salome.myStudy)
|
||||
mesh = smesh.Mesh(object)
|
||||
|
||||
print "Converting SMESH Mesh '%s'" % mesh.GetName()
|
||||
|
||||
# =============================================================================
|
||||
# Get basic mesh info
|
||||
nNodes = mesh.NbNodes()
|
||||
nFaces = mesh.NbFaces()
|
||||
nTris = mesh.NbTriangles()
|
||||
nEdges = mesh.NbEdges()
|
||||
nodeIds = mesh.GetNodesId()
|
||||
faceIds = mesh.GetElementsByType(SMESH.FACE)
|
||||
edgeIds = mesh.GetElementsByType(SMESH.EDGE)
|
||||
|
||||
# Check that mesh is strictly triangular
|
||||
if nFaces != nTris:
|
||||
raise RuntimeError('Mesh is not strictly triangular')
|
||||
|
||||
# Get patch and subset names & ids
|
||||
# All SMESH.FACE groups are assumed to be patches
|
||||
# All SMESH.EDGE groups are assumed to be feature subsets
|
||||
# All SMESH.NODE groups are assumed to be point subsets
|
||||
patches = OrderedDict()
|
||||
pointSubsets = OrderedDict()
|
||||
featureEdgeSubsets = OrderedDict()
|
||||
|
||||
for group in mesh.GetGroups():
|
||||
if group.GetType() == SMESH.FACE:
|
||||
patches[group.GetName()] = group.GetIDs()
|
||||
elif group.GetType() == SMESH.EDGE:
|
||||
featureEdgeSubsets[group.GetName()] = group.GetIDs()
|
||||
elif group.GetType() == SMESH.NODE:
|
||||
pointSubsets[group.GetName()] = group.GetIDs()
|
||||
|
||||
# =============================================================================
|
||||
# Process faces and patches
|
||||
# Get patchId for each face
|
||||
lastPatchId = len(patches)
|
||||
patchIds = [lastPatchId] * max(faceIds)
|
||||
patchId = 0
|
||||
for name, ids in patches.iteritems():
|
||||
for faceId in ids:
|
||||
if patchIds[faceId-1] == lastPatchId:
|
||||
patchIds[faceId-1] = patchId
|
||||
else:
|
||||
print "Face %d is assigned to both groups %s and %s" % (faceId, name, patches.keys()[patchIds[faceId-1]])
|
||||
raise RuntimeError('Groups of faces are not unique, i.e. they overlap.')
|
||||
|
||||
patchId += 1
|
||||
|
||||
# Compact and reorder patchIds to match faceIds
|
||||
patchIds = [patchIds[faceId-1] for faceId in faceIds]
|
||||
|
||||
# Reorder faces by increasing group id
|
||||
faceAndpatchIds = sorted(zip(faceIds, patchIds), key=itemgetter(1))
|
||||
faceIds, patchIds = zip(*faceAndpatchIds)
|
||||
|
||||
# Add unused faces to the default patch
|
||||
defaultFaces = [faceId for faceId, patchId in faceAndpatchIds if patchId == lastPatchId]
|
||||
if len(defaultFaces) > 0:
|
||||
patches['defaultFaces'] = defaultFaces
|
||||
|
||||
defaultFaces = None
|
||||
|
||||
# =============================================================================
|
||||
# Process feature edges
|
||||
if not allEdges:
|
||||
edgeIds = []
|
||||
for name, ids in featureEdgeSubsets.iteritems():
|
||||
edgeIds += ids
|
||||
|
||||
edgeIds = list(set(edgeIds))
|
||||
nEdges = len(edgeIds)
|
||||
|
||||
# Reverse mapping of edge ids since they aren't necessarily numbered 1..nEdges
|
||||
if len(edgeIds):
|
||||
edgeMap = [-1] * max(edgeIds)
|
||||
else:
|
||||
edgeMap = []
|
||||
|
||||
i=0
|
||||
for edgeId in edgeIds:
|
||||
edgeMap[edgeId-1] = i
|
||||
i += 1
|
||||
|
||||
# =============================================================================
|
||||
# Process nodes
|
||||
# Reverse mapping of node ids since nodes aren't necessarily numbered 1..nNodes
|
||||
nodeMap = [-1] * max(nodeIds)
|
||||
i=0
|
||||
for nodeId in nodeIds:
|
||||
nodeMap[nodeId-1] = i
|
||||
i += 1
|
||||
|
||||
# =============================================================================
|
||||
|
||||
self._mesh = mesh
|
||||
|
||||
self._nodeIds = nodeIds
|
||||
self._edgeIds = edgeIds
|
||||
self._faceIds = faceIds
|
||||
|
||||
self._nodeMap = nodeMap
|
||||
self._edgeMap = edgeMap
|
||||
self._faceMap = []
|
||||
|
||||
self._patches = patches
|
||||
self._pointSubsets = pointSubsets
|
||||
self._featureEdgeSubsets = featureEdgeSubsets
|
||||
self._faceSubsets = {}
|
||||
|
||||
print 'Done'
|
||||
|
||||
def nNodes(self):
|
||||
'''
|
||||
Return the number of nodes
|
||||
'''
|
||||
return len(self._nodeIds)
|
||||
|
||||
def nEdges(self):
|
||||
'''
|
||||
Return the number of edges
|
||||
'''
|
||||
return len(self._edgeIds)
|
||||
|
||||
def nFacets(self):
|
||||
'''
|
||||
Return the number of triangular facets
|
||||
'''
|
||||
return len(self._faceIds)
|
||||
|
||||
def nPatches(self):
|
||||
'''
|
||||
Return the number of patches
|
||||
'''
|
||||
return len(self._patches)
|
||||
|
||||
def _writePatchDefs(self, f, typeName = 'wall'):
|
||||
'''
|
||||
Write the patch definitions to file as an OpenFOAM geometricSurfacePatchList.
|
||||
NOTE: All patches are assumed to be walls.
|
||||
'''
|
||||
patches = self._patches
|
||||
|
||||
f.write('%d\n(\n' % len(patches))
|
||||
for name in patches.iterkeys():
|
||||
f.write('%s\t%s\n' % (name, typeName))
|
||||
|
||||
f.write(')\n')
|
||||
|
||||
def _writeNodes(self, f):
|
||||
'''
|
||||
Write the nodes to file as an OpenFOAM pointField.
|
||||
'''
|
||||
mesh = self._mesh
|
||||
nodeIds = self._nodeIds
|
||||
|
||||
f.write('%d\n(\n' % len(nodeIds))
|
||||
|
||||
for x, y, z in [mesh.GetNodeXYZ(nodeId) for nodeId in nodeIds]:
|
||||
f.write( '( %g %g %g )\n' % (x, y, z))
|
||||
|
||||
f.write(')\n')
|
||||
|
||||
def _writeFeatureEdges(self, f):
|
||||
'''
|
||||
Write the feature edges to file as an OpenFOAM edgeList.
|
||||
'''
|
||||
mesh = self._mesh
|
||||
nodeMap = self._nodeMap
|
||||
edgeIds = self._edgeIds
|
||||
|
||||
f.write('%d\n(\n' % len(edgeIds))
|
||||
|
||||
for edgeId in edgeIds:
|
||||
nodes = mesh.GetElemNodes(edgeId)
|
||||
f.write( '(' + ' '.join([str(nodeMap[nodeId-1]) for nodeId in nodes]) + ')\n')
|
||||
|
||||
f.write(')\n')
|
||||
|
||||
def _writeFacets(self, f):
|
||||
'''
|
||||
Write the facets to file as an OpenFOAM List of labelledTri.
|
||||
'''
|
||||
from itertools import chain
|
||||
|
||||
mesh = self._mesh
|
||||
nodeMap = self._nodeMap
|
||||
patches = self._patches
|
||||
|
||||
f.write('%d\n(\n' % sum([len(patch) for patch in patches.itervalues()]))
|
||||
|
||||
patchId = 0
|
||||
for patchId, (patchName, faceIds) in enumerate(patches.iteritems()):
|
||||
for faceId in faceIds:
|
||||
nodes = mesh.GetElemNodes(faceId)
|
||||
f.write( '((' + ' '.join([str(nodeMap[nodeId-1]) for nodeId in nodes]) + ') %d)\n' % patchId)
|
||||
|
||||
f.write(')\n')
|
||||
|
||||
def _writeSubsets(self, f, subsets, map, typeId):
|
||||
'''
|
||||
General function to write a subset to file as an OpenFOAM Map<meshSubset>.
|
||||
'''
|
||||
f.write('%d\n(\n' % len(subsets))
|
||||
for name, ids in subsets.iteritems():
|
||||
f.write('%s %s %d ( %s )\n' % (name, typeId, len(ids), ' '.join([str(map[id-1]) for id in ids])))
|
||||
|
||||
f.write(')\n')
|
||||
|
||||
def _writePointSubsets(self, f):
|
||||
'''
|
||||
Write the point subsets to file as and OpenFOAM Map<meshSubset>.
|
||||
'''
|
||||
self._writeSubsets(f, self._pointSubsets, self._nodeMap, '2')
|
||||
|
||||
def _writeFaceSubsets(self, f):
|
||||
'''
|
||||
Write the face subsets to file as and OpenFOAM Map<meshSubset>.
|
||||
'''
|
||||
self._writeSubsets(f, self._faceSubsets, self._faceMap, '4')
|
||||
|
||||
def _writeFeatureEdgeSubsets(self, f):
|
||||
'''
|
||||
Write the feature edge subsets to file as and OpenFOAM Map<meshSubset>.
|
||||
'''
|
||||
self._writeSubsets(f, self._featureEdgeSubsets, self._edgeMap, '8')
|
||||
|
||||
def writeEdgeMesh(self, fileName):
|
||||
'''
|
||||
Write to file as an OpenFOAM edgeMesh
|
||||
|
||||
fileName - The file name to write
|
||||
'''
|
||||
# Create file
|
||||
f = open(fileName, 'wb') # NOTE: file opened as binary to ensure unix-style line breaks
|
||||
|
||||
# Write header
|
||||
f.write(foamHeader('edgeMesh', self._mesh.GetName()))
|
||||
|
||||
self._writeNodes(f)
|
||||
self._writeFeatureEdges(f)
|
||||
|
||||
f.close()
|
||||
|
||||
print 'edgeMesh written to %s' % fileName
|
||||
|
||||
def writeFtr(self, fileName):
|
||||
'''
|
||||
Write to file as an OpenFOAM cfMesh FTR file
|
||||
|
||||
fileName - the file name to write
|
||||
'''
|
||||
# Create file
|
||||
f = open(fileName, 'wb') # NOTE: file opened as binary to ensure unix-style line breaks
|
||||
|
||||
self._writePatchDefs(f)
|
||||
self._writeNodes(f)
|
||||
self._writeFacets(f)
|
||||
|
||||
f.close()
|
||||
|
||||
print 'triSurf written to %s' % fileName
|
||||
|
||||
def writeFms(self, fileName):
|
||||
'''
|
||||
Write to file as an OpenFOAM cfMesh FMS file
|
||||
|
||||
fileName - the file name to write
|
||||
'''
|
||||
# Create file
|
||||
f = open(fileName, 'wb') # NOTE: file opened as binary to ensure unix-style line breaks
|
||||
|
||||
self._writePatchDefs(f)
|
||||
self._writeNodes(f)
|
||||
self._writeFacets(f)
|
||||
self._writeFeatureEdges(f)
|
||||
self._writePointSubsets(f)
|
||||
self._writeFaceSubsets(f)
|
||||
self._writeFeatureEdgeSubsets(f)
|
||||
|
||||
f.close()
|
||||
|
||||
print 'triSurf written to %s' % fileName
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import salome
|
||||
salome.salome_init()
|
||||
|
||||
import SMESH, SALOMEDS
|
|
@ -1,3 +0,0 @@
|
|||
surfaceToFMS.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/surfaceToFMS
|
|
@ -1,9 +0,0 @@
|
|||
EXE_INC = \
|
||||
-I$(FOAM_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
|
||||
-I$(LIB_SRC)/triSurface/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-ltriSurface \
|
||||
-lmeshLibrary \
|
||||
-lmeshTools
|
|
@ -1,63 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | cfMesh: A library for mesh generation
|
||||
\\ / O peration |
|
||||
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
|
||||
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of cfMesh.
|
||||
|
||||
cfMesh 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.
|
||||
|
||||
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Reads the specified surface and writes it in the fms format.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "IFstream.H"
|
||||
#include "fileName.H"
|
||||
#include "triSurf.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
argList::validArgs.append("input surface file");
|
||||
argList args(argc, argv);
|
||||
|
||||
const fileName inFileName(args.args()[1]);
|
||||
if( inFileName.ext() == "fms" )
|
||||
FatalError << "trying to convert a fms file to itself"
|
||||
<< exit(FatalError);
|
||||
|
||||
fileName outFileName(inFileName.lessExt()+".fms");
|
||||
|
||||
const triSurf surface(inFileName);
|
||||
|
||||
surface.writeSurface(outFileName);
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
|
@ -30,9 +30,10 @@ Description
|
|||
Author
|
||||
Hrvoje Jasak, Wikki Ltd. All rights reserved
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "coupledLduMatrix.H"
|
||||
#include "processorLduInterfaceField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -42,9 +43,6 @@ namespace Foam
|
|||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct given size
|
||||
|
@ -219,8 +217,8 @@ void Foam::coupledLduMatrix::initMatrixInterfaces
|
|||
{
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::blocking
|
||||
|| Pstream::defaultCommsType == Pstream::nonBlocking
|
||||
Pstream::defaultCommsType() == Pstream::blocking
|
||||
|| Pstream::defaultCommsType() == Pstream::nonBlocking
|
||||
)
|
||||
{
|
||||
forAll (interfaces[rowI], interfaceI)
|
||||
|
@ -242,7 +240,10 @@ void Foam::coupledLduMatrix::initMatrixInterfaces
|
|||
matrices[rowI],
|
||||
coupleCoeffs[rowI][interfaceI],
|
||||
cmpt,
|
||||
Pstream::defaultCommsType,
|
||||
static_cast<const Pstream::commsTypes>
|
||||
(
|
||||
Pstream::defaultCommsType()
|
||||
),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
@ -267,8 +268,8 @@ void Foam::coupledLduMatrix::initMatrixInterfaces
|
|||
{
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::blocking
|
||||
|| Pstream::defaultCommsType == Pstream::nonBlocking
|
||||
Pstream::defaultCommsType() == Pstream::blocking
|
||||
|| Pstream::defaultCommsType() == Pstream::nonBlocking
|
||||
)
|
||||
{
|
||||
forAll (interfaces[rowI], interfaceI)
|
||||
|
@ -290,7 +291,10 @@ void Foam::coupledLduMatrix::initMatrixInterfaces
|
|||
matrices[rowI],
|
||||
coupleCoeffs[rowI][interfaceI],
|
||||
cmpt,
|
||||
static_cast<const Pstream::commsTypes>(Pstream::defaultCommsType()),
|
||||
static_cast<const Pstream::commsTypes>
|
||||
(
|
||||
Pstream::defaultCommsType()
|
||||
),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
@ -326,13 +330,4 @@ void Foam::coupledLduMatrix::updateMatrixInterfaces
|
|||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -209,21 +209,27 @@ void Foam::Pstream::initCommunicationSchedule()
|
|||
// Initialise my process number to 0 (the master)
|
||||
int Foam::Pstream::myProcNo_(0);
|
||||
|
||||
|
||||
// By default this is not a parallel run
|
||||
bool Foam::Pstream::parRun_(false);
|
||||
|
||||
|
||||
// List of process IDs
|
||||
Foam::List<int> Foam::Pstream::procIDs_(1, 0);
|
||||
|
||||
|
||||
// Standard transfer message type
|
||||
const int Foam::Pstream::msgType_(1);
|
||||
|
||||
|
||||
// Linear communication schedule
|
||||
Foam::List<Foam::Pstream::commsStruct> Foam::Pstream::linearCommunication_(0);
|
||||
|
||||
|
||||
// Multi level communication schedule
|
||||
Foam::List<Foam::Pstream::commsStruct> Foam::Pstream::treeCommunication_(0);
|
||||
|
||||
|
||||
// Should compact transfer be used in which floats replace doubles
|
||||
// reducing the bandwidth requirement at the expense of some loss
|
||||
// in accuracy
|
||||
|
@ -234,6 +240,7 @@ Foam::Pstream::floatTransfer
|
|||
0
|
||||
);
|
||||
|
||||
|
||||
// Number of processors at which the reduce algorithm changes from linear to
|
||||
// tree
|
||||
const Foam::debug::optimisationSwitch
|
||||
|
@ -243,18 +250,20 @@ Foam::Pstream::nProcsSimpleSum
|
|||
16
|
||||
);
|
||||
|
||||
|
||||
// Default commsType
|
||||
Foam::Pstream::commsTypes Foam::Pstream::defaultCommsType_
|
||||
(
|
||||
commsTypeNames
|
||||
[
|
||||
debug::optimisationSwitches().lookupOrAddDefault
|
||||
(
|
||||
"commsType",
|
||||
word("blocking")
|
||||
)
|
||||
]
|
||||
);
|
||||
// Foam::Pstream::commsTypes Foam::Pstream::defaultCommsType
|
||||
// (
|
||||
// commsTypeNames
|
||||
// [
|
||||
// debug::optimisationSwitches().lookupOrAddDefault
|
||||
// (
|
||||
// "commsType",
|
||||
// word("blocking")
|
||||
// )
|
||||
// ]
|
||||
// );
|
||||
|
||||
|
||||
const Foam::debug::optimisationSwitch
|
||||
Foam::Pstream::defaultCommsType
|
||||
|
@ -264,4 +273,5 @@ Foam::Pstream::defaultCommsType
|
|||
"blocking, nonBlocking, scheduled"
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -232,10 +232,9 @@ public:
|
|||
static const Foam::debug::optimisationSwitch nProcsSimpleSum;
|
||||
|
||||
//- Default commsType
|
||||
static commsTypes defaultCommsType_;
|
||||
|
||||
static const Foam::debug::optimisationSwitch defaultCommsType;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given optional buffer size
|
||||
|
|
|
@ -205,7 +205,8 @@ public:
|
|||
// A null pointer is treated like an empty dictionary.
|
||||
dictionary(const dictionary*);
|
||||
|
||||
//- Construct by transferring parameter contents given parent dictionary
|
||||
//- Construct by transferring parameter contents from
|
||||
// given parent dictionary
|
||||
dictionary(const dictionary& parentDict, const Xfer<dictionary>&);
|
||||
|
||||
//- Construct top-level dictionary by transferring parameter contents
|
||||
|
@ -245,7 +246,7 @@ public:
|
|||
|
||||
//- Search dictionary for given keyword
|
||||
// If recursive, search parent dictionaries
|
||||
bool found(const word&, bool recursive=false) const;
|
||||
bool found(const word&, bool recursive = false) const;
|
||||
|
||||
//- Find and return an entry data stream pointer if present
|
||||
// otherwise return NULL.
|
||||
|
@ -269,7 +270,8 @@ public:
|
|||
bool patternMatch
|
||||
);
|
||||
|
||||
//- Find and return an entry data stream if present otherwise error.
|
||||
//- Find and return an entry data stream
|
||||
// if present otherwise error.
|
||||
// If recursive, search parent dictionaries.
|
||||
// If patternMatch, use regular expressions.
|
||||
const entry& lookupEntry
|
||||
|
@ -285,8 +287,8 @@ public:
|
|||
ITstream& lookup
|
||||
(
|
||||
const word&,
|
||||
bool recursive=false,
|
||||
bool patternMatch=true
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
) const;
|
||||
|
||||
//- Find and return a T,
|
||||
|
@ -298,8 +300,8 @@ public:
|
|||
(
|
||||
const word&,
|
||||
const T&,
|
||||
bool recursive=false,
|
||||
bool patternMatch=true
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
) const;
|
||||
|
||||
//- Find and return a T, if not found return the given
|
||||
|
@ -311,8 +313,8 @@ public:
|
|||
(
|
||||
const word&,
|
||||
const T&,
|
||||
bool recursive=false,
|
||||
bool patternMatch=true
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
);
|
||||
|
||||
//- Find an entry if present, and assign to T
|
||||
|
@ -324,8 +326,8 @@ public:
|
|||
(
|
||||
const word&,
|
||||
T&,
|
||||
bool recursive=false,
|
||||
bool patternMatch=true
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
) const;
|
||||
|
||||
//- Check if entry is a sub-dictionary
|
||||
|
@ -349,7 +351,7 @@ public:
|
|||
wordList toc() const;
|
||||
|
||||
//- Return the list of available keys or patterns
|
||||
List<keyType> keys(bool patterns=false) const;
|
||||
List<keyType> keys(bool patterns = false) const;
|
||||
|
||||
|
||||
// Editing
|
||||
|
@ -361,28 +363,28 @@ public:
|
|||
//- Add a new entry
|
||||
// With the merge option, dictionaries are interwoven and
|
||||
// primitive entries are overwritten
|
||||
bool add(entry*, bool mergeEntry=false);
|
||||
bool add(entry*, bool mergeEntry = false);
|
||||
|
||||
//- Add an entry
|
||||
// With the merge option, dictionaries are interwoven and
|
||||
// primitive entries are overwritten
|
||||
void add(const entry&, bool mergeEntry=false);
|
||||
void add(const entry&, bool mergeEntry = false);
|
||||
|
||||
//- Add a word entry
|
||||
// optionally overwrite an existing entry
|
||||
void add(const keyType&, const word&, bool overwrite=false);
|
||||
void add(const keyType&, const word&, bool overwrite = false);
|
||||
|
||||
//- Add a string entry
|
||||
// optionally overwrite an existing entry
|
||||
void add(const keyType&, const string&, bool overwrite=false);
|
||||
void add(const keyType&, const string&, bool overwrite = false);
|
||||
|
||||
//- Add a label entry
|
||||
// optionally overwrite an existing entry
|
||||
void add(const keyType&, const label, bool overwrite=false);
|
||||
void add(const keyType&, const label, bool overwrite = false);
|
||||
|
||||
//- Add a scalar entry
|
||||
// optionally overwrite an existing entry
|
||||
void add(const keyType&, const scalar, bool overwrite=false);
|
||||
void add(const keyType&, const scalar, bool overwrite = false);
|
||||
|
||||
//- Add a dictionary entry
|
||||
// optionally merge with an existing sub-dictionary
|
||||
|
@ -390,13 +392,13 @@ public:
|
|||
(
|
||||
const keyType&,
|
||||
const dictionary&,
|
||||
bool mergeEntry=false
|
||||
bool mergeEntry = false
|
||||
);
|
||||
|
||||
//- Add a T entry
|
||||
// optionally overwrite an existing entry
|
||||
template<class T>
|
||||
void add(const keyType&, const T&, bool overwrite=false);
|
||||
void add(const keyType&, const T&, bool overwrite = false);
|
||||
|
||||
//- Assign a new entry, overwrite any existing entry
|
||||
void set(entry*);
|
||||
|
@ -420,7 +422,7 @@ public:
|
|||
(
|
||||
const keyType& oldKeyword,
|
||||
const keyType& newKeyword,
|
||||
bool forceOverwrite=false
|
||||
bool forceOverwrite = false
|
||||
);
|
||||
|
||||
//- Merge entries from the given dictionary.
|
||||
|
@ -445,7 +447,7 @@ public:
|
|||
|
||||
// Write
|
||||
|
||||
void write(Ostream&, bool subDict=true) const;
|
||||
void write(Ostream&, bool subDict = true) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
|
|
@ -138,7 +138,7 @@ public: \
|
|||
Type::debug(std::string(Name), DebugSwitch, SwitchDescr)
|
||||
|
||||
//- Define the debug information
|
||||
#define defineDebugSwitch(Type, DebugSwitch, SwitchDescr) \
|
||||
#define defineDebugSwitch(Type, DebugSwitch, SwitchDescr) \
|
||||
defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch, SwitchDescr);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
|
|
|
@ -287,20 +287,20 @@ evaluate()
|
|||
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::blocking
|
||||
|| Pstream::defaultCommsType == Pstream::nonBlocking
|
||||
Pstream::defaultCommsType() == Pstream::blocking
|
||||
|| Pstream::defaultCommsType() == Pstream::nonBlocking
|
||||
)
|
||||
{
|
||||
forAll(*this, patchi)
|
||||
{
|
||||
this->operator[](patchi).initEvaluate
|
||||
(
|
||||
static_cast<Pstream::commsTypes>(Pstream::defaultCommsType())
|
||||
);
|
||||
(
|
||||
static_cast<Pstream::commsTypes>(Pstream::defaultCommsType())
|
||||
);
|
||||
}
|
||||
|
||||
// Block for any outstanding requests
|
||||
if (Pstream::defaultCommsType == Pstream::nonBlocking)
|
||||
if (Pstream::defaultCommsType() == Pstream::nonBlocking)
|
||||
{
|
||||
IPstream::waitRequests();
|
||||
OPstream::waitRequests();
|
||||
|
@ -309,12 +309,12 @@ evaluate()
|
|||
forAll(*this, patchi)
|
||||
{
|
||||
this->operator[](patchi).evaluate
|
||||
(
|
||||
static_cast<Pstream::commsTypes>(Pstream::defaultCommsType())
|
||||
);
|
||||
(
|
||||
static_cast<Pstream::commsTypes>(Pstream::defaultCommsType())
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::scheduled)
|
||||
else if (Pstream::defaultCommsType() == Pstream::scheduled)
|
||||
{
|
||||
const lduSchedule& patchSchedule =
|
||||
bmesh_.mesh().globalData().patchSchedule();
|
||||
|
@ -356,8 +356,8 @@ evaluateCoupled()
|
|||
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::blocking
|
||||
|| Pstream::defaultCommsType == Pstream::nonBlocking
|
||||
Pstream::defaultCommsType() == Pstream::blocking
|
||||
|| Pstream::defaultCommsType() == Pstream::nonBlocking
|
||||
)
|
||||
{
|
||||
forAll(*this, patchi)
|
||||
|
@ -366,13 +366,16 @@ evaluateCoupled()
|
|||
{
|
||||
this->operator[](patchi).initEvaluate
|
||||
(
|
||||
static_cast<Pstream::commsTypes>(Pstream::defaultCommsType())
|
||||
static_cast<Pstream::commsTypes>
|
||||
(
|
||||
Pstream::defaultCommsType()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Block for any outstanding requests
|
||||
if (Pstream::defaultCommsType == Pstream::nonBlocking)
|
||||
if (Pstream::defaultCommsType() == Pstream::nonBlocking)
|
||||
{
|
||||
IPstream::waitRequests();
|
||||
OPstream::waitRequests();
|
||||
|
@ -383,13 +386,16 @@ evaluateCoupled()
|
|||
if (this->operator[](patchi).coupled())
|
||||
{
|
||||
this->operator[](patchi).evaluate
|
||||
(
|
||||
static_cast<Pstream::commsTypes>(Pstream::defaultCommsType())
|
||||
);
|
||||
(
|
||||
static_cast<Pstream::commsTypes>
|
||||
(
|
||||
Pstream::defaultCommsType()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::scheduled)
|
||||
else if (Pstream::defaultCommsType() == Pstream::scheduled)
|
||||
{
|
||||
const lduSchedule& patchSchedule =
|
||||
bmesh_.mesh().globalData().patchSchedule();
|
||||
|
|
|
@ -1156,7 +1156,7 @@ void GlobalPointPatchField
|
|||
|
||||
// Requires global sync points to flush buffers before gather-scatter
|
||||
// communications. Reconsider. HJ, 29/Mar/2011
|
||||
if (Pstream::defaultCommsType == Pstream::nonBlocking)
|
||||
if (Pstream::defaultCommsType() == Pstream::nonBlocking)
|
||||
{
|
||||
IPstream::waitRequests();
|
||||
OPstream::waitRequests();
|
||||
|
@ -1284,7 +1284,7 @@ void GlobalPointPatchField
|
|||
|
||||
// Requires global sync points to flush buffers before gather-scatter
|
||||
// communications. Reconsider. HJ, 29/Mar/2011
|
||||
if (Pstream::defaultCommsType == Pstream::nonBlocking)
|
||||
if (Pstream::defaultCommsType() == Pstream::nonBlocking)
|
||||
{
|
||||
IPstream::waitRequests();
|
||||
OPstream::waitRequests();
|
||||
|
|
|
@ -54,17 +54,17 @@ Foam::argList::initValidTables::initValidTables()
|
|||
// switches from the command-line
|
||||
|
||||
// Instantiate a NamedEnum for the controlDict switches names
|
||||
const Foam::NamedEnum
|
||||
const NamedEnum
|
||||
<
|
||||
Foam::debug::globalControlDictSwitchSet,
|
||||
DIM_GLOBALCONTROLDICTSWITCHSET
|
||||
debug::globalControlDictSwitchSet,
|
||||
debug::DIM_GLOBAL_CONTROL_DICT_SWITCH_SET
|
||||
>
|
||||
globalControlDictSwitchSetNames;
|
||||
|
||||
forAll(globalControlDictSwitchSetNames, gI)
|
||||
forAll (globalControlDictSwitchSetNames, gI)
|
||||
{
|
||||
word switchSetName = globalControlDictSwitchSetNames.names[gI];
|
||||
validOptions.set(switchSetName, "key1=val1,key2=val2,...");
|
||||
word switchSetName = globalControlDictSwitchSetNames.names[gI];
|
||||
validOptions.set(switchSetName, "key1=val1,key2=val2,...");
|
||||
}
|
||||
|
||||
validOptions.set("dumpControlSwitches", "");
|
||||
|
@ -529,61 +529,64 @@ Foam::argList::argList
|
|||
// global controlDict dictionary using the environment variable
|
||||
// FOAM_GLOBAL_CONTROLDICT.
|
||||
fileName optionalGlobControlDictFileName =
|
||||
getEnv("FOAM_GLOBAL_CONTROLDICT");
|
||||
getEnv("FOAM_GLOBAL_CONTROLDICT");
|
||||
|
||||
if (optionalGlobControlDictFileName.size() )
|
||||
{
|
||||
debug::updateCentralDictVars
|
||||
(
|
||||
optionalGlobControlDictFileName,
|
||||
Pstream::master() && bannerEnabled
|
||||
);
|
||||
debug::updateCentralDictVars
|
||||
(
|
||||
optionalGlobControlDictFileName,
|
||||
Pstream::master() && bannerEnabled
|
||||
);
|
||||
}
|
||||
|
||||
// Now that the rootPath_/globalCase_ directory is known (following the call
|
||||
// to getRootCase()), we grab any global control switches overrides from the
|
||||
// current case's controlDict.
|
||||
// Now that the rootPath_/globalCase_ directory is known (following the
|
||||
// call to getRootCase()), we grab any global control switches overrides
|
||||
// from the current case's controlDict.
|
||||
|
||||
debug::updateCentralDictVars
|
||||
(
|
||||
rootPath_/globalCase_/"system/controlDict",
|
||||
Pstream::master() && bannerEnabled
|
||||
rootPath_/globalCase_/"system/controlDict",
|
||||
Pstream::master() && bannerEnabled
|
||||
);
|
||||
|
||||
// Finally, a command-line override for central controlDict's variables.
|
||||
// This is the ultimate override for the global control switches.
|
||||
|
||||
// Instantiate a NamedEnum for the controlDict switches names
|
||||
const Foam::NamedEnum
|
||||
const NamedEnum
|
||||
<
|
||||
Foam::debug::globalControlDictSwitchSet,
|
||||
DIM_GLOBALCONTROLDICTSWITCHSET
|
||||
debug::globalControlDictSwitchSet,
|
||||
debug::DIM_GLOBAL_CONTROL_DICT_SWITCH_SET
|
||||
>
|
||||
globalControlDictSwitchSetNames;
|
||||
|
||||
forAll(globalControlDictSwitchSetNames, gI)
|
||||
forAll (globalControlDictSwitchSetNames, gI)
|
||||
{
|
||||
word switchSetName = globalControlDictSwitchSetNames.names[gI];
|
||||
word switchSetName = globalControlDictSwitchSetNames.names[gI];
|
||||
|
||||
if( optionFound(switchSetName) )
|
||||
Foam::debug::updateCentralDictVars
|
||||
(
|
||||
globalControlDictSwitchSetNames[switchSetName],
|
||||
option(switchSetName)
|
||||
);
|
||||
if (optionFound(switchSetName))
|
||||
{
|
||||
debug::updateCentralDictVars
|
||||
(
|
||||
globalControlDictSwitchSetNames[switchSetName],
|
||||
option(switchSetName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if( optionFound("dumpControlSwitches") )
|
||||
if ( optionFound("dumpControlSwitches") )
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Dumping the application's control switches.
|
||||
// We dump the full information to the console using a standard
|
||||
// dictionary format, so one can copy/paste this information directly
|
||||
// into a case's system/controlDict file to override some switches
|
||||
// values without having to always use the command-line options.
|
||||
Foam::debug::dumpControlSwitchesToConsole();
|
||||
}
|
||||
// We dump the full information to the console using a standard
|
||||
// dictionary format, so one can copy/paste this information
|
||||
// directly into a case's system/controlDict file to
|
||||
// override some switches values without having to always
|
||||
// use the command-line options.
|
||||
debug::dumpControlSwitchesToConsole();
|
||||
}
|
||||
|
||||
::exit(0);
|
||||
}
|
||||
|
@ -630,8 +633,10 @@ Foam::argList::argList
|
|||
{
|
||||
Info<< "Slaves : " << slaveProcs << nl
|
||||
<< "Pstream initialized with:" << nl
|
||||
<< " floatTransfer : " << Pstream::floatTransfer << nl
|
||||
<< " nProcsSimpleSum : " << Pstream::nProcsSimpleSum() << nl
|
||||
<< " floatTransfer : "
|
||||
<< Pstream::floatTransfer << nl
|
||||
<< " nProcsSimpleSum : "
|
||||
<< Pstream::nProcsSimpleSum() << nl
|
||||
<< " commsType : "
|
||||
<< Pstream::commsTypeNames[Pstream::defaultCommsType()]
|
||||
<< endl;
|
||||
|
@ -663,9 +668,10 @@ Foam::argList::argList
|
|||
// If the macro AppSpecificDictionary is used, one can
|
||||
// modify the application-specific dictionnary using the
|
||||
// command-line parameter -appDict
|
||||
if(appDictName_ != "")
|
||||
optionReadIfPresent("appDict", appDictName_);
|
||||
|
||||
if (appDictName_ != "")
|
||||
{
|
||||
optionReadIfPresent("appDict", appDictName_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -706,7 +712,7 @@ void Foam::argList::printUsage() const
|
|||
Info<< " <" << iter().c_str() << '>';
|
||||
}
|
||||
|
||||
int i=0;
|
||||
int i = 0;
|
||||
SortableList<Foam::string> sortedValidOptions(validOptions.size());
|
||||
|
||||
for
|
||||
|
@ -716,7 +722,7 @@ void Foam::argList::printUsage() const
|
|||
++iter, ++i
|
||||
)
|
||||
{
|
||||
OStringStream keyValuePair;
|
||||
OStringStream keyValuePair;
|
||||
keyValuePair << "[-" << iter.key();
|
||||
|
||||
if (iter().size())
|
||||
|
@ -725,12 +731,12 @@ void Foam::argList::printUsage() const
|
|||
}
|
||||
|
||||
keyValuePair<< ']';
|
||||
sortedValidOptions[i]= keyValuePair.str();
|
||||
sortedValidOptions[i]= keyValuePair.str();
|
||||
}
|
||||
sortedValidOptions.sort();
|
||||
|
||||
forAll(sortedValidOptions, sI)
|
||||
Info << " " << sortedValidOptions[sI].c_str();
|
||||
forAll (sortedValidOptions, sI)
|
||||
Info << " " << sortedValidOptions[sI].c_str();
|
||||
|
||||
// place help/doc/srcDoc options of the way at the end,
|
||||
// but with an extra space to separate it a little
|
||||
|
@ -747,7 +753,7 @@ void Foam::argList::displayDoc(bool source) const
|
|||
// for source code: change foo_8C.html to foo_8C_source.html
|
||||
if (source)
|
||||
{
|
||||
forAll(docExts, extI)
|
||||
forAll (docExts, extI)
|
||||
{
|
||||
docExts[extI].replace(".", "_source.");
|
||||
}
|
||||
|
@ -756,9 +762,9 @@ void Foam::argList::displayDoc(bool source) const
|
|||
fileName docFile;
|
||||
bool found = false;
|
||||
|
||||
forAll(docDirs, dirI)
|
||||
forAll (docDirs, dirI)
|
||||
{
|
||||
forAll(docExts, extI)
|
||||
forAll (docExts, extI)
|
||||
{
|
||||
docFile = docDirs[dirI]/executable_ + docExts[extI];
|
||||
docFile.expand();
|
||||
|
|
|
@ -49,42 +49,51 @@ namespace debug
|
|||
// Typedefs
|
||||
// Hashtables to static class attributes addresses holding the
|
||||
// runtime dimensionedConstants values
|
||||
typedef std::map<std::string, std::list<controlSwitches<Foam::scalar> *> > ListConstantsControlSwitches;
|
||||
typedef std::map<std::string, std::list<controlSwitches<Foam::scalar> *> >
|
||||
ListConstantsControlSwitches;
|
||||
|
||||
extern ListConstantsControlSwitches* constantsSwitchValues_;
|
||||
|
||||
|
||||
class constantsSwitch
|
||||
: public controlSwitches<Foam::scalar>
|
||||
:
|
||||
public controlSwitches<scalar>
|
||||
{
|
||||
public:
|
||||
constantsSwitch
|
||||
(
|
||||
const std::string& switchName,
|
||||
const Foam::scalar& switchValue,
|
||||
const std::string& switchDescription = ""
|
||||
)
|
||||
:
|
||||
controlSwitches<Foam::scalar>
|
||||
(
|
||||
switchName,
|
||||
debug::constantsFromDict(switchName.c_str(), switchValue),
|
||||
switchDescription,
|
||||
debug::DIMENSIONEDCONSTANTS,
|
||||
&constantsSwitchValues_
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from name and value
|
||||
constantsSwitch
|
||||
(
|
||||
const std::string& switchName,
|
||||
const Foam::scalar& switchValue,
|
||||
const std::string& switchDescription = ""
|
||||
)
|
||||
:
|
||||
controlSwitches<scalar>
|
||||
(
|
||||
switchName,
|
||||
debug::constantsFromDict(switchName.c_str(), switchValue),
|
||||
switchDescription,
|
||||
debug::DIMENSIONED_CONSTANTS,
|
||||
&constantsSwitchValues_
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~constantsSwitch()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
// Assignement operator
|
||||
void operator=(const Foam::scalar& rhs)
|
||||
{
|
||||
controlSwitches<Foam::scalar>::operator=(rhs);
|
||||
}
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Assignement operator
|
||||
void operator=(const Foam::scalar& rhs)
|
||||
{
|
||||
controlSwitches<Foam::scalar>::operator=(rhs);
|
||||
}
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
|
|
@ -38,13 +38,13 @@ namespace debug
|
|||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::debug::controlSwitches<Type>::controlSwitches()
|
||||
:
|
||||
switchValue_(Type(0)),
|
||||
switchDescription_("")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
Foam::debug::controlSwitches<T>::controlSwitches(const T& switchValue)
|
||||
|
@ -71,28 +71,41 @@ Foam::debug::controlSwitches<T>::controlSwitches
|
|||
// Register the switch in its list
|
||||
if (*switchValuesTable == NULL)
|
||||
{
|
||||
*switchValuesTable = new std::map<std::string, std::list<controlSwitches<T> *> >();
|
||||
*switchValuesTable =
|
||||
new std::map<std::string, std::list<controlSwitches<T> *> >();
|
||||
}
|
||||
|
||||
switchValuesTable_ = *switchValuesTable;
|
||||
std::map<std::string, std::list<controlSwitches<T> *> >&switchValues = *switchValuesTable_;
|
||||
std::map<std::string, std::list<controlSwitches<T> *> >&
|
||||
switchValues = *switchValuesTable_;
|
||||
|
||||
// Memorize this switch object address
|
||||
if (switchValues.find(switchName) != switchValues.end())
|
||||
{
|
||||
switchValues[switchName].push_back(this);
|
||||
switchValues[switchName].push_back(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::list<controlSwitches<T>* > pList;
|
||||
pList.push_back(this);
|
||||
switchValues.insert(std::pair<std::string, std::list<controlSwitches<T>* > >(switchName, pList));
|
||||
std::list<controlSwitches<T>* > pList;
|
||||
pList.push_back(this);
|
||||
|
||||
switchValues.insert
|
||||
(
|
||||
std::pair<std::string, std::list<controlSwitches<T>* > >
|
||||
(
|
||||
switchName,
|
||||
pList
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::debug::controlSwitches<T>::controlSwitches(const Foam::debug::controlSwitches<T>& csw)
|
||||
Foam::debug::controlSwitches<T>::controlSwitches
|
||||
(
|
||||
const debug::controlSwitches<T>& csw
|
||||
)
|
||||
:
|
||||
switchName_(csw.switchName_),
|
||||
switchValue_(csw.switchValue_),
|
||||
|
@ -107,15 +120,19 @@ template<class T>
|
|||
Foam::debug::controlSwitches<T>::~controlSwitches()
|
||||
{
|
||||
// Unregister the switch from its list
|
||||
std::map<std::string, std::list<controlSwitches<T> *> >&switchValuesTable = *switchValuesTable_;
|
||||
|
||||
// Remove entry or key if pointers list is empty
|
||||
switchValuesTable[switchName_].remove(this);
|
||||
|
||||
// Replace the updated list
|
||||
if(switchValuesTable[switchName_].size() == 0)
|
||||
if (switchValuesTable_)
|
||||
{
|
||||
switchValuesTable.erase(switchName_);
|
||||
std::map<std::string, std::list<controlSwitches<T> *> >&
|
||||
switchValuesTable = *switchValuesTable_;
|
||||
|
||||
// Remove entry or key if pointers list is empty
|
||||
switchValuesTable[switchName_].remove(this);
|
||||
|
||||
// Replace the updated list
|
||||
if (switchValuesTable[switchName_].empty())
|
||||
{
|
||||
switchValuesTable.erase(switchName_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,25 +140,33 @@ Foam::debug::controlSwitches<T>::~controlSwitches()
|
|||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
void Foam::debug::controlSwitches<T>::operator=(const Foam::debug::controlSwitches<T>& rhs)
|
||||
void Foam::debug::controlSwitches<T>::operator=
|
||||
(
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
// Check for assignment to self
|
||||
if (this == &rhs)
|
||||
{
|
||||
std::cerr << "Foam::debug::controlSwitches<T>::operator=(const Foam::controlSwitches<T>&)"
|
||||
<< "--> FOAM FATAL ERROR: "
|
||||
<< "Attempted assignment to self"
|
||||
<< std::endl;
|
||||
std::abort();
|
||||
exit(-1);
|
||||
std::cerr
|
||||
<< "Foam::debug::controlSwitches<T>::operator="
|
||||
<< "(const Foam::controlSwitches<T>&)"
|
||||
<< "--> FOAM FATAL ERROR: "
|
||||
<< "Attempted assignment to self"
|
||||
<< std::endl;
|
||||
|
||||
std::abort();
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
switchValue_ = rhs.switchValue_;
|
||||
switchDescription_ = rhs.switchDescription_;
|
||||
switchValue_ = rhs.switchValue_;
|
||||
switchDescription_ = rhs.switchDescription_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
|
@ -150,8 +175,8 @@ void printControlSwitches
|
|||
const std::string& dictName,
|
||||
const std::map
|
||||
<
|
||||
std::string,
|
||||
std::list<Foam::debug::controlSwitches<T> *>
|
||||
std::string,
|
||||
std::list<Foam::debug::controlSwitches<T> *>
|
||||
>* mapListSwitchesPtr,
|
||||
const char* commsTypesNames[]
|
||||
)
|
||||
|
@ -160,99 +185,103 @@ void printControlSwitches
|
|||
|
||||
if (mapListSwitchesPtr)
|
||||
{
|
||||
const std::map
|
||||
<
|
||||
std::string,
|
||||
std::list<Foam::debug::controlSwitches<T> *>
|
||||
>& mapListSwitches = *mapListSwitchesPtr;
|
||||
const std::map
|
||||
<
|
||||
std::string,
|
||||
std::list<Foam::debug::controlSwitches<T> *>
|
||||
>& mapListSwitches = *mapListSwitchesPtr;
|
||||
|
||||
typename std::map
|
||||
<
|
||||
std::string,
|
||||
std::list<Foam::debug::controlSwitches<T> *>
|
||||
>::const_iterator it;
|
||||
typename std::map
|
||||
<
|
||||
std::string,
|
||||
std::list<Foam::debug::controlSwitches<T> *>
|
||||
>::const_iterator it;
|
||||
|
||||
// Compute the maximum length of the switches names.
|
||||
// Trying to make things pretty with std::setw by lining-up the values.
|
||||
// Useful for the debugSwitches because non-zero flags will be much
|
||||
// easier to spot.
|
||||
std::size_t maxLengthKey = 0;
|
||||
|
||||
for (it = mapListSwitches.begin(); it != mapListSwitches.end(); it++)
|
||||
{
|
||||
std::string switchName = it->first;
|
||||
maxLengthKey = std::max(maxLengthKey, switchName.length());
|
||||
}
|
||||
|
||||
// Compute the maximum length of the switches names.
|
||||
// Trying to make things pretty with std::setw by lining-up the values.
|
||||
// Useful for the debugSwitches because non-zero flags will be much
|
||||
// easier to spot.
|
||||
std::size_t maxLengthKey = 0;
|
||||
for (it = mapListSwitches.begin(); it != mapListSwitches.end(); it++)
|
||||
{
|
||||
std::string switchName = it->first;
|
||||
maxLengthKey = std::max(maxLengthKey, switchName.length());
|
||||
}
|
||||
// Still, we clip at 60 characters max.
|
||||
maxLengthKey = std::min(maxLengthKey, size_t(60));
|
||||
maxLengthKey = std::min(maxLengthKey, size_t(60));
|
||||
|
||||
for (it = mapListSwitches.begin(); it != mapListSwitches.end(); it++)
|
||||
{
|
||||
// Switch name
|
||||
std::string switchName = it->first;
|
||||
for (it = mapListSwitches.begin(); it != mapListSwitches.end(); it++)
|
||||
{
|
||||
// Switch name
|
||||
std::string switchName = it->first;
|
||||
|
||||
// Switches list, all identical values, but from different instances.
|
||||
// So we only need to echo the first switch of the list.
|
||||
std::list<Foam::debug::controlSwitches<T> *> swList = it->second;
|
||||
Foam::debug::controlSwitches<T>& value = *(swList.front());
|
||||
// Switches list, all identical values, but from
|
||||
// different instances.
|
||||
// So we only need to echo the first switch of the list.
|
||||
std::list<Foam::debug::controlSwitches<T> *> swList = it->second;
|
||||
Foam::debug::controlSwitches<T>& value = *(swList.front());
|
||||
|
||||
std::cout << " "
|
||||
<< std::left
|
||||
<< std::setw(maxLengthKey)
|
||||
<< switchName
|
||||
<< " ";
|
||||
std::cout
|
||||
<< " " << std::left << std::setw(maxLengthKey)
|
||||
<< switchName << " ";
|
||||
|
||||
// Special handling for commsTypes from optimisationSwitches
|
||||
if (commsTypesNames && switchName.compare("commsType") == 0)
|
||||
{
|
||||
int valEnumAsIndex = value();
|
||||
// Special handling for commsTypes from optimisationSwitches
|
||||
if (commsTypesNames && switchName.compare("commsType") == 0)
|
||||
{
|
||||
int valEnumAsIndex = value();
|
||||
|
||||
std::cout << commsTypesNames[valEnumAsIndex] << ";";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << value() << ";";
|
||||
}
|
||||
std::cout << commsTypesNames[valEnumAsIndex] << ";";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << value() << ";";
|
||||
}
|
||||
|
||||
// Now, for the switch description, since numerous switches might
|
||||
// be defined with identical names, but different descriptions
|
||||
// eg: ggi debugSwitch, we will concatenate all the non-empty
|
||||
// switches descriptions for a given switch
|
||||
// Now, for the switch description, since numerous switches might
|
||||
// be defined with identical names, but different descriptions
|
||||
// eg: ggi debugSwitch, we will concatenate all the non-empty
|
||||
// switches descriptions for a given switch
|
||||
|
||||
std::string switchDescription("");
|
||||
std::string switchDescription("");
|
||||
|
||||
typename std::list<Foam::debug::controlSwitches<T> *>::iterator itL;
|
||||
for (itL = swList.begin(); itL != swList.end(); itL++)
|
||||
{
|
||||
Foam::debug::controlSwitches<T>& sw = *(*itL);
|
||||
std::string thisSwitchDescr = sw.switchDescription();
|
||||
typename
|
||||
std::list<Foam::debug::controlSwitches<T> *>::iterator itL;
|
||||
|
||||
if
|
||||
(
|
||||
!thisSwitchDescr.empty() &&
|
||||
switchDescription.find(thisSwitchDescr) == std::string::npos
|
||||
)
|
||||
{
|
||||
switchDescription += thisSwitchDescr + ". ";
|
||||
}
|
||||
}
|
||||
for (itL = swList.begin(); itL != swList.end(); itL++)
|
||||
{
|
||||
debug::controlSwitches<T>& sw = *(*itL);
|
||||
std::string thisSwitchDescr = sw.switchDescription();
|
||||
|
||||
if (!switchDescription.empty())
|
||||
{
|
||||
std::cout << "\t// " << switchDescription;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
if
|
||||
(
|
||||
!thisSwitchDescr.empty()
|
||||
&& switchDescription.find(thisSwitchDescr) ==
|
||||
std::string::npos
|
||||
)
|
||||
{
|
||||
switchDescription += thisSwitchDescr + ". ";
|
||||
}
|
||||
}
|
||||
|
||||
if (!switchDescription.empty())
|
||||
{
|
||||
std::cout << "\t// " << switchDescription;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << " // No switches of this type for this application"
|
||||
<< std::endl;
|
||||
std::cout
|
||||
<< " // No switches of this type for this application"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
std::cout << "}\n\n";
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -261,3 +290,4 @@ void printControlSwitches
|
|||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -35,14 +35,14 @@ Description
|
|||
- Tolerances switches
|
||||
- DimensionedConstants values
|
||||
|
||||
This class is a specialization of the safe_bool class, where additional
|
||||
This class is a specialization of the safeBool class, where additional
|
||||
boolean operators are allowed. This class is also offering access to
|
||||
information like the switch name, etc.
|
||||
|
||||
Note:
|
||||
We will be using std::map and std::list for the containers for this class.
|
||||
In some sections of the code where controlSwitches are being used, we are at
|
||||
a relatively low level, so we cannot use HashTable and DynamicList.
|
||||
In some sections of the code where controlSwitches are being used, we are
|
||||
at a relatively low level, so we cannot use HashTable and DynamicList.
|
||||
MB 23/05/2014
|
||||
|
||||
SourceFiles
|
||||
|
@ -58,7 +58,7 @@ SourceFiles
|
|||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "safe_bool.H"
|
||||
#include "safeBool.H"
|
||||
|
||||
#include "scalar.H"
|
||||
#include "debug.H"
|
||||
|
@ -68,19 +68,149 @@ SourceFiles
|
|||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
namespace debug
|
||||
{
|
||||
template<class T> class controlSwitches;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator==
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator==
|
||||
(
|
||||
const T& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator==
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const T& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator!=
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator!=
|
||||
(
|
||||
const T& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator!=
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const T& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator>=
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator>=
|
||||
(
|
||||
const T& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator>=
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const T& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator>
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator>
|
||||
(
|
||||
const T& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator>
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const T& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator<=
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator<=
|
||||
(
|
||||
const T& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator<=
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const T& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator<
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator<
|
||||
(
|
||||
const T& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline bool operator<
|
||||
(
|
||||
const debug::controlSwitches<T>&lhs,
|
||||
const T& rhs
|
||||
);
|
||||
|
||||
namespace debug
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
template<class T> class controlSwitches;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class controlSwitches Declaration
|
||||
Class controlSwitches Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T>
|
||||
class controlSwitches
|
||||
: public safe_bool<controlSwitches<T> > // using the CRTP idiom
|
||||
:
|
||||
public safeBool<controlSwitches<T> > // using the CRTP idiom
|
||||
{
|
||||
// Private data
|
||||
|
||||
|
@ -97,9 +227,9 @@ class controlSwitches
|
|||
std::string switchDescription_;
|
||||
|
||||
//- Handle to runTime switches list
|
||||
std::map<std::string, std::list<controlSwitches<T> *> >* switchValuesTable_ ;
|
||||
std::map<std::string, std::list<controlSwitches<T> *> >*
|
||||
switchValuesTable_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
public:
|
||||
|
||||
|
@ -109,73 +239,64 @@ public:
|
|||
controlSwitches();
|
||||
|
||||
//- Construct from components
|
||||
controlSwitches(const T& data);
|
||||
explicit controlSwitches(const T& data);
|
||||
|
||||
controlSwitches
|
||||
(
|
||||
const std::string& switchName,
|
||||
const T& switchValue,
|
||||
const std::string& switchDescription,
|
||||
globalControlDictSwitchSet switchSet,
|
||||
std::map<std::string, std::list<controlSwitches<T> *> >** switchesValues
|
||||
);
|
||||
(
|
||||
const std::string& switchName,
|
||||
const T& switchValue,
|
||||
const std::string& switchDescription,
|
||||
globalControlDictSwitchSet switchSet,
|
||||
std::map<std::string, std::list<controlSwitches<T> *> >**
|
||||
switchesValues
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
controlSwitches(const controlSwitches&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~controlSwitches();
|
||||
~controlSwitches();
|
||||
|
||||
|
||||
// Member Functions
|
||||
// Access
|
||||
|
||||
// Check
|
||||
bool boolean_test() const
|
||||
{
|
||||
// Perform Boolean logic here
|
||||
return switchValue_ != 0;
|
||||
}
|
||||
{
|
||||
// Perform Boolean logic here
|
||||
return switchValue_ != 0;
|
||||
}
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
// Assignement operator
|
||||
//- Assignement operator
|
||||
void operator=(const T&);
|
||||
|
||||
//- Assignement operator
|
||||
void operator=(const controlSwitches&);
|
||||
|
||||
// & operator
|
||||
//- & operator
|
||||
const T operator&(const T&);
|
||||
|
||||
// == operator
|
||||
bool operator==(const T&) const;
|
||||
|
||||
// >= operator
|
||||
bool operator>=(const T&);
|
||||
|
||||
// > operator
|
||||
bool operator>(const T&);
|
||||
|
||||
// < operator
|
||||
bool operator<(const T&);
|
||||
|
||||
// Return value
|
||||
//- Return value
|
||||
T operator()() const
|
||||
{
|
||||
return switchValue_;
|
||||
}
|
||||
{
|
||||
return switchValue_;
|
||||
}
|
||||
|
||||
// Return switch name
|
||||
std::string switchName()
|
||||
{
|
||||
return switchName_;
|
||||
}
|
||||
// Return switch description
|
||||
{
|
||||
return switchName_;
|
||||
}
|
||||
|
||||
//- Return switch description
|
||||
std::string switchDescription()
|
||||
{
|
||||
return switchDescription_;
|
||||
}
|
||||
{
|
||||
return switchDescription_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ License
|
|||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
|
@ -33,37 +31,212 @@ inline void Foam::debug::controlSwitches<T>::operator=(const T& rhs)
|
|||
switchValue_ = rhs;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T Foam::debug::controlSwitches<T>::operator&(const T& rhs)
|
||||
{
|
||||
return switchValue_ & rhs;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::debug::controlSwitches<T>::operator==(const T& rhs) const
|
||||
{
|
||||
return switchValue_ == rhs;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::debug::controlSwitches<T>::operator>=(const T& rhs)
|
||||
inline bool Foam::operator==
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
return switchValue_ >= rhs;
|
||||
return lhs() == rhs();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::debug::controlSwitches<T>::operator>(const T& rhs)
|
||||
inline bool Foam::operator==
|
||||
(
|
||||
const T& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
return switchValue_ > rhs;
|
||||
return lhs == rhs();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::debug::controlSwitches<T>::operator<(const T& rhs)
|
||||
inline bool Foam::operator==
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const T& rhs
|
||||
)
|
||||
{
|
||||
return switchValue_ < rhs;
|
||||
return lhs() == rhs;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator!=
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
return lhs() != rhs();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator!=
|
||||
(
|
||||
const T& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
return lhs != rhs();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator!=
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const T& rhs
|
||||
)
|
||||
{
|
||||
return lhs() != rhs;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator>=
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
return lhs() >= rhs();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator>=
|
||||
(
|
||||
const T& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
return lhs >= rhs();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator>=
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const T& rhs
|
||||
)
|
||||
{
|
||||
return lhs() >= rhs;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator>
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
return lhs() > rhs();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator>
|
||||
(
|
||||
const T& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
return lhs > rhs();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator>
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const T& rhs
|
||||
)
|
||||
{
|
||||
return lhs() > rhs;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator<=
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
return lhs() <= rhs();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator<=
|
||||
(
|
||||
const T& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
return lhs <= rhs();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator<=
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const T& rhs
|
||||
)
|
||||
{
|
||||
return lhs() <= rhs;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator<
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
return lhs() < rhs();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator<
|
||||
(
|
||||
const T& lhs,
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
return lhs < rhs();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::operator<
|
||||
(
|
||||
const debug::controlSwitches<T>& lhs,
|
||||
const T& rhs
|
||||
)
|
||||
{
|
||||
return lhs() < rhs;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -49,40 +49,50 @@ namespace debug
|
|||
// Typedefs
|
||||
// Hashtable to static class attributes addresses holding the
|
||||
// runtime debug switch values
|
||||
typedef std::map<std::string, std::list<controlSwitches<int> *> > ListDebugControlSwitches;
|
||||
typedef std::map<std::string, std::list<controlSwitches<int> *> >
|
||||
ListDebugControlSwitches;
|
||||
|
||||
extern ListDebugControlSwitches* debugSwitchValues_;
|
||||
|
||||
class debugSwitch
|
||||
: public controlSwitches<int>
|
||||
:
|
||||
public controlSwitches<int>
|
||||
{
|
||||
public:
|
||||
debugSwitch
|
||||
(
|
||||
const std::string& switchName,
|
||||
const int& switchValue,
|
||||
const std::string& switchDescription = ""
|
||||
)
|
||||
:
|
||||
controlSwitches<int>
|
||||
(
|
||||
switchName,
|
||||
debug::debugSwitchFromDict(switchName.c_str(), switchValue),
|
||||
switchDescription,
|
||||
debug::DEBUGSWITCHES,
|
||||
&debugSwitchValues_
|
||||
)
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from name and value
|
||||
debugSwitch
|
||||
(
|
||||
const std::string& switchName,
|
||||
const int& switchValue,
|
||||
const std::string& switchDescription = ""
|
||||
)
|
||||
:
|
||||
controlSwitches<int>
|
||||
(
|
||||
switchName,
|
||||
debug::debugSwitchFromDict(switchName.c_str(), switchValue),
|
||||
switchDescription,
|
||||
debug::DEBUG_SWITCHES,
|
||||
&debugSwitchValues_
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~debugSwitch()
|
||||
{}
|
||||
|
||||
virtual ~debugSwitch()
|
||||
{
|
||||
}
|
||||
|
||||
// Assignement operator
|
||||
void operator=(const int& rhs)
|
||||
{
|
||||
controlSwitches<int>::operator=(rhs);
|
||||
}
|
||||
// Member operators
|
||||
|
||||
//- Assignement operator
|
||||
void operator=(const int& rhs)
|
||||
{
|
||||
controlSwitches<int>::operator=(rhs);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -90,6 +100,8 @@ public:
|
|||
|
||||
} // End namespace debug
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
|
|
@ -48,7 +48,8 @@ namespace debug
|
|||
// Typedefs
|
||||
// Hashtable to static class attributes addresses holding the
|
||||
// runtime info switch values
|
||||
typedef std::map<std::string, std::list<controlSwitches<int> *> > ListInfoControlSwitches;
|
||||
typedef std::map<std::string, std::list<controlSwitches<int> *> >
|
||||
ListInfoControlSwitches;
|
||||
|
||||
extern ListInfoControlSwitches* infoSwitchValues_;
|
||||
|
||||
|
@ -56,32 +57,40 @@ class infoSwitch
|
|||
: public controlSwitches<int>
|
||||
{
|
||||
public:
|
||||
infoSwitch
|
||||
(
|
||||
const std::string& switchName,
|
||||
const int& switchValue,
|
||||
const std::string& switchDescription = ""
|
||||
)
|
||||
:
|
||||
controlSwitches<int>
|
||||
(
|
||||
switchName,
|
||||
debug::infoSwitchFromDict(switchName.c_str(), switchValue),
|
||||
switchDescription,
|
||||
debug::INFOSWITCHES,
|
||||
&infoSwitchValues_
|
||||
)
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from name and value
|
||||
infoSwitch
|
||||
(
|
||||
const std::string& switchName,
|
||||
const int& switchValue,
|
||||
const std::string& switchDescription = ""
|
||||
)
|
||||
:
|
||||
controlSwitches<int>
|
||||
(
|
||||
switchName,
|
||||
debug::infoSwitchFromDict(switchName.c_str(), switchValue),
|
||||
switchDescription,
|
||||
debug::INFO_SWITCHES,
|
||||
&infoSwitchValues_
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~infoSwitch()
|
||||
{}
|
||||
|
||||
virtual ~infoSwitch()
|
||||
{
|
||||
}
|
||||
|
||||
// Assignement operator
|
||||
void operator=(const int& rhs)
|
||||
{
|
||||
controlSwitches<int>::operator=(rhs);
|
||||
}
|
||||
// Member operators
|
||||
|
||||
//- Assignement operator
|
||||
void operator=(const int& rhs)
|
||||
{
|
||||
controlSwitches<int>::operator=(rhs);
|
||||
}
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
|
|
@ -49,64 +49,77 @@ namespace debug
|
|||
// Typedefs
|
||||
// Hashtable to static class attributes addresses holding the
|
||||
// runtime optimisation switch values
|
||||
typedef std::map<std::string, std::list<controlSwitches<int> *> > ListOptimisationControlSwitches;
|
||||
typedef std::map<std::string, std::list<controlSwitches<int> *> >
|
||||
ListOptimisationControlSwitches;
|
||||
|
||||
extern ListOptimisationControlSwitches* optimisationSwitchValues_;
|
||||
|
||||
|
||||
class optimisationSwitch
|
||||
: public controlSwitches<int>
|
||||
:
|
||||
public controlSwitches<int>
|
||||
{
|
||||
public:
|
||||
optimisationSwitch
|
||||
(
|
||||
const std::string& switchName,
|
||||
const int& switchValue,
|
||||
const std::string& switchDescription = ""
|
||||
)
|
||||
:
|
||||
controlSwitches<int>
|
||||
(
|
||||
switchName,
|
||||
debug::optimisationSwitchFromDict(switchName.c_str(), switchValue),
|
||||
switchDescription,
|
||||
debug::OPTIMISATIONSWITCHES,
|
||||
&optimisationSwitchValues_
|
||||
)
|
||||
{}
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from name and value
|
||||
optimisationSwitch
|
||||
(
|
||||
const std::string& switchName,
|
||||
const int& switchValue,
|
||||
const std::string& switchDescription = ""
|
||||
)
|
||||
:
|
||||
controlSwitches<int>
|
||||
(
|
||||
switchName,
|
||||
debug::optimisationSwitchFromDict
|
||||
(
|
||||
switchName.c_str(),
|
||||
switchValue
|
||||
),
|
||||
switchDescription,
|
||||
debug::OPTIMISATION_SWITCHES,
|
||||
&optimisationSwitchValues_
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// This constructor is essentially for 'commsType'
|
||||
optimisationSwitch
|
||||
(
|
||||
const std::string& switchName,
|
||||
const std::string& switchValue,
|
||||
const std::string& switchDescription = ""
|
||||
)
|
||||
:
|
||||
controlSwitches<int>
|
||||
(
|
||||
switchName,
|
||||
debug::optimisationSwitchFromDict(switchName, switchValue),
|
||||
switchDescription,
|
||||
debug::OPTIMISATIONSWITCHES,
|
||||
&optimisationSwitchValues_
|
||||
)
|
||||
{}
|
||||
//- This constructor is essentially for 'commsType'
|
||||
optimisationSwitch
|
||||
(
|
||||
const std::string& switchName,
|
||||
const std::string& switchValue,
|
||||
const std::string& switchDescription = ""
|
||||
)
|
||||
:
|
||||
controlSwitches<int>
|
||||
(
|
||||
switchName,
|
||||
debug::optimisationSwitchFromDict
|
||||
(
|
||||
switchName.c_str(),
|
||||
switchValue
|
||||
),
|
||||
switchDescription,
|
||||
debug::OPTIMISATION_SWITCHES,
|
||||
&optimisationSwitchValues_
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~optimisationSwitch()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
// Assignement operator
|
||||
void operator=(const int& rhs)
|
||||
{
|
||||
controlSwitches<int>::operator=(rhs);
|
||||
}
|
||||
// Member operators
|
||||
|
||||
bool operator==(const int& rhs) const
|
||||
{
|
||||
return controlSwitches<int>::operator==(rhs);
|
||||
}
|
||||
// Assignement operator
|
||||
void operator=(const int& rhs)
|
||||
{
|
||||
controlSwitches<int>::operator=(rhs);
|
||||
}
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
|
|
@ -22,7 +22,7 @@ License
|
|||
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::safe_bool
|
||||
Foam::safeBool
|
||||
|
||||
Description
|
||||
Implementation of the Safe Bool Idiom.
|
||||
|
@ -35,8 +35,8 @@ SourceFiles
|
|||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef safe_bool_H
|
||||
#define safe_bool_H
|
||||
#ifndef safeBool_H
|
||||
#define safeBool_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -44,54 +44,59 @@ namespace Foam
|
|||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class safe_bool_base Declaration
|
||||
Class safeBool_base Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
class safe_bool_base
|
||||
|
||||
class safeBoolBase
|
||||
{
|
||||
public:
|
||||
typedef void (safe_bool_base::*bool_type)() const;
|
||||
void this_type_does_not_support_comparisons() const {}
|
||||
typedef void (safeBoolBase::*boolType)() const;
|
||||
void thisTypeDoesNotSupportComparisons() const {}
|
||||
|
||||
protected:
|
||||
|
||||
safe_bool_base() {}
|
||||
safe_bool_base(const safe_bool_base&) {}
|
||||
safe_bool_base& operator=(const safe_bool_base&) {return *this;}
|
||||
~safe_bool_base() {}
|
||||
safeBoolBase() {}
|
||||
safeBoolBase(const safeBoolBase&) {}
|
||||
safeBoolBase& operator=(const safeBoolBase&) {return *this;}
|
||||
~safeBoolBase() {}
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class safe_bool Declaration
|
||||
Class safeBool Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <typename T=void>
|
||||
class safe_bool
|
||||
class safeBool
|
||||
:
|
||||
private safe_bool_base
|
||||
private safeBoolBase
|
||||
{
|
||||
// private or protected inheritance is very important here as it triggers the
|
||||
// access control violation in main.
|
||||
|
||||
public:
|
||||
operator bool_type() const
|
||||
|
||||
operator boolType() const
|
||||
{
|
||||
return (static_cast<const T*>(this))->boolean_test()
|
||||
? &safe_bool_base::this_type_does_not_support_comparisons : 0;
|
||||
return (static_cast<const T*>(this))->boolean_test()
|
||||
? &safeBoolBase::thisTypeDoesNotSupportComparisons : 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//- Destructor
|
||||
~safe_bool()
|
||||
~safeBool()
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "safe_boolI.H"
|
||||
#include "safeBoolI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
|
@ -23,50 +23,80 @@ License
|
|||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template <typename T>
|
||||
inline bool operator==(const Foam::safe_bool<T>& lhs, bool b)
|
||||
inline bool operator==(const Foam::safeBool<T>& lhs, bool b)
|
||||
{
|
||||
if (b)
|
||||
{
|
||||
if (lhs) return true;
|
||||
else return false;
|
||||
if (lhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lhs) return false;
|
||||
else return true;
|
||||
if (lhs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool operator==(bool b, const Foam::safe_bool<T>& rhs)
|
||||
inline bool operator==(bool b, const Foam::safeBool<T>& rhs)
|
||||
{
|
||||
if (b)
|
||||
{
|
||||
if (rhs) return true;
|
||||
else return false;
|
||||
if (rhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rhs) return false;
|
||||
else return true;
|
||||
if (rhs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T, typename U>
|
||||
inline bool operator==(const Foam::safe_bool<T>& lhs,const Foam::safe_bool<U>& rhs)
|
||||
inline bool operator==
|
||||
(
|
||||
const Foam::safeBool<T>& lhs,
|
||||
const Foam::safeBool<U>& rhs
|
||||
)
|
||||
{
|
||||
lhs.this_type_does_not_support_comparisons();
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T,typename U>
|
||||
inline bool operator!=(const Foam::safe_bool<T>& lhs,const Foam::safe_bool<U>& rhs)
|
||||
inline bool operator!=
|
||||
(
|
||||
const Foam::safeBool<T>& lhs,
|
||||
const Foam::safeBool<U>& rhs
|
||||
)
|
||||
{
|
||||
lhs.this_type_does_not_support_comparisons();
|
||||
return false;
|
|
@ -49,41 +49,50 @@ namespace debug
|
|||
// Typedefs
|
||||
// Hashtable to static class attributes addresses holding the
|
||||
// runtime tolerances switch values
|
||||
typedef std::map<std::string, std::list<controlSwitches<Foam::scalar> *> > ListTolerancesControlSwitches;
|
||||
typedef std::map<std::string, std::list<controlSwitches<Foam::scalar> *> >
|
||||
ListTolerancesControlSwitches;
|
||||
|
||||
extern ListTolerancesControlSwitches* tolerancesSwitchValues_;
|
||||
|
||||
class tolerancesSwitch
|
||||
: public controlSwitches<Foam::scalar>
|
||||
:
|
||||
public controlSwitches<scalar>
|
||||
{
|
||||
public:
|
||||
tolerancesSwitch
|
||||
(
|
||||
const std::string& switchName,
|
||||
const Foam::scalar& switchValue,
|
||||
const std::string& switchDescription = ""
|
||||
)
|
||||
:
|
||||
controlSwitches<Foam::scalar>
|
||||
(
|
||||
switchName,
|
||||
debug::tolerancesFromDict(switchName.c_str(), switchValue),
|
||||
switchDescription,
|
||||
debug::TOLERANCES,
|
||||
&tolerancesSwitchValues_
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from name and value
|
||||
tolerancesSwitch
|
||||
(
|
||||
const std::string& switchName,
|
||||
const Foam::scalar& switchValue,
|
||||
const std::string& switchDescription = ""
|
||||
)
|
||||
:
|
||||
controlSwitches<scalar>
|
||||
(
|
||||
switchName,
|
||||
debug::tolerancesFromDict(switchName.c_str(), switchValue),
|
||||
switchDescription,
|
||||
debug::TOLERANCES,
|
||||
&tolerancesSwitchValues_
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~tolerancesSwitch()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
// Assignement operator
|
||||
void operator=(const Foam::scalar& rhs)
|
||||
{
|
||||
controlSwitches<Foam::scalar>::operator=(rhs);
|
||||
}
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Assignement operator
|
||||
void operator=(const Foam::scalar& rhs)
|
||||
{
|
||||
controlSwitches<Foam::scalar>::operator=(rhs);
|
||||
}
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -40,12 +40,6 @@ SourceFiles
|
|||
namespace Foam
|
||||
{
|
||||
|
||||
// Number of global controlDict switches sets
|
||||
// Currently, we have:
|
||||
// DebugSwitches, InfoSwitches, OptimisationSwitches, Tolerances,
|
||||
// and DimensionedConstants
|
||||
#define DIM_GLOBALCONTROLDICTSWITCHSET 5
|
||||
|
||||
// Forward declaration of classes
|
||||
class dictionary;
|
||||
class fileName;
|
||||
|
@ -57,13 +51,22 @@ namespace debug
|
|||
//- Define central control dictionary switchSet
|
||||
enum globalControlDictSwitchSet
|
||||
{
|
||||
DEBUGSWITCHES,
|
||||
INFOSWITCHES,
|
||||
OPTIMISATIONSWITCHES,
|
||||
TOLERANCES,
|
||||
DIMENSIONEDCONSTANTS
|
||||
DEBUG_SWITCHES,
|
||||
INFO_SWITCHES,
|
||||
OPTIMISATION_SWITCHES,
|
||||
TOLERANCES,
|
||||
DIMENSIONED_CONSTANTS
|
||||
};
|
||||
|
||||
// Number of global controlDict switches sets
|
||||
// Currently, we have:
|
||||
// DebugSwitches
|
||||
// InfoSwitches
|
||||
// OptimisationSwitches
|
||||
// Tolerances,
|
||||
// DimensionedConstants
|
||||
static const int DIM_GLOBAL_CONTROL_DICT_SWITCH_SET = 5;
|
||||
|
||||
//- The central control dictionary.
|
||||
dictionary& controlDict();
|
||||
|
||||
|
@ -89,36 +92,46 @@ namespace debug
|
|||
int infoSwitchFromDict(const char* name, const int defaultValue = 0);
|
||||
|
||||
//- Lookup optimisation switch or add default value.
|
||||
int optimisationSwitchFromDict(const char* name, const int defaultValue = 0);
|
||||
int optimisationSwitchFromDict(const Foam::string name, const Foam::word defaultValue);
|
||||
int optimisationSwitchFromDict
|
||||
(
|
||||
const char* name,
|
||||
const int defaultValue = 0
|
||||
);
|
||||
|
||||
int optimisationSwitchFromDict
|
||||
(
|
||||
const Foam::string name,
|
||||
const Foam::word defaultValue
|
||||
);
|
||||
|
||||
//- Lookup tolerances switch or add default value.
|
||||
double tolerancesFromDict(const char* name, const double defaultValue = 0);
|
||||
double tolerancesFromDict
|
||||
(
|
||||
const char* name,
|
||||
const double defaultValue = 0
|
||||
);
|
||||
|
||||
//- Lookup dimensionedConstants switch or add default value.
|
||||
double constantsFromDict(const char* name, const double defaultValue = 0);
|
||||
|
||||
//- Internal function to lookup a sub-dictionary from controlDict.
|
||||
dictionary& switchSet
|
||||
double constantsFromDict
|
||||
(
|
||||
const globalControlDictSwitchSet globalControlDictSwitchSetName,
|
||||
dictionary*& subDictPtr
|
||||
const char* name,
|
||||
const double defaultValue = 0
|
||||
);
|
||||
|
||||
//- Update central controlDict variables
|
||||
// supported keyValues format: key1=value1,key2=value2
|
||||
void updateCentralDictVars
|
||||
(
|
||||
const globalControlDictSwitchSet centralDictSwitchSetName,
|
||||
const Foam::string& keyValues,
|
||||
const bool verbose=true
|
||||
const globalControlDictSwitchSet centralDictSwitchSetName,
|
||||
const Foam::string& keyValues,
|
||||
const bool verbose = true
|
||||
);
|
||||
|
||||
//- Update central controlDict variables from a file
|
||||
void updateCentralDictVars
|
||||
(
|
||||
const Foam::fileName& file,
|
||||
const bool verbose=true
|
||||
const Foam::fileName& file,
|
||||
const bool verbose = true
|
||||
);
|
||||
|
||||
//- Dump the central controlDict variables to the console using a standard
|
||||
|
|
|
@ -24,6 +24,7 @@ License
|
|||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "dimensionedConstants.H"
|
||||
#include "NamedEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -36,13 +37,21 @@ dictionary* dimensionedConstantsPtr_(NULL);
|
|||
|
||||
dictionary& dimensionedConstants()
|
||||
{
|
||||
return debug::switchSet
|
||||
// Cannot use static NamedEnum in static initialisation
|
||||
// Making local copy
|
||||
const NamedEnum
|
||||
<
|
||||
debug::globalControlDictSwitchSet,
|
||||
debug::DIM_GLOBAL_CONTROL_DICT_SWITCH_SET
|
||||
> globalControlDictSwitchSetNames;
|
||||
|
||||
return debug::controlDict().subDict
|
||||
(
|
||||
debug::DIMENSIONEDCONSTANTS,
|
||||
dimensionedConstantsPtr_
|
||||
globalControlDictSwitchSetNames[debug::DIMENSIONED_CONSTANTS]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
|
|
@ -63,6 +63,7 @@ T dimensionedConstant
|
|||
else
|
||||
{
|
||||
dimensionedConstants().add(switchName, defaultValue);
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ GGIInterpolation<MasterPatch, SlavePatch>::faceBoundBoxExtendSpanFraction_
|
|||
(
|
||||
"GGIFaceBoundBoxExtendSpanFraction",
|
||||
1.0e-2,
|
||||
"GGI faces bounding box expansion factor. Add robustness for quick-search algo. Keep it to a few percent."
|
||||
"GGI faces bounding box expansion factor. "
|
||||
"Add robustness for quick-search algo. Keep it to a few percent."
|
||||
);
|
||||
|
||||
template<class MasterPatch, class SlavePatch>
|
||||
|
@ -448,7 +449,7 @@ void GGIInterpolation<MasterPatch, SlavePatch>::findNeighboursBBOctree
|
|||
treeBoundBox bbFaceMaster(facePoints);
|
||||
|
||||
lmasterFaceBB[faceMi] =
|
||||
bbFaceMaster.extend(faceBoundBoxExtendSpanFraction_);
|
||||
bbFaceMaster.extend(faceBoundBoxExtendSpanFraction_());
|
||||
}
|
||||
|
||||
// Initialize the list of slave patch faces bounding box
|
||||
|
@ -492,7 +493,7 @@ void GGIInterpolation<MasterPatch, SlavePatch>::findNeighboursBBOctree
|
|||
treeBoundBox bbFaceSlave(facePoints);
|
||||
|
||||
lslaveFaceBB[faceSi] =
|
||||
bbFaceSlave.extend(faceBoundBoxExtendSpanFraction_);
|
||||
bbFaceSlave.extend(faceBoundBoxExtendSpanFraction_());
|
||||
}
|
||||
|
||||
// Create the slave octreeData, using the boundBox flavor
|
||||
|
@ -507,9 +508,9 @@ void GGIInterpolation<MasterPatch, SlavePatch>::findNeighboursBBOctree
|
|||
(
|
||||
slaveOverallBB, // overall search domain
|
||||
slaveDataBB,
|
||||
octreeSearchMinNLevel_, // min number of levels
|
||||
octreeSearchMaxLeafRatio_, // max avg. size of leaves
|
||||
octreeSearchMaxShapeRatio_ // max avg. duplicity.
|
||||
octreeSearchMinNLevel_(), // min number of levels
|
||||
octreeSearchMaxLeafRatio_(), // max avg. size of leaves
|
||||
octreeSearchMaxShapeRatio_() // max avg. duplicity.
|
||||
);
|
||||
|
||||
const vectorField& masterFaceNormals = masterPatch_.faceNormals();
|
||||
|
|
|
@ -41,8 +41,8 @@ void Foam::BlockLduMatrix<Type>::initInterfaces
|
|||
{
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::blocking
|
||||
|| Pstream::defaultCommsType == Pstream::nonBlocking
|
||||
Pstream::defaultCommsType() == Pstream::blocking
|
||||
|| Pstream::defaultCommsType() == Pstream::nonBlocking
|
||||
)
|
||||
{
|
||||
forAll (interfaces_, interfaceI)
|
||||
|
@ -61,7 +61,7 @@ void Foam::BlockLduMatrix<Type>::initInterfaces
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::scheduled)
|
||||
else if (Pstream::defaultCommsType() == Pstream::scheduled)
|
||||
{
|
||||
const lduSchedule& patchSchedule = this->patchSchedule();
|
||||
|
||||
|
@ -109,12 +109,12 @@ void Foam::BlockLduMatrix<Type>::updateInterfaces
|
|||
{
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::blocking
|
||||
|| Pstream::defaultCommsType == Pstream::nonBlocking
|
||||
Pstream::defaultCommsType() == Pstream::blocking
|
||||
|| Pstream::defaultCommsType() == Pstream::nonBlocking
|
||||
)
|
||||
{
|
||||
// Block until all sends/receives have been finished
|
||||
if (Pstream::defaultCommsType == Pstream::nonBlocking)
|
||||
if (Pstream::defaultCommsType() == Pstream::nonBlocking)
|
||||
{
|
||||
IPstream::waitRequests();
|
||||
OPstream::waitRequests();
|
||||
|
@ -136,7 +136,7 @@ void Foam::BlockLduMatrix<Type>::updateInterfaces
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::scheduled)
|
||||
else if (Pstream::defaultCommsType() == Pstream::scheduled)
|
||||
{
|
||||
const lduSchedule& patchSchedule = this->patchSchedule();
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ void Foam::BlockLduMatrix<scalar>::initInterfaces
|
|||
{
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::blocking
|
||||
|| Pstream::defaultCommsType == Pstream::nonBlocking
|
||||
Pstream::defaultCommsType() == Pstream::blocking
|
||||
|| Pstream::defaultCommsType() == Pstream::nonBlocking
|
||||
)
|
||||
{
|
||||
forAll (interfaces, interfaceI)
|
||||
|
@ -65,7 +65,7 @@ void Foam::BlockLduMatrix<scalar>::initInterfaces
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::scheduled)
|
||||
else if (Pstream::defaultCommsType() == Pstream::scheduled)
|
||||
{
|
||||
const lduSchedule& patchSchedule = this->patchSchedule();
|
||||
|
||||
|
@ -113,12 +113,12 @@ void Foam::BlockLduMatrix<scalar>::updateInterfaces
|
|||
{
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::blocking
|
||||
|| Pstream::defaultCommsType == Pstream::nonBlocking
|
||||
Pstream::defaultCommsType() == Pstream::blocking
|
||||
|| Pstream::defaultCommsType() == Pstream::nonBlocking
|
||||
)
|
||||
{
|
||||
// Block until all sends/receives have been finished
|
||||
if (Pstream::defaultCommsType == Pstream::nonBlocking)
|
||||
if (Pstream::defaultCommsType() == Pstream::nonBlocking)
|
||||
{
|
||||
IPstream::waitRequests();
|
||||
OPstream::waitRequests();
|
||||
|
@ -140,7 +140,7 @@ void Foam::BlockLduMatrix<scalar>::updateInterfaces
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::scheduled)
|
||||
else if (Pstream::defaultCommsType() == Pstream::scheduled)
|
||||
{
|
||||
const lduSchedule& patchSchedule = this->patchSchedule();
|
||||
|
||||
|
|
|
@ -132,7 +132,10 @@ void Foam::lduMatrix::updateMatrixInterfaces
|
|||
*this,
|
||||
coupleCoeffs[interfaceI],
|
||||
cmpt,
|
||||
static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
|
||||
static_cast<Pstream::commsTypes>
|
||||
(
|
||||
Pstream::defaultCommsType()
|
||||
),
|
||||
switchToLhs
|
||||
);
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ Foam::ProcessorTopology<Patch, ProcPatch>::ProcessorTopology
|
|||
Pstream::scatterList(*this);
|
||||
}
|
||||
|
||||
if (Pstream::parRun() && Pstream::defaultCommsType == Pstream::scheduled)
|
||||
if (Pstream::parRun() && Pstream::defaultCommsType() == Pstream::scheduled)
|
||||
{
|
||||
label patchEvali = 0;
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ public:
|
|||
{
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::nonBlocking
|
||||
Pstream::defaultCommsType() == Pstream::nonBlocking
|
||||
&& contiguous<T>()
|
||||
)
|
||||
{
|
||||
|
@ -220,7 +220,7 @@ public:
|
|||
fld
|
||||
);
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::scheduled)
|
||||
else if (Pstream::defaultCommsType() == Pstream::scheduled)
|
||||
{
|
||||
distribute
|
||||
(
|
||||
|
|
|
@ -209,7 +209,7 @@ void Foam::processorPolyPatch::calcGeometry()
|
|||
faceNormals[facei] = point(1, 0, 0);
|
||||
nbrFaceNormals[facei] = faceNormals[facei];
|
||||
}
|
||||
else if (mag(magSf - nbrMagSf)/avSf > polyPatch::matchTol_())
|
||||
else if (mag(magSf - nbrMagSf)/avSf > polyPatch::matchTol_)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
|
@ -220,7 +220,7 @@ void Foam::processorPolyPatch::calcGeometry()
|
|||
<< "patch: " << name()
|
||||
<< " my area: " << magSf
|
||||
<< " neighbour area: " << nbrMagSf
|
||||
<< " matching tolerance: " << polyPatch::matchTol_()
|
||||
<< " matching tolerance: " << polyPatch::matchTol_
|
||||
<< endl
|
||||
<< "Mesh face: " << start()+facei
|
||||
<< " vertices: "
|
||||
|
|
|
@ -105,12 +105,7 @@ public:
|
|||
// HJ, 7/Sep/2008
|
||||
scalar oldTol = planarTol_();
|
||||
|
||||
// Is this still necessary? If not a const, then it is not a const.
|
||||
// MB 18/05_2014
|
||||
//scalar* ptPtr = const_cast<scalar*>(&planarTol_);
|
||||
//(*ptPtr) = t;
|
||||
|
||||
planarTol_ = t;
|
||||
planarTol_ = t;
|
||||
|
||||
return oldTol;
|
||||
}
|
||||
|
|
|
@ -44,30 +44,38 @@ namespace Foam
|
|||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::immersedBoundaryFvPatch::radiusFactor_
|
||||
const Foam::debug::tolerancesSwitch
|
||||
Foam::immersedBoundaryFvPatch::radiusFactor_
|
||||
(
|
||||
debug::tolerances("immersedBoundaryRadiusFactor", 3.5)
|
||||
// debug::tolerances("immersedBoundaryRadiusFactor", 5)
|
||||
"immersedBoundaryRadiusFactor",
|
||||
3.5
|
||||
// 5
|
||||
);
|
||||
|
||||
|
||||
Foam::scalar Foam::immersedBoundaryFvPatch::angleFactor_
|
||||
const Foam::debug::tolerancesSwitch
|
||||
Foam::immersedBoundaryFvPatch::angleFactor_
|
||||
(
|
||||
debug::tolerances("immersedBoundaryAngleFactor", 80)
|
||||
// debug::tolerances("immersedBoundaryAngleFactor", 170)
|
||||
"immersedBoundaryAngleFactor",
|
||||
80
|
||||
// 170
|
||||
);
|
||||
|
||||
|
||||
Foam::label Foam::immersedBoundaryFvPatch::maxCellCellRows_
|
||||
const Foam::debug::optimisationSwitch
|
||||
Foam::immersedBoundaryFvPatch::maxCellCellRows_
|
||||
(
|
||||
debug::optimisationSwitch("immersedBoundaryMaxCellCellRows", 4)
|
||||
// debug::optimisationSwitch("immersedBoundaryMaxCellCellRows", 5)
|
||||
"immersedBoundaryMaxCellCellRows",
|
||||
4
|
||||
// 5
|
||||
);
|
||||
|
||||
|
||||
Foam::scalar Foam::immersedBoundaryFvPatch::distFactor_
|
||||
const Foam::debug::tolerancesSwitch
|
||||
Foam::immersedBoundaryFvPatch::distFactor_
|
||||
(
|
||||
debug::tolerances("immersedBoundaryDistFactor", 1.5)
|
||||
"immersedBoundaryDistFactor",
|
||||
1.5
|
||||
);
|
||||
|
||||
|
||||
|
@ -994,9 +1002,9 @@ void Foam::immersedBoundaryFvPatch::makeIbPointsAndNormals() const
|
|||
// Adjust search span if needed. HJ, 14/Dec/2012
|
||||
vector span
|
||||
(
|
||||
2*radiusFactor_*delta[cellI],
|
||||
2*radiusFactor_*delta[cellI],
|
||||
2*radiusFactor_*delta[cellI]
|
||||
2*radiusFactor_()*delta[cellI],
|
||||
2*radiusFactor_()*delta[cellI],
|
||||
2*radiusFactor_()*delta[cellI]
|
||||
);
|
||||
|
||||
pointIndexHit pih = tss.nearest(ibCellCentres[cellI], span);
|
||||
|
@ -1051,7 +1059,7 @@ void Foam::immersedBoundaryFvPatch::makeIbPointsAndNormals() const
|
|||
}
|
||||
|
||||
// Calculate sampling points locations
|
||||
ibSamplingPoints = ibPoints + distFactor_*(ibCellCentres - ibPoints);
|
||||
ibSamplingPoints = ibPoints + distFactor_()*(ibCellCentres - ibPoints);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1113,7 +1121,7 @@ void Foam::immersedBoundaryFvPatch::makeIbCellCells() const
|
|||
const vectorField& C = mesh_.cellCentres();
|
||||
|
||||
scalarField rM(ibCellSizes());
|
||||
rM *= radiusFactor_;
|
||||
rM *= radiusFactor_();
|
||||
|
||||
const vectorField& ibp = ibPoints();
|
||||
|
||||
|
@ -1146,7 +1154,7 @@ void Foam::immersedBoundaryFvPatch::makeIbCellCells() const
|
|||
if (r <= rM[cellI])
|
||||
{
|
||||
scalar angleLimit =
|
||||
-Foam::cos(angleFactor_*mathematicalConstant::pi/180);
|
||||
-Foam::cos(angleFactor_()*mathematicalConstant::pi/180);
|
||||
|
||||
vector dir = (C[curCell] - ibp[cellI]);
|
||||
dir /= mag(dir) + SMALL;
|
||||
|
@ -2016,7 +2024,7 @@ void Foam::immersedBoundaryFvPatch::findCellCells
|
|||
labelList curCells = cellSet.toc();
|
||||
|
||||
// Second and other rows
|
||||
for (label nRows = 1; nRows < maxCellCellRows_; nRows++)
|
||||
for (label nRows = 1; nRows < maxCellCellRows_(); nRows++)
|
||||
{
|
||||
curCells = cellSet.toc();
|
||||
|
||||
|
|
|
@ -82,19 +82,19 @@ class immersedBoundaryFvPatch
|
|||
|
||||
//- Fitting angle rejection factor (deg)
|
||||
// Cells within the the radius will be used for the fitting function
|
||||
static scalar angleFactor_;
|
||||
static const debug::tolerancesSwitch angleFactor_;
|
||||
|
||||
//- Fitting radius factor
|
||||
// Cells within the the radius will be used for the fitting function
|
||||
static scalar radiusFactor_;
|
||||
static const debug::tolerancesSwitch radiusFactor_;
|
||||
|
||||
//- Maximum number of rows in cell-cell search
|
||||
static label maxCellCellRows_;
|
||||
static const debug::optimisationSwitch maxCellCellRows_;
|
||||
|
||||
//- Sampling point distance factor
|
||||
// Sampling point is located distFactor further away from the wall
|
||||
// from the immersed boundary cell centre
|
||||
static scalar distFactor_;
|
||||
static const debug::tolerancesSwitch distFactor_;
|
||||
|
||||
|
||||
// Demand-driven data
|
||||
|
|
|
@ -37,16 +37,19 @@ namespace Foam
|
|||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
label immersedBoundaryFvPatchField<Type>::nBcIter_
|
||||
const Foam::debug::optimisationSwitch
|
||||
immersedBoundaryFvPatchField<Type>::nBcIter_
|
||||
(
|
||||
debug::optimisationSwitch("immersedBoundaryNBCIter", 5)
|
||||
);
|
||||
|
||||
|
||||
template<class Type>
|
||||
scalar immersedBoundaryFvPatchField<Type>::bcTolerance_
|
||||
const Foam::debug::tolerancesSwitch
|
||||
immersedBoundaryFvPatchField<Type>::bcTolerance_
|
||||
(
|
||||
debug::tolerances("immersedBoundaryBCTolerance", 0.01)
|
||||
"immersedBoundaryBCTolerance",
|
||||
0.01
|
||||
);
|
||||
|
||||
|
||||
|
@ -249,9 +252,9 @@ immersedBoundaryFvPatchField<Type>::imposeDirichletCondition() const
|
|||
|
||||
reduce(maxError, maxOp<scalar>());
|
||||
}
|
||||
while (maxError > bcTolerance_ && counter < nBcIter_);
|
||||
while (maxError > bcTolerance_() && counter < nBcIter_());
|
||||
|
||||
if (counter == nBcIter_ && debug)
|
||||
if (counter == nBcIter_() && debug)
|
||||
{
|
||||
InfoIn
|
||||
(
|
||||
|
@ -435,9 +438,9 @@ immersedBoundaryFvPatchField<Type>::imposeNeumannCondition() const
|
|||
|
||||
reduce(maxError, maxOp<scalar>());
|
||||
}
|
||||
while (maxError > bcTolerance_ && counter < nBcIter_);
|
||||
while (maxError > bcTolerance_() && counter < nBcIter_());
|
||||
|
||||
if (counter == nBcIter_ && debug)
|
||||
if (counter == nBcIter_() && debug)
|
||||
{
|
||||
InfoIn
|
||||
(
|
||||
|
|
|
@ -158,10 +158,10 @@ public:
|
|||
// Static algorithm control data
|
||||
|
||||
//- Number of boundary condition update iterations
|
||||
static label nBcIter_;
|
||||
static const debug::optimisationSwitch nBcIter_;
|
||||
|
||||
//- Boundary condition update tolerance
|
||||
static scalar bcTolerance_;
|
||||
static const debug::tolerancesSwitch bcTolerance_;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
|
|
@ -88,7 +88,7 @@ class pamgPolicy
|
|||
// Private Static Data
|
||||
|
||||
//- Diagonal scaling factor
|
||||
static const Foam::debug::tolerancesSwitch diagFactor_;
|
||||
static const debug::tolerancesSwitch diagFactor_;
|
||||
|
||||
|
||||
public:
|
||||
|
|
|
@ -127,7 +127,10 @@ void tetFemMatrix<Type>::check()
|
|||
*this,
|
||||
coupledBouCoeffs[interfaceI],
|
||||
0,
|
||||
static_cast<Pstream::commsTypes>(Pstream::defaultCommsType()),
|
||||
static_cast<Pstream::commsTypes>
|
||||
(
|
||||
Pstream::defaultCommsType()
|
||||
),
|
||||
false // Do not switch to lhs
|
||||
);
|
||||
}
|
||||
|
|
|
@ -33,20 +33,18 @@ boundaryField
|
|||
upperWall
|
||||
{
|
||||
type epsilonWallFunction;
|
||||
refValue uniform 0;
|
||||
value uniform 14.855;
|
||||
Cmu 0.09;
|
||||
kappa 0.41;
|
||||
E 9.8;
|
||||
value uniform 14.855;
|
||||
}
|
||||
lowerWall
|
||||
{
|
||||
type epsilonWallFunction;
|
||||
refValue uniform 0;
|
||||
value uniform 14.855;
|
||||
Cmu 0.09;
|
||||
kappa 0.41;
|
||||
E 9.8;
|
||||
value uniform 14.855;
|
||||
}
|
||||
frontAndBack
|
||||
{
|
||||
|
@ -54,5 +52,4 @@ boundaryField
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -46,5 +46,4 @@ boundaryField
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -34,7 +34,7 @@ purgeWrite 0;
|
|||
|
||||
writeFormat ascii;
|
||||
|
||||
//writePrecision 12;
|
||||
writePrecision 6;
|
||||
|
||||
writeCompression uncompressed;
|
||||
|
||||
|
|
Reference in a new issue