Test-volField.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) 2011-2015 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  Application
25  Test-volField
26 
27  \*---------------------------------------------------------------------------*/
28 
29 #include "fvCFD.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 int main(int argc, char *argv[])
35 {
36 #include "setRootCase.H"
37 
38 #include "createTime.H"
39 
40  //这里创建了Mesh对象,是FvMesh,有限体积法的Mesh
41  // 9 Foam::fvMesh mesh
42  // (
43  // Foam::IOobject
44  // (
45  // Foam::fvMesh::defaultRegion,
46  // runTime.timeName(),
47  // runTime,
48  // Foam::IOobject::MUST_READ
49  // )
50  // );
51 #include "createMesh.H"
52 
53  Info << " ================mesh infomation are ============" << endl;
54  Info << " ================mesh infomation are ============" << endl;
55 
56  Info << " ========mesh.boundaryMesh()=====================" << endl;
57  Info << mesh.boundaryMesh() << endl;
58  Info << " ======================== " << endl;
59 
60  Info << " ========mesh.bounds()=====================" << endl;
61  Info << mesh.bounds() << endl;
62  Info << " ======================== " << endl;
63 
64  Info << " ========mesh.cellshape()=====================" << endl;
65  Info << mesh.cellShapes() << endl;
66  Info << " ======================== " << endl;
67 
68  Info << " ========mesh.cellZone()=====================" << endl;
69  Info << mesh.cellZones() << endl;
70  Info << " ======================== " << endl;
71 
72  Info << " ========mesh.faceNeighbour()=====================" << endl;
73  Info << mesh.faceNeighbour() << endl;
74  Info << " ======================== " << endl;
75 
76  Info << " ========mesh.faceOwner()=====================" << endl;
77  Info << mesh.faceOwner()<< endl;
78  Info << " ======================== " << endl;
79 
80  Info << " ========mesh.faceZone()=====================" << endl;
81  Info << mesh.faceZones() << endl;
82  Info << " ======================== " << endl;
83 
84  Info << " ========mesh.meshDir()=====================" << endl;
85  Info << mesh.meshDir() << endl;
86  Info << " ======================== " << endl;
87 
88  Info << " ========mesh.nSolutionD()=====================" << endl;
89  Info << mesh.nSolutionD() << endl;
90  Info << " ======================== " << endl;
91 
92  Info << " ========mesh.geometricD()=====================" << endl;
93  Info << mesh.geometricD() << endl;
94  Info << " ======================== " << endl;
95 
96  Info << " ========mesh.pointZone()=====================" << endl;
97  Info << mesh.pointZones() << endl;
98  Info << " ======================== " << endl;
99 
100  Info << " ========mesh.cellCells()=====================" << endl;
101  Info << mesh.cellCells() << endl;
102  Info << " ======================== " << endl;
103 
104  Info << " ========mesh.cellCentres()=====================" << endl;
105  Info << mesh.cellCentres() << endl;
106  Info << " ======================== " << endl;
107 
108  Info << " ========mesh.cellEdge()=====================" << endl;
109  Info << mesh.cellEdges() << endl;
110  Info << " ======================== " << endl;
111 
112  Info << " ========mesh.cellPoints()=====================" << endl;
113  Info << mesh.cellPoints() << endl;
114  Info << " ======================== " << endl;
115 
116  Info << " ========mesh.volumes()=====================" << endl;
117  Info << mesh.cellVolumes() << endl;
118  Info << " ======================== " << endl;
119 
120  Info << " ========mesh.edges()=====================" << endl;
121  Info << mesh.edges() << endl;
122  Info << " ======================== " << endl;
123 
124  Info << " ========mesh.edgeCells()=====================" << endl;
125  Info << mesh.edgeCells() << endl;
126  Info << " ======================== " << endl;
127 
128  Info << " ========mesh.edgeFaces()=====================" << endl;
129  Info << mesh.edgeFaces() << endl;
130  Info << " ======================== " << endl;
131 
132  Info << " ========mesh.faceEdges()=====================" << endl;
133  Info << mesh.faceEdges() << endl;
134  Info << " ======================== " << endl;
135 
136  Info << " ========mesh.faceAreas()=====================" << endl;
137  Info << mesh.faceAreas() << endl;
138  Info << " ======================== " << endl;
139 
140  Info << " ========mesh.faceCentres()=====================" << endl;
141  Info << mesh.faceCentres() << endl;
142  Info << " ======================== " << endl;
143 
144  Info << " ========mesh.ncells()=====================" << endl;
145  Info << mesh.nCells() << endl;
146  Info << " ======================== " << endl;
147 
148 
149  Info << " ========mesh.nEdges()=====================" << endl;
150  Info << mesh.nEdges() << endl;
151  Info << " ======================== " << endl;
152 
153  Info << " ========mesh.nFaces()=====================" << endl;
154  Info << mesh.nFaces() << endl;
155  Info << " ======================== " << endl;
156 
157  Info << " ========mesh(pointcells)=====================" << endl;
158  Info << mesh.pointCells() << endl;
159  Info << " ======================== " << endl;
160 
161 
162  Info << " ========mesh(pointEdge)=====================" << endl;
163  Info << mesh.pointEdges() << endl;
164  Info << " ======================== " << endl;
165 
166  Info << " ========meshpointFaces()=====================" << endl;
167  Info << mesh.pointFaces() << endl;
168  Info << " ======================== " << endl;
169 
170  Info << " ========mesh(pointPoints)=====================" << endl;
171  Info << mesh.pointPoints() << endl;
172  Info << " ======================== " << endl;
173 
174  Info << " ========mesh(pointZones)=====================" << endl;
175  Info << mesh.pointZones() << endl;
176  Info << " ======================== " << endl;
177 
178  Info << " ========mesh.points()()=====================" << endl;
179  Info << mesh.points() << endl;
180  Info << " ======================== " << endl;
181 
182 
183  Info<< "Reading field p\n" << endl;
185  (
186  IOobject
187  (
188  "p",
189  runTime.timeName(),
190  mesh,
191  IOobject::MUST_READ,
192  IOobject::AUTO_WRITE
193  ),
194  mesh
195  );
196 
197 
198  Info<< "p.boundaryField()===" << endl;
199  Info << p.boundaryField()<< endl;
200  Info<< "========================" << endl<< endl;
201 
202  Info<< "p.componet(x)===" << endl;
203  Info << p.component('x') << endl;
204  Info<< "========================" << endl<< endl;
205 
206  Info<< "p.componet(y)===" << endl;
207  Info << p.component('y') << endl;
208  Info<< "========================" << endl<< endl;
209 
210  Info<< "p.componet(z)===" << endl;
211  Info << p.component('z')<< endl;
212  Info<< "========================" << endl<< endl;
213 
214  Info<< "p.correctBoundaryConditions===" << endl;
215  //Info <<p.correctBoundaryConditions() << endl;
216  Info<< "========================" << endl<< endl;
217 
218 
219  Info<< "p.dimensionedInternalField()===" << endl;
220  Info << p.dimensionedInternalField() << endl;
221  Info<< "========================" << endl<< endl;
222 
223 
224  Info<< "p.internalField()=== "<< endl;
225  Info << p.internalField()<<endl;
226  Info<< "========================" << endl<< endl;
227 
228 
229  Info<< "p.dimensions()===" << endl;
230  Info << p.dimensions()<< endl;
231  Info<< "========================" << endl<< endl;
232 
233  Info<< "p===" << endl;
234  Info << p<< endl;
235  Info<< "========================" << endl<< endl;
236 
237  Info<< "Reading field U\n" << endl;
239  (
240  IOobject
241  (
242  "U",
243  runTime.timeName(),
244  mesh,
245  IOobject::MUST_READ,
246  IOobject::AUTO_WRITE
247  ),
248  mesh
249  );
250 
251  Info<< "U.boundaryField()===" << endl;
252  Info << U.boundaryField()<< endl;
253  Info<< "========================" << endl<< endl;
254 
255  forAll(U.boundaryField(),boudaryI)
256  {
257  Info <<endl<< "No. " << boudaryI << " : " << U.boundaryField()[boudaryI] << endl;
258  Info << "No. " << boudaryI << " fixesValue : " << U.boundaryField()[boudaryI].fixesValue() << endl;
259  Info << "No. " << boudaryI << " type : " << U.boundaryField()[boudaryI].type() << endl;
260 
261 
262  forAll(U.boundaryField()[boudaryI],faceID)
263  {
264  Info << "No.face " << faceID << " : " << U.boundaryField()[boudaryI][faceID].typeName << endl;
265 
266  //这种方式可以获取patch上的数值
267  Info << "No.face " << faceID << " : " << U.boundaryField()[boudaryI][faceID][0] << endl;
268  Info << "No.face " << faceID << " : " << U.boundaryField()[boudaryI][faceID][1] << endl;
269  Info << "No.face " << faceID << " : " << U.boundaryField()[boudaryI][faceID][2] << endl;
270  //这种方式也可以获取patch上的数值
271  Info << "No.face " << faceID << " : " << U.boundaryField()[boudaryI][faceID].x() << endl;
272  Info << "No.face " << faceID << " : " << U.boundaryField()[boudaryI][faceID].y() << endl;
273  Info << "No.face " << faceID << " : " << U.boundaryField()[boudaryI][faceID].z() << endl;
274 
275  //这个就是0 1 2 三个数
276  Info << "No.face " << faceID << " : " << U.boundaryField()[boudaryI][faceID].X<< endl;
277  Info << "No.face " << faceID << " : " << U.boundaryField()[boudaryI][faceID].Y<< endl;
278  Info << "No.face " << faceID << " : " << U.boundaryField()[boudaryI][faceID].Z<< endl;
279 
280  Info << "No.face " << faceID << " : " << U.boundaryField()[boudaryI][faceID].size()<< endl;
281  }
282 
283 
284  Info << "No. " << boudaryI << " patchInternalField : " << U.boundaryField()[boudaryI].patchInternalField() << endl;
285  Info << "No. " << boudaryI << " patchInternalField : " << U.boundaryField()[boudaryI].byteSize() << endl;
286  Info << "No. " << boudaryI << " patchInternalField : " << U.boundaryField()[boudaryI].data() << endl;
287  // Info << "No. " << boudaryI << " patchNeighbourField : " << U.boundaryField()[boudaryI].patchNeighbourField() << endl;
288  Info << "No. " << boudaryI << " typeName : " << U.boundaryField()[boudaryI].typeName_() << endl;
289  Info << "No. " << boudaryI << " typeName : " << U.boundaryField()[boudaryI].typeName << endl;
290  Info << "No. " << boudaryI << " patch type : " << U.boundaryField()[boudaryI].patchType() << endl;
291  Info << "No. " << boudaryI << " internal Field:" << U.boundaryField()[boudaryI].internalField() << endl;
292  Info <<endl;
293  }
294 
295 
296  Info<< "U.componet(0)===" << endl;
297  Info << U.component(0) << endl;
298  Info<< "========================" << endl<< endl;
299 
300  Info<< "U.componet(1)===" << endl;
301  Info << U.component(1) << endl;
302  Info<< "========================" << endl<< endl;
303 
304  Info<< "U.componet(2)===" << endl;
305  Info << U.component(2)<< endl;
306  Info<< "========================" << endl<< endl;
307 
308 #include "createPhi.H"
309 
310  //建立面上的量,流量Flux
311  // 28 Creates and initialises the relative face-flux field phi.
312  // 29
313  // 30 \*---------------------------------------------------------------------------*/
314  // 31
315  // 32 #ifndef createPhi_H
316  // 33 #define createPhi_H
317  // 34
318  // 35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
319  // 36
320  // 37 Info<< "Reading/calculating face flux field phi\n" << endl;
321  // 38
322  // 39 surfaceScalarField phi
323  // 40 (
324  // 41 IOobject
325  // 42 (
326  // 43 "phi",
327  // 44 runTime.timeName(),
328  // 45 mesh,
329  // 46 IOobject::READ_IF_PRESENT,
330  // 47 IOobject::AUTO_WRITE
331  // 48 ),
332  // 49 linearInterpolate(U) & mesh.Sf()
333  // 50 );
334  // 51
335 
337  (
338  IOobject
339  (
340  "st",
341  runTime.timeName(),
342  mesh,
343  IOobject::NO_READ,
344  IOobject::NO_WRITE
345  ),
346  mesh,
347  dimensioned<symmTensor>("st", dimless, symmTensor::one),
348  zeroGradientFvPatchSymmTensorField::typeName
349  );
350 
352  (
353  solve
354  (
355  fvm::ddt(st)
356  + fvm::div(phi, st)
358  (
360  st
361  )
362  ==
364  (
365  "source",
367  symmTensor(0, 2, 0, 1, 1.5, 0)
368  )
369  )
370  );
371 
372  Info<< nl
373  << "Detailed SolverPerformance<symmTensor>: " << nl
374  << " " << sP << endl;
375 
376  Info<< nl
377  << "solverPerformanceDict: "
379 
380  return 0;
381 }
382 
383 
384 // ************************************************************************* //
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:979
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
p
p
Definition: pEqn.H:62
main
int main(int argc, char *argv[])
Definition: Test-volField.C:31
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::primitiveMesh::cellPoints
const labelListList & cellPoints() const
Definition: primitiveMeshCellPoints.C:31
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::primitiveMesh::edgeFaces
const labelListList & edgeFaces() const
Definition: primitiveMeshEdgeFaces.C:31
transformGeometricField.H
Spatial transformation functions for FieldFields.
Foam::primitiveMesh::pointFaces
const labelListList & pointFaces() const
Definition: primitiveMeshPointFaces.C:32
Foam::polyMesh::cellZones
const cellZoneMesh & cellZones() const
Return cell zone mesh.
Definition: polyMesh.H:469
Foam::fvc::div
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::primitiveMesh::edges
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
Definition: primitiveMeshEdges.C:353
Foam::primitiveMesh::pointEdges
const labelListList & pointEdges() const
Definition: primitiveMeshPointEdges.C:96
Foam::polyMesh::geometricD
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
Definition: polyMesh.C:784
Foam::primitiveMesh::nEdges
label nEdges() const
Definition: primitiveMeshI.H:41
U
U
Definition: pEqn.H:46
Foam::polyMesh::faceZones
const faceZoneMesh & faceZones() const
Return face zone mesh.
Definition: polyMesh.H:463
Foam::primitiveMesh::nCells
label nCells() const
Definition: primitiveMeshI.H:64
Foam::fvc::laplacian
tmp< GeometricField< Type, fvPatchField, volMesh > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcLaplacian.C:45
solve
rhoEqn solve()
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Foam::primitiveMesh::cellEdges
const labelListList & cellEdges() const
Definition: primitiveMeshCellEdges.C:118
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::polyMesh::pointZones
const pointZoneMesh & pointZones() const
Return point zone mesh.
Definition: polyMesh.H:457
Foam::polyMesh::faceOwner
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1017
Foam::primitiveMesh::faceEdges
const labelListList & faceEdges() const
Definition: primitiveMeshEdges.C:366
Foam::primitiveMesh::cellCells
const labelListList & cellCells() const
Definition: primitiveMeshCellCells.C:100
Foam::data::solverPerformanceDict
const dictionary & solverPerformanceDict() const
Return the dictionary of solver performance data.
Definition: data.C:56
Foam::symmTensor
SymmTensor< scalar > symmTensor
SymmTensor of scalars.
Definition: symmTensor.H:48
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
Foam::primitiveMesh::edgeCells
const labelListList & edgeCells() const
Definition: primitiveMeshEdgeCells.C:32
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::primitiveMesh::cellVolumes
const scalarField & cellVolumes() const
Definition: primitiveMeshCellCentresAndVols.C:222
Foam::primitiveMesh::cellShapes
const cellShapeList & cellShapes() const
Return cell shapes.
Definition: primitiveMesh.C:230
Foam::polyMesh::meshDir
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
Definition: polyMesh.C:766
Foam::polyMesh::nSolutionD
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
Definition: polyMesh.C:812
Foam::polyMesh::bounds
const boundBox & bounds() const
Return mesh bounding box.
Definition: polyMesh.H:427
setRootCase.H
Foam::primitiveMesh::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshCellCentresAndVols.C:211
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::primitiveMesh::nFaces
label nFaces() const
Definition: primitiveMeshI.H:58
Foam::primitiveMesh::faceCentres
const vectorField & faceCentres() const
Definition: primitiveMeshFaceCentresAndAreas.C:130
createMesh.H
Foam::primitiveMesh::pointCells
const labelListList & pointCells() const
Definition: primitiveMeshPointCells.C:108
createTime.H
fvCFD.H
Foam::fvc::ddt
tmp< GeometricField< Type, fvPatchField, volMesh > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
Definition: fvcDdt.C:45
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::SolverPerformance
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics.
Definition: SolverPerformance.H:49
Foam::polyMesh::faceNeighbour
virtual const labelList & faceNeighbour() const
Return face neighbour.
Definition: polyMesh.C:1023
Foam::primitiveMesh::pointPoints
const labelListList & pointPoints() const
Definition: primitiveMeshPointPoints.C:91
Foam::primitiveMesh::faceAreas
const vectorField & faceAreas() const
Definition: primitiveMeshFaceCentresAndAreas.C:141