Commit d06d0e8f authored by Mark Olesen's avatar Mark Olesen

ENH: change vtk::Tools from a class to a namespace

- allows localized extension of functionality
parent bd248fc0
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -78,8 +78,6 @@ namespace vtk ...@@ -78,8 +78,6 @@ namespace vtk
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class faMeshAdaptor class faMeshAdaptor
:
protected vtk::Tools
{ {
public: public:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -91,8 +91,6 @@ namespace vtk ...@@ -91,8 +91,6 @@ namespace vtk
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class fvMeshAdaptor class fvMeshAdaptor
:
protected vtk::Tools
{ {
public: public:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -94,7 +94,7 @@ void Foam::vtk::fvMeshAdaptor::convertVolField ...@@ -94,7 +94,7 @@ void Foam::vtk::fvMeshAdaptor::convertVolField
// To improve code reuse, we allocate the CellData as a zeroed-field // To improve code reuse, we allocate the CellData as a zeroed-field
// ahead of time. // ahead of time.
vtkSmartPointer<vtkFloatArray> cdata = zeroField<Type> vtkSmartPointer<vtkFloatArray> cdata = vtk::Tools::zeroField<Type>
( (
fld.name(), fld.name(),
dataset->GetNumberOfPolys() dataset->GetNumberOfPolys()
...@@ -121,7 +121,7 @@ void Foam::vtk::fvMeshAdaptor::convertVolField ...@@ -121,7 +121,7 @@ void Foam::vtk::fvMeshAdaptor::convertVolField
fvPatchField<Type>(p, fld).patchInternalField() fvPatchField<Type>(p, fld).patchInternalField()
); );
transcribeFloatData(cdata, tpptf()); vtk::Tools::transcribeFloatData(cdata, tpptf());
if if
( (
...@@ -138,7 +138,7 @@ void Foam::vtk::fvMeshAdaptor::convertVolField ...@@ -138,7 +138,7 @@ void Foam::vtk::fvMeshAdaptor::convertVolField
} }
else else
{ {
transcribeFloatData(cdata, ptf); vtk::Tools::transcribeFloatData(cdata, ptf);
if if
( (
...@@ -291,7 +291,7 @@ vtkSmartPointer<vtkFloatArray> Foam::vtk::fvMeshAdaptor::convertPointField ...@@ -291,7 +291,7 @@ vtkSmartPointer<vtkFloatArray> Foam::vtk::fvMeshAdaptor::convertPointField
{ {
for (const label meshPointi : pointMap) for (const label meshPointi : pointMap)
{ {
foamToVtkTuple(scratch, pfld[meshPointi]); vtk::Tools::foamToVtkTuple(scratch, pfld[meshPointi]);
data->SetTuple(pointi++, scratch); data->SetTuple(pointi++, scratch);
} }
} }
...@@ -299,7 +299,7 @@ vtkSmartPointer<vtkFloatArray> Foam::vtk::fvMeshAdaptor::convertPointField ...@@ -299,7 +299,7 @@ vtkSmartPointer<vtkFloatArray> Foam::vtk::fvMeshAdaptor::convertPointField
{ {
for (const Type& val : pfld) for (const Type& val : pfld)
{ {
foamToVtkTuple(scratch, val); vtk::Tools::foamToVtkTuple(scratch, val);
data->SetTuple(pointi++, scratch); data->SetTuple(pointi++, scratch);
} }
} }
...@@ -311,7 +311,7 @@ vtkSmartPointer<vtkFloatArray> Foam::vtk::fvMeshAdaptor::convertPointField ...@@ -311,7 +311,7 @@ vtkSmartPointer<vtkFloatArray> Foam::vtk::fvMeshAdaptor::convertPointField
{ {
for (const label meshCelli : addPointCellLabels) for (const label meshCelli : addPointCellLabels)
{ {
foamToVtkTuple(scratch, vfld[meshCelli]); vtk::Tools::foamToVtkTuple(scratch, vfld[meshCelli]);
data->SetTuple(pointi++, scratch); data->SetTuple(pointi++, scratch);
} }
} }
...@@ -319,7 +319,10 @@ vtkSmartPointer<vtkFloatArray> Foam::vtk::fvMeshAdaptor::convertPointField ...@@ -319,7 +319,10 @@ vtkSmartPointer<vtkFloatArray> Foam::vtk::fvMeshAdaptor::convertPointField
{ {
for (const label meshCelli : addPointCellLabels) for (const label meshCelli : addPointCellLabels)
{ {
foamToVtkTuple(scratch, interpolatePointToCell(pfld, meshCelli)); vtk::Tools::foamToVtkTuple
(
scratch, interpolatePointToCell(pfld, meshCelli)
);
data->SetTuple(pointi++, scratch); data->SetTuple(pointi++, scratch);
} }
} }
...@@ -362,7 +365,7 @@ Foam::vtk::fvMeshAdaptor::convertVolFieldToVTK ...@@ -362,7 +365,7 @@ Foam::vtk::fvMeshAdaptor::convertVolFieldToVTK
vtkIdType celli = 0; vtkIdType celli = 0;
for (const label meshCelli : cellMap) for (const label meshCelli : cellMap)
{ {
foamToVtkTuple(scratch, fld[meshCelli]); vtk::Tools::foamToVtkTuple(scratch, fld[meshCelli]);
data->SetTuple(celli++, scratch); data->SetTuple(celli++, scratch);
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -116,8 +116,7 @@ template<class Type> class List; ...@@ -116,8 +116,7 @@ template<class Type> class List;
class vtkPVFoam class vtkPVFoam
: :
private foamPvCore, private foamPvCore
protected vtk::Tools
{ {
// Convenience typedefs // Convenience typedefs
typedef PrimitivePatchInterpolation<primitivePatch> patchInterpolator; typedef PrimitivePatchInterpolation<primitivePatch> patchInterpolator;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -116,7 +116,7 @@ void Foam::vtkPVFoam::convertVolField ...@@ -116,7 +116,7 @@ void Foam::vtkPVFoam::convertVolField
// To improve code reuse, we allocate the CellData as a zeroed-field // To improve code reuse, we allocate the CellData as a zeroed-field
// ahead of time. // ahead of time.
vtkSmartPointer<vtkFloatArray> cdata = zeroField<Type> vtkSmartPointer<vtkFloatArray> cdata = vtk::Tools::zeroField<Type>
( (
fld.name(), fld.name(),
dataset->GetNumberOfPolys() dataset->GetNumberOfPolys()
...@@ -147,11 +147,12 @@ void Foam::vtkPVFoam::convertVolField ...@@ -147,11 +147,12 @@ void Foam::vtkPVFoam::convertVolField
fvPatchField<Type>(p, fld).patchInternalField() fvPatchField<Type>(p, fld).patchInternalField()
); );
coffset += transcribeFloatData(cdata, tpptf(), coffset); coffset +=
vtk::Tools::transcribeFloatData(cdata, tpptf(), coffset);
if (allowPdata && patchId < patchInterpList.size()) if (allowPdata && patchId < patchInterpList.size())
{ {
pdata = convertFieldToVTK pdata = vtk::Tools::convertFieldToVTK
( (
fld.name(), fld.name(),
patchInterpList[patchId].faceToPointInterpolate(tpptf)() patchInterpList[patchId].faceToPointInterpolate(tpptf)()
...@@ -160,11 +161,12 @@ void Foam::vtkPVFoam::convertVolField ...@@ -160,11 +161,12 @@ void Foam::vtkPVFoam::convertVolField
} }
else else
{ {
coffset += transcribeFloatData(cdata, ptf, coffset); coffset +=
vtk::Tools::transcribeFloatData(cdata, ptf, coffset);
if (allowPdata && patchId < patchInterpList.size()) if (allowPdata && patchId < patchInterpList.size())
{ {
pdata = convertFieldToVTK pdata = vtk::Tools::convertFieldToVTK
( (
fld.name(), fld.name(),
patchInterpList[patchId].faceToPointInterpolate(ptf)() patchInterpList[patchId].faceToPointInterpolate(ptf)()
...@@ -488,11 +490,13 @@ void Foam::vtkPVFoam::convertAreaFields ...@@ -488,11 +490,13 @@ void Foam::vtkPVFoam::convertAreaFields
foamVtpData& vtpData = iter.val(); foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset; auto dataset = vtpData.dataset;
vtkSmartPointer<vtkFloatArray> cdata = convertFieldToVTK vtkSmartPointer<vtkFloatArray> cdata =
( vtk::Tools::convertFieldToVTK
fld.name(), (
fld fld.name(),
); fld
);
dataset->GetCellData()->AddArray(cdata); dataset->GetCellData()->AddArray(cdata);
} }
} }
...@@ -585,11 +589,12 @@ void Foam::vtkPVFoam::convertPointFields ...@@ -585,11 +589,12 @@ void Foam::vtkPVFoam::convertPointFields
const label patchId = patchIds[0]; const label patchId = patchIds[0];
vtkSmartPointer<vtkFloatArray> pdata = convertFieldToVTK vtkSmartPointer<vtkFloatArray> pdata =
( vtk::Tools::convertFieldToVTK
fieldName, (
pfld.boundaryField()[patchId].patchInternalField()() fieldName,
); pfld.boundaryField()[patchId].patchInternalField()()
);
dataset->GetPointData()->AddArray(pdata); dataset->GetPointData()->AddArray(pdata);
} }
...@@ -629,7 +634,7 @@ void Foam::vtkPVFoam::convertPointFields ...@@ -629,7 +634,7 @@ void Foam::vtkPVFoam::convertPointFields
); );
vtkSmartPointer<vtkFloatArray> pdata = vtkSmartPointer<vtkFloatArray> pdata =
convertFieldToVTK vtk::Tools::convertFieldToVTK
( (
fieldName, fieldName,
znfld znfld
...@@ -807,7 +812,7 @@ void Foam::vtkPVFoam::convertLagrangianFields ...@@ -807,7 +812,7 @@ void Foam::vtkPVFoam::convertLagrangianFields
IOField<Type> fld(ioobj); IOField<Type> fld(ioobj);
vtkSmartPointer<vtkFloatArray> data = vtkSmartPointer<vtkFloatArray> data =
convertFieldToVTK vtk::Tools::convertFieldToVTK
( (
ioobj.name(), ioobj.name(),
fld fld
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment