Commit 19ae0c6d authored by Sergio Ferraris's avatar Sergio Ferraris
Browse files

Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

parents 0c33cbc9 1d679022
......@@ -40,123 +40,47 @@ internalFacesOnly true;
// Baffles to create.
baffles
{
baffleFaces
baffle1
{
//- Use predefined faceZone to select faces and orientation.
type faceZone;
zoneName baffleFaces;
//- Use surface to select faces and orientation.
type searchableSurface;
surface triSurfaceMesh;
name baffle1D.stl;
//- Optional flip
//flip false;
patches
{
master
{
//- Master side patch
name baffles;
type wall;
//- Optional override of added patchfields. If not specified
// any added patchfields are of type calculated.
patchFields
{
epsilon
{
type epsilonWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
k
{
type kqRWallFunction;
value uniform 0;
}
nut
{
type nutkWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
nuTilda
{
type zeroGradient;
}
p
{
type zeroGradient;
}
U
{
type fixedValue;
value uniform (0 0 0);
}
}
}
slave
// Generate patchGroup baffle1 with two patches:
// - baffle1_master
// - baffle1_slave
patchPairs
{
type wall;
//- Optional override of added patchfields. If not specified
// any added patchfields are of type calculated.
patchFields
{
//- Slave side patch
name baffles;
type wall;
patchFields
U
{
epsilon
{
type epsilonWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
k
{
type kqRWallFunction;
value uniform 0;
}
nut
{
type nutkWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
nuTilda
{
type zeroGradient;
}
p
{
type zeroGradient;
}
U
{
type fixedValue;
value uniform (0 0 0);
}
type fixedValue;
value uniform (0 0 0);
}
}
}
}
cyclicFaces
{
//- Select faces and orientation through a searchableSurface
type searchableSurface;
surface searchablePlate;
//name sphere.stl; // name if surface=triSurfaceMesh
origin (0.099 -0.006 0.004);
span (0 0.012 0.012);
// Generate patches explicitly
patches
{
master
......
......@@ -303,7 +303,9 @@ surfaces
// Sampling on triSurface
type sampledTriSurfaceMesh;
surface integrationPlane.stl;
source boundaryFaces; // sample cells or boundaryFaces
source boundaryFaces; // What to sample: cells (nearest cell)
// insideCells (only triangles inside cell)
// boundaryFaces (nearest boundary face)
interpolate true;
}
);
......
......@@ -14,7 +14,13 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// List of pairs of source/target patches for mapping
// Specify how to map patches. There are three different options:
// - patch exists in the source case: specify mapping (patchMap)
// - patch should be interpolated from internal values in source case
// (cuttingPatches)
// - patch should not be mapped. Default if not in patchMap or cuttingPatches
// List of pairs of target/source patches for mapping
patchMap
(
lid movingWall
......
......@@ -387,6 +387,7 @@ $(cellShape)/cellShapeIO.C
$(cellShape)/cellShapeIOList.C
meshes/Identifiers/patch/patchIdentifier.C
meshes/Identifiers/patch/coupleGroupIdentifier.C
meshes/MeshObject/meshObject.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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_;
}