1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
27 \*---------------------------------------------------------------------------*/
29 #ifndef vtkPV3FoamFaceField_H
30 #define vtkPV3FoamFaceField_H
33 #include "vtkCellData.h"
34 #include "vtkFloatArray.h"
35 #include "vtkMultiBlockDataSet.h"
36 #include "vtkPolyData.h"
38 #include "vtkFOAMTupleRemap.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 void Foam::vtkPV3Foam::convertFaceField
45 const GeometricField<Type, fvPatchField, volMesh>& tf,
46 vtkMultiBlockDataSet* output,
47 const partInfo& selector,
48 const label datasetNo,
50 const labelList& faceLabels
53 const label nComp = pTraits<Type>::nComponents;
54 const label nInternalFaces = mesh.nInternalFaces();
55 const label nFaces = mesh.nFaces();
56 const labelList& faceOwner = mesh.faceOwner();
57 const labelList& faceNeigh = mesh.faceNeighbour();
59 vtkFloatArray *cellData = vtkFloatArray::New();
60 cellData->SetNumberOfTuples( faceLabels.size() );
61 cellData->SetNumberOfComponents( nComp );
62 cellData->Allocate( nComp*faceLabels.size() );
63 cellData->SetName( tf.name().c_str() );
67 Info<< "convert convertFaceField: "
69 << " size = " << tf.size()
71 << " nTuples = " << faceLabels.size() << endl;
76 // for interior faces: average owner/neighbour
77 // for boundary faces: owner
78 forAll(faceLabels, faceI)
80 // Bug fix: filter inactive faces. HJ, 21/Mar/2011
81 const label faceNo = faceLabels[faceI];
83 if (faceNo < nInternalFaces)
85 Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
87 for (direction d = 0; d < nComp; d++)
89 vec[d] = component(t, d);
92 else if (faceNo < nFaces)
94 const Type& t = tf[faceOwner[faceNo]];
95 for (direction d = 0; d < nComp; d++)
97 vec[d] = component(t, d);
102 for (direction d = 0; d < nComp; d++)
107 vtkFOAMTupleRemap<Type>(vec);
109 cellData->InsertTuple(faceI, vec);
113 vtkPolyData::SafeDownCast
115 GetDataSetFromBlock(output, selector, datasetNo)
117 ->AddArray(cellData);
124 void Foam::vtkPV3Foam::convertFaceField
126 const GeometricField<Type, fvPatchField, volMesh>& tf,
127 vtkMultiBlockDataSet* output,
128 const partInfo& selector,
129 const label datasetNo,
134 const label nComp = pTraits<Type>::nComponents;
135 const label nInternalFaces = mesh.nInternalFaces();
136 const label nFaces = mesh.nFaces();
137 const labelList& faceOwner = mesh.faceOwner();
138 const labelList& faceNeigh = mesh.faceNeighbour();
140 vtkFloatArray *cellData = vtkFloatArray::New();
141 cellData->SetNumberOfTuples( fSet.size() );
142 cellData->SetNumberOfComponents( nComp );
143 cellData->Allocate( nComp*fSet.size() );
144 cellData->SetName( tf.name().c_str() );
148 Info<< "convert convertFaceField: "
150 << " size = " << tf.size()
151 << " nComp=" << nComp
152 << " nTuples = " << fSet.size() << endl;
157 // for interior faces: average owner/neighbour
158 // for boundary faces: owner
160 forAllConstIter(faceSet, fSet, iter)
162 const label faceNo = iter.key();
164 // Bug fix: filter inactive faces. HJ, 21/Mar/2011
165 if (faceNo < nInternalFaces)
167 Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
169 for (direction d = 0; d < nComp; d++)
171 vec[d] = component(t, d);
174 else if (faceNo < nFaces)
176 const Type& t = tf[faceOwner[faceNo]];
177 for (direction d = 0; d < nComp; d++)
179 vec[d] = component(t, d);
184 for (direction d = 0; d < nComp; d++)
189 vtkFOAMTupleRemap<Type>(vec);
191 cellData->InsertTuple(faceI, vec);
196 vtkPolyData::SafeDownCast
198 GetDataSetFromBlock(output, selector, datasetNo)
200 ->AddArray(cellData);
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 // ************************************************************************* //