Salome HOME
Create insitu library.
[modules/paravis.git] / src / Plugins / GhostCellsGenerator / vtkPVUnstructuredGridGhostCellsGenerator.cxx
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    vtkPVUnstructuredGridGhostCellsGenerator.cxx
5
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13
14 =========================================================================*/
15
16 #include "vtkPVUnstructuredGridGhostCellsGenerator.h"
17 #include "vtkPVConfig.h" // need ParaView defines before MPI stuff
18
19 #include "vtkInformation.h"
20 #include "vtkInformationVector.h"
21 #include "vtkMultiProcessController.h"
22 #include "vtkNew.h"
23 #include "vtkObjectFactory.h"
24 #include "vtkStreamingDemandDrivenPipeline.h"
25 #include "vtkUnstructuredGrid.h"
26
27 #ifdef PARAVIEW_USE_MPI
28 #  include "vtkPUnstructuredGridGhostCellsGenerator.h"
29 #endif
30
31 static const char* PVUGGCG_GLOBAL_POINT_IDS = "GlobalNodeIds";
32
33 //----------------------------------------------------------------------------
34
35 vtkStandardNewMacro(vtkPVUnstructuredGridGhostCellsGenerator)
36 vtkSetObjectImplementationMacro(
37   vtkPVUnstructuredGridGhostCellsGenerator, Controller, vtkMultiProcessController);
38
39 //----------------------------------------------------------------------------
40 vtkPVUnstructuredGridGhostCellsGenerator::vtkPVUnstructuredGridGhostCellsGenerator()
41 {
42   this->Controller = NULL;
43   this->SetController(vtkMultiProcessController::GetGlobalController());
44
45   this->GlobalPointIdsArrayName = NULL;
46   this->UseGlobalPointIds = true;
47   this->SetGlobalPointIdsArrayName(PVUGGCG_GLOBAL_POINT_IDS);
48 }
49
50 //----------------------------------------------------------------------------
51 vtkPVUnstructuredGridGhostCellsGenerator::~vtkPVUnstructuredGridGhostCellsGenerator()
52 {
53   this->SetController(NULL);
54   this->SetGlobalPointIdsArrayName(NULL);
55 }
56
57 //-----------------------------------------------------------------------------
58 void vtkPVUnstructuredGridGhostCellsGenerator::PrintSelf(ostream& os, vtkIndent indent)
59 {
60   Superclass::PrintSelf(os, indent);
61 }
62
63 //-----------------------------------------------------------------------------
64 int vtkPVUnstructuredGridGhostCellsGenerator::RequestData(
65   vtkInformation *vtkNotUsed(request),
66   vtkInformationVector **inputVector,
67   vtkInformationVector *outputVector)
68 {
69   // get the info objects
70   vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
71   vtkInformation *outInfo = outputVector->GetInformationObject(0);
72
73   // get the input and output. Input may just have the UnstructuredGridBase
74   // interface, but output should be an unstructured grid.
75   vtkUnstructuredGridBase *input = vtkUnstructuredGridBase::SafeDownCast(
76     inInfo->Get(vtkDataObject::DATA_OBJECT()));
77   vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
78     outInfo->Get(vtkDataObject::DATA_OBJECT()));
79 #ifdef PARAVIEW_USE_MPI
80   vtkNew<vtkPUnstructuredGridGhostCellsGenerator> ghostGenerator;
81   ghostGenerator->SetInputData(input);
82   ghostGenerator->SetController(this->Controller);
83   ghostGenerator->SetUseGlobalPointIds(this->UseGlobalPointIds);
84   ghostGenerator->SetGlobalPointIdsArrayName(this->GlobalPointIdsArrayName);
85   ghostGenerator->Update();
86   output->ShallowCopy(ghostGenerator->GetOutput());
87 #else
88   output->ShallowCopy(input);
89 #endif
90   return 1;
91 }