Commit 5ece14ec authored by mattijs's avatar mattijs
Browse files

BUG: finite volume did not work before.

parent 46ad2e55
- allocate/free tags.
Not tested.
OK - test blockMesh with cyclics
unitTestCases/singleCyclic/
OK - test cyclics sequential running.
unitTestCases/singleCyclic/
OK - test decomposePar
OK - FaceCellWave
unitTestCases/twoCavityCyclicForWallDistance/
OK - non-parallel finite volume : channelFoam
unitTestCases/channel395-splitCyclic vs. channel395-dev
OK - parallel finite volume with processorCyclic: channelFoam
unitTestCases/channel395-splitCyclic vs. channel395-dev
- amg
- test createPatch pointSync
- pointFields on cyclics. volPointInterpolation.
- jumpCyclics
- fanFvPatchField
- activeBaffleVelocity
- work out overlapping communication for PstreamBuffers.
Different tag?
- fvMeshDistribute to split processor patches into ones with different
separation.
- fvMeshSubset
- kivaToFoam/readKivaGrid.H sorts cyclics (but in incorrect order?)
- grep for size()/2
- pointEdgeWave (maybe through inversePointDistanceDiffusivity?)
- regionSplit
- scotchDecomp
- isoSurface.C
- preProcessing/foamUpgradeCyclics
- referredCellList.C
- renumberMesh
- work out scheduled communication?
compile:
......@@ -296,12 +296,7 @@ label mergePatchFaces
const faceZone& fZone = mesh.faceZones()[zoneID];
zoneFlip = fZone.flipMap()[fZone.whichFace(newMasterI)];
}
labelPair patchIDs = polyTopoChange::whichPatch
(
mesh.boundaryMesh(),
newMasterI
);
label patchID = mesh.boundaryMesh().whichPatch(newMasterI);
Pout<< "Restoring new master face " << newMasterI
<< " to vertices " << setFaceVerts[0] << endl;
......@@ -316,11 +311,10 @@ label mergePatchFaces
own, // owner
-1, // neighbour
false, // face flip
patchIDs[0], // patch for face
patchID, // patch for face
false, // remove from zone
zoneID, // zone for face
zoneFlip, // face flip in zone
patchIDs[1] // subPatch
zoneFlip // face flip in zone
)
);
......@@ -342,10 +336,9 @@ label mergePatchFaces
-1, // masterEdgeID,
newMasterI, // masterFaceID,
false, // flipFaceFlux,
patchIDs[0], // patchID,
patchID, // patchID,
zoneID, // zoneID,
zoneFlip, // zoneFlip
patchIDs[1] // subPatch
zoneFlip // zoneFlip
)
);
}
......
......@@ -45,12 +45,17 @@ defineTypeNameAndDebug(Foam::cellSplitter, 0);
void Foam::cellSplitter::getFaceInfo
(
const label faceI,
labelPair& patchIDs,
label& patchID,
label& zoneID,
label& zoneFlip
) const
{
patchIDs = polyTopoChange::whichPatch(mesh_.boundaryMesh(), faceI);
patchID = -1;
if (!mesh_.isInternalFace(faceI))
{
patchID = mesh_.boundaryMesh().whichPatch(faceI);
}
zoneID = mesh_.faceZones().whichZone(faceI);
......@@ -161,16 +166,17 @@ void Foam::cellSplitter::setRefinement
label anchorPoint = mesh_.cellPoints()[cellI][0];
label addedPointI = meshMod.setAction
(
polyAddPoint
label addedPointI =
meshMod.setAction
(
iter(), // point
anchorPoint, // master point
-1, // zone for point
true // supports a cell
)
);
polyAddPoint
(
iter(), // point
anchorPoint, // master point
-1, // zone for point
true // supports a cell
)
);
addedPoints_.insert(cellI, addedPointI);
//Pout<< "Added point " << addedPointI
......@@ -199,17 +205,19 @@ void Foam::cellSplitter::setRefinement
// Add other pyramids
for (label i = 1; i < cFaces.size(); i++)
label addedCellI = meshMod.setAction
(
polyAddCell
{
label addedCellI =
meshMod.setAction
(
-1, // master point
-1, // master edge
-1, // master face
cellI, // master cell
-1 // zone
)
);
polyAddCell
(
-1, // master point
-1, // master edge
-1, // master face
cellI, // master cell
-1 // zone
)
);
newCells[i] = addedCellI;
}
......@@ -296,8 +304,7 @@ void Foam::cellSplitter::setRefinement
false, // flux flip
-1, // patch for face
-1, // zone for face
false, // face zone flip
-1 // subPatch
false // face zone flip
)
);
}
......@@ -343,8 +350,7 @@ void Foam::cellSplitter::setRefinement
false, // flux flip
-1, // patch for face
-1, // zone for face
false, // face zone flip
-1 // subPatch
false // face zone flip
)
);
}
......@@ -399,8 +405,7 @@ void Foam::cellSplitter::setRefinement
-1, // patch for face
false, // remove from zone
-1, // zone for face
false, // face zone flip
-1 // subPatch
false // face zone flip
)
);
}
......@@ -418,8 +423,7 @@ void Foam::cellSplitter::setRefinement
-1, // patch for face
false, // remove from zone
-1, // zone for face
false, // face zone flip
-1 // subPatch
false // face zone flip
)
);
}
......@@ -429,9 +433,9 @@ void Foam::cellSplitter::setRefinement
{
label newOwn = newOwner(faceI, cellToCells);
labelPair patchIDs;
label zoneID, zoneFlip;
getFaceInfo(faceI, patchIDs, zoneID, zoneFlip);
label patchID, zoneID, zoneFlip;
getFaceInfo(faceI, patchID, zoneID, zoneFlip);
meshMod.setAction
(
polyModifyFace
......@@ -441,11 +445,10 @@ void Foam::cellSplitter::setRefinement
newOwn, // owner
-1, // neighbour
false, // flux flip
patchIDs[0], // patch for face
patchID, // patch for face
false, // remove from zone
zoneID, // zone for face
zoneFlip, // face zone flip
patchIDs[1]
zoneFlip // face zone flip
)
);
}
......
......@@ -39,7 +39,6 @@ SourceFiles
#include "Map.H"
#include "edge.H"
#include "labelPair.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -74,7 +73,7 @@ class cellSplitter
void getFaceInfo
(
const label faceI,
labelPair& patchIDs,
label& patchID,
label& zoneID,
label& zoneFlip
) const;
......
......@@ -1200,8 +1200,7 @@ int main(int argc, char *argv[])
false, // flipFaceFlux
-1, // patchID
faceZonei, // zoneID
fm[facei], // zoneFlip
-1 // subPatchID
fm[facei] // zoneFlip
);
}
......@@ -1252,8 +1251,7 @@ int main(int argc, char *argv[])
false, // flipFaceFlux
patchi, // patchID
-1, // zoneID
false, // zoneFlip
-1 // subPatchID
false // zoneFlip
);
// For baffles create the opposite face
......@@ -1270,8 +1268,7 @@ int main(int argc, char *argv[])
false, // flipFaceFlux
patchi, // patchID
-1, // zoneID
false, // zoneFlip
-1
false // zoneFlip
);
}
}
......@@ -1320,8 +1317,7 @@ int main(int argc, char *argv[])
false, //flipFaceFlux
-1, //patchID
-1, //zoneID
false, //zoneFlip
-1 //subPatchID
false //zoneFlip
);
}
}
......
......@@ -136,8 +136,7 @@ void Foam::extrude2DMesh::setRefinement
false, // flipFaceFlux
-1, // patchID
zoneID, // zoneID
zoneFlip, // zoneFlip
-1 // subPatchID
zoneFlip // zoneFlip
);
}
......@@ -174,8 +173,7 @@ void Foam::extrude2DMesh::setRefinement
false, // flipFaceFlux
patchI, // patchID
zoneID, // zoneID
zoneFlip, // zoneFlip
-1 //?TBD subPatchID
zoneFlip // zoneFlip
);
}
}
......@@ -238,8 +236,7 @@ void Foam::extrude2DMesh::setRefinement
false, // flipFaceFlux
frontPatchI, // patchID
-1, // zoneID
false, // zoneFlip
-1 //?TDB subPatchID
false // zoneFlip
);
// Offset to create front face.
......@@ -258,8 +255,7 @@ void Foam::extrude2DMesh::setRefinement
false, // flipFaceFlux
frontPatchI, // patchID
-1, // zoneID
false, // zoneFlip
-1 //?TDB subPatchID
false // zoneFlip
);
}
}
......
......@@ -198,69 +198,55 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
forAll(patches, patchI)
{
if (isA<cyclicPolyPatch>(patches[patchI]))
if
(
isA<cyclicPolyPatch>(patches[patchI])
&& refCast<const cyclicPolyPatch>(patches[patchI]).owner()
)
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(patches[patchI]);
label halfSize = cycPatch.size()/2;
// Dump halves
// Dump patches
{
OFstream str(prefix+cycPatch.name()+"_half0.obj");
OFstream str(prefix+cycPatch.name()+".obj");
Pout<< "Dumping " << cycPatch.name()
<< " half0 faces to " << str.name() << endl;
<< " faces to " << str.name() << endl;
meshTools::writeOBJ
(
str,
static_cast<faceList>
(
SubList<face>
(
cycPatch,
halfSize
)
),
cycPatch,
cycPatch.points()
);
}
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
{
OFstream str(prefix+cycPatch.name()+"_half1.obj");
Pout<< "Dumping " << cycPatch.name()
<< " half1 faces to " << str.name() << endl;
OFstream str(prefix+nbrPatch.name()+".obj");
Pout<< "Dumping " << nbrPatch.name()
<< " faces to " << str.name() << endl;
meshTools::writeOBJ
(
str,
static_cast<faceList>
(
SubList<face>
(
cycPatch,
halfSize,
halfSize
)
),
cycPatch.points()
nbrPatch,
nbrPatch.points()
);
}
// Lines between corresponding face centres
OFstream str(prefix+cycPatch.name()+"_match.obj");
OFstream str(prefix+cycPatch.name()+nbrPatch.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++)
forAll(cycPatch, faceI)
{
const point& fc0 = mesh.faceCentres()[cycPatch.start()+faceI];
meshTools::writeOBJ(str, fc0);
vertI++;
label nbrFaceI = halfSize + faceI;
const point& fc1 =
mesh.faceCentres()[cycPatch.start()+nbrFaceI];
const point& fc1 = mesh.faceCentres()[nbrPatch.start()+faceI];
meshTools::writeOBJ(str, fc1);
vertI++;
......@@ -273,34 +259,13 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
void separateList
(
const vectorField& separation,
const vector& separation,
UList<vector>& field
)
{
if (separation.size() == 1)
forAll(field, i)
{
// 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);
field[i] += separation;
}
}
......@@ -427,13 +392,19 @@ void syncPoints
{
const polyPatch& pp = patches[patchI];
if (isA<cyclicPolyPatch>(pp))
if
(
isA<cyclicPolyPatch>(pp)
&& refCast<const cyclicPolyPatch>(pp).owner()
)
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(pp);
const edgeList& coupledPoints = cycPatch.coupledPoints();
const labelList& meshPts = cycPatch.meshPoints();
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const labelList& nbrMeshPts = nbrPatch.meshPoints();
pointField half0Values(coupledPoints.size());
......@@ -452,14 +423,14 @@ void syncPoints
else if (cycPatch.separated())
{
hasTransformation = true;
const vectorField& v = cycPatch.coupledPolyPatch::separation();
const vector& v = cycPatch.separation();
separateList(v, half0Values);
}
forAll(coupledPoints, i)
{
const edge& e = coupledPoints[i];
label point1 = meshPts[e[1]];
label point1 = nbrMeshPts[e[1]];
points[point1] = half0Values[i];
}
}
......@@ -783,13 +754,8 @@ int main(int argc, char *argv[])
// 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.
// - for separated ones use user specified offset vector
forAll(mesh.boundaryMesh(), patchI)
{
......@@ -813,51 +779,18 @@ int main(int argc, char *argv[])
if (cycpp.transform() == cyclicPolyPatch::TRANSLATIONAL)
{
// Force to wanted separation
Info<< "On cyclic translation patch " << pp.name()
<< " forcing uniform separation of "
<< cycpp.separationVector() << endl;
const_cast<vectorField&>(cpp.separation()) =
pointField(1, cycpp.separationVector());
const_cast<vector&>(cpp.separation()) =
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;
}
}
}
......
......@@ -306,8 +306,6 @@ 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)
{
......@@ -315,16 +313,6 @@ autoPtr<mapPolyMesh> reorderMesh
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
......@@ -335,8 +323,7 @@ autoPtr<mapPolyMesh> reorderMesh
xferMove(newNeighbour),
patchSizes,
patchStarts,
subPatches,
subPatchStarts
true
);
return autoPtr<mapPolyMesh>
......
......@@ -556,7 +556,7 @@ void getInterfaceSizes
label cellI = mesh.faceOwner()[i+mesh.nInternalFaces()];
coupledRegion[i] = cellRegion[cellI];
}
syncTools::swapBoundaryFaceList(mesh, coupledRegion, false);
syncTools::swapBoundaryFaceList(mesh, coupledRegion);
forAll(coupledRegion, i)
{
......@@ -726,7 +726,7 @@ autoPtr<mapPolyMesh> createRegionMesh
<