Commit 0fd2a5f0 authored by mattijs's avatar mattijs
Browse files

making stitchMesh,mergePatchPairs work

parent 6427d612
......@@ -243,14 +243,7 @@ int main(int argc, char *argv[])
meshDict.lookup("mergePatchPairs")
);
if (mergePatchPairs.size())
{
FatalErrorIn(args.executable())
<< "mergePatchPairs not currently supported."
<< exit(FatalError);
}
//// #include "mergePatchPairs.H"
# include "mergePatchPairs.H"
}
else
{
......
......@@ -63,6 +63,7 @@ Description
#include "slidingInterface.H"
#include "perfectInterface.H"
#include "IOobjectList.H"
#include "ReadFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -90,34 +91,6 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
}
// Read field
template<class GeoField>
void readFields
(
const fvMesh& mesh,
const IOobjectList& objects,
PtrList<GeoField>& fields
)
{
// Search list of objects for volScalarFields
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
// Construct the vol scalar fields
fields.setSize(fieldObjects.size());
label fieldi = 0;
for
(
IOobjectList::iterator iter = fieldObjects.begin();
iter != fieldObjects.end();
++iter
)
{
fields.set(fieldi++, new GeoField(*iter(), mesh));
}
}
// Main program:
int main(int argc, char *argv[])
......@@ -343,7 +316,8 @@ int main(int argc, char *argv[])
cutZoneName,
masterPatchName,
slavePatchName,
tom // integral or partial
tom, // integral or partial
true // couple/decouple mode
)
);
}
......@@ -355,30 +329,30 @@ int main(int argc, char *argv[])
// Read all current fvFields so they will get mapped
Info<< "Reading all current volfields" << endl;
PtrList<volScalarField> volScalarFields;
readFields(mesh, objects, volScalarFields);
ReadFields(mesh, objects, volScalarFields);
PtrList<volVectorField> volVectorFields;
readFields(mesh, objects, volVectorFields);
ReadFields(mesh, objects, volVectorFields);
PtrList<volSphericalTensorField> volSphericalTensorFields;
readFields(mesh, objects, volSphericalTensorFields);
ReadFields(mesh, objects, volSphericalTensorFields);
PtrList<volSymmTensorField> volSymmTensorFields;
readFields(mesh, objects, volSymmTensorFields);
ReadFields(mesh, objects, volSymmTensorFields);
PtrList<volTensorField> volTensorFields;
readFields(mesh, objects, volTensorFields);
ReadFields(mesh, objects, volTensorFields);
//- uncomment if you want to interpolate surface fields (usually bad idea)
//Info<< "Reading all current surfaceFields" << endl;
//PtrList<surfaceScalarField> surfaceScalarFields;
//readFields(mesh, objects, surfaceScalarFields);
//ReadFields(mesh, objects, surfaceScalarFields);
//
//PtrList<surfaceVectorField> surfaceVectorFields;
//readFields(mesh, objects, surfaceVectorFields);
//ReadFields(mesh, objects, surfaceVectorFields);
//
//PtrList<surfaceTensorField> surfaceTensorFields;
//readFields(mesh, objects, surfaceTensorFields);
//ReadFields(mesh, objects, surfaceTensorFields);
if (!overwrite)
{
......@@ -394,11 +368,22 @@ int main(int argc, char *argv[])
if (overwrite)
{
mesh.setInstance(oldInstance);
stitcher.instance() = oldInstance;
}
Info << nl << "Writing polyMesh to time " << runTime.timeName() << endl;
IOstream::defaultPrecision(10);
if (!mesh.write())
// Bypass runTime write (since only writes at outputTime)
if
(
!runTime.objectRegistry::writeObject
(
runTime.writeFormat(),
IOstream::currentVersion,
runTime.writeCompression()
)
)
{
FatalErrorIn(args.executable())
<< "Failed writing polyMesh."
......
......@@ -35,9 +35,11 @@ License
#include "plane.H"
#include "polyTopoChanger.H"
#include "polyAddPoint.H"
#include "polyRemovePoint.H"
#include "polyAddFace.H"
#include "polyModifyPoint.H"
#include "polyModifyFace.H"
#include "polyRemoveFace.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -765,6 +767,9 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
projectedSlavePoints
);
// Demand driven calculate the cut faces. Apart from the
// cutFaces/cutFaceMaster/cutFaceSlave no information from the cutPatch
// is used anymore!
const faceList& cutFaces = cutPatch.cutFaces();
const labelList& cutFaceMaster = cutPatch.cutFaceMaster();
const labelList& cutFaceSlave = cutPatch.cutFaceSlave();
......@@ -1109,22 +1114,26 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
{
nOrphanedMasters++;
// Recover original orientation
ref.setAction
(
polyModifyFace
(
masterPatch[faceI], // new face
masterPatchAddr[faceI], // master face index
-1, // owner
-1, // neighbour
false, // flux flip
-1, // patch ID
false, // remove from zone
masterFaceZoneID_.index(), // zone ID
false // zone flip
)
);
//// Recover original orientation
//ref.setAction
//(
// polyModifyFace
// (
// masterPatch[faceI], // new face
// masterPatchAddr[faceI], // master face index
// -1, // owner
// -1, // neighbour
// false, // flux flip
// -1, // patch ID
// false, // remove from zone
// masterFaceZoneID_.index(), // zone ID
// false // zone flip
// )
//);
//Pout<< "**MJ:deleting master face " << masterPatchAddr[faceI]
// << " old verts:" << masterPatch[faceI] << endl;
ref.setAction(polyRemoveFace(masterPatchAddr[faceI]));
}
}
......@@ -1136,22 +1145,26 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
{
nOrphanedSlaves++;
// Recover original orientation
ref.setAction
(
polyModifyFace
(
slavePatch[faceI], // new face
slavePatchAddr[faceI], // slave face index
-1, // owner
-1, // neighbour
false, // flux flip
-1, // patch ID
false, // remove from zone
slaveFaceZoneID_.index(), // zone ID
false // zone flip
)
);
//// Recover original orientation
//ref.setAction
//(
// polyModifyFace
// (
// slavePatch[faceI], // new face
// slavePatchAddr[faceI], // slave face index
// -1, // owner
// -1, // neighbour
// false, // flux flip
// -1, // patch ID
// false, // remove from zone
// slaveFaceZoneID_.index(), // zone ID
// false // zone flip
// )
//);
//Pout<< "**MJ:deleting slave face " << slavePatchAddr[faceI]
// << " old verts:" << slavePatch[faceI] << endl;
ref.setAction(polyRemoveFace(slavePatchAddr[faceI]));
}
}
......@@ -1400,24 +1413,46 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
face newFace;
newFace.transfer(newFaceLabels);
// Pout << "Modifying master stick-out face " << curFaceID << " old face: " << oldFace << " new face: " << newFace << endl;
//Pout << "Modifying master stick-out face " << curFaceID
// << " old face: " << oldFace << " new face: " << newFace << endl;
// Modify the face
ref.setAction
(
polyModifyFace
if (mesh.isInternalFace(curFaceID))
{
ref.setAction
(
newFace, // modified face
curFaceID, // label of face being modified
own[curFaceID], // owner
nei[curFaceID], // neighbour
false, // face flip
mesh.boundaryMesh().whichPatch(curFaceID), // patch for face
false, // remove from zone
modifiedFaceZone, // zone for face
modifiedFaceZoneFlip // face flip in zone
)
);
polyModifyFace
(
newFace, // modified face
curFaceID, // label of face being modified
own[curFaceID], // owner
nei[curFaceID], // neighbour
false, // face flip
-1, // patch for face
false, // remove from zone
modifiedFaceZone, // zone for face
modifiedFaceZoneFlip // face flip in zone
)
);
}
else
{
ref.setAction
(
polyModifyFace
(
newFace, // modified face
curFaceID, // label of face being modified
own[curFaceID], // owner
-1, // neighbour
false, // face flip
mesh.boundaryMesh().whichPatch(curFaceID), // patch for face
false, // remove from zone
modifiedFaceZone, // zone for face
modifiedFaceZoneFlip // face flip in zone
)
);
}
}
}
......@@ -1688,21 +1723,42 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
// Pout << "Modifying slave stick-out face " << curFaceID << " old face: " << oldFace << " new face: " << newFace << endl;
// Modify the face
ref.setAction
(
polyModifyFace
if (mesh.isInternalFace(curFaceID))
{
ref.setAction
(
newFace, // modified face
curFaceID, // label of face being modified
own[curFaceID], // owner
nei[curFaceID], // neighbour
false, // face flip
mesh.boundaryMesh().whichPatch(curFaceID), // patch for face
false, // remove from zone
modifiedFaceZone, // zone for face
modifiedFaceZoneFlip // face flip in zone
)
);
polyModifyFace
(
newFace, // modified face
curFaceID, // label of face being modified
own[curFaceID], // owner
nei[curFaceID], // neighbour
false, // face flip
-1, // patch for face
false, // remove from zone
modifiedFaceZone, // zone for face
modifiedFaceZoneFlip // face flip in zone
)
);
}
else
{
ref.setAction
(
polyModifyFace
(
newFace, // modified face
curFaceID, // label of face being modified
own[curFaceID], // owner
-1, // neighbour
false, // face flip
mesh.boundaryMesh().whichPatch(curFaceID), // patch for face
false, // remove from zone
modifiedFaceZone, // zone for face
modifiedFaceZoneFlip // face flip in zone
)
);
}
}
}
......@@ -1735,15 +1791,25 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
// slave patch
nRetiredPoints++;
//ref.setAction
//(
// polyModifyPoint
// (
// slaveMeshPoints[pointI], // point ID
// points[slaveMeshPoints[pointI]], // point
// false, // remove from zone
// mesh.pointZones().whichZone(slaveMeshPoints[pointI]),// zone
// false // in a cell
// )
//);
//Pout<< "MJ retire slave point " << slaveMeshPoints[pointI]
// << " coord " << points[slaveMeshPoints[pointI]]
// << endl;
ref.setAction
(
polyModifyPoint
polyRemovePoint
(
slaveMeshPoints[pointI], // point ID
points[slaveMeshPoints[pointI]], // point
false, // remove from zone
mesh.pointZones().whichZone(slaveMeshPoints[pointI]),// zone
false // in a cell
slaveMeshPoints[pointI]
)
);
......
......@@ -28,6 +28,8 @@ Description
#include "enrichedPatch.H"
#include "demandDrivenData.H"
#include "OFstream.H"
#include "meshTools.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -249,6 +251,33 @@ bool Foam::enrichedPatch::checkSupport() const
}
void Foam::enrichedPatch::writeOBJ(const fileName& fName) const
{
OFstream str(fName);
const pointField& lp = localPoints();
forAll(lp, pointI)
{
meshTools::writeOBJ(str, lp[pointI]);
}
const faceList& faces = localFaces();
forAll(faces, faceI)
{
const face& f = faces[faceI];
str << 'f';
forAll(f, fp)
{
str << ' ' << f[fp]+1;
}
str << nl;
}
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
......
......@@ -199,9 +199,9 @@ public:
(
const primitiveFacePatch& masterPatch,
const primitiveFacePatch& slavePatch,
const labelList& slavePointPointHits,
const labelList& slavePointEdgeHits,
const List<objectHit>& slavePointFaceHits
const labelList& slavePointPointHits,// -1 or common point snapped to
const labelList& slavePointEdgeHits, // -1 or common edge snapped to
const List<objectHit>& slavePointFaceHits // master face snapped to
);
......@@ -276,6 +276,10 @@ public:
//- Check if the patch is fully supported
bool checkSupport() const;
//- Debugging: dump graphical representation to obj format file
void writeOBJ(const fileName&) const;
};
......
......@@ -664,14 +664,15 @@ void Foam::slidingInterface::updateMesh(const mapPolyMesh& m)
masterPatchID_.update(mesh.boundaryMesh());
slavePatchID_.update(mesh.boundaryMesh());
if (!attached())
{
calcAttachedAddressing();
}
else
{
renumberAttachedAddressing(m);
}
//MJ:Disabled updating
// if (!attached())
// {
// calcAttachedAddressing();
// }
// else
// {
// renumberAttachedAddressing(m);
// }
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment