ENH: cyclic: added patchGroup coupling

This commit is contained in:
mattijs
2013-11-13 18:07:40 +00:00
parent 40df4488fc
commit 99401a4d54
11 changed files with 97 additions and 33 deletions

View File

@ -387,6 +387,7 @@ $(cellShape)/cellShapeIO.C
$(cellShape)/cellShapeIOList.C $(cellShape)/cellShapeIOList.C
meshes/Identifiers/patch/patchIdentifier.C meshes/Identifiers/patch/patchIdentifier.C
meshes/Identifiers/patch/coupleGroupIdentifier.C
meshes/MeshObject/meshObject.C meshes/MeshObject/meshObject.C

View File

@ -171,7 +171,7 @@ void Foam::cyclicPolyPatch::calcTransforms
"cyclicPolyPatch::calcTransforms()" "cyclicPolyPatch::calcTransforms()"
) << "Patch " << name() ) << "Patch " << name()
<< " has transform type " << transformTypeNames[transform()] << " has transform type " << transformTypeNames[transform()]
<< ", neighbour patch " << neighbPatchName_ << ", neighbour patch " << neighbPatchName()
<< " has transform type " << " has transform type "
<< neighbPatch().transformTypeNames[neighbPatch().transform()] << neighbPatch().transformTypeNames[neighbPatch().transform()]
<< exit(FatalError); << exit(FatalError);
@ -350,7 +350,7 @@ void Foam::cyclicPolyPatch::calcTransforms
<< neighbPatch().separationVector_ << neighbPatch().separationVector_
<< " by more than tolerance " << avgTol << endl << " by more than tolerance " << avgTol << endl
<< "patch:" << name() << "patch:" << name()
<< " neighbour:" << neighbPatchName_ << " neighbour:" << neighbPatchName()
<< endl; << endl;
} }
@ -374,7 +374,7 @@ void Foam::cyclicPolyPatch::calcTransforms
<< "Continuing with specified separation vector " << "Continuing with specified separation vector "
<< separationVector_ << endl << separationVector_ << endl
<< "patch:" << name() << "patch:" << name()
<< " neighbour:" << neighbPatchName_ << " neighbour:" << neighbPatchName()
<< endl; << endl;
} }
@ -658,6 +658,7 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
: :
coupledPolyPatch(name, dict, index, bm, patchType), coupledPolyPatch(name, dict, index, bm, patchType),
neighbPatchName_(dict.lookupOrDefault("neighbourPatch", word::null)), neighbPatchName_(dict.lookupOrDefault("neighbourPatch", word::null)),
coupleGroup_(dict),
neighbPatchID_(-1), neighbPatchID_(-1),
rotationAxis_(vector::zero), rotationAxis_(vector::zero),
rotationCentre_(point::zero), rotationCentre_(point::zero),
@ -665,7 +666,7 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
coupledPointsPtr_(NULL), coupledPointsPtr_(NULL),
coupledEdgesPtr_(NULL) coupledEdgesPtr_(NULL)
{ {
if (neighbPatchName_ == word::null) if (neighbPatchName_ == word::null && !coupleGroup_.valid())
{ {
FatalIOErrorIn FatalIOErrorIn
( (
@ -733,7 +734,8 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
) )
: :
coupledPolyPatch(pp, bm), coupledPolyPatch(pp, bm),
neighbPatchName_(pp.neighbPatchName()), neighbPatchName_(pp.neighbPatchName_),
coupleGroup_(pp.coupleGroup_),
neighbPatchID_(-1), neighbPatchID_(-1),
rotationAxis_(pp.rotationAxis_), rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_), rotationCentre_(pp.rotationCentre_),
@ -753,11 +755,12 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
const label index, const label index,
const label newSize, const label newSize,
const label newStart, const label newStart,
const word& neighbPatchName const word& neighbName
) )
: :
coupledPolyPatch(pp, bm, index, newSize, newStart), coupledPolyPatch(pp, bm, index, newSize, newStart),
neighbPatchName_(neighbPatchName), neighbPatchName_(neighbName),
coupleGroup_(pp.coupleGroup_),
neighbPatchID_(-1), neighbPatchID_(-1),
rotationAxis_(pp.rotationAxis_), rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_), rotationCentre_(pp.rotationCentre_),
@ -765,10 +768,10 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
coupledPointsPtr_(NULL), coupledPointsPtr_(NULL),
coupledEdgesPtr_(NULL) coupledEdgesPtr_(NULL)
{ {
if (neighbPatchName_ == name()) if (neighbName == name())
{ {
FatalErrorIn("cyclicPolyPatch::cyclicPolyPatch(..)") FatalErrorIn("cyclicPolyPatch::cyclicPolyPatch(..)")
<< "Neighbour patch name " << neighbPatchName_ << "Neighbour patch name " << neighbName
<< " cannot be the same as this patch " << name() << " cannot be the same as this patch " << name()
<< exit(FatalError); << exit(FatalError);
} }
@ -789,6 +792,7 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
: :
coupledPolyPatch(pp, bm, index, mapAddressing, newStart), coupledPolyPatch(pp, bm, index, mapAddressing, newStart),
neighbPatchName_(pp.neighbPatchName_), neighbPatchName_(pp.neighbPatchName_),
coupleGroup_(pp.coupleGroup_),
neighbPatchID_(-1), neighbPatchID_(-1),
rotationAxis_(pp.rotationAxis_), rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_), rotationCentre_(pp.rotationCentre_),
@ -809,16 +813,29 @@ Foam::cyclicPolyPatch::~cyclicPolyPatch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::word& Foam::cyclicPolyPatch::neighbPatchName() const
{
if (neighbPatchName_.empty())
{
// Try and use patchGroup to find samplePatch and sampleRegion
label patchID = coupleGroup_.findOtherPatchID(*this);
neighbPatchName_ = boundaryMesh()[patchID].name();
}
return neighbPatchName_;
}
Foam::label Foam::cyclicPolyPatch::neighbPatchID() const Foam::label Foam::cyclicPolyPatch::neighbPatchID() const
{ {
if (neighbPatchID_ == -1) if (neighbPatchID_ == -1)
{ {
neighbPatchID_ = this->boundaryMesh().findPatchID(neighbPatchName_); neighbPatchID_ = this->boundaryMesh().findPatchID(neighbPatchName());
if (neighbPatchID_ == -1) if (neighbPatchID_ == -1)
{ {
FatalErrorIn("cyclicPolyPatch::neighbPatchID() const") FatalErrorIn("cyclicPolyPatch::neighbPatchID() const")
<< "Illegal neighbourPatch name " << neighbPatchName_ << "Illegal neighbourPatch name " << neighbPatchName()
<< endl << "Valid patch names are " << endl << "Valid patch names are "
<< this->boundaryMesh().names() << this->boundaryMesh().names()
<< exit(FatalError); << exit(FatalError);
@ -1256,7 +1273,7 @@ bool Foam::cyclicPolyPatch::order
{ {
Pout<< "order : of " << pp.size() Pout<< "order : of " << pp.size()
<< " faces of patch:" << name() << " faces of patch:" << name()
<< " neighbour:" << neighbPatchName_ << " neighbour:" << neighbPatchName()
<< endl; << endl;
} }
faceMap.setSize(pp.size()); faceMap.setSize(pp.size());
@ -1444,8 +1461,12 @@ bool Foam::cyclicPolyPatch::order
void Foam::cyclicPolyPatch::write(Ostream& os) const void Foam::cyclicPolyPatch::write(Ostream& os) const
{ {
coupledPolyPatch::write(os); coupledPolyPatch::write(os);
if (!neighbPatchName_.empty())
{
os.writeKeyword("neighbourPatch") << neighbPatchName_ os.writeKeyword("neighbourPatch") << neighbPatchName_
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
}
coupleGroup_.write(os);
switch (transform()) switch (transform())
{ {
case ROTATIONAL: case ROTATIONAL:

View File

@ -2,7 +2,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-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -50,6 +50,7 @@ SourceFiles
#include "edgeList.H" #include "edgeList.H"
#include "polyBoundaryMesh.H" #include "polyBoundaryMesh.H"
#include "diagTensorField.H" #include "diagTensorField.H"
#include "coupleGroupIdentifier.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -67,7 +68,10 @@ class cyclicPolyPatch
// Private data // Private data
//- Name of other half //- Name of other half
const word neighbPatchName_; mutable word neighbPatchName_;
//- Optional patchGroup to find neighbPatch
const coupleGroupIdentifier coupleGroup_;
//- Index of other half //- Index of other half
mutable label neighbPatchID_; mutable label neighbPatchID_;
@ -306,12 +310,10 @@ public:
// Member Functions // Member Functions
const word& neighbPatchName() const //- Neighbour patch name
{ const word& neighbPatchName() const;
return neighbPatchName_;
}
//- Neighbour patchID. //- Neighbour patchID
virtual label neighbPatchID() const; virtual label neighbPatchID() const;
virtual bool owner() const virtual bool owner() const

View File

@ -125,7 +125,7 @@ void Foam::cyclicAMIPolyPatch::calcTransforms
FatalErrorIn("cyclicAMIPolyPatch::calcTransforms()") FatalErrorIn("cyclicAMIPolyPatch::calcTransforms()")
<< "Patch " << name() << "Patch " << name()
<< " has transform type " << transformTypeNames[transform()] << " has transform type " << transformTypeNames[transform()]
<< ", neighbour patch " << nbrPatchName_ << ", neighbour patch " << neighbPatchName()
<< " has transform type " << " has transform type "
<< neighbPatch().transformTypeNames[neighbPatch().transform()] << neighbPatch().transformTypeNames[neighbPatch().transform()]
<< exit(FatalError); << exit(FatalError);
@ -416,7 +416,8 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
) )
: :
coupledPolyPatch(name, dict, index, bm, patchType), coupledPolyPatch(name, dict, index, bm, patchType),
nbrPatchName_(dict.lookup("neighbourPatch")), nbrPatchName_(dict.lookupOrDefault<word>("neighbourPatch", "")),
coupleGroup_(dict),
nbrPatchID_(-1), nbrPatchID_(-1),
rotationAxis_(vector::zero), rotationAxis_(vector::zero),
rotationCentre_(point::zero), rotationCentre_(point::zero),
@ -426,6 +427,22 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
surfPtr_(NULL), surfPtr_(NULL),
surfDict_(dict.subOrEmptyDict("surface")) surfDict_(dict.subOrEmptyDict("surface"))
{ {
if (nbrPatchName_ == word::null && !coupleGroup_.valid())
{
FatalIOErrorIn
(
"cyclicAMIPolyPatch::cyclicAMIPolyPatch"
"("
"const word&, "
"const dictionary&, "
"const label, "
"const polyBoundaryMesh&"
")",
dict
) << "No \"neighbourPatch\" or \"coupleGroup\" provided."
<< exit(FatalIOError);
}
if (nbrPatchName_ == name) if (nbrPatchName_ == name)
{ {
FatalIOErrorIn FatalIOErrorIn
@ -495,6 +512,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
: :
coupledPolyPatch(pp, bm), coupledPolyPatch(pp, bm),
nbrPatchName_(pp.nbrPatchName_), nbrPatchName_(pp.nbrPatchName_),
coupleGroup_(pp.coupleGroup_),
nbrPatchID_(-1), nbrPatchID_(-1),
rotationAxis_(pp.rotationAxis_), rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_), rotationCentre_(pp.rotationCentre_),
@ -521,6 +539,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
: :
coupledPolyPatch(pp, bm, index, newSize, newStart), coupledPolyPatch(pp, bm, index, newSize, newStart),
nbrPatchName_(nbrPatchName), nbrPatchName_(nbrPatchName),
coupleGroup_(pp.coupleGroup_),
nbrPatchID_(-1), nbrPatchID_(-1),
rotationAxis_(pp.rotationAxis_), rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_), rotationCentre_(pp.rotationCentre_),
@ -561,6 +580,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
: :
coupledPolyPatch(pp, bm, index, mapAddressing, newStart), coupledPolyPatch(pp, bm, index, mapAddressing, newStart),
nbrPatchName_(pp.nbrPatchName_), nbrPatchName_(pp.nbrPatchName_),
coupleGroup_(pp.coupleGroup_),
nbrPatchID_(-1), nbrPatchID_(-1),
rotationAxis_(pp.rotationAxis_), rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_), rotationCentre_(pp.rotationCentre_),
@ -584,12 +604,12 @@ Foam::label Foam::cyclicAMIPolyPatch::neighbPatchID() const
{ {
if (nbrPatchID_ == -1) if (nbrPatchID_ == -1)
{ {
nbrPatchID_ = this->boundaryMesh().findPatchID(nbrPatchName_); nbrPatchID_ = this->boundaryMesh().findPatchID(neighbPatchName());
if (nbrPatchID_ == -1) if (nbrPatchID_ == -1)
{ {
FatalErrorIn("cyclicPolyAMIPatch::neighbPatchID() const") FatalErrorIn("cyclicPolyAMIPatch::neighbPatchID() const")
<< "Illegal neighbourPatch name " << nbrPatchName_ << "Illegal neighbourPatch name " << neighbPatchName()
<< nl << "Valid patch names are " << nl << "Valid patch names are "
<< this->boundaryMesh().names() << this->boundaryMesh().names()
<< exit(FatalError); << exit(FatalError);
@ -832,8 +852,12 @@ Foam::label Foam::cyclicAMIPolyPatch::pointFace
void Foam::cyclicAMIPolyPatch::write(Ostream& os) const void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
{ {
coupledPolyPatch::write(os); coupledPolyPatch::write(os);
if (!nbrPatchName_.empty())
{
os.writeKeyword("neighbourPatch") << nbrPatchName_ os.writeKeyword("neighbourPatch") << nbrPatchName_
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
}
coupleGroup_.write(os);
switch (transform()) switch (transform())
{ {

View File

@ -38,6 +38,7 @@ SourceFiles
#include "coupledPolyPatch.H" #include "coupledPolyPatch.H"
#include "AMIPatchToPatchInterpolation.H" #include "AMIPatchToPatchInterpolation.H"
#include "polyBoundaryMesh.H" #include "polyBoundaryMesh.H"
#include "coupleGroupIdentifier.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -58,7 +59,10 @@ private:
// Private data // Private data
//- Name of other half //- Name of other half
const word nbrPatchName_; mutable word nbrPatchName_;
//- Optional patchGroup to find neighbPatch
const coupleGroupIdentifier coupleGroup_;
//- Index of other half //- Index of other half
mutable label nbrPatchID_; mutable label nbrPatchID_;

View File

@ -27,6 +27,13 @@ License
inline const Foam::word& Foam::cyclicAMIPolyPatch::neighbPatchName() const inline const Foam::word& Foam::cyclicAMIPolyPatch::neighbPatchName() const
{ {
if (nbrPatchName_.empty())
{
// Try and use patchGroup to find samplePatch and sampleRegion
label patchID = coupleGroup_.findOtherPatchID(*this);
nbrPatchName_ = boundaryMesh()[patchID].name();
}
return nbrPatchName_; return nbrPatchName_;
} }

View File

@ -199,7 +199,6 @@ mappedPatches/mappedPolyPatch/mappedPatchBase.C
mappedPatches/mappedPolyPatch/mappedPolyPatch.C mappedPatches/mappedPolyPatch/mappedPolyPatch.C
mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C
mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C
mappedPatches/mappedPolyPatch/coupleGroupIdentifier.C
mappedPatches/mappedPointPatch/mappedPointPatch.C mappedPatches/mappedPointPatch/mappedPointPatch.C
mappedPatches/mappedPointPatch/mappedWallPointPatch.C mappedPatches/mappedPointPatch/mappedWallPointPatch.C

View File

@ -1402,10 +1402,16 @@ void Foam::mappedPatchBase::write(Ostream& os) const
{ {
os.writeKeyword("sampleMode") << sampleModeNames_[mode_] os.writeKeyword("sampleMode") << sampleModeNames_[mode_]
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
os.writeKeyword("sampleRegion") << sampleRegion() if (!sampleRegion_.empty())
{
os.writeKeyword("sampleRegion") << sampleRegion_
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
os.writeKeyword("samplePatch") << samplePatch() }
if (!samplePatch_.empty())
{
os.writeKeyword("samplePatch") << samplePatch_
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
}
coupleGroup_.write(os); coupleGroup_.write(os);
if if