1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 \*---------------------------------------------------------------------------*/
30 #ifndef vtkPV3FoamFaceField_H
31 #define vtkPV3FoamFaceField_H
34 #include "vtkCellData.h"
35 #include "vtkFloatArray.h"
36 #include "vtkMultiBlockDataSet.h"
37 #include "vtkPolyData.h"
39 #include "vtkOpenFOAMTupleRemap.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 void Foam::vtkPV3Foam::convertFaceField
46 const GeometricField<Type, fvPatchField, volMesh>& tf,
47 vtkMultiBlockDataSet* output,
48 const partInfo& selector,
49 const label datasetNo,
51 const labelList& faceLabels
54 const label nComp = pTraits<Type>::nComponents;
55 const label nInternalFaces = mesh.nInternalFaces();
56 const label nFaces = mesh.nFaces();
57 const labelList& faceOwner = mesh.faceOwner();
58 const labelList& faceNeigh = mesh.faceNeighbour();
60 vtkFloatArray *cellData = vtkFloatArray::New();
61 cellData->SetNumberOfTuples( faceLabels.size() );
62 cellData->SetNumberOfComponents( nComp );
63 cellData->Allocate( nComp*faceLabels.size() );
64 cellData->SetName( tf.name().c_str() );
68 Info<< "convert convertFaceField: "
70 << " size = " << tf.size()
72 << " nTuples = " << faceLabels.size() << endl;
77 // for interior faces: average owner/neighbour
78 // for boundary faces: owner
79 forAll(faceLabels, faceI)
81 // Bug fix: filter inactive faces. HJ, 21/Mar/2011
82 const label faceNo = faceLabels[faceI];
84 if (faceNo < nInternalFaces)
86 Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
88 for (direction d = 0; d < nComp; d++)
90 vec[d] = component(t, d);
93 else if (faceNo < nFaces)
95 const Type& t = tf[faceOwner[faceNo]];
96 for (direction d = 0; d < nComp; d++)
98 vec[d] = component(t, d);
103 for (direction d = 0; d < nComp; d++)
108 vtkOpenFOAMTupleRemap<Type>(vec);
110 cellData->InsertTuple(faceI, vec);
114 vtkPolyData::SafeDownCast
116 GetDataSetFromBlock(output, selector, datasetNo)
118 ->AddArray(cellData);
125 void Foam::vtkPV3Foam::convertFaceField
127 const GeometricField<Type, fvPatchField, volMesh>& tf,
128 vtkMultiBlockDataSet* output,
129 const partInfo& selector,
130 const label datasetNo,
135 const label nComp = pTraits<Type>::nComponents;
136 const label nInternalFaces = mesh.nInternalFaces();
137 const label nFaces = mesh.nFaces();
138 const labelList& faceOwner = mesh.faceOwner();
139 const labelList& faceNeigh = mesh.faceNeighbour();
141 vtkFloatArray *cellData = vtkFloatArray::New();
142 cellData->SetNumberOfTuples( fSet.size() );
143 cellData->SetNumberOfComponents( nComp );
144 cellData->Allocate( nComp*fSet.size() );
145 cellData->SetName( tf.name().c_str() );
149 Info<< "convert convertFaceField: "
151 << " size = " << tf.size()
152 << " nComp=" << nComp
153 << " nTuples = " << fSet.size() << endl;
158 // for interior faces: average owner/neighbour
159 // for boundary faces: owner
161 forAllConstIter(faceSet, fSet, iter)
163 const label faceNo = iter.key();
165 // Bug fix: filter inactive faces. HJ, 21/Mar/2011
166 if (faceNo < nInternalFaces)
168 Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
170 for (direction d = 0; d < nComp; d++)
172 vec[d] = component(t, d);
175 else if (faceNo < nFaces)
177 const Type& t = tf[faceOwner[faceNo]];
178 for (direction d = 0; d < nComp; d++)
180 vec[d] = component(t, d);
185 for (direction d = 0; d < nComp; d++)
190 vtkOpenFOAMTupleRemap<Type>(vec);
192 cellData->InsertTuple(faceI, vec);
197 vtkPolyData::SafeDownCast
199 GetDataSetFromBlock(output, selector, datasetNo)
201 ->AddArray(cellData);
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 // ************************************************************************* //