functionObjects: renamed faceSource -> surfaceRegion, cellSource -> volRegion

The use of the term 'source' in the context of post-processing is
confusing and does not properly describe the process of region
selection.  The new names 'surfaceRegion' and 'volRegion' better
describe the purpose of the functionObjects which is to provide field
processing functionality limited to a specified region of space, either
a surface or volume.

The keyword 'source' is renamed 'regionType' which better describes the
purpose which is to specify the method by which the surface or volume
region is selected.

The keyword to select the name of the surface or volume region is
renamed from 'sourceName' to 'name' consistent with the other
name-changes above.
This commit is contained in:
Henry Weller
2016-06-12 20:56:51 +01:00
parent e2336fefd3
commit 83321bd4f7
99 changed files with 9723 additions and 259 deletions

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "boundaryToFace.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(boundaryToFace, 0);
addToRunTimeSelectionTable(topoSetSource, boundaryToFace, word);
addToRunTimeSelectionTable(topoSetSource, boundaryToFace, istream);
}
Foam::topoSetSource::addToUsageTable Foam::boundaryToFace::usage_
(
boundaryToFace::typeName,
"\n Usage: boundaryToFace\n\n"
" Select all boundary faces\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::boundaryToFace::combine(topoSet& set, const bool add) const
{
for
(
label facei = mesh().nInternalFaces();
facei < mesh().nFaces();
facei++
)
{
addOrDelete(set, facei, add);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::boundaryToFace::boundaryToFace(const polyMesh& mesh)
:
topoSetSource(mesh)
{}
// Construct from dictionary
Foam::boundaryToFace::boundaryToFace(const polyMesh& mesh, const dictionary&)
:
topoSetSource(mesh)
{}
// Construct from Istream
Foam::boundaryToFace::boundaryToFace
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::boundaryToFace::~boundaryToFace()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::boundaryToFace::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all boundary faces ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all boundary faces ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,117 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::boundaryToFace
Description
A topoSetSource to select all external (boundary) faces.
SourceFiles
boundaryToFace.C
\*---------------------------------------------------------------------------*/
#ifndef boundaryToFace_H
#define boundaryToFace_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class boundaryToFace Declaration
\*---------------------------------------------------------------------------*/
class boundaryToFace
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("boundaryToFace");
// Constructors
//- Construct from components
boundaryToFace(const polyMesh&);
//- Construct from dictionary
boundaryToFace
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
boundaryToFace
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~boundaryToFace();
// Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,145 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "boxToFace.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(boxToFace, 0);
addToRunTimeSelectionTable(topoSetSource, boxToFace, word);
addToRunTimeSelectionTable(topoSetSource, boxToFace, istream);
}
Foam::topoSetSource::addToUsageTable Foam::boxToFace::usage_
(
boxToFace::typeName,
"\n Usage: boxToFace ((minx miny minz) (maxx maxy maxz))\n\n"
" Select all face with faceCentre within bounding box\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::boxToFace::combine(topoSet& set, const bool add) const
{
const pointField& ctrs = mesh_.faceCentres();
forAll(ctrs, facei)
{
forAll(bbs_, i)
{
if (bbs_[i].contains(ctrs[facei]))
{
addOrDelete(set, facei, add);
break;
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::boxToFace::boxToFace
(
const polyMesh& mesh,
const treeBoundBoxList& bbs
)
:
topoSetSource(mesh),
bbs_(bbs)
{}
// Construct from dictionary
Foam::boxToFace::boxToFace
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
bbs_
(
dict.found("box")
? treeBoundBoxList(1, treeBoundBox(dict.lookup("box")))
: dict.lookup("boxes")
)
{}
// Construct from Istream
Foam::boxToFace::boxToFace
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
bbs_(1, treeBoundBox(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::boxToFace::~boxToFace()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::boxToFace::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding faces with centre within boxes " << bbs_ << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing faces with centre within boxes " << bbs_ << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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::boxToFace
Description
A topoSetSource to select faces based on face centres inside box.
SourceFiles
boxToFace.C
\*---------------------------------------------------------------------------*/
#ifndef boxToFace_H
#define boxToFace_H
#include "topoSetSource.H"
#include "treeBoundBoxList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class boxToFace Declaration
\*---------------------------------------------------------------------------*/
class boxToFace
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Bounding box.
treeBoundBoxList bbs_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("boxToFace");
// Constructors
//- Construct from components
boxToFace
(
const polyMesh& mesh,
const treeBoundBoxList& bbs
);
//- Construct from dictionary
boxToFace
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
boxToFace
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~boxToFace();
// Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,228 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "cellToFace.H"
#include "polyMesh.H"
#include "cellSet.H"
#include "Time.H"
#include "syncTools.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cellToFace, 0);
addToRunTimeSelectionTable(topoSetSource, cellToFace, word);
addToRunTimeSelectionTable(topoSetSource, cellToFace, istream);
template<>
const char* Foam::NamedEnum
<
Foam::cellToFace::cellAction,
2
>::names[] =
{
"all",
"both"
};
}
Foam::topoSetSource::addToUsageTable Foam::cellToFace::usage_
(
cellToFace::typeName,
"\n Usage: cellToFace <cellSet> all|both\n\n"
" Select -all : all faces of cells in the cellSet\n"
" -both: faces where both neighbours are in the cellSet\n\n"
);
const Foam::NamedEnum<Foam::cellToFace::cellAction, 2>
Foam::cellToFace::cellActionNames_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::cellToFace::combine(topoSet& set, const bool add) const
{
// Load the set
if (!exists(mesh_.time().path()/topoSet::localPath(mesh_, setName_)))
{
SeriousError<< "Cannot load set "
<< setName_ << endl;
}
cellSet loadedSet(mesh_, setName_);
if (option_ == ALL)
{
// Add all faces from cell
forAllConstIter(cellSet, loadedSet, iter)
{
const label celli = iter.key();
const labelList& cFaces = mesh_.cells()[celli];
forAll(cFaces, cFacei)
{
addOrDelete(set, cFaces[cFacei], add);
}
}
}
else if (option_ == BOTH)
{
// Add all faces whose both neighbours are in set.
const label nInt = mesh_.nInternalFaces();
const labelList& own = mesh_.faceOwner();
const labelList& nei = mesh_.faceNeighbour();
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
// Check all internal faces
for (label facei = 0; facei < nInt; facei++)
{
if (loadedSet.found(own[facei]) && loadedSet.found(nei[facei]))
{
addOrDelete(set, facei, add);
}
}
// Get coupled cell status
boolList neiInSet(mesh_.nFaces()-nInt, false);
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchi];
if (pp.coupled())
{
label facei = pp.start();
forAll(pp, i)
{
neiInSet[facei-nInt] = loadedSet.found(own[facei]);
facei++;
}
}
}
syncTools::swapBoundaryFaceList(mesh_, neiInSet);
// Check all boundary faces
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchi];
if (pp.coupled())
{
label facei = pp.start();
forAll(pp, i)
{
if (loadedSet.found(own[facei]) && neiInSet[facei-nInt])
{
addOrDelete(set, facei, add);
}
facei++;
}
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from componenta
Foam::cellToFace::cellToFace
(
const polyMesh& mesh,
const word& setName,
const cellAction option
)
:
topoSetSource(mesh),
setName_(setName),
option_(option)
{}
// Construct from dictionary
Foam::cellToFace::cellToFace
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
setName_(dict.lookup("set")),
option_(cellActionNames_.read(dict.lookup("option")))
{}
// Construct from Istream
Foam::cellToFace::cellToFace
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
setName_(checkIs(is)),
option_(cellActionNames_.read(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cellToFace::~cellToFace()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cellToFace::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding faces according to cellSet " << setName_
<< " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing faces according to cellSet " << setName_
<< " ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,145 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::cellToFace
Description
A topoSetSource to select a faceSet from cells.
Either all faces of cell or some other criterion.
See implementation.
Note: when picking up coupled faces uses cells on neighbouring processors.
SourceFiles
cellToFace.C
\*---------------------------------------------------------------------------*/
#ifndef cellToFace_H
#define cellToFace_H
#include "topoSetSource.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cellToFace Declaration
\*---------------------------------------------------------------------------*/
class cellToFace
:
public topoSetSource
{
public:
//- Enumeration defining the valid options
enum cellAction
{
ALL,
BOTH
};
private:
//- Add usage string
static addToUsageTable usage_;
static const NamedEnum<cellAction, 2> cellActionNames_;
//- Name of set to use
word setName_;
//- Option
cellAction option_;
// Private Member Functions
//- Depending on face to cell option add to or delete from cellSet.
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("cellToFace");
// Constructors
//- Construct from components
cellToFace
(
const polyMesh& mesh,
const word& setName,
const cellAction option
);
//- Construct from dictionary
cellToFace
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
cellToFace
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~cellToFace();
// Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,129 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "faceToFace.H"
#include "polyMesh.H"
#include "faceSet.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(faceToFace, 0);
addToRunTimeSelectionTable(topoSetSource, faceToFace, word);
addToRunTimeSelectionTable(topoSetSource, faceToFace, istream);
}
Foam::topoSetSource::addToUsageTable Foam::faceToFace::usage_
(
faceToFace::typeName,
"\n Usage: faceToFace <faceSet>\n\n"
" Select all faces in the faceSet\n\n"
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::faceToFace::faceToFace
(
const polyMesh& mesh,
const word& setName
)
:
topoSetSource(mesh),
setName_(setName)
{}
// Construct from dictionary
Foam::faceToFace::faceToFace
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
setName_(dict.lookup("set"))
{}
// Construct from Istream
Foam::faceToFace::faceToFace
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
setName_(checkIs(is))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faceToFace::~faceToFace()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::faceToFace::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all faces from faceSet " << setName_ << " ..."
<< endl;
// Load the set
faceSet loadedSet(mesh_, setName_);
set.addSet(loadedSet);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all faces from faceSet " << setName_ << " ..."
<< endl;
// Load the set
faceSet loadedSet(mesh_, setName_);
set.deleteSet(loadedSet);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,118 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::faceToFace
Description
A topoSetSource to select faces based on usage in another faceSet.
SourceFiles
faceToFace.C
\*---------------------------------------------------------------------------*/
#ifndef faceToFace_H
#define faceToFace_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faceToFace Declaration
\*---------------------------------------------------------------------------*/
class faceToFace
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Name of set to use
word setName_;
public:
//- Runtime type information
TypeName("faceToFace");
// Constructors
//- Construct from components
faceToFace
(
const polyMesh& mesh,
const word& setName
);
//- Construct from dictionary
faceToFace
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
faceToFace
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~faceToFace();
// Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,131 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "labelToFace.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(labelToFace, 0);
addToRunTimeSelectionTable(topoSetSource, labelToFace, word);
addToRunTimeSelectionTable(topoSetSource, labelToFace, istream);
}
Foam::topoSetSource::addToUsageTable Foam::labelToFace::usage_
(
labelToFace::typeName,
"\n Usage: labelToFace (i0 i1 .. in)\n\n"
" Select faces by label\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::labelToFace::combine(topoSet& set, const bool add) const
{
forAll(labels_, labelI)
{
addOrDelete(set, labels_[labelI], add);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::labelToFace::labelToFace
(
const polyMesh& mesh,
const labelList& labels
)
:
topoSetSource(mesh),
labels_(labels)
{}
// Construct from dictionary
Foam::labelToFace::labelToFace
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
labels_(dict.lookup("value"))
{}
// Construct from Istream
Foam::labelToFace::labelToFace
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
labels_(checkIs(is))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::labelToFace::~labelToFace()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::labelToFace::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding faces mentioned in dictionary" << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing faces mentioned dictionary" << " ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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::labelToFace
Description
A topoSetSource to select faces given explicitly provided face labels.
SourceFiles
labelToFace.C
\*---------------------------------------------------------------------------*/
#ifndef labelToFace_H
#define labelToFace_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class labelToFace Declaration
\*---------------------------------------------------------------------------*/
class labelToFace
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Cell labels read from dictionary
labelList labels_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("labelToFace");
// Constructors
//- Construct from components
labelToFace
(
const polyMesh& mesh,
const labelList& labels
);
//- Construct from dictionary
labelToFace
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
labelToFace
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~labelToFace();
// Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,171 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "normalToFace.H"
#include "polyMesh.H"
#include "faceSet.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(normalToFace, 0);
addToRunTimeSelectionTable(topoSetSource, normalToFace, word);
addToRunTimeSelectionTable(topoSetSource, normalToFace, istream);
}
Foam::topoSetSource::addToUsageTable Foam::normalToFace::usage_
(
normalToFace::typeName,
"\n Usage: normalToFace (nx ny nz) <tol>\n\n"
" Select faces with normal aligned to unit vector (nx ny nz)\n"
" to within tol\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::normalToFace::setNormal()
{
normal_ /= mag(normal_) + VSMALL;
Info<< " normalToFace : Normalized vector to " << normal_ << endl;
if (tol_ < -1 || tol_ > 1)
{
FatalErrorInFunction
<< "tolerance not within range -1..1 : " << tol_
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::normalToFace::normalToFace
(
const polyMesh& mesh,
const vector& normal,
const scalar tol
)
:
topoSetSource(mesh),
normal_(normal),
tol_(tol)
{
setNormal();
}
// Construct from dictionary
Foam::normalToFace::normalToFace(const polyMesh& mesh, const dictionary& dict)
:
topoSetSource(mesh),
normal_(dict.lookup("normal")),
tol_(readScalar(dict.lookup("cos")))
{
setNormal();
}
// Construct from Istream
Foam::normalToFace::normalToFace(const polyMesh& mesh, Istream& is)
:
topoSetSource(mesh),
normal_(checkIs(is)),
tol_(readScalar(checkIs(is)))
{
setNormal();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::normalToFace::~normalToFace()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::normalToFace::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding faces according to normal being aligned with "
<< normal_ << " (to within " << tol_ << ") ..." << endl;
forAll(mesh_.faceAreas(), facei)
{
vector n = mesh_.faceAreas()[facei];
n /= mag(n) + VSMALL;
if (mag(1 - (n & normal_)) < tol_)
{
set.insert(facei);
}
}
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing faces according to normal being aligned with "
<< normal_ << " (to within " << tol_ << ") ..." << endl;
DynamicList<label> toBeRemoved(set.size()/10);
forAllConstIter(topoSet, set, iter)
{
const label facei = iter.key();
vector n = mesh_.faceAreas()[facei];
n /= mag(n) + VSMALL;
if (mag(1 - (n & normal_)) < tol_)
{
toBeRemoved.append(facei);
}
}
forAll(toBeRemoved, i)
{
set.erase(toBeRemoved[i]);
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,123 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::normalToFace
Description
A topoSetSource to select faces based on normal.
SourceFiles
normalToFace.C
\*---------------------------------------------------------------------------*/
#ifndef normalToFace_H
#define normalToFace_H
#include "topoSetSource.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class normalToFace Declaration
\*---------------------------------------------------------------------------*/
class normalToFace
:
public topoSetSource
{
private:
//- Add usage string
static addToUsageTable usage_;
//- (unit)vector to compare to
vector normal_;
//- Tolerance (i.e. cos of angle between normal_ and faceNormal)
const scalar tol_;
// Private Member Functions
//- Normalize normal and check tolerance
void setNormal();
public:
//- Runtime type information
TypeName("normalToFace");
// Constructors
//- Construct from components
normalToFace
(
const polyMesh& mesh,
const vector& normal,
const scalar tol
);
//- Construct from dictionary
normalToFace(const polyMesh& mesh, const dictionary& dict);
//- Construct from Istream
normalToFace(const polyMesh& mesh, Istream&);
//- Destructor
virtual ~normalToFace();
// Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,161 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "patchToFace.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(patchToFace, 0);
addToRunTimeSelectionTable(topoSetSource, patchToFace, word);
addToRunTimeSelectionTable(topoSetSource, patchToFace, istream);
}
Foam::topoSetSource::addToUsageTable Foam::patchToFace::usage_
(
patchToFace::typeName,
"\n Usage: patchToFace patch\n\n"
" Select all faces in the patch. Note:accepts wildcards for patch.\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::patchToFace::combine(topoSet& set, const bool add) const
{
labelHashSet patchIDs = mesh_.boundaryMesh().patchSet
(
List<wordRe>(1, patchName_),
true, // warn if not found
true // use patch groups if available
);
forAllConstIter(labelHashSet, patchIDs, iter)
{
label patchi = iter.key();
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
Info<< " Found matching patch " << pp.name()
<< " with " << pp.size() << " faces." << endl;
for
(
label facei = pp.start();
facei < pp.start() + pp.size();
facei++
)
{
addOrDelete(set, facei, add);
}
}
if (patchIDs.empty())
{
WarningInFunction
<< "Cannot find any patch named " << patchName_ << endl
<< "Valid names are " << mesh_.boundaryMesh().names() << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::patchToFace::patchToFace
(
const polyMesh& mesh,
const word& patchName
)
:
topoSetSource(mesh),
patchName_(patchName)
{}
// Construct from dictionary
Foam::patchToFace::patchToFace
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
patchName_(dict.lookup("name"))
{}
// Construct from Istream
Foam::patchToFace::patchToFace
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
patchName_(checkIs(is))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchToFace::~patchToFace()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::patchToFace::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all faces of patch " << patchName_ << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all faces of patch " << patchName_ << " ..."
<< endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::patchToFace
Description
A topoSetSource to select faces based on usage in patches.
SourceFiles
patchToFace.C
\*---------------------------------------------------------------------------*/
#ifndef patchToFace_H
#define patchToFace_H
#include "topoSetSource.H"
#include "wordRe.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class patchToFace Declaration
\*---------------------------------------------------------------------------*/
class patchToFace
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Name/regular expression of patch
wordRe patchName_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("patchToFace");
// Constructors
//- Construct from components
patchToFace
(
const polyMesh& mesh,
const word& patchName
);
//- Construct from dictionary
patchToFace
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
patchToFace
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~patchToFace();
// Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,224 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "pointToFace.H"
#include "polyMesh.H"
#include "pointSet.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(pointToFace, 0);
addToRunTimeSelectionTable(topoSetSource, pointToFace, word);
addToRunTimeSelectionTable(topoSetSource, pointToFace, istream);
template<>
const char* Foam::NamedEnum
<
Foam::pointToFace::pointAction,
3
>::names[] =
{
"any",
"all",
"edge"
};
}
Foam::topoSetSource::addToUsageTable Foam::pointToFace::usage_
(
pointToFace::typeName,
"\n Usage: pointToFace <pointSet> any|all|edge\n\n"
" Select faces with\n"
" -any point in the pointSet\n"
" -all points in the pointSet\n\n"
" -two consecutive points (an edge) in the pointSet\n\n"
);
const Foam::NamedEnum<Foam::pointToFace::pointAction, 3>
Foam::pointToFace::pointActionNames_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::pointToFace::combine(topoSet& set, const bool add) const
{
// Load the set
pointSet loadedSet(mesh_, setName_);
if (option_ == ANY)
{
// Add faces with any point in loadedSet
forAllConstIter(pointSet, loadedSet, iter)
{
const label pointi = iter.key();
const labelList& pFaces = mesh_.pointFaces()[pointi];
forAll(pFaces, pFacei)
{
addOrDelete(set, pFaces[pFacei], add);
}
}
}
else if (option_ == ALL)
{
// Add all faces whose points are all in set.
// Count number of points using face.
Map<label> numPoints(loadedSet.size());
forAllConstIter(pointSet, loadedSet, iter)
{
const label pointi = iter.key();
const labelList& pFaces = mesh_.pointFaces()[pointi];
forAll(pFaces, pFacei)
{
const label facei = pFaces[pFacei];
Map<label>::iterator fndFace = numPoints.find(facei);
if (fndFace == numPoints.end())
{
numPoints.insert(facei, 1);
}
else
{
fndFace()++;
}
}
}
// Include faces that are referenced as many times as there are points
// in face -> all points of face
forAllConstIter(Map<label>, numPoints, iter)
{
const label facei = iter.key();
if (iter() == mesh_.faces()[facei].size())
{
addOrDelete(set, facei, add);
}
}
}
else if (option_ == EDGE)
{
const faceList& faces = mesh_.faces();
forAll(faces, facei)
{
const face& f = faces[facei];
forAll(f, fp)
{
if (loadedSet.found(f[fp]) && loadedSet.found(f.nextLabel(fp)))
{
addOrDelete(set, facei, add);
break;
}
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::pointToFace::pointToFace
(
const polyMesh& mesh,
const word& setName,
const pointAction option
)
:
topoSetSource(mesh),
setName_(setName),
option_(option)
{}
// Construct from dictionary
Foam::pointToFace::pointToFace
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
setName_(dict.lookup("set")),
option_(pointActionNames_.read(dict.lookup("option")))
{}
// Construct from Istream
Foam::pointToFace::pointToFace
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
setName_(checkIs(is)),
option_(pointActionNames_.read(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::pointToFace::~pointToFace()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::pointToFace::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding faces according to pointSet " << setName_
<< " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing faces according to pointSet " << setName_
<< " ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,144 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 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::pointToFace
Description
A topoSetSource to select faces based on use of points.
SourceFiles
pointToFace.C
\*---------------------------------------------------------------------------*/
#ifndef pointToFace_H
#define pointToFace_H
#include "topoSetSource.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class pointToFace Declaration
\*---------------------------------------------------------------------------*/
class pointToFace
:
public topoSetSource
{
public:
//- Enumeration defining the valid options
enum pointAction
{
ANY,
ALL,
EDGE
};
private:
//- Add usage string
static addToUsageTable usage_;
static const NamedEnum<pointAction, 3> pointActionNames_;
//- Name of set to use
word setName_;
//- Option
pointAction option_;
// Private Member Functions
//- Depending on face to cell option add to or delete from cellSet.
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("pointToFace");
// Constructors
//- Construct from components
pointToFace
(
const polyMesh& mesh,
const word& setName,
const pointAction option
);
//- Construct from dictionary
pointToFace
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
pointToFace
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~pointToFace();
// Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,254 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 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 "regionToFace.H"
#include "polyMesh.H"
#include "faceSet.H"
#include "mappedPatchBase.H"
#include "indirectPrimitivePatch.H"
#include "PatchTools.H"
#include "addToRunTimeSelectionTable.H"
#include "PatchEdgeFaceWave.H"
#include "patchEdgeFaceRegion.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(regionToFace, 0);
addToRunTimeSelectionTable(topoSetSource, regionToFace, word);
addToRunTimeSelectionTable(topoSetSource, regionToFace, istream);
}
Foam::topoSetSource::addToUsageTable Foam::regionToFace::usage_
(
regionToFace::typeName,
"\n Usage: regionToFace <faceSet> (x y z)\n\n"
" Select all faces in the connected region of the faceSet"
" starting from the point.\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::regionToFace::markZone
(
const indirectPrimitivePatch& patch,
const label proci,
const label facei,
const label zoneI,
labelList& faceZone
) const
{
// Data on all edges and faces
List<patchEdgeFaceRegion> allEdgeInfo(patch.nEdges());
List<patchEdgeFaceRegion> allFaceInfo(patch.size());
DynamicList<label> changedEdges;
DynamicList<patchEdgeFaceRegion> changedInfo;
if (Pstream::myProcNo() == proci)
{
const labelList& fEdges = patch.faceEdges()[facei];
forAll(fEdges, i)
{
changedEdges.append(fEdges[i]);
changedInfo.append(zoneI);
}
}
// Walk
PatchEdgeFaceWave
<
indirectPrimitivePatch,
patchEdgeFaceRegion
> calc
(
mesh_,
patch,
changedEdges,
changedInfo,
allEdgeInfo,
allFaceInfo,
returnReduce(patch.nEdges(), sumOp<label>())
);
forAll(allFaceInfo, facei)
{
if (allFaceInfo[facei].region() == zoneI)
{
faceZone[facei] = zoneI;
}
}
}
void Foam::regionToFace::combine(topoSet& set, const bool add) const
{
Info<< " Loading subset " << setName_ << " to delimit search region."
<< endl;
faceSet subSet(mesh_, setName_);
indirectPrimitivePatch patch
(
IndirectList<face>(mesh_.faces(), subSet.toc()),
mesh_.points()
);
mappedPatchBase::nearInfo ni
(
pointIndexHit(false, Zero, -1),
Tuple2<scalar, label>
(
sqr(GREAT),
Pstream::myProcNo()
)
);
forAll(patch, i)
{
const point& fc = patch.faceCentres()[i];
scalar d2 = magSqr(fc-nearPoint_);
if (!ni.first().hit() || d2 < ni.second().first())
{
ni.second().first() = d2;
ni.first().setHit();
ni.first().setPoint(fc);
ni.first().setIndex(i);
}
}
// Globally reduce
combineReduce(ni, mappedPatchBase::nearestEqOp());
Info<< " Found nearest face at " << ni.first().rawPoint()
<< " on processor " << ni.second().second()
<< " face " << ni.first().index()
<< " distance " << Foam::sqrt(ni.second().first()) << endl;
labelList faceRegion(patch.size(), -1);
markZone
(
patch,
ni.second().second(), // proci
ni.first().index(), // start face
0, // currentZone
faceRegion
);
forAll(faceRegion, facei)
{
if (faceRegion[facei] == 0)
{
addOrDelete(set, patch.addressing()[facei], add);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::regionToFace::regionToFace
(
const polyMesh& mesh,
const word& setName,
const point& nearPoint
)
:
topoSetSource(mesh),
setName_(setName),
nearPoint_(nearPoint)
{}
// Construct from dictionary
Foam::regionToFace::regionToFace
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
setName_(dict.lookup("set")),
nearPoint_(dict.lookup("nearPoint"))
{}
// Construct from Istream
Foam::regionToFace::regionToFace
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
setName_(checkIs(is)),
nearPoint_(checkIs(is))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::regionToFace::~regionToFace()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::regionToFace::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all faces of connected region of set "
<< setName_
<< " starting from point "
<< nearPoint_ << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all cells of connected region of set "
<< setName_
<< " starting from point "
<< nearPoint_ << " ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,139 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 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::regionToFace
Description
A topoSetSource to select faces belonging to topological connected region
(that contains given point)
SourceFiles
regionToFace.C
\*---------------------------------------------------------------------------*/
#ifndef regionToFace_H
#define regionToFace_H
#include "topoSetSource.H"
#include "PackedBoolList.H"
#include "indirectPrimitivePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class regionToFace Declaration
\*---------------------------------------------------------------------------*/
class regionToFace
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Name of set to use
word setName_;
//- Coordinate that is nearest/on connected region
point nearPoint_;
// Private Member Functions
//- Walk edge-face-edge
void markZone
(
const indirectPrimitivePatch& patch,
const label proci,
const label facei,
const label zoneI,
labelList& faceZone
) const;
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("regionToFace");
// Constructors
//- Construct from components
regionToFace
(
const polyMesh& mesh,
const word& setName,
const point& nearPoint
);
//- Construct from dictionary
regionToFace
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
regionToFace
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~regionToFace();
// Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,162 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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 "zoneToFace.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(zoneToFace, 0);
addToRunTimeSelectionTable(topoSetSource, zoneToFace, word);
addToRunTimeSelectionTable(topoSetSource, zoneToFace, istream);
}
Foam::topoSetSource::addToUsageTable Foam::zoneToFace::usage_
(
zoneToFace::typeName,
"\n Usage: zoneToFace zone\n\n"
" Select all faces in the faceZone."
" Note:accepts wildcards for zone.\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::zoneToFace::combine(topoSet& set, const bool add) const
{
bool hasMatched = false;
forAll(mesh_.faceZones(), i)
{
const faceZone& zone = mesh_.faceZones()[i];
if (zoneName_.match(zone.name()))
{
const labelList& faceLabels = mesh_.faceZones()[i];
Info<< " Found matching zone " << zone.name()
<< " with " << faceLabels.size() << " faces." << endl;
hasMatched = true;
forAll(faceLabels, i)
{
// Only do active faces
if (faceLabels[i] < mesh_.nFaces())
{
addOrDelete(set, faceLabels[i], add);
}
}
}
}
if (!hasMatched)
{
WarningInFunction
<< "Cannot find any faceZone named " << zoneName_ << endl
<< "Valid names are " << mesh_.faceZones().names() << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::zoneToFace::zoneToFace
(
const polyMesh& mesh,
const word& zoneName
)
:
topoSetSource(mesh),
zoneName_(zoneName)
{}
// Construct from dictionary
Foam::zoneToFace::zoneToFace
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
zoneName_(dict.lookup("name"))
{}
// Construct from Istream
Foam::zoneToFace::zoneToFace
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
zoneName_(checkIs(is))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::zoneToFace::~zoneToFace()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::zoneToFace::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all faces of faceZone " << zoneName_ << " ..."
<< endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all faces of faceZone " << zoneName_ << " ..."
<< endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::zoneToFace
Description
A topoSetSource to select faces based on faceZone.
SourceFiles
zoneToFace.C
\*---------------------------------------------------------------------------*/
#ifndef zoneToFace_H
#define zoneToFace_H
#include "topoSetSource.H"
#include "wordRe.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class zoneToFace Declaration
\*---------------------------------------------------------------------------*/
class zoneToFace
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Name/regular expression of cellZone
wordRe zoneName_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("zoneToFace");
// Constructors
//- Construct from components
zoneToFace
(
const polyMesh& mesh,
const word& zoneName
);
//- Construct from dictionary
zoneToFace
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
zoneToFace
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~zoneToFace();
// Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,144 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "boxToCell.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(boxToCell, 0);
addToRunTimeSelectionTable(topoSetSource, boxToCell, word);
addToRunTimeSelectionTable(topoSetSource, boxToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::boxToCell::usage_
(
boxToCell::typeName,
"\n Usage: boxToCell (minx miny minz) (maxx maxy maxz)\n\n"
" Select all cells with cellCentre within bounding box\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::boxToCell::combine(topoSet& set, const bool add) const
{
const pointField& ctrs = mesh_.cellCentres();
forAll(ctrs, celli)
{
forAll(bbs_, i)
{
if (bbs_[i].contains(ctrs[celli]))
{
addOrDelete(set, celli, add);
break;
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::boxToCell::boxToCell
(
const polyMesh& mesh,
const treeBoundBoxList& bbs
)
:
topoSetSource(mesh),
bbs_(bbs)
{}
// Construct from dictionary
Foam::boxToCell::boxToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
bbs_
(
dict.found("box")
? treeBoundBoxList(1, treeBoundBox(dict.lookup("box")))
: dict.lookup("boxes")
)
{}
// Construct from Istream
Foam::boxToCell::boxToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
bbs_(1, treeBoundBox(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::boxToCell::~boxToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::boxToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells with center within boxes " << bbs_ << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells with center within boxes " << bbs_ << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,127 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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::boxToCell
Description
A topoSetSource to select cells based on cell centres inside box(es).
SourceFiles
boxToCell.C
\*---------------------------------------------------------------------------*/
#ifndef boxToCell_H
#define boxToCell_H
#include "topoSetSource.H"
#include "treeBoundBoxList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class boxToCell Declaration
\*---------------------------------------------------------------------------*/
class boxToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Bounding box.
treeBoundBoxList bbs_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("boxToCell");
// Constructors
//- Construct from components
boxToCell
(
const polyMesh& mesh,
const treeBoundBoxList& bbs
);
//- Construct from dictionary
boxToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
boxToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~boxToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,129 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "cellToCell.H"
#include "polyMesh.H"
#include "cellSet.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cellToCell, 0);
addToRunTimeSelectionTable(topoSetSource, cellToCell, word);
addToRunTimeSelectionTable(topoSetSource, cellToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::cellToCell::usage_
(
cellToCell::typeName,
"\n Usage: cellToCell <cellSet>\n\n"
" Select all cells in the cellSet\n\n"
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::cellToCell::cellToCell
(
const polyMesh& mesh,
const word& setName
)
:
topoSetSource(mesh),
setName_(setName)
{}
// Construct from dictionary
Foam::cellToCell::cellToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
setName_(dict.lookup("set"))
{}
// Construct from Istream
Foam::cellToCell::cellToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
setName_(checkIs(is))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cellToCell::~cellToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cellToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::ADD) || (action == topoSetSource::NEW))
{
Info<< " Adding all elements of cellSet " << setName_ << " ..."
<< endl;
// Load the set
cellSet loadedSet(mesh_, setName_);
set.addSet(loadedSet);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all elements of cellSet " << setName_ << " ..."
<< endl;
// Load the set
cellSet loadedSet(mesh_, setName_);
set.deleteSet(loadedSet);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,118 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::cellToCell
Description
A topoSetSource to select the cells from another cellSet.
SourceFiles
cellToCell.C
\*---------------------------------------------------------------------------*/
#ifndef cellToCell_H
#define cellToCell_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cellToCell Declaration
\*---------------------------------------------------------------------------*/
class cellToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Name of set to use
word setName_;
public:
//- Runtime type information
TypeName("cellToCell");
// Constructors
//- Construct from components
cellToCell
(
const polyMesh& mesh,
const word& setName
);
//- Construct from dictionary
cellToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
cellToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~cellToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,161 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "cylinderAnnulusToCell.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cylinderAnnulusToCell, 0);
addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToCell, word);
addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::cylinderAnnulusToCell::usage_
(
cylinderAnnulusToCell::typeName,
"\n Usage: cylinderAnnulusToCell (p1X p1Y p1Z) (p2X p2Y p2Z)"
" outerRadius innerRadius\n\n"
" Select all cells with cell centre within bounding cylinder annulus\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::cylinderAnnulusToCell::combine(topoSet& set, const bool add) const
{
const vector axis = p2_ - p1_;
const scalar orad2 = sqr(outerRadius_);
const scalar irad2 = sqr(innerRadius_);
const scalar magAxis2 = magSqr(axis);
const pointField& ctrs = mesh_.cellCentres();
forAll(ctrs, celli)
{
vector d = ctrs[celli] - p1_;
scalar magD = d & axis;
if ((magD > 0) && (magD < magAxis2))
{
scalar d2 = (d & d) - sqr(magD)/magAxis2;
if ((d2 < orad2) && (d2 > irad2))
{
addOrDelete(set, celli, add);
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cylinderAnnulusToCell::cylinderAnnulusToCell
(
const polyMesh& mesh,
const vector& p1,
const vector& p2,
const scalar outerRadius,
const scalar innerRadius
)
:
topoSetSource(mesh),
p1_(p1),
p2_(p2),
outerRadius_(outerRadius),
innerRadius_(innerRadius)
{}
Foam::cylinderAnnulusToCell::cylinderAnnulusToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
p1_(dict.lookup("p1")),
p2_(dict.lookup("p2")),
outerRadius_(readScalar(dict.lookup("outerRadius"))),
innerRadius_(readScalar(dict.lookup("innerRadius")))
{}
// Construct from Istream
Foam::cylinderAnnulusToCell::cylinderAnnulusToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
p1_(checkIs(is)),
p2_(checkIs(is)),
outerRadius_(readScalar(checkIs(is))),
innerRadius_(readScalar(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cylinderAnnulusToCell::~cylinderAnnulusToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cylinderAnnulusToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells with centre within cylinder annulus,"
<< " with p1 = "
<< p1_ << ", p2 = " << p2_ << " and outer radius = " << outerRadius_
<< " and inner radius = " << innerRadius_
<< endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells with centre within cylinder, with p1 = "
<< p1_ << ", p2 = " << p2_ << " and outer radius = " << outerRadius_
<< " and inner radius " << innerRadius_
<< endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,138 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::cylinderAnnulusToCell
Description
A topoSetSource to select cells based on cell centres inside a
cylinder annulus.
SourceFiles
cylinderAnnulusToCell.C
\*---------------------------------------------------------------------------*/
#ifndef cylinderAnnulusToCell_H
#define cylinderAnnulusToCell_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cylinderAnnulusToCell Declaration
\*---------------------------------------------------------------------------*/
class cylinderAnnulusToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- First point on cylinder axis
vector p1_;
//- Second point on cylinder axis
vector p2_;
//- Outer Radius
scalar outerRadius_;
//- Inner Radius
scalar innerRadius_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("cylinderAnnulusToCell");
// Constructors
//- Construct from components
cylinderAnnulusToCell
(
const polyMesh& mesh,
const vector& p1,
const vector& p2,
const scalar outerRadius,
const scalar innerRadius
);
//- Construct from dictionary
cylinderAnnulusToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
cylinderAnnulusToCell
(
const polyMesh& mesh,
Istream&
);
// Destructor
virtual ~cylinderAnnulusToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "cylinderToCell.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cylinderToCell, 0);
addToRunTimeSelectionTable(topoSetSource, cylinderToCell, word);
addToRunTimeSelectionTable(topoSetSource, cylinderToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::cylinderToCell::usage_
(
cylinderToCell::typeName,
"\n Usage: cylinderToCell (p1X p1Y p1Z) (p2X p2Y p2Z) radius\n\n"
" Select all cells with cell centre within bounding cylinder\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::cylinderToCell::combine(topoSet& set, const bool add) const
{
const vector axis = p2_ - p1_;
const scalar rad2 = sqr(radius_);
const scalar magAxis2 = magSqr(axis);
const pointField& ctrs = mesh_.cellCentres();
forAll(ctrs, celli)
{
vector d = ctrs[celli] - p1_;
scalar magD = d & axis;
if ((magD > 0) && (magD < magAxis2))
{
scalar d2 = (d & d) - sqr(magD)/magAxis2;
if (d2 < rad2)
{
addOrDelete(set, celli, add);
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cylinderToCell::cylinderToCell
(
const polyMesh& mesh,
const vector& p1,
const vector& p2,
const scalar radius
)
:
topoSetSource(mesh),
p1_(p1),
p2_(p2),
radius_(radius)
{}
Foam::cylinderToCell::cylinderToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
p1_(dict.lookup("p1")),
p2_(dict.lookup("p2")),
radius_(readScalar(dict.lookup("radius")))
{}
// Construct from Istream
Foam::cylinderToCell::cylinderToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
p1_(checkIs(is)),
p2_(checkIs(is)),
radius_(readScalar(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cylinderToCell::~cylinderToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cylinderToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells with centre within cylinder, with p1 = "
<< p1_ << ", p2 = " << p2_ << " and radius = " << radius_ << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells with centre within cylinder, with p1 = "
<< p1_ << ", p2 = " << p2_ << " and radius = " << radius_ << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::cylinderToCell
Description
A topoSetSource to select cells based on cell centres inside a cylinder.
SourceFiles
cylinderToCell.C
\*---------------------------------------------------------------------------*/
#ifndef cylinderToCell_H
#define cylinderToCell_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cylinderToCell Declaration
\*---------------------------------------------------------------------------*/
class cylinderToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- First point on cylinder axis
vector p1_;
//- Second point on cylinder axis
vector p2_;
//- Radius
scalar radius_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("cylinderToCell");
// Constructors
//- Construct from components
cylinderToCell
(
const polyMesh& mesh,
const vector& p1,
const vector& p2,
const scalar radius
);
//- Construct from dictionary
cylinderToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
cylinderToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~cylinderToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,226 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "faceToCell.H"
#include "polyMesh.H"
#include "faceSet.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(faceToCell, 0);
addToRunTimeSelectionTable(topoSetSource, faceToCell, word);
addToRunTimeSelectionTable(topoSetSource, faceToCell, istream);
template<>
const char* Foam::NamedEnum
<
Foam::faceToCell::faceAction,
4
>::names[] =
{
"neighbour",
"owner",
"any",
"all"
};
}
Foam::topoSetSource::addToUsageTable Foam::faceToCell::usage_
(
faceToCell::typeName,
"\n Usage: faceToCell <faceSet> neighbour|owner|any|all\n\n"
" Select cells that are the owner|neighbour|any"
" of the faces in the faceSet or where all faces are in the faceSet\n\n"
);
const Foam::NamedEnum<Foam::faceToCell::faceAction, 4>
Foam::faceToCell::faceActionNames_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faceToCell::combine(topoSet& set, const bool add) const
{
// Load the set
faceSet loadedSet(mesh_, setName_);
// Handle owner/neighbour/any selection
forAllConstIter(faceSet, loadedSet, iter)
{
const label facei = iter.key();
if ((option_ == OWNER) || (option_ == ANY))
{
const label celli = mesh_.faceOwner()[facei];
addOrDelete(set, celli, add);
}
if (mesh_.isInternalFace(facei))
{
if ((option_ == NEIGHBOUR) || (option_ == ANY))
{
const label celli = mesh_.faceNeighbour()[facei];
addOrDelete(set, celli, add);
}
}
}
// Handle all selection.
if (option_ == ALL)
{
// Count number of selected faces per cell.
Map<label> facesPerCell(loadedSet.size());
forAllConstIter(faceSet, loadedSet, iter)
{
const label facei = iter.key();
const label own = mesh_.faceOwner()[facei];
Map<label>::iterator fndOwn = facesPerCell.find(own);
if (fndOwn == facesPerCell.end())
{
facesPerCell.insert(own, 1);
}
else
{
fndOwn()++;
}
if (mesh_.isInternalFace(facei))
{
label nei = mesh_.faceNeighbour()[facei];
Map<label>::iterator fndNei = facesPerCell.find(nei);
if (fndNei == facesPerCell.end())
{
facesPerCell.insert(nei, 1);
}
else
{
fndNei()++;
}
}
}
// Include cells that are referenced as many times as they have faces
// -> all faces in set.
forAllConstIter(Map<label>, facesPerCell, iter)
{
const label celli = iter.key();
if (iter() == mesh_.cells()[celli].size())
{
addOrDelete(set, celli, add);
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::faceToCell::faceToCell
(
const polyMesh& mesh,
const word& setName,
const faceAction option
)
:
topoSetSource(mesh),
setName_(setName),
option_(option)
{}
// Construct from dictionary
Foam::faceToCell::faceToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
setName_(dict.lookup("set")),
option_(faceActionNames_.read(dict.lookup("option")))
{}
// Construct from Istream
Foam::faceToCell::faceToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
setName_(checkIs(is)),
option_(faceActionNames_.read(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faceToCell::~faceToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::faceToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells according to faceSet " << setName_
<< " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells according to faceSet " << setName_
<< " ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,144 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::faceToCell
Description
A topoSetSource to select cells based on usage in faces.
SourceFiles
faceToCell.C
\*---------------------------------------------------------------------------*/
#ifndef faceToCell_H
#define faceToCell_H
#include "topoSetSource.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faceToCell Declaration
\*---------------------------------------------------------------------------*/
class faceToCell
:
public topoSetSource
{
public:
//- Enumeration defining the valid options
enum faceAction
{
NEIGHBOUR,
OWNER,
ANY,
ALL
};
private:
static const NamedEnum<faceAction, 4> faceActionNames_;
//- Add usage string
static addToUsageTable usage_;
//- Name of set to use
word setName_;
//- Option
faceAction option_;
// Private Member Functions
//- Depending on face to cell option add to or delete from cellSet.
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("faceToCell");
// Constructors
//- Construct from components
faceToCell
(
const polyMesh& mesh,
const word& setName,
const faceAction option
);
//- Construct from dictionary
faceToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
faceToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~faceToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,183 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "faceZoneToCell.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(faceZoneToCell, 0);
addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, word);
addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, istream);
template<>
const char* Foam::NamedEnum
<
Foam::faceZoneToCell::faceAction,
2
>::names[] =
{
"master",
"slave"
};
}
Foam::topoSetSource::addToUsageTable Foam::faceZoneToCell::usage_
(
faceZoneToCell::typeName,
"\n Usage: faceZoneToCell zone master|slave\n\n"
" Select master or slave side of the faceZone."
" Note:accepts wildcards for zone.\n\n"
);
const Foam::NamedEnum<Foam::faceZoneToCell::faceAction, 2>
Foam::faceZoneToCell::faceActionNames_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
{
bool hasMatched = false;
forAll(mesh_.faceZones(), i)
{
const faceZone& zone = mesh_.faceZones()[i];
if (zoneName_.match(zone.name()))
{
const labelList& cellLabels =
(
option_ == MASTER
? zone.masterCells()
: zone.slaveCells()
);
Info<< " Found matching zone " << zone.name()
<< " with " << cellLabels.size() << " cells on selected side."
<< endl;
hasMatched = true;
forAll(cellLabels, i)
{
// Only do active cells
if (cellLabels[i] >= 0 && cellLabels[i] < mesh_.nCells())
{
addOrDelete(set, cellLabels[i], add);
}
}
}
}
if (!hasMatched)
{
WarningInFunction
<< "Cannot find any faceZone named " << zoneName_ << endl
<< "Valid names are " << mesh_.faceZones().names() << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::faceZoneToCell::faceZoneToCell
(
const polyMesh& mesh,
const word& zoneName,
const faceAction option
)
:
topoSetSource(mesh),
zoneName_(zoneName),
option_(option)
{}
// Construct from dictionary
Foam::faceZoneToCell::faceZoneToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
zoneName_(dict.lookup("name")),
option_(faceActionNames_.read(dict.lookup("option")))
{}
// Construct from Istream
Foam::faceZoneToCell::faceZoneToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
zoneName_(checkIs(is)),
option_(faceActionNames_.read(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faceZoneToCell::~faceZoneToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::faceZoneToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all " << faceActionNames_[option_]
<< " cells of faceZone " << zoneName_ << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all " << faceActionNames_[option_]
<< " cells of faceZone " << zoneName_ << " ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,141 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::faceZoneToCell
Description
A topoSetSource to select cells based on side of faceZone.
SourceFiles
faceZoneToCell.C
\*---------------------------------------------------------------------------*/
#ifndef faceZoneToCell_H
#define faceZoneToCell_H
#include "topoSetSource.H"
#include "wordRe.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faceZoneToCell Declaration
\*---------------------------------------------------------------------------*/
class faceZoneToCell
:
public topoSetSource
{
public:
//- Enumeration defining the valid options
enum faceAction
{
MASTER,
SLAVE
};
private:
// Private data
static const NamedEnum<faceAction, 2> faceActionNames_;
//- Add usage string
static addToUsageTable usage_;
//- Name/regular expression of faceZone
wordRe zoneName_;
//- Option
faceAction option_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("faceZoneToCell");
// Constructors
//- Construct from components
faceZoneToCell
(
const polyMesh& mesh,
const word& zoneName,
const faceAction option
);
//- Construct from dictionary
faceZoneToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
faceZoneToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~faceZoneToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,97 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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::fieldDictionary
Description
Read field as dictionary (without mesh).
\*---------------------------------------------------------------------------*/
#ifndef fieldDictionary_H
#define fieldDictionary_H
#include "regIOobject.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fieldDictionary Declaration
\*---------------------------------------------------------------------------*/
class fieldDictionary
:
public regIOobject,
public dictionary
{
const word type_;
public:
// Redefine type name to be of the instantiated type
virtual const word& type() const
{
return type_;
}
// Constructors
//- Construct from ioobject and overloaded typename.
fieldDictionary(const IOobject& io, const word& type)
:
regIOobject(io),
dictionary(readStream(type)),
type_(type)
{
close();
}
// Member functions
bool writeData(Ostream& os) const
{
static_cast<const dictionary&>(*this).write(os, false);
return os.good();
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,230 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "fieldToCell.H"
#include "polyMesh.H"
#include "cellSet.H"
#include "Time.H"
#include "IFstream.H"
#include "fieldDictionary.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(fieldToCell, 0);
addToRunTimeSelectionTable(topoSetSource, fieldToCell, word);
addToRunTimeSelectionTable(topoSetSource, fieldToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::fieldToCell::usage_
(
fieldToCell::typeName,
"\n Usage: fieldToCell field min max\n\n"
" Select all cells with field value >= min and <= max\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::fieldToCell::applyToSet
(
const topoSetSource::setAction action,
const scalarField& field,
topoSet& set
) const
{
Info<< " Field min:" << min(field)
<< " max:" << max(field) << endl;
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all cells with value of field " << fieldName_
<< " within range " << min_ << ".." << max_ << endl;
forAll(field, celli)
{
if (field[celli] >= min_ && field[celli] <= max_)
{
set.insert(celli);
}
}
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all cells with value of field " << fieldName_
<< " within range " << min_ << ".." << max_ << endl;
forAll(field, celli)
{
if (field[celli] >= min_ && field[celli] <= max_)
{
set.erase(celli);
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::fieldToCell::fieldToCell
(
const polyMesh& mesh,
const word& fieldName,
const scalar min,
const scalar max
)
:
topoSetSource(mesh),
fieldName_(fieldName),
min_(min),
max_(max)
{}
// Construct from dictionary
Foam::fieldToCell::fieldToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
fieldName_(dict.lookup("field")),
min_(readScalar(dict.lookup("min"))),
max_(readScalar(dict.lookup("max")))
{}
// Construct from Istream
Foam::fieldToCell::fieldToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
fieldName_(checkIs(is)),
min_(readScalar(checkIs(is))),
max_(readScalar(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldToCell::~fieldToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
// // Construct temporary fvMesh from polyMesh
// fvMesh fMesh
// (
// mesh(), // IOobject
// mesh().points(),
// mesh().faces(),
// mesh().cells()
// );
//
// const polyBoundaryMesh& patches = mesh().boundaryMesh();
//
// List<polyPatch*> newPatches(patches.size());
// forAll(patches, patchi)
// {
// const polyPatch& pp = patches[patchi];
//
// newPatches[patchi] =
// patches[patchi].clone
// (
// fMesh.boundaryMesh(),
// patchi,
// pp.size(),
// pp.start()
// ).ptr();
// }
// fMesh.addFvPatches(newPatches);
// Try to load field
IOobject fieldObject
(
fieldName_,
mesh().time().timeName(),
mesh(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE,
false
);
if (!fieldObject.headerOk())
{
WarningInFunction
<< "Cannot read field " << fieldName_
<< " from time " << mesh().time().timeName() << endl;
}
else if (fieldObject.headerClassName() == "volScalarField")
{
IFstream str(fieldObject.filePath());
// Read dictionary
fieldDictionary fieldDict(fieldObject, fieldObject.headerClassName());
scalarField internalVals("internalField", fieldDict, mesh().nCells());
applyToSet(action, internalVals, set);
}
else if (fieldObject.headerClassName() == "volVectorField")
{
IFstream str(fieldObject.filePath());
// Read dictionary
fieldDictionary fieldDict(fieldObject, fieldObject.headerClassName());
vectorField internalVals("internalField", fieldDict, mesh().nCells());
applyToSet(action, mag(internalVals), set);
}
else
{
WarningInFunction
<< "Cannot handle fields of type " << fieldObject.headerClassName()
<< endl;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,140 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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::fieldToCell
Description
A topoSetSource to select cells based on field values.
SourceFiles
fieldToCell.C
\*---------------------------------------------------------------------------*/
#ifndef fieldToCell_H
#define fieldToCell_H
#include "topoSetSource.H"
#include "scalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fieldToCell Declaration
\*---------------------------------------------------------------------------*/
class fieldToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Name of volScalarField
word fieldName_;
//- Min to subset field values with
scalar min_;
//- Max ,,
scalar max_;
// Private Member Functions
//- Depending on field values add to or delete from cellSet.
void applyToSet
(
const topoSetSource::setAction action,
const scalarField& field,
topoSet& set
) const;
public:
//- Runtime type information
TypeName("fieldToCell");
// Constructors
//- Construct from components
fieldToCell
(
const polyMesh& mesh,
const word& fieldName,
const scalar min,
const scalar max
);
//- Construct from dictionary
fieldToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
fieldToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~fieldToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,131 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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 "labelToCell.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(labelToCell, 0);
addToRunTimeSelectionTable(topoSetSource, labelToCell, word);
addToRunTimeSelectionTable(topoSetSource, labelToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::labelToCell::usage_
(
labelToCell::typeName,
"\n Usage: labelToCell (i0 i1 .. in)\n\n"
" Select cells by cellLabel\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::labelToCell::combine(topoSet& set, const bool add) const
{
forAll(labels_, labelI)
{
addOrDelete(set, labels_[labelI], add);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::labelToCell::labelToCell
(
const polyMesh& mesh,
const labelList& labels
)
:
topoSetSource(mesh),
labels_(labels)
{}
// Construct from dictionary
Foam::labelToCell::labelToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
labels_(dict.lookup("value"))
{}
// Construct from Istream
Foam::labelToCell::labelToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
labels_(checkIs(is))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::labelToCell::~labelToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::labelToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells mentioned in dictionary" << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells mentioned in dictionary" << " ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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::labelToCell
Description
A topoSetSource to select cells based on explicitly given labels.
SourceFiles
labelToCell.C
\*---------------------------------------------------------------------------*/
#ifndef labelToCell_H
#define labelToCell_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class labelToCell Declaration
\*---------------------------------------------------------------------------*/
class labelToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Cell labels read from dictionary
labelList labels_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("labelToCell");
// Constructors
//- Construct from components
labelToCell
(
const polyMesh& mesh,
const labelList& labels
);
//- Construct from dictionary
labelToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
labelToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~labelToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,174 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "nbrToCell.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(nbrToCell, 0);
addToRunTimeSelectionTable(topoSetSource, nbrToCell, word);
addToRunTimeSelectionTable(topoSetSource, nbrToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::nbrToCell::usage_
(
nbrToCell::typeName,
"\n Usage: nbrToCell <nNeighbours>\n\n"
" Select all cells with <= nNeighbours neighbouring cells\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::nbrToCell::combine(topoSet& set, const bool add) const
{
const cellList& cells = mesh().cells();
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
boolList isCoupled(mesh_.nFaces()-mesh_.nInternalFaces(), false);
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchi];
if (pp.coupled())
{
label facei = pp.start();
forAll(pp, i)
{
isCoupled[facei-mesh_.nInternalFaces()] = true;
facei++;
}
}
}
forAll(cells, celli)
{
const cell& cFaces = cells[celli];
label nNbrCells = 0;
forAll(cFaces, i)
{
label facei = cFaces[i];
if (mesh_.isInternalFace(facei))
{
nNbrCells++;
}
else if (isCoupled[facei-mesh_.nInternalFaces()])
{
nNbrCells++;
}
}
if (nNbrCells <= minNbrs_)
{
addOrDelete(set, celli, add);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::nbrToCell::nbrToCell
(
const polyMesh& mesh,
const label minNbrs
)
:
topoSetSource(mesh),
minNbrs_(minNbrs)
{}
// Construct from dictionary
Foam::nbrToCell::nbrToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
minNbrs_(readLabel(dict.lookup("neighbours")))
{}
// Construct from Istream
Foam::nbrToCell::nbrToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
minNbrs_(readLabel(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::nbrToCell::~nbrToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::nbrToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells with only " << minNbrs_ << " or less"
" neighbouring cells" << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells with only " << minNbrs_ << " or less"
" neighbouring cells" << " ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::nbrToCell
Description
A topoSetSource to select cells based on number of neighbouring cells
(i.e. number of internal or coupled faces)
SourceFiles
nbrToCell.C
\*---------------------------------------------------------------------------*/
#ifndef nbrToCell_H
#define nbrToCell_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class nbrToCell Declaration
\*---------------------------------------------------------------------------*/
class nbrToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Number of internal faces on cell
label minNbrs_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("nbrToCell");
// Constructors
//- Construct from components
nbrToCell
(
const polyMesh& mesh,
const label minNbrs
);
//- Construct from dictionary
nbrToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
nbrToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~nbrToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,130 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "nearestToCell.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(nearestToCell, 0);
addToRunTimeSelectionTable(topoSetSource, nearestToCell, word);
addToRunTimeSelectionTable(topoSetSource, nearestToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::nearestToCell::usage_
(
nearestToCell::typeName,
"\n Usage: nearestToCell (pt0 .. ptn)\n\n"
" Select the nearest cell for each of the points pt0 ..ptn\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::nearestToCell::combine(topoSet& set, const bool add) const
{
forAll(points_, pointi)
{
addOrDelete(set, mesh_.findNearestCell(points_[pointi]), add);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::nearestToCell::nearestToCell
(
const polyMesh& mesh,
const pointField& points
)
:
topoSetSource(mesh),
points_(points)
{}
// Construct from dictionary
Foam::nearestToCell::nearestToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
points_(dict.lookup("points"))
{}
// Construct from Istream
Foam::nearestToCell::nearestToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
points_(checkIs(is))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::nearestToCell::~nearestToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::nearestToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells nearest to " << points_ << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells nearest to " << points_ << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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::nearestToCell
Description
A topoSetSource to select cells nearest to points.
SourceFiles
nearestToCell.C
\*---------------------------------------------------------------------------*/
#ifndef nearestToCell_H
#define nearestToCell_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class nearestToCell Declaration
\*---------------------------------------------------------------------------*/
class nearestToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Points to select nearest to
pointField points_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("nearestToCell");
// Constructors
//- Construct from components
nearestToCell
(
const polyMesh& mesh,
const pointField& points
);
//- Construct from dictionary
nearestToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
nearestToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~nearestToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,183 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "pointToCell.H"
#include "polyMesh.H"
#include "pointSet.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(pointToCell, 0);
addToRunTimeSelectionTable(topoSetSource, pointToCell, word);
addToRunTimeSelectionTable(topoSetSource, pointToCell, istream);
template<>
const char* Foam::NamedEnum
<
Foam::pointToCell::pointAction,
2
>::names[] =
{
"any",
"edge"
};
}
Foam::topoSetSource::addToUsageTable Foam::pointToCell::usage_
(
pointToCell::typeName,
"\n Usage: pointToCell <pointSet> any|edge\n\n"
" Select all cells with any point ('any') or any edge ('edge')"
" in the pointSet\n\n"
);
const Foam::NamedEnum<Foam::pointToCell::pointAction, 2>
Foam::pointToCell::pointActionNames_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::pointToCell::combine(topoSet& set, const bool add) const
{
// Load the set
pointSet loadedSet(mesh_, setName_);
// Handle any selection
if (option_ == ANY)
{
forAllConstIter(pointSet, loadedSet, iter)
{
const label pointi = iter.key();
const labelList& pCells = mesh_.pointCells()[pointi];
forAll(pCells, pCelli)
{
addOrDelete(set, pCells[pCelli], add);
}
}
}
else if (option_ == EDGE)
{
const faceList& faces = mesh_.faces();
forAll(faces, facei)
{
const face& f = faces[facei];
forAll(f, fp)
{
if (loadedSet.found(f[fp]) && loadedSet.found(f.nextLabel(fp)))
{
addOrDelete(set, mesh_.faceOwner()[facei], add);
if (mesh_.isInternalFace(facei))
{
addOrDelete(set, mesh_.faceNeighbour()[facei], add);
}
}
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::pointToCell::pointToCell
(
const polyMesh& mesh,
const word& setName,
const pointAction option
)
:
topoSetSource(mesh),
setName_(setName),
option_(option)
{}
// Construct from dictionary
Foam::pointToCell::pointToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
setName_(dict.lookup("set")),
option_(pointActionNames_.read(dict.lookup("option")))
{}
// Construct from Istream
Foam::pointToCell::pointToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
setName_(checkIs(is)),
option_(pointActionNames_.read(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::pointToCell::~pointToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::pointToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells according to pointSet " << setName_
<< " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells according to pointSet " << setName_
<< " ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,141 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 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::pointToCell
Description
A topoSetSource to select cells based on usage of points.
SourceFiles
pointToCell.C
\*---------------------------------------------------------------------------*/
#ifndef pointToCell_H
#define pointToCell_H
#include "topoSetSource.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class pointToCell Declaration
\*---------------------------------------------------------------------------*/
class pointToCell
:
public topoSetSource
{
public:
//- Enumeration defining the valid options
enum pointAction
{
ANY, // Cells using any point in set
EDGE // Cells using an edge with both points in set
//ALL // Possible extension: cells whose all points are in set
};
private:
//- Add usage string
static addToUsageTable usage_;
static const NamedEnum<pointAction, 2> pointActionNames_;
//- Name of set to use
word setName_;
//- Option
pointAction option_;
// Private Member Functions
//- Depending on point-to-cell option add to or delete from cellSet.
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("pointToCell");
// Constructors
//- Construct from components
pointToCell
(
const polyMesh& mesh,
const word& setName,
const pointAction option
);
//- Construct from dictionary
pointToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
pointToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~pointToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,468 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "regionToCell.H"
#include "regionSplit.H"
#include "emptyPolyPatch.H"
#include "cellSet.H"
#include "syncTools.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(regionToCell, 0);
addToRunTimeSelectionTable(topoSetSource, regionToCell, word);
addToRunTimeSelectionTable(topoSetSource, regionToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::regionToCell::usage_
(
regionToCell::typeName,
"\n Usage: regionToCell subCellSet (pt0 .. ptn)\n\n"
" Select all cells in the connected region containing"
" points (pt0..ptn).\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::regionToCell::markRegionFaces
(
const boolList& selectedCell,
boolList& regionFace
) const
{
// Internal faces
const labelList& faceOwner = mesh_.faceOwner();
const labelList& faceNeighbour = mesh_.faceNeighbour();
forAll(faceNeighbour, facei)
{
if
(
selectedCell[faceOwner[facei]]
!= selectedCell[faceNeighbour[facei]]
)
{
regionFace[facei] = true;
}
}
// Swap neighbour selectedCell state
boolList nbrSelected;
syncTools::swapBoundaryCellList(mesh_, selectedCell, nbrSelected);
// Boundary faces
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
forAll(pbm, patchi)
{
const polyPatch& pp = pbm[patchi];
const labelUList& faceCells = pp.faceCells();
forAll(faceCells, i)
{
label facei = pp.start()+i;
label bFacei = facei-mesh_.nInternalFaces();
if
(
selectedCell[faceCells[i]]
!= selectedCell[nbrSelected[bFacei]]
)
{
regionFace[facei] = true;
}
}
}
}
Foam::boolList Foam::regionToCell::findRegions
(
const bool verbose,
const regionSplit& cellRegion
) const
{
boolList keepRegion(cellRegion.nRegions(), false);
forAll(insidePoints_, i)
{
// Find the region containing the insidePoint
label celli = mesh_.findCell(insidePoints_[i]);
label keepRegionI = -1;
label keepProci = -1;
if (celli != -1)
{
keepRegionI = cellRegion[celli];
keepProci = Pstream::myProcNo();
}
reduce(keepRegionI, maxOp<label>());
keepRegion[keepRegionI] = true;
reduce(keepProci, maxOp<label>());
if (keepProci == -1)
{
FatalErrorInFunction
<< "Did not find " << insidePoints_[i]
<< " in mesh." << " Mesh bounds are " << mesh_.bounds()
<< exit(FatalError);
}
if (verbose)
{
Info<< " Found location " << insidePoints_[i]
<< " in cell " << celli << " on processor " << keepProci
<< " in global region " << keepRegionI
<< " out of " << cellRegion.nRegions() << " regions." << endl;
}
}
return keepRegion;
}
void Foam::regionToCell::unselectOutsideRegions
(
boolList& selectedCell
) const
{
// Determine faces on the edge of selectedCell
boolList blockedFace(mesh_.nFaces(), false);
markRegionFaces(selectedCell, blockedFace);
// Determine regions
regionSplit cellRegion(mesh_, blockedFace);
// Determine regions containing insidePoints_
boolList keepRegion(findRegions(true, cellRegion));
// Go back to bool per cell
forAll(cellRegion, celli)
{
if (!keepRegion[cellRegion[celli]])
{
selectedCell[celli] = false;
}
}
}
void Foam::regionToCell::shrinkRegions
(
boolList& selectedCell
) const
{
// Select points on unselected cells and boundary
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boolList boundaryPoint(mesh_.nPoints(), false);
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
forAll(pbm, patchi)
{
const polyPatch& pp = pbm[patchi];
if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
{
forAll(pp, i)
{
const face& f = pp[i];
forAll(f, fp)
{
boundaryPoint[f[fp]] = true;
}
}
}
}
forAll(selectedCell, celli)
{
if (!selectedCell[celli])
{
const labelList& cPoints = mesh_.cellPoints(celli);
forAll(cPoints, i)
{
boundaryPoint[cPoints[i]] = true;
}
}
}
syncTools::syncPointList(mesh_, boundaryPoint, orEqOp<bool>(), false);
// Select all cells using these points
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label nChanged = 0;
forAll(boundaryPoint, pointi)
{
if (boundaryPoint[pointi])
{
const labelList& pCells = mesh_.pointCells(pointi);
forAll(pCells, i)
{
label celli = pCells[i];
if (selectedCell[celli])
{
selectedCell[celli] = false;
nChanged++;
}
}
}
}
Info<< " Eroded " << returnReduce(nChanged, sumOp<label>())
<< " cells." << endl;
}
void Foam::regionToCell::erode
(
boolList& selectedCell
) const
{
//Info<< "Entering shrinkRegions:" << count(selectedCell) << endl;
//generateField("selectedCell_before", selectedCell)().write();
// Now erode and see which regions get disconnected
boolList shrunkSelectedCell(selectedCell);
for (label iter = 0; iter < nErode_; iter++)
{
shrinkRegions(shrunkSelectedCell);
}
//Info<< "After shrinking:" << count(shrunkSelectedCell) << endl;
//generateField("shrunkSelectedCell", shrunkSelectedCell)().write();
// Determine faces on the edge of shrunkSelectedCell
boolList blockedFace(mesh_.nFaces(), false);
markRegionFaces(shrunkSelectedCell, blockedFace);
// Find disconnected regions
regionSplit cellRegion(mesh_, blockedFace);
// Determine regions containing insidePoints
boolList keepRegion(findRegions(true, cellRegion));
// Extract cells in regions that are not to be kept.
boolList removeCell(mesh_.nCells(), false);
forAll(cellRegion, celli)
{
if (shrunkSelectedCell[celli] && !keepRegion[cellRegion[celli]])
{
removeCell[celli] = true;
}
}
//Info<< "removeCell before:" << count(removeCell) << endl;
//generateField("removeCell_before", removeCell)().write();
// Grow removeCell
for (label iter = 0; iter < nErode_; iter++)
{
// Grow selected cell in regions that are not for keeping
boolList boundaryPoint(mesh_.nPoints(), false);
forAll(removeCell, celli)
{
if (removeCell[celli])
{
const labelList& cPoints = mesh_.cellPoints(celli);
forAll(cPoints, i)
{
boundaryPoint[cPoints[i]] = true;
}
}
}
syncTools::syncPointList(mesh_, boundaryPoint, orEqOp<bool>(), false);
// Select all cells using these points
label nChanged = 0;
forAll(boundaryPoint, pointi)
{
if (boundaryPoint[pointi])
{
const labelList& pCells = mesh_.pointCells(pointi);
forAll(pCells, i)
{
label celli = pCells[i];
if (!removeCell[celli])
{
removeCell[celli] = true;
nChanged++;
}
}
}
}
}
//Info<< "removeCell after:" << count(removeCell) << endl;
//generateField("removeCell_after", removeCell)().write();
// Unmark removeCell
forAll(removeCell, celli)
{
if (removeCell[celli])
{
selectedCell[celli] = false;
}
}
}
void Foam::regionToCell::combine(topoSet& set, const bool add) const
{
// Note: wip. Select cells first
boolList selectedCell(mesh_.nCells(), true);
if (setName_.size() && setName_ != "none")
{
Info<< " Loading subset " << setName_ << " to delimit search region."
<< endl;
cellSet subSet(mesh_, setName_);
selectedCell = false;
forAllConstIter(cellSet, subSet, iter)
{
selectedCell[iter.key()] = true;
}
}
unselectOutsideRegions(selectedCell);
if (nErode_ > 0)
{
erode(selectedCell);
}
forAll(selectedCell, celli)
{
if (selectedCell[celli])
{
addOrDelete(set, celli, add);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::regionToCell::regionToCell
(
const polyMesh& mesh,
const word& setName,
const pointField& insidePoints,
const label nErode
)
:
topoSetSource(mesh),
setName_(setName),
insidePoints_(insidePoints),
nErode_(nErode)
{}
// Construct from dictionary
Foam::regionToCell::regionToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
setName_(dict.lookupOrDefault<word>("set", "none")),
insidePoints_
(
dict.found("insidePoints")
? dict.lookup("insidePoints")
: dict.lookup("insidePoint")
),
nErode_(dict.lookupOrDefault("nErode", 0))
{}
// Construct from Istream
Foam::regionToCell::regionToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
setName_(checkIs(is)),
insidePoints_(checkIs(is)),
nErode_(0)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::regionToCell::~regionToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::regionToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all cells of connected region containing points "
<< insidePoints_ << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all cells of connected region containing points "
<< insidePoints_ << " ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,168 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 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::regionToCell
Description
TopoSetSource. Select cells belonging to topological connected region
(that contains given points)
In dictionary input:
// optional name of cellSet delimiting search
set c0;
//- Number of cell layers to erode mesh to detect holes in the mesh
// Set to 0 if not used.
nErode 3;
// points inside region to select
insidePoints ((1 2 3));
SourceFiles
regionToCell.C
\*---------------------------------------------------------------------------*/
#ifndef regionToCell_H
#define regionToCell_H
#include "topoSetSource.H"
#include "boolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class regionSplit;
/*---------------------------------------------------------------------------*\
Class regionToCell Declaration
\*---------------------------------------------------------------------------*/
class regionToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Name of cellSet to keep to
const word setName_;
//- Coordinate(s) that is inside connected region
const pointField insidePoints_;
//- Number of layers to erode
const label nErode_;
// Private Member Functions
//- Mark faces inbetween selected and unselected elements
void markRegionFaces
(
const boolList& selectedCell,
boolList& regionFace
) const;
//- Determine for every disconnected region in the mesh whether
// it contains a locationInMesh
boolList findRegions(const bool verbose, const regionSplit&) const;
//- Unselect regions not containing a locationInMesh
void unselectOutsideRegions(boolList& selectedCell) const;
//- Unselect one layer of cells from selectedCell
void shrinkRegions(boolList& selectedCell) const;
//- Erode a given number of layers from selectedCell. Remove any
// region that gets disconnected that way.
void erode(boolList& selectedCell) const;
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("regionToCell");
// Constructors
//- Construct from components
regionToCell
(
const polyMesh& mesh,
const word& setName,
const pointField& insidePoints,
const label nErode
);
//- Construct from dictionary
regionToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
regionToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~regionToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet(const topoSetSource::setAction action, topoSet&)
const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,193 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "rotatedBoxToCell.H"
#include "polyMesh.H"
#include "cellModeller.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(rotatedBoxToCell, 0);
addToRunTimeSelectionTable(topoSetSource, rotatedBoxToCell, word);
addToRunTimeSelectionTable(topoSetSource, rotatedBoxToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::rotatedBoxToCell::usage_
(
rotatedBoxToCell::typeName,
"\n Usage: rotatedBoxToCell (originx originy originz)"
" (ix iy iz) (jx jy jz) (kx ky kz)\n\n"
" Select all cells with cellCentre within parallelopiped\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::rotatedBoxToCell::combine(topoSet& set, const bool add) const
{
// Define a cell for the box
pointField boxPoints(8);
boxPoints[0] = origin_;
boxPoints[1] = origin_ + i_;
boxPoints[2] = origin_ + i_ + j_;
boxPoints[3] = origin_ + j_;
boxPoints[4] = origin_ + k_;
boxPoints[5] = origin_ + k_ + i_;
boxPoints[6] = origin_ + k_ + i_ + j_;
boxPoints[7] = origin_ + k_ + j_;
labelList boxVerts(8);
forAll(boxVerts, i)
{
boxVerts[i] = i;
}
const cellModel& hex = *(cellModeller::lookup("hex"));
// Get outwards pointing faces.
faceList boxFaces(cellShape(hex, boxVerts).faces());
// Precalculate normals
vectorField boxFaceNormals(boxFaces.size());
forAll(boxFaces, i)
{
boxFaceNormals[i] = boxFaces[i].normal(boxPoints);
//Pout<< "Face:" << i << " position:" << boxFaces[i].centre(boxPoints)
// << " normal:" << boxFaceNormals[i] << endl;
}
// Check whether cell centre is inside all faces of box.
const pointField& ctrs = mesh_.cellCentres();
forAll(ctrs, celli)
{
bool inside = true;
forAll(boxFaces, i)
{
const face& f = boxFaces[i];
if (((ctrs[celli] - boxPoints[f[0]]) & boxFaceNormals[i]) > 0)
{
inside = false;
break;
}
}
if (inside)
{
addOrDelete(set, celli, add);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::rotatedBoxToCell::rotatedBoxToCell
(
const polyMesh& mesh,
const vector& origin,
const vector& i,
const vector& j,
const vector& k
)
:
topoSetSource(mesh),
origin_(origin),
i_(i),
j_(j),
k_(k)
{}
// Construct from dictionary
Foam::rotatedBoxToCell::rotatedBoxToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
origin_(dict.lookup("origin")),
i_(dict.lookup("i")),
j_(dict.lookup("j")),
k_(dict.lookup("k"))
{}
// Construct from Istream
Foam::rotatedBoxToCell::rotatedBoxToCell(const polyMesh& mesh, Istream& is)
:
topoSetSource(mesh),
origin_(is),
i_(is),
j_(is),
k_(is)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::rotatedBoxToCell::~rotatedBoxToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::rotatedBoxToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells with center within rotated box " << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells with center within rotated box " << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,136 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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::rotatedBoxToCell
Description
A topoSetSource to select cells based on cell centres inside
rotated/skewed box (parallelopiped?).
Box defined as origin and i,j,k vectors.
E.g. box rotated 45 degrees around z-axis with sizes sqrt(0.2^2+0.2^2)
(and extra large, 200 in z direction):
\verbatim
origin ( 0.4 0.4 -100);
i ( 0.2 0.2 0);
j (-0.2 0.2 0);
k ( 0.0 0.0 100);
\endverbatim
SourceFiles
rotatedBoxToCell.C
\*---------------------------------------------------------------------------*/
#ifndef rotatedBoxToCell_H
#define rotatedBoxToCell_H
#include "topoSetSource.H"
#include "treeBoundBox.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class rotatedBoxToCell Declaration
\*---------------------------------------------------------------------------*/
class rotatedBoxToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Skewed box
const vector origin_;
const vector i_;
const vector j_;
const vector k_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("rotatedBoxToCell");
// Constructors
//- Construct from components
rotatedBoxToCell
(
const polyMesh& mesh,
const vector& origin,
const vector& i,
const vector& j,
const vector& k
);
//- Construct from dictionary
rotatedBoxToCell(const polyMesh& mesh, const dictionary& dict);
//- Construct from Istream
rotatedBoxToCell(const polyMesh& mesh, Istream&);
//- Destructor
virtual ~rotatedBoxToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,178 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "shapeToCell.H"
#include "polyMesh.H"
#include "unitConversion.H"
#include "hexMatcher.H"
#include "cellFeatures.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(shapeToCell, 0);
addToRunTimeSelectionTable(topoSetSource, shapeToCell, word);
addToRunTimeSelectionTable(topoSetSource, shapeToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::shapeToCell::usage_
(
shapeToCell::typeName,
"\n Usage: shapeToCell tet|pyr|prism|hex|tetWedge|wedge|splitHex\n\n"
" Select all cells of given cellShape.\n"
" (splitHex hardcoded with internal angle < 10 degrees)\n"
);
// Angle for polys to be considered splitHexes.
Foam::scalar Foam::shapeToCell::featureCos = Foam::cos(degToRad(10.0));
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::shapeToCell::combine(topoSet& set, const bool add) const
{
if (type_ == "splitHex")
{
for (label celli = 0; celli < mesh_.nCells(); celli++)
{
cellFeatures superCell(mesh_, featureCos, celli);
if (hexMatcher().isA(superCell.faces()))
{
addOrDelete(set, celli, add);
}
}
}
else
{
const cellModel& wantedModel = *(cellModeller::lookup(type_));
const cellShapeList& cellShapes = mesh_.cellShapes();
forAll(cellShapes, celli)
{
if (cellShapes[celli].model() == wantedModel)
{
addOrDelete(set, celli, add);
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::shapeToCell::shapeToCell
(
const polyMesh& mesh,
const word& type
)
:
topoSetSource(mesh),
type_(type)
{
if (!cellModeller::lookup(type_) && (type_ != "splitHex"))
{
FatalErrorInFunction
<< "Illegal cell type " << type_ << exit(FatalError);
}
}
// Construct from dictionary
Foam::shapeToCell::shapeToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
type_(dict.lookup("type"))
{
if (!cellModeller::lookup(type_) && (type_ != "splitHex"))
{
FatalErrorInFunction
<< "Illegal cell type " << type_ << exit(FatalError);
}
}
// Construct from Istream
Foam::shapeToCell::shapeToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
type_(checkIs(is))
{
if (!cellModeller::lookup(type_) && (type_ != "splitHex"))
{
FatalErrorInFunction
<< "Illegal cell type " << type_ << exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::shapeToCell::~shapeToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::shapeToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all cells of type " << type_ << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all cells of type " << type_ << " ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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::shapeToCell
Description
A topoSetSource to select cells based on cell shape.
Handles all ones from cellModeller and splitHex with 10 degrees
feature angle.
SourceFiles
shapeToCell.C
\*---------------------------------------------------------------------------*/
#ifndef shapeToCell_H
#define shapeToCell_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class shapeToCell Declaration
\*---------------------------------------------------------------------------*/
class shapeToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Name of cell type
word type_;
// Private Member Functions
//- Depending on cell type add to or delete from cellSet.
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("shapeToCell");
// Static data
//- Cos of feature angle for polyHedral to be splitHex
static scalar featureCos;
// Constructors
//- Construct from components
shapeToCell
(
const polyMesh& mesh,
const word& type
);
//- Construct from dictionary
shapeToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
shapeToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~shapeToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,138 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "sphereToCell.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(sphereToCell, 0);
addToRunTimeSelectionTable(topoSetSource, sphereToCell, word);
addToRunTimeSelectionTable(topoSetSource, sphereToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::sphereToCell::usage_
(
sphereToCell::typeName,
"\n Usage: sphereToCell (centreX centreY centreZ) radius\n\n"
" Select all cells with cellCentre within bounding sphere\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sphereToCell::combine(topoSet& set, const bool add) const
{
const pointField& ctrs = mesh_.cellCentres();
const scalar radSquared = radius_*radius_;
forAll(ctrs, celli)
{
scalar offset = magSqr(centre_ - ctrs[celli]);
if (offset <= radSquared)
{
addOrDelete(set, celli, add);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sphereToCell::sphereToCell
(
const polyMesh& mesh,
const vector& centre,
const scalar radius
)
:
topoSetSource(mesh),
centre_(centre),
radius_(radius)
{}
Foam::sphereToCell::sphereToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
centre_(dict.lookup("centre")),
radius_(readScalar(dict.lookup("radius")))
{}
// Construct from Istream
Foam::sphereToCell::sphereToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
centre_(checkIs(is)),
radius_(readScalar(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sphereToCell::~sphereToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sphereToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells with centre within sphere, with centre = "
<< centre_ << " and radius = " << radius_ << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells with centre within sphere, with centre = "
<< centre_ << " and radius = " << radius_ << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,130 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::sphereToCell
Description
A topoSetSource to select cells based on cell centres inside sphere.
SourceFiles
sphereToCell.C
\*---------------------------------------------------------------------------*/
#ifndef sphereToCell_H
#define sphereToCell_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class sphereToCell Declaration
\*---------------------------------------------------------------------------*/
class sphereToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Centre
vector centre_;
//- Radius
scalar radius_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("sphereToCell");
// Constructors
//- Construct from components
sphereToCell
(
const polyMesh& mesh,
const vector& centre,
const scalar radius
);
//- Construct from dictionary
sphereToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
sphereToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~sphereToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,506 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 "surfaceToCell.H"
#include "polyMesh.H"
#include "meshSearch.H"
#include "triSurface.H"
#include "triSurfaceSearch.H"
#include "cellClassification.H"
#include "cpuTime.H"
#include "demandDrivenData.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(surfaceToCell, 0);
addToRunTimeSelectionTable(topoSetSource, surfaceToCell, word);
addToRunTimeSelectionTable(topoSetSource, surfaceToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::surfaceToCell::usage_
(
surfaceToCell::typeName,
"\n Usage: surfaceToCell"
"<surface> <outsidePoints> <cut> <inside> <outside> <near> <curvature>\n\n"
" <surface> name of triSurface\n"
" <outsidePoints> list of points that define outside\n"
" <cut> boolean whether to include cells cut by surface\n"
" <inside> ,, ,, inside surface\n"
" <outside> ,, ,, outside surface\n"
" <near> scalar; include cells with centre <= near to surface\n"
" <curvature> scalar; include cells close to strong curvature"
" on surface\n"
" (curvature defined as difference in surface normal at nearest"
" point on surface for each vertex of cell)\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::surfaceToCell::getNearest
(
const triSurfaceSearch& querySurf,
const label pointi,
const point& pt,
const vector& span,
Map<label>& cache
)
{
Map<label>::const_iterator iter = cache.find(pointi);
if (iter != cache.end())
{
// Found cached answer
return iter();
}
else
{
pointIndexHit inter = querySurf.nearest(pt, span);
// Triangle label (can be -1)
label triI = inter.index();
// Store triangle on point
cache.insert(pointi, triI);
return triI;
}
}
bool Foam::surfaceToCell::differingPointNormals
(
const triSurfaceSearch& querySurf,
const vector& span, // Current search span
const label celli,
const label cellTriI, // Nearest (to cell centre) surface triangle
Map<label>& pointToNearest // Cache for nearest triangle to point
) const
{
const triSurface& surf = querySurf.surface();
const vectorField& normals = surf.faceNormals();
const faceList& faces = mesh().faces();
const pointField& points = mesh().points();
const labelList& cFaces = mesh().cells()[celli];
forAll(cFaces, cFacei)
{
const face& f = faces[cFaces[cFacei]];
forAll(f, fp)
{
label pointi = f[fp];
label pointTriI =
getNearest
(
querySurf,
pointi,
points[pointi],
span,
pointToNearest
);
if (pointTriI != -1 && pointTriI != cellTriI)
{
scalar cosAngle = normals[pointTriI] & normals[cellTriI];
if (cosAngle < 0.9)
{
return true;
}
}
}
}
return false;
}
void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
{
cpuTime timer;
if (useSurfaceOrientation_ && (includeInside_ || includeOutside_))
{
const meshSearch queryMesh(mesh_);
//- Calculate for each searchPoint inside/outside status.
boolList isInside(querySurf().calcInside(mesh_.cellCentres()));
Info<< " Marked inside/outside using surface orientation in = "
<< timer.cpuTimeIncrement() << " s" << endl << endl;
forAll(isInside, celli)
{
if (isInside[celli] && includeInside_)
{
addOrDelete(set, celli, add);
}
else if (!isInside[celli] && includeOutside_)
{
addOrDelete(set, celli, add);
}
}
}
else if (includeCut_ || includeInside_ || includeOutside_)
{
//
// Cut cells with surface and classify cells
//
// Construct search engine on mesh
const meshSearch queryMesh(mesh_);
// Check all 'outside' points
forAll(outsidePoints_, outsideI)
{
const point& outsidePoint = outsidePoints_[outsideI];
// Find cell point is in. Linear search.
label celli = queryMesh.findCell(outsidePoint, -1, false);
if (returnReduce(celli, maxOp<label>()) == -1)
{
FatalErrorInFunction
<< "outsidePoint " << outsidePoint
<< " is not inside any cell"
<< exit(FatalError);
}
}
// Cut faces with surface and classify cells
cellClassification cellType
(
mesh_,
queryMesh,
querySurf(),
outsidePoints_
);
Info<< " Marked inside/outside using surface intersection in = "
<< timer.cpuTimeIncrement() << " s" << endl << endl;
//- Add/remove cells using set
forAll(cellType, celli)
{
label cType = cellType[celli];
if
(
(
includeCut_
&& (cType == cellClassification::CUT)
)
|| (
includeInside_
&& (cType == cellClassification::INSIDE)
)
|| (
includeOutside_
&& (cType == cellClassification::OUTSIDE)
)
)
{
addOrDelete(set, celli, add);
}
}
}
if (nearDist_ > 0)
{
//
// Determine distance to surface
//
const pointField& ctrs = mesh_.cellCentres();
// Box dimensions to search in octree.
const vector span(nearDist_, nearDist_, nearDist_);
if (curvature_ < -1)
{
Info<< " Selecting cells with cellCentre closer than "
<< nearDist_ << " to surface" << endl;
// No need to test curvature. Insert near cells into set.
forAll(ctrs, celli)
{
const point& c = ctrs[celli];
pointIndexHit inter = querySurf().nearest(c, span);
if (inter.hit() && (mag(inter.hitPoint() - c) < nearDist_))
{
addOrDelete(set, celli, add);
}
}
Info<< " Determined nearest surface point in = "
<< timer.cpuTimeIncrement() << " s" << endl << endl;
}
else
{
// Test near cells for curvature
Info<< " Selecting cells with cellCentre closer than "
<< nearDist_ << " to surface and curvature factor"
<< " less than " << curvature_ << endl;
// Cache for nearest surface triangle for a point
Map<label> pointToNearest(mesh_.nCells()/10);
forAll(ctrs, celli)
{
const point& c = ctrs[celli];
pointIndexHit inter = querySurf().nearest(c, span);
if (inter.hit() && (mag(inter.hitPoint() - c) < nearDist_))
{
if
(
differingPointNormals
(
querySurf(),
span,
celli,
inter.index(), // nearest surface triangle
pointToNearest
)
)
{
addOrDelete(set, celli, add);
}
}
}
Info<< " Determined nearest surface point in = "
<< timer.cpuTimeIncrement() << " s" << endl << endl;
}
}
}
void Foam::surfaceToCell::checkSettings() const
{
if
(
(nearDist_ < 0)
&& (curvature_ < -1)
&& (
(includeCut_ && includeInside_ && includeOutside_)
|| (!includeCut_ && !includeInside_ && !includeOutside_)
)
)
{
FatalErrorInFunction
<< "Illegal include cell specification."
<< " Result would be either all or no cells." << endl
<< "Please set one of includeCut, includeInside, includeOutside"
<< " to true, set nearDistance to a value > 0"
<< " or set curvature to a value -1 .. 1."
<< exit(FatalError);
}
if (useSurfaceOrientation_ && includeCut_)
{
FatalErrorInFunction
<< "Illegal include cell specification."
<< " You cannot specify both 'useSurfaceOrientation'"
<< " and 'includeCut'"
<< " since 'includeCut' specifies a topological split"
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceToCell::surfaceToCell
(
const polyMesh& mesh,
const fileName& surfName,
const pointField& outsidePoints,
const bool includeCut,
const bool includeInside,
const bool includeOutside,
const bool useSurfaceOrientation,
const scalar nearDist,
const scalar curvature
)
:
topoSetSource(mesh),
surfName_(surfName),
outsidePoints_(outsidePoints),
includeCut_(includeCut),
includeInside_(includeInside),
includeOutside_(includeOutside),
useSurfaceOrientation_(useSurfaceOrientation),
nearDist_(nearDist),
curvature_(curvature),
surfPtr_(new triSurface(surfName_)),
querySurfPtr_(new triSurfaceSearch(*surfPtr_)),
IOwnPtrs_(true)
{
checkSettings();
}
Foam::surfaceToCell::surfaceToCell
(
const polyMesh& mesh,
const fileName& surfName,
const triSurface& surf,
const triSurfaceSearch& querySurf,
const pointField& outsidePoints,
const bool includeCut,
const bool includeInside,
const bool includeOutside,
const bool useSurfaceOrientation,
const scalar nearDist,
const scalar curvature
)
:
topoSetSource(mesh),
surfName_(surfName),
outsidePoints_(outsidePoints),
includeCut_(includeCut),
includeInside_(includeInside),
includeOutside_(includeOutside),
useSurfaceOrientation_(useSurfaceOrientation),
nearDist_(nearDist),
curvature_(curvature),
surfPtr_(&surf),
querySurfPtr_(&querySurf),
IOwnPtrs_(false)
{
checkSettings();
}
Foam::surfaceToCell::surfaceToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
surfName_(fileName(dict.lookup("file")).expand()),
outsidePoints_(dict.lookup("outsidePoints")),
includeCut_(readBool(dict.lookup("includeCut"))),
includeInside_(readBool(dict.lookup("includeInside"))),
includeOutside_(readBool(dict.lookup("includeOutside"))),
useSurfaceOrientation_
(
dict.lookupOrDefault<bool>("useSurfaceOrientation", false)
),
nearDist_(readScalar(dict.lookup("nearDistance"))),
curvature_(readScalar(dict.lookup("curvature"))),
surfPtr_(new triSurface(surfName_)),
querySurfPtr_(new triSurfaceSearch(*surfPtr_)),
IOwnPtrs_(true)
{
checkSettings();
}
Foam::surfaceToCell::surfaceToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
surfName_(checkIs(is)),
outsidePoints_(checkIs(is)),
includeCut_(readBool(checkIs(is))),
includeInside_(readBool(checkIs(is))),
includeOutside_(readBool(checkIs(is))),
useSurfaceOrientation_(false),
nearDist_(readScalar(checkIs(is))),
curvature_(readScalar(checkIs(is))),
surfPtr_(new triSurface(surfName_)),
querySurfPtr_(new triSurfaceSearch(*surfPtr_)),
IOwnPtrs_(true)
{
checkSettings();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceToCell::~surfaceToCell()
{
if (IOwnPtrs_)
{
deleteDemandDrivenData(surfPtr_);
deleteDemandDrivenData(querySurfPtr_);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfaceToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells in relation to surface " << surfName_
<< " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells in relation to surface " << surfName_
<< " ..." << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,228 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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::surfaceToCell
Description
A topoSetSource to select cells based on relation to surface.
Selects:
- all cells inside/outside/cut by surface
- all cells inside/outside surface ('useSurfaceOrientation', requires closed
surface)
- cells with centre nearer than XXX to surface
- cells with centre nearer than XXX to surface \b and with normal
at nearest point to centre and cell-corners differing by
more than YYY (i.e., point of high curvature)
SourceFiles
surfaceToCell.C
\*---------------------------------------------------------------------------*/
#ifndef surfaceToCell_H
#define surfaceToCell_H
#include "topoSetSource.H"
#include "Map.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class triSurfaceSearch;
class triSurface;
/*---------------------------------------------------------------------------*\
Class surfaceToCell Declaration
\*---------------------------------------------------------------------------*/
class surfaceToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Name of surface file
const fileName surfName_;
//- Points which are outside
const pointField outsidePoints_;
//- Include cut cells
const bool includeCut_;
//- Include inside cells
const bool includeInside_;
//- Include outside cells
const bool includeOutside_;
//- Determine inside/outside purely using geometric test
// (does not allow includeCut)
const bool useSurfaceOrientation_;
//- If > 0 : include cells with distance from cellCentre to surface
// less than nearDist.
const scalar nearDist_;
//- If > -1 : include cells with normals at nearest surface points
// varying more than curvature_.
const scalar curvature_;
//- triSurface to search on. On pointer since can be external.
const triSurface* surfPtr_;
//- Search engine on surface.
const triSurfaceSearch* querySurfPtr_;
//- Whether I allocated above surface ptrs or whether they are
// external.
const bool IOwnPtrs_;
// Private Member Functions
//- Find index of nearest triangle to point. Returns triangle or -1 if
// not found within search span.
// Cache result under pointi.
static label getNearest
(
const triSurfaceSearch& querySurf,
const label pointi,
const point& pt,
const vector& searchSpan,
Map<label>& cache
);
//- Return true if surface normal of nearest points to vertices on
// cell differ from that on cell centre. Points cached in
// pointToNearest.
bool differingPointNormals
(
const triSurfaceSearch& querySurf,
const vector& span,
const label celli,
const label cellTriI,
Map<label>& pointToNearest
) const;
//- Depending on surface add to or delete from cellSet.
void combine(topoSet& set, const bool add) const;
//- Check values at construction time.
void checkSettings() const;
const triSurfaceSearch& querySurf() const
{
return *querySurfPtr_;
}
public:
//- Runtime type information
TypeName("surfaceToCell");
// Constructors
//- Construct from components
surfaceToCell
(
const polyMesh& mesh,
const fileName& surfName,
const pointField& outsidePoints,
const bool includeCut,
const bool includeInside,
const bool includeOutside,
const bool useSurfaceOrientation,
const scalar nearDist,
const scalar curvature
);
//- Construct from components (supplied surface, surfaceSearch)
surfaceToCell
(
const polyMesh& mesh,
const fileName& surfName,
const triSurface& surf,
const triSurfaceSearch& querySurf,
const pointField& outsidePoints,
const bool includeCut,
const bool includeInside,
const bool includeOutside,
const bool useSurfaceOrientation,
const scalar nearDist,
const scalar curvature
);
//- Construct from dictionary
surfaceToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
surfaceToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~surfaceToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,342 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 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 "targetVolumeToCell.H"
#include "polyMesh.H"
#include "globalMeshData.H"
#include "plane.H"
#include "cellSet.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(targetVolumeToCell, 0);
addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, word);
addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::targetVolumeToCell::usage_
(
targetVolumeToCell::typeName,
"\n Usage: targetVolumeToCell (nx ny nz)\n\n"
" Adjust plane until obtained selected volume\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::scalar Foam::targetVolumeToCell::volumeOfSet
(
const PackedBoolList& selected
) const
{
scalar sumVol = 0.0;
forAll(selected, celli)
{
if (selected[celli])
{
sumVol += mesh_.cellVolumes()[celli];
}
}
return returnReduce(sumVol, sumOp<scalar>());
}
Foam::label Foam::targetVolumeToCell::selectCells
(
const scalar normalComp,
const PackedBoolList& maskSet,
PackedBoolList& selected
) const
{
selected.setSize(mesh_.nCells());
selected = false;
label nSelected = 0;
forAll(mesh_.cellCentres(), celli)
{
const point& cc = mesh_.cellCentres()[celli];
if (maskSet[celli] && ((cc&n_) < normalComp))
{
selected[celli] = true;
nSelected++;
}
}
return returnReduce(nSelected, sumOp<label>());
}
void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
{
if (vol_ <= 0)
{
// Select no cells
return;
}
PackedBoolList maskSet(mesh_.nCells(), 1);
label nTotCells = mesh_.globalData().nTotalCells();
if (maskSetName_.size())
{
// Read cellSet
Info<< " Operating on subset defined by cellSet " << maskSetName_
<< endl;
maskSet = 0;
cellSet subset(mesh_, maskSetName_);
forAllConstIter(cellSet, subset, iter)
{
maskSet[iter.key()] = 1;
}
nTotCells = returnReduce(subset.size(), sumOp<label>());
}
// Get plane for min,max volume.
// Planes all have base (0 0 0) and fixed normal so work only on normal
// component.
scalar maxComp = -GREAT;
label maxCells = 0;
//scalar maxVol = 0;
scalar minComp = GREAT;
{
const boundBox& bb = mesh_.bounds();
pointField points(bb.points());
//label minPointi = -1;
label maxPointi = -1;
forAll(points, pointi)
{
scalar c = (points[pointi]&n_);
if (c > maxComp)
{
maxComp = c;
maxPointi = pointi;
}
else if (c < minComp)
{
minComp = c;
//minPointi = pointi;
}
}
PackedBoolList maxSelected(mesh_.nCells());
maxCells = selectCells(maxComp, maskSet, maxSelected);
//maxVol = volumeOfSet(maxSelected);
// Check that maxPoint indeed selects all cells
if (maxCells != nTotCells)
{
WarningInFunction
<< "Plane " << plane(points[maxPointi], n_)
<< " selects " << maxCells
<< " cells instead of all " << nTotCells
<< " cells. Results might be wrong." << endl;
}
}
// Bisection
// ~~~~~~~~~
PackedBoolList selected(mesh_.nCells());
label nSelected = -1;
scalar selectedVol = 0.0;
//scalar selectedComp = 0.0;
scalar low = minComp;
scalar high = maxComp;
const scalar tolerance = SMALL*100*(maxComp-minComp);
while ((high-low) > tolerance)
{
scalar mid = 0.5*(low + high);
nSelected = selectCells(mid, maskSet, selected);
selectedVol = volumeOfSet(selected);
//Pout<< "High:" << high << " low:" << low << " mid:" << mid << nl
// << " nSelected:" << nSelected << nl
// << " vol :" << selectedVol << nl
// << endl;
if (selectedVol < vol_)
{
low = mid;
PackedBoolList highSelected(mesh_.nCells());
label nHigh = selectCells(high, maskSet, selected);
if (nSelected == nHigh)
{
break;
}
}
else
{
high = mid;
PackedBoolList lowSelected(mesh_.nCells());
label nLow = selectCells(low, maskSet, selected);
if (nSelected == nLow)
{
break;
}
}
}
nSelected = selectCells(high, maskSet, selected);
selectedVol = volumeOfSet(selected);
if (selectedVol < vol_)
{
//selectedComp = high;
}
else
{
nSelected = selectCells(low, maskSet, selected);
selectedVol = volumeOfSet(selected);
if (selectedVol < vol_)
{
//selectedComp = low;
}
else
{
WarningInFunction
<< "Did not converge onto plane. " << nl
<< "high plane:"
<< plane(high*n_, n_)
<< nl
<< "low plane :"
<< plane(low*n_, n_)
<< endl;
}
}
Info<< " Selected " << nSelected << " with actual volume " << selectedVol
<< endl;
forAll(selected, celli)
{
if (selected[celli])
{
addOrDelete(set, celli, add);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::targetVolumeToCell::targetVolumeToCell
(
const polyMesh& mesh,
const scalar vol,
const vector& n
)
:
topoSetSource(mesh),
vol_(vol),
n_(n)
{}
// Construct from dictionary
Foam::targetVolumeToCell::targetVolumeToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
vol_(readScalar(dict.lookup("volume"))),
n_(dict.lookup("normal")),
maskSetName_(dict.lookupOrDefault<word>("set", ""))
{}
// Construct from Istream
Foam::targetVolumeToCell::targetVolumeToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
vol_(readScalar(checkIs(is))),
n_(checkIs(is))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::targetVolumeToCell::~targetVolumeToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::targetVolumeToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells up to target volume " << vol_
<< " out of total volume " << gSum(mesh_.cellVolumes()) << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells up to target volume " << vol_
<< " out of total volume " << gSum(mesh_.cellVolumes()) << endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,143 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 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::targetVolumeToCell
Description
A topoSetSource to select cells based on the wanted volume of selected
cells. Adapts a plane until it has enough.
SourceFiles
targetVolumeToCell.C
\*---------------------------------------------------------------------------*/
#ifndef targetVolumeToCell_H
#define targetVolumeToCell_H
#include "topoSetSource.H"
#include "PackedBoolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class targetVolumeToCell Declaration
\*---------------------------------------------------------------------------*/
class targetVolumeToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Wanted volume
const scalar vol_;
//- Normal of plane to sweep
const vector n_;
//- Optional name of cellSet to calculate volume in
const word maskSetName_;
// Private Member Functions
scalar volumeOfSet(const PackedBoolList&) const;
label selectCells
(
const scalar normalComp,
const PackedBoolList&,
PackedBoolList& selected
) const;
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("targetVolumeToCell");
// Constructors
//- Construct from components
targetVolumeToCell
(
const polyMesh& mesh,
const scalar vol,
const vector&
);
//- Construct from dictionary
targetVolumeToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
targetVolumeToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~targetVolumeToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,162 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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 "zoneToCell.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(zoneToCell, 0);
addToRunTimeSelectionTable(topoSetSource, zoneToCell, word);
addToRunTimeSelectionTable(topoSetSource, zoneToCell, istream);
}
Foam::topoSetSource::addToUsageTable Foam::zoneToCell::usage_
(
zoneToCell::typeName,
"\n Usage: zoneToCell zone\n\n"
" Select all cells in the cellZone."
" Note:accepts wildcards for zone.\n\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::zoneToCell::combine(topoSet& set, const bool add) const
{
bool hasMatched = false;
forAll(mesh_.cellZones(), i)
{
const cellZone& zone = mesh_.cellZones()[i];
if (zoneName_.match(zone.name()))
{
const labelList& cellLabels = mesh_.cellZones()[i];
Info<< " Found matching zone " << zone.name()
<< " with " << cellLabels.size() << " cells." << endl;
hasMatched = true;
forAll(cellLabels, i)
{
// Only do active cells
if (cellLabels[i] < mesh_.nCells())
{
addOrDelete(set, cellLabels[i], add);
}
}
}
}
if (!hasMatched)
{
WarningInFunction
<< "Cannot find any cellZone named " << zoneName_ << endl
<< "Valid names are " << mesh_.cellZones().names() << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::zoneToCell::zoneToCell
(
const polyMesh& mesh,
const word& zoneName
)
:
topoSetSource(mesh),
zoneName_(zoneName)
{}
// Construct from dictionary
Foam::zoneToCell::zoneToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
zoneName_(dict.lookup("name"))
{}
// Construct from Istream
Foam::zoneToCell::zoneToCell
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
zoneName_(checkIs(is))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::zoneToCell::~zoneToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::zoneToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all cells of cellZone " << zoneName_ << " ..."
<< endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all cells of cellZone " << zoneName_ << " ..."
<< endl;
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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::zoneToCell
Description
A topoSetSource to select faces based on cellZone.
SourceFiles
zoneToCell.C
\*---------------------------------------------------------------------------*/
#ifndef zoneToCell_H
#define zoneToCell_H
#include "topoSetSource.H"
#include "wordRe.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class zoneToCell Declaration
\*---------------------------------------------------------------------------*/
class zoneToCell
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Name/regular expression of cellZone
wordRe zoneName_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("zoneToCell");
// Constructors
//- Construct from components
zoneToCell
(
const polyMesh& mesh,
const word& zoneName
);
//- Construct from dictionary
zoneToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
zoneToCell
(
const polyMesh& mesh,
Istream&
);
//- Destructor
virtual ~zoneToCell();
// Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //