ENH: boxToCell/face/point: have 'boxes' for multiple boxes

This commit is contained in:
mattijs
2012-07-10 10:02:01 +01:00
parent d490f96086
commit 413d25fbd2
7 changed files with 72 additions and 43 deletions

View File

@ -95,11 +95,12 @@ FoamFile
// type hex; // hex/wedge/prism/pyr/tet/tetWedge/splitHex
// }
//
// // Cells with cell centre within box
// // Cells with cell centre within box ('box') or multiple boxes ('boxes')
// source boxToCell;
// sourceInfo
// {
// box (0 0 0) (1 1 1);
// //boxes ((0 0 0) (1 1 1) (10 10 10)(11 11 11));
// }
//
// // Cells with cell centre within box
@ -223,11 +224,12 @@ FoamFile
// name ".*Zone1"; // Name of faceZone, regular expressions allowed
// }
//
// // Faces with face centre within box
// // Faces with face centre within box ('box') or multiple boxes ('boxes')
// source boxToFace;
// sourceInfo
// {
// box (0 0 0) (1 1 1);
// //boxes ((0 0 0) (1 1 1) (10 10 10)(11 11 11));
// }
//
// // Faces with normal to within certain angle aligned with vector.
@ -295,11 +297,12 @@ FoamFile
// points ((0 0 0) (1 1 1));
// }
//
// // Points with coordinate within box
// // Points with coordinate within box ('box') or multiple boxes ('boxes')
// source boxToPoint;
// sourceInfo
// {
// box (0 0 0) (1 1 1);
// //boxes ((0 0 0) (1 1 1) (10 10 10)(11 11 11));
// }
//
// // Select based on surface

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,9 +58,13 @@ void Foam::boxToCell::combine(topoSet& set, const bool add) const
forAll(ctrs, cellI)
{
if (bb_.contains(ctrs[cellI]))
forAll(bbs_, i)
{
addOrDelete(set, cellI, add);
if (bbs_[i].contains(ctrs[cellI]))
{
addOrDelete(set, cellI, add);
break;
}
}
}
}
@ -72,11 +76,11 @@ void Foam::boxToCell::combine(topoSet& set, const bool add) const
Foam::boxToCell::boxToCell
(
const polyMesh& mesh,
const treeBoundBox& bb
const treeBoundBoxList& bbs
)
:
topoSetSource(mesh),
bb_(bb)
bbs_(bbs)
{}
@ -88,7 +92,12 @@ Foam::boxToCell::boxToCell
)
:
topoSetSource(mesh),
bb_(dict.lookup("box"))
bbs_
(
dict.found("box")
? treeBoundBoxList(1, treeBoundBox(dict.lookup("box")))
: dict.lookup("boxes")
)
{}
@ -100,7 +109,7 @@ Foam::boxToCell::boxToCell
)
:
topoSetSource(mesh),
bb_(checkIs(is))
bbs_(1, treeBoundBox(checkIs(is)))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -119,13 +128,13 @@ void Foam::boxToCell::applyToSet
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding cells with center within box " << bb_ << endl;
Info<< " Adding cells with center within boxes " << bbs_ << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing cells with center within box " << bb_ << endl;
Info<< " Removing cells with center within boxes " << bbs_ << endl;
combine(set, false);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,7 +25,7 @@ Class
Foam::boxToCell
Description
A topoSetSource to select cells based on cell centres inside box.
A topoSetSource to select cells based on cell centres inside box(es).
SourceFiles
boxToCell.C
@ -36,7 +36,7 @@ SourceFiles
#define boxToCell_H
#include "topoSetSource.H"
#include "treeBoundBox.H"
#include "treeBoundBoxList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -59,7 +59,7 @@ class boxToCell
//- bounding box.
treeBoundBox bb_;
treeBoundBoxList bbs_;
// Private Member Functions
@ -78,7 +78,7 @@ public:
boxToCell
(
const polyMesh& mesh,
const treeBoundBox& bb
const treeBoundBoxList& bbs
);
//- Construct from dictionary

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,9 +58,13 @@ void Foam::boxToFace::combine(topoSet& set, const bool add) const
forAll(ctrs, faceI)
{
if (bb_.contains(ctrs[faceI]))
forAll(bbs_, i)
{
addOrDelete(set, faceI, add);
if (bbs_[i].contains(ctrs[faceI]))
{
addOrDelete(set, faceI, add);
break;
}
}
}
}
@ -72,11 +76,11 @@ void Foam::boxToFace::combine(topoSet& set, const bool add) const
Foam::boxToFace::boxToFace
(
const polyMesh& mesh,
const treeBoundBox& bb
const treeBoundBoxList& bbs
)
:
topoSetSource(mesh),
bb_(bb)
bbs_(bbs)
{}
@ -88,7 +92,12 @@ Foam::boxToFace::boxToFace
)
:
topoSetSource(mesh),
bb_(dict.lookup("box"))
bbs_
(
dict.found("box")
? treeBoundBoxList(1, treeBoundBox(dict.lookup("box")))
: dict.lookup("boxes")
)
{}
@ -100,7 +109,7 @@ Foam::boxToFace::boxToFace
)
:
topoSetSource(mesh),
bb_(checkIs(is))
bbs_(1, treeBoundBox(checkIs(is)))
{}
@ -120,13 +129,13 @@ void Foam::boxToFace::applyToSet
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding faces with centre within box " << bb_ << endl;
Info<< " Adding faces with centre within boxes " << bbs_ << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing faces with centre within box " << bb_ << endl;
Info<< " Removing faces with centre within boxes " << bbs_ << endl;
combine(set, false);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,7 +36,7 @@ SourceFiles
#define boxToFace_H
#include "topoSetSource.H"
#include "treeBoundBox.H"
#include "treeBoundBoxList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -58,7 +58,7 @@ class boxToFace
static addToUsageTable usage_;
//- bounding box.
treeBoundBox bb_;
treeBoundBoxList bbs_;
// Private Member Functions
@ -77,7 +77,7 @@ public:
boxToFace
(
const polyMesh& mesh,
const treeBoundBox& bb
const treeBoundBoxList& bbs
);
//- Construct from dictionary

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,9 +58,12 @@ void Foam::boxToPoint::combine(topoSet& set, const bool add) const
forAll(pts, pointI)
{
if (bb_.contains(pts[pointI]))
forAll(bbs_, i)
{
addOrDelete(set, pointI, add);
if (bbs_[i].contains(pts[pointI]))
{
addOrDelete(set, pointI, add);
}
}
}
}
@ -72,11 +75,11 @@ void Foam::boxToPoint::combine(topoSet& set, const bool add) const
Foam::boxToPoint::boxToPoint
(
const polyMesh& mesh,
const treeBoundBox& bb
const treeBoundBoxList& bbs
)
:
topoSetSource(mesh),
bb_(bb)
bbs_(bbs)
{}
@ -88,7 +91,12 @@ Foam::boxToPoint::boxToPoint
)
:
topoSetSource(mesh),
bb_(dict.lookup("box"))
bbs_
(
dict.found("box")
? treeBoundBoxList(1, treeBoundBox(dict.lookup("box")))
: dict.lookup("boxes")
)
{}
@ -100,7 +108,7 @@ Foam::boxToPoint::boxToPoint
)
:
topoSetSource(mesh),
bb_(checkIs(is))
bbs_(1, treeBoundBox(checkIs(is)))
{}
@ -120,14 +128,14 @@ void Foam::boxToPoint::applyToSet
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding points that are within box " << bb_ << " ..."
Info<< " Adding points that are within boxes " << bbs_ << " ..."
<< endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing points that are within box " << bb_ << " ..."
Info<< " Removing points that are within boxes " << bbs_ << " ..."
<< endl;
combine(set, false);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,7 +36,7 @@ SourceFiles
#define boxToPoint_H
#include "topoSetSource.H"
#include "treeBoundBox.H"
#include "treeBoundBoxList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -58,7 +58,7 @@ class boxToPoint
static addToUsageTable usage_;
//- bounding box.
treeBoundBox bb_;
treeBoundBoxList bbs_;
// Private Member Functions
@ -77,7 +77,7 @@ public:
boxToPoint
(
const polyMesh& mesh,
const treeBoundBox& bb
const treeBoundBoxList& bb
);
//- Construct from dictionary