Loading...
Searching...
No Matches
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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2012-2017 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "fileControl.H"
30#include "scalarList.H"
31#include "vectorTools.H"
32#include "pointIOField.H"
33#include "scalarIOField.H"
34#include "triadIOField.H"
35
36// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37
38namespace Foam
39{
40
43(
47);
48
49}
50
51
52// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53
54Foam::fileControl::fileControl
55(
56 const Time& runTime,
57 const word& name,
58 const dictionary& controlFunctionDict,
59 const conformationSurfaces& geometryToConformTo,
60 const scalar& defaultCellSize
61)
62:
63 cellSizeAndAlignmentControl
64 (
65 runTime,
66 name,
67 controlFunctionDict,
68 geometryToConformTo,
69 defaultCellSize
70 ),
71 pointsFile_(controlFunctionDict.get<fileName>("pointsFile")),
72 sizesFile_(controlFunctionDict.get<fileName>("sizesFile")),
73 alignmentsFile_(controlFunctionDict.get<fileName>("alignmentsFile")),
74 maxPriority_(controlFunctionDict.get<label>("priority"))
75{
76 Info<< indent << "Loading " << name << " from file:" << nl
77 << indent << " priority : " << maxPriority_ << nl
78 << indent << " points : " << pointsFile_ << nl
79 << indent << " sizes : " << sizesFile_ << nl
80 << indent << " alignments : " << alignmentsFile_
81 << endl;
82}
83
84
85// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
86//
87//Foam::scalar Foam::fileControl::cellSize(const point& pt) const
88//{
89// FixedList<scalar, 4> bary;
90// Cell_handle ch;
91//
92// triangulatedMesh_.barycentricCoords(pt, bary, ch);
93//
94// scalar size = 0;
95// forAll(bary, pI)
96// {
97// size += bary[pI]*ch->vertex(pI)->size();
98// }
99//
100// return size;
101//}
102//
103//
105//Foam::tensor Foam::fileControl::cellAlignment(const point& pt) const
106//{
107// FixedList<scalar, 4> bary;
108// Cell_handle ch;
109//
110// triangulatedMesh_.barycentricCoords(pt, bary, ch);
111//
112// label nearest = 0;
113//
114// tensor alignment = Zero;
115// forAll(bary, pI)
116// {
117// //alignment += bary[pI]*ch->vertex(pI)->alignment();
118//
119// // Find nearest point
120// if (bary[pI] > nearest)
121// {
122// alignment = ch->vertex(pI)->alignment();
123// nearest = bary[pI];
124// }
125// }
126//
127// return alignment;
128//}
129//
130//
132//void Foam::fileControl::cellSizeAndAlignment
133//(
134// const point& pt,
135// scalar& size,
136// tensor& alignment
137//) const
138//{
139// FixedList<scalar, 4> bary;
140// Cell_handle ch;
141//
142// triangulatedMesh_.barycentricCoords(pt, bary, ch);
143//
144// size = 0;
145// forAll(bary, pI)
146// {
147// size += bary[pI]*ch->vertex(pI)->size();
148// }
149//
155//
156// alignment = cellAlignment(pt);
157//}
158
159
161(
162 DynamicList<Foam::point>& pts,
163 DynamicList<scalar>& sizes
164) const
165{
166 return;
167}
168
169
171(
173 scalarField& sizes,
174 triadField& alignments
175) const
176{
177 Info<< " Reading points from file : " << pointsFile_ << endl;
178
180 (
182 (
183 pointsFile_,
184 runTime_.constant(),
185 runTime_,
187 )
188 );
189
190 Info<< " Reading sizes from file : " << sizesFile_ << endl;
191
193 (
195 (
196 sizesFile_,
197 runTime_.constant(),
198 runTime_,
200 )
201 );
202
203 Info<< " Reading alignments from file : " << alignmentsFile_ << endl;
204
205 alignments = triadIOField::readContents
206 (
208 (
209 alignmentsFile_,
210 runTime_.constant(),
211 runTime_,
213 )
214 );
215
216 if ((pts.size() != sizes.size()) || (pts.size() != alignments.size()))
217 {
219 << "Size of list of points, sizes and alignments do not match:"
220 << nl
221 << "Points size = " << pts.size() << nl
222 << "Sizes size = " << sizes.size() << nl
223 << "Alignments size = " << alignments.size()
224 << abort(FatalError);
225 }
226}
227
228
229// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
static Field< vector > readContents(const IOobject &io)
@ MUST_READ
Reading required.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
virtual void cellSizeFunctionVertices(DynamicList< Foam::point > &pts, DynamicList< scalar > &sizes) const
virtual void initialVertices(pointField &pts, scalarField &sizes, triadField &alignments) const
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
engineTime & runTime
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
auto & name
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
Ostream & indent(Ostream &os)
Indent stream.
Definition Ostream.H:481
errorManip< error > abort(error &err)
Definition errorManip.H:139
Field< triad > triadField
Specialisation of Field<T> for triad.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
const pointField & pts