ENH: handle partially attached master/slave faces (issue #608)

- addresses problems if faces are already partly attached
  (eg, on a single vertex or along an edge).
This commit is contained in:
Mark Olesen
2017-10-06 14:18:54 +02:00
parent 1cfb59fe1a
commit 00b94c4a40
26 changed files with 1739 additions and 1197 deletions

View File

@ -197,30 +197,57 @@ class polyTopoChange
// Private Member Functions // Private Member Functions
//- Reorder contents of container according to map //- Reorder contents of container according to oldToNew map
template<class T> template<class T>
static void reorder(const labelList& map, DynamicList<T>&); static void reorder
template<class T> (
static void reorder(const labelList& map, List<DynamicList<T>>&); const labelUList& oldToNew,
template<class T> DynamicList<T>& lst
static void renumberKey(const labelList& map, Map<T>&); );
template<class T>
static void reorder
(
const labelUList& oldToNew,
List<DynamicList<T>>& lst
);
template<class T>
static void renumberKey
(
const labelUList& oldToNew,
Map<T>& map
);
//- Renumber elements of container according to oldToNew map
static void renumber
(
const labelUList& oldToNew,
labelHashSet& labels
);
//- Renumber elements of container according to map
static void renumber(const labelList&, labelHashSet&);
//- Special handling of reverse maps which have <-1 in them //- Special handling of reverse maps which have <-1 in them
static void renumberReverseMap(const labelList&, DynamicList<label>&); static void renumberReverseMap
(
const labelUList& oldToNew,
DynamicList<label>& elems
);
//- Renumber & compact elements of list according to map //- Renumber & compact elements of list according to map
static void renumberCompact(const labelList&, labelList&); static void renumberCompact
(
const labelUList& oldToNew,
labelList& elems
);
//- Get all set elements as a labelHashSet //- Get all set elements as a labelHashSet
static labelHashSet getSetIndices(const PackedBoolList&); static labelHashSet getSetIndices(const PackedBoolList& lst);
//- Count number of added and removed quantities from maps. //- Count number of added and removed quantities from maps.
static void countMap static void countMap
( (
const labelList& map, const labelUList& map,
const labelList& reverseMap, const labelUList& reverseMap,
label& nAdd, label& nAdd,
label& nInflate, label& nInflate,
label& nMerge, label& nMerge,
@ -228,19 +255,19 @@ class polyTopoChange
); );
//- Print some stats about mesh //- Print some stats about mesh
static void writeMeshStats(const polyMesh& mesh, Ostream&); static void writeMeshStats(const polyMesh& mesh, Ostream& os);
//- Calculate object maps. Requires reverseMap to have destination //- Calculate object maps. Requires reverseMap to have destination
// to be marked with <-1. // to be marked with <-1.
static void getMergeSets static void getMergeSets
( (
const labelList& reverseCellMap, const labelUList& reverseCellMap,
const labelList& cellMap, const labelUList& cellMap,
List<objectMap>& cellsFromCells List<objectMap>& cellsFromCells
); );
//- Are all face vertices valid //- Are all face vertices valid
bool hasValidPoints(const face&) const; bool hasValidPoints(const face& f) const;
//- Return face points //- Return face points
pointField facePoints(const face& f) const; pointField facePoints(const face& f) const;
@ -248,7 +275,7 @@ class polyTopoChange
//- Check inputs to modFace or addFace //- Check inputs to modFace or addFace
void checkFace void checkFace
( (
const face&, const face& f,
const label facei, const label facei,
const label own, const label own,
const label nei, const label nei,
@ -274,16 +301,16 @@ class polyTopoChange
//- Cell ordering (bandCompression). Returns number of remaining cells. //- Cell ordering (bandCompression). Returns number of remaining cells.
label getCellOrder label getCellOrder
( (
const CompactListList<label, labelList>&, const CompactListList<label, labelList>& cellCellAddressing,
labelList& labelList& oldToNew
) const; ) const;
//- Do upper-triangular ordering and patch ordering. //- Do upper-triangular ordering and patch ordering.
void getFaceOrder void getFaceOrder
( (
const label nActiveFaces, const label nActiveFaces,
const labelList& cellFaces, const labelUList& cellFaces,
const labelList& cellFaceOffsets, const labelUList& cellFaceOffsets,
labelList& oldToNew, labelList& oldToNew,
labelList& patchSizes, labelList& patchSizes,
@ -294,7 +321,7 @@ class polyTopoChange
void reorderCompactFaces void reorderCompactFaces
( (
const label newSize, const label newSize,
const labelList& oldToNew const labelUList& oldToNew
); );
//- Remove all unused/removed points/faces/cells and update //- Remove all unused/removed points/faces/cells and update
@ -314,50 +341,50 @@ class polyTopoChange
//- Select either internal or external faces out of faceLabels //- Select either internal or external faces out of faceLabels
static labelList selectFaces static labelList selectFaces
( (
const primitiveMesh&, const primitiveMesh& mesh,
const labelList& faceLabels, const labelUList& faceLabels,
const bool internalFacesOnly const bool internalFacesOnly
); );
//- Calculate mapping for patchpoints only //- Calculate mapping for patchpoints only
void calcPatchPointMap void calcPatchPointMap
( (
const List<Map<label>>&, const UList<Map<label>>& oldPatchMeshPointMaps,
const polyBoundaryMesh&, const polyBoundaryMesh& boundary,
labelListList& labelListList& patchPointMap
) const; ) const;
void calcFaceInflationMaps void calcFaceInflationMaps
( (
const polyMesh&, const polyMesh& mesh,
List<objectMap>&, List<objectMap>& facesFromPoints,
List<objectMap>&, List<objectMap>& facesFromEdges,
List<objectMap>& List<objectMap>& facesFromFaces
) const; ) const;
void calcCellInflationMaps void calcCellInflationMaps
( (
const polyMesh&, const polyMesh& mesh,
List<objectMap>&, List<objectMap>& cellsFromPoints,
List<objectMap>&, List<objectMap>& cellsFromEdges,
List<objectMap>&, List<objectMap>& cellsFromFaces,
List<objectMap>& List<objectMap>& cellsFromCells
) const; ) const;
void resetZones void resetZones
( (
const polyMesh&, // mesh to get existing info from const polyMesh& mesh, // mesh to get existing info from
polyMesh&, // mesh to change zones on polyMesh& newMesh, // mesh to change zones on
labelListList&, labelListList& pointZoneMap,
labelListList&, labelListList& faceZoneFaceMap,
labelListList& labelListList& cellZoneMap
) const; ) const;
void calcFaceZonePointMap void calcFaceZonePointMap
( (
const polyMesh&, const polyMesh& mesh,
const List<Map<label>>&, const UList<Map<label>>& oldFaceZoneMeshPointMaps,
labelListList& labelListList& faceZonePointMap
) const; ) const;
@ -367,15 +394,15 @@ class polyTopoChange
void reorderCoupledFaces void reorderCoupledFaces
( (
const bool syncParallel, const bool syncParallel,
const polyBoundaryMesh&, const polyBoundaryMesh& boundary,
const labelList& patchStarts, const labelUList& patchStarts,
const labelList& patchSizes, const labelUList& patchSizes,
const pointField& points const pointField& points
); );
void compactAndReorder void compactAndReorder
( (
const polyMesh&, const polyMesh& mesh,
const bool syncParallel, const bool syncParallel,
const bool orderCells, const bool orderCells,
const bool orderPoints, const bool orderPoints,
@ -445,12 +472,15 @@ public:
} }
//- Is point removed? //- Is point removed?
// Considered removed if point is GREAT.
inline bool pointRemoved(const label pointi) const; inline bool pointRemoved(const label pointi) const;
//- Is face removed? //- Is face removed?
// Considered removed if face is empty
inline bool faceRemoved(const label facei) const; inline bool faceRemoved(const label facei) const;
//- Is cell removed? //- Is cell removed?
// Considered removed if the cellMap is -2
inline bool cellRemoved(const label celli) const; inline bool cellRemoved(const label celli) const;
@ -463,11 +493,11 @@ public:
// or zone ids. // or zone ids.
void addMesh void addMesh
( (
const polyMesh&, const polyMesh& mesh,
const labelList& patchMap, const labelUList& patchMap,
const labelList& pointZoneMap, const labelUList& pointZoneMap,
const labelList& faceZoneMap, const labelUList& faceZoneMap,
const labelList& cellZoneMap const labelUList& cellZoneMap
); );
//- Explicitly pre-size the dynamic storage for expected mesh //- Explicitly pre-size the dynamic storage for expected mesh
@ -491,7 +521,7 @@ public:
// - inCell = false: add retired point (to end of point list) // - inCell = false: add retired point (to end of point list)
label addPoint label addPoint
( (
const point&, const point& pt,
const label masterPointID, const label masterPointID,
const label zoneID, const label zoneID,
const bool inCell const bool inCell
@ -499,17 +529,18 @@ public:
//- Modify coordinate. //- Modify coordinate.
// Notes: // Notes:
// - zoneID = +ve (add to zoneID), -ve (remove from zones)
// - inCell = false: add retired point (to end of point list) // - inCell = false: add retired point (to end of point list)
void modifyPoint void modifyPoint
( (
const label, const label pointi,
const point&, const point& pt,
const label newZoneID, const label zoneID,
const bool inCell const bool inCell
); );
//- Remove/merge point. //- Remove/merge point.
void removePoint(const label, const label); void removePoint(const label pointi, const label mergePointi);
//- Add face to cells. Return new face label. //- Add face to cells. Return new face label.
// own,nei<0, zoneID>=0 : add inactive face (to end of face list) // own,nei<0, zoneID>=0 : add inactive face (to end of face list)
@ -541,7 +572,7 @@ public:
); );
//- Remove/merge face. //- Remove/merge face.
void removeFace(const label, const label); void removeFace(const label facei, const label mergeFacei);
//- Add cell. Return new cell label. //- Add cell. Return new cell label.
label addCell label addCell
@ -554,10 +585,10 @@ public:
); );
//- Modify zone of cell //- Modify zone of cell
void modifyCell(const label, const label zoneID); void modifyCell(const label celli, const label zoneID);
//- Remove/merge cell. //- Remove/merge cell.
void removeCell(const label, const label); void removeCell(const label celli, const label mergeCelli);
//- Explicitly set the number of patches if construct-without-mesh //- Explicitly set the number of patches if construct-without-mesh
// used. // used.

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,20 +30,20 @@ License
template<class T> template<class T>
void Foam::polyTopoChange::reorder void Foam::polyTopoChange::reorder
( (
const labelList& oldToNew, const labelUList& oldToNew,
DynamicList<T>& lst DynamicList<T>& lst
) )
{ {
// Create copy // Create copy
DynamicList<T> oldLst(lst); DynamicList<T> oldLst(lst);
forAll(oldToNew, elemI) forAll(oldToNew, i)
{ {
label newElemI = oldToNew[elemI]; const label newIdx = oldToNew[i];
if (newElemI != -1) if (newIdx >= 0)
{ {
lst[newElemI] = oldLst[elemI]; lst[newIdx] = oldLst[i];
} }
} }
} }
@ -52,20 +52,20 @@ void Foam::polyTopoChange::reorder
template<class T> template<class T>
void Foam::polyTopoChange::reorder void Foam::polyTopoChange::reorder
( (
const labelList& oldToNew, const labelUList& oldToNew,
List<DynamicList<T>>& lst List<DynamicList<T>>& lst
) )
{ {
// Create copy // Create copy
List<DynamicList<T>> oldLst(lst); List<DynamicList<T>> oldLst(lst);
forAll(oldToNew, elemI) forAll(oldToNew, i)
{ {
label newElemI = oldToNew[elemI]; const label newIdx = oldToNew[i];
if (newElemI != -1) if (newIdx >= 0)
{ {
lst[newElemI].transfer(oldLst[elemI]); lst[newIdx].transfer(oldLst[i]);
} }
} }
} }
@ -74,23 +74,23 @@ void Foam::polyTopoChange::reorder
template<class T> template<class T>
void Foam::polyTopoChange::renumberKey void Foam::polyTopoChange::renumberKey
( (
const labelList& oldToNew, const labelUList& oldToNew,
Map<T>& elems Map<T>& map
) )
{ {
Map<T> newElems(elems.size()); Map<T> newMap(map.capacity());
forAllConstIter(typename Map<T>, elems, iter) forAllConstIters(map, iter)
{ {
label newElem = oldToNew[iter.key()]; const label newKey = oldToNew[iter.key()];
if (newElem >= 0) if (newKey >= 0)
{ {
newElems.insert(newElem, iter()); newMap.insert(newKey, iter.object());
} }
} }
elems.transfer(newElems); map.transfer(newMap);
} }

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -40,18 +40,16 @@ void Foam::slidingInterface::decoupleInterface
{ {
if (debug) if (debug)
{ {
Pout<< "void slidingInterface::decoupleInterface(" Pout<< FUNCTION_NAME << nl
<< "polyTopoChange& ref) const : " << ": Decoupling sliding interface " << name() << endl;
<< "Decoupling sliding interface " << name() << endl;
} }
if (!attached_) if (!attached_)
{ {
if (debug) if (debug)
{ {
Pout<< "void slidingInterface::decoupleInterface(" Pout<< FUNCTION_NAME << nl
<< "polyTopoChange& ref) const : " << ": Interface already decoupled." << endl;
<< "Interface already decoupled." << endl;
} }
return; return;
@ -61,22 +59,23 @@ void Foam::slidingInterface::decoupleInterface
clearCouple(ref); clearCouple(ref);
const polyMesh& mesh = topoChanger().mesh(); const polyMesh& mesh = topoChanger().mesh();
const pointField& points = mesh.points();
const faceList& faces = mesh.faces(); const faceList& faces = mesh.faces();
const cellList& cells = mesh.cells(); const cellList& cells = mesh.cells();
const labelList& own = mesh.faceOwner(); const labelList& own = mesh.faceOwner();
const labelList& nei = mesh.faceNeighbour(); const labelList& nei = mesh.faceNeighbour();
const faceZoneMesh& faceZones = mesh.faceZones();
// Master side // Master side
const primitiveFacePatch& masterPatch = const primitiveFacePatch& masterPatch =
mesh.faceZones()[masterFaceZoneID_.index()](); faceZones[masterFaceZoneID_.index()]();
const labelList& masterPatchAddr = const labelList& masterPatchAddr =
mesh.faceZones()[masterFaceZoneID_.index()]; faceZones[masterFaceZoneID_.index()];
const boolList& masterPatchFlip = const boolList& masterPatchFlip =
mesh.faceZones()[masterFaceZoneID_.index()].flipMap(); faceZones[masterFaceZoneID_.index()].flipMap();
const labelList& masterFc = masterFaceCells(); const labelList& masterFc = masterFaceCells();
@ -119,13 +118,13 @@ void Foam::slidingInterface::decoupleInterface
// Slave side // Slave side
const primitiveFacePatch& slavePatch = const primitiveFacePatch& slavePatch =
mesh.faceZones()[slaveFaceZoneID_.index()](); faceZones[slaveFaceZoneID_.index()]();
const labelList& slavePatchAddr = const labelList& slavePatchAddr =
mesh.faceZones()[slaveFaceZoneID_.index()]; faceZones[slaveFaceZoneID_.index()];
const boolList& slavePatchFlip = const boolList& slavePatchFlip =
mesh.faceZones()[slaveFaceZoneID_.index()].flipMap(); faceZones[slaveFaceZoneID_.index()].flipMap();
const labelList& slaveFc = slaveFaceCells(); const labelList& slaveFc = slaveFaceCells();
@ -147,16 +146,7 @@ void Foam::slidingInterface::decoupleInterface
// Recover retired points on the slave side // Recover retired points on the slave side
forAll(newFace, pointi) forAll(newFace, pointi)
{ {
Map<label>::const_iterator rpmIter = rpm.find(newFace[pointi]); newFace[pointi] = rpm.lookup(newFace[pointi], newFace[pointi]);
if (rpmIter != rpm.end())
{
// Master of retired point; grab its original
// Pout<< "Reinstating retired point: " << newFace[pointi]
// << " with old: " << rpm.find(newFace[pointi])()
// << endl;
newFace[pointi] = rpmIter();
}
} }
ref.setAction ref.setAction
@ -181,12 +171,10 @@ void Foam::slidingInterface::decoupleInterface
// Grab the list of faces in the layer // Grab the list of faces in the layer
const labelList& masterStickOuts = masterStickOutFaces(); const labelList& masterStickOuts = masterStickOutFaces();
forAll(masterStickOuts, facei) for (const label curFaceID : masterStickOuts)
{ {
// Renumber the face and remove additional points // Renumber the face and remove additional points
const label curFaceID = masterStickOuts[facei];
const face& oldFace = faces[curFaceID]; const face& oldFace = faces[curFaceID];
DynamicList<label> newFaceLabels(oldFace.size()); DynamicList<label> newFaceLabels(oldFace.size());
@ -219,17 +207,18 @@ void Foam::slidingInterface::decoupleInterface
} }
// Get face zone and its flip // Get face zone and its flip
label modifiedFaceZone = mesh.faceZones().whichZone(curFaceID); const label modifiedFaceZone = faceZones.whichZone(curFaceID);
bool modifiedFaceZoneFlip = false;
if (modifiedFaceZone >= 0) const bool modifiedFaceZoneFlip =
{ (
modifiedFaceZoneFlip = modifiedFaceZone >= 0
mesh.faceZones()[modifiedFaceZone].flipMap() ?
faceZones[modifiedFaceZone].flipMap()
[ [
mesh.faceZones()[modifiedFaceZone].whichFace(curFaceID) faceZones[modifiedFaceZone].whichFace(curFaceID)
]; ]
} : false
);
face newFace; face newFace;
newFace.transfer(newFaceLabels); newFace.transfer(newFaceLabels);
@ -265,23 +254,22 @@ void Foam::slidingInterface::decoupleInterface
primitiveMesh::facesPerCell_*(masterPatch.size() + slavePatch.size()) primitiveMesh::facesPerCell_*(masterPatch.size() + slavePatch.size())
); );
forAll(slaveFc, facei) for (const label slaveFci : slaveFc)
{ {
const labelList& curFaces = cells[slaveFc[facei]]; const labelList& curFaces = cells[slaveFci];
forAll(curFaces, facei) for (const label facei : curFaces)
{ {
// Check if the face belongs to the slave face zone; and // Check if the face belongs to the slave face zone; and
// if it has been removed; if not add it // if it has been removed; if not add it
if if
( (
mesh.faceZones().whichZone(curFaces[facei]) faceZones.whichZone(facei)
!= slaveFaceZoneID_.index() != slaveFaceZoneID_.index()
&& !ref.faceRemoved(curFaces[facei]) && !ref.faceRemoved(facei)
) )
{ {
slaveLayerCellFaceMap.insert(curFaces[facei]); slaveLayerCellFaceMap.insert(facei);
} }
} }
} }
@ -292,12 +280,10 @@ void Foam::slidingInterface::decoupleInterface
// Grab master point mapping // Grab master point mapping
const Map<label>& masterPm = masterPatch.meshPointMap(); const Map<label>& masterPm = masterPatch.meshPointMap();
forAll(slaveStickOuts, facei) for (const label curFaceID : slaveStickOuts)
{ {
// Renumber the face and remove additional points // Renumber the face and remove additional points
const label curFaceID = slaveStickOuts[facei];
const face& oldFace = faces[curFaceID]; const face& oldFace = faces[curFaceID];
DynamicList<label> newFaceLabels(oldFace.size()); DynamicList<label> newFaceLabels(oldFace.size());
@ -307,16 +293,19 @@ void Foam::slidingInterface::decoupleInterface
forAll(oldFace, pointi) forAll(oldFace, pointi)
{ {
// Check if the point is removed or retired // Check if the point is removed or retired
if (rpm.found(oldFace[pointi]))
const label retiredPointi = rpm.lookup(oldFace[pointi], -1);
if (retiredPointi != -1)
{ {
// Master of retired point; grab its original // Master of retired point; grab its original
changed = true; changed = true;
// Pout<< "Reinstating retired point: " << oldFace[pointi] // Pout<< "Reinstating retired point: " << oldFace[pointi]
// << " with old: " << rpm.find(oldFace[pointi])() // << " with old: " << retiredPointi
// << endl; // << endl;
newFaceLabels.append(rpm.find(oldFace[pointi])()); newFaceLabels.append(retiredPointi);
} }
else if (ref.pointRemoved(oldFace[pointi])) else if (ref.pointRemoved(oldFace[pointi]))
{ {
@ -346,17 +335,19 @@ void Foam::slidingInterface::decoupleInterface
} }
// Get face zone and its flip // Get face zone and its flip
label modifiedFaceZone = mesh.faceZones().whichZone(curFaceID); const label modifiedFaceZone =
bool modifiedFaceZoneFlip = false; faceZones.whichZone(curFaceID);
if (modifiedFaceZone >= 0) const bool modifiedFaceZoneFlip =
{ (
modifiedFaceZoneFlip = modifiedFaceZone >= 0
mesh.faceZones()[modifiedFaceZone].flipMap() ?
faceZones[modifiedFaceZone].flipMap()
[ [
mesh.faceZones()[modifiedFaceZone].whichFace(curFaceID) faceZones[modifiedFaceZone].whichFace(curFaceID)
]; ]
} : false
);
face newFace; face newFace;
newFace.transfer(newFaceLabels); newFace.transfer(newFaceLabels);
@ -386,21 +377,19 @@ void Foam::slidingInterface::decoupleInterface
} }
// Bring all slave patch points back to life // Bring all slave patch points back to life
const pointField& points = mesh.points();
const labelList& slaveMeshPoints = const labelList& slaveMeshPoints =
mesh.faceZones()[slaveFaceZoneID_.index()]().meshPoints(); faceZones[slaveFaceZoneID_.index()]().meshPoints();
forAll(slaveMeshPoints, pointi) for (const label slavePointi : slaveMeshPoints)
{ {
ref.setAction ref.setAction
( (
polyModifyPoint polyModifyPoint
( (
slaveMeshPoints[pointi], // point ID slavePointi, // point ID
points[slaveMeshPoints[pointi]], // point points[slavePointi], // point
false, // remove from zone false, // remove from zone
mesh.pointZones().whichZone(slaveMeshPoints[pointi]), // zone mesh.pointZones().whichZone(slavePointi), // zone
true // in a cell true // in a cell
) )
); );
@ -414,9 +403,8 @@ void Foam::slidingInterface::decoupleInterface
if (debug) if (debug)
{ {
Pout<< "void slidingInterface::coupleInterface(" Pout<< FUNCTION_NAME << nl
<< "polyTopoChange& ref) const : " << ": Finished decoupling sliding interface " << name() << endl;
<< "Finished decoupling sliding interface " << name() << endl;
} }
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -47,7 +47,7 @@ void Foam::enrichedPatch::calcMeshPoints() const
<< abort(FatalError); << abort(FatalError);
} }
meshPointsPtr_ = new labelList(pointMap().toc()); meshPointsPtr_ = new labelList(std::move(pointMap().toc()));
labelList& mp = *meshPointsPtr_; labelList& mp = *meshPointsPtr_;
sort(mp); sort(mp);
@ -88,7 +88,7 @@ void Foam::enrichedPatch::calcLocalFaces() const
forAll(f, pointi) forAll(f, pointi)
{ {
curlf[pointi] = mpLookup.find(f[pointi])(); curlf[pointi] = mpLookup.cfind(f[pointi])();
} }
} }
} }
@ -110,7 +110,7 @@ void Foam::enrichedPatch::calcLocalPoints() const
forAll(lp, i) forAll(lp, i)
{ {
lp[i] = pointMap().find(mp[i])(); lp[i] = pointMap().cfind(mp[i])();
} }
} }
@ -131,14 +131,13 @@ void Foam::enrichedPatch::clearOut()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::enrichedPatch::enrichedPatch Foam::enrichedPatch::enrichedPatch
( (
const primitiveFacePatch& masterPatch, const primitiveFacePatch& masterPatch,
const primitiveFacePatch& slavePatch, const primitiveFacePatch& slavePatch,
const labelList& slavePointPointHits, const labelUList& slavePointPointHits,
const labelList& slavePointEdgeHits, const labelUList& slavePointEdgeHits,
const List<objectHit>& slavePointFaceHits const UList<objectHit>& slavePointFaceHits
) )
: :
masterPatch_(masterPatch), masterPatch_(masterPatch),
@ -252,36 +251,20 @@ void Foam::enrichedPatch::writeOBJ(const fileName& fName) const
{ {
OFstream str(fName); OFstream str(fName);
const pointField& lp = localPoints(); meshTools::writeOBJ(str, localPoints());
forAll(lp, pointi)
{
meshTools::writeOBJ(str, lp[pointi]);
}
const faceList& faces = localFaces(); const faceList& faces = localFaces();
forAll(faces, facei) for (const face& f : faces)
{ {
const face& f = faces[facei];
str << 'f'; str << 'f';
forAll(f, fp) for (const label fp : f)
{ {
str << ' ' << f[fp]+1; str << ' ' << fp+1;
} }
str << nl; str << nl;
} }
} }
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// ************************************************************************* // // ************************************************************************* //

View File

@ -36,8 +36,7 @@ Description
Note: Note:
If new points are created during master-slave edge cutting, they If new points are created during master-slave edge cutting, they
should be registred with the pointMap. should be registered with the pointMap.
SourceFiles SourceFiles
enrichedPatch.C enrichedPatch.C
@ -134,10 +133,10 @@ class enrichedPatch
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
enrichedPatch(const enrichedPatch&); enrichedPatch(const enrichedPatch&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const enrichedPatch&); void operator=(const enrichedPatch&) = delete;
// Creation of demand-driven private data // Creation of demand-driven private data
@ -196,11 +195,11 @@ public:
( (
const primitiveFacePatch& masterPatch, const primitiveFacePatch& masterPatch,
const primitiveFacePatch& slavePatch, const primitiveFacePatch& slavePatch,
const labelList& slavePointPointHits, const labelUList& slavePointPointHits,
// -1 or common point snapped to // -1 or common point snapped to
const labelList& slavePointEdgeHits, const labelUList& slavePointEdgeHits,
// -1 or common edge snapped to // -1 or common edge snapped to
const List<objectHit>& slavePointFaceHits const UList<objectHit>& slavePointFaceHits
// master face snapped to // master face snapped to
); );
@ -213,23 +212,17 @@ public:
// Access // Access
//- Return non-const access to point map to add points
Map<point>& pointMap();
//- Return map of points //- Return map of points
const Map<point>& pointMap() const; inline const Map<point>& pointMap() const;
//- Return non-const access to point map to add points
inline Map<point>& pointMap();
//- Return map of point merges //- Return map of point merges
Map<label>& pointMergeMap() inline const Map<label>& pointMergeMap() const;
{
return pointMergeMap_;
}
//- Return map of point merges //- Return map of point merges
const Map<label>& pointMergeMap() const inline Map<label>& pointMergeMap();
{
return pointMergeMap_;
}
// Topological data // Topological data
@ -278,7 +271,7 @@ public:
//- Debugging: dump graphical representation to obj format file //- Debugging: dump graphical representation to obj format file
void writeOBJ(const fileName&) const; void writeOBJ(const fileName& fName) const;
}; };
@ -288,6 +281,10 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "enrichedPatchI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -32,7 +32,7 @@ Description
#include "DynamicList.H" #include "DynamicList.H"
#include "labelPair.H" #include "labelPair.H"
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "HashSet.H" #include "edgeHashes.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -94,9 +94,8 @@ void Foam::enrichedPatch::calcCutFaces() const
// the points projected onto the face. // the points projected onto the face.
// Create a set of edge usage parameters // Create a set of edge usage parameters
HashSet<edge, Hash<edge>> edgesUsedOnce(pp.size()); edgeHashSet edgesUsedOnce(pp.size());
HashSet<edge, Hash<edge>> edgesUsedTwice edgeHashSet edgesUsedTwice(pp.size()*primitiveMesh::edgesPerPoint_);
(pp.size()*primitiveMesh::edgesPerPoint_);
forAll(lf, facei) forAll(lf, facei)
@ -145,9 +144,9 @@ void Foam::enrichedPatch::calcCutFaces() const
// Insert the edges of current face into the seed list. // Insert the edges of current face into the seed list.
edgeList cfe = curLocalFace.edges(); edgeList cfe = curLocalFace.edges();
forAll(curLocalFace, edgeI) for (const edge& e : cfe)
{ {
edgeSeeds.append(cfe[edgeI]); edgeSeeds.append(e);
} }
// Grab face normal // Grab face normal
@ -156,9 +155,7 @@ void Foam::enrichedPatch::calcCutFaces() const
while (edgeSeeds.size()) while (edgeSeeds.size())
{ {
// Pout<< "edgeSeeds.size(): " // Pout<< "edgeSeeds.size(): " << edgeSeeds.size() << endl;
// << edgeSeeds.size()
// << endl;
const edge curEdge = edgeSeeds.removeHead(); const edge curEdge = edgeSeeds.removeHead();
@ -198,6 +195,7 @@ void Foam::enrichedPatch::calcCutFaces() const
cutFaceGlobalPoints.append(mp[prevPointLabel]); cutFaceGlobalPoints.append(mp[prevPointLabel]);
cutFaceLocalPoints.append(prevPointLabel); cutFaceLocalPoints.append(prevPointLabel);
// Pout<< "prevPointLabel: " << mp[prevPointLabel] << endl; // Pout<< "prevPointLabel: " << mp[prevPointLabel] << endl;
// Grab current point and append it to the list // Grab current point and append it to the list
label curPointLabel = curEdge.end(); label curPointLabel = curEdge.end();
point curPoint = lp[curPointLabel]; point curPoint = lp[curPointLabel];
@ -266,7 +264,7 @@ void Foam::enrichedPatch::calcCutFaces() const
newDir /= magNewDir; newDir /= magNewDir;
scalar curAtanTurn = const scalar curAtanTurn =
atan2(newDir & right, newDir & ahead); atan2(newDir & right, newDir & ahead);
// Pout<< " atan: " << curAtanTurn << endl; // Pout<< " atan: " << curAtanTurn << endl;
@ -352,19 +350,18 @@ void Foam::enrichedPatch::calcCutFaces() const
// If the edge corresponds to a starting face edge, // If the edge corresponds to a starting face edge,
// mark the starting face edge as true // mark the starting face edge as true
forAll(cutFaceLocal, cutI) forAll(cutFaceLocal, cuti)
{ {
const edge curCutFaceEdge const edge curCutFaceEdge
( (
cutFaceLocal[cutI], cutFaceLocal[cuti],
cutFaceLocal.nextLabel(cutI) cutFaceLocal.nextLabel(cuti)
); );
// Increment the usage count using two hash sets // Increment the usage count using two hash sets
HashSet<edge, Hash<edge>>::iterator euoIter = auto euoIter = edgesUsedOnce.find(curCutFaceEdge);
edgesUsedOnce.find(curCutFaceEdge);
if (euoIter == edgesUsedOnce.end()) if (!euoIter.found())
{ {
// Pout<< "Found edge not used before: " // Pout<< "Found edge not used before: "
// << curCutFaceEdge // << curCutFaceEdge
@ -435,12 +432,12 @@ void Foam::enrichedPatch::calcCutFaces() const
if (facei < slavePatch_.size()) if (facei < slavePatch_.size())
{ {
Map<labelList>::const_iterator mpfAddrIter = const auto mpfAddrIter =
masterPointFaceAddr.find(cutFaceGlobal[0]); masterPointFaceAddr.cfind(cutFaceGlobal[0]);
bool otherSideFound = false; bool otherSideFound = false;
if (mpfAddrIter != masterPointFaceAddr.end()) if (mpfAddrIter.found())
{ {
bool miss = false; bool miss = false;
@ -456,18 +453,13 @@ void Foam::enrichedPatch::calcCutFaces() const
pointi++ pointi++
) )
{ {
Map<labelList>::const_iterator const auto mpfAddrPointIter =
mpfAddrPointIter = masterPointFaceAddr.cfind
masterPointFaceAddr.find
( (
cutFaceGlobal[pointi] cutFaceGlobal[pointi]
); );
if if (!mpfAddrPointIter.found())
(
mpfAddrPointIter
== masterPointFaceAddr.end()
)
{ {
// Point is off the master patch. Skip // Point is off the master patch. Skip
miss = true; miss = true;
@ -479,15 +471,11 @@ void Foam::enrichedPatch::calcCutFaces() const
// For every current face, try to find it in the // For every current face, try to find it in the
// zero-list // zero-list
forAll(curMasterFaces, i) for (const label facei : curMasterFaces)
{ {
forAll(masterFacesOfPZero, j) forAll(masterFacesOfPZero, j)
{ {
if if (facei == masterFacesOfPZero[j])
(
curMasterFaces[i]
== masterFacesOfPZero[j]
)
{ {
hits[j]++; hits[j]++;
break; break;
@ -644,7 +632,7 @@ void Foam::enrichedPatch::calcCutFaces() const
} // end of local faces } // end of local faces
// Re-pack the list into compact storage // Re-pack lists into compact storage
cutFacesPtr_ = new faceList(); cutFacesPtr_ = new faceList();
cutFacesPtr_->transfer(cf); cutFacesPtr_->transfer(cf);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,11 +26,11 @@ License
#include "enrichedPatch.H" #include "enrichedPatch.H"
#include "DynamicList.H" #include "DynamicList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::label Foam::enrichedPatch::enrichedFaceRatio_ = 3; const Foam::label Foam::enrichedPatch::enrichedFaceRatio_ = 3;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::enrichedPatch::calcEnrichedFaces void Foam::enrichedPatch::calcEnrichedFaces
@ -79,68 +79,57 @@ void Foam::enrichedPatch::calcEnrichedFaces
forAll(slavePatch_, facei) forAll(slavePatch_, facei)
{ {
const face oldFace = slavePatch_[facei]; const face& oldFace = slavePatch_[facei];
const face oldLocalFace = slaveLocalFaces[facei]; const face& oldLocalFace = slaveLocalFaces[facei];
// Info<< "old slave face " << facei << ": " << oldFace << endl;
const labelList& curEdges = slaveFaceEdges[facei]; const labelList& curEdges = slaveFaceEdges[facei];
// Info<< "old slave face[" << facei << "] " << oldFace << endl;
DynamicList<label> newFace(oldFace.size()*enrichedFaceRatio_); DynamicList<label> newFace(oldFace.size()*enrichedFaceRatio_);
// Note: The number of points and edges in a face is always identical // Note: The number of points and edges in a face is always identical
// so both can be done is the same loop // so both can be done is the same loop
forAll(oldFace, i) forAll(oldFace, i)
{ {
// Add the point // Add the point.
Map<label>::const_iterator mpIter = // Using the mapped point id if possible
pmm.find(oldFace[i]);
if (mpIter == pmm.end()) const label mappedPointi = pmm.lookup(oldFace[i], oldFace[i]);
{
// Point not mapped newFace.append(mappedPointi);
newFace.append(oldFace[i]);
// Add the projected point into the patch support // Add the projected point into the patch support
pointMap().insert pointMap().insert
( (
oldFace[i], // Global label of point mappedPointi, // Global label of point
projectedSlavePoints[oldLocalFace[i]] // Projected position projectedSlavePoints[oldLocalFace[i]] // Projected position
); );
}
else
{
// Point mapped
newFace.append(mpIter());
// Add the projected point into the patch support
pointMap().insert
(
mpIter(), // Merged global label of point
projectedSlavePoints[oldLocalFace[i]] // Projected position
);
}
// Grab the edge points // Grab the edge points
const labelList& slavePointsOnEdge = const labelList& pointsOnEdge =
pointsIntoSlaveEdges[curEdges[i]]; pointsIntoSlaveEdges[curEdges[i]];
// Info<< "slavePointsOnEdge for " // Info<< "slave pointsOnEdge for "
// << curEdges[i] << ": " << slavePointsOnEdge // << curEdges[i] << ": " << pointsOnEdge
// << endl; // << endl;
// If there are no points on the edge, skip everything // If there are no points on the edge, skip everything
// If there is only one point, no need for sorting // If there is only one point, no need for sorting
if (slavePointsOnEdge.size()) if (pointsOnEdge.size())
{ {
// Sort edge points in order // Sort edge points in order
scalarField edgePointWeights(slavePointsOnEdge.size()); scalarField weightOnEdge(pointsOnEdge.size());
const point& startPoint = projectedSlavePoints[oldLocalFace[i]];
vector e = const point& startPoint =
projectedSlavePoints[oldLocalFace.nextLabel(i)] projectedSlavePoints[oldLocalFace[i]];
- startPoint;
scalar magSqrE = magSqr(e); const point& endPoint =
projectedSlavePoints[oldLocalFace.nextLabel(i)];
vector e = (endPoint - startPoint);
const scalar magSqrE = magSqr(e);
if (magSqrE > SMALL) if (magSqrE > SMALL)
{ {
@ -154,27 +143,34 @@ void Foam::enrichedPatch::calcEnrichedFaces
<< abort(FatalError); << abort(FatalError);
} }
pointField slavePosOnEdge(slavePointsOnEdge.size()); pointField positionOnEdge(pointsOnEdge.size());
forAll(slavePointsOnEdge, edgePointi) forAll(pointsOnEdge, edgePointi)
{ {
slavePosOnEdge[edgePointi] = positionOnEdge[edgePointi] =
pointMap().find(slavePointsOnEdge[edgePointi])(); pointMap()[pointsOnEdge[edgePointi]];
edgePointWeights[edgePointi] = weightOnEdge[edgePointi] =
(e & (slavePosOnEdge[edgePointi] - startPoint)); (
e
&
(
positionOnEdge[edgePointi]
- startPoint
)
);
} }
if (debug) if (debug)
{ {
// Check weights: all new points should be on the edge // Check weights: all new points should be on the edge
if (min(edgePointWeights) < 0 || max(edgePointWeights) > 1) if (min(weightOnEdge) < 0 || max(weightOnEdge) > 1)
{ {
FatalErrorInFunction FatalErrorInFunction
<< " not on the edge for edge " << curEdges[i] << " not on the edge for edge " << curEdges[i]
<< " of face " << facei << " in slave patch." << nl << " of face " << facei << " in slave patch." << nl
<< "Min weight: " << min(edgePointWeights) << "Min weight: " << min(weightOnEdge)
<< " Max weight: " << max(edgePointWeights) << " Max weight: " << max(weightOnEdge)
<< abort(FatalError); << abort(FatalError);
} }
} }
@ -182,101 +178,98 @@ void Foam::enrichedPatch::calcEnrichedFaces
// Go through the points and collect them based on // Go through the points and collect them based on
// weights from lower to higher. This gives the // weights from lower to higher. This gives the
// correct order of points along the edge. // correct order of points along the edge.
forAll(edgePointWeights, passI) forAll(weightOnEdge, passI)
{ {
// Max weight can only be one, so the sorting is // Max weight can only be one, so the sorting is
// done by elimination. // done by elimination.
label nextPoint = -1; label nextPoint = -1;
scalar dist = 2; scalar dist = 2;
forAll(edgePointWeights, wI) forAll(weightOnEdge, wI)
{ {
if (edgePointWeights[wI] < dist) if (weightOnEdge[wI] < dist)
{ {
dist = edgePointWeights[wI]; dist = weightOnEdge[wI];
nextPoint = wI; nextPoint = wI;
} }
} }
// Insert the next point and reset its weight to exclude it // Insert the next point and reset its weight to exclude it
// from future picks // from future picks
newFace.append(slavePointsOnEdge[nextPoint]); newFace.append(pointsOnEdge[nextPoint]);
edgePointWeights[nextPoint] = GREAT; weightOnEdge[nextPoint] = GREAT;
// Add the point into patch support // Add the point into patch support
pointMap().insert pointMap().insert
( (
slavePointsOnEdge[nextPoint], pointsOnEdge[nextPoint],
slavePosOnEdge[nextPoint] positionOnEdge[nextPoint]
); );
} }
} }
} }
// Info<< "New slave face " << facei << ": " << newFace << endl;
// Info<< "New slave face[" << facei << "] "
// << flatOutput(newFace) << " was " << flatOutput(oldFace)
// << endl;
// Add the new face to the list // Add the new face to the list
enrichedFaces[nEnrichedFaces].transfer(newFace); enrichedFaces[nEnrichedFaces].transfer(newFace);
nEnrichedFaces++; nEnrichedFaces++;
} }
// Add master faces into the enriched faces list // Add master faces into the enriched faces list
forAll(masterPatch_, facei) forAll(masterPatch_, facei)
{ {
const face& oldFace = masterPatch_[facei]; const face& oldFace = masterPatch_[facei];
const face& oldLocalFace = masterLocalFaces[facei]; const face& oldLocalFace = masterLocalFaces[facei];
// Info<< "old master face: " << oldFace << endl;
const labelList& curEdges = masterFaceEdges[facei]; const labelList& curEdges = masterFaceEdges[facei];
// Info<< "old master face[" << facei << "] " << oldFace << endl;
DynamicList<label> newFace(oldFace.size()*enrichedFaceRatio_); DynamicList<label> newFace(oldFace.size()*enrichedFaceRatio_);
// Note: The number of points and edges in a face is always identical // Note: The number of points and edges in a face is always identical
// so both can be done is the same loop // so both can be done is the same loop
forAll(oldFace, i) forAll(oldFace, i)
{ {
// Add the point // Add the point.
Map<label>::const_iterator mpIter = // Using the mapped point id if possible
pmm.find(oldFace[i]);
if (mpIter == pmm.end()) const label mappedPointi = pmm.lookup(oldFace[i], oldFace[i]);
{
// Point not mapped newFace.append(mappedPointi);
newFace.append(oldFace[i]);
// Add the point into patch support // Add the point into patch support
pointMap().insert pointMap().insert
( (
oldFace[i], mappedPointi, // Global label of point
masterLocalPoints[oldLocalFace[i]] masterLocalPoints[oldLocalFace[i]]
); );
}
else
{
// Point mapped
newFace.append(mpIter());
// Add the point into support
pointMap().insert(mpIter(), masterLocalPoints[oldLocalFace[i]]);
}
// Grab the edge points // Grab the edge points
const labelList& masterPointsOnEdge = const labelList& pointsOnEdge =
pointsIntoMasterEdges[curEdges[i]]; pointsIntoMasterEdges[curEdges[i]];
// If there are no points on the edge, skip everything // If there are no points on the edge, skip everything
// If there is only one point, no need for sorting // If there is only one point, no need for sorting
if (masterPointsOnEdge.size()) if (pointsOnEdge.size())
{ {
// Sort edge points in order // Sort edge points in order
scalarField edgePointWeights(masterPointsOnEdge.size()); scalarField weightOnEdge(pointsOnEdge.size());
const point& startPoint = masterLocalPoints[oldLocalFace[i]];
vector e = const point& startPoint =
masterLocalPoints[oldLocalFace.nextLabel(i)] masterLocalPoints[oldLocalFace[i]];
- startPoint;
scalar magSqrE = magSqr(e); const point& endPoint =
masterLocalPoints[oldLocalFace.nextLabel(i)];
vector e = (endPoint - startPoint);
const scalar magSqrE = magSqr(e);
if (magSqrE > SMALL) if (magSqrE > SMALL)
{ {
@ -290,27 +283,33 @@ void Foam::enrichedPatch::calcEnrichedFaces
<< abort(FatalError); << abort(FatalError);
} }
pointField masterPosOnEdge(masterPointsOnEdge.size()); pointField positionOnEdge(pointsOnEdge.size());
forAll(masterPointsOnEdge, edgePointi) forAll(pointsOnEdge, edgePointi)
{ {
masterPosOnEdge[edgePointi] = positionOnEdge[edgePointi] =
pointMap().find(masterPointsOnEdge[edgePointi])(); pointMap()[pointsOnEdge[edgePointi]];
edgePointWeights[edgePointi] = weightOnEdge[edgePointi] =
(e & (masterPosOnEdge[edgePointi] - startPoint)); (
e
&
(
positionOnEdge[edgePointi] - startPoint
)
);
} }
if (debug) if (debug)
{ {
// Check weights: all new points should be on the edge // Check weights: all new points should be on the edge
if (min(edgePointWeights) < 0 || max(edgePointWeights) > 1) if (min(weightOnEdge) < 0 || max(weightOnEdge) > 1)
{ {
FatalErrorInFunction FatalErrorInFunction
<< " not on the edge for edge " << curEdges[i] << " not on the edge for edge " << curEdges[i]
<< " of face " << facei << " in master patch." << nl << " of face " << facei << " in master patch." << nl
<< "Min weight: " << min(edgePointWeights) << "Min weight: " << min(weightOnEdge)
<< " Max weight: " << max(edgePointWeights) << " Max weight: " << max(weightOnEdge)
<< abort(FatalError); << abort(FatalError);
} }
} }
@ -318,37 +317,40 @@ void Foam::enrichedPatch::calcEnrichedFaces
// Go through the points and collect them based on // Go through the points and collect them based on
// weights from lower to higher. This gives the // weights from lower to higher. This gives the
// correct order of points along the edge. // correct order of points along the edge.
forAll(edgePointWeights, passI) forAll(weightOnEdge, passI)
{ {
// Max weight can only be one, so the sorting is // Max weight can only be one, so the sorting is
// done by elimination. // done by elimination.
label nextPoint = -1; label nextPoint = -1;
scalar dist = 2; scalar dist = 2;
forAll(edgePointWeights, wI) forAll(weightOnEdge, wI)
{ {
if (edgePointWeights[wI] < dist) if (weightOnEdge[wI] < dist)
{ {
dist = edgePointWeights[wI]; dist = weightOnEdge[wI];
nextPoint = wI; nextPoint = wI;
} }
} }
// Insert the next point and reset its weight to exclude it // Insert the next point and reset its weight to exclude it
// from future picks // from future picks
newFace.append(masterPointsOnEdge[nextPoint]); newFace.append(pointsOnEdge[nextPoint]);
edgePointWeights[nextPoint] = GREAT; weightOnEdge[nextPoint] = GREAT;
// Add the point into patch support // Add the point into patch support
pointMap().insert pointMap().insert
( (
masterPointsOnEdge[nextPoint], pointsOnEdge[nextPoint],
masterPosOnEdge[nextPoint] positionOnEdge[nextPoint]
); );
} }
} }
} }
// Info<< "New master face: " << newFace << endl;
// Info<< "New master face[" << facei << "] "
// << flatOutput(newFace) << " was " << flatOutput(oldFace)
// << endl;
// Add the new face to the list // Add the new face to the list
enrichedFaces[nEnrichedFaces].transfer(newFace); enrichedFaces[nEnrichedFaces].transfer(newFace);

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::Map<Foam::point>& Foam::enrichedPatch::pointMap() const
{
if (!pointMapComplete_)
{
completePointMap();
}
return pointMap_;
}
inline Foam::Map<Foam::point>& Foam::enrichedPatch::pointMap()
{
if (!pointMapComplete_)
{
completePointMap();
}
return pointMap_;
}
inline const Foam::Map<Foam::label>& Foam::enrichedPatch::pointMergeMap() const
{
return pointMergeMap_;
}
inline Foam::Map<Foam::label>& Foam::enrichedPatch::pointMergeMap()
{
return pointMergeMap_;
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -32,6 +32,7 @@ License
const Foam::label Foam::enrichedPatch::nFaceHits_ = 4; const Foam::label Foam::enrichedPatch::nFaceHits_ = 4;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::enrichedPatch::calcMasterPointFaces() const void Foam::enrichedPatch::calcMasterPointFaces() const
@ -51,7 +52,7 @@ void Foam::enrichedPatch::calcMasterPointFaces() const
// Master face points lists the points of the enriched master face plus // Master face points lists the points of the enriched master face plus
// points projected into the master face // points projected into the master face
Map<DynamicList<label>> mpf(meshPoints().size()); Map<DynamicList<label>> mpf(2*meshPoints().size());
const faceList& ef = enrichedFaces(); const faceList& ef = enrichedFaces();
@ -59,28 +60,14 @@ void Foam::enrichedPatch::calcMasterPointFaces() const
forAll(masterPatch_, facei) forAll(masterPatch_, facei)
{ {
const face& curFace = ef[facei + slavePatch_.size()]; const face& curFace = ef[facei + slavePatch_.size()];
// Pout<< "Cur face in pfAddr: " << curFace << endl;
forAll(curFace, pointi)
{
Map<DynamicList<label>>::iterator mpfIter =
mpf.find(curFace[pointi]);
if (mpfIter == mpf.end()) for (const label pointi : curFace)
{ {
// Not found, add new dynamic list DynamicList<label>& dynLst = mpf(pointi); // Get or create
mpf.insert
(
curFace[pointi],
DynamicList<label>(primitiveMesh::facesPerPoint_)
);
// Iterator is invalidated - have to find again dynLst.reserve(primitiveMesh::facesPerPoint_); // Min size for list
mpf.find(curFace[pointi])().append(facei);
} dynLst.append(facei);
else
{
mpfIter().append(facei);
}
} }
} }
@ -96,50 +83,27 @@ void Foam::enrichedPatch::calcMasterPointFaces() const
&& slavePointFaceHits_[pointi].hit() && slavePointFaceHits_[pointi].hit()
) )
{ {
// Get the index of projected point corresponding to this slave // Index of projected point corresponding to this slave point
// point const label mergedPointi = pointMergeMap()[slaveMeshPoints[pointi]];
const label mergedSmp =
pointMergeMap().find(slaveMeshPoints[pointi])();
Map<DynamicList<label>>::iterator mpfIter = DynamicList<label>& dynLst = mpf(mergedPointi); // Get or create
mpf.find(mergedSmp);
if (mpfIter == mpf.end()) dynLst.reserve(primitiveMesh::facesPerPoint_); // Min size for list
{
// Not found, add new dynamic list
mpf.insert
(
mergedSmp,
DynamicList<label>(primitiveMesh::facesPerPoint_)
);
// Iterator is invalidated - have to find again dynLst.append(slavePointFaceHits_[pointi].hitObject());
mpf.find(mergedSmp)().append
(
slavePointFaceHits_[pointi].hitObject()
);
}
else
{
mpfIter().append(slavePointFaceHits_[pointi].hitObject());
}
} }
} }
// Re-pack dynamic lists into normal lists // Re-pack dynamic lists into normal lists
const labelList mpfToc = mpf.toc();
masterPointFacesPtr_ = new Map<labelList>(2*mpfToc.size()); masterPointFacesPtr_ = new Map<labelList>(2*mpf.size());
Map<labelList>& masterPointFaceAddr = *masterPointFacesPtr_; Map<labelList>& masterPointFaceMap = *masterPointFacesPtr_;
forAll(mpfToc, mpfTocI) forAllIters(mpf, mpfIter)
{ {
labelList l; masterPointFaceMap(mpfIter.key()).transfer(mpfIter.object());
l.transfer(mpf.find(mpfToc[mpfTocI])());
masterPointFaceAddr.insert(mpfToc[mpfTocI], l);
} }
// Pout<< "masterPointFaceAddr: " << masterPointFaceAddr << endl; // Pout<< "masterPointFaceMap: " << masterPointFaceMap << endl;
} }

View File

@ -40,8 +40,8 @@ void Foam::enrichedPatch::completePointMap() const
const Map<label>& pmm = pointMergeMap(); const Map<label>& pmm = pointMergeMap();
// Get the mesh points for both patches. If the point has not been // Get the mesh points for both patches.
// merged away, add it to the map // If the point has not been merged away, add it to the map
// Do master patch // Do master patch
const labelList& masterMeshPoints = masterPatch_.meshPoints(); const labelList& masterMeshPoints = masterPatch_.meshPoints();
@ -77,29 +77,4 @@ void Foam::enrichedPatch::completePointMap() const
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::Map<Foam::point>& Foam::enrichedPatch::pointMap()
{
if (!pointMapComplete_)
{
completePointMap();
}
return pointMap_;
}
const Foam::Map<Foam::point>& Foam::enrichedPatch::pointMap() const
{
if (!pointMapComplete_)
{
completePointMap();
}
return pointMap_;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,9 +27,6 @@ License
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "DynamicList.H" #include "DynamicList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::enrichedPatch::calcPointPoints() const void Foam::enrichedPatch::calcPointPoints() const
@ -52,16 +49,14 @@ void Foam::enrichedPatch::calcPointPoints() const
bool found = false; bool found = false;
forAll(lf, facei) for (const face& curFace : lf)
{ {
const face& curFace = lf[facei];
forAll(curFace, pointi) forAll(curFace, pointi)
{ {
DynamicList<label>& curPp = pp[curFace[pointi]]; DynamicList<label>& curPp = pp[curFace[pointi]];
// Do next label // Do next label
label next = curFace.nextLabel(pointi); const label next = curFace.nextLabel(pointi);
found = false; found = false;
@ -80,7 +75,7 @@ void Foam::enrichedPatch::calcPointPoints() const
} }
// Do previous label // Do previous label
label prev = curFace.prevLabel(pointi); const label prev = curFace.prevLabel(pointi);
found = false; found = false;
forAll(curPp, i) forAll(curPp, i)

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -34,7 +34,7 @@ void Foam::slidingInterface::calcAttachedAddressing() const
{ {
if (debug) if (debug)
{ {
Pout<< "void Foam::slidingInterface::calcAttachedAddressing() const " Pout<< FUNCTION_NAME
<< " for object " << name() << " : " << " for object " << name() << " : "
<< "Calculating zone face-cell addressing." << "Calculating zone face-cell addressing."
<< endl; << endl;
@ -140,64 +140,85 @@ void Foam::slidingInterface::calcAttachedAddressing() const
// Calculate stick-out faces // Calculate stick-out faces
const labelListList& pointFaces = mesh.pointFaces(); const labelListList& pointFaces = mesh.pointFaces();
// Master side labelHashSet stickOutFaceMap
labelHashSet masterStickOutFaceMap
( (
primitiveMesh::facesPerCell_*(masterPatch.size()) primitiveMesh::facesPerCell_
* max(masterPatch.size(), slavePatch.size())
); );
// Master side
const labelList& masterMeshPoints = masterPatch.meshPoints(); const labelList& masterMeshPoints = masterPatch.meshPoints();
forAll(masterMeshPoints, pointi) stickOutFaceMap.clear();
{
const labelList& curFaces = pointFaces[masterMeshPoints[pointi]];
forAll(curFaces, facei) for (const label pointi : masterMeshPoints)
{ {
// Check if the face belongs to the master face zone; for (const label facei : pointFaces[pointi])
// if not add it {
const label zoneIdx = faceZones.whichZone(facei);
// Add if face not already part of master or slave face zone
// This handles partially attached faces.
if if
( (
faceZones.whichZone(curFaces[facei]) zoneIdx != masterFaceZoneID_.index()
!= masterFaceZoneID_.index() && zoneIdx != slaveFaceZoneID_.index()
) )
{ {
masterStickOutFaceMap.insert(curFaces[facei]); stickOutFaceMap.insert(facei);
} }
} }
} }
masterStickOutFacesPtr_ = new labelList(masterStickOutFaceMap.toc()); // Sort in debug mode for easier diagnostics
if (debug)
{
masterStickOutFacesPtr_ =
new labelList(std::move(stickOutFaceMap.sortedToc()));
}
else
{
masterStickOutFacesPtr_ =
new labelList(std::move(stickOutFaceMap.toc()));
}
// Slave side // Slave side
labelHashSet slaveStickOutFaceMap
(
primitiveMesh::facesPerCell_*(slavePatch.size())
);
const labelList& slaveMeshPoints = slavePatch.meshPoints(); const labelList& slaveMeshPoints = slavePatch.meshPoints();
forAll(slaveMeshPoints, pointi) stickOutFaceMap.clear();
{
const labelList& curFaces = pointFaces[slaveMeshPoints[pointi]];
forAll(curFaces, facei) for (const label pointi : slaveMeshPoints)
{ {
// Check if the face belongs to the slave face zone; for (const label facei : pointFaces[pointi])
// if not add it {
const label zoneIdx = faceZones.whichZone(facei);
// Add if face not already part of master or slave face zone
// This handles partially attached faces.
if if
( (
faceZones.whichZone(curFaces[facei]) zoneIdx != masterFaceZoneID_.index()
!= slaveFaceZoneID_.index() && zoneIdx != slaveFaceZoneID_.index()
) )
{ {
slaveStickOutFaceMap.insert(curFaces[facei]); stickOutFaceMap.insert(facei);
} }
} }
} }
slaveStickOutFacesPtr_ = new labelList(slaveStickOutFaceMap.toc()); // Sort in debug mode for easier diagnostics
if (debug)
{
slaveStickOutFacesPtr_ =
new labelList(std::move(stickOutFaceMap.sortedToc()));
}
else
{
slaveStickOutFacesPtr_ =
new labelList(std::move(stickOutFaceMap.toc()));
}
stickOutFaceMap.clear();
// Retired point addressing does not exist at this stage. // Retired point addressing does not exist at this stage.
// It will be filled when the interface is coupled. // It will be filled when the interface is coupled.
@ -208,7 +229,6 @@ void Foam::slidingInterface::calcAttachedAddressing() const
); );
// Ditto for cut point edge map. This is a rough guess of its size // Ditto for cut point edge map. This is a rough guess of its size
//
cutPointEdgePairMapPtr_ = cutPointEdgePairMapPtr_ =
new Map<Pair<edge>> new Map<Pair<edge>>
( (
@ -224,7 +244,7 @@ void Foam::slidingInterface::calcAttachedAddressing() const
if (debug) if (debug)
{ {
Pout<< "void Foam::slidingInterface::calcAttachedAddressing() const " Pout<< FUNCTION_NAME
<< " for object " << name() << " : " << " for object " << name() << " : "
<< "Finished calculating zone face-cell addressing." << "Finished calculating zone face-cell addressing."
<< endl; << endl;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -58,8 +58,8 @@ bool Foam::slidingInterface::projectPoints() const
{ {
if (debug) if (debug)
{ {
Pout<< "bool slidingInterface::projectPoints() : " Pout<< FUNCTION_NAME << nl
<< " for object " << name() << " : " << ": for object " << name() << " : "
<< "Projecting slave points onto master surface." << endl; << "Projecting slave points onto master surface." << endl;
} }
@ -126,12 +126,11 @@ bool Foam::slidingInterface::projectPoints() const
scalarField minMasterPointLength(masterLocalPoints.size(), GREAT); scalarField minMasterPointLength(masterLocalPoints.size(), GREAT);
scalarField minMasterFaceLength(masterPatch.size(), GREAT); scalarField minMasterFaceLength(masterPatch.size(), GREAT);
forAll(masterEdges, edgeI) forAll(masterEdges, edgei)
{ {
const edge& curEdge = masterEdges[edgeI]; const edge& curEdge = masterEdges[edgei];
const scalar curLength = const scalar curLength = curEdge.mag(masterLocalPoints);
masterEdges[edgeI].mag(masterLocalPoints);
// Do points // Do points
minMasterPointLength[curEdge.start()] = minMasterPointLength[curEdge.start()] =
@ -149,14 +148,14 @@ bool Foam::slidingInterface::projectPoints() const
); );
// Do faces // Do faces
const labelList& curFaces = masterEdgeFaces[edgeI]; const labelList& curFaces = masterEdgeFaces[edgei];
forAll(curFaces, facei) for (const label facei : curFaces)
{ {
minMasterFaceLength[curFaces[facei]] = minMasterFaceLength[facei] =
min min
( (
minMasterFaceLength[curFaces[facei]], minMasterFaceLength[facei],
curLength curLength
); );
} }
@ -169,12 +168,11 @@ bool Foam::slidingInterface::projectPoints() const
scalarField minSlavePointLength(slaveLocalPoints.size(), GREAT); scalarField minSlavePointLength(slaveLocalPoints.size(), GREAT);
scalarField minSlaveFaceLength(slavePatch.size(), GREAT); scalarField minSlaveFaceLength(slavePatch.size(), GREAT);
forAll(slaveEdges, edgeI) forAll(slaveEdges, edgei)
{ {
const edge& curEdge = slaveEdges[edgeI]; const edge& curEdge = slaveEdges[edgei];
const scalar curLength = const scalar curLength = curEdge.mag(slaveLocalPoints);
slaveEdges[edgeI].mag(slaveLocalPoints);
// Do points // Do points
minSlavePointLength[curEdge.start()] = minSlavePointLength[curEdge.start()] =
@ -192,14 +190,14 @@ bool Foam::slidingInterface::projectPoints() const
); );
// Do faces // Do faces
const labelList& curFaces = slaveEdgeFaces[edgeI]; const labelList& curFaces = slaveEdgeFaces[edgei];
forAll(curFaces, facei) for (const label facei : curFaces)
{ {
minSlaveFaceLength[curFaces[facei]] = minSlaveFaceLength[facei] =
min min
( (
minSlaveFaceLength[curFaces[facei]], minSlaveFaceLength[facei],
curLength curLength
); );
} }
@ -219,25 +217,15 @@ bool Foam::slidingInterface::projectPoints() const
projectionAlgo_ projectionAlgo_
); );
// Pout<< "USING N-SQUARED!!!" << endl;
// List<objectHit> slavePointFaceHits =
// projectPointsNSquared<face, List, const pointField&>
// (
// slavePatch,
// masterPatch,
// slavePointNormals,
// projectionAlgo_
// );
if (debug) if (debug)
{ {
label nHits = 0; label nHits = 0;
forAll(slavePointFaceHits, pointi) for (const auto& hit : slavePointFaceHits)
{ {
if (slavePointFaceHits[pointi].hit()) if (hit.hit())
{ {
nHits++; ++nHits;
} }
} }
@ -247,8 +235,7 @@ bool Foam::slidingInterface::projectPoints() const
} }
// Projected slave points are stored for mesh motion correction // Projected slave points are stored for mesh motion correction
if (projectedSlavePointsPtr_) delete projectedSlavePointsPtr_; deleteDemandDrivenData(projectedSlavePointsPtr_);
projectedSlavePointsPtr_ = projectedSlavePointsPtr_ =
new pointField(slavePointFaceHits.size(), Zero); new pointField(slavePointFaceHits.size(), Zero);
pointField& projectedSlavePoints = *projectedSlavePointsPtr_; pointField& projectedSlavePoints = *projectedSlavePointsPtr_;
@ -380,29 +367,27 @@ bool Foam::slidingInterface::projectPoints() const
// Check for zero-length edges in slave projection // Check for zero-length edges in slave projection
scalar minEdgeLength = GREAT; scalar minEdgeLength = GREAT;
scalar el = 0;
label nShortEdges = 0; label nShortEdges = 0;
forAll(slaveEdges, edgeI) for (const edge& e : slaveEdges)
{ {
el = slaveEdges[edgeI].mag(projectedSlavePoints); const scalar len = e.mag(projectedSlavePoints);
minEdgeLength = min(minEdgeLength, len);
if (el < SMALL) if (len < SMALL)
{ {
Pout<< "Point projection problems for edge: " Pout<< "Point projection problems for edge: "
<< slaveEdges[edgeI] << ". Length = " << el << e << ". Length = " << len
<< endl; << endl;
nShortEdges++; nShortEdges++;
} }
minEdgeLength = min(minEdgeLength, el);
} }
if (nShortEdges > 0) if (nShortEdges > 0)
{ {
FatalErrorInFunction FatalErrorInFunction
<< " short projected edges " << nShortEdges << " short projected edges "
<< "after adjustment for object " << name() << "after adjustment for object " << name()
<< abort(FatalError); << abort(FatalError);
} }
@ -439,10 +424,10 @@ bool Foam::slidingInterface::projectPoints() const
{ {
if (slavePointFaceHits[pointi].hit()) if (slavePointFaceHits[pointi].hit())
{ {
// Taking a non-const reference so the point can be adjusted // Use non-const reference so the point can be adjusted
point& curPoint = projectedSlavePoints[pointi]; point& curPoint = projectedSlavePoints[pointi];
// Get the hit face // Get the hit face (on master)
const face& hitFace = const face& hitFace =
masterLocalFaces[slavePointFaceHits[pointi].hitObject()]; masterLocalFaces[slavePointFaceHits[pointi].hitObject()];
@ -450,10 +435,10 @@ bool Foam::slidingInterface::projectPoints() const
scalar mergeDist = GREAT; scalar mergeDist = GREAT;
// Try all point before deciding on best fit. // Try all point before deciding on best fit.
forAll(hitFace, hitPointi) for (const label hitPointi : hitFace)
{ {
scalar dist = const scalar dist =
mag(masterLocalPoints[hitFace[hitPointi]] - curPoint); mag(masterLocalPoints[hitPointi] - curPoint);
// Calculate the tolerance // Calculate the tolerance
const scalar mergeTol = const scalar mergeTol =
@ -461,12 +446,12 @@ bool Foam::slidingInterface::projectPoints() const
min min
( (
minSlavePointLength[pointi], minSlavePointLength[pointi],
minMasterPointLength[hitFace[hitPointi]] minMasterPointLength[hitPointi]
); );
if (dist < mergeTol && dist < mergeDist) if (dist < mergeTol && dist < mergeDist)
{ {
mergePoint = hitFace[hitPointi]; mergePoint = hitPointi;
mergeDist = dist; mergeDist = dist;
// Pout<< "Merging slave point " // Pout<< "Merging slave point "
@ -481,12 +466,17 @@ bool Foam::slidingInterface::projectPoints() const
if (mergePoint > -1) if (mergePoint > -1)
{ {
// Point is to be merged with master point // Slave point is to be merged with master point.
// This may also include a false positive when the two points
// already point to the same global point, but this will need
// to be addressed by the caller.
nMergedPoints++; nMergedPoints++;
slavePointPointHits[pointi] = mergePoint; slavePointPointHits[pointi] = mergePoint;
curPoint = masterLocalPoints[mergePoint];
masterPointPointHits[mergePoint] = pointi; masterPointPointHits[mergePoint] = pointi;
// Adjust (snap) slave point
curPoint = masterLocalPoints[mergePoint];
} }
} }
} }
@ -498,20 +488,18 @@ bool Foam::slidingInterface::projectPoints() const
{ {
// Check for zero-length edges in slave projection // Check for zero-length edges in slave projection
scalar minEdgeLength = GREAT; scalar minEdgeLength = GREAT;
scalar el = 0;
forAll(slaveEdges, edgeI) for (const edge& e : slaveEdges)
{ {
el = slaveEdges[edgeI].mag(projectedSlavePoints); const scalar len = e.mag(projectedSlavePoints);
minEdgeLength = min(minEdgeLength, len);
if (el < SMALL) if (len < SMALL)
{ {
Pout<< "Point projection problems for edge: " Pout<< "Point projection problems for edge: "
<< slaveEdges[edgeI] << ". Length = " << el << e << ". Length = " << len
<< endl; << endl;
} }
minEdgeLength = min(minEdgeLength, el);
} }
if (minEdgeLength < SMALL) if (minEdgeLength < SMALL)
@ -556,16 +544,16 @@ bool Foam::slidingInterface::projectPoints() const
scalar minDistance = GREAT; scalar minDistance = GREAT;
forAll(hitFaceEdges, edgeI) for (const label edgei : hitFaceEdges)
{ {
const edge& curEdge = masterEdges[hitFaceEdges[edgeI]]; const edge& curEdge = masterEdges[edgei];
pointHit edgeHit = pointHit edgeHit =
curEdge.line(masterLocalPoints).nearestDist(curPoint); curEdge.line(masterLocalPoints).nearestDist(curPoint);
if (edgeHit.hit()) if (edgeHit.hit())
{ {
scalar dist = const scalar dist =
mag(edgeHit.hitPoint() - projectedSlavePoints[pointi]); mag(edgeHit.hitPoint() - projectedSlavePoints[pointi]);
if (dist < mergeTol && dist < minDistance) if (dist < mergeTol && dist < minDistance)
@ -573,7 +561,7 @@ bool Foam::slidingInterface::projectPoints() const
// Point is to be moved onto master edge // Point is to be moved onto master edge
nMovedPoints++; nMovedPoints++;
slavePointEdgeHits[pointi] = hitFaceEdges[edgeI]; slavePointEdgeHits[pointi] = edgei;
projectedSlavePoints[pointi] = edgeHit.hitPoint(); projectedSlavePoints[pointi] = edgeHit.hitPoint();
minDistance = dist; minDistance = dist;
@ -582,7 +570,7 @@ bool Foam::slidingInterface::projectPoints() const
// << slavePatch.meshPoints()[pointi] // << slavePatch.meshPoints()[pointi]
// << " (" << pointi // << " (" << pointi
// << ") at " << slaveLocalPoints[pointi] // << ") at " << slaveLocalPoints[pointi]
// << " onto master edge " << hitFaceEdges[edgeI] // << " onto master edge " << edgei
// << " or (" // << " or ("
// << masterLocalPoints[curEdge.start()] // << masterLocalPoints[curEdge.start()]
// << masterLocalPoints[curEdge.end()] // << masterLocalPoints[curEdge.end()]
@ -607,7 +595,7 @@ bool Foam::slidingInterface::projectPoints() const
forAll(hitMasterEdge, hmeI) forAll(hitMasterEdge, hmeI)
{ {
scalar hmeDist = const scalar hmeDist =
mag(masterLocalPoints[hitMasterEdge[hmeI]] - curPoint); mag(masterLocalPoints[hitMasterEdge[hmeI]] - curPoint);
// Calculate the tolerance // Calculate the tolerance
@ -660,20 +648,18 @@ bool Foam::slidingInterface::projectPoints() const
// Check for zero-length edges in slave projection // Check for zero-length edges in slave projection
scalar minEdgeLength = GREAT; scalar minEdgeLength = GREAT;
scalar el = 0;
forAll(slaveEdges, edgeI) for (const edge& e : slaveEdges)
{ {
el = slaveEdges[edgeI].mag(projectedSlavePoints); const scalar len = e.mag(projectedSlavePoints);
minEdgeLength = min(minEdgeLength, len);
if (el < SMALL) if (len < SMALL)
{ {
Pout<< "Point projection problems for edge: " Pout<< "Point projection problems for edge: "
<< slaveEdges[edgeI] << ". Length = " << el << e << ". Length = " << len
<< endl; << endl;
} }
minEdgeLength = min(minEdgeLength, el);
} }
if (minEdgeLength < SMALL) if (minEdgeLength < SMALL)
@ -747,25 +733,19 @@ bool Foam::slidingInterface::projectPoints() const
labelHashSet addedFaces(2*primitiveMesh::edgesPerFace_); labelHashSet addedFaces(2*primitiveMesh::edgesPerFace_);
forAll(slaveEdges, edgeI) forAll(slaveEdges, edgei)
{ {
const edge& curEdge = slaveEdges[edgeI]; const edge& curEdge = slaveEdges[edgei];
{ {
// Clear the maps
curFaceMap.clear();
addedFaces.clear();
// Grab the faces for start and end points // Grab the faces for start and end points
const label startFace = const label startFace =
slavePointFaceHits[curEdge.start()].hitObject(); slavePointFaceHits[curEdge.start()].hitObject();
const label endFace = slavePointFaceHits[curEdge.end()].hitObject();
// Insert the start face into the list const label endFace =
curFaceMap.insert(startFace); slavePointFaceHits[curEdge.end()].hitObject();
addedFaces.insert(startFace);
// Pout<< "Doing edge " << edgeI // Pout<< "Doing edge " << edgei
// << " or " << curEdge // << " or " << curEdge
// << " start: " // << " start: "
// << slavePointFaceHits[curEdge.start()].hitObject() // << slavePointFaceHits[curEdge.start()].hitObject()
@ -774,32 +754,42 @@ bool Foam::slidingInterface::projectPoints() const
// << endl; // << endl;
// If the end face is on the list, the face collection is finished // If the end face is on the list, the face collection is finished
label nSweeps = 0;
bool completed = false; bool completed = false;
while (nSweeps < edgeFaceEscapeLimit_) if (!completed)
{ {
nSweeps++; // Forward sweep
if (addedFaces.found(endFace)) // Clear the maps
{ curFaceMap.clear();
completed = true;
}
// Add all face neighbours of face in the map
const labelList cf = addedFaces.toc();
addedFaces.clear(); addedFaces.clear();
forAll(cf, cfI) // Insert the start face into the list
{ curFaceMap.insert(startFace);
const labelList& curNbrs = masterFaceFaces[cf[cfI]]; addedFaces.insert(startFace);
forAll(curNbrs, nbrI) for
(
label nSweeps = 0;
nSweeps < edgeFaceEscapeLimit_;
++nSweeps
)
{ {
if (!curFaceMap.found(curNbrs[nbrI])) completed = addedFaces.found(endFace);
// Add all face neighbours of face in the map
const labelList cf(std::move(addedFaces.toc()));
addedFaces.clear();
for (const label cfi : cf)
{ {
curFaceMap.insert(curNbrs[nbrI]); const labelList& curNbrs = masterFaceFaces[cfi];
addedFaces.insert(curNbrs[nbrI]);
for (const label nbri : curNbrs)
{
if (curFaceMap.insert(nbri))
{
addedFaces.insert(nbri);
} }
} }
} }
@ -811,9 +801,12 @@ bool Foam::slidingInterface::projectPoints() const
Pout<< "."; Pout<< ".";
} }
} }
}
if (!completed) if (!completed)
{ {
// Reverse sweep
if (debug) if (debug)
{ {
Pout<< "x"; Pout<< "x";
@ -822,35 +815,32 @@ bool Foam::slidingInterface::projectPoints() const
// It is impossible to reach the end from the start, probably // It is impossible to reach the end from the start, probably
// due to disconnected domain. Do search in opposite direction // due to disconnected domain. Do search in opposite direction
label nReverseSweeps = 0;
addedFaces.clear(); addedFaces.clear();
curFaceMap.insert(endFace); curFaceMap.insert(endFace);
addedFaces.insert(endFace); addedFaces.insert(endFace);
while (nReverseSweeps < edgeFaceEscapeLimit_) for
(
label nSweeps = 0;
nSweeps < edgeFaceEscapeLimit_;
++nSweeps
)
{ {
nReverseSweeps++; completed = addedFaces.found(startFace);
if (addedFaces.found(startFace))
{
completed = true;
}
// Add all face neighbours of face in the map // Add all face neighbours of face in the map
const labelList cf = addedFaces.toc(); const labelList cf(std::move(addedFaces.toc()));
addedFaces.clear(); addedFaces.clear();
forAll(cf, cfI) for (const label cfi : cf)
{ {
const labelList& curNbrs = masterFaceFaces[cf[cfI]]; const labelList& curNbrs = masterFaceFaces[cfi];
forAll(curNbrs, nbrI) for (const label nbri : curNbrs)
{ {
if (!curFaceMap.found(curNbrs[nbrI])) if (curFaceMap.insert(nbri))
{ {
curFaceMap.insert(curNbrs[nbrI]); addedFaces.insert(nbri);
addedFaces.insert(curNbrs[nbrI]);
} }
} }
} }
@ -887,16 +877,11 @@ bool Foam::slidingInterface::projectPoints() const
nFacesPerSlaveEdge_*primitiveMesh::pointsPerFace_ nFacesPerSlaveEdge_*primitiveMesh::pointsPerFace_
); );
const labelList curFaces = curFaceMap.toc(); for (const label facei : curFaceMap)
// Pout<< "curFaces: " << curFaces << endl;
forAll(curFaces, facei)
{ {
const face& f = masterLocalFaces[curFaces[facei]]; const face& f = masterLocalFaces[facei];
forAll(f, pointi) curPointMap.insert(f); // Insert all face points
{
curPointMap.insert(f[pointi]);
}
} }
const labelList curMasterPoints = curPointMap.toc(); const labelList curMasterPoints = curPointMap.toc();
@ -912,7 +897,7 @@ bool Foam::slidingInterface::projectPoints() const
// is used to reject master points out of reach. // is used to reject master points out of reach.
// Calculated as a combination of travel distance in projection and // Calculated as a combination of travel distance in projection and
// edge length // edge length
scalar slaveCatchDist = const scalar slaveCatchDist =
edgeMasterCatchFraction_*edgeMag edgeMasterCatchFraction_*edgeMag
+ 0.5* + 0.5*
( (
@ -945,10 +930,8 @@ bool Foam::slidingInterface::projectPoints() const
edgeNormalInPlane /= mag(edgeNormalInPlane); edgeNormalInPlane /= mag(edgeNormalInPlane);
forAll(curMasterPoints, pointi) for (const label cmp : curMasterPoints)
{ {
const label cmp = curMasterPoints[pointi];
// Skip the current point if the edge start or end has // Skip the current point if the edge start or end has
// been adjusted onto in // been adjusted onto in
if if
@ -974,11 +957,11 @@ bool Foam::slidingInterface::projectPoints() const
// Strict checking of slave cut to avoid capturing // Strict checking of slave cut to avoid capturing
// end points. // end points.
scalar cutOnSlave = const scalar cutOnSlave =
((edgeLineHit.hitPoint() - edgeLine.start()) & edgeVec) ((edgeLineHit.hitPoint() - edgeLine.start()) & edgeVec)
/sqr(edgeMag); /sqr(edgeMag);
scalar distInEdgePlane = const scalar distInEdgePlane =
min min
( (
edgeLineHit.distance(), edgeLineHit.distance(),
@ -1032,14 +1015,14 @@ bool Foam::slidingInterface::projectPoints() const
} }
// Snap to point onto edge // Snap to point onto edge
masterPointEdgeHits[cmp] = edgeI; masterPointEdgeHits[cmp] = edgei;
masterPointEdgeDist[cmp] = edgeLineHit.distance(); masterPointEdgeDist[cmp] = edgeLineHit.distance();
// Pout<< "Inserting master point " // Pout<< "Inserting master point "
// << masterPatch.meshPoints()[cmp] // << masterPatch.meshPoints()[cmp]
// << " (" << cmp // << " (" << cmp
// << ") at " << masterLocalPoints[cmp] // << ") at " << masterLocalPoints[cmp]
// << " into slave edge " << edgeI // << " into slave edge " << edgei
// << " " << curEdge // << " " << curEdge
// << " cutOnSlave: " << cutOnSlave // << " cutOnSlave: " << cutOnSlave
// << " distInEdgePlane: " << distInEdgePlane // << " distInEdgePlane: " << distInEdgePlane
@ -1096,16 +1079,20 @@ bool Foam::slidingInterface::projectPoints() const
// Store the addressing arrays and projected points // Store the addressing arrays and projected points
deleteDemandDrivenData(slavePointPointHitsPtr_); deleteDemandDrivenData(slavePointPointHitsPtr_);
slavePointPointHitsPtr_ = new labelList(slavePointPointHits); slavePointPointHitsPtr_ = new labelList();
slavePointPointHitsPtr_->transfer(slavePointPointHits);
deleteDemandDrivenData(slavePointEdgeHitsPtr_); deleteDemandDrivenData(slavePointEdgeHitsPtr_);
slavePointEdgeHitsPtr_ = new labelList(slavePointEdgeHits); slavePointEdgeHitsPtr_ = new labelList();
slavePointEdgeHitsPtr_->transfer(slavePointEdgeHits);
deleteDemandDrivenData(slavePointFaceHitsPtr_); deleteDemandDrivenData(slavePointFaceHitsPtr_);
slavePointFaceHitsPtr_ = new List<objectHit>(slavePointFaceHits); slavePointFaceHitsPtr_ = new List<objectHit>();
slavePointFaceHitsPtr_->transfer(slavePointFaceHits);
deleteDemandDrivenData(masterPointEdgeHitsPtr_); deleteDemandDrivenData(masterPointEdgeHitsPtr_);
masterPointEdgeHitsPtr_ = new labelList(masterPointEdgeHits); masterPointEdgeHitsPtr_ = new labelList();
masterPointEdgeHitsPtr_->transfer(masterPointEdgeHits);
if (debug) if (debug)
{ {
@ -1128,16 +1115,20 @@ bool Foam::slidingInterface::projectPoints() const
{ {
// Must be restart. Force topological change. // Must be restart. Force topological change.
deleteDemandDrivenData(slavePointPointHitsPtr_); deleteDemandDrivenData(slavePointPointHitsPtr_);
slavePointPointHitsPtr_ = new labelList(slavePointPointHits); slavePointPointHitsPtr_ = new labelList();
slavePointPointHitsPtr_->transfer(slavePointPointHits);
deleteDemandDrivenData(slavePointEdgeHitsPtr_); deleteDemandDrivenData(slavePointEdgeHitsPtr_);
slavePointEdgeHitsPtr_ = new labelList(slavePointEdgeHits); slavePointEdgeHitsPtr_ = new labelList();
slavePointEdgeHitsPtr_->transfer(slavePointEdgeHits);
deleteDemandDrivenData(slavePointFaceHitsPtr_); deleteDemandDrivenData(slavePointFaceHitsPtr_);
slavePointFaceHitsPtr_ = new List<objectHit>(slavePointFaceHits); slavePointFaceHitsPtr_ = new List<objectHit>();
slavePointFaceHitsPtr_->transfer(slavePointFaceHits);
deleteDemandDrivenData(masterPointEdgeHitsPtr_); deleteDemandDrivenData(masterPointEdgeHitsPtr_);
masterPointEdgeHitsPtr_ = new labelList(masterPointEdgeHits); masterPointEdgeHitsPtr_ = new labelList();
masterPointEdgeHitsPtr_->transfer(masterPointEdgeHits);
if (debug) if (debug)
{ {
@ -1218,16 +1209,20 @@ bool Foam::slidingInterface::projectPoints() const
{ {
// Grab new data // Grab new data
deleteDemandDrivenData(slavePointPointHitsPtr_); deleteDemandDrivenData(slavePointPointHitsPtr_);
slavePointPointHitsPtr_ = new labelList(slavePointPointHits); slavePointPointHitsPtr_ = new labelList();
slavePointPointHitsPtr_->transfer(slavePointPointHits);
deleteDemandDrivenData(slavePointEdgeHitsPtr_); deleteDemandDrivenData(slavePointEdgeHitsPtr_);
slavePointEdgeHitsPtr_ = new labelList(slavePointEdgeHits); slavePointEdgeHitsPtr_ = new labelList();
slavePointEdgeHitsPtr_->transfer(slavePointEdgeHits);
deleteDemandDrivenData(slavePointFaceHitsPtr_); deleteDemandDrivenData(slavePointFaceHitsPtr_);
slavePointFaceHitsPtr_ = new List<objectHit>(slavePointFaceHits); slavePointFaceHitsPtr_ = new List<objectHit>();
slavePointFaceHitsPtr_->transfer(slavePointFaceHits);
deleteDemandDrivenData(masterPointEdgeHitsPtr_); deleteDemandDrivenData(masterPointEdgeHitsPtr_);
masterPointEdgeHitsPtr_ = new labelList(masterPointEdgeHits); masterPointEdgeHitsPtr_ = new labelList();
masterPointEdgeHitsPtr_->transfer(masterPointEdgeHits);
if (debug) if (debug)
{ {

View File

@ -0,0 +1,8 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions
cleanCase0
rmdir constant 2> /dev/null
# -----------------------------------------------------------------------------

View File

@ -0,0 +1,19 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
runApplication blockMesh
runApplication topoSet
runApplication subsetMesh final -patch outer -resultTime 0
# Avoid any inconsistencies
rm -f constant/polyMesh/{cellZones,faceZones,pointZones}
runApplication -s patches topoSet -dict system/topoSetDict.patches
runApplication createPatch -overwrite
# rm -f 0/polyMesh/{cellZones,faceZones,pointZones}
# -----------------------------------------------------------------------------

View File

@ -0,0 +1,12 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
runApplication ./Allmesh
for dir in x y z
do
runApplication -s dir-$dir stitchMesh -partial outer$dir inner$dir
done
# -----------------------------------------------------------------------------

View File

@ -0,0 +1,50 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
[ "$#" -gt 0 ] || {
echo "provide x, y, z or -all directions"
exit 1
}
unset optAll
for dir
do
case "$dir" in
-x | x) rm -rf 1 2 3 ;;
-y | y) rm -rf 2 3 ;;
-z | z) rm -rf 3 ;;
-all | all)
optAll=true
rm -rf 1 2 3
;;
*)
echo "provide x, y, z or -all directions"
exit 1
;;
esac
done
if [ "$optAll" = true ]
then
set -- x y z
fi
stitch()
{
local dir=$1
stitchMesh -partial outer$dir inner$dir | tee log.stitch-$dir
}
for dir
do
case "$dir" in
-x | x) [ -d 1 ] || stitch x;;
-y | y) [ -d 2 ] || stitch y;;
-z | z) [ -d 3 ] || stitch z;;
esac
done
# -----------------------------------------------------------------------------

View File

@ -0,0 +1,132 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1;
// Dimensions for outer box
lo 0; // outer lower corner
uo 1; // outer upper corner
// Dimensions for inner box
li -0.1; // inner lower corner
ui 0.497; // inner upper corner
// ^^^^^ very poorly handled gaps
ui 0.498; // inner upper corner
// ^^^^^ slave patch probably does not project onto master
ui 0.499; // inner upper corner
// ^^^^^ OK
vertices
(
( $lo $lo $lo )
( $uo $lo $lo )
( $uo $uo $lo )
( $lo $uo $lo )
( $lo $lo $uo )
( $uo $lo $uo )
( $uo $uo $uo )
( $lo $uo $uo )
( $li $li $li )
( $ui $li $li )
( $ui $ui $li )
( $li $ui $li )
( $li $li $ui )
( $ui $li $ui )
( $ui $ui $ui )
( $li $ui $ui )
);
blocks
(
hex (0 1 2 3 4 5 6 7) (6 6 6) simpleGrading (1 1 1)
hex (8 9 10 11 12 13 14 15) (10 10 10) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
wallso
{
type patch;
faces
(
// Walls of the outside block
(0 4 7 3)
(1 2 6 5)
(0 1 5 4)
(3 7 6 2)
(0 3 2 1)
(4 5 6 7)
);
}
wallsi
{
type patch;
faces
(
// Walls of the inside block
(8 12 15 11)
(8 9 13 12)
(8 11 10 9)
);
}
// Outer faces populated by subsetMesh
outer
{
type patch;
faces ();
}
innerx
{
type patch;
inGroups (inner);
faces
(
(9 10 14 13)
);
}
innery
{
type patch;
inGroups (inner);
faces
(
(11 15 14 10)
);
}
innerz
{
type patch;
inGroups (inner);
faces
(
(12 13 14 15)
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application simpleFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 1;
writeControl runTime;
writeInterval 1;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
pointSync false;
outerSet
{
patchInfo
{
type patch;
inGroups (outer);
}
constructFrom set;
}
// Patches to create.
patches
(
{
name outerx;
set outerx;
$outerSet;
}
{
name outery;
set outery;
$outerSet;
}
{
name outerz;
set outerz;
$outerSet;
}
);
// ************************************************************************* //

View File

@ -0,0 +1,55 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss cubic;
}
laplacianSchemes
{
default Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
fluxRequired
{
default no;
p ;
}
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver PCG;
preconditioner DIC;
tolerance 1e-06;
relTol 0;
}
U
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-05;
relTol 0;
}
}
PISO
{
nCorrectors 2;
nNonOrthogonalCorrectors 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,106 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
// Outer cube
{
name outer;
type cellSet;
action new;
source regionToCell;
sourceInfo
{
insidePoints
(
(0.99 0.99 0.99)
);
}
}
{
name corner;
type cellSet;
action new;
source boxToCell;
sourceInfo
{
box (-1 -1 -1)(0.5 0.5 0.5);
}
}
{
name inner;
type cellSet;
action new;
source cellToCell;
sourceInfo
{
set corner;
}
}
{
name inner;
type cellSet;
action delete;
source cellToCell;
sourceInfo
{
set outer;
}
}
{
name outer;
type cellSet;
action delete;
source cellToCell;
sourceInfo
{
set corner;
}
}
{
name corner;
type cellSet;
action clear;
}
{
name final;
type cellSet;
action new;
source cellToCell;
sourceInfo
{
set outer;
}
}
{
name final;
type cellSet;
action add;
source cellToCell;
sourceInfo
{
set inner;
}
}
);
// ************************************************************************* //

View File

@ -0,0 +1,88 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
newFromPatch
{
type faceSet;
action new;
source patchToFace;
sourceInfo
{
name outer;
}
}
subsetNormal
{
type faceSet;
action subset;
source normalToFace;
sourceInfo
{
cos 0.1;
}
}
actions
(
// outerx
{
name outerx;
$newFromPatch
}
{
name outerx;
$subsetNormal;
sourceInfo
{
normal (-1 0 0);
}
}
// outery
{
name outery;
$newFromPatch
}
{
name outery;
$subsetNormal;
sourceInfo
{
normal (0 -1 0);
}
}
// outerz
{
name outerz;
$newFromPatch
}
{
name outerz;
$subsetNormal;
sourceInfo
{
normal (0 0 -1);
}
}
);
// ************************************************************************* //