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

This commit is contained in:
andy 2012-11-22 17:31:33 +00:00
commit 7d6b30ffc5
9 changed files with 331 additions and 20 deletions

View File

@ -471,6 +471,47 @@ autoPtr<mapPolyMesh> reorderMesh
true
);
// Re-do the faceZones
{
faceZoneMesh& faceZones = mesh.faceZones();
faceZones.clearAddressing();
forAll(faceZones, zoneI)
{
faceZone& fZone = faceZones[zoneI];
labelList newAddressing(fZone.size());
boolList newFlipMap(fZone.size());
forAll(fZone, i)
{
label oldFaceI = fZone[i];
newAddressing[i] = reverseFaceOrder[oldFaceI];
if (flipFaceFlux.found(newAddressing[i]))
{
newFlipMap[i] = !fZone.flipMap()[i];
}
else
{
newFlipMap[i] = fZone.flipMap()[i];
}
}
fZone.resetAddressing(newAddressing, newFlipMap);
}
}
// Re-do the cellZones
{
cellZoneMesh& cellZones = mesh.cellZones();
cellZones.clearAddressing();
forAll(cellZones, zoneI)
{
cellZones[zoneI] = UIndirectList<label>
(
reverseCellOrder,
cellZones[zoneI]
)();
}
}
return autoPtr<mapPolyMesh>
(
new mapPolyMesh

View File

@ -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
@ -132,15 +132,30 @@ Foam::word Foam::Time::findInstance
|| rOpt == IOobject::MUST_READ_IF_MODIFIED
)
{
FatalErrorIn
(
"Time::findInstance"
"(const fileName&, const word&"
", const IOobject::readOption, const word&)"
) << "Cannot find file \"" << name << "\" in directory "
<< dir << " in times " << timeName()
<< " down to " << stopInstance
<< exit(FatalError);
if (name.empty())
{
FatalErrorIn
(
"Time::findInstance"
"(const fileName&, const word&"
", const IOobject::readOption, const word&)"
) << "Cannot find directory "
<< dir << " in times " << timeName()
<< " down to " << stopInstance
<< exit(FatalError);
}
else
{
FatalErrorIn
(
"Time::findInstance"
"(const fileName&, const word&"
", const IOobject::readOption, const word&)"
) << "Cannot find file \"" << name << "\" in directory "
<< dir << " in times " << timeName()
<< " down to " << stopInstance
<< exit(FatalError);
}
}
return ts[instanceI].name();

View File

@ -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
@ -481,6 +481,15 @@ public:
);
}
//- Swap to obtain neighbour cell values for all boundary faces
template <class T>
static void swapBoundaryCellList
(
const polyMesh& mesh,
const UList<T>& cellData,
List<T>& neighbourCellData
);
// Sparse versions
//- Synchronize values on selected points.

View File

