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 // 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; // source boxToCell;
// sourceInfo // sourceInfo
// { // {
// box (0 0 0) (1 1 1); // 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 // // Cells with cell centre within box
@ -223,11 +224,12 @@ FoamFile
// name ".*Zone1"; // Name of faceZone, regular expressions allowed // 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; // source boxToFace;
// sourceInfo // sourceInfo
// { // {
// box (0 0 0) (1 1 1); // 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. // // Faces with normal to within certain angle aligned with vector.
@ -295,11 +297,12 @@ FoamFile
// points ((0 0 0) (1 1 1)); // points ((0 0 0) (1 1 1));
// } // }
// //
// // Points with coordinate within box // // Points with coordinate within box ('box') or multiple boxes ('boxes')
// source boxToPoint; // source boxToPoint;
// sourceInfo // sourceInfo
// { // {
// box (0 0 0) (1 1 1); // box (0 0 0) (1 1 1);
// //boxes ((0 0 0) (1 1 1) (10 10 10)(11 11 11));
// } // }
// //
// // Select based on surface // // Select based on surface

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -58,9 +58,13 @@ void Foam::boxToFace::combine(topoSet& set, const bool add) const
forAll(ctrs, faceI) forAll(ctrs, faceI)
{ {
if (bb_.contains(ctrs[faceI])) forAll(bbs_, i)
{
if (bbs_[i].contains(ctrs[faceI]))
{ {
addOrDelete(set, faceI, add); addOrDelete(set, faceI, add);
break;
}
} }
} }
} }
@ -72,11 +76,11 @@ void Foam::boxToFace::combine(topoSet& set, const bool add) const
Foam::boxToFace::boxToFace Foam::boxToFace::boxToFace
( (
const polyMesh& mesh, const polyMesh& mesh,
const treeBoundBox& bb const treeBoundBoxList& bbs
) )
: :
topoSetSource(mesh), topoSetSource(mesh),
bb_(bb) bbs_(bbs)
{} {}
@ -88,7 +92,12 @@ Foam::boxToFace::boxToFace
) )
: :
topoSetSource(mesh), 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), 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)) 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); combine(set, true);
} }
else if (action == topoSetSource::DELETE) 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); combine(set, false);
} }

View File

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

View File

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

View File

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