topoSet: rotatedBoxToCell: Added box and rotation specification
The rotatedBoxToCell topoSet source can now be specified by providing
the geometry of a non-rotated box and how it should be rotated. For
example, in system/topoSetDict:
actions
(
{
name c1;
type cellSet;
action new;
source rotatedBoxToCell;
box (0.4 0.4 -100) (0.6 0.6 100);
centre (0.4 0.4 0);
n1 (1 0 0);
n2 (1 1 0);
}
);
This selects cells in a box rotated from (1 0 0) to (1 1 0) (i.e., 45
degrees around the z-axis), with width and depth of 0.2, height of 200,
and with a bottom left corner at (0.4 0.4 -100).
The origin, i, j, k, specification is still available, and will be used
if the keyword "box" is not present. The equivalent input to the above
in this form is as follows:
actions
(
{
name c1;
type cellSet;
action new;
source rotatedBoxToCell;
origin (0.4 0.4 -100);
i (0.141421 0.141421 0);
j (-0.141421 0.141421 0);
k (0 0 200);
}
);
This commit is contained in:
@ -26,6 +26,7 @@ License
|
||||
#include "rotatedBoxToCell.H"
|
||||
#include "polyMesh.H"
|
||||
#include "cellModeller.H"
|
||||
#include "transform.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -123,11 +124,34 @@ Foam::rotatedBoxToCell::rotatedBoxToCell
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
origin_(dict.lookup("origin")),
|
||||
i_(dict.lookup("i")),
|
||||
j_(dict.lookup("j")),
|
||||
k_(dict.lookup("k"))
|
||||
{}
|
||||
origin_(),
|
||||
i_(),
|
||||
j_(),
|
||||
k_()
|
||||
{
|
||||
if (dict.found("box"))
|
||||
{
|
||||
const boundBox bb(dict.lookup("box"));
|
||||
const vector c(dict.lookupOrDefault<vector>("centre", bb.midpoint()));
|
||||
const vector n1(normalised(dict.lookup<vector>("n1")));
|
||||
const vector n2(normalised(dict.lookup<vector>("n2")));
|
||||
|
||||
const tensor R(rotationTensor(n1, n2));
|
||||
const pointField bbPoints(bb.points());
|
||||
|
||||
origin_ = (R & (bb.min() - c)) + c;
|
||||
i_ = R & (bbPoints[1] - bb.min());
|
||||
j_ = R & (bbPoints[3] - bb.min());
|
||||
k_ = R & (bbPoints[4] - bb.min());
|
||||
}
|
||||
else
|
||||
{
|
||||
origin_ = dict.lookup<point>("origin");
|
||||
i_ = dict.lookup<vector>("i");
|
||||
j_ = dict.lookup<vector>("j");
|
||||
k_ = dict.lookup<vector>("k");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -25,17 +25,38 @@ Class
|
||||
Foam::rotatedBoxToCell
|
||||
|
||||
Description
|
||||
A topoSetSource to select cells based on cell centres inside
|
||||
rotated/skewed box (parallelopiped?).
|
||||
A topoSetSource to select cells based on cell centres inside a rotated
|
||||
and/or skewed box.
|
||||
|
||||
The box can be defined with an origin and three vectors; i, j, and k. The
|
||||
origin is one corner of the box, and the vectors are the edges connected to
|
||||
that corner.
|
||||
|
||||
For example, the following defines a box rotated 45 degrees around the
|
||||
z-axis, with width and depth of 0.2, height of 200, and with a bottom left
|
||||
corner at (0.4 0.4 -100):
|
||||
|
||||
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);
|
||||
origin (0.4 0.4 -100);
|
||||
i (0.141421 0.141421 0);
|
||||
j (-0.141421 0.141421 0);
|
||||
k (0 0 200);
|
||||
\endverbatim
|
||||
|
||||
Alternatively, the box can be defined using a non-rotated box and details
|
||||
of how it should be rotated. This syntax is triggered by the presence of
|
||||
the keyword "box". A standard bounding box is supplied, along with a centre
|
||||
of rotation and two vectors, n1 and n2. The rotation is taken to be that
|
||||
which transforms n1 onto n2.
|
||||
|
||||
The above example can be equivalently specified in this alternative form as
|
||||
follows:
|
||||
|
||||
\verbatim
|
||||
box (0.4 0.4 -100) (0.6 0.6 100);
|
||||
centre (0.4 0.4 0);
|
||||
n1 (1 0 0);
|
||||
n2 (1 1 0);
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
@ -62,16 +83,19 @@ class rotatedBoxToCell
|
||||
:
|
||||
public topoSetSource
|
||||
{
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Skewed box origin
|
||||
vector origin_;
|
||||
|
||||
//- Skewed box edge vector
|
||||
vector i_;
|
||||
|
||||
//- Skewed box
|
||||
const vector origin_;
|
||||
const vector i_;
|
||||
const vector j_;
|
||||
const vector k_;
|
||||
//- Skewed box edge vector
|
||||
vector j_;
|
||||
|
||||
//- Skewed box edge vector
|
||||
vector k_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
Reference in New Issue
Block a user