mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: mapped: allow coupling specification through coupleGroup
This commit is contained in:
@ -199,6 +199,7 @@ mappedPatches/mappedPolyPatch/mappedPatchBase.C
|
||||
mappedPatches/mappedPolyPatch/mappedPolyPatch.C
|
||||
mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C
|
||||
mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C
|
||||
mappedPatches/mappedPolyPatch/coupleGroupIdentifier.C
|
||||
|
||||
mappedPatches/mappedPointPatch/mappedPointPatch.C
|
||||
mappedPatches/mappedPointPatch/mappedWallPointPatch.C
|
||||
|
||||
@ -0,0 +1,260 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "coupleGroupIdentifier.H"
|
||||
#include "polyMesh.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::coupleGroupIdentifier::findOtherPatchID
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const polyPatch& thisPatch
|
||||
) const
|
||||
{
|
||||
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
|
||||
|
||||
if (!valid())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"coupleGroupIdentifier::findOtherPatchID(const polyPatch&) const"
|
||||
) << "Invalid coupleGroup patch group"
|
||||
<< " on patch " << thisPatch.name()
|
||||
<< " in region " << pbm.mesh().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
HashTable<labelList, word>::const_iterator fnd =
|
||||
pbm.groupPatchIDs().find(name());
|
||||
|
||||
if (fnd == pbm.groupPatchIDs().end())
|
||||
{
|
||||
if (&mesh == &thisPatch.boundaryMesh().mesh())
|
||||
{
|
||||
// thisPatch should be in patchGroup
|
||||
FatalErrorIn
|
||||
(
|
||||
"coupleGroupIdentifier::findOtherPatchID"
|
||||
"(const polyMesh&, const polyPatch&) const"
|
||||
) << "Patch " << thisPatch.name()
|
||||
<< " should be in patchGroup " << name()
|
||||
<< " in region " << pbm.mesh().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Mesh has patch group
|
||||
const labelList& patchIDs = fnd();
|
||||
|
||||
if (&mesh == &thisPatch.boundaryMesh().mesh())
|
||||
{
|
||||
if (patchIDs.size() > 2 || patchIDs.size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"coupleGroupIdentifier::findOtherPatchID"
|
||||
"(const polyMesh&, const polyPatch&) const"
|
||||
) << "Couple patchGroup " << name()
|
||||
<< " with contents " << patchIDs
|
||||
<< " not of size < 2"
|
||||
<< " on patch " << thisPatch.name()
|
||||
<< " region " << thisPatch.boundaryMesh().mesh().name()
|
||||
<< exit(FatalError);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
label index = findIndex(patchIDs, thisPatch.index());
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"coupleGroupIdentifier::findOtherPatchID"
|
||||
"(const polyMesh&, const polyPatch&) const"
|
||||
) << "Couple patchGroup " << name()
|
||||
<< " with contents " << patchIDs
|
||||
<< " does not contain patch " << thisPatch.name()
|
||||
<< " in region " << pbm.mesh().name()
|
||||
<< exit(FatalError);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (patchIDs.size() == 2)
|
||||
{
|
||||
// Return the other patch
|
||||
return patchIDs[1-index];
|
||||
}
|
||||
else // size == 1
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (patchIDs.size() != 1)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"coupleGroupIdentifier::findOtherPatchID"
|
||||
"(const polyMesh&, const polyPatch&) const"
|
||||
) << "Couple patchGroup " << name()
|
||||
<< " with contents " << patchIDs
|
||||
<< " in region " << mesh.name()
|
||||
<< " should only contain a single patch"
|
||||
<< " when matching patch " << thisPatch.name()
|
||||
<< " in region " << pbm.mesh().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return patchIDs[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::coupleGroupIdentifier::coupleGroupIdentifier()
|
||||
:
|
||||
name_()
|
||||
{}
|
||||
|
||||
|
||||
Foam::coupleGroupIdentifier::coupleGroupIdentifier(const word& name)
|
||||
:
|
||||
name_(name)
|
||||
{}
|
||||
|
||||
|
||||
Foam::coupleGroupIdentifier::coupleGroupIdentifier(const dictionary& dict)
|
||||
:
|
||||
name_(dict.lookupOrDefault<word>("coupleGroup", ""))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::coupleGroupIdentifier::findOtherPatchID
|
||||
(
|
||||
const polyPatch& thisPatch
|
||||
) const
|
||||
{
|
||||
const polyBoundaryMesh& pbm = thisPatch.boundaryMesh();
|
||||
|
||||
return findOtherPatchID(pbm.mesh(), thisPatch);
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::coupleGroupIdentifier::findOtherPatchID
|
||||
(
|
||||
const polyPatch& thisPatch,
|
||||
word& otherRegion
|
||||
) const
|
||||
{
|
||||
const polyBoundaryMesh& pbm = thisPatch.boundaryMesh();
|
||||
const polyMesh& thisMesh = pbm.mesh();
|
||||
const Time& runTime = thisMesh.time();
|
||||
|
||||
|
||||
// Loop over all regions to find other patch in coupleGroup
|
||||
HashTable<const polyMesh*> meshSet = runTime.lookupClass<polyMesh>();
|
||||
|
||||
label otherPatchID = -1;
|
||||
|
||||
forAllConstIter(HashTable<const polyMesh*>, meshSet, iter)
|
||||
{
|
||||
const polyMesh& mesh = *iter();
|
||||
|
||||
label patchID = findOtherPatchID(mesh, thisPatch);
|
||||
|
||||
if (patchID != -1)
|
||||
{
|
||||
if (otherPatchID != -1)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"coupleGroupIdentifier::findOtherPatchID"
|
||||
"(const polyPatch&, word&) const"
|
||||
) << "Couple patchGroup " << name()
|
||||
<< " should be present on only two patches"
|
||||
<< " in any of the meshes in " << meshSet.sortedToc()
|
||||
<< endl
|
||||
<< " It seems to be present on patch "
|
||||
<< thisPatch.name()
|
||||
<< " in region " << thisMesh.name()
|
||||
<< ", on patch " << otherPatchID
|
||||
<< " in region " << otherRegion
|
||||
<< " and on patch " << patchID
|
||||
<< " in region " << mesh.name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
otherPatchID = patchID;
|
||||
otherRegion = mesh.name();
|
||||
}
|
||||
}
|
||||
|
||||
if (otherPatchID == -1)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"coupleGroupIdentifier::findOtherPatchID"
|
||||
"(const polyPatch&, word&) const"
|
||||
) << "Couple patchGroup " << name()
|
||||
<< " not found in any of the other meshes " << meshSet.sortedToc()
|
||||
<< " on patch " << thisPatch.name()
|
||||
<< " region " << thisMesh.name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return otherPatchID;
|
||||
}
|
||||
|
||||
|
||||
void Foam::coupleGroupIdentifier::write(Ostream& os) const
|
||||
{
|
||||
if (valid())
|
||||
{
|
||||
os.writeKeyword("coupleGroup") << name() << token::END_STATEMENT << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const coupleGroupIdentifier& p)
|
||||
{
|
||||
p.write(os);
|
||||
os.check("Ostream& operator<<(Ostream& os, const coupleGroupIdentifier& p");
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,128 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Class
|
||||
Foam::coupleGroupIdentifier
|
||||
|
||||
Description
|
||||
Encapsulates using patchGroups to specify coupled patch
|
||||
|
||||
SourceFiles
|
||||
coupleGroupIdentifierI.H
|
||||
coupleGroupIdentifier.C
|
||||
coupleGroupIdentifierIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coupleGroupIdentifier_H
|
||||
#define coupleGroupIdentifier_H
|
||||
|
||||
#include "word.H"
|
||||
#include "label.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class polyPatch;
|
||||
class Ostream;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
class coupleGroupIdentifier;
|
||||
Ostream& operator<<(Ostream&, const coupleGroupIdentifier&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class coupleGroupIdentifier Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class coupleGroupIdentifier
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of patchGroup
|
||||
word name_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Find other patch in specified mesh. Returns index of patch or -1.
|
||||
label findOtherPatchID(const polyMesh&, const polyPatch&) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
coupleGroupIdentifier();
|
||||
|
||||
//- Construct from components
|
||||
coupleGroupIdentifier(const word& patchGroupName);
|
||||
|
||||
//- Construct from dictionary
|
||||
coupleGroupIdentifier(const dictionary&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Name of patchGroup
|
||||
inline const word& name() const;
|
||||
|
||||
//- Is a valid patchGroup
|
||||
inline bool valid() const;
|
||||
|
||||
//- Find other patch in same region. Returns index of patch or -1.
|
||||
label findOtherPatchID(const polyPatch&) const;
|
||||
|
||||
//- Find other patch and region. Returns index of patch and sets
|
||||
// otherRegion to name of region. Fatal error if patch not found
|
||||
label findOtherPatchID(const polyPatch&, word&) const;
|
||||
|
||||
//- Write the data as a dictionary
|
||||
void write(Ostream&) const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const coupleGroupIdentifier&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "coupleGroupIdentifierI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "coupleGroupIdentifier.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word& Foam::coupleGroupIdentifier::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::coupleGroupIdentifier::valid() const
|
||||
{
|
||||
return !name_.empty();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -40,6 +40,7 @@ License
|
||||
#include "SubField.H"
|
||||
#include "triPointRef.H"
|
||||
#include "syncTools.H"
|
||||
#include "treeDataCell.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -202,7 +203,7 @@ void Foam::mappedPatchBase::findSamples
|
||||
{
|
||||
case NEARESTCELL:
|
||||
{
|
||||
if (samplePatch_.size() && samplePatch_ != "none")
|
||||
if (samplePatch().size() && samplePatch() != "none")
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
@ -213,14 +214,13 @@ void Foam::mappedPatchBase::findSamples
|
||||
}
|
||||
|
||||
//- Note: face-diagonal decomposition
|
||||
const meshSearchMeshObject& meshSearchEngine =
|
||||
meshSearchMeshObject::New(mesh);
|
||||
const indexedOctree<Foam::treeDataCell>& tree = mesh.cellTree();
|
||||
|
||||
forAll(samples, sampleI)
|
||||
{
|
||||
const point& sample = samples[sampleI];
|
||||
|
||||
label cellI = meshSearchEngine.findCell(sample);
|
||||
label cellI = tree.findInside(sample);
|
||||
|
||||
if (cellI == -1)
|
||||
{
|
||||
@ -391,7 +391,7 @@ void Foam::mappedPatchBase::findSamples
|
||||
|
||||
case NEARESTFACE:
|
||||
{
|
||||
if (samplePatch_.size() && samplePatch_ != "none")
|
||||
if (samplePatch().size() && samplePatch() != "none")
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
@ -454,7 +454,7 @@ void Foam::mappedPatchBase::findSamples
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "mappedPatchBase::findSamples on mesh " << sampleRegion_
|
||||
Info<< "mappedPatchBase::findSamples on mesh " << sampleRegion()
|
||||
<< " : " << endl;
|
||||
forAll(nearest, sampleI)
|
||||
{
|
||||
@ -516,8 +516,8 @@ void Foam::mappedPatchBase::calcMapping() const
|
||||
bool sampleMyself =
|
||||
(
|
||||
mode_ == NEARESTPATCHFACE
|
||||
&& sampleRegion_ == patch_.boundaryMesh().mesh().name()
|
||||
&& samplePatch_ == patch_.name()
|
||||
&& sampleRegion() == patch_.boundaryMesh().mesh().name()
|
||||
&& samplePatch() == patch_.name()
|
||||
);
|
||||
|
||||
// Check offset
|
||||
@ -544,9 +544,9 @@ void Foam::mappedPatchBase::calcMapping() const
|
||||
<< " will find the faces themselves which does not make sense"
|
||||
<< " for anything but testing." << endl
|
||||
<< "patch_:" << patch_.name() << endl
|
||||
<< "sampleRegion_:" << sampleRegion_ << endl
|
||||
<< "sampleRegion_:" << sampleRegion() << endl
|
||||
<< "mode_:" << sampleModeNames_[mode_] << endl
|
||||
<< "samplePatch_:" << samplePatch_ << endl
|
||||
<< "samplePatch_:" << samplePatch() << endl
|
||||
<< "offsetMode_:" << offsetModeNames_[offsetMode_] << endl;
|
||||
}
|
||||
|
||||
@ -604,12 +604,10 @@ void Foam::mappedPatchBase::calcMapping() const
|
||||
<< " out of " << sampleProcs.size() << " total samples."
|
||||
<< " Sampling these on owner cell centre instead." << endl
|
||||
<< "On patch " << patch_.name()
|
||||
<< " on region " << sampleRegion_
|
||||
<< " on region " << sampleRegion()
|
||||
<< " in mode " << sampleModeNames_[mode_] << endl
|
||||
<< "whilst sampling patch " << samplePatch_ << endl
|
||||
<< " with offset mode " << offsetModeNames_[offsetMode_]
|
||||
<< endl
|
||||
<< "Suppressing further warnings from " << type() << endl;
|
||||
<< "with offset mode " << offsetModeNames_[offsetMode_]
|
||||
<< ". Suppressing further warnings from " << type() << endl;
|
||||
|
||||
hasWarned = true;
|
||||
}
|
||||
@ -657,7 +655,7 @@ void Foam::mappedPatchBase::calcMapping() const
|
||||
// << " for proc:" << patchFaceProcs[i]
|
||||
// << " face:" << patchFaces[i]
|
||||
// << " at:" << patchFc[i] << endl
|
||||
// << "Found data in region " << sampleRegion_
|
||||
// << "Found data in region " << sampleRegion()
|
||||
// << " at proc:" << sampleProcs[i]
|
||||
// << " face:" << sampleIndices[i]
|
||||
// << " at:" << sampleLocations[i]
|
||||
@ -942,7 +940,8 @@ Foam::mappedPatchBase::mappedPatchBase
|
||||
patch_(pp),
|
||||
sampleRegion_(patch_.boundaryMesh().mesh().name()),
|
||||
mode_(NEARESTPATCHFACE),
|
||||
samplePatch_("none"),
|
||||
samplePatch_(""),
|
||||
coupleGroup_(),
|
||||
offsetMode_(UNIFORM),
|
||||
offset_(vector::zero),
|
||||
offsets_(pp.size(), offset_),
|
||||
@ -969,6 +968,7 @@ Foam::mappedPatchBase::mappedPatchBase
|
||||
sampleRegion_(sampleRegion),
|
||||
mode_(mode),
|
||||
samplePatch_(samplePatch),
|
||||
coupleGroup_(),
|
||||
offsetMode_(NONUNIFORM),
|
||||
offset_(vector::zero),
|
||||
offsets_(offsets),
|
||||
@ -995,6 +995,7 @@ Foam::mappedPatchBase::mappedPatchBase
|
||||
sampleRegion_(sampleRegion),
|
||||
mode_(mode),
|
||||
samplePatch_(samplePatch),
|
||||
coupleGroup_(),
|
||||
offsetMode_(UNIFORM),
|
||||
offset_(offset),
|
||||
offsets_(0),
|
||||
@ -1021,6 +1022,7 @@ Foam::mappedPatchBase::mappedPatchBase
|
||||
sampleRegion_(sampleRegion),
|
||||
mode_(mode),
|
||||
samplePatch_(samplePatch),
|
||||
coupleGroup_(),
|
||||
offsetMode_(NORMAL),
|
||||
offset_(vector::zero),
|
||||
offsets_(0),
|
||||
@ -1041,16 +1043,10 @@ Foam::mappedPatchBase::mappedPatchBase
|
||||
)
|
||||
:
|
||||
patch_(pp),
|
||||
sampleRegion_
|
||||
(
|
||||
dict.lookupOrDefault
|
||||
(
|
||||
"sampleRegion",
|
||||
patch_.boundaryMesh().mesh().name()
|
||||
)
|
||||
),
|
||||
sampleRegion_(dict.lookupOrDefault<word>("sampleRegion", "")),
|
||||
mode_(sampleModeNames_.read(dict.lookup("sampleMode"))),
|
||||
samplePatch_(dict.lookup("samplePatch")),
|
||||
samplePatch_(dict.lookupOrDefault<word>("samplePatch", "")),
|
||||
coupleGroup_(dict),
|
||||
offsetMode_(UNIFORM),
|
||||
offset_(vector::zero),
|
||||
offsets_(0),
|
||||
@ -1062,6 +1058,16 @@ Foam::mappedPatchBase::mappedPatchBase
|
||||
surfPtr_(NULL),
|
||||
surfDict_(dict.subOrEmptyDict("surface"))
|
||||
{
|
||||
if (!coupleGroup_.valid())
|
||||
{
|
||||
if (sampleRegion_.empty())
|
||||
{
|
||||
// If no coupleGroup and no sampleRegion assume local region
|
||||
sampleRegion_ = patch_.boundaryMesh().mesh().name();
|
||||
sameRegion_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (dict.found("offsetMode"))
|
||||
{
|
||||
offsetMode_ = offsetModeNames_.read(dict.lookup("offsetMode"));
|
||||
@ -1099,7 +1105,7 @@ Foam::mappedPatchBase::mappedPatchBase
|
||||
//offsets_ = pointField(dict.lookup("offsets"));
|
||||
offsets_ = readListOrField("offsets", dict, patch_.size());
|
||||
}
|
||||
else
|
||||
else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
@ -1116,6 +1122,60 @@ Foam::mappedPatchBase::mappedPatchBase
|
||||
}
|
||||
|
||||
|
||||
Foam::mappedPatchBase::mappedPatchBase
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const sampleMode mode,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
patch_(pp),
|
||||
sampleRegion_(dict.lookupOrDefault<word>("sampleRegion", "")),
|
||||
mode_(mode),
|
||||
samplePatch_(dict.lookupOrDefault<word>("samplePatch", "")),
|
||||
coupleGroup_(dict), //dict.lookupOrDefault<word>("coupleGroup", "")),
|
||||
offsetMode_(UNIFORM),
|
||||
offset_(vector::zero),
|
||||
offsets_(0),
|
||||
distance_(0.0),
|
||||
sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
|
||||
mapPtr_(NULL),
|
||||
AMIPtr_(NULL),
|
||||
AMIReverse_(dict.lookupOrDefault<bool>("flipNormals", false)),
|
||||
surfPtr_(NULL),
|
||||
surfDict_(dict.subOrEmptyDict("surface"))
|
||||
{
|
||||
if (mode != NEARESTPATCHFACE && mode != NEARESTPATCHFACEAMI)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"mappedPatchBase::mappedPatchBase\n"
|
||||
"(\n"
|
||||
" const polyPatch&,\n"
|
||||
" const sampleMode,\n"
|
||||
" const dictionary&\n"
|
||||
")\n",
|
||||
dict
|
||||
) << "Construct from sampleMode and dictionary only applicable for "
|
||||
<< " collocated patches in modes "
|
||||
<< sampleModeNames_[NEARESTPATCHFACE] << ','
|
||||
<< sampleModeNames_[NEARESTPATCHFACEAMI]
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
if (!coupleGroup_.valid())
|
||||
{
|
||||
if (sampleRegion_.empty())
|
||||
{
|
||||
// If no coupleGroup and no sampleRegion assume local region
|
||||
sampleRegion_ = patch_.boundaryMesh().mesh().name();
|
||||
sameRegion_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::mappedPatchBase::mappedPatchBase
|
||||
(
|
||||
const polyPatch& pp,
|
||||
@ -1126,6 +1186,7 @@ Foam::mappedPatchBase::mappedPatchBase
|
||||
sampleRegion_(mpb.sampleRegion_),
|
||||
mode_(mpb.mode_),
|
||||
samplePatch_(mpb.samplePatch_),
|
||||
coupleGroup_(mpb.coupleGroup_),
|
||||
offsetMode_(mpb.offsetMode_),
|
||||
offset_(mpb.offset_),
|
||||
offsets_(mpb.offsets_),
|
||||
@ -1150,6 +1211,7 @@ Foam::mappedPatchBase::mappedPatchBase
|
||||
sampleRegion_(mpb.sampleRegion_),
|
||||
mode_(mpb.mode_),
|
||||
samplePatch_(mpb.samplePatch_),
|
||||
coupleGroup_(mpb.coupleGroup_),
|
||||
offsetMode_(mpb.offsetMode_),
|
||||
offset_(mpb.offset_),
|
||||
offsets_
|
||||
@ -1190,7 +1252,7 @@ const Foam::polyMesh& Foam::mappedPatchBase::sampleMesh() const
|
||||
{
|
||||
return patch_.boundaryMesh().mesh().time().lookupObject<polyMesh>
|
||||
(
|
||||
sampleRegion_
|
||||
sampleRegion()
|
||||
);
|
||||
}
|
||||
|
||||
@ -1199,12 +1261,12 @@ const Foam::polyPatch& Foam::mappedPatchBase::samplePolyPatch() const
|
||||
{
|
||||
const polyMesh& nbrMesh = sampleMesh();
|
||||
|
||||
const label patchI = nbrMesh.boundaryMesh().findPatchID(samplePatch_);
|
||||
const label patchI = nbrMesh.boundaryMesh().findPatchID(samplePatch());
|
||||
|
||||
if (patchI == -1)
|
||||
{
|
||||
FatalErrorIn("mappedPatchBase::samplePolyPatch()")
|
||||
<< "Cannot find patch " << samplePatch_
|
||||
<< "Cannot find patch " << samplePatch()
|
||||
<< " in region " << sampleRegion_ << endl
|
||||
<< "Valid patches are " << nbrMesh.boundaryMesh().names()
|
||||
<< exit(FatalError);
|
||||
@ -1340,46 +1402,60 @@ void Foam::mappedPatchBase::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("sampleMode") << sampleModeNames_[mode_]
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("sampleRegion") << sampleRegion_
|
||||
os.writeKeyword("sampleRegion") << sampleRegion()
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("samplePatch") << samplePatch_
|
||||
os.writeKeyword("samplePatch") << samplePatch()
|
||||
<< token::END_STATEMENT << nl;
|
||||
coupleGroup_.write(os);
|
||||
|
||||
os.writeKeyword("offsetMode") << offsetModeNames_[offsetMode_]
|
||||
<< token::END_STATEMENT << nl;
|
||||
|
||||
switch (offsetMode_)
|
||||
if
|
||||
(
|
||||
offsetMode_ == UNIFORM
|
||||
&& offset_ == vector::zero
|
||||
&& (mode_ == NEARESTPATCHFACE || mode_ == NEARESTPATCHFACEAMI)
|
||||
)
|
||||
{
|
||||
case UNIFORM:
|
||||
{
|
||||
os.writeKeyword("offset") << offset_ << token::END_STATEMENT << nl;
|
||||
break;
|
||||
}
|
||||
case NONUNIFORM:
|
||||
{
|
||||
offsets_.writeEntry("offsets", os);
|
||||
break;
|
||||
}
|
||||
case NORMAL:
|
||||
{
|
||||
os.writeKeyword("distance") << distance_ << token::END_STATEMENT
|
||||
<< nl;
|
||||
break;
|
||||
}
|
||||
// Collocated mode. No need to write offset data
|
||||
}
|
||||
|
||||
if (mode_ == NEARESTPATCHFACEAMI)
|
||||
else
|
||||
{
|
||||
if (AMIReverse_)
|
||||
os.writeKeyword("offsetMode") << offsetModeNames_[offsetMode_]
|
||||
<< token::END_STATEMENT << nl;
|
||||
|
||||
switch (offsetMode_)
|
||||
{
|
||||
os.writeKeyword("flipNormals") << AMIReverse_
|
||||
<< token::END_STATEMENT << nl;
|
||||
case UNIFORM:
|
||||
{
|
||||
os.writeKeyword("offset") << offset_ << token::END_STATEMENT
|
||||
<< nl;
|
||||
break;
|
||||
}
|
||||
case NONUNIFORM:
|
||||
{
|
||||
offsets_.writeEntry("offsets", os);
|
||||
break;
|
||||
}
|
||||
case NORMAL:
|
||||
{
|
||||
os.writeKeyword("distance") << distance_ << token::END_STATEMENT
|
||||
<< nl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!surfDict_.empty())
|
||||
if (mode_ == NEARESTPATCHFACEAMI)
|
||||
{
|
||||
os.writeKeyword(surfDict_.dictName());
|
||||
os << surfDict_;
|
||||
if (AMIReverse_)
|
||||
{
|
||||
os.writeKeyword("flipNormals") << AMIReverse_
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
if (!surfDict_.empty())
|
||||
{
|
||||
os.writeKeyword(surfDict_.dictName());
|
||||
os << surfDict_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,9 +45,13 @@ Description
|
||||
// beforehand)
|
||||
sampleMode nearestCell;
|
||||
|
||||
// If sampleMod is nearestPatchFace : patch to find faces of
|
||||
// If sampleMode is nearestPatchFace : patch to find faces of
|
||||
samplePatch movingWall;
|
||||
|
||||
// If sampleMode is nearestPatchFace : specify patchgroup to find
|
||||
// samplePatch and sampleRegion (if not provided)
|
||||
coupleGroup baffleGroup;
|
||||
|
||||
// How to supply offset (w.r.t. my patch face centres):
|
||||
// - uniform : single offset vector
|
||||
// - nonuniform : per-face offset vector
|
||||
@ -78,6 +82,7 @@ SourceFiles
|
||||
#include "Tuple2.H"
|
||||
#include "pointIndexHit.H"
|
||||
#include "AMIPatchToPatchInterpolation.H"
|
||||
#include "coupleGroupIdentifier.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -180,13 +185,16 @@ protected:
|
||||
const polyPatch& patch_;
|
||||
|
||||
//- Region to sample
|
||||
const word sampleRegion_;
|
||||
mutable word sampleRegion_;
|
||||
|
||||
//- What to sample
|
||||
const sampleMode mode_;
|
||||
|
||||
//- Patch (if in sampleMode NEARESTPATCH*)
|
||||
const word samplePatch_;
|
||||
mutable word samplePatch_;
|
||||
|
||||
//- PatchGroup (if in sampleMode NEARESTPATCH*)
|
||||
const coupleGroupIdentifier coupleGroup_;
|
||||
|
||||
//- How to obtain samples
|
||||
offsetMode offsetMode_;
|
||||
@ -201,7 +209,7 @@ protected:
|
||||
scalar distance_;
|
||||
|
||||
//- Same region
|
||||
const bool sameRegion_;
|
||||
mutable bool sameRegion_;
|
||||
|
||||
|
||||
// Derived information
|
||||
@ -315,6 +323,11 @@ public:
|
||||
//- Construct from dictionary
|
||||
mappedPatchBase(const polyPatch&, const dictionary&);
|
||||
|
||||
//- Construct from dictionary and (collocated) sample mode
|
||||
// (only for nearestPatchFace, nearestPatchFaceAMI, nearestPatchPoint)
|
||||
// Assumes zero offset.
|
||||
mappedPatchBase(const polyPatch&, const sampleMode, const dictionary&);
|
||||
|
||||
//- Construct as copy, resetting patch
|
||||
mappedPatchBase(const polyPatch&, const mappedPatchBase&);
|
||||
|
||||
@ -346,6 +359,9 @@ public:
|
||||
//- Patch (only if NEARESTPATCHFACE)
|
||||
inline const word& samplePatch() const;
|
||||
|
||||
//- PatchGroup (only if NEARESTPATCHFACE)
|
||||
inline const word& coupleGroup() const;
|
||||
|
||||
//- Return size of mapped mesh/patch/boundary
|
||||
inline label sampleSize() const;
|
||||
|
||||
|
||||
@ -32,16 +32,62 @@ Foam::mappedPatchBase::mode() const
|
||||
|
||||
inline const Foam::word& Foam::mappedPatchBase::sampleRegion() const
|
||||
{
|
||||
if (sampleRegion_.empty())
|
||||
{
|
||||
if (!coupleGroup_.valid())
|
||||
{
|
||||
FatalErrorIn("mappedPatchBase::sampleRegion()")
|
||||
<< "Supply either a regionName or a coupleGroup"
|
||||
<< " for patch " << patch_.name()
|
||||
<< " in region " << patch_.boundaryMesh().mesh().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Try and use patchGroup to find samplePatch and sampleRegion
|
||||
label samplePatchID = coupleGroup_.findOtherPatchID
|
||||
(
|
||||
patch_,
|
||||
sampleRegion_
|
||||
);
|
||||
|
||||
samplePatch_ = sampleMesh().boundaryMesh()[samplePatchID].name();
|
||||
}
|
||||
return sampleRegion_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::word& Foam::mappedPatchBase::samplePatch() const
|
||||
{
|
||||
if (samplePatch_.empty())
|
||||
{
|
||||
if (!coupleGroup_.valid())
|
||||
{
|
||||
FatalErrorIn("mappedPatchBase::samplePolyPatch()")
|
||||
<< "Supply either a patchName or a coupleGroup"
|
||||
<< " for patch " << patch_.name()
|
||||
<< " in region " << patch_.boundaryMesh().mesh().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Try and use patchGroup to find samplePatch and sampleRegion
|
||||
label samplePatchID = coupleGroup_.findOtherPatchID
|
||||
(
|
||||
patch_,
|
||||
sampleRegion_
|
||||
);
|
||||
|
||||
samplePatch_ = sampleMesh().boundaryMesh()[samplePatchID].name();
|
||||
}
|
||||
return samplePatch_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::word& Foam::mappedPatchBase::coupleGroup() const
|
||||
{
|
||||
return coupleGroup_.name();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::mappedPatchBase::sampleSize() const
|
||||
{
|
||||
switch (mode_)
|
||||
|
||||
Reference in New Issue
Block a user