rotatedBoxToCell.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "rotatedBoxToCell.H"
00030 #include "polyMesh.H"
00031 #include "cellModeller.H"
00032
00033 #include "addToRunTimeSelectionTable.H"
00034
00035
00036
00037 namespace Foam
00038 {
00039
00040 defineTypeNameAndDebug(rotatedBoxToCell, 0);
00041
00042 addToRunTimeSelectionTable(topoSetSource, rotatedBoxToCell, word);
00043
00044 addToRunTimeSelectionTable(topoSetSource, rotatedBoxToCell, istream);
00045
00046 }
00047
00048
00049 Foam::topoSetSource::addToUsageTable Foam::rotatedBoxToCell::usage_
00050 (
00051 rotatedBoxToCell::typeName,
00052 "\n Usage: rotatedBoxToCell (originx originy originz)"
00053 " (ix iy iz) (jx jy jz) (kx ky kz)\n\n"
00054 " Select all cells with cellCentre within parallelopiped\n\n"
00055 );
00056
00057
00058
00059
00060 void Foam::rotatedBoxToCell::combine(topoSet& set, const bool add) const
00061 {
00062
00063 pointField boxPoints(8);
00064 boxPoints[0] = origin_;
00065 boxPoints[1] = origin_ + i_;
00066 boxPoints[2] = origin_ + i_ + j_;
00067 boxPoints[3] = origin_ + j_;
00068 boxPoints[4] = origin_ + k_;
00069 boxPoints[5] = origin_ + k_ + i_;
00070 boxPoints[6] = origin_ + k_ + i_ + j_;
00071 boxPoints[7] = origin_ + k_ + j_;
00072
00073 labelList boxVerts(8);
00074 forAll(boxVerts, i)
00075 {
00076 boxVerts[i] = i;
00077 }
00078
00079 const cellModel& hex = *(cellModeller::lookup("hex"));
00080
00081
00082 faceList boxFaces(cellShape(hex, boxVerts).faces());
00083
00084
00085 vectorField boxFaceNormals(boxFaces.size());
00086 forAll(boxFaces, i)
00087 {
00088 boxFaceNormals[i] = boxFaces[i].normal(boxPoints);
00089
00090 Pout<< "Face:" << i << " position:" << boxFaces[i].centre(boxPoints)
00091 << " normal:" << boxFaceNormals[i] << endl;
00092 }
00093
00094
00095
00096 const pointField& ctrs = mesh_.cellCentres();
00097
00098 forAll(ctrs, cellI)
00099 {
00100 bool inside = true;
00101
00102 forAll(boxFaces, i)
00103 {
00104 const face& f = boxFaces[i];
00105
00106 if (((ctrs[cellI] - boxPoints[f[0]]) & boxFaceNormals[i]) > 0)
00107 {
00108 inside = false;
00109 break;
00110 }
00111 }
00112
00113 if (inside)
00114 {
00115 addOrDelete(set, cellI, add);
00116 }
00117 }
00118 }
00119
00120
00121
00122
00123
00124 Foam::rotatedBoxToCell::rotatedBoxToCell
00125 (
00126 const polyMesh& mesh,
00127 const vector& origin,
00128 const vector& i,
00129 const vector& j,
00130 const vector& k
00131 )
00132 :
00133 topoSetSource(mesh),
00134 origin_(origin_),
00135 i_(i),
00136 j_(j),
00137 k_(k)
00138 {}
00139
00140
00141
00142 Foam::rotatedBoxToCell::rotatedBoxToCell
00143 (
00144 const polyMesh& mesh,
00145 const dictionary& dict
00146 )
00147 :
00148 topoSetSource(mesh),
00149 origin_(dict.lookup("origin")),
00150 i_(dict.lookup("i")),
00151 j_(dict.lookup("j")),
00152 k_(dict.lookup("k"))
00153 {}
00154
00155
00156
00157 Foam::rotatedBoxToCell::rotatedBoxToCell(const polyMesh& mesh, Istream& is)
00158 :
00159 topoSetSource(mesh),
00160 origin_(is),
00161 i_(is),
00162 j_(is),
00163 k_(is)
00164 {}
00165
00166
00167
00168
00169 Foam::rotatedBoxToCell::~rotatedBoxToCell()
00170 {}
00171
00172
00173
00174
00175 void Foam::rotatedBoxToCell::applyToSet
00176 (
00177 const topoSetSource::setAction action,
00178 topoSet& set
00179 ) const
00180 {
00181 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00182 {
00183 Info<< " Adding cells with center within rotated box " << endl;
00184
00185 combine(set, true);
00186 }
00187 else if (action == topoSetSource::DELETE)
00188 {
00189 Info<< " Removing cells with center within rotated box " << endl;
00190
00191 combine(set, false);
00192 }
00193 }
00194
00195
00196
Copyright © 2000-2009 OpenCFD Ltd