Merge branch 'master' into splitCyclic

Conflicts:
	applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C
	applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L
	applications/utilities/mesh/generation/blockMesh/blockMesh.C
	applications/utilities/mesh/generation/blockMesh/createTopology.C
	applications/utilities/mesh/generation/snappyHexMesh/Make/options
	src/OpenFOAM/containers/Lists/ListOps/ListOps.H
	src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
	src/OpenFOAM/containers/Lists/UList/UList.H
	src/OpenFOAM/containers/Lists/UList/UListI.H
	src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.C
	src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C
	src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C
	src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H
	src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
	src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H
	src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C
	src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C
	src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H
	src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C
	src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C
	src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C
	src/decompositionAgglomeration/Allwmake
	src/decompositionAgglomeration/decompositionMethods/Make/files
	src/decompositionAgglomeration/decompositionMethods/Make/options
	src/dynamicMesh/attachDetach/attachInterface.C
	src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C
	src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H
	src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C
	src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C
	src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H
	src/dynamicMesh/polyTopoChange/polyTopoChange/removePoints.H
	src/dynamicMesh/slidingInterface/coupleSlidingInterface.C
	src/finiteVolume/Make/files
	tutorials/channelOodles/channel395/constant/polyMesh/blockMeshDict
	tutorials/icoFoam/cavity/constant/polyMesh/blockMeshDict
	wmake/rules/linux64Gcc/c++Opt
This commit is contained in:
mattijs
2009-08-07 08:19:53 +01:00
9335 changed files with 762380 additions and 594169 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,8 +48,9 @@ int main(int argc, char *argv[])
# include "createTime.H"
runTime.functionObjects().off();
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
bool overwrite = args.options().found("overwrite");
bool overwrite = args.optionFound("overwrite");
if (!overwrite)
{
@ -61,11 +62,15 @@ int main(int argc, char *argv[])
attachPolyTopoChanger(mesh).attach();
if (overwrite)
{
mesh.setInstance(oldInstance);
}
mesh.write();
Info<< "End\n" << endl;
return(0);
return 0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -77,6 +77,7 @@ int main(int argc, char *argv[])
# include "createTime.H"
runTime.functionObjects().off();
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
Info<< "Mesh read in = "
<< runTime.cpuTimeIncrement()
@ -90,7 +91,7 @@ int main(int argc, char *argv[])
boundaryMesh bMesh;
scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
bool overwrite = args.options().found("overwrite");
bool overwrite = args.optionFound("overwrite");
scalar minCos = Foam::cos(featureAngle * mathematicalConstant::pi/180.0);
@ -243,6 +244,10 @@ int main(int argc, char *argv[])
polyMeshRepatcher.repatch();
// Write resulting mesh
if (overwrite)
{
mesh.setInstance(oldInstance);
}
mesh.write();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,19 +74,7 @@ int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
Info<< "Reading mesh for time = " << runTime.value() << endl;
Info<< "Create mesh\n" << endl;
polyMesh mesh
(
IOobject
(
polyMesh::defaultRegion,
runTime.timeName(),
runTime
)
);
# include "createPolyMesh.H"
Info<< "Reading cellSetDict\n" << endl;

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -26,12 +26,31 @@ action new;
topoSetSources
(
// Select by explicitly providing cell labels
labelToCell
{
value (12 13 56); // labels of cells
}
// Copy elements from cellSet
cellToCell
{
set c1;
}
// Cells in cell zone
zoneToCell
{
name ".*Zone"; // Name of cellZone, regular expressions allowed
}
// Cells on master or slave side of faceZone
faceZoneToCell
{
name ".*Zone"; // Name of faceZone, regular expressions allowed
option master; // master/slave
}
// Select based on faceSet
faceToCell
{
@ -51,12 +70,6 @@ topoSetSources
//option all; // cell with all points in pointSet
}
// Select by explicitly providing cell labels
labelToCell
{
value (12 13 56); // labels of cells
}
// Select based on cellShape
shapeToCell
{
@ -79,18 +92,19 @@ topoSetSources
k (10 10 10);
}
// Cells in cell zone
zoneToCell
// Cells with centre within cylinder
cylinderToCell
{
name cellZone; // name of cellZone
p1 (0.2 0.2 -10); // start point on cylinder axis
p2 (0.2 0.2 0); // end point on cylinder axis
radius 5.0;
}
// values of field within certain range
fieldToCell
// Cells with centre within sphere
sphereToCell
{
fieldName U; // Note: uses mag(U) since volVectorField
min 0.1;
max 0.5;
centre (0.2 0.2 -10);
radius 5.0;
}
// Cells with cellCentre nearest to coordinates
@ -102,17 +116,33 @@ topoSetSources
// Select based on surface
surfaceToCell
{
file "www.avl.com-geometry.stl";
outsidePoints ((-99 -99 -59)); // definition of outside
includeCut false; // cells cut by surface
includeInside false; // cells not on outside of surf
includeOutside false; // cells on outside of surf
nearDistance -1; // cells with centre near surf
// (set to -1 if not used)
curvature 0.9; // cells within nearDistance
// and near surf curvature
// (set to -100 if not used)
file "www.avl.com-geometry.stl";
outsidePoints ((-99 -99 -59)); // definition of outside
includeCut false; // cells cut by surface
includeInside false; // cells not on outside of surf
includeOutside false; // cells on outside of surf
nearDistance -1; // cells with centre near surf
// (set to -1 if not used)
curvature 0.9; // cells within nearDistance
// and near surf curvature
// (set to -100 if not used)
}
// values of field within certain range
fieldToCell
{
fieldName U; // Note: uses mag(U) since volVectorField
min 0.1;
max 0.5;
}
// Mesh region (non-face connected part of (subset of)mesh)
regionToCell
{
set c0; // name of cellSet giving mesh subset
insidePoint (1 2 3); // point inside region to select
}
);

View File

@ -1,6 +0,0 @@
printMeshStats.C
checkTopology.C
checkGeometry.C
checkMesh.C
EXE = $(FOAM_APPBIN)/checkMesh

View File

@ -1,5 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lmeshTools

View File

@ -1,220 +0,0 @@
#include "checkGeometry.H"
#include "polyMesh.H"
#include "globalMeshData.H"
#include "cellSet.H"
#include "faceSet.H"
#include "pointSet.H"
Foam::label Foam::checkGeometry
(
const polyMesh& mesh,
bool checkPointNearness,
bool checkCellDeterminant
)
{
label noFailedChecks = 0;
Info<< "\nChecking geometry..." << endl;
boundBox bb(mesh.points());
Pout<< " Domain bounding box: "
<< bb.min() << " " << bb.max() << endl;
// Get a small relative length from the bounding box
const boundBox& globalBb = mesh.globalData().bb();
if (Pstream::parRun())
{
Info<< " Overall domain bounding box: "
<< globalBb.min() << " " << globalBb.max() << endl;
}
// Min length
scalar minDistSqr = magSqr(1e-6*(globalBb.max() - globalBb.min()));
if (mesh.checkClosedBoundary(true)) noFailedChecks++;
{
cellSet cells(mesh, "nonClosedCells", mesh.nCells()/100+1);
cellSet aspectCells(mesh, "highAspectRatioCells", mesh.nCells()/100+1);
if (mesh.checkClosedCells(true, &cells, &aspectCells))
{
noFailedChecks++;
if (cells.size() > 0)
{
Pout<< " <<Writing " << cells.size()
<< " non closed cells to set " << cells.name() << endl;
cells.write();
}
}
if (aspectCells.size() > 0)
{
Pout<< " <<Writing " << aspectCells.size()
<< " cells with high aspect ratio to set "
<< aspectCells.name() << endl;
aspectCells.write();
}
}
{
faceSet faces(mesh, "zeroAreaFaces", mesh.nFaces()/100 + 1);
if (mesh.checkFaceAreas(true, &faces))
{
noFailedChecks++;
if (faces.size() > 0)
{
Pout<< " <<Writing " << faces.size()
<< " zero area faces to set " << faces.name() << endl;
faces.write();
}
}
}
{
cellSet cells(mesh, "zeroVolumeCells", mesh.nCells()/100 + 1);
if (mesh.checkCellVolumes(true, &cells))
{
noFailedChecks++;
if (cells.size() > 0)
{
Pout<< " <<Writing " << cells.size()
<< " zero volume cells to set " << cells.name() << endl;
cells.write();
}
}
}
{
faceSet faces(mesh, "nonOrthoFaces", mesh.nFaces()/100 + 1);
if (mesh.checkFaceOrthogonality(true, &faces))
{
noFailedChecks++;
}
if (faces.size() > 0)
{
Pout<< " <<Writing " << faces.size()
<< " non-orthogonal faces to set " << faces.name() << endl;
faces.write();
}
}
{
faceSet faces(mesh, "wrongOrientedFaces", mesh.nFaces()/100 + 1);
if (mesh.checkFacePyramids(true, -SMALL, &faces))
{
noFailedChecks++;
if (faces.size() > 0)
{
Pout<< " <<Writing " << faces.size()
<< " faces with incorrect orientation to set "
<< faces.name() << endl;
faces.write();
}
}
}
{
faceSet faces(mesh, "skewFaces", mesh.nFaces()/100 + 1);
if (mesh.checkFaceSkewness(true, &faces))
{
noFailedChecks++;
if (faces.size() > 0)
{
Pout<< " <<Writing " << faces.size()
<< " skew faces to set " << faces.name() << endl;
faces.write();
}
}
}
if (checkPointNearness)
{
// Note use of nPoints since don't want edge construction.
pointSet points(mesh, "shortEdges", mesh.nPoints()/1000 + 1);
if (mesh.checkEdgeLength(true, minDistSqr, &points))
{
//noFailedChecks++;
if (points.size() > 0)
{
Pout<< " <<Writing " << points.size()
<< " points on short edges to set " << points.name()
<< endl;
points.write();
}
}
label nEdgeClose = points.size();
if (mesh.checkPointNearness(false, minDistSqr, &points))
{
//noFailedChecks++;
if (points.size() > nEdgeClose)
{
pointSet nearPoints(mesh, "nearPoints", points);
Pout<< " <<Writing " << nearPoints.size()
<< " near (closer than " << Foam::sqrt(minDistSqr)
<< " apart) points to set " << nearPoints.name() << endl;
nearPoints.write();
}
}
}
{
faceSet faces(mesh, "concaveFaces", mesh.nFaces()/100 + 1);
if (mesh.checkFaceAngles(true, 10, &faces))
{
//noFailedChecks++;
if (faces.size() > 0)
{
Pout<< " <<Writing " << faces.size()
<< " faces with concave angles to set " << faces.name()
<< endl;
faces.write();
}
}
}
{
faceSet faces(mesh, "warpedFaces", mesh.nFaces()/100 + 1);
if (mesh.checkFaceFlatness(true, 0.8, &faces))
{
//noFailedChecks++;
if (faces.size() > 0)
{
Pout<< " <<Writing " << faces.size()
<< " warped faces to set " << faces.name() << endl;
faces.write();
}
}
}
if (checkCellDeterminant)
{
cellSet cells(mesh, "underdeterminedCells", mesh.nCells()/100);
if (mesh.checkCellDeterminant(true, &cells))
{
noFailedChecks++;
Pout<< " <<Writing " << cells.size()
<< " under-determines cells to set " << cells.name() << endl;
cells.write();
}
}
return noFailedChecks;
}

View File

@ -1,13 +0,0 @@
#include "label.H"
namespace Foam
{
class polyMesh;
label checkGeometry
(
const polyMesh& mesh,
bool checkPointNearness,
bool checkCellDeterminant
);
}

View File

@ -1,152 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
checkMesh
Description
Checks validity of a mesh
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "polyMesh.H"
#include "globalMeshData.H"
#include "printMeshStats.H"
#include "checkTopology.H"
#include "checkGeometry.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "addTimeOptionsNoConstant.H"
argList::validOptions.insert("fullTopology", "");
argList::validOptions.insert("pointNearness", "");
argList::validOptions.insert("cellDeterminant", "");
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
# include "checkTimeOptionsNoConstant.H"
runTime.setTime(Times[startTime], startTime);
# include "createPolyMesh.H"
bool firstCheck = true;
for (label i=startTime; i<endTime; i++)
{
runTime.setTime(Times[i], i);
polyMesh::readUpdateState state = mesh.readUpdate();
if
(
firstCheck
|| state == polyMesh::TOPO_CHANGE
|| state == polyMesh::TOPO_PATCH_CHANGE
)
{
firstCheck = false;
Info<< "Time = " << runTime.timeName() << nl << endl;
// Clear mesh before checking
mesh.clearOut();
// Reconstruct globalMeshData
mesh.globalData();
printMeshStats(mesh);
label noFailedChecks = 0;
noFailedChecks += checkTopology
(
mesh,
args.options().found("fullTopology")
);
noFailedChecks += checkGeometry
(
mesh,
args.options().found("pointNearness"),
args.options().found("cellDeterminant")
);
reduce(noFailedChecks, sumOp<label>());
if (noFailedChecks == 0)
{
Info<< "\nMesh OK."
<< nl << endl;
}
else
{
Info<< "\nFailed " << noFailedChecks << " mesh checks."
<< nl << endl;
}
}
else if (state == polyMesh::POINTS_MOVED)
{
label noFailedChecks = checkGeometry
(
mesh,
args.options().found("pointNearness"),
args.options().found("cellDeterminant")
);
reduce(noFailedChecks, sumOp<label>());
if (noFailedChecks == 0)
{
Info << "\nMesh OK."
<< nl << endl;
}
else
{
Info<< "\nFailed " << noFailedChecks << " mesh checks."
<< nl << endl;
}
}
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //

View File

@ -1,236 +0,0 @@
#include "checkTopology.H"
#include "polyMesh.H"
#include "Time.H"
#include "regionSplit.H"
#include "cellSet.H"
#include "faceSet.H"
#include "pointSet.H"
#include "IOmanip.H"
Foam::label Foam::checkTopology(const polyMesh& mesh, bool fullTopology)
{
label noFailedChecks = 0;
Pout<< "Checking topology..." << endl;
// Check if the boundary definition is unique
mesh.boundaryMesh().checkDefinition(true);
// Check if the boundary processor patches are correct
mesh.boundaryMesh().checkParallelSync(true);
{
pointSet points(mesh, "unusedPoints", mesh.nPoints()/100);
if (mesh.checkPoints(true, &points))
{
noFailedChecks++;
Pout<< " <<Writing " << points.size()
<< " unused points to set " << points.name() << endl;
points.write();
}
}
{
faceSet faces(mesh, "upperTriangularFace", mesh.nFaces()/100);
if (mesh.checkUpperTriangular(true, &faces))
{
noFailedChecks++;
Pout<< " <<Writing " << faces.size()
<< " unordered faces to set " << faces.name() << endl;
faces.write();
}
}
{
cellSet cells(mesh, "zipUpCells", mesh.nCells()/100);
if (mesh.checkCellsZipUp(true, &cells))
{
noFailedChecks++;
Pout<< " <<Writing " << cells.size()
<< " cells with over used edges to set " << cells.name()
<< endl;
cells.write();
}
}
{
faceSet faces(mesh, "outOfRangeFaces", mesh.nFaces()/100);
if (mesh.checkFaceVertices(true, &faces))
{
noFailedChecks++;
Pout<< " <<Writing " << faces.size()
<< " faces with out-of-range vertices to set " << faces.name()
<< endl;
faces.write();
}
}
{
faceSet faces(mesh, "edgeFaces", mesh.nFaces()/100);
if (mesh.checkFaceFaces(true, &faces))
{
noFailedChecks++;
Pout<< " <<Writing " << faces.size()
<< " faces with incorrect edges to set " << faces.name()
<< endl;
faces.write();
}
}
{
regionSplit rs(mesh);
if (rs.nRegions() == 1)
{
Info<< " Number of regions: " << rs.nRegions() << " (OK)."
<< endl;
}
else
{
Info<< " *Number of regions: " << rs.nRegions() << endl;
Info<< " The mesh has multiple regions which are not connected "
"by any face." << endl
<< " <<Writing region information to "
<< mesh.time().timeName()/"cellToRegion"
<< endl;
labelIOList ctr
(
IOobject
(
"cellToRegion",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rs
);
ctr.write();
}
}
if (!Pstream::parRun())
{
Pout<< "\nChecking patch topology for multiply connected surfaces ..."
<< endl;
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Non-manifold points
pointSet points
(
mesh,
"nonManifoldPoints",
mesh.nPoints()/100
);
Pout.setf(ios_base::left);
Pout<< " "
<< setw(20) << "Patch"
<< setw(9) << "Faces"
<< setw(9) << "Points"
<< " Surface" << endl;
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
primitivePatch::surfaceTopo pTyp = pp.surfaceType();
if (pp.size() == 0)
{
Pout<< " "
<< setw(20) << pp.name()
<< setw(9) << pp.size()
<< setw(9) << pp.nPoints()
<< " ok (empty)" << endl;
}
else if (pTyp == primitivePatch::MANIFOLD)
{
if (pp.checkPointManifold(true, &points))
{
Pout<< " "
<< setw(20) << pp.name()
<< setw(9) << pp.size()
<< setw(9) << pp.nPoints()
<< " multiply connected (shared point)" << endl;
}
else
{
Pout<< " "
<< setw(20) << pp.name()
<< setw(9) << pp.size()
<< setw(9) << pp.nPoints()
<< " ok (closed singly connected surface)" << endl;
}
// Add points on non-manifold edges to make set complete
pp.checkTopology(false, &points);
}
else
{
pp.checkTopology(false, &points);
if (pTyp == primitivePatch::OPEN)
{
Pout<< " "
<< setw(20) << pp.name()
<< setw(9) << pp.size()
<< setw(9) << pp.nPoints()
<< " ok (not multiply connected)" << endl;
}
else
{
Pout<< " "
<< setw(20) << pp.name()
<< setw(9) << pp.size()
<< setw(9) << pp.nPoints()
<< " multiply connected surface (shared edge)"
<< endl;
}
}
}
if (points.size() > 0)
{
Pout<< " <<Writing " << points.size()
<< " conflicting points to set "
<< points.name() << endl;
points.write();
}
//Pout.setf(ios_base::right);
}
// Force creation of all addressing if requested.
// Errors will be reported as required
if (fullTopology)
{
mesh.cells();
mesh.faces();
mesh.edges();
mesh.points();
mesh.faceOwner();
mesh.faceNeighbour();
mesh.cellCells();
mesh.edgeCells();
mesh.pointCells();
mesh.edgeFaces();
mesh.pointFaces();
mesh.cellEdges();
mesh.faceEdges();
mesh.pointEdges();
}
return noFailedChecks;
}

View File

@ -1,8 +0,0 @@
#include "label.H"
namespace Foam
{
class polyMesh;
label checkTopology(const polyMesh& mesh, bool fullTopology);
}

View File

@ -1,95 +0,0 @@
#include "printMeshStats.H"
#include "polyMesh.H"
#include "globalMeshData.H"
#include "hexMatcher.H"
#include "wedgeMatcher.H"
#include "prismMatcher.H"
#include "pyrMatcher.H"
#include "tetWedgeMatcher.H"
#include "tetMatcher.H"
void Foam::printMeshStats(const polyMesh& mesh)
{
Pout<< "Mesh stats" << nl
<< " points: " << mesh.points().size() << nl
<< " faces: " << mesh.faces().size() << nl
<< " internal faces: " << mesh.faceNeighbour().size() << nl
<< " cells: " << mesh.cells().size() << nl
<< " boundary patches: " << mesh.boundaryMesh().size() << nl
<< " point zones: " << mesh.pointZones().size() << nl
<< " face zones: " << mesh.faceZones().size() << nl
<< " cell zones: " << mesh.cellZones().size() << nl
<< endl;
if (Pstream::parRun())
{
const globalMeshData& parData = mesh.globalData();
Info<< "Overall stats" << nl
<< " points: " << parData.nTotalPoints() << nl
<< " faces: " << parData.nTotalFaces() << nl
<< " cells: " << parData.nTotalCells() << nl
<< endl;
}
// Construct shape recognizers
hexMatcher hex;
prismMatcher prism;
wedgeMatcher wedge;
pyrMatcher pyr;
tetWedgeMatcher tetWedge;
tetMatcher tet;
// Counters for different cell types
label nHex = 0;
label nWedge = 0;
label nPrism = 0;
label nPyr = 0;
label nTet = 0;
label nTetWedge = 0;
label nUnknown = 0;
for(label cellI = 0; cellI < mesh.nCells(); cellI++)
{
if (hex.isA(mesh, cellI))
{
nHex++;
}
else if (tet.isA(mesh, cellI))
{
nTet++;
}
else if (pyr.isA(mesh, cellI))
{
nPyr++;
}
else if (prism.isA(mesh, cellI))
{
nPrism++;
}
else if (wedge.isA(mesh, cellI))
{
nWedge++;
}
else if (tetWedge.isA(mesh, cellI))
{
nTetWedge++;
}
else
{
nUnknown++;
}
}
Pout<< "Number of cells of each type: " << nl
<< " hexahedra: " << nHex << nl
<< " prisms: " << nPrism << nl
<< " wedges: " << nWedge << nl
<< " pyramids: " << nPyr << nl
<< " tet wedges: " << nTetWedge << nl
<< " tetrahedra: " << nTet << nl
<< " polyhedra: " << nUnknown
<< nl << endl;
}

View File

@ -1,6 +0,0 @@
namespace Foam
{
class polyMesh;
void printMeshStats(const polyMesh& mesh);
}

View File

@ -20,19 +20,16 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
// Min length
scalar minDistSqr = magSqr(1e-6*(globalBb.max() - globalBb.min()));
scalar minDistSqr = magSqr(1e-6 * globalBb.span());
// Non-empty directions
const Vector<label> validDirs = (mesh.directions() + Vector<label>::one)/2;
const Vector<label> validDirs = (mesh.geometricD() + Vector<label>::one)/2;
Info<< " Mesh (non-empty, non-wedge) directions " << validDirs << endl;
Info<< " Mesh (non-empty) directions " << validDirs << endl;
const Vector<label> solDirs = (mesh.solutionD() + Vector<label>::one)/2;
Info<< " Mesh (non-empty) directions " << solDirs << endl;
scalar nGeomDims = mesh.nGeometricD();
Info<< " Mesh (non-empty, non-wedge) dimensions "
<< nGeomDims << endl;
if (nGeomDims < 3)
if (mesh.nGeometricD() < 3)
{
pointSet nonAlignedPoints(mesh, "nonAlignedEdges", mesh.nPoints()/100);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,7 +31,9 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "polyMesh.H"
#include "globalMeshData.H"
@ -45,48 +47,34 @@ using namespace Foam;
int main(int argc, char *argv[])
{
timeSelector::addOptions(false); // no constant
# include "addRegionOption.H"
# include "addTimeOptionsNoConstant.H"
argList::validOptions.insert("noTopology", "");
argList::validOptions.insert("allGeometry", "");
argList::validOptions.insert("allTopology", "");
# include "setRootCase.H"
const bool noTopology = args.options().found("noTopology");
const bool allGeometry = args.options().found("allGeometry");
const bool allTopology = args.options().found("allTopology");
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
# include "checkTimeOptionsNoConstant.H"
runTime.setTime(Times[startTime], startTime);
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createNamedPolyMesh.H"
bool firstCheck = true;
const bool noTopology = args.optionFound("noTopology");
const bool allGeometry = args.optionFound("allGeometry");
const bool allTopology = args.optionFound("allTopology");
for (label i=startTime; i<endTime; i++)
forAll(timeDirs, timeI)
{
runTime.setTime(Times[i], i);
runTime.setTime(timeDirs[timeI], timeI);
polyMesh::readUpdateState state = mesh.readUpdate();
if
(
firstCheck
!timeI
|| state == polyMesh::TOPO_CHANGE
|| state == polyMesh::TOPO_PATCH_CHANGE
)
{
firstCheck = false;
Info<< "Time = " << runTime.timeName() << nl << endl;
// Clear mesh before checking
@ -110,39 +98,37 @@ int main(int argc, char *argv[])
if (noFailedChecks == 0)
{
Info<< "\nMesh OK."
<< nl << endl;
Info<< "\nMesh OK.\n" << endl;
}
else
{
Info<< "\nFailed " << noFailedChecks << " mesh checks."
<< nl << endl;
Info<< "\nFailed " << noFailedChecks << " mesh checks.\n"
<< endl;
}
}
else if (state == polyMesh::POINTS_MOVED)
{
Info<< "Time = " << runTime.timeName() << nl << endl;
label noFailedChecks = checkGeometry(mesh, allGeometry);
label nFailedChecks = checkGeometry(mesh, allGeometry);
reduce(noFailedChecks, sumOp<label>());
reduce(nFailedChecks, sumOp<label>());
if (noFailedChecks == 0)
if (nFailedChecks)
{
Info << "\nMesh OK."
<< nl << endl;
Info<< "\nFailed " << nFailedChecks << " mesh checks.\n"
<< endl;
}
else
{
Info<< "\nFailed " << noFailedChecks << " mesh checks."
<< nl << endl;
Info << "\nMesh OK.\n" << endl;
}
}
}
Info<< "End\n" << endl;
return(0);
return 0;
}

View File

@ -7,6 +7,31 @@
#include "pointSet.H"
#include "IOmanip.H"
bool Foam::checkSync(const wordList& names)
{
List<wordList> allNames(Pstream::nProcs());
allNames[Pstream::myProcNo()] = names;
Pstream::gatherList(allNames);
bool hasError = false;
for (label procI = 1; procI < allNames.size(); procI++)
{
if (allNames[procI] != allNames[0])
{
hasError = true;
Info<< " ***Inconsistent zones across processors, "
"processor 0 has zones:" << allNames[0]
<< ", processor " << procI << " has zones:"
<< allNames[procI]
<< endl;
}
}
return hasError;
}
Foam::label Foam::checkTopology
(
const polyMesh& mesh,
@ -24,6 +49,36 @@ Foam::label Foam::checkTopology
// Check if the boundary processor patches are correct
mesh.boundaryMesh().checkParallelSync(true);
// Check names of zones are equal
if (checkSync(mesh.cellZones().names()))
{
noFailedChecks++;
}
if (checkSync(mesh.faceZones().names()))
{
noFailedChecks++;
}
if (checkSync(mesh.pointZones().names()))
{
noFailedChecks++;
}
// Check contents of faceZones consistent
{
forAll(mesh.faceZones(), zoneI)
{
if (mesh.faceZones()[zoneI].checkParallelSync(false))
{
Info<< " ***FaceZone " << mesh.faceZones()[zoneI].name()
<< " is not correctly synchronised"
<< " acrosss coupled boundaries."
<< " (coupled faces both"
<< " present in set but with opposite flipmap)" << endl;
noFailedChecks++;
}
}
}
{
pointSet points(mesh, "unusedPoints", mesh.nPoints()/100);
if (mesh.checkPoints(true, &points))
@ -102,6 +157,67 @@ Foam::label Foam::checkTopology
}
}
if (allTopology)
{
labelList nInternalFaces(mesh.nCells(), 0);
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
{
nInternalFaces[mesh.faceOwner()[faceI]]++;
nInternalFaces[mesh.faceNeighbour()[faceI]]++;
}
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAll(patches, patchI)
{
if (patches[patchI].coupled())
{
const unallocLabelList& owners = patches[patchI].faceCells();
forAll(owners, i)
{
nInternalFaces[owners[i]]++;
}
}
}
faceSet oneCells(mesh, "oneInternalFaceCells", mesh.nCells()/100);
faceSet twoCells(mesh, "twoInternalFacesCells", mesh.nCells()/100);
forAll(nInternalFaces, cellI)
{
if (nInternalFaces[cellI] <= 1)
{
oneCells.insert(cellI);
}
else if (nInternalFaces[cellI] == 2)
{
twoCells.insert(cellI);
}
}
label nOneCells = returnReduce(oneCells.size(), sumOp<label>());
if (nOneCells > 0)
{
Info<< " <<Writing " << nOneCells
<< " cells with with single non-boundary face to set "
<< oneCells.name()
<< endl;
oneCells.write();
}
label nTwoCells = returnReduce(twoCells.size(), sumOp<label>());
if (nTwoCells > 0)
{
Info<< " <<Writing " << nTwoCells
<< " cells with with single non-boundary face to set "
<< twoCells.name()
<< endl;
twoCells.write();
}
}
{
regionSplit rs(mesh);
@ -109,7 +225,7 @@ Foam::label Foam::checkTopology
{
Info<< " Number of regions: " << rs.nRegions() << " (OK)."
<< endl;
}
else
{
@ -177,7 +293,7 @@ Foam::label Foam::checkTopology
primitivePatch::surfaceTopo pTyp = pp.surfaceType();
if (pp.size() == 0)
if (pp.empty())
{
Pout<< setw(34) << "ok (empty)";
}
@ -214,7 +330,7 @@ Foam::label Foam::checkTopology
const pointField& pts = pp.points();
const labelList& mp = pp.meshPoints();
boundBox bb(vector::zero, vector::zero);
boundBox bb; // zero-sized
if (returnReduce(mp.size(), sumOp<label>()) > 0)
{
bb.min() = pts[mp[0]];
@ -232,7 +348,7 @@ Foam::label Foam::checkTopology
Pout<< endl;
}
if (points.size() > 0)
if (points.size())
{
Pout<< " <<Writing " << points.size()
<< " conflicting points to set "

View File

@ -1,8 +1,11 @@
#include "label.H"
#include "wordList.H"
namespace Foam
{
class polyMesh;
bool checkSync(const wordList& names);
label checkTopology(const polyMesh&, const bool, const bool);
}

View File

@ -69,13 +69,13 @@ void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
<< " cells: "
<< returnReduce(mesh.cells().size(), sumOp<label>()) << nl
<< " boundary patches: "
<< returnReduce(mesh.boundaryMesh().size(), sumOp<label>()) << nl
<< mesh.boundaryMesh().size() << nl
<< " point zones: "
<< returnReduce(mesh.pointZones().size(), sumOp<label>()) << nl
<< mesh.pointZones().size() << nl
<< " face zones: "
<< returnReduce(mesh.faceZones().size(), sumOp<label>()) << nl
<< mesh.faceZones().size() << nl
<< " cell zones: "
<< returnReduce(mesh.cellZones().size(), sumOp<label>()) << nl
<< mesh.cellZones().size() << nl
<< endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,11 +23,11 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Makes internal faces into boundary faces. Does not duplicate points. Use
mergeOrSplitBaffles if you want this.
Makes internal faces into boundary faces. Does not duplicate points, unlike
mergeOrSplitBaffles.
Note: if any coupled patch face is selected for baffling automatically
the opposite member is selected for baffling as well. Note that this
Note: if any coupled patch face is selected for baffling the opposite
member has to be selected for baffling as well. Note that this
is the same as repatching. This was added only for convenience so
you don't have to filter coupled boundary out of your set.
@ -43,47 +43,154 @@ Description
#include "ReadFields.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "ZoneIDs.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void modifyOrAddFace
(
polyTopoChange& meshMod,
const face& f,
const label faceI,
const label own,
const bool flipFaceFlux,
const label newPatchI,
const label zoneID,
const bool zoneFlip,
PackedBoolList& modifiedFace
)
{
if (!modifiedFace[faceI])
{
// First usage of face. Modify.
meshMod.setAction
(
polyModifyFace
(
f, // modified face
faceI, // label of face
own, // owner
-1, // neighbour
flipFaceFlux, // face flip
newPatchI, // patch for face
false, // remove from zone
zoneID, // zone for face
zoneFlip // face flip in zone
)
);
modifiedFace[faceI] = 1;
}
else
{
// Second or more usage of face. Add.
meshMod.setAction
(
polyAddFace
(
f, // modified face
own, // owner
-1, // neighbour
-1, // master point
-1, // master edge
faceI, // master face
flipFaceFlux, // face flip
newPatchI, // patch for face
zoneID, // zone for face
zoneFlip // face flip in zone
)
);
}
}
label findPatchID(const polyMesh& mesh, const word& name)
{
label patchI = mesh.boundaryMesh().findPatchID(name);
if (patchI == -1)
{
FatalErrorIn("findPatchID(const polyMesh&, const word&)")
<< "Cannot find patch " << name << endl
<< "Valid patches are " << mesh.boundaryMesh().names()
<< exit(FatalError);
}
return patchI;
}
// Main program:
int main(int argc, char *argv[])
{
argList::validArgs.append("set");
argList::validArgs.append("faceZone");
argList::validArgs.append("patch");
argList::validOptions.insert("additionalPatches", "(patch2 .. patchN)");
argList::validOptions.insert("internalFacesOnly", "");
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createMesh.H"
const word oldInstance = mesh.pointsInstance();
const polyBoundaryMesh& patches = mesh.boundaryMesh();
const faceZoneMesh& faceZones = mesh.faceZones();
// Faces to baffle
word setName(args.additionalArgs()[0]);
Pout<< "Reading faceSet from " << setName << nl << endl;
faceSet facesToSplit(mesh, setName);
Pout<< "Read " << facesToSplit.size() << " faces from " << setName
<< nl << endl;
faceZoneID zoneID(args.additionalArgs()[0], faceZones);
Info<< "Converting faces on zone " << zoneID.name()
<< " into baffles." << nl << endl;
const faceZone& fZone = faceZones[zoneID.index()];
Info<< "Found " << returnReduce(fZone.size(), sumOp<label>())
<< " faces on zone " << zoneID.name() << nl << endl;
// Make sure patches and zoneFaces are synchronised across couples
patches.checkParallelSync(true);
fZone.checkParallelSync(true);
// Patches to put baffles into
DynamicList<label> newPatches(1);
// Patch to put them into
word patchName(args.additionalArgs()[1]);
label wantedPatchI = patches.findPatchID(patchName);
newPatches.append(findPatchID(mesh, patchName));
Info<< "Using patch " << patchName
<< " at index " << newPatches[0] << endl;
Pout<< "Using patch " << patchName << " at index " << wantedPatchI << endl;
if (wantedPatchI == -1)
// Additional patches
if (args.optionFound("additionalPatches"))
{
FatalErrorIn(args.executable())
<< "Cannot find patch " << patchName << exit(FatalError);
const wordList patchNames
(
args.optionLookup("additionalPatches")()
);
newPatches.reserve(patchNames.size() + 1);
forAll(patchNames, i)
{
newPatches.append(findPatchID(mesh, patchNames[i]));
Info<< "Using additional patch " << patchNames[i]
<< " at index " << newPatches[newPatches.size()-1] << endl;
}
}
bool overwrite = args.optionFound("overwrite");
bool internalFacesOnly = args.optionFound("internalFacesOnly");
if (internalFacesOnly)
{
Info<< "Not converting faces on non-coupled patches." << nl << endl;
}
bool overwrite = args.options().found("overwrite");
// Read objects in time directory
IOobjectList objects(mesh, runTime.timeName());
@ -127,107 +234,192 @@ int main(int argc, char *argv[])
polyTopoChange meshMod(mesh);
// Creating baffles:
// - coupled boundary faces : become the patch specified
// - non-coupled ,, : illegal
// - internal faces : converted into boundary faces.
// Do the actual changes. Note:
// - loop in incrementing face order (not necessary if faceZone ordered).
// Preserves any existing ordering on patch faces.
// - two passes, do non-flip faces first and flip faces second. This
// guarantees that when e.g. creating a cyclic all faces from one
// side come first and faces from the other side next.
labelList newPatch(mesh.nFaces(), -1);
forAllConstIter(faceSet, facesToSplit, iter)
// Whether first use of face (modify) or consecutive (add)
PackedBoolList modifiedFace(mesh.nFaces());
// Never modify coupled faces
forAll(patches, patchI)
{
label faceI = iter.key();
label patchI = patches.whichPatch(faceI);
if (patchI == -1)
const polyPatch& pp = patches[patchI];
if (pp.coupled())
{
newPatch[faceI] = wantedPatchI;
}
else
{
if (patches[patchI].coupled())
forAll(pp, i)
{
if (patchI != wantedPatchI)
modifiedFace[pp.start()+i] = 1;
}
}
}
label nModified = 0;
forAll(newPatches, i)
{
label newPatchI = newPatches[i];
// Pass 1. Do selected side of zone
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
{
label zoneFaceI = fZone.whichFace(faceI);
if (zoneFaceI != -1)
{
if (!fZone.flipMap()[zoneFaceI])
{
newPatch[faceI] = wantedPatchI;
// Use owner side of face
modifyOrAddFace
(
meshMod,
mesh.faces()[faceI], // modified face
faceI, // label of face
mesh.faceOwner()[faceI],// owner
false, // face flip
newPatchI, // patch for face
zoneID.index(), // zone for face
false, // face flip in zone
modifiedFace // modify or add status
);
}
else
{
// Use neighbour side of face
modifyOrAddFace
(
meshMod,
mesh.faces()[faceI].reverseFace(), // modified face
faceI, // label of face
mesh.faceNeighbour()[faceI],// owner
true, // face flip
newPatchI, // patch for face
zoneID.index(), // zone for face
true, // face flip in zone
modifiedFace // modify or add status
);
}
nModified++;
}
}
// Pass 2. Do other side of zone
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
{
label zoneFaceI = fZone.whichFace(faceI);
if (zoneFaceI != -1)
{
if (!fZone.flipMap()[zoneFaceI])
{
// Use neighbour side of face
modifyOrAddFace
(
meshMod,
mesh.faces()[faceI].reverseFace(), // modified face
faceI, // label of face
mesh.faceNeighbour()[faceI], // owner
true, // face flip
newPatchI, // patch for face
zoneID.index(), // zone for face
true, // face flip in zone
modifiedFace // modify or add
);
}
else
{
// Use owner side of face
modifyOrAddFace
(
meshMod,
mesh.faces()[faceI], // modified face
faceI, // label of face
mesh.faceOwner()[faceI],// owner
false, // face flip
newPatchI, // patch for face
zoneID.index(), // zone for face
false, // face flip in zone
modifiedFace // modify or add status
);
}
}
else
{
FatalErrorIn(args.executable())
<< "Can only create baffles from internal faces"
<< " or coupled boundary faces." << endl
<< "Face " << faceI << " is a boundary face on patch "
<< patches[patchI].name() << exit(FatalError);
}
}
}
// If one side of a coupled boundary is marked for baffling, make sure to
// also do the other side.
// Modify any boundary faces
// ~~~~~~~~~~~~~~~~~~~~~~~~~
syncTools::syncFaceList(mesh, newPatch, maxEqOp<label>(), false);
// Normal boundary:
// - move to new patch. Might already be back-to-back baffle
// you want to add cyclic to. Do warn though.
//
// Processor boundary:
// - do not move to cyclic
// - add normal patches though.
// For warning once per patch.
labelHashSet patchWarned;
label nBaffled = 0;
forAll(newPatch, faceI)
{
if (newPatch[faceI] != -1)
forAll(patches, patchI)
{
const face& f = mesh.faces()[faceI];
label zoneID = faceZones.whichZone(faceI);
bool zoneFlip = false;
if (zoneID >= 0)
const polyPatch& pp = patches[patchI];
if (pp.coupled() && patches[newPatchI].coupled())
{
const faceZone& fZone = faceZones[zoneID];
zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
// Do not allow coupled faces to be moved to different coupled
// patches.
}
meshMod.setAction
(
polyModifyFace
(
f, // modified face
faceI, // label of face
mesh.faceOwner()[faceI], // owner
-1, // neighbour
false, // face flip
newPatch[faceI], // patch for face
false, // remove from zone
zoneID, // zone for face
zoneFlip // face flip in zone
)
);
if (mesh.isInternalFace(faceI))
else if (pp.coupled() || !internalFacesOnly)
{
meshMod.setAction
(
polyAddFace
(
f.reverseFace(), // modified face
mesh.faceNeighbour()[faceI],// owner
-1, // neighbour
-1, // masterPointID
-1, // masterEdgeID
faceI, // masterFaceID,
false, // face flip
newPatch[faceI], // patch for face
zoneID, // zone for face
zoneFlip // face flip in zone
)
);
}
forAll(pp, i)
{
label faceI = pp.start()+i;
nBaffled++;
label zoneFaceI = fZone.whichFace(faceI);
if (zoneFaceI != -1)
{
if (patchWarned.insert(patchI))
{
WarningIn(args.executable())
<< "Found boundary face (in patch " << pp.name()
<< ") in faceZone " << fZone.name()
<< " to convert to baffle patch "
<< patches[newPatchI].name()
<< endl
<< " Run with -internalFacesOnly option"
<< " if you don't wish to convert"
<< " boundary faces." << endl;
}
modifyOrAddFace
(
meshMod,
mesh.faces()[faceI], // modified face
faceI, // label of face
mesh.faceOwner()[faceI], // owner
false, // face flip
newPatchI, // patch for face
zoneID.index(), // zone for face
fZone.flipMap()[zoneFaceI], // face flip in zone
modifiedFace // modify or add status
);
nModified++;
}
}
}
}
}
Pout<< "Converted locally " << nBaffled
Info<< "Converted " << returnReduce(nModified, sumOp<label>())
<< " faces into boundary faces on patch " << patchName << nl << endl;
if (!overwrite)
@ -247,7 +439,11 @@ int main(int argc, char *argv[])
mesh.movePoints(map().preMotionPoints());
}
Pout<< "Writing mesh to " << runTime.timeName() << endl;
if (overwrite)
{
mesh.setInstance(oldInstance);
}
Info<< "Writing mesh to " << runTime.timeName() << endl;
mesh.write();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,6 +34,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "cyclicPolyPatch.H"
#include "syncTools.H"
#include "argList.H"
#include "polyMesh.H"
@ -72,23 +73,6 @@ public:
};
label getPatch(const polyBoundaryMesh& patches, const word& patchName)
{
label patchI = patches.findPatchID(patchName);
if (patchI == -1)
{
FatalErrorIn("createPatch(const polyBoundaryMesh&, const word&)")
<< "Cannot find source patch " << patchName
<< endl << "Valid patch names are " << patches.names()
<< exit(FatalError);
}
return patchI;
}
void changePatchID
(
const polyMesh& mesh,
@ -171,7 +155,7 @@ void filterPatches(polyMesh& mesh)
if (isA<processorPolyPatch>(pp))
{
if (pp.size() > 0)
if (pp.size())
{
allPatches.append
(
@ -224,6 +208,8 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
// Dump halves
{
OFstream str(prefix+cycPatch.name()+"_half0.obj");
Pout<< "Dumping cycPatch.name() half0 faces to " << str.name()
<< endl;
meshTools::writeOBJ
(
str,
@ -240,6 +226,8 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
}
{
OFstream str(prefix+cycPatch.name()+"_half1.obj");
Pout<< "Dumping cycPatch.name() half1 faces to " << str.name()
<< endl;
meshTools::writeOBJ
(
str,
@ -256,32 +244,14 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
);
}
// cycPatch.writeOBJ
// (
// prefix+cycPatch.name()+"_half0.obj",
// SubList<face>
// (
// cycPatch,
// halfSize
// ),
// cycPatch.points()
// );
// cycPatch.writeOBJ
// (
// prefix+cycPatch.name()+"_half1.obj",
// SubList<face>
// (
// cycPatch,
// halfSize,
// halfSize
// ),
// cycPatch.points()
// );
// Lines between corresponding face centres
OFstream str(prefix+cycPatch.name()+"_match.obj");
label vertI = 0;
Pout<< "Dumping cyclic match as lines between face centres to "
<< str.name() << endl;
for (label faceI = 0; faceI < halfSize; faceI++)
{
const point& fc0 = mesh.faceCentres()[cycPatch.start()+faceI];
@ -289,7 +259,8 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
vertI++;
label nbrFaceI = halfSize + faceI;
const point& fc1 = mesh.faceCentres()[cycPatch.start()+nbrFaceI];
const point& fc1 =
mesh.faceCentres()[cycPatch.start()+nbrFaceI];
meshTools::writeOBJ(str, fc1);
vertI++;
@ -300,6 +271,247 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
}
void separateList
(
const vectorField& separation,
UList<vector>& field
)
{
if (separation.size() == 1)
{
// Single value for all.
forAll(field, i)
{
field[i] += separation[0];
}
}
else if (separation.size() == field.size())
{
forAll(field, i)
{
field[i] += separation[i];
}
}
else
{
FatalErrorIn
(
"separateList(const vectorField&, UList<vector>&)"
) << "Sizes of field and transformation not equal. field:"
<< field.size() << " transformation:" << separation.size()
<< abort(FatalError);
}
}
// Synchronise points on both sides of coupled boundaries.
template <class CombineOp>
void syncPoints
(
const polyMesh& mesh,
pointField& points,
const CombineOp& cop,
const point& nullValue
)
{
if (points.size() != mesh.nPoints())
{
FatalErrorIn
(
"syncPoints"
"(const polyMesh&, pointField&, const CombineOp&, const point&)"
) << "Number of values " << points.size()
<< " is not equal to the number of points in the mesh "
<< mesh.nPoints() << abort(FatalError);
}
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Is there any coupled patch with transformation?
bool hasTransformation = false;
if (Pstream::parRun())
{
// Send
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
if
(
isA<processorPolyPatch>(pp)
&& pp.nPoints() > 0
&& refCast<const processorPolyPatch>(pp).owner()
)
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(pp);
// Get data per patchPoint in neighbouring point numbers.
pointField patchInfo(procPatch.nPoints(), nullValue);
const labelList& meshPts = procPatch.meshPoints();
const labelList& nbrPts = procPatch.neighbPoints();
forAll(nbrPts, pointI)
{
label nbrPointI = nbrPts[pointI];
if (nbrPointI >= 0 && nbrPointI < patchInfo.size())
{
patchInfo[nbrPointI] = points[meshPts[pointI]];
}
}
OPstream toNbr(Pstream::blocking, procPatch.neighbProcNo());
toNbr << patchInfo;
}
}
// Receive and set.
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
if
(
isA<processorPolyPatch>(pp)
&& pp.nPoints() > 0
&& !refCast<const processorPolyPatch>(pp).owner()
)
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(pp);
pointField nbrPatchInfo(procPatch.nPoints());
{
// We do not know the number of points on the other side
// so cannot use Pstream::read.
IPstream fromNbr
(
Pstream::blocking,
procPatch.neighbProcNo()
);
fromNbr >> nbrPatchInfo;
}
// Null any value which is not on neighbouring processor
nbrPatchInfo.setSize(procPatch.nPoints(), nullValue);
if (!procPatch.parallel())
{
hasTransformation = true;
transformList(procPatch.forwardT(), nbrPatchInfo);
}
else if (procPatch.separated())
{
hasTransformation = true;
separateList(-procPatch.separation(), nbrPatchInfo);
}
const labelList& meshPts = procPatch.meshPoints();
forAll(meshPts, pointI)
{
label meshPointI = meshPts[pointI];
points[meshPointI] = nbrPatchInfo[pointI];
}
}
}
}
// Do the cyclics.
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
if (isA<cyclicPolyPatch>(pp))
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(pp);
const edgeList& coupledPoints = cycPatch.coupledPoints();
const labelList& meshPts = cycPatch.meshPoints();
pointField half0Values(coupledPoints.size());
forAll(coupledPoints, i)
{
const edge& e = coupledPoints[i];
label point0 = meshPts[e[0]];
half0Values[i] = points[point0];
}
if (!cycPatch.parallel())
{
hasTransformation = true;
transformList(cycPatch.reverseT(), half0Values);
}
else if (cycPatch.separated())
{
hasTransformation = true;
const vectorField& v = cycPatch.coupledPolyPatch::separation();
separateList(v, half0Values);
}
forAll(coupledPoints, i)
{
const edge& e = coupledPoints[i];
label point1 = meshPts[e[1]];
points[point1] = half0Values[i];
}
}
}
//- Note: hasTransformation is only used for warning messages so
// reduction not strictly nessecary.
//reduce(hasTransformation, orOp<bool>());
// Synchronize multiple shared points.
const globalMeshData& pd = mesh.globalData();
if (pd.nGlobalPoints() > 0)
{
if (hasTransformation)
{
WarningIn
(
"syncPoints"
"(const polyMesh&, pointField&, const CombineOp&, const point&)"
) << "There are decomposed cyclics in this mesh with"
<< " transformations." << endl
<< "This is not supported. The result will be incorrect"
<< endl;
}
// Values on shared points.
pointField sharedPts(pd.nGlobalPoints(), nullValue);
forAll(pd.sharedPointLabels(), i)
{
label meshPointI = pd.sharedPointLabels()[i];
// Fill my entries in the shared points
sharedPts[pd.sharedPointAddr()[i]] = points[meshPointI];
}
// Combine on master.
Pstream::listCombineGather(sharedPts, cop);
Pstream::listCombineScatter(sharedPts);
// Now we will all have the same information. Merge it back with
// my local information.
forAll(pd.sharedPointLabels(), i)
{
label meshPointI = pd.sharedPointLabels()[i];
points[meshPointI] = sharedPts[pd.sharedPointAddr()[i]];
}
}
}
// Main program:
int main(int argc, char *argv[])
@ -310,7 +522,7 @@ int main(int argc, char *argv[])
# include "createTime.H"
runTime.functionObjects().off();
const bool overwrite = args.options().found("overwrite");
const bool overwrite = args.optionFound("overwrite");
Info<< "Reading createPatchDict." << nl << endl;
@ -340,6 +552,7 @@ int main(int argc, char *argv[])
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -357,7 +570,7 @@ int main(int argc, char *argv[])
// 1. Add all new patches
// ~~~~~~~~~~~~~~~~~~~~~~
if (patchSources.size() > 0)
if (patchSources.size())
{
// Old and new patches.
DynamicList<polyPatch*> allPatches(patches.size()+patchSources.size());
@ -393,25 +606,26 @@ int main(int argc, char *argv[])
label destPatchI = patches.findPatchID(patchName);
word patchType(dict.lookup("type"));
if (destPatchI == -1)
{
dictionary patchDict(dict.subDict("dictionary"));
destPatchI = allPatches.size();
Info<< "Adding new patch " << patchName
<< " of type " << patchType
<< " as patch " << destPatchI << endl;
<< " as patch " << destPatchI
<< " from " << patchDict << endl;
patchDict.set("nFaces", 0);
patchDict.set("startFace", startFaceI);
// Add an empty patch.
allPatches.append
(
polyPatch::New
(
patchType,
patchName,
0, // size
startFaceI, // start
patchDict,
destPatchI,
patches
).ptr()
@ -473,14 +687,12 @@ int main(int argc, char *argv[])
if (sourceType == "patches")
{
wordList patchSources(dict.lookup("patches"));
labelHashSet patchSources(patches.patchSet(dict.lookup("patches")));
// Repatch faces of the patches.
forAll(patchSources, sourceI)
forAllConstIter(labelHashSet, patchSources, iter)
{
label patchI = getPatch(patches, patchSources[sourceI]);
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[iter.key()];
Info<< "Moving faces from patch " << pp.name()
<< " to patch " << destPatchI << endl;
@ -550,6 +762,8 @@ int main(int argc, char *argv[])
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, true);
mesh.movePoints(map().preMotionPoints());
dumpCyclicMatch("coupled_", mesh);
// Synchronise points.
if (!pointSync)
{
@ -557,16 +771,100 @@ int main(int argc, char *argv[])
}
else
{
Info<< "Synchronising points." << nl << endl;
// This is a bit tricky. Both normal and position might be out and
// current separation also includes the normal
// ( separation_ = (nf&(Cr - Cf))*nf ).
// For processor patches:
// - disallow multiple separation/transformation. This basically
// excludes decomposed cyclics. Use the (probably 0) separation
// to align the points.
// For cyclic patches:
// - for separated ones use our own recalculated offset vector
// - for rotational ones use current one.
forAll(mesh.boundaryMesh(), patchI)
{
const polyPatch& pp = mesh.boundaryMesh()[patchI];
if (pp.size() && isA<coupledPolyPatch>(pp))
{
const coupledPolyPatch& cpp =
refCast<const coupledPolyPatch>(pp);
if (cpp.separated())
{
Info<< "On coupled patch " << pp.name()
<< " separation[0] was "
<< cpp.separation()[0] << endl;
if (isA<cyclicPolyPatch>(pp))
{
const cyclicPolyPatch& cycpp =
refCast<const cyclicPolyPatch>(pp);
if (cycpp.transform() == cyclicPolyPatch::TRANSLATIONAL)
{
Info<< "On cyclic translation patch " << pp.name()
<< " forcing uniform separation of "
<< cycpp.separationVector() << endl;
const_cast<vectorField&>(cpp.separation()) =
pointField(1, cycpp.separationVector());
}
else
{
const_cast<vectorField&>(cpp.separation()) =
pointField
(
1,
pp[pp.size()/2].centre(mesh.points())
- pp[0].centre(mesh.points())
);
}
}
else
{
const_cast<vectorField&>(cpp.separation())
.setSize(1);
}
Info<< "On coupled patch " << pp.name()
<< " forcing uniform separation of "
<< cpp.separation() << endl;
}
else if (!cpp.parallel())
{
Info<< "On coupled patch " << pp.name()
<< " forcing uniform rotation of "
<< cpp.forwardT()[0] << endl;
const_cast<tensorField&>
(
cpp.forwardT()
).setSize(1);
const_cast<tensorField&>
(
cpp.reverseT()
).setSize(1);
Info<< "On coupled patch " << pp.name()
<< " forcing uniform rotation of "
<< cpp.forwardT() << endl;
}
}
}
Info<< "Synchronising points." << endl;
pointField newPoints(mesh.points());
syncTools::syncPointList
syncPoints
(
mesh,
newPoints,
nearestEqOp(), // cop
point(GREAT, GREAT, GREAT), // nullValue
true // applySeparation
nearestEqOp(),
point(GREAT, GREAT, GREAT)
);
scalarField diff(mag(newPoints-mesh.points()));
@ -583,6 +881,8 @@ int main(int argc, char *argv[])
filterPatches(mesh);
dumpCyclicMatch("final_", mesh);
// Set the precision of the points data to 10
IOstream::defaultPrecision(10);
@ -591,6 +891,10 @@ int main(int argc, char *argv[])
{
runTime++;
}
else
{
mesh.setInstance(oldInstance);
}
// Write resulting mesh
Info<< "Writing repatched mesh to " << runTime.timeName() << nl << endl;

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -15,29 +15,62 @@ FoamFile
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// This application/dictionary controls:
// - optional: create new patches from boundary faces (either given as
// a set of patches or as a faceSet)
// - always: order faces on coupled patches such that they are opposite. This
// is done for all coupled faces, not just for any patches created.
// - optional: synchronise points on coupled patches.
// 1. Create cyclic:
// - specify where the faces should come from
// - specify the type of cyclic. If a rotational specify the rotationAxis
// and centre to make matching easier
// - pointSync true to guarantee points to line up.
// 2. Correct incorrect cyclic:
// This will usually fail upon loading:
// "face 0 area does not match neighbour 2 by 0.0100005%"
// " -- possible face ordering problem."
// - change patch type from 'cyclic' to 'patch' in the polyMesh/boundary file.
// - loosen match tolerance to get case to load
// - regenerate cyclic as above
// Tolerance used in matching faces. Absolute tolerance is span of
// face times this factor.
// face times this factor. To load incorrectly matches meshes set this
// to a higher value.
matchTolerance 1E-3;
// Do a synchronisation of coupled points.
// Do a synchronisation of coupled points after creation of any patches.
pointSync true;
// Patches to create.
// If no patches does a coupled point and face synchronisation anyway.
patches
(
{
// Name of new patch
name leftRight0;
name sidePatches;
// Type of new patch
type cyclic;
dictionary
{
type cyclic;
// How to construct: either 'patches' or 'set'
// Optional: explicitly set transformation tensor.
// Used when matching and synchronising points.
//transform translational;
//separationVector (-2289 0 0);
transform rotational;
rotationAxis (1 0 0);
rotationCentre (0 0 0);
}
// How to construct: either from 'patches' or 'set'
constructFrom patches;
// If constructFrom = patches : names of patches
patches (half0 half1);
// If constructFrom = patches : names of patches. Wildcards allowed.
patches ("periodic.*");
// If constructFrom = set : name of faceSet
set f0;
@ -45,11 +78,16 @@ patches
{
name bottom;
type patch;
// Type of new patch
dictionary
{
type wall;
}
constructFrom set;
patches (half0 half1);
patches ();
set bottomFaces;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -52,19 +52,17 @@ int main(int argc, char *argv[])
# include "createTime.H"
# include "createMesh.H"
pointMesh pMesh(mesh);
volPointInterpolation pInterp(mesh, pMesh);
volPointInterpolation pInterp(mesh);
// Get times list
instantList Times = runTime.times();
pointField zeroPoints(mesh.points());
runTime.setTime(Times[0], 0);
for (int i = 1; i<Times.size(); i++)
// skip "constant" time
for (label timeI = 1; timeI < Times.size(); ++timeI)
{
runTime.setTime(Times[i], i);
runTime.setTime(Times[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
@ -100,7 +98,7 @@ int main(int argc, char *argv[])
Info<< "End\n" << endl;
return(0);
return 0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,19 +74,7 @@ int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
Info<< "Reading mesh for time = " << runTime.value() << endl;
Info<< "Create mesh\n" << endl;
polyMesh mesh
(
IOobject
(
polyMesh::defaultRegion,
runTime.timeName(),
runTime
)
);
# include "createPolyMesh.H"
Info<< "Reading faceSetDict\n" << endl;

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -56,13 +56,13 @@ topoSetSources
// All faces of patch
patchToFace
{
name movingWall;
name ".*Wall"; // Name of patch, regular expressions allowed
}
// All faces of faceZone
zoneToFace
{
name faceZone1; // Name of faceZone
name ".*Zone1"; // Name of faceZone, regular expressions allowed
}
// Faces with face centre within box

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,7 +26,7 @@ Application
flattenMesh
Description
Flatten the front and back planes of a 2D cartesian mesh.
Flattens the front and back planes of a 2D cartesian mesh.
\*---------------------------------------------------------------------------*/
@ -90,7 +90,7 @@ int main(int argc, char *argv[])
}
}
twoDCorr.correctPoints(points);
twoDCorr.correctPoints(points);
// Set the precision of the points data to 10
IOstream::defaultPrecision(10);
@ -98,7 +98,7 @@ int main(int argc, char *argv[])
Info << "Writing points into directory " << points.path() << nl << endl;
points.write();
return(0);
return 0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Pick up cells with cell centre 'inside' of surface. Requires surface
Picks up cells with cell centre 'inside' of surface. Requires surface
to be closed and singly connected.
\*---------------------------------------------------------------------------*/

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,7 +42,7 @@ int main(int argc, char *argv[])
# include "setRoots.H"
# include "createTimes.H"
Info<< "Reading master mesh for time = " << runTimeMaster.value() << endl;
Info<< "Reading master mesh for time = " << runTimeMaster.timeName() << endl;
Info<< "Create mesh\n" << endl;
mergePolyMesh masterMesh
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
);
Info<< "Reading mesh to add for time = " << runTimeToAdd.value() << endl;
Info<< "Reading mesh to add for time = " << runTimeToAdd.timeName() << endl;
Info<< "Create mesh\n" << endl;
polyMesh meshToAdd
@ -71,7 +71,7 @@ int main(int argc, char *argv[])
runTimeMaster++;
Info<< "Writing combined mesh to " << runTimeMaster.value() << endl;
Info<< "Writing combined mesh to " << runTimeMaster.timeName() << endl;
masterMesh.addMesh(meshToAdd);
masterMesh.merge();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,10 +34,7 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(mergePolyMesh, 1);
}
defineTypeNameAndDebug(Foam::mergePolyMesh, 1);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -142,9 +139,9 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Point zones
wordList curPointZoneNames = pointZones().names();
if (curPointZoneNames.size() > 0)
if (curPointZoneNames.size())
{
pointZoneNames_.setSize(2*curPointZoneNames.size());
pointZoneNames_.setCapacity(2*curPointZoneNames.size());
}
forAll (curPointZoneNames, zoneI)
@ -155,9 +152,9 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Face zones
wordList curFaceZoneNames = faceZones().names();
if (curFaceZoneNames.size() > 0)
if (curFaceZoneNames.size())
{
faceZoneNames_.setSize(2*curFaceZoneNames.size());
faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
}
forAll (curFaceZoneNames, zoneI)
{
@ -167,9 +164,9 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Cell zones
wordList curCellZoneNames = cellZones().names();
if (curCellZoneNames.size() > 0)
if (curCellZoneNames.size())
{
cellZoneNames_.setSize(2*curCellZoneNames.size());
cellZoneNames_.setCapacity(2*curCellZoneNames.size());
}
forAll (curCellZoneNames, zoneI)
{
@ -333,11 +330,11 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
newOwn = own[faceI];
if (newOwn > -1) newOwn = renumberCells[newOwn];
if (newPatch > -1)
if (newPatch > -1)
{
newNei = -1;
}
else
}
else
{
newNei = nei[faceI];
newNei = renumberCells[newNei];
@ -373,7 +370,7 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
)
);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,7 +26,7 @@ Application
mergeOrSplitBaffles
Description
Detect faces that share points (baffles). Either merge them or
Detects faces that share points (baffles). Either merge them or
duplicate the points.
Notes:
@ -154,17 +154,86 @@ void insertDuplicateMerge
}
labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces)
{
// Get all duplicate face labels (in boundaryFaces indices!).
labelList duplicates = localPointRegion::findDuplicateFaces
(
mesh,
boundaryFaces
);
// Check that none are on processor patches
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAll(duplicates, bFaceI)
{
if (duplicates[bFaceI] != -1)
{
label faceI = mesh.nInternalFaces() + bFaceI;
label patchI = patches.whichPatch(faceI);
if (isA<processorPolyPatch>(patches[patchI]))
{
FatalErrorIn("findBaffles(const polyMesh&, const labelList&)")
<< "Duplicate face " << faceI
<< " is on a processorPolyPatch."
<< "This is not allowed." << nl
<< "Face:" << faceI
<< " is on patch:" << patches[patchI].name()
<< abort(FatalError);
}
}
}
// Write to faceSet for ease of postprocessing.
{
faceSet duplicateSet
(
mesh,
"duplicateFaces",
(mesh.nFaces() - mesh.nInternalFaces())/256
);
forAll(duplicates, bFaceI)
{
label otherFaceI = duplicates[bFaceI];
if (otherFaceI != -1 && otherFaceI > bFaceI)
{
duplicateSet.insert(mesh.nInternalFaces() + bFaceI);
duplicateSet.insert(mesh.nInternalFaces() + otherFaceI);
}
}
Pout<< "Writing " << duplicateSet.size()
<< " duplicate faces to faceSet " << duplicateSet.objectPath()
<< nl << endl;
duplicateSet.write();
}
return duplicates;
}
int main(int argc, char *argv[])
{
argList::validOptions.insert("split", "");
argList::validOptions.insert("overwrite", "");
argList::validOptions.insert("detectOnly", "");
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createMesh.H"
const word oldInstance = mesh.pointsInstance();
bool split = args.options().found("split");
bool overwrite = args.options().found("overwrite");
bool split = args.optionFound("split");
bool overwrite = args.optionFound("overwrite");
bool detectOnly = args.optionFound("detectOnly");
// Collect all boundary faces
labelList boundaryFaces(mesh.nFaces() - mesh.nInternalFaces());
@ -175,6 +244,15 @@ int main(int argc, char *argv[])
}
if (detectOnly)
{
findBaffles(mesh, boundaryFaces);
return 0;
}
// Read objects in time directory
IOobjectList objects(mesh, runTime.timeName());
@ -238,62 +316,7 @@ int main(int argc, char *argv[])
<< nl << endl;
// Get all duplicate face labels (in boundaryFaces indices!).
labelList duplicates = localPointRegion::findDuplicateFaces
(
mesh,
boundaryFaces
);
// Check that none are on processor patches
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAll(duplicates, bFaceI)
{
if (duplicates[bFaceI] != -1)
{
label faceI = mesh.nInternalFaces() + bFaceI;
label patchI = patches.whichPatch(faceI);
if (isA<processorPolyPatch>(patches[patchI]))
{
FatalErrorIn(args.executable())
<< "Duplicate face " << faceI
<< " is on a processorPolyPatch."
<< "This is not allowed." << nl
<< "Face:" << faceI
<< " is on patch:" << patches[patchI].name()
<< abort(FatalError);
}
}
}
// Write to faceSet for ease of postprocessing.
{
faceSet duplicateSet
(
mesh,
"duplicateFaces",
(mesh.nFaces() - mesh.nInternalFaces())/256
);
forAll(duplicates, bFaceI)
{
label otherFaceI = duplicates[bFaceI];
if (otherFaceI != -1 && otherFaceI > bFaceI)
{
duplicateSet.insert(mesh.nInternalFaces() + bFaceI);
duplicateSet.insert(mesh.nInternalFaces() + otherFaceI);
}
}
Pout<< "Writing " << duplicateSet.size()
<< " duplicate faces to faceSet " << duplicateSet.objectPath()
<< nl << endl;
duplicateSet.write();
}
labelList duplicates(findBaffles(mesh, boundaryFaces));
// Merge into internal faces.
insertDuplicateMerge(mesh, duplicates, meshMod);
@ -316,7 +339,10 @@ int main(int argc, char *argv[])
mesh.movePoints(map().preMotionPoints());
}
if (overwrite)
{
mesh.setInstance(oldInstance);
}
Pout<< "Writing mesh to time " << runTime.timeName() << endl;
mesh.write();
@ -351,7 +377,7 @@ int main(int argc, char *argv[])
Info<< "End\n" << endl;
return(0);
return 0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -374,9 +374,9 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
mirrorMeshPtr_ = new fvMesh
(
io,
newPoints,
newFaces,
newCells
xferMove(newPoints),
xferMove(newFaces),
xferMove(newCells)
);
fvMesh& pMesh = *mirrorMeshPtr_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,6 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Mirrors a mesh around a given plane.
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -46,7 +46,7 @@ int main(int argc, char *argv[])
# include "createTime.H"
# include "createDynamicFvMesh.H"
for (runTime++; !runTime.end(); runTime++)
while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,7 +47,7 @@ int main(int argc, char *argv[])
Info<< "\nStarting time loop\n" << endl;
for (runTime++; !runTime.end(); runTime++)
while (runTime.loop())
{
Info<< "Time = " << runTime.theta() << " CA-deg\n" << endl;
@ -62,7 +62,7 @@ int main(int argc, char *argv[])
Info<< "\n end\n";
return(0);
return 0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -46,7 +46,7 @@ int main(int argc, char *argv[])
autoPtr<Foam::motionSolver> motionPtr = motionSolver::New(mesh);
for (runTime++; !runTime.end(); runTime++)
while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,7 +48,7 @@ string getLine(std::ifstream& is)
{
std::getline(is, line);
}
while((line.size() > 0) && (line[0] == '#'));
while (line.size() && line[0] == '#');
return line;
}
@ -60,13 +60,13 @@ labelList parseVertices(const string& line)
DynamicList<label> verts;
// Assume 'l' is followed by space.
label endNum = 1;
string::size_type endNum = 1;
do
{
label startNum = line.find_first_not_of(' ', endNum);
string::size_type startNum = line.find_first_not_of(' ', endNum);
if (startNum == label(string::npos))
if (startNum == string::npos)
{
break;
}
@ -74,7 +74,7 @@ labelList parseVertices(const string& line)
endNum = line.find(' ', startNum);
string vertexSpec;
if (endNum != label(string::npos))
if (endNum != string::npos)
{
vertexSpec = line.substr(startNum, endNum-startNum);
}
@ -83,10 +83,10 @@ labelList parseVertices(const string& line)
vertexSpec = line.substr(startNum, line.size() - startNum);
}
label slashPos = vertexSpec.find('/');
string::size_type slashPos = vertexSpec.find('/');
label vertI = 0;
if (slashPos != label(string::npos))
if (slashPos != string::npos)
{
IStringStream intStream(vertexSpec.substr(0, slashPos));

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,19 +74,7 @@ int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
Info<< "Reading mesh for time = " << runTime.value() << endl;
Info<< "Create mesh\n" << endl;
polyMesh mesh
(
IOobject
(
polyMesh::defaultRegion,
runTime.timeName(),
runTime
)
);
# include "createPolyMesh.H"
Info<< "Reading pointSetDict\n" << endl;

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -51,6 +51,18 @@ topoSetSources
value (12 13 56); // labels of points
}
// All points in pointzone
zoneToPoint
{
name ".*Zone"; // name of pointZone, regular expressions allowed
}
// Points nearest to coordinates
nearestToPoint
{
points ((0 0 0) (1 1 1));
}
// Points with coordinate within box
boxToPoint
{
@ -60,12 +72,12 @@ topoSetSources
// Select based on surface
surfaceToPoint
{
file "www.avl.com-geometry.stl";
nearDistance 0.1; // points near to surface
includeInside false; // points on inside of surface
// (requires closed surface with consistent
// normals)
includeOutside false; // ,, outside ,,
file "www.avl.com-geometry.stl";
nearDistance 0.1; // points near to surface
includeInside false; // points on inside of surface
// (requires closed surface with consistent
// normals)
includeOutside false; // ,, outside ,,
}
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,9 +23,10 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Utility to refine cells in multiple directions. Either supply -all
option to refine all cells (3D refinement for 3D cases; 2D for 2D cases)
or reads a refineMeshDict with
Utility to refine cells in multiple directions.
Either supply -all option to refine all cells (3D refinement for 3D
cases; 2D for 2D cases) or reads a refineMeshDict with
- cellSet to refine
- directions to refine
@ -300,6 +301,7 @@ int main(int argc, char *argv[])
# include "createTime.H"
runTime.functionObjects().off();
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
printEdgeStats(mesh);
@ -308,8 +310,8 @@ int main(int argc, char *argv[])
// Read/construct control dictionary
//
bool readDict = args.options().found("dict");
bool overwrite = args.options().found("overwrite");
bool readDict = args.optionFound("dict");
bool overwrite = args.optionFound("overwrite");
// List of cells to refine
labelList refCells;
@ -427,6 +429,10 @@ int main(int argc, char *argv[])
// Write resulting mesh
if (overwrite)
{
mesh.setInstance(oldInstance);
}
mesh.write();
@ -485,7 +491,7 @@ int main(int argc, char *argv[])
{
const labelList& added = oldToNew[oldCellI];
if (added.size() > 0)
if (added.size())
{
forAll(added, i)
{

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -2,7 +2,7 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/decompositionAgglomeration/decompositionMethods/lnInclude
-I$(LIB_SRC)/decompositionMethods/decompositionMethods/lnInclude
EXE_LIBS = \
-lmeshTools \

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anispulation |
-------------------------------------------------------------------------------
License
@ -306,23 +306,37 @@ autoPtr<mapPolyMesh> reorderMesh
labelList patchStarts(patches.size());
labelList oldPatchNMeshPoints(patches.size());
labelListList patchPointMap(patches.size());
labelListList subPatches(patches.size());
labelListList subPatchStarts(patches.size());
forAll(patches, patchI)
{
patchSizes[patchI] = patches[patchI].size();
patchStarts[patchI] = patches[patchI].start();
oldPatchNMeshPoints[patchI] = patches[patchI].nPoints();
patchPointMap[patchI] = identity(patches[patchI].nPoints());
if (isA<processorPolyPatch>(patches[patchI]))
{
const processorPolyPatch& ppp = refCast<const processorPolyPatch>
(
patches[patchI]
);
subPatches[patchI] = ppp.patchIDs();
subPatchStarts[patchI] = ppp.starts();
}
}
mesh.resetPrimitives
(
mesh.nFaces(),
mesh.points(),
newFaces,
newOwner,
newNeighbour,
Xfer<pointField>::null(),
xferMove(newFaces),
xferMove(newOwner),
xferMove(newNeighbour),
patchSizes,
patchStarts
patchStarts,
subPatches,
subPatchStarts
);
return autoPtr<mapPolyMesh>
@ -384,12 +398,10 @@ int main(int argc, char *argv[])
runTime.setTime(Times[startTime], startTime);
# include "createMesh.H"
const word oldInstance = mesh.pointsInstance();
const bool blockOrder = args.options().found("blockOrder");
const bool blockOrder = args.optionFound("blockOrder");
if (blockOrder)
{
Info<< "Ordering cells into regions (using decomposition);"
@ -397,15 +409,14 @@ int main(int argc, char *argv[])
<< endl;
}
const bool orderPoints = args.options().found("orderPoints");
const bool orderPoints = args.optionFound("orderPoints");
if (orderPoints)
{
Info<< "Ordering points into internal and boundary points." << nl
<< endl;
}
const bool writeMaps = args.options().found("writeMaps");
const bool writeMaps = args.optionFound("writeMaps");
if (writeMaps)
{
@ -413,7 +424,7 @@ int main(int argc, char *argv[])
<< endl;
}
bool overwrite = args.options().found("overwrite");
bool overwrite = args.optionFound("overwrite");
label band = getBand(mesh.faceOwner(), mesh.faceNeighbour());
@ -632,6 +643,11 @@ int main(int argc, char *argv[])
<< endl;
}
if (overwrite)
{
mesh.setInstance(oldInstance);
}
Info<< "Writing mesh to " << runTime.timeName() << endl;
mesh.write();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anispulation |
-------------------------------------------------------------------------------
License
@ -31,6 +31,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "fvMesh.H"
#include "volFields.H"
@ -66,7 +67,8 @@ void RotateFields
int main(int argc, char *argv[])
{
# include "addTimeOptions.H"
timeSelector::addOptions();
argList::validArgs.append("n1");
argList::validArgs.append("n2");
@ -105,19 +107,15 @@ int main(int argc, char *argv[])
points.write();
}
// Get times list
instantList Times = runTime.times();
// set startTime and endTime depending on -time and -latestTime options
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
for (label i=startTime; i<endTime; i++)
forAll(timeDirs, timeI)
{
runTime.setTime(Times[i], i);
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;

View File

@ -2,8 +2,9 @@
cd ${0%/*} || exit 1 # run from this directory
READLINE=0
if [ -f /usr/include/readline/readline.h ]; then
echo "Found readline/readline.h include file. Enabling readline support."
if [ -f /usr/include/readline/readline.h ]
then
echo "Found readline/readline.h -- enabling readline support."
READLINE=1
export READLINELINK="-lreadline -lncurses"
break

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,12 +31,11 @@ Description
#include "Time.H"
#include "polyMesh.H"
#include "globalMeshData.H"
#include "topoSetSource.H"
#include "topoSet.H"
#include "IStringStream.H"
#include "topoSet.H"
#include "cellSet.H"
#include "faceSet.H"
#include "pointSet.H"
#include "topoSetSource.H"
#include "OFstream.H"
#include "IFstream.H"
#include "demandDrivenData.H"
@ -48,8 +47,8 @@ Description
#if READLINE != 0
#include <readline/readline.h>
#include <readline/history.h>
# include <readline/readline.h>
# include <readline/history.h>
#endif
using namespace Foam;
@ -89,7 +88,7 @@ void backup
const word& toName
)
{
if (fromSet.size() > 0)
if (fromSet.size())
{
Pout<< " Backing up " << fromName << " into " << toName << endl;
@ -284,7 +283,7 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
polyMesh::meshSubDir/"sets"
);
IOobjectList cellSets(objects.lookupClass(cellSet::typeName));
if (cellSets.size() > 0)
if (cellSets.size())
{
os << "cellSets:" << endl;
forAllConstIter(IOobjectList, cellSets, iter)
@ -294,7 +293,7 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
}
}
IOobjectList faceSets(objects.lookupClass(faceSet::typeName));
if (faceSets.size() > 0)
if (faceSets.size())
{
os << "faceSets:" << endl;
forAllConstIter(IOobjectList, faceSets, iter)
@ -304,7 +303,7 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
}
}
IOobjectList pointSets(objects.lookupClass(pointSet::typeName));
if (pointSets.size() > 0)
if (pointSets.size())
{
os << "pointSets:" << endl;
forAllConstIter(IOobjectList, pointSets, iter)
@ -347,7 +346,7 @@ bool doCommand
bool ok = true;
// Set to work on
autoPtr<topoSet> currentSetPtr(NULL);
autoPtr<topoSet> currentSetPtr;
word sourceType;
@ -367,7 +366,7 @@ bool doCommand
{
r = IOobject::NO_READ;
backup(mesh, setName, setName + "_old");
//backup(mesh, setName, setName + "_old");
currentSetPtr = topoSet::New(setType, mesh, setName, typSize);
}
@ -383,7 +382,7 @@ bool doCommand
currentSet.resize(max(currentSet.size(), typSize));
}
if (!currentSetPtr.valid())
if (currentSetPtr.empty())
{
Pout<< " Cannot construct/load set "
<< topoSet::localPath(mesh, setName) << endl;
@ -399,11 +398,11 @@ bool doCommand
<< " Action:" << actionName
<< endl;
if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
{
// currentSet has been read so can make copy.
backup(mesh, setName, currentSet, setName + "_old");
}
//if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
//{
// // currentSet has been read so can make copy.
// backup(mesh, setName, currentSet, setName + "_old");
//}
switch (action)
{
@ -522,7 +521,7 @@ bool doCommand
Pout<< fIOErr.message().c_str() << endl;
if (sourceType.size() != 0)
if (sourceType.size())
{
Pout<< topoSetSource::usage(sourceType).c_str();
}
@ -533,7 +532,7 @@ bool doCommand
Pout<< fErr.message().c_str() << endl;
if (sourceType.size() != 0)
if (sourceType.size())
{
Pout<< topoSetSource::usage(sourceType).c_str();
}
@ -558,7 +557,8 @@ void printMesh(const Time& runTime, const polyMesh& mesh)
<< " cells:" << mesh.nCells()
<< " faces:" << mesh.nFaces()
<< " points:" << mesh.nPoints()
<< " patches:" << mesh.boundaryMesh().size() << nl;
<< " patches:" << mesh.boundaryMesh().size()
<< " bb:" << mesh.bounds() << nl;
}
@ -571,7 +571,7 @@ commandStatus parseType
IStringStream& is
)
{
if (setType.size() == 0)
if (setType.empty())
{
Pout<< "Type 'help' for usage information" << endl;
@ -591,24 +591,10 @@ commandStatus parseType
}
else if (setType == "time")
{
scalar time = readScalar(is);
scalar requestedTime = readScalar(is);
instantList Times = runTime.times();
int nearestIndex = -1;
scalar nearestDiff = Foam::GREAT;
forAll(Times, timeIndex)
{
if (Times[timeIndex].name() == "constant") continue;
scalar diff = fabs(Times[timeIndex].value() - time);
if (diff < nearestDiff)
{
nearestDiff = diff;
nearestIndex = timeIndex;
}
}
label nearestIndex = Time::findClosestTimeIndex(Times, requestedTime);
Pout<< "Changing time from " << runTime.timeName()
<< " to " << Times[nearestIndex].name()
@ -646,7 +632,8 @@ commandStatus parseType
}
default:
{
FatalErrorIn("parseType") << "Illegal mesh update state "
FatalErrorIn("parseType")
<< "Illegal mesh update state "
<< stat << abort(FatalError);
break;
}
@ -689,7 +676,7 @@ commandStatus parseAction(const word& actionName)
{
commandStatus stat = INVALID;
if (actionName.size() != 0)
if (actionName.size())
{
try
{
@ -714,14 +701,16 @@ commandStatus parseAction(const word& actionName)
int main(int argc, char *argv[])
{
# include "addRegionOption.H"
# include "addTimeOptions.H"
argList::validOptions.insert("noVTK", "");
argList::validOptions.insert("batch", "file");
# include "addTimeOptions.H"
# include "setRootCase.H"
# include "createTime.H"
bool writeVTK = !args.options().found("noVTK");
bool writeVTK = !args.optionFound("noVTK");
// Get times list
instantList Times = runTime.times();
@ -730,7 +719,7 @@ int main(int argc, char *argv[])
runTime.setTime(Times[startTime], startTime);
# include "createPolyMesh.H"
# include "createNamedPolyMesh.H"
// Print some mesh info
printMesh(runTime, mesh);
@ -738,13 +727,14 @@ int main(int argc, char *argv[])
std::ifstream* fileStreamPtr(NULL);
if (args.options().found("batch"))
if (args.optionFound("batch"))
{
fileName batchFile(args.options()["batch"]);
fileName batchFile(args.option("batch"));
Pout<< "Reading commands from file " << batchFile << endl;
if (!exists(batchFile))
// we cannot handle .gz files
if (!isFile(batchFile, false))
{
FatalErrorIn(args.executable())
<< "Cannot open file " << batchFile << exit(FatalError);
@ -790,7 +780,7 @@ int main(int argc, char *argv[])
std::getline(*fileStreamPtr, rawLine);
if (rawLine.size() > 0)
if (rawLine.size())
{
Pout<< "Doing:" << rawLine << endl;
}
@ -819,7 +809,7 @@ int main(int argc, char *argv[])
# endif
}
if (rawLine.size() == 0 || rawLine[0] == '#')
if (rawLine.empty() || rawLine[0] == '#')
{
continue;
}
@ -861,7 +851,7 @@ int main(int argc, char *argv[])
delete fileStreamPtr;
}
Pout << nl << "End" << endl;
Pout<< "\nEnd" << endl;
return 0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,7 +28,7 @@ Description
#include "writeFuns.H"
#ifdef __mips
#if defined(__mips) && !defined(__SICORTEX__)
#include <standards.h>
#include <sys/endian.h>
#endif

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -70,7 +70,7 @@ void writePointSet
labelList pointLabels(set.toc());
pointField setPoints(IndirectList<point>(mesh.points(), pointLabels)());
pointField setPoints(mesh.points(), pointLabels);
// Write points

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,8 +28,8 @@ Description
There is one catch: for faceZones you also need to specify a flip
condition which basically denotes the side of the face. In this app
it reads a cellSet (xxxCells if 'xxx' is the name of the faceSet) and
any face whose neighbour is in the cellSet gets a flip=true.
it reads a cellSet (xxxCells if 'xxx' is the name of the faceSet) which
is the masterCells of the zone.
There are lots of situations in which this will go wrong but it is the
best I can think of for now.
@ -48,6 +48,7 @@ Description
#include "OFstream.H"
#include "IFstream.H"
#include "IOobjectList.H"
#include "SortableList.H"
using namespace Foam;
@ -63,8 +64,7 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
# include "createTime.H"
bool noFlipMap = args.options().found("noFlipMap");
bool noFlipMap = args.optionFound("noFlipMap");
// Get times list
instantList Times = runTime.times();
@ -72,9 +72,8 @@ int main(int argc, char *argv[])
label startTime = Times.size()-1;
label endTime = Times.size();
// check -time and -latestTime options
# include "checkTimeOption.H"
# include "checkLatestTimeOption.H"
runTime.setTime(Times[startTime], startTime);
@ -88,7 +87,7 @@ int main(int argc, char *argv[])
polyMesh::meshSubDir/"sets"
);
Pout<< "Searched : " << mesh.pointsInstance()/polyMesh::meshSubDir/"sets"
Info<< "Searched : " << mesh.pointsInstance()/polyMesh::meshSubDir/"sets"
<< nl
<< "Found : " << objects.names() << nl
<< endl;
@ -96,7 +95,7 @@ int main(int argc, char *argv[])
IOobjectList pointObjects(objects.lookupClass(pointSet::typeName));
Pout<< "pointSets:" << pointObjects.names() << endl;
//Pout<< "pointSets:" << pointObjects.names() << endl;
for
(
@ -107,6 +106,7 @@ int main(int argc, char *argv[])
{
// Not in memory. Load it.
pointSet set(*iter());
SortableList<label> pointLabels(set.toc());
label zoneID = mesh.pointZones().findZoneID(set.name());
if (zoneID == -1)
@ -120,69 +120,31 @@ int main(int argc, char *argv[])
new pointZone
(
set.name(), //name
set.toc(), //addressing
pointLabels, //addressing
sz, //index
mesh.pointZones() //pointZoneMesh
)
);
mesh.pointZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.pointZones().instance() = mesh.facesInstance();
}
else
{
Info<< "Overwriting contents of existing pointZone " << zoneID
<< " with that of set " << set.name() << "." << endl;
mesh.pointZones()[zoneID] = set.toc();
mesh.pointZones()[zoneID] = pointLabels;
mesh.pointZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.pointZones().instance() = mesh.facesInstance();
}
}
IOobjectList cellObjects(objects.lookupClass(cellSet::typeName));
Pout<< "cellSets:" << cellObjects.names() << endl;
for
(
IOobjectList::const_iterator iter = cellObjects.begin();
iter != cellObjects.end();
++iter
)
{
// Not in memory. Load it.
cellSet set(*iter());
label zoneID = mesh.cellZones().findZoneID(set.name());
if (zoneID == -1)
{
Info<< "Adding set " << set.name() << " as a cellZone." << endl;
label sz = mesh.cellZones().size();
mesh.cellZones().setSize(sz+1);
mesh.cellZones().set
(
sz,
new cellZone
(
set.name(), //name
set.toc(), //addressing
sz, //index
mesh.cellZones() //pointZoneMesh
)
);
mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
}
else
{
Info<< "Overwriting contents of existing cellZone " << zoneID
<< " with that of set " << set.name() << "." << endl;
mesh.cellZones()[zoneID] = set.toc();
mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
}
}
IOobjectList faceObjects(objects.lookupClass(faceSet::typeName));
Pout<< "faceSets:" << faceObjects.names() << endl;
HashSet<word> slaveCellSets;
//Pout<< "faceSets:" << faceObjects.names() << endl;
for
(
@ -193,20 +155,18 @@ int main(int argc, char *argv[])
{
// Not in memory. Load it.
faceSet set(*iter());
SortableList<label> faceLabels(set.toc());
DynamicList<label> addressing(set.size());
DynamicList<bool> flipMap(set.size());
if (!noFlipMap)
{
word setName(set.name() + "Cells");
word setName(set.name() + "SlaveCells");
Pout<< "Trying to load cellSet " << setName
<< " to find out the flipMap." << nl
<< "If the neighbour side of the face is in the cellSet"
<< " the flipMap becomes true," << nl
<< "in all other cases it stays false."
<< " If you do not care about the flipMap"
Info<< "Trying to load cellSet " << setName
<< " to find out the slave side of the zone." << nl
<< "If you do not care about the flipMap"
<< " (i.e. do not use the sideness)" << nl
<< "use the -noFlipMap command line option."
<< endl;
@ -214,9 +174,12 @@ int main(int argc, char *argv[])
// Load corresponding cells
cellSet cells(mesh, setName);
forAllConstIter(faceSet, set, iter)
// Store setName to exclude from cellZones further on
slaveCellSets.insert(setName);
forAll(faceLabels, i)
{
label faceI = iter.key();
label faceI = faceLabels[i];
bool flip = false;
@ -273,9 +236,10 @@ int main(int argc, char *argv[])
else
{
// No flip map.
forAllConstIter(faceSet, set, iter)
forAll(faceLabels, i)
{
addressing.append(iter.key());
label faceI = faceLabels[i];
addressing.append(faceI);
flipMap.append(false);
}
}
@ -299,6 +263,7 @@ int main(int argc, char *argv[])
)
);
mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.faceZones().instance() = mesh.facesInstance();
}
else
{
@ -310,10 +275,63 @@ int main(int argc, char *argv[])
flipMap.shrink()
);
mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.faceZones().instance() = mesh.facesInstance();
}
}
Pout<< "Writing mesh." << endl;
IOobjectList cellObjects(objects.lookupClass(cellSet::typeName));
//Pout<< "cellSets:" << cellObjects.names() << endl;
for
(
IOobjectList::const_iterator iter = cellObjects.begin();
iter != cellObjects.end();
++iter
)
{
if (!slaveCellSets.found(iter.key()))
{
// Not in memory. Load it.
cellSet set(*iter());
SortableList<label> cellLabels(set.toc());
label zoneID = mesh.cellZones().findZoneID(set.name());
if (zoneID == -1)
{
Info<< "Adding set " << set.name() << " as a cellZone." << endl;
label sz = mesh.cellZones().size();
mesh.cellZones().setSize(sz+1);
mesh.cellZones().set
(
sz,
new cellZone
(
set.name(), //name
cellLabels, //addressing
sz, //index
mesh.cellZones() //pointZoneMesh
)
);
mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.cellZones().instance() = mesh.facesInstance();
}
else
{
Info<< "Overwriting contents of existing cellZone " << zoneID
<< " with that of set " << set.name() << "." << endl;
mesh.cellZones()[zoneID] = cellLabels;
mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.cellZones().instance() = mesh.facesInstance();
}
}
}
Info<< "Writing mesh." << endl;
if (!mesh.write())
{
@ -322,7 +340,7 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
Pout << nl << "End" << endl;
Info<< nl << "End" << endl;
return 0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,14 +22,11 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "regionSide.H"
#include "meshTools.H"
#include "primitiveMesh.H"
#include "IndirectList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -113,7 +110,7 @@ Foam::label Foam::regionSide::otherEdge
) << "Cannot find other edge on face " << faceI << " that uses point "
<< pointI << " but not point " << freePointI << endl
<< "Edges on face:" << fEdges
<< " verts:" << IndirectList<edge>(mesh.edges(), fEdges)()
<< " verts:" << UIndirectList<edge>(mesh.edges(), fEdges)()
<< " Vertices on face:"
<< mesh.faces()[faceI]
<< " Vertices on original edge:" << e << abort(FatalError);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -45,7 +45,7 @@ SourceFiles
#ifndef regionSide_H
#define regionSide_H
#include "labelHashSet.H"
#include "HashSet.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -50,15 +50,12 @@ Description
#include "attachDetach.H"
#include "attachPolyTopoChanger.H"
#include "regionSide.H"
#include "primitiveFacePatch.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Calculation engine for set of faces in a mesh
typedef PrimitivePatch<face, List, const pointField&> facePatch;
// Find edge between points v0 and v1.
label findEdge(const primitiveMesh& mesh, const label v0, const label v1)
{
@ -100,10 +97,10 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
<< exit(FatalError);
}
if (bMesh[patchI].size() != 0)
if (bMesh[patchI].size())
{
FatalErrorIn("checkPatch(const polyBoundaryMesh&, const word&)")
<< "Patch " << name << " is present but not of zero size"
<< "Patch " << name << " is present but non-zero size"
<< exit(FatalError);
}
}
@ -124,11 +121,12 @@ int main(int argc, char *argv[])
# include "createTime.H"
runTime.functionObjects().off();
# include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance();
word setName(args.additionalArgs()[0]);
word masterPatch(args.additionalArgs()[1]);
word slavePatch(args.additionalArgs()[2]);
bool overwrite = args.options().found("overwrite");
bool overwrite = args.optionFound("overwrite");
// List of faces to split
faceSet facesSet(mesh, setName);
@ -162,10 +160,16 @@ int main(int argc, char *argv[])
// set of edges on side of this region. Use PrimitivePatch to find these.
//
IndirectList<face> zoneFaces(mesh.faces(), faces);
// Addressing on faces only in mesh vertices.
facePatch fPatch(zoneFaces(), mesh.points());
primitiveFacePatch fPatch
(
UIndirectList<face>
(
mesh.faces(),
faces
),
mesh.points()
);
const labelList& meshPoints = fPatch.meshPoints();
@ -262,7 +266,12 @@ int main(int argc, char *argv[])
splitter.attach();
Info << nl << "Writing polyMesh" << endl;
if (overwrite)
{
mesh.setInstance(oldInstance);
}
Info<< "Writing mesh to " << runTime.timeName() << endl;
if (!mesh.write())
{
FatalErrorIn(args.executable())

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,19 +23,26 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Splits mesh into multiple regions. Each region is defined as a domain
whose cells can all be reached by cell-face-cell walking without crossing
Splits mesh into multiple regions.
Each region is defined as a domain whose cells can all be reached by
cell-face-cell walking without crossing
- boundary faces
- additional faces from faceset (-blockedFaces faceSet).
- any face inbetween differing cellZones (-cellZones)
Output is:
- mesh with multiple regions
- mesh with multiple regions or
- mesh with cells put into cellZones (-makeCellZones)
Should work in parallel but cellZone interfaces cannot align with
Note:
- Should work in parallel but cellZone interfaces cannot align with
processor boundaries so use the correct option in decomposition to
preserve those interfaces.
- If a cell zone gets split into more than one region it can detect
the largest matching region (-sloppyCellZones). This will accept any
region that covers more than 50% of the zone. It has to be a subset
so cannot have any cells in any other zone.
\*---------------------------------------------------------------------------*/
@ -52,6 +59,7 @@ Description
#include "EdgeMap.H"
#include "syncTools.H"
#include "ReadFields.H"
#include "directMappedWallPolyPatch.H"
using namespace Foam;
@ -488,17 +496,18 @@ labelList getNonRegionCells(const labelList& cellRegion, const label regionI)
}
// Get per region-region interface the sizes.
// If sumParallel does merge.
EdgeMap<label> getInterfaceSizes
// Get per region-region interface the sizes. If sumParallel sums sizes.
// Returns interfaces as straight list for looping in identical order.
void getInterfaceSizes
(
const polyMesh& mesh,
const labelList& cellRegion,
const bool sumParallel
const bool sumParallel,
edgeList& interfaces,
EdgeMap<label>& interfaceSizes
)
{
EdgeMap<label> interfaceSizes;
forAll(mesh.faceNeighbour(), faceI)
{
label ownRegion = cellRegion[mesh.faceOwner()[faceI]];
@ -585,7 +594,12 @@ EdgeMap<label> getInterfaceSizes
}
}
return interfaceSizes;
// Make sure all processors have interfaces in same order
interfaces = interfaceSizes.toc();
if (sumParallel)
{
Pstream::scatter(interfaces);
}
}
@ -607,7 +621,7 @@ autoPtr<mapPolyMesh> createRegionMesh
"fvSchemes",
mesh.time().system(),
regionName,
mesh.db(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
@ -616,7 +630,7 @@ autoPtr<mapPolyMesh> createRegionMesh
Info<< "Testing:" << io.objectPath() << endl;
if (!io.headerOk())
//if (!exists(io.objectPath()))
// if (!exists(io.objectPath()))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;
@ -636,7 +650,7 @@ autoPtr<mapPolyMesh> createRegionMesh
"fvSolution",
mesh.time().system(),
regionName,
mesh.db(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
@ -705,11 +719,7 @@ autoPtr<mapPolyMesh> createRegionMesh
if (otherRegion != -1)
{
edge interface
(
min(regionI, otherRegion),
max(regionI, otherRegion)
);
edge interface(regionI, otherRegion);
// Find the patch.
if (regionI < otherRegion)
@ -756,7 +766,8 @@ void createAndWriteRegion
const regionSplit& cellRegion,
const wordList& regionNames,
const EdgeMap<label>& interfaceToPatch,
const label regionI
const label regionI,
const word& newMeshInstance
)
{
Info<< "Creating mesh for region " << regionI
@ -848,6 +859,7 @@ void createAndWriteRegion
const polyBoundaryMesh& newPatches = newMesh().boundaryMesh();
newPatches.checkParallelSync(true);
// Delete empty patches
// ~~~~~~~~~~~~~~~~~~~~
@ -863,13 +875,12 @@ void createAndWriteRegion
{
const polyPatch& pp = newPatches[patchI];
if
(
!isA<processorPolyPatch>(pp)
&& returnReduce(pp.size(), sumOp<label>()) > 0
)
if (!isA<processorPolyPatch>(pp))
{
oldToNew[patchI] = newI++;
if (returnReduce(pp.size(), sumOp<label>()) > 0)
{
oldToNew[patchI] = newI++;
}
}
}
@ -878,7 +889,7 @@ void createAndWriteRegion
{
const polyPatch& pp = newPatches[patchI];
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
if (isA<processorPolyPatch>(pp) && pp.size())
{
oldToNew[patchI] = newI++;
}
@ -900,6 +911,7 @@ void createAndWriteRegion
Info<< "Writing new mesh" << endl;
newMesh().setInstance(newMeshInstance);
newMesh().write();
// Write addressing files like decomposePar
@ -983,10 +995,15 @@ void createAndWriteRegion
}
// Create for every region-region interface with non-zero size two patches.
// First one is for minimumregion to maximumregion.
// Note that patches get created in same order on all processors (if parallel)
// since looping over synchronised 'interfaces'.
EdgeMap<label> addRegionPatches
(
fvMesh& mesh,
const regionSplit& cellRegion,
const edgeList& interfaces,
const EdgeMap<label>& interfaceSizes,
const wordList& regionNames
)
@ -998,26 +1015,23 @@ EdgeMap<label> addRegionPatches
EdgeMap<label> interfaceToPatch(cellRegion.nRegions());
// Keep start of added patches for later.
label minAddedPatchI = labelMax;
forAllConstIter(EdgeMap<label>, interfaceSizes, iter)
forAll(interfaces, interI)
{
if (iter() > 0)
{
const edge& e = iter.key();
const edge& e = interfaces[interI];
if (interfaceSizes[e] > 0)
{
label patchI = addPatch
(
mesh,
regionNames[e[0]] + "_to_" + regionNames[e[1]],
polyPatch::typeName
directMappedWallPolyPatch::typeName
);
addPatch
(
mesh,
regionNames[e[1]] + "_to_" + regionNames[e[0]],
polyPatch::typeName
directMappedWallPolyPatch::typeName
);
Info<< "For interface between region " << e[0]
@ -1025,90 +1039,188 @@ EdgeMap<label> addRegionPatches
<< " " << mesh.boundaryMesh()[patchI].name()
<< endl;
interfaceToPatch.insert(iter.key(), patchI);
minAddedPatchI = min(minAddedPatchI, patchI);
interfaceToPatch.insert(e, patchI);
}
}
//Info<< "minAddedPatchI:" << minAddedPatchI << endl;
return interfaceToPatch;
}
// Checks if regionI in cellRegion corresponds to existing zone.
label findCorrespondingZone
//// Checks if regionI in cellRegion is subset of existing cellZone. Returns -1
//// if no zone found, zone otherwise
//label findCorrespondingSubZone
//(
// const cellZoneMesh& cellZones,
// const labelList& existingZoneID,
// const labelList& cellRegion,
// const label regionI
//)
//{
// // Zone corresponding to region. No corresponding zone.
// label zoneI = labelMax;
//
// labelList regionCells = findIndices(cellRegion, regionI);
//
// if (regionCells.empty())
// {
// // My local portion is empty. Maps to any empty cellZone. Mark with
// // special value which can get overwritten by other processors.
// zoneI = -1;
// }
// else
// {
// // Get zone for first element.
// zoneI = existingZoneID[regionCells[0]];
//
// if (zoneI == -1)
// {
// zoneI = labelMax;
// }
// else
// {
// // 1. All regionCells in zoneI?
// forAll(regionCells, i)
// {
// if (existingZoneID[regionCells[i]] != zoneI)
// {
// zoneI = labelMax;
// break;
// }
// }
// }
// }
//
// // Determine same zone over all processors.
// reduce(zoneI, maxOp<label>());
//
// if (zoneI == labelMax)
// {
// // Cells in region that are not in zoneI
// zoneI = -1;
// }
//
// return zoneI;
//}
// Find region that covers most of cell zone
label findCorrespondingRegion
(
const cellZoneMesh& cellZones,
const labelList& existingZoneID,
const labelList& cellRegion,
const label regionI
const labelList& existingZoneID, // per cell the (unique) zoneID
const regionSplit& cellRegion,
const label zoneI,
const label minOverlapSize
)
{
// Zone corresponding to region. No corresponding zone.
label zoneI = labelMax;
// Per region the number of cells in zoneI
labelList cellsInZone(cellRegion.nRegions(), 0);
labelList regionCells = findIndices(cellRegion, regionI);
if (regionCells.size() == 0)
forAll(cellRegion, cellI)
{
// My local portion is empty. Maps to any empty cellZone. Mark with
// special value which can get overwritten by other processors.
zoneI = -1;
if (existingZoneID[cellI] == zoneI)
{
cellsInZone[cellRegion[cellI]]++;
}
}
Pstream::listCombineGather(cellsInZone, plusEqOp<label>());
Pstream::listCombineScatter(cellsInZone);
// Pick region with largest overlap of zoneI
label regionI = findMax(cellsInZone);
if (cellsInZone[regionI] < minOverlapSize)
{
// Region covers too little of zone. Not good enough.
regionI = -1;
}
else
{
// Get zone for first element.
zoneI = existingZoneID[regionCells[0]];
if (zoneI == -1)
// Check that region contains no cells that aren't in cellZone.
forAll(cellRegion, cellI)
{
zoneI = labelMax;
}
else
{
// 1. All regionCells in zoneI?
forAll(regionCells, i)
if (cellRegion[cellI] == regionI && existingZoneID[cellI] != zoneI)
{
if (existingZoneID[regionCells[i]] != zoneI)
{
zoneI = labelMax;
break;
}
}
}
}
// Determine same zone over all processors.
reduce(zoneI, maxOp<label>());
// 2. All of cellZone present?
if (zoneI == labelMax)
{
zoneI = -1;
}
else if (zoneI != -1)
{
const cellZone& cz = cellZones[zoneI];
forAll(cz, i)
{
if (cellRegion[cz[i]] != regionI)
{
zoneI = -1;
// cellI in regionI but not in zoneI
regionI = -1;
break;
}
}
// If one in error, all should be in error. Note that branch gets taken
// on all procs.
reduce(zoneI, minOp<label>());
reduce(regionI, minOp<label>());
}
return zoneI;
return regionI;
}
//// Checks if cellZone has corresponding cellRegion.
//label findCorrespondingRegion
//(
// const cellZoneMesh& cellZones,
// const labelList& existingZoneID, // per cell the (unique) zoneID
// const regionSplit& cellRegion,
// const label zoneI
//)
//{
// // Region corresponding to zone. Start off with special value: no
// // corresponding region.
// label regionI = labelMax;
//
// const cellZone& cz = cellZones[zoneI];
//
// if (cz.empty())
// {
// // My local portion is empty. Maps to any empty cellZone. Mark with
// // special value which can get overwritten by other processors.
// regionI = -1;
// }
// else
// {
// regionI = cellRegion[cz[0]];
//
// forAll(cz, i)
// {
// if (cellRegion[cz[i]] != regionI)
// {
// regionI = labelMax;
// break;
// }
// }
// }
//
// // Determine same zone over all processors.
// reduce(regionI, maxOp<label>());
//
//
// // 2. All of region present?
//
// if (regionI == labelMax)
// {
// regionI = -1;
// }
// else if (regionI != -1)
// {
// forAll(cellRegion, cellI)
// {
// if (cellRegion[cellI] == regionI && existingZoneID[cellI] != zoneI)
// {
// // cellI in regionI but not in zoneI
// regionI = -1;
// break;
// }
// }
// // If one in error, all should be in error. Note that branch gets taken
// // on all procs.
// reduce(regionI, minOp<label>());
// }
//
// return regionI;
//}
// Main program:
int main(int argc, char *argv[])
@ -1119,24 +1231,30 @@ int main(int argc, char *argv[])
argList::validOptions.insert("largestOnly", "");
argList::validOptions.insert("insidePoint", "point");
argList::validOptions.insert("overwrite", "");
argList::validOptions.insert("detectOnly", "");
argList::validOptions.insert("sloppyCellZones", "");
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createMesh.H"
const word oldInstance = mesh.pointsInstance();
word blockedFacesName;
if (args.options().found("blockedFaces"))
if (args.optionFound("blockedFaces"))
{
blockedFacesName = args.options()["blockedFaces"];
blockedFacesName = args.option("blockedFaces");
Info<< "Reading blocked internal faces from faceSet "
<< blockedFacesName << nl << endl;
}
bool largestOnly = args.options().found("largestOnly");
bool insidePoint = args.options().found("insidePoint");
bool useCellZones = args.options().found("cellZones");
bool overwrite = args.options().found("overwrite");
bool makeCellZones = args.optionFound("makeCellZones");
bool largestOnly = args.optionFound("largestOnly");
bool insidePoint = args.optionFound("insidePoint");
bool useCellZones = args.optionFound("cellZones");
bool overwrite = args.optionFound("overwrite");
bool detectOnly = args.optionFound("detectOnly");
bool sloppyCellZones = args.optionFound("sloppyCellZones");
if (insidePoint && largestOnly)
{
@ -1200,7 +1318,7 @@ int main(int argc, char *argv[])
boolList blockedFace;
// Read from faceSet
if (blockedFacesName.size() > 0)
if (blockedFacesName.size())
{
faceSet blockedFaceSet(mesh, blockedFacesName);
Info<< "Read " << returnReduce(blockedFaceSet.size(), sumOp<label>())
@ -1280,6 +1398,31 @@ int main(int argc, char *argv[])
Info<< "Writing region per cell file (for manual decomposition) to "
<< cellToRegion.objectPath() << nl << endl;
}
// Write for postprocessing
{
volScalarField cellToRegion
(
IOobject
(
"cellToRegion",
mesh.facesInstance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh,
dimensionedScalar("zero", dimless, 0)
);
forAll(cellRegion, cellI)
{
cellToRegion[cellI] = cellRegion[cellI];
}
cellToRegion.write();
Info<< "Writing region per cell as volScalarField to "
<< cellToRegion.objectPath() << nl << endl;
}
// Sizes per region
@ -1306,40 +1449,131 @@ int main(int argc, char *argv[])
Info<< endl;
// Sizes per cellzone
// ~~~~~~~~~~~~~~~~~~
labelList zoneSizes(cellZones.size(), 0);
if (useCellZones || makeCellZones || sloppyCellZones)
{
List<wordList> zoneNames(Pstream::nProcs());
zoneNames[Pstream::myProcNo()] = cellZones.names();
Pstream::gatherList(zoneNames);
Pstream::scatterList(zoneNames);
forAll(zoneNames, procI)
{
if (zoneNames[procI] != zoneNames[0])
{
FatalErrorIn(args.executable())
<< "cellZones not synchronised across processors." << endl
<< "Master has cellZones " << zoneNames[0] << endl
<< "Processor " << procI
<< " has cellZones " << zoneNames[procI]
<< exit(FatalError);
}
}
forAll(cellZones, zoneI)
{
zoneSizes[zoneI] = returnReduce
(
cellZones[zoneI].size(),
sumOp<label>()
);
}
}
// Whether region corresponds to a cellzone
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Info<< "Region\tZone\tName" << nl
<< "------\t----\t----" << endl;
// Region per zone
labelList regionToZone(cellRegion.nRegions());
labelList regionToZone(cellRegion.nRegions(), -1);
// Name of region
wordList regionNames(cellRegion.nRegions());
// Zone to region
labelList zoneToRegion(cellZones.size(), -1);
if (sloppyCellZones)
{
Info<< "Trying to match regions to existing cell zones;"
<< " region can be subset of cell zone." << nl << endl;
forAll(cellZones, zoneI)
{
label regionI = findCorrespondingRegion
(
zoneID,
cellRegion,
zoneI,
label(0.5*zoneSizes[zoneI]) // minimum overlap
);
if (regionI != -1)
{
Info<< "Sloppily matched region " << regionI
<< " size " << regionSizes[regionI]
<< " to zone " << zoneI << " size " << zoneSizes[zoneI]
<< endl;
zoneToRegion[zoneI] = regionI;
regionToZone[regionI] = zoneI;
regionNames[regionI] = cellZones[zoneI].name();
}
}
}
else
{
Info<< "Trying to match regions to existing cell zones." << nl << endl;
forAll(cellZones, zoneI)
{
label regionI = findCorrespondingRegion
(
zoneID,
cellRegion,
zoneI,
1 // minimum overlap
);
if (regionI != -1)
{
zoneToRegion[zoneI] = regionI;
regionToZone[regionI] = zoneI;
regionNames[regionI] = cellZones[zoneI].name();
}
}
}
// Allocate region names for unmatched regions.
forAll(regionToZone, regionI)
{
regionToZone[regionI] = findCorrespondingZone
(
cellZones,
zoneID,
cellRegion,
regionI
);
if (regionToZone[regionI] != -1)
{
regionNames[regionI] = cellZones[regionToZone[regionI]].name();
}
else
if (regionToZone[regionI] == -1)
{
regionNames[regionI] = "domain" + Foam::name(regionI);
}
}
// Print region to zone
Info<< "Region\tZone\tName" << nl
<< "------\t----\t----" << endl;
forAll(regionToZone, regionI)
{
Info<< regionI << '\t' << regionToZone[regionI] << '\t'
<< regionNames[regionI] << nl;
}
Info<< endl;
//// Print zone to region
//Info<< "Zone\tName\tRegion" << nl
// << "----\t----\t------" << endl;
//forAll(zoneToRegion, zoneI)
//{
// Info<< zoneI << '\t' << cellZones[zoneI].name() << '\t'
// << zoneToRegion[zoneI] << nl;
//}
//Info<< endl;
// Since we're going to mess with patches make sure all non-processor ones
// are on all processors.
@ -1348,29 +1582,35 @@ int main(int argc, char *argv[])
// Sizes of interface between regions. From pair of regions to number of
// faces.
EdgeMap<label> interfaceSizes
edgeList interfaces;
EdgeMap<label> interfaceSizes;
getInterfaceSizes
(
getInterfaceSizes
(
mesh,
cellRegion,
true // sum in parallel?
)
mesh,
cellRegion,
true, // sum in parallel?
interfaces,
interfaceSizes
);
Info<< "Region\tRegion\tFaces" << nl
Info<< "Sizes inbetween regions:" << nl << nl
<< "Region\tRegion\tFaces" << nl
<< "------\t------\t-----" << endl;
forAllConstIter(EdgeMap<label>, interfaceSizes, iter)
forAll(interfaces, interI)
{
const edge& e = iter.key();
const edge& e = interfaces[interI];
Info<< e[0] << '\t' << e[1] << '\t' << iter() << nl;
Info<< e[0] << '\t' << e[1] << '\t' << interfaceSizes[e] << nl;
}
Info<< endl;
if (detectOnly)
{
return 0;
}
// Read objects in time directory
@ -1420,7 +1660,7 @@ int main(int argc, char *argv[])
{
Info<< "Only one region. Doing nothing." << endl;
}
else if (args.options().found("makeCellZones"))
else if (makeCellZones)
{
Info<< "Putting cells into cellZones instead of splitting mesh."
<< endl;
@ -1476,12 +1716,16 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
mesh.setInstance(runTime.timeName());
}
else
{
mesh.setInstance(oldInstance);
}
Info<< "Writing cellZones as new mesh to time " << runTime.timeName()
<< nl << endl;
mesh.setInstance(runTime.timeName());
mesh.write();
@ -1511,6 +1755,7 @@ int main(int argc, char *argv[])
(
mesh,
cellRegion,
interfaces,
interfaceSizes,
regionNames
)
@ -1528,7 +1773,7 @@ int main(int argc, char *argv[])
if (insidePoint)
{
point insidePoint(IStringStream(args.options()["insidePoint"])());
point insidePoint(args.optionLookup("insidePoint")());
label regionI = -1;
@ -1563,7 +1808,8 @@ int main(int argc, char *argv[])
cellRegion,
regionNames,
interfaceToPatch,
regionI
regionI,
(overwrite ? oldInstance : runTime.timeName())
);
}
else if (largestOnly)
@ -1580,7 +1826,8 @@ int main(int argc, char *argv[])
cellRegion,
regionNames,
interfaceToPatch,
regionI
regionI,
(overwrite ? oldInstance : runTime.timeName())
);
}
else
@ -1598,7 +1845,8 @@ int main(int argc, char *argv[])
cellRegion,
regionNames,
interfaceToPatch,
regionI
regionI,
(overwrite ? oldInstance : runTime.timeName())
);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -60,10 +60,10 @@ Description
#include "polyTopoChanger.H"
#include "mapPolyMesh.H"
#include "ListOps.H"
#include "IndirectList.H"
#include "slidingInterface.H"
#include "perfectInterface.H"
#include "IOobjectList.H"
#include "ReadFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -82,7 +82,7 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
<< exit(FatalError);
}
if (bMesh[patchI].size() == 0)
if (bMesh[patchI].empty())
{
FatalErrorIn("checkPatch(const polyBoundaryMesh&, const word&)")
<< "Patch " << name << " is present but zero size"
@ -91,34 +91,6 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
}
// Read field
template<class GeoField>
void readFields
(
const fvMesh& mesh,
const IOobjectList& objects,
PtrList<GeoField>& fields
)
{
// Search list of objects for volScalarFields
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
// Construct the vol scalar fields
fields.setSize(fieldObjects.size());
label fieldi = 0;
for
(
IOobjectList::iterator iter = fieldObjects.begin();
iter != fieldObjects.end();
++iter
)
{
fields.set(fieldi++, new GeoField(*iter(), mesh));
}
}
// Main program:
int main(int argc, char *argv[])
@ -137,14 +109,15 @@ int main(int argc, char *argv[])
# include "createTime.H"
runTime.functionObjects().off();
# include "createMesh.H"
const word oldInstance = mesh.pointsInstance();
word masterPatchName(args.additionalArgs()[0]);
word slavePatchName(args.additionalArgs()[1]);
bool partialCover = args.options().found("partial");
bool perfectCover = args.options().found("perfect");
bool overwrite = args.options().found("overwrite");
bool partialCover = args.optionFound("partial");
bool perfectCover = args.optionFound("perfect");
bool overwrite = args.optionFound("overwrite");
if (partialCover && perfectCover)
{
@ -343,7 +316,8 @@ int main(int argc, char *argv[])
cutZoneName,
masterPatchName,
slavePatchName,
tom // integral or partial
tom, // integral or partial
true // couple/decouple mode
)
);
}
@ -355,30 +329,30 @@ int main(int argc, char *argv[])
// Read all current fvFields so they will get mapped
Info<< "Reading all current volfields" << endl;
PtrList<volScalarField> volScalarFields;
readFields(mesh, objects, volScalarFields);
ReadFields(mesh, objects, volScalarFields);
PtrList<volVectorField> volVectorFields;
readFields(mesh, objects, volVectorFields);
ReadFields(mesh, objects, volVectorFields);
PtrList<volSphericalTensorField> volSphericalTensorFields;
readFields(mesh, objects, volSphericalTensorFields);
ReadFields(mesh, objects, volSphericalTensorFields);
PtrList<volSymmTensorField> volSymmTensorFields;
readFields(mesh, objects, volSymmTensorFields);
ReadFields(mesh, objects, volSymmTensorFields);
PtrList<volTensorField> volTensorFields;
readFields(mesh, objects, volTensorFields);
ReadFields(mesh, objects, volTensorFields);
//- uncomment if you want to interpolate surface fields (usually bad idea)
//Info<< "Reading all current surfaceFields" << endl;
//PtrList<surfaceScalarField> surfaceScalarFields;
//readFields(mesh, objects, surfaceScalarFields);
//ReadFields(mesh, objects, surfaceScalarFields);
//
//PtrList<surfaceVectorField> surfaceVectorFields;
//readFields(mesh, objects, surfaceVectorFields);
//ReadFields(mesh, objects, surfaceVectorFields);
//
//PtrList<surfaceTensorField> surfaceTensorFields;
//readFields(mesh, objects, surfaceTensorFields);
//ReadFields(mesh, objects, surfaceTensorFields);
if (!overwrite)
{
@ -391,10 +365,25 @@ int main(int argc, char *argv[])
mesh.movePoints(morphMap->preMotionPoints());
// Write mesh
if (overwrite)
{
mesh.setInstance(oldInstance);
stitcher.instance() = oldInstance;
}
Info << nl << "Writing polyMesh to time " << runTime.timeName() << endl;
IOstream::defaultPrecision(10);
if (!mesh.write())
// Bypass runTime write (since only writes at outputTime)
if
(
!runTime.objectRegistry::writeObject
(
runTime.writeFormat(),
IOstream::currentVersion,
runTime.writeCompression()
)
)
{
FatalErrorIn(args.executable())
<< "Failed writing polyMesh."

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -159,9 +159,10 @@ int main(int argc, char *argv[])
# include "createTime.H"
runTime.functionObjects().off();
# include "createMesh.H"
const word oldInstance = mesh.pointsInstance();
word setName(args.additionalArgs()[0]);
bool overwrite = args.options().found("overwrite");
bool overwrite = args.optionFound("overwrite");
Info<< "Reading cell set from " << setName << endl << endl;
@ -171,9 +172,9 @@ int main(int argc, char *argv[])
label patchI = -1;
if (args.options().found("patch"))
if (args.optionFound("patch"))
{
word patchName(args.options()["patch"]);
word patchName(args.option("patch"));
patchI = mesh.boundaryMesh().findPatchID(patchName);
@ -276,7 +277,7 @@ int main(int argc, char *argv[])
// Read point fields and subset
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pointMesh pMesh(mesh);
const pointMesh& pMesh = pointMesh::New(mesh);
wordList pointScalarNames(objects.names(pointScalarField::typeName));
PtrList<pointScalarField> pointScalarFlds(pointScalarNames.size());
@ -331,8 +332,12 @@ int main(int argc, char *argv[])
{
runTime++;
}
else
{
mesh.setInstance(oldInstance);
}
Info<< "Writing subsetted mesh and fields to time " << runTime.value()
Info<< "Writing subsetted mesh and fields to time " << runTime.timeName()
<< endl;
subsetter.subMesh().write();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,7 +27,10 @@ Application
Description
Transforms the mesh points in the polyMesh directory according to the
options:
translate, rotate and scale options.
Usage
Options are:
-translate vector
Translates the points by the given vector,
@ -35,14 +38,22 @@ Description
-rotate (vector vector)
Rotates the points from the first vector to the second,
or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees)
or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees)
-scale vector
Scales the points by the given vector.
The any or all of the three options may be specified and are processed
in the above order.
With -rotateFields (in combination with -rotate) it will also
read & transform vector & tensor fields.
With -rotateFields (in combination with -rotate/yawPitchRoll/rollPitchYaw)
it will also read & transform vector & tensor fields.
Note:
yaw (rotation about z)
pitch (rotation about y)
roll (rotation about x)
\*---------------------------------------------------------------------------*/
@ -58,6 +69,7 @@ Description
#include "IStringStream.H"
using namespace Foam;
using namespace Foam::mathematicalConstant;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -131,9 +143,11 @@ int main(int argc, char *argv[])
{
argList::validOptions.insert("translate", "vector");
argList::validOptions.insert("rotate", "(vector vector)");
argList::validOptions.insert("rollPitchYaw", "(roll pitch yaw)");
argList::validOptions.insert("yawPitchRoll", "(yaw pitch roll)");
argList::validOptions.insert("rotateFields", "");
argList::validOptions.insert("scale", "vector");
# include "setRootCase.H"
# include "createTime.H"
@ -152,7 +166,7 @@ int main(int argc, char *argv[])
);
if (args.options().size() == 0)
if (args.options().empty())
{
FatalErrorIn(args.executable())
<< "No options supplied, please use one or more of "
@ -160,18 +174,18 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
if (args.options().found("translate"))
if (args.optionFound("translate"))
{
vector transVector(IStringStream(args.options()["translate"])());
vector transVector(args.optionLookup("translate")());
Info<< "Translating points by " << transVector << endl;
points += transVector;
}
if (args.options().found("rotate"))
if (args.optionFound("rotate"))
{
Pair<vector> n1n2(IStringStream(args.options()["rotate"])());
Pair<vector> n1n2(args.optionLookup("rotate")());
n1n2[0] /= mag(n1n2[0]);
n1n2[1] /= mag(n1n2[1]);
tensor T = rotationTensor(n1n2[0], n1n2[1]);
@ -180,15 +194,67 @@ int main(int argc, char *argv[])
points = transform(T, points);
if (args.options().found("rotateFields"))
if (args.optionFound("rotateFields"))
{
rotateFields(runTime, T);
}
}
if (args.options().found("scale"))
else if (args.optionFound("rollPitchYaw"))
{
vector scaleVector(IStringStream(args.options()["scale"])());
vector v(args.optionLookup("rollPitchYaw")());
Info<< "Rotating points by" << nl
<< " roll " << v.x() << nl
<< " pitch " << v.y() << nl
<< " yaw " << v.z() << endl;
// Convert to radians
v *= pi/180.0;
quaternion R(v.x(), v.y(), v.z());
Info<< "Rotating points by quaternion " << R << endl;
points = transform(R, points);
if (args.optionFound("rotateFields"))
{
rotateFields(runTime, R.R());
}
}
else if (args.optionFound("yawPitchRoll"))
{
vector v(args.optionLookup("yawPitchRoll")());
Info<< "Rotating points by" << nl
<< " yaw " << v.x() << nl
<< " pitch " << v.y() << nl
<< " roll " << v.z() << endl;
// Convert to radians
v *= pi/180.0;
scalar yaw = v.x();
scalar pitch = v.y();
scalar roll = v.z();
quaternion R = quaternion(vector(0, 0, 1), yaw);
R *= quaternion(vector(0, 1, 0), pitch);
R *= quaternion(vector(1, 0, 0), roll);
Info<< "Rotating points by quaternion " << R << endl;
points = transform(R, points);
if (args.optionFound("rotateFields"))
{
rotateFields(runTime, R.R());
}
}
if (args.optionFound("scale"))
{
vector scaleVector(args.optionLookup("scale")());
Info<< "Scaling points by " << scaleVector << endl;
@ -203,7 +269,7 @@ int main(int argc, char *argv[])
Info << "Writing points into directory " << points.path() << nl << endl;
points.write();
return(0);
return 0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -59,7 +59,7 @@ int main(int argc, char *argv[])
Info<< "End\n" << endl;
return(0);
return 0;
}