@ -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
@ -1553,6 +1553,45 @@ void Foam::syncTools::syncFaceList
}
template <class T>
void Foam::syncTools::swapBoundaryCellList
(
const polyMesh& mesh,
const UList<T>& cellData,
List<T>& neighbourCellData
)
{
if (cellData.size() != mesh.nCells())
{
FatalErrorIn
(
"syncTools<class T>::swapBoundaryCellList"
"(const polyMesh&, const UList<T>&, List<T>&)"
) << "Number of cell values " << cellData.size()
<< " is not equal to the number of cells in the mesh "
<< mesh.nCells() << abort(FatalError);
}
const polyBoundaryMesh& patches = mesh.boundaryMesh();
label nBnd = mesh.nFaces()-mesh.nInternalFaces();
neighbourCellData.setSize(nBnd);
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
const labelUList& faceCells = pp.faceCells();
forAll(faceCells, i)
{
label bFaceI = pp.start()+i-mesh.nInternalFaces();
neighbourCellData[bFaceI] = cellData[faceCells[i]];
}
}
syncTools::swapBoundaryFaceList(mesh, neighbourCellData);
}
template <unsigned nBits>
void Foam::syncTools::swapFaceList
(

View File

@ -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
@ -104,6 +104,8 @@ bool Foam::motionSmoother::checkMesh
(
readScalar(dict.lookup("minTriangleTwist", true))
);
scalar minFaceFlatness = -1.0;
dict.readIfPresent("minFaceFlatness", minFaceFlatness, true);
const scalar minDet
(
readScalar(dict.lookup("minDeterminant", true))
@ -356,6 +358,30 @@ bool Foam::motionSmoother::checkMesh
nWrongFaces = nNewWrongFaces;
}
if (minFaceFlatness > -SMALL)
{
polyMeshGeometry::checkFaceFlatness
(
report,
minFaceFlatness,
mesh,
mesh.faceAreas(),
mesh.faceCentres(),
mesh.points(),
checkFaces,
&wrongFaces
);
label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
Info<< " faces with flatness < "
<< setw(5) << minFaceFlatness
<< " : "
<< nNewWrongFaces-nWrongFaces << endl;
nWrongFaces = nNewWrongFaces;
}
if (minDet > -1)
{
polyMeshGeometry::checkCellDeterminant
@ -479,6 +505,8 @@ bool Foam::motionSmoother::checkMesh
(
readScalar(dict.lookup("minTriangleTwist", true))
);
scalar minFaceFlatness = -1.0;
dict.readIfPresent("minFaceFlatness", minFaceFlatness, true);
const scalar minDet
(
readScalar(dict.lookup("minDeterminant", true))
@ -697,6 +725,27 @@ bool Foam::motionSmoother::checkMesh
nWrongFaces = nNewWrongFaces;
}
if (minFaceFlatness > -1)
{
meshGeom.checkFaceFlatness
(
report,
minFaceFlatness,
meshGeom.mesh().points(),
checkFaces,
&wrongFaces
);
label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
Info<< " faces with flatness < "
<< setw(5) << minFaceFlatness
<< " : "
<< nNewWrongFaces-nWrongFaces << endl;
nWrongFaces = nNewWrongFaces;
}
if (minDet > -1)
{
meshGeom.checkCellDeterminant

View File

@ -341,8 +341,8 @@ bool Foam::polyMeshGeometry::checkFaceTet
{
Pout<< "bool polyMeshGeometry::checkFaceTets("
<< "const bool, const scalar, const pointField&"
<< ", const pointField&, const labelList&,"
<< " labelHashSet*): "
<< ", const pointField&"
<< ", const labelList&, labelHashSet*) : "
<< "face " << faceI
<< " has a triangle that points the wrong way."
<< endl
@ -373,9 +373,6 @@ Foam::polyMeshGeometry::polyMeshGeometry(const polyMesh& mesh)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Take over properties from mesh
@ -2014,6 +2011,113 @@ bool Foam::polyMeshGeometry::checkTriangleTwist
}
bool Foam::polyMeshGeometry::checkFaceFlatness
(
const bool report,
const scalar minFlatness,
const polyMesh& mesh,
const vectorField& faceAreas,
const vectorField& faceCentres,
const pointField& p,
const labelList& checkFaces,
labelHashSet* setPtr
)
{
if (minFlatness < -SMALL || minFlatness > 1+SMALL)
{
FatalErrorIn
(
"polyMeshGeometry::checkFaceFlatness"
"(const bool, const scalar, const polyMesh&, const pointField&"
", const pointField&, const labelList&, labelHashSet*)"
) << "minFlatness should be [0..1] but is now " << minFlatness
<< abort(FatalError);
}
const faceList& fcs = mesh.faces();
label nWarped = 0;
forAll(checkFaces, i)
{
label faceI = checkFaces[i];
const face& f = fcs[faceI];
if (f.size() > 3)
{
const point& fc = faceCentres[faceI];
// Sum triangle areas
scalar sumArea = 0.0;
forAll(f, fp)
{
sumArea += triPointRef
(
p[f[fp]],
p[f.nextLabel(fp)],
fc
).mag();
}
if (sumArea/mag(faceAreas[faceI]) < minFlatness)
{
nWarped++;
if (setPtr)
{
setPtr->insert(faceI);
}
}
}
}
reduce(nWarped, sumOp<label>());
if (report)
{
if (nWarped> 0)
{
Info<< "There are " << nWarped
<< " faces with area of invidual triangles"
<< " compared to overall area less than "
<< minFlatness << nl << endl;
}
else
{
Info<< "All faces are flat in that the area of invidual triangles"
<< " compared to overall area is less than "
<< minFlatness << nl << endl;
}
}
if (nWarped > 0)
{
if (report)
{
WarningIn
(
"polyMeshGeometry::checkFaceFlatness"
"(const bool, const scalar, const polyMesh&"
", const pointField&, const pointField&, const labelList&"
", labelHashSet*)"
) << nWarped << " non-flat faces "
<< "(area of invidual triangles"
<< " compared to overall area"
<< " < " << minFlatness << ") found.\n"
<< endl;
}
return true;
}
else
{
return false;
}
}
bool Foam::polyMeshGeometry::checkFaceArea
(
const bool report,
@ -2398,6 +2502,29 @@ bool Foam::polyMeshGeometry::checkTriangleTwist
}
bool Foam::polyMeshGeometry::checkFaceFlatness
(
const bool report,
const scalar minFlatness,
const pointField& p,
const labelList& checkFaces,
labelHashSet* setPtr
) const
{
return checkFaceFlatness
(
report,
minFlatness,
mesh_,
faceAreas_,
faceCentres_,
p,
checkFaces,
setPtr
);
}
bool Foam::polyMeshGeometry::checkFaceArea
(
const bool report,

View File

@ -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
@ -303,6 +303,19 @@ public:
labelHashSet* setPtr
);
//- Area of faces v.s. sum of triangle areas
static bool checkFaceFlatness
(
const bool report,
const scalar minFlatness,
const polyMesh&,
const vectorField& faceAreas,
const vectorField& faceCentres,
const pointField& p,
const labelList& checkFaces,
labelHashSet* setPtr
);
//- Small faces
static bool checkFaceArea
(
@ -314,6 +327,7 @@ public:
labelHashSet* setPtr
);
//- Area of internal faces v.s. boundary faces
static bool checkCellDeterminant
(
const bool report,
@ -413,6 +427,15 @@ public:
labelHashSet* setPtr
) const;
bool checkFaceFlatness
(
const bool report,
const scalar minFlatness,
const pointField& p,
const labelList& checkFaces,
labelHashSet* setPtr
) const;
bool checkFaceArea
(
const bool report,

View File

@ -168,7 +168,8 @@ public:
return names_;
}
//- Per 'interface' surface : name of faceZone to put faces into
//- Per 'interface' surface : empty or name of faceZone to put
// faces into
const wordList& faceZoneNames() const
{
return faceZoneNames_;

View File

@ -39,6 +39,13 @@ writeInterval 100;
purgeWrite 0;
//- Have regular restart files
secondaryWriteControl cpuTime;
secondaryWriteInterval 120;
secondaryPurgeWrite 1;
writeFormat ascii;
writePrecision 6;