Global controlDict pre-merge.

This commit is contained in:
Hrvoje Jasak 2015-05-14 20:31:22 +01:00
parent a2300be5f9
commit e054cad9be
61 changed files with 1770 additions and 3353 deletions

View file

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

View file

@ -1,3 +0,0 @@
FMSToSurface.C
EXE = $(FOAM_APPBIN)/FMSToSurface

View file

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

View file

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

View file

@ -1,3 +0,0 @@
FMSToVTK.C
EXE = $(FOAM_APPBIN)/FMSToVTK

View file

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

View file

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

View file

@ -1,3 +0,0 @@
importSurfaceAsSubset.C
EXE = $(FOAM_APPBIN)/importSurfaceAsSubset

View file

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

View file

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

View file

@ -1,3 +0,0 @@
improveSymmetryPlanes.C
EXE = $(FOAM_APPBIN)/improveSymmetryPlanes

View file

@ -1,7 +0,0 @@
EXE_INC = \
-I$(FOAM_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lmeshTools \
-lmeshLibrary

View file

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

View file

@ -1,3 +0,0 @@
mergeSurfacePatches.C
EXE = $(FOAM_APPBIN)/mergeSurfacePatches

View file

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

View file

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

View file

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

View file

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

View file

@ -1,3 +0,0 @@
surfaceToFMS.C
EXE = $(FOAM_APPBIN)/surfaceToFMS

View file

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

View file

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

View file

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

View file

@ -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"
);
// ************************************************************************* //

View file

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

View file

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

View file

@ -287,8 +287,8 @@ evaluate()
if
(
Pstream::defaultCommsType == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking
Pstream::defaultCommsType() == Pstream::blocking
|| Pstream::defaultCommsType() == Pstream::nonBlocking
)
{
forAll(*this, patchi)
@ -300,7 +300,7 @@ evaluate()
}
// Block for any outstanding requests
if (Pstream::defaultCommsType == Pstream::nonBlocking)
if (Pstream::defaultCommsType() == Pstream::nonBlocking)
{
IPstream::waitRequests();
OPstream::waitRequests();
@ -314,7 +314,7 @@ evaluate()
);
}
}
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();
@ -384,12 +387,15 @@ evaluateCoupled()
{
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();

View file

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

View file

@ -54,10 +54,10 @@ 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;
@ -540,9 +540,9 @@ Foam::argList::argList
);
}
// 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
(
@ -554,10 +554,10 @@ Foam::argList::argList
// 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;
@ -566,12 +566,14 @@ Foam::argList::argList
word switchSetName = globalControlDictSwitchSetNames.names[gI];
if (optionFound(switchSetName))
Foam::debug::updateCentralDictVars
{
debug::updateCentralDictVars
(
globalControlDictSwitchSetNames[switchSetName],
option(switchSetName)
);
}
}
if ( optionFound("dumpControlSwitches") )
{
@ -579,10 +581,11 @@ Foam::argList::argList
{
// 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();
// 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;
@ -664,8 +669,9 @@ Foam::argList::argList
// modify the application-specific dictionnary using the
// command-line parameter -appDict
if (appDictName_ != "")
{
optionReadIfPresent("appDict", appDictName_);
}
}

View file

@ -49,15 +49,21 @@ 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:
// Constructors
//- Construct from name and value
constantsSwitch
(
const std::string& switchName,
@ -65,22 +71,25 @@ public:
const std::string& switchDescription = ""
)
:
controlSwitches<Foam::scalar>
controlSwitches<scalar>
(
switchName,
debug::constantsFromDict(switchName.c_str(), switchValue),
switchDescription,
debug::DIMENSIONEDCONSTANTS,
debug::DIMENSIONED_CONSTANTS,
&constantsSwitchValues_
)
{
}
{}
//- Destructor
virtual ~constantsSwitch()
{
}
{}
// Assignement operator
// Member operators
//- Assignement operator
void operator=(const Foam::scalar& rhs)
{
controlSwitches<Foam::scalar>::operator=(rhs);

View file

@ -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,11 +71,13 @@ 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())
@ -86,13 +88,24 @@ Foam::debug::controlSwitches<T>::controlSwitches
{
std::list<controlSwitches<T>* > pList;
pList.push_back(this);
switchValues.insert(std::pair<std::string, std::list<controlSwitches<T>* > >(switchName, pList));
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,32 +120,43 @@ template<class T>
Foam::debug::controlSwitches<T>::~controlSwitches()
{
// Unregister the switch from its list
std::map<std::string, std::list<controlSwitches<T> *> >&switchValuesTable = *switchValuesTable_;
if (switchValuesTable_)
{
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[switchName_].empty())
{
switchValuesTable.erase(switchName_);
}
}
}
// * * * * * * * * * * * * * * 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>&)"
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
@ -142,6 +166,7 @@ void Foam::debug::controlSwitches<T>::operator=(const Foam::debug::controlSwitch
}
}
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
template<class T>
@ -177,11 +202,13 @@ void printControlSwitches
// 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));
@ -190,16 +217,15 @@ void printControlSwitches
// Switch name
std::string switchName = it->first;
// Switches list, all identical values, but from different instances.
// 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)
@ -220,16 +246,19 @@ void printControlSwitches
std::string switchDescription("");
typename std::list<Foam::debug::controlSwitches<T> *>::iterator itL;
typename
std::list<Foam::debug::controlSwitches<T> *>::iterator itL;
for (itL = swList.begin(); itL != swList.end(); itL++)
{
Foam::debug::controlSwitches<T>& sw = *(*itL);
debug::controlSwitches<T>& sw = *(*itL);
std::string thisSwitchDescr = sw.switchDescription();
if
(
!thisSwitchDescr.empty() &&
switchDescription.find(thisSwitchDescr) == std::string::npos
!thisSwitchDescr.empty()
&& switchDescription.find(thisSwitchDescr) ==
std::string::npos
)
{
switchDescription += thisSwitchDescr + ". ";
@ -245,14 +274,14 @@ void printControlSwitches
}
else
{
std::cout << " // No switches of this type for this application"
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
// ************************************************************************* //

View file

@ -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,11 +68,140 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
namespace debug
{
// Forward declaration of classes
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
{
/*---------------------------------------------------------------------------*\
Class controlSwitches Declaration
@ -80,7 +209,8 @@ template<class T> class controlSwitches;
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,7 +239,7 @@ public:
controlSwitches();
//- Construct from components
controlSwitches(const T& data);
explicit controlSwitches(const T& data);
controlSwitches
(
@ -117,18 +247,19 @@ public:
const T& switchValue,
const std::string& switchDescription,
globalControlDictSwitchSet switchSet,
std::map<std::string, std::list<controlSwitches<T> *> >** switchesValues
std::map<std::string, std::list<controlSwitches<T> *> >**
switchesValues
);
//- Construct as copy
controlSwitches(const controlSwitches&);
//- Destructor
~controlSwitches();
// Member Functions
// Access
// Check
bool boolean_test() const
@ -137,30 +268,19 @@ public:
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_;
@ -171,7 +291,8 @@ public:
{
return switchName_;
}
// Return switch description
//- Return switch description
std::string switchDescription()
{
return switchDescription_;

View file

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

View file

@ -49,14 +49,20 @@ 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:
// Constructors
//- Construct from name and value
debugSwitch
(
const std::string& switchName,
@ -69,16 +75,20 @@ public:
switchName,
debug::debugSwitchFromDict(switchName.c_str(), switchValue),
switchDescription,
debug::DEBUGSWITCHES,
debug::DEBUG_SWITCHES,
&debugSwitchValues_
)
{}
virtual ~debugSwitch()
{
}
// Assignement operator
//- Destructor
virtual ~debugSwitch()
{}
// Member operators
//- Assignement operator
void operator=(const int& rhs)
{
controlSwitches<int>::operator=(rhs);
@ -90,6 +100,8 @@ public:
} // End namespace debug
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -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,6 +57,10 @@ class infoSwitch
: public controlSwitches<int>
{
public:
// Constructors
//- Construct from name and value
infoSwitch
(
const std::string& switchName,
@ -68,16 +73,20 @@ public:
switchName,
debug::infoSwitchFromDict(switchName.c_str(), switchValue),
switchDescription,
debug::INFOSWITCHES,
debug::INFO_SWITCHES,
&infoSwitchValues_
)
{}
virtual ~infoSwitch()
{
}
// Assignement operator
//- Destructor
virtual ~infoSwitch()
{}
// Member operators
//- Assignement operator
void operator=(const int& rhs)
{
controlSwitches<int>::operator=(rhs);

View file

@ -49,14 +49,21 @@ 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:
// Constructors
//- Construct from name and value
optimisationSwitch
(
const std::string& switchName,
@ -67,15 +74,19 @@ public:
controlSwitches<int>
(
switchName,
debug::optimisationSwitchFromDict(switchName.c_str(), switchValue),
debug::optimisationSwitchFromDict
(
switchName.c_str(),
switchValue
),
switchDescription,
debug::OPTIMISATIONSWITCHES,
debug::OPTIMISATION_SWITCHES,
&optimisationSwitchValues_
)
{}
// This constructor is essentially for 'commsType'
//- This constructor is essentially for 'commsType'
optimisationSwitch
(
const std::string& switchName,
@ -86,27 +97,29 @@ public:
controlSwitches<int>
(
switchName,
debug::optimisationSwitchFromDict(switchName, switchValue),
debug::optimisationSwitchFromDict
(
switchName.c_str(),
switchValue
),
switchDescription,
debug::OPTIMISATIONSWITCHES,
debug::OPTIMISATION_SWITCHES,
&optimisationSwitchValues_
)
{}
//- Destructor
virtual ~optimisationSwitch()
{
}
{}
// Member operators
// Assignement operator
void operator=(const int& rhs)
{
controlSwitches<int>::operator=(rhs);
}
bool operator==(const int& rhs) const
{
return controlSwitches<int>::operator==(rhs);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -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;
? &safeBoolBase::thisTypeDoesNotSupportComparisons : 0;
}
protected:
//- Destructor
~safe_bool()
~safeBool()
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "safe_boolI.H"
#include "safeBoolI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -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
{
if (lhs) return false;
else return true;
return false;
}
}
else
{
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
{
if (rhs) return false;
else return true;
return false;
}
}
else
{
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;

View file

@ -49,14 +49,20 @@ 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:
// Constructors
//- Construct from name and value
tolerancesSwitch
(
const std::string& switchName,
@ -64,7 +70,7 @@ public:
const std::string& switchDescription = ""
)
:
controlSwitches<Foam::scalar>
controlSwitches<scalar>
(
switchName,
debug::tolerancesFromDict(switchName.c_str(), switchValue),
@ -72,14 +78,17 @@ public:
debug::TOLERANCES,
&tolerancesSwitchValues_
)
{
}
{}
//- Destructor
virtual ~tolerancesSwitch()
{
}
{}
// Assignement operator
// Member operators
//- Assignement operator
void operator=(const Foam::scalar& rhs)
{
controlSwitches<Foam::scalar>::operator=(rhs);

View file

@ -50,11 +50,7 @@ namespace debug
template<>
const char*
Foam::NamedEnum
<
Foam::debug::globalControlDictSwitchSet,
5
>::names[] =
Foam::NamedEnum<Foam::debug::globalControlDictSwitchSet, 5>::names[] =
{
"DebugSwitches",
"InfoSwitches",
@ -66,11 +62,6 @@ Foam::NamedEnum
//! @cond ignoreDocumentation - local scope
dictionary* controlDictPtr_(NULL);
dictionary* debugSwitchesPtr_(NULL);
dictionary* infoSwitchesPtr_(NULL);
dictionary* optimisationSwitchesPtr_(NULL);
dictionary* tolerancesPtr_(NULL);
dictionary* constantsPtr_(NULL);
// to ensure controlDictPtr_ is deleted at the end of the run
class deleteControlDictPtr
@ -85,7 +76,7 @@ public:
if (controlDictPtr_)
{
delete controlDictPtr_;
controlDictPtr_ = 0;
controlDictPtr_ = NULL;
}
}
};
@ -105,8 +96,8 @@ Foam::dictionary& Foam::debug::controlDict()
{
// We are totally getting rid of the central controlDict file located
// under $WM_PROJECT_DIR/etc/controlDict.
// But we still need to create a central dictionary for the global control
// switches.
// But we still need to create a central dictionary for
// global control switches.
// At first, all the different subdicts will be empty, like this:
// DebugSwitches{}
// InfoSwitches{}
@ -114,107 +105,121 @@ Foam::dictionary& Foam::debug::controlDict()
// Tolerances{}
// DimensionedConstants{}
//
// We will also merge with other predefined dictionaries as we go along.
// Then, as the libraries will instantiate the various control switches,
// We will also merge with other predefined dictionaries
// as we go along.
// Then, as the libraries will instantiate the control switches,
// the corresponding subdicts will get populated.
// MB 05/2015
const string dictEmptySectionStr("{}\n");
string emptyGlobalDictStr;
// Make control dict
cerr<< "Make control dict\n";
controlDictPtr_ = new dictionary();
dictionary& cDict = *controlDictPtr_;
// This is a bit less readable than explicitely reusing the hard-coded
// string values, but we then get the added flexibility to change the
// name of the subDicts without too much impact to the rest of source
// code.
const Foam::NamedEnum
// Cannot use static NamedEnum in static initialisation
// Making local copy
const NamedEnum
<
Foam::debug::globalControlDictSwitchSet,
DIM_GLOBALCONTROLDICTSWITCHSET
>
globalControlDictSwitchSetNames;
globalControlDictSwitchSet,
DIM_GLOBAL_CONTROL_DICT_SWITCH_SET
> globalControlDictSwitchSetNames;
// Add a subDict for each switch set
forAll (globalControlDictSwitchSetNames, gI)
{
emptyGlobalDictStr +=
globalControlDictSwitchSetNames.names[gI] +
dictEmptySectionStr;
cerr<< "Adding subdict"
<< globalControlDictSwitchSetNames.names[gI]
<< "\n";
cDict.add(globalControlDictSwitchSetNames.names[gI], dictionary());
}
controlDictPtr_ = new dictionary
(
IStringStream(emptyGlobalDictStr)()
);
}
return *controlDictPtr_;
}
Foam::dictionary& Foam::debug::switchSet
(
const globalControlDictSwitchSet globalControlDictSwitchSetName,
dictionary*& subDictPtr
)
{
if (!subDictPtr)
{
const Foam::NamedEnum
<
Foam::debug::globalControlDictSwitchSet,
DIM_GLOBALCONTROLDICTSWITCHSET
>
globalControlDictSwitchSetNames;
word subDictName = globalControlDictSwitchSetNames[globalControlDictSwitchSetName];
entry* ePtr = controlDict().lookupEntryPtr
(
subDictName, false, false
);
if (!ePtr || !ePtr->isDict())
{
cerr<< "debug::switchSet(const globalControlDictSwitchSet, dictionary*&):\n"
<< " Cannot find " << subDictName << " in dictionary "
<< controlDict().name().c_str()
<< std::endl << std::endl;
::exit(1);
}
subDictPtr = &ePtr->dict();
}
return *subDictPtr;
}
Foam::dictionary& Foam::debug::debugSwitches()
{
return switchSet(debug::DEBUGSWITCHES, debugSwitchesPtr_);
// Cannot use static NamedEnum in static initialisation
// Making local copy
const NamedEnum
<
globalControlDictSwitchSet,
DIM_GLOBAL_CONTROL_DICT_SWITCH_SET
> globalControlDictSwitchSetNames;
return controlDict().subDict
(
globalControlDictSwitchSetNames[debug::DEBUG_SWITCHES]
);
}
Foam::dictionary& Foam::debug::infoSwitches()
{
return switchSet(debug::INFOSWITCHES, infoSwitchesPtr_);
// Cannot use static NamedEnum in static initialisation
// Making local copy
const NamedEnum
<
globalControlDictSwitchSet,
DIM_GLOBAL_CONTROL_DICT_SWITCH_SET
> globalControlDictSwitchSetNames;
return controlDict().subDict
(
globalControlDictSwitchSetNames[debug::INFO_SWITCHES]
);
}
Foam::dictionary& Foam::debug::optimisationSwitches()
{
return switchSet(debug::OPTIMISATIONSWITCHES, optimisationSwitchesPtr_);
// Cannot use static NamedEnum in static initialisation
// Making local copy
const NamedEnum
<
globalControlDictSwitchSet,
DIM_GLOBAL_CONTROL_DICT_SWITCH_SET
> globalControlDictSwitchSetNames;
return controlDict().subDict
(
globalControlDictSwitchSetNames[debug::OPTIMISATION_SWITCHES]
);
}
Foam::dictionary& Foam::debug::tolerances()
{
return switchSet(debug::TOLERANCES, tolerancesPtr_);
// Cannot use static NamedEnum in static initialisation
// Making local copy
const NamedEnum
<
globalControlDictSwitchSet,
DIM_GLOBAL_CONTROL_DICT_SWITCH_SET
> globalControlDictSwitchSetNames;
return controlDict().subDict
(
globalControlDictSwitchSetNames[debug::TOLERANCES]
);
}
Foam::dictionary& Foam::debug::constants()
{
return switchSet(debug::DIMENSIONEDCONSTANTS, constantsPtr_);
// Cannot use static NamedEnum in static initialisation
// Making local copy
const NamedEnum
<
globalControlDictSwitchSet,
DIM_GLOBAL_CONTROL_DICT_SWITCH_SET
> globalControlDictSwitchSetNames;
return controlDict().subDict
(
globalControlDictSwitchSetNames[debug::DIMENSIONED_CONSTANTS]
);
}
@ -252,17 +257,20 @@ int Foam::debug::optimisationSwitchFromDict
// This is essentially for reading 'commsType'
int Foam::debug::optimisationSwitchFromDict
(
const Foam::string name,
const Foam::word defaultValueStr
const string name,
const word defaultValueStr
)
{
int retValue = 0;
if (name == "commsType")
{
Foam::string valueStr = optimisationSwitches().lookupOrAddDefault
string valueStr = optimisationSwitches().lookupOrAddDefault
(
name, defaultValueStr, false, false
name,
defaultValueStr,
false,
false
);
retValue = Pstream::commsTypeNames[valueStr];
@ -302,30 +310,31 @@ double Foam::debug::constantsFromDict
void Foam::debug::updateCentralDictVars
(
const Foam::debug::globalControlDictSwitchSet globalControlDictSwitchSetName,
const Foam::string& keyValues,
const debug::globalControlDictSwitchSet gcdSwitchSetName,
const string& keyValues,
const bool verbose
)
{
Foam::word token;
word token;
// Extract the multiple keyValues, separated by ','
std::istringstream issmkvs(keyValues);
while (getline(issmkvs, token, ','))
{
// Cleanup
Foam::string::stripInvalid<word>(token);
string::stripInvalid<word>(token);
// Extract the keyValue pair, separated by '='
std::istringstream isskv(token);
while (getline(isskv, token, '='))
{
Foam::word key = token;
word key = token;
switch(globalControlDictSwitchSetName)
switch(gcdSwitchSetName)
{
case DEBUGSWITCHES:
case DEBUG_SWITCHES:
{
if (debugSwitchValues_)
{
@ -336,7 +345,9 @@ void Foam::debug::updateCentralDictVars
label newDebugValue;
isskv >> newDebugValue;
if (Foam::debug::debugSwitches().readIfPresent
if
(
debug::debugSwitches().readIfPresent
(
key,
oldDebugValue
@ -345,14 +356,23 @@ void Foam::debug::updateCentralDictVars
{
if (verbose)
{
Info << "CtrlDict : Modification of DebugSwitches: "
InfoIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "CtrlDict : "
<< "Modification of DebugSwitches: "
<< key
<< ": old value: " << oldDebugValue
<< ", new value: " << newDebugValue
<< endl;
}
Foam::debug::debugSwitches().set
debug::debugSwitches().set
(
key,
newDebugValue
@ -376,7 +396,7 @@ void Foam::debug::updateCentralDictVars
{
// Usage of non-existent DebugSwitches: best to
// abort right away
SortableList<Foam::word> sortedValidKeys
SortableList<word> sortedValidKeys
(
debugSwitchValues.size()
);
@ -393,10 +413,16 @@ void Foam::debug::updateCentralDictVars
}
sortedValidKeys.sort();
FatalError
<< "Usage of non-existent DebugSwitches name: "
<< key
<< endl << endl
FatalErrorIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "Usage of non-existent DebugSwitches name: "
<< key << nl << nl
<< "Valid entries for this application are: "
<< sortedValidKeys
<< exit(FatalError);
@ -404,14 +430,21 @@ void Foam::debug::updateCentralDictVars
}
else
{
FatalError
<< "No DebugSwitches values are available for "
FatalErrorIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "No DebugSwitches values are available for "
<< "this application."
<< exit(FatalError);
}
}
break;
case INFOSWITCHES:
case INFO_SWITCHES:
{
if (infoSwitchValues_)
{
@ -422,7 +455,9 @@ void Foam::debug::updateCentralDictVars
label newInfoValue;
isskv >> newInfoValue;
if (Foam::debug::infoSwitches().readIfPresent
if
(
debug::infoSwitches().readIfPresent
(
key,
oldInfoValue
@ -431,14 +466,15 @@ void Foam::debug::updateCentralDictVars
{
if (verbose)
{
Info << "CtrlDict : Modification of InfoSwitches: "
Info<< "CtrlDict : "
<< "Modification of InfoSwitches: "
<< key
<< ": old value: " << oldInfoValue
<< ", new value: " << newInfoValue
<< endl;
}
Foam::debug::infoSwitches().set(key, newInfoValue);
debug::infoSwitches().set(key, newInfoValue);
std::list<controlSwitches<int> *> curList =
infoSwitchValues[key];
@ -458,7 +494,7 @@ void Foam::debug::updateCentralDictVars
{
// Usage of non-existent InfoSwitches: best to
// abort right away
SortableList<Foam::word> sortedValidKeys
SortableList<word> sortedValidKeys
(
infoSwitchValues.size()
);
@ -475,10 +511,16 @@ void Foam::debug::updateCentralDictVars
}
sortedValidKeys.sort();
FatalError
<< "Usage of non-existent InfoSwitches name: "
<< key
<< endl << endl
FatalErrorIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "Usage of non-existent InfoSwitches name: "
<< key << nl << nl
<< "Valid entries for this application are: "
<< sortedValidKeys
<< exit(FatalError);
@ -486,24 +528,34 @@ void Foam::debug::updateCentralDictVars
}
else
{
FatalError
<< "No InfoSwitches values are available for "
FatalErrorIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "No InfoSwitches values are available for "
<< "this application."
<< exit(FatalError);
}
}
break;
case OPTIMISATIONSWITCHES:
case OPTIMISATION_SWITCHES:
{
if (optimisationSwitchValues_)
{
ListOptimisationControlSwitches&
optimisationSwitchValues = *optimisationSwitchValues_;
optimisationSwitchValues =
*optimisationSwitchValues_;
label newOptimisationValue;
label oldOptimisationValue;
word newOptimisationValueStr;
word oldOptimisationValueStr;
bool keyIsPresent(false);
// We need to check if the switch 'commsType' is being
@ -515,9 +567,13 @@ void Foam::debug::updateCentralDictVars
// Handle a string value, then convert to enum
isskv >> newOptimisationValueStr;
newOptimisationValue =
Pstream::commsTypeNames[newOptimisationValueStr];
Pstream::commsTypeNames
[
newOptimisationValueStr
];
keyIsPresent =
Foam::debug::optimisationSwitches().readIfPresent
debug::optimisationSwitches().readIfPresent
(
key,
oldOptimisationValueStr
@ -528,19 +584,25 @@ void Foam::debug::updateCentralDictVars
// Handling label values
isskv >> newOptimisationValue;
keyIsPresent =
Foam::debug::optimisationSwitches().readIfPresent
debug::optimisationSwitches().readIfPresent
(
key,
oldOptimisationValue
);
std::ostringstream newOptimisationValueOstream;
newOptimisationValueOstream << newOptimisationValue;
newOptimisationValueOstream
<< newOptimisationValue;
newOptimisationValueStr =
newOptimisationValueOstream.str();
std::ostringstream oldOptimisationValueOstream;
oldOptimisationValueOstream << oldOptimisationValue;
oldOptimisationValueOstream
<< oldOptimisationValue;
oldOptimisationValueStr =
oldOptimisationValueOstream.str();
}
@ -549,7 +611,15 @@ void Foam::debug::updateCentralDictVars
{
if (verbose)
{
Info << "CtrlDict : Modification of "
InfoIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "CtrlDict : Modification of "
<< "OptimisationSwitches: "
<< key
<< ": old value: "
@ -559,7 +629,7 @@ void Foam::debug::updateCentralDictVars
<< endl;
}
Foam::debug::optimisationSwitches().set
debug::optimisationSwitches().set
(
key,
newOptimisationValue
@ -581,9 +651,9 @@ void Foam::debug::updateCentralDictVars
}
else
{
// Usage of non-existent OptimisationSwitches: best to
// abort right away
SortableList<Foam::word> sortedValidKeys
// Usage of non-existent OptimisationSwitches:
// best to abort right away
SortableList<word> sortedValidKeys
(
optimisationSwitchValues.size()
);
@ -600,8 +670,15 @@ void Foam::debug::updateCentralDictVars
}
sortedValidKeys.sort();
FatalError
<< "Usage of non-existent "
FatalErrorIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "Usage of non-existent "
<< " OptimisationSwitches name: " << key
<< endl << endl
<< "Valid entries for this application are: "
@ -611,8 +688,15 @@ void Foam::debug::updateCentralDictVars
}
else
{
FatalError
<< "No OptimisationSwitches values are available "
FatalErrorIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "No OptimisationSwitches values are available "
<< "for this application."
<< exit(FatalError);
}
@ -629,7 +713,9 @@ void Foam::debug::updateCentralDictVars
scalar newTolerancesValue;
isskv >> newTolerancesValue;
if (Foam::debug::tolerances().readIfPresent
if
(
debug::tolerances().readIfPresent
(
key,
oldTolerancesValue
@ -638,14 +724,23 @@ void Foam::debug::updateCentralDictVars
{
if (verbose)
{
Info << "CtrlDict : Modification of Tolerances: "
InfoIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "CtrlDict : "
<< "Modification of Tolerances: "
<< key
<< ": old value: " << oldTolerancesValue
<< ", new value: " << newTolerancesValue
<< endl;
}
Foam::debug::tolerances().set
debug::tolerances().set
(
key,
newTolerancesValue
@ -669,7 +764,7 @@ void Foam::debug::updateCentralDictVars
{
// Usage of non-existent Tolerances: best to
// abort right away
SortableList<Foam::word> sortedValidKeys
SortableList<word> sortedValidKeys
(
tolerancesSwitchValues.size()
);
@ -686,10 +781,16 @@ void Foam::debug::updateCentralDictVars
}
sortedValidKeys.sort();
FatalError
<< "Usage of non-existent Tolerances name: "
<< key
<< endl << endl
FatalErrorIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "Usage of non-existent Tolerances name: "
<< key << nl << nl
<< "Valid entries for this application are: "
<< sortedValidKeys
<< exit(FatalError);
@ -697,14 +798,21 @@ void Foam::debug::updateCentralDictVars
}
else
{
FatalError
<< "No Tolerances values are available for "
FatalErrorIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "No Tolerances values are available for "
<< "this application."
<< exit(FatalError);
}
}
break;
case DIMENSIONEDCONSTANTS:
case DIMENSIONED_CONSTANTS:
{
if (constantsSwitchValues_)
{
@ -715,7 +823,9 @@ void Foam::debug::updateCentralDictVars
scalar newDimensionedConstantsValue;
isskv >> newDimensionedConstantsValue;
if (Foam::dimensionedConstants().readIfPresent
if
(
dimensionedConstants().readIfPresent
(
key,
oldDimensionedConstantsValue
@ -724,7 +834,16 @@ void Foam::debug::updateCentralDictVars
{
if (verbose)
{
Info << "CtrlDict : Modification of DimensionedConstants: "
InfoIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "CtrlDict : "
<< "Modification of DimensionedConstants: "
<< key
<< ": old value: "
<< oldDimensionedConstantsValue
@ -733,7 +852,7 @@ void Foam::debug::updateCentralDictVars
<< endl;
}
Foam::dimensionedConstants().set
dimensionedConstants().set
(
key,
newDimensionedConstantsValue
@ -755,9 +874,9 @@ void Foam::debug::updateCentralDictVars
}
else
{
// Usage of non-existent DimensionedConstants: best to
// abort right away
SortableList<Foam::word> sortedValidKeys
// Usage of non-existent DimensionedConstants:
// best to abort right away
SortableList<word> sortedValidKeys
(
constantsSwitchValues.size()
);
@ -774,11 +893,17 @@ void Foam::debug::updateCentralDictVars
}
sortedValidKeys.sort();
FatalError
<< "Usage of non-existent "
FatalErrorIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "Usage of non-existent "
<< "DimensionedConstants name: "
<< key
<< endl << endl
<< key << nl << nl
<< "Valid entries for this application are: "
<< sortedValidKeys
<< exit(FatalError);
@ -786,8 +911,15 @@ void Foam::debug::updateCentralDictVars
}
else
{
FatalError
<< "No DimensionedConstants values are available "
FatalErrorIn
(
"debug::updateCentralDictVars\n"
"(\n"
" const globalControlDictSwitchSet,\n"
" const string& keyValues,\n"
" const bool verbose\n"
")"
) << "No DimensionedConstants values are available "
<< "for this application."
<< exit(FatalError);
}
@ -800,9 +932,10 @@ void Foam::debug::updateCentralDictVars
}
}
void Foam::debug::updateCentralDictVars
(
const Foam::fileName& fName,
const fileName& fName,
const bool verbose
)
{
@ -819,23 +952,25 @@ void Foam::debug::updateCentralDictVars
IFstream(fName)()
);
const dictionary& optionalGlobControlDict = *optionalGlobControlDictPtr_;
const dictionary& optionalGlobControlDict =
*optionalGlobControlDictPtr_;
const Foam::NamedEnum
const NamedEnum
<
Foam::debug::globalControlDictSwitchSet,
DIM_GLOBALCONTROLDICTSWITCHSET
debug::globalControlDictSwitchSet,
DIM_GLOBAL_CONTROL_DICT_SWITCH_SET
>
globalControlDictSwitchSetNames;
gcdSwitchSetNames;
// We merge the content of each subdicts
forAll(globalControlDictSwitchSetNames, gI)
forAll(gcdSwitchSetNames, gI)
{
string subDictName(globalControlDictSwitchSetNames.names[gI]);
string subDictName(gcdSwitchSetNames.names[gI]);
if (optionalGlobControlDict.isDict(subDictName))
{
const dictionary& subD = optionalGlobControlDict.subDict(subDictName);
const dictionary& subD =
optionalGlobControlDict.subDict(subDictName);
const wordList toc = subD.toc();
OStringStream keyValuePairs;
@ -849,7 +984,7 @@ void Foam::debug::updateCentralDictVars
// Update global dictionary
updateCentralDictVars
(
globalControlDictSwitchSetNames[subDictName],
gcdSwitchSetNames[subDictName],
keyValuePairs.str(),
false // keep quiet when using files...
);
@ -863,10 +998,10 @@ void Foam::debug::updateCentralDictVars
void Foam::debug::dumpControlSwitchesToConsole()
{
const Foam::NamedEnum
const NamedEnum
<
Foam::debug::globalControlDictSwitchSet,
DIM_GLOBALCONTROLDICTSWITCHSET
debug::globalControlDictSwitchSet,
DIM_GLOBAL_CONTROL_DICT_SWITCH_SET
>
globalControlDictSwitchSetNames;
@ -874,27 +1009,27 @@ void Foam::debug::dumpControlSwitchesToConsole()
debug::printControlSwitches
(
globalControlDictSwitchSetNames[debug::DEBUGSWITCHES],
globalControlDictSwitchSetNames[debug::DEBUG_SWITCHES],
debug::debugSwitchValues_
);
debug::printControlSwitches
(
globalControlDictSwitchSetNames[debug::INFOSWITCHES],
globalControlDictSwitchSetNames[debug::INFO_SWITCHES],
debug::infoSwitchValues_
);
// We are forced to pass the string descriptions of the Pstream::commsTypes
// for the optimisationSwitches group because this switch is in fact an enum
// but we need to specify its corresponding string equivalent in a controlDict
// dictionary. And at the low level we are playing, including Pstream.H is out
// of the question.
// MB 2015
// We are forced to pass the string descriptions of the
// Pstream::commsTypes for the optimisationSwitches group because
// this switch is in fact an enum but we need to specify its
// corresponding string equivalent in a controlDict
// dictionary. And at the low level we are playing, including
// Pstream.H is out of the question. MB 2015
debug::printControlSwitches
(
globalControlDictSwitchSetNames[debug::OPTIMISATIONSWITCHES],
globalControlDictSwitchSetNames[debug::OPTIMISATION_SWITCHES],
debug::optimisationSwitchValues_,
Foam::Pstream::commsTypeNames.names
Pstream::commsTypeNames.names
);
debug::printControlSwitches
@ -905,7 +1040,7 @@ void Foam::debug::dumpControlSwitchesToConsole()
debug::printControlSwitches
(
globalControlDictSwitchSetNames[debug::DIMENSIONEDCONSTANTS],
globalControlDictSwitchSetNames[debug::DIMENSIONED_CONSTANTS],
debug::constantsSwitchValues_
);

View file

@ -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,
DEBUG_SWITCHES,
INFO_SWITCHES,
OPTIMISATION_SWITCHES,
TOLERANCES,
DIMENSIONEDCONSTANTS
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,20 +92,30 @@ 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

View file

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

View file

@ -63,6 +63,7 @@ T dimensionedConstant
else
{
dimensionedConstants().add(switchName, defaultValue);
return defaultValue;
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -105,11 +105,6 @@ 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;
return oldTol;

View file

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

View file

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

View file

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

View file

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

View file

@ -88,7 +88,7 @@ class pamgPolicy
// Private Static Data
//- Diagonal scaling factor
static const Foam::debug::tolerancesSwitch diagFactor_;
static const debug::tolerancesSwitch diagFactor_;
public:

View file

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

View file

@ -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
}
}
// ************************************************************************* //

View file

@ -46,5 +46,4 @@ boundaryField
}
}
// ************************************************************************* //

View file

@ -34,7 +34,7 @@ purgeWrite 0;
writeFormat ascii;
//writePrecision 12;
writePrecision 6;
writeCompression uncompressed;