fileControl.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2012-2016 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 "fileControl.H"
28 #include "tetrahedron.H"
29 #include "scalarList.H"
30 #include "vectorTools.H"
31 #include "pointIOField.H"
32 #include "scalarIOField.H"
33 #include "triadIOField.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 defineTypeNameAndDebug(fileControl, 0);
42 (
43  cellSizeAndAlignmentControl,
44  fileControl,
45  dictionary
46 );
47 
48 }
49 
50 
51 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
52 
53 
54 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 
56 Foam::fileControl::fileControl
57 (
58  const Time& runTime,
59  const word& name,
60  const dictionary& controlFunctionDict,
61  const conformationSurfaces& geometryToConformTo,
62  const scalar& defaultCellSize
63 )
64 :
65  cellSizeAndAlignmentControl
66  (
67  runTime,
68  name,
69  controlFunctionDict,
70  geometryToConformTo,
71  defaultCellSize
72  ),
73  pointsFile_(controlFunctionDict.lookup("pointsFile")),
74  sizesFile_(controlFunctionDict.lookup("sizesFile")),
75  alignmentsFile_(controlFunctionDict.lookup("alignmentsFile")),
76  maxPriority_(readLabel(controlFunctionDict.lookup("priority")))
77 {
78  Info<< indent << "Loading " << name << " from file:" << nl
79  << indent << " priority : " << maxPriority_ << nl
80  << indent << " points : " << pointsFile_ << nl
81  << indent << " sizes : " << sizesFile_ << nl
82  << indent << " alignments : " << alignmentsFile_
83  << endl;
84 }
85 
86 
87 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
88 
90 {}
91 
92 
93 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
94 //
95 //Foam::scalar Foam::fileControl::cellSize(const point& pt) const
96 //{
97 // scalarList bary;
98 // Cell_handle ch;
99 //
100 // triangulatedMesh_.barycentricCoords(pt, bary, ch);
101 //
102 // scalar size = 0;
103 // forAll(bary, pI)
104 // {
105 // size += bary[pI]*ch->vertex(pI)->size();
106 // }
107 //
108 // return size;
109 //}
110 //
111 //
113 //Foam::tensor Foam::fileControl::cellAlignment(const point& pt) const
114 //{
115 // scalarList bary;
116 // Cell_handle ch;
117 //
118 // triangulatedMesh_.barycentricCoords(pt, bary, ch);
119 //
120 // label nearest = 0;
121 //
122 // tensor alignment = Zero;
123 // forAll(bary, pI)
124 // {
125 // //alignment += bary[pI]*ch->vertex(pI)->alignment();
126 //
127 // // Find nearest point
128 // if (bary[pI] > nearest)
129 // {
130 // alignment = ch->vertex(pI)->alignment();
131 // nearest = bary[pI];
132 // }
133 // }
134 //
135 // return alignment;
136 //}
137 //
138 //
140 //void Foam::fileControl::cellSizeAndAlignment
141 //(
142 // const point& pt,
143 // scalar& size,
144 // tensor& alignment
145 //) const
146 //{
147 // scalarList bary;
148 // Cell_handle ch;
149 //
150 // triangulatedMesh_.barycentricCoords(pt, bary, ch);
151 //
152 // size = 0;
153 // forAll(bary, pI)
154 // {
155 // size += bary[pI]*ch->vertex(pI)->size();
156 // }
157 //
163 //
164 // alignment = cellAlignment(pt);
165 //}
166 
167 
169 (
170  DynamicList<Foam::point>& pts,
171  DynamicList<scalar>& sizes
172 ) const
173 {
174  return;
175 }
176 
177 
179 (
180  pointField& pts,
181  scalarField& sizes,
182  triadField& alignments
183 ) const
184 {
185  Info<< " Reading points from file : " << pointsFile_ << endl;
186 
187  pointIOField pointsTmp
188  (
189  IOobject
190  (
191  pointsFile_,
192  runTime_.constant(),
193  runTime_,
196  false
197  )
198  );
199 
200  pts.transfer(pointsTmp);
201 
202  Info<< " Reading sizes from file : " << sizesFile_ << endl;
203 
204  scalarIOField sizesTmp
205  (
206  IOobject
207  (
208  sizesFile_,
209  runTime_.constant(),
210  runTime_,
213  false
214  )
215  );
216 
217  sizes.transfer(sizesTmp);
218 
219  Info<< " Reading alignments from file : " << alignmentsFile_ << endl;
220 
221  triadIOField alignmentsTmp
222  (
223  IOobject
224  (
225  alignmentsFile_,
226  runTime_.constant(),
227  runTime_,
230  false
231  )
232  );
233 
234  alignments.transfer(alignmentsTmp);
235 
236  if ((pts.size() != sizes.size()) || (pts.size() != alignments.size()))
237  {
239  << "Size of list of points, sizes and alignments do not match:"
240  << nl
241  << "Points size = " << pts.size() << nl
242  << "Sizes size = " << sizes.size() << nl
243  << "Alignments size = " << alignments.size()
244  << abort(FatalError);
245  }
246 }
247 
248 
249 // ************************************************************************* //
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:223
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
vectorIOField pointIOField
pointIOField is a vectorIOField.
Definition: pointIOField.H:42
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
Macros for easy insertion into run-time selection tables.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
stressControl lookup("compactNormalStress") >> compactNormalStress
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
~fileControl()
Destructor.
IOField< scalar > scalarIOField
scalarField with IO.
Definition: scalarIOField.H:42
errorManip< error > abort(error &err)
Definition: errorManip.H:131
label readLabel(Istream &is)
Definition: label.H:64
Field< triad > triadField
Specialisation of Field<T> for triad.
Definition: triadField.H:49
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
static const char nl
Definition: Ostream.H:262
defineTypeNameAndDebug(combustionModel, 0)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
virtual void initialVertices(pointField &pts, scalarField &sizes, triadField &alignments) const
virtual void cellSizeFunctionVertices(DynamicList< Foam::point > &pts, DynamicList< scalar > &sizes) const
messageStream Info
IOField< triad > triadIOField
triadField with IO.
Definition: triadIOField.H:42
Namespace for OpenFOAM.