Commit c2dd9825 authored by Mark Olesen's avatar Mark Olesen
Browse files

Merge commit 'OpenCFD/master' into olesenm

parents 23476071 77913b2e
......@@ -225,6 +225,8 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
// Dump halves
{
OFstream str(prefix+cycPatch.name()+"_half0.obj");
Pout<< "Dumping cycPatch.name() half0 faces to " << str.name()
<< endl;
meshTools::writeOBJ
(
str,
......@@ -241,6 +243,8 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
}
{
OFstream str(prefix+cycPatch.name()+"_half1.obj");
Pout<< "Dumping cycPatch.name() half1 faces to " << str.name()
<< endl;
meshTools::writeOBJ
(
str,
......@@ -262,6 +266,9 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
OFstream str(prefix+cycPatch.name()+"_match.obj");
label vertI = 0;
Pout<< "Dumping cyclic match as lines between face centres to "
<< str.name() << endl;
for (label faceI = 0; faceI < halfSize; faceI++)
{
const point& fc0 = mesh.faceCentres()[cycPatch.start()+faceI];
......@@ -773,6 +780,8 @@ int main(int argc, char *argv[])
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, true);
mesh.movePoints(map().preMotionPoints());
dumpCyclicMatch("coupled_", mesh);
// Synchronise points.
if (!pointSync)
{
......@@ -890,6 +899,8 @@ int main(int argc, char *argv[])
filterPatches(mesh);
dumpCyclicMatch("final_", mesh);
// Set the precision of the points data to 10
IOstream::defaultPrecision(10);
......
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "system";
local "";
class dictionary;
object createPatcheDict;
version 2.0;
format ascii;
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// This application/dictionary controls:
// - optional: create new patches from boundary faces (either given as
// a set of patches or as a faceSet)
// - always: order faces on coupled patches such that they are opposite. This
// is done for all coupled faces, not just for any patches created.
// - optional: synchronise points on coupled patches.
// 1. Create cyclic:
// - specify where the faces should come from
// - specify the type of cyclic. If a rotational specify the rotationAxis
// and centre to make matching easier
// - pointSync true to guarantee points to line up.
// 2. Correct incorrect cyclic:
// This will usually fail upon loading:
// "face 0 area does not match neighbour 2 by 0.0100005%"
// " -- possible face ordering problem."
// - change patch type from 'cyclic' to 'patch' in the polyMesh/boundary file.
// - loosen match tolerance to get case to load
// - regenerate cyclic as above
// Tolerance used in matching faces. Absolute tolerance is span of
// face times this factor.
matchTolerance 1E-6;
// face times this factor. To load incorrectly matches meshes set this
// to a higher value.
matchTolerance 1E-3;
// Do a synchronisation of coupled points.
// Do a synchronisation of coupled points after creation of any patches.
pointSync true;
// Patches to create.
// If no patches does a coupled point and face synchronisation anyway.
patches
(
{
// Name of new patch
name sidePatches;
// Dictionary for new patch
dictionary
{
// Type of new patch
dictionary
{
type cyclic;
// Optional: used when matching and synchronising points.
// Optional: explicitly set transformation tensor.
// Used when matching and synchronising points.
//transform translational;
//separationVector (-2289 0 0);
}
transform rotational;
rotationAxis (1 0 0);
rotationCentre (0 0 0);
}
// How to construct: either 'patches' or 'set'
// How to construct: either from 'patches' or 'set'
constructFrom patches;
// If constructFrom = patches : names of patches
//patches (periodic-1 periodic-2);
patches (outlet-side1 outlet-side2);
patches (periodic-1 periodic-2);
// If constructFrom = set : name of faceSet
set f0;
}
//{
// name bottom;
// // Dictionary for new patch
// dictionary
// {
// type patch;
// }
//
// constructFrom set;
//
// patches (half0 half1);
//
// set bottomFaces;
//}
{
name bottom;
// Type of new patch
dictionary
{
type wall;
}
constructFrom set;
patches ();
set bottomFaces;
}
);
......
......@@ -104,12 +104,12 @@ public:
);
// Destructor
static bool Delete(const Mesh& mesh);
// Destructors
virtual ~MeshObject();
static bool Delete(const Mesh& mesh);
// Member Functions
......
......@@ -320,9 +320,9 @@ void Foam::coupledPolyPatch::calcTransformTensors
if (debug)
{
Pout<< " rotation " << sum(mag(forwardT_ - forwardT_[0]))
<< " more than local tolerance " << error
<< ". Assuming uniform rotation." << endl;
Pout<< " difference in rotation less than"
<< " local tolerance "
<< error << ". Assuming uniform rotation." << endl;
}
}
}
......
......@@ -34,6 +34,7 @@ License
#include "matchPoints.H"
#include "EdgeMap.H"
#include "Time.H"
#include "transformList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -89,6 +90,9 @@ void Foam::cyclicPolyPatch::calcTransforms()
{
const pointField& points = this->points();
// Determine geometric quantities on the two halves
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
primitivePatch half0
(
SubList<face>
......@@ -199,15 +203,69 @@ void Foam::cyclicPolyPatch::calcTransforms()
}
// Calculate transformation tensors
calcTransformTensors
(
half0Ctrs,
half1Ctrs,
half0Normals,
half1Normals,
half0Tols
);
// See if transformation is prescribed
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
switch (transform_)
{
case ROTATIONAL:
{
// Specified single rotation tensor.
// Get best fitting face and its opposite number
label face0 = getConsistentRotationFace(half0Ctrs);
label face1 = face0;
vector n0 =
(
(half0Ctrs[face0] - rotationCentre_)
^ rotationAxis_
);
vector n1 =
(
(half1Ctrs[face1] - rotationCentre_)
^ -rotationAxis_
);
n0 /= mag(n0) + VSMALL;
n1 /= mag(n1) + VSMALL;
if (debug)
{
Pout<< "cyclicPolyPatch::calcTransforms :"
<< " Specified rotation :"
<< " n0:" << n0 << " n1:" << n1 << endl;
}
// Calculate transformation tensors from face0,1 only.
// Note: can use tight tolerance now.
calcTransformTensors
(
pointField(1, half0Ctrs[face0]),
pointField(1, half1Ctrs[face1]),
vectorField(1, n0),
vectorField(1, n1),
scalarField(1, half0Tols[face0]),
1E-4
);
break;
}
default:
{
// Calculate transformation tensors from all faces.
calcTransformTensors
(
half0Ctrs,
half1Ctrs,
half0Normals,
half1Normals,
half0Tols
);
break;
}
}
}
}
......@@ -402,6 +460,7 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors
const faceList& half0Faces,
const faceList& half1Faces,
pointField& ppPoints,
pointField& half0Ctrs,
pointField& half1Ctrs,
pointField& anchors0,
......@@ -442,6 +501,8 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors
anchors0[faceI] = Foam::transform(reverseT, anchors0[faceI]);
}
ppPoints = Foam::transform(reverseT, pp.points());
break;
}
//- Problem: usually specified translation is not accurate enough
......@@ -501,6 +562,7 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors
anchors0[faceI]
);
}
ppPoints = Foam::transform(reverseT, pp.points());
}
else
{
......@@ -524,6 +586,7 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors
half0Ctrs += ctr1 - ctr0;
anchors0 += ctr1 - ctr0;
ppPoints = pp.points() + ctr1 - ctr0;
}
break;
}
......@@ -1079,7 +1142,7 @@ bool Foam::cyclicPolyPatch::order
faceList half1Faces(IndirectList<face>(pp, half1ToPatch));
// Get geometric quantities
pointField half0Ctrs, half1Ctrs, anchors0;
pointField half0Ctrs, half1Ctrs, anchors0, ppPoints;
scalarField tols;
getCentresAndAnchors
(
......@@ -1087,6 +1150,7 @@ bool Foam::cyclicPolyPatch::order
half0Faces,
half1Faces,
ppPoints,
half0Ctrs,
half1Ctrs,
anchors0,
......@@ -1108,6 +1172,44 @@ bool Foam::cyclicPolyPatch::order
{
Pout<< "cyclicPolyPatch::order : test if already ordered:"
<< matchedAll << endl;
// Dump halves
fileName nm0("match1_"+name()+"_half0_faces.obj");
Pout<< "cyclicPolyPatch::order : Writing half0"
<< " faces to OBJ file " << nm0 << endl;
writeOBJ(nm0, half0Faces, ppPoints);
fileName nm1("match1_"+name()+"_half1_faces.obj");
Pout<< "cyclicPolyPatch::order : Writing half1"
<< " faces to OBJ file " << nm1 << endl;
writeOBJ(nm1, half1Faces, pp.points());
OFstream ccStr
(
boundaryMesh().mesh().time().path()
/"match1_"+ name() + "_faceCentres.obj"
);
Pout<< "cyclicPolyPatch::order : "
<< "Dumping currently found cyclic match as lines between"
<< " corresponding face centres to file " << ccStr.name()
<< endl;
// Recalculate untransformed face centres
//pointField rawHalf0Ctrs = calcFaceCentres(half0Faces, pp.points());
label vertI = 0;
forAll(half1Ctrs, i)
{
//if (from1To0[i] != -1)
{
// Write edge between c1 and c0
//const point& c0 = rawHalf0Ctrs[from1To0[i]];
//const point& c0 = half0Ctrs[from1To0[i]];
const point& c0 = half0Ctrs[i];
const point& c1 = half1Ctrs[i];
writeOBJ(ccStr, c0, c1, vertI);
}
}
}
......@@ -1133,6 +1235,7 @@ bool Foam::cyclicPolyPatch::order
half0Faces,
half1Faces,
ppPoints,
half0Ctrs,
half1Ctrs,
anchors0,
......@@ -1153,6 +1256,42 @@ bool Foam::cyclicPolyPatch::order
{
Pout<< "cyclicPolyPatch::order : test if pairwise ordered:"
<< matchedAll << endl;
// Dump halves
fileName nm0("match2_"+name()+"_half0_faces.obj");
Pout<< "cyclicPolyPatch::order : Writing half0"
<< " faces to OBJ file " << nm0 << endl;
writeOBJ(nm0, half0Faces, ppPoints);
fileName nm1("match2_"+name()+"_half1_faces.obj");
Pout<< "cyclicPolyPatch::order : Writing half1"
<< " faces to OBJ file " << nm1 << endl;
writeOBJ(nm1, half1Faces, pp.points());
OFstream ccStr
(
boundaryMesh().mesh().time().path()
/"match2_"+name()+"_faceCentres.obj"
);
Pout<< "cyclicPolyPatch::order : "
<< "Dumping currently found cyclic match as lines between"
<< " corresponding face centres to file " << ccStr.name()
<< endl;
// Recalculate untransformed face centres
//pointField rawHalf0Ctrs = calcFaceCentres(half0Faces, pp.points());
label vertI = 0;
forAll(half1Ctrs, i)
{
if (from1To0[i] != -1)
{
// Write edge between c1 and c0
//const point& c0 = rawHalf0Ctrs[from1To0[i]];
const point& c0 = half0Ctrs[from1To0[i]];
const point& c1 = half1Ctrs[i];
writeOBJ(ccStr, c0, c1, vertI);
}
}
}
}
......@@ -1209,6 +1348,7 @@ bool Foam::cyclicPolyPatch::order
half0Faces,
half1Faces,
ppPoints,
half0Ctrs,
half1Ctrs,
anchors0,
......@@ -1229,8 +1369,43 @@ bool Foam::cyclicPolyPatch::order
{
Pout<< "cyclicPolyPatch::order : test if baffles:"
<< matchedAll << endl;
}
// Dump halves
fileName nm0("match3_"+name()+"_half0_faces.obj");
Pout<< "cyclicPolyPatch::order : Writing half0"
<< " faces to OBJ file " << nm0 << endl;
writeOBJ(nm0, half0Faces, ppPoints);
fileName nm1("match3_"+name()+"_half1_faces.obj");
Pout<< "cyclicPolyPatch::order : Writing half1"
<< " faces to OBJ file " << nm1 << endl;
writeOBJ(nm1, half1Faces, pp.points());
OFstream ccStr
(
boundaryMesh().mesh().time().path()
/"match3_"+ name() + "_faceCentres.obj"
);
Pout<< "cyclicPolyPatch::order : "
<< "Dumping currently found cyclic match as lines between"
<< " corresponding face centres to file " << ccStr.name()
<< endl;
// Recalculate untransformed face centres
//pointField rawHalf0Ctrs = calcFaceCentres(half0Faces, pp.points());
label vertI = 0;
forAll(half1Ctrs, i)
{
if (from1To0[i] != -1)
{
// Write edge between c1 and c0
//const point& c0 = rawHalf0Ctrs[from1To0[i]];
const point& c0 = half0Ctrs[from1To0[i]];
const point& c1 = half1Ctrs[i];
writeOBJ(ccStr, c0, c1, vertI);
}
}
}
}
}
......@@ -1259,6 +1434,7 @@ bool Foam::cyclicPolyPatch::order
half0Faces,
half1Faces,
ppPoints,
half0Ctrs,
half1Ctrs,
anchors0,
......@@ -1279,6 +1455,42 @@ bool Foam::cyclicPolyPatch::order
{
Pout<< "cyclicPolyPatch::order : automatic ordering result:"
<< matchedAll << endl;
// Dump halves
fileName nm0("match4_"+name()+"_half0_faces.obj");
Pout<< "cyclicPolyPatch::order : Writing half0"
<< " faces to OBJ file " << nm0 << endl;
writeOBJ(nm0, half0Faces, ppPoints);
fileName nm1("match4_"+name()+"_half1_faces.obj");
Pout<< "cyclicPolyPatch::order : Writing half1"
<< " faces to OBJ file " << nm1 << endl;
writeOBJ(nm1, half1Faces, pp.points());
OFstream ccStr
(
boundaryMesh().mesh().time().path()
/"match4_"+ name() + "_faceCentres.obj"
);
Pout<< "cyclicPolyPatch::order : "
<< "Dumping currently found cyclic match as lines between"
<< " corresponding face centres to file " << ccStr.name()
<< endl;
// Recalculate untransformed face centres
//pointField rawHalf0Ctrs = calcFaceCentres(half0Faces, pp.points());
label vertI = 0;
forAll(half1Ctrs, i)
{
if (from1To0[i] != -1)
{
// Write edge between c1 and c0
//const point& c0 = rawHalf0Ctrs[from1To0[i]];
const point& c0 = half0Ctrs[from1To0[i]];
const point& c1 = half1Ctrs[i];
writeOBJ(ccStr, c0, c1, vertI);
}
}
}
}
......
......@@ -141,6 +141,7 @@ private:
const faceList& half0Faces,
const faceList& half1Faces,
pointField& ppPoints,
pointField& half0Ctrs,
pointField& half1Ctrs,
pointField& anchors0,
......
......@@ -152,6 +152,11 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
{
mesh.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes.
mesh.clearOut();
}
faceCombiner.updateMesh(map);
......@@ -301,6 +306,11 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
{
mesh.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes.
mesh.clearOut();
}
faceCombiner.updateMesh(map);
......@@ -363,6 +373,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoLayerDriver::doRemovePoints
{
mesh.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes.
mesh.clearOut();
}
pointRemover.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0));
......@@ -411,6 +426,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoLayerDriver::doRestorePoints
{
mesh.movePoints(map().preMotionPoints());