boxUniform.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "boxUniform.H"
27 #include "meshSearch.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace sampledSets
35 {
38 }
39 }
40 
41 
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43 
44 bool Foam::sampledSets::boxUniform::calcSamples
45 (
46  DynamicList<point>& samplingPositions,
47  DynamicList<scalar>&,
48  DynamicList<label>& samplingSegments,
49  DynamicList<label>& samplingCells,
50  DynamicList<label>& samplingFaces
51 ) const
52 {
53  const meshSearch& searchEngine = meshSearch::New(mesh());
54 
55  for (label k = 0; k < nPoints_.z(); ++ k)
56  {
57  for (label j = 0; j < nPoints_.y(); ++ j)
58  {
59  for (label i = 0; i < nPoints_.x(); ++ i)
60  {
61  const vector t =
62  cmptDivide(vector(i, j, k), vector(nPoints_) - vector::one);
63 
64  const point pt =
65  cmptMultiply(vector::one - t, box_.min())
66  + cmptMultiply(t, box_.max());
67 
68  const label celli = searchEngine.findCell(pt);
69 
70  if (celli != -1)
71  {
72  samplingPositions.append(pt);
73  samplingSegments.append
74  (
75  i + j*nPoints_.x() + k*nPoints_.x()*nPoints_.y()
76  );
77  samplingCells.append(celli);
78  samplingFaces.append(-1);
79  }
80  }
81  }
82  }
83 
84  // This set is unordered. Distances have not been created.
85  return false;
86 }
87 
88 
89 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
90 
92 (
93  const word& name,
94  const polyMesh& mesh,
95  const dictionary& dict
96 )
97 :
99  box_(dict),
100  nPoints_(dict.lookup("nPoints"))
101 {}
102 
103 
104 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
105 
107 {}
108 
109 
110 // ************************************************************************* //
label k
Macros for easy insertion into run-time selection tables.
static const Form one
Definition: VectorSpace.H:119
const Cmpt & z() const
Definition: VectorI.H:87
const Cmpt & y() const
Definition: VectorI.H:81
const Cmpt & x() const
Definition: VectorI.H:75
const point & min() const
Minimum point defining the bounding box.
Definition: boundBoxI.H:88
const point & max() const
Maximum point defining the bounding box.
Definition: boundBoxI.H:94
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
static const meshSearch & New(const polyMesh &mesh, const pointInCellShapes=pointInCellShapes::tets)
Lookup or construct from mesh and cell decomposition option.
Definition: meshSearch.C:61
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:64
const polyMesh & mesh() const
Access the mesh.
Definition: sampledSetI.H:36
Uniform 3D-grid of samples.
Definition: boxUniform.H:94
virtual ~boxUniform()
Destructor.
Definition: boxUniform.C:106
boxUniform(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: boxUniform.C:92
Set of sets to sample. Call sampledSets.write() to sample&write files.
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
defineTypeNameAndDebug(arcUniform, 0)
addToRunTimeSelectionTable(sampledSet, arcUniform, word)
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
tmp< DimensionedField< Type, GeoMesh, Field > > cmptMultiply(const DimensionedField< Type, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< Type, GeoMesh, PrimitiveField2 > &df2)
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
tmp< DimensionedField< Type, GeoMesh, Field > > cmptDivide(const DimensionedField< Type, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< Type, GeoMesh, PrimitiveField2 > &df2)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dictionary dict