Commit cbbc796b authored by andy's avatar andy
Browse files

Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

parents 7c218f7a 4268427c
......@@ -146,5 +146,3 @@
(
additionalControlsDict.lookup("solvePrimaryRegion")
);
IObasicSourceList sources(mesh);
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -36,7 +36,10 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::cellSplitter, 0);
namespace Foam
{
defineTypeNameAndDebug(cellSplitter, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......
......@@ -466,8 +466,8 @@ int main(int argc, char *argv[])
labelListList pointPoints;
autoPtr<mapDistribute> meshDistributor = buildMap(mesh, pointPoints);
triadField alignments = buildAlignmentField(mesh);
pointField points = buildPointField(mesh);
triadField alignments(buildAlignmentField(mesh));
pointField points(buildPointField(mesh));
mesh.printInfo(Info);
......
......@@ -168,7 +168,8 @@ public:
);
//- Inserts points into the triangulation if the point is within
// the circumsphere of another cell
// the circumsphere of another cell. Returns HashSet of failed
// point insertions
template<class PointIterator>
labelPairHashSet rangeInsertReferredWithInfo
(
......
......@@ -24,7 +24,7 @@ EXE_INC = \
-IPrintTable \
-I../vectorTools
EXE_LIBS = \
LIB_LIBS = \
-lmeshTools \
-ledgeMesh \
-lfileFormats \
......
......@@ -585,7 +585,7 @@ Foam::label Foam::cellShapeControl::refineMesh
const autoPtr<backgroundMeshDecomposition>& decomposition
)
{
const pointField cellCentres = shapeControlMesh_.cellCentres();
const pointField cellCentres(shapeControlMesh_.cellCentres());
Info<< " Created cell centres" << endl;
......@@ -682,7 +682,7 @@ Foam::label Foam::cellShapeControl::refineMesh
)
);
verts.last().targetCellSize() = lastCellSize;
verts.last().alignment() = tensor::I;
verts.last().alignment() = triad::unset;
}
}
......@@ -704,8 +704,8 @@ void Foam::cellShapeControl::smoothMesh()
pointPoints
);
triadField alignments = buildAlignmentField(shapeControlMesh_);
pointField points = buildPointField(shapeControlMesh_);
triadField alignments(buildAlignmentField(shapeControlMesh_));
pointField points(buildPointField(shapeControlMesh_));
// Setup the sizes and alignments on each point
triadField fixedAlignments(shapeControlMesh_.vertexCount(), triad::unset);
......@@ -721,12 +721,7 @@ void Foam::cellShapeControl::smoothMesh()
{
const tensor& alignment = vit->alignment();
fixedAlignments[vit->index()] = triad
(
alignment.x(),
alignment.y(),
alignment.z()
);
fixedAlignments[vit->index()] = alignment;
}
}
......@@ -881,12 +876,7 @@ void Foam::cellShapeControl::smoothMesh()
{
if (vit->real())
{
vit->alignment() = tensor
(
alignments[vit->index()].x(),
alignments[vit->index()].y(),
alignments[vit->index()].z()
);
vit->alignment() = alignments[vit->index()];
}
}
......@@ -911,9 +901,7 @@ void Foam::cellShapeControl::smoothMesh()
{
if (vit->referred())
{
const triad& t = alignments[referredPoints[referredI++]];
vit->alignment() = tensor(t.x(), t.y(), t.z());
vit->alignment() = alignments[referredPoints[referredI++]];
}
}
}
......
......@@ -684,7 +684,7 @@ void Foam::cellShapeControlMesh::insertBoundingPoints(const boundBox& bb)
boundBox bbInflate = bb;
bbInflate.inflate(10);
pointField pts = bbInflate.points();
pointField pts(bbInflate.points());
forAll(pts, pI)
{
......
......@@ -263,8 +263,6 @@ Foam::triSurfaceScalarField Foam::automatic::load()
surfaceCellSize.write();
debug = 1;
if (debug)
{
faceList faces(surface_.size());
......
......@@ -30,6 +30,7 @@ License
#include "indexedCellChecks.H"
#include "CGAL/Exact_predicates_exact_constructions_kernel.h"
#include "CGAL/Gmpq.h"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
......@@ -211,9 +212,8 @@ void Foam::conformalVoronoiMesh::checkDuals()
typedef CGAL::Exact_predicates_exact_constructions_kernel EK2;
typedef CGAL::Regular_triangulation_euclidean_traits_3<EK2> EK;
typedef CGAL::Cartesian_converter<typename baseK::Kernel, EK2> To_exact;
typedef CGAL::Cartesian_converter<EK2, typename baseK::Kernel>
Back_from_exact;
typedef CGAL::Cartesian_converter<baseK::Kernel, EK2> To_exact;
typedef CGAL::Cartesian_converter<EK2, baseK::Kernel> Back_from_exact;
// PackedBoolList bPoints(number_of_finite_cells());
......@@ -391,13 +391,13 @@ void Foam::conformalVoronoiMesh::checkDuals()
CGAL::Gmpq z(CGAL::to_double(masterPoint.z()));
std::cout<< "master = " << x << " " << y << " " << z
<< endl;
<< std::endl;
CGAL::Gmpq xs(CGAL::to_double(closestPoint.x()));
CGAL::Gmpq ys(CGAL::to_double(closestPoint.y()));
CGAL::Gmpq zs(CGAL::to_double(closestPoint.z()));
std::cout<< "slave = " << xs << " " << ys << " " << zs
<< endl;
<< std::endl;
}
}
else
......
......@@ -142,7 +142,7 @@ inline int CGAL::indexedVertex<Gt, Vb>::index() const
template<class Gt, class Vb>
inline typename CGAL::indexedVertex<Gt, Vb>::vertexType&
inline Foam::indexedVertexEnum::vertexType&
CGAL::indexedVertex<Gt, Vb>::type()
{
return type_;
......@@ -150,7 +150,7 @@ CGAL::indexedVertex<Gt, Vb>::type()
template<class Gt, class Vb>
inline typename CGAL::indexedVertex<Gt, Vb>::vertexType
inline Foam::indexedVertexEnum::vertexType
CGAL::indexedVertex<Gt, Vb>::type() const
{
return type_;
......
......@@ -64,14 +64,22 @@ int main(int argc, char *argv[])
)
);
conformalVoronoiMesh::debug = true;
conformalVoronoiMesh mesh(runTime, cvMeshDict);
if (checkGeometry)
{
const searchableSurfaces& allGeometry = mesh.allGeometry();
const searchableSurfaces allGeometry
(
IOobject
(
"cvSearchableSurfaces",
runTime.constant(),
"triSurface",
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
cvMeshDict.subDict("geometry")
);
// Write some stats
allGeometry.writeStats(List<wordList>(0), Info);
......@@ -91,6 +99,11 @@ int main(int argc, char *argv[])
}
conformalVoronoiMesh::debug = true;
conformalVoronoiMesh mesh(runTime, cvMeshDict);
while (runTime.loop())
{
Info<< nl << "Time = " << runTime.timeName() << endl;
......
......@@ -803,7 +803,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
if (allGeometry)
{
cellSet cells(mesh, "underdeterminedCells", mesh.nCells()/100);
if (mesh.checkCellDeterminant(true, &cells, mesh.geometricD()))
if (mesh.checkCellDeterminant(true, &cells))
{
noFailedChecks++;
......
......@@ -33,7 +33,10 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::mergePolyMesh, 1);
namespace Foam
{
defineTypeNameAndDebug(mergePolyMesh, 1);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......
......@@ -34,7 +34,10 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::meshDualiser, 0);
namespace Foam
{
defineTypeNameAndDebug(meshDualiser, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......
......@@ -14,7 +14,7 @@ if [ -f /usr/include/readline/readline.h -a "${1%NO_READLINE}" = "$1" ]
then
echo "Found <readline/readline.h> -- enabling readline support."
export COMP_FLAGS="-DHAS_READLINE"
export LINK_FLAGS="-lreadline -lncurses"
export LINK_FLAGS="-lreadline"
fi
wmake
......
cellSelection/cellSelection.C
cellSelection/badQualityCellSelection.C
cellSelection/outsideCellSelection.C
subsetMesh.C
EXE = $(FOAM_APPBIN)/subsetMesh
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "outsideCellSelection.H"
#include "addToRunTimeSelectionTable.H"
#include "faceSet.H"
#include "polyMesh.H"
#include "motionSmoother.H"
#include "regionSplit.H"
#include "syncTools.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace cellSelections
{
defineTypeNameAndDebug(outsideCellSelection, 0);
addToRunTimeSelectionTable(cellSelection, outsideCellSelection, dictionary);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::cellSelections::outsideCellSelection::generateField
(
const word& name,
const boolList& lst
) const
{
const fvMesh& mesh = dynamic_cast<const fvMesh&>(mesh_);
tmp<volScalarField> tfld
(
new volScalarField
(
IOobject
(
name,
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(name, dimless, 0),
zeroGradientFvPatchScalarField::typeName
)
);
scalarField& fld = tfld().internalField();
forAll(fld, celli)
{
fld[celli] = 1.0*lst[celli];
}
tfld().correctBoundaryConditions();
return tfld;
}
void Foam::cellSelections::outsideCellSelection::markRegionFaces
(
const boolList& selectedCell,
boolList& regionFace
) const
{
// Internal faces
const labelList& faceOwner = mesh_.faceOwner();
const labelList& faceNeighbour = mesh_.faceNeighbour();
forAll(faceNeighbour, faceI)
{
if
(
selectedCell[faceOwner[faceI]]
!= selectedCell[faceNeighbour[faceI]]
)
{
regionFace[faceI] = true;
}
}
// Swap neighbour selectedCell state
boolList nbrSelected;
syncTools::swapBoundaryCellList(mesh_, selectedCell, nbrSelected);
// Boundary faces
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
forAll(pbm, patchI)
{
const polyPatch& pp = pbm[patchI];
const labelUList& faceCells = pp.faceCells();
forAll(faceCells, i)
{
label faceI = pp.start()+i;
label bFaceI = faceI-mesh_.nInternalFaces();
if
(
selectedCell[faceCells[i]]
!= selectedCell[nbrSelected[bFaceI]]
)
{
regionFace[faceI] = true;
}
}
}
}
Foam::boolList Foam::cellSelections::outsideCellSelection::findRegions
(
const bool verbose,
const regionSplit& cellRegion
) const
{
boolList keepRegion(cellRegion.nRegions(), false);
forAll(locationsInMesh_, i)
{
// Find the region containing the insidePoint
label cellI = mesh_.findCell(locationsInMesh_[i]);
label keepRegionI = -1;
label keepProcI = -1;
if (cellI != -1)
{
keepRegionI = cellRegion[cellI];
keepProcI = Pstream::myProcNo();
}
reduce(keepRegionI, maxOp<label>());
keepRegion[keepRegionI] = true;
reduce(keepProcI, maxOp<label>());
if (keepProcI == -1)
{
FatalErrorIn
(
"outsideCellSelection::findRegions"
"(const bool, const regionSplit&)"
) << "Did not find " << locationsInMesh_[i]
<< " in mesh." << " Mesh bounds are " << mesh_.bounds()
<< exit(FatalError);
}
if (verbose)
{
Info<< "Found location " << locationsInMesh_[i]
<< " in cell " << cellI << " on processor " << keepProcI
<< " in global region " << keepRegionI
<< " out of " << cellRegion.nRegions() << " regions." << endl;
}
}
return keepRegion;
}
void Foam::cellSelections::outsideCellSelection::unselectOutsideRegions
(
boolList& selectedCell
) const
{
// Determine faces on the edge of selectedCell
boolList blockedFace(mesh_.nFaces(), false);
markRegionFaces(selectedCell, blockedFace);
// Determine regions
regionSplit cellRegion(mesh_, blockedFace);
// Determine regions containing locationsInMesh_
boolList keepRegion(findRegions(true, cellRegion));
// Go back to bool per cell
forAll(cellRegion, cellI)
{
if (!keepRegion[cellRegion[cellI]])
{
selectedCell[cellI] = false;
}
}
}
void Foam::cellSelections::outsideCellSelection::shrinkRegions
(
boolList& selectedCell
) const
{
// Select points on unselected cells and boundary
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boolList boundaryPoint(mesh_.nPoints(), false);
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
forAll(pbm, patchI)
{
const polyPatch& pp = pbm[patchI];
if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
{
forAll(pp, i)
{
const face& f = pp[i];
forAll(f, fp)
{
boundaryPoint[f[fp]] = true;
}
}
}
}
forAll(selectedCell, cellI)
{
if (!selectedCell[cellI])
{
const labelList& cPoints = mesh_.cellPoints(cellI);
forAll(cPoints, i)
{
boundaryPoint[cPoints[i]] = true;
}
}
}
syncTools::syncPointList(mesh_, boundaryPoint, orEqOp<bool>(), false);
// Select all cells using these points
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label nChanged = 0;
forAll(boundaryPoint, pointI)
{
if (boundaryPoint[pointI])
{
const labelList& pCells = mesh_.pointCells(pointI);
forAll(pCells, i)
{
label cellI = pCells[i];
if (selectedCell[cellI])
{
selectedCell[cellI] = false;
nChanged++;
}
}
}
}
}
void Foam::cellSelections::outsideCellSelection::erode
(
boolList& selectedCell