From c07e9f66000e794148c802956294827dc823b043 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Wed, 23 Feb 2011 16:51:46 +0000 Subject: [PATCH] ENH: coupledPolyPatch: pass in transform type to enable 180 degree rotations --- .../basic/coupled/coupledPolyPatch.C | 38 +++++++++++++++---- .../basic/coupled/coupledPolyPatch.H | 21 +++++++++- .../constraint/cyclic/cyclicPolyPatch.C | 20 ++-------- .../constraint/cyclic/cyclicPolyPatch.H | 14 ------- 4 files changed, 53 insertions(+), 40 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C index 34b2b091de9..b26b225690f 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,9 +30,24 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -defineTypeNameAndDebug(Foam::coupledPolyPatch, 0); +namespace Foam +{ + defineTypeNameAndDebug(coupledPolyPatch, 0); + + scalar coupledPolyPatch::matchTol = 1E-3; -Foam::scalar Foam::coupledPolyPatch::matchTol = 1E-3; + template<> + const char* NamedEnum<coupledPolyPatch::transformType, 4>::names[] = + { + "unknown", + "rotational", + "translational", + "noOrdering" + }; + + const NamedEnum<coupledPolyPatch::transformType, 4> + coupledPolyPatch::transformTypeNames; +} // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // @@ -204,12 +219,14 @@ void Foam::coupledPolyPatch::calcTransformTensors const vectorField& nf, const vectorField& nr, const scalarField& smallDist, - const scalar absTol + const scalar absTol, + const transformType transform ) const { if (debug) { Pout<< "coupledPolyPatch::calcTransformTensors : " << name() << endl + << " transform:" << transformTypeNames[transform] << nl << " (half)size:" << Cf.size() << nl << " absTol:" << absTol << nl << " smallDist min:" << min(smallDist) << nl @@ -242,9 +259,16 @@ void Foam::coupledPolyPatch::calcTransformTensors Pout<< " error:" << error << endl; } - if (sum(mag(nf & nr)) < Cf.size()-error) + if + ( + transform == ROTATIONAL + || ( + transform != TRANSLATIONAL + && (sum(mag(nf & nr)) < Cf.size()-error) + ) + ) { - // Rotation, no separation + // Type is rotation or unknown and normals not aligned // Assume per-face differing transformation, correct later @@ -284,7 +308,7 @@ void Foam::coupledPolyPatch::calcTransformTensors } else { - // No rotation, possible separation + // Translational or (unknown and normals aligned) forwardT_.setSize(0); reverseT_.setSize(0); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H index 31fc9bcb1ba..682e9962b62 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -53,6 +53,20 @@ class coupledPolyPatch : public polyPatch { +public: + + enum transformType + { + UNKNOWN, // unspecified; automatic ordering + ROTATIONAL, // rotation along coordinate axis + TRANSLATIONAL, // translation + NOORDERING // unspecified, no automatic ordering + }; + static const NamedEnum<transformType, 4> transformTypeNames; + + +private: + // Private data //- offset (distance) vector from one side of the couple to the other @@ -82,6 +96,8 @@ protected: //- Calculate the transformation tensors // smallDist : matching distance per face // absTol : absolute error in normal + // if transformType = unknown it first tries rotational, then + // translational transform void calcTransformTensors ( const vectorField& Cf, @@ -89,7 +105,8 @@ protected: const vectorField& nf, const vectorField& nr, const scalarField& smallDist, - const scalar absTol = matchTol + const scalar absTol = matchTol, + const transformType = UNKNOWN ) const; //- Initialise the calculation of the patch geometry diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index a5039132f9f..03032fbb537 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -44,24 +44,8 @@ namespace Foam addToRunTimeSelectionTable(polyPatch, cyclicPolyPatch, word); addToRunTimeSelectionTable(polyPatch, cyclicPolyPatch, dictionary); - - template<> - const char* Foam::NamedEnum - < - Foam::cyclicPolyPatch::transformType, - 4 - >::names[] = - { - "unknown", - "rotational", - "translational", - "noOrdering" - }; } -const Foam::NamedEnum<Foam::cyclicPolyPatch::transformType, 4> - Foam::cyclicPolyPatch::transformTypeNames; - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -271,7 +255,9 @@ void Foam::cyclicPolyPatch::calcTransforms static_cast<const pointField&>(half1Ctrs), half0Normals, half1Normals, - half0Tols + half0Tols, + matchTol, + transform_ ); if (transform_ == ROTATIONAL && !parallel() && forwardT().size() > 1) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H index dd0d14db86e..68a008bdedd 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H @@ -64,20 +64,6 @@ class cyclicPolyPatch : public coupledPolyPatch { -public: - - enum transformType - { - UNKNOWN, // unspecified; automatic ordering - ROTATIONAL, // rotation along coordinate axis - TRANSLATIONAL, // translation - NOORDERING // unspecified, no automatic ordering - }; - static const NamedEnum<transformType, 4> transformTypeNames; - - -private: - // Private data //- Name of other half -- GitLab