vtkAMRGhostExchange.h 5.04 KB
Newer Older
George Zagaris's avatar
George Zagaris committed
1
2
3
/*=========================================================================

 Program:   Visualization Toolkit
4
 Module:    vtkAMRGhostExchange.h
George Zagaris's avatar
George Zagaris committed
5
6
7
8
9
10
11
12
13
14

 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
 All rights reserved.
 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

 This software is distributed WITHOUT ANY WARRANTY; without even
 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.  See the above copyright notice for more information.

 =========================================================================*/
15
// .NAME vtkAMRGhostExchange -- Transfers data at the block boundaries
George Zagaris's avatar
George Zagaris committed
16
17
18
//
// .SECTION Description
// A concrete instance of vtkHierarchicalBoxDataSet algorithm that implements
19
20
21
22
23
24
// functionality for extruding ghost layers, computing the donor-receiver pairs
// at the inter-block boundaries and transfering of the solution.
//
// .SECTION Caveats
// In the present implementation the solution is transfered from either lower
// resolution blocks or same resolution blocks.
George Zagaris's avatar
George Zagaris committed
25

26
27
#ifndef vtkAMRGhostExchange_H_
#define vtkAMRGhostExchange_H_
George Zagaris's avatar
George Zagaris committed
28
29
30

#include "vtkHierarchicalBoxDataSetAlgorithm.h"

31
#include <vtkstd/map>
32
33
#include <string>

George Zagaris's avatar
George Zagaris committed
34
35
36
37
class vtkHierarchicalBoxDataSet;
class vtkAMRBox;
class vtkAMRInterBlockConnectivity;
class vtkMultiProcessController;
38
39
class vtkUniformGrid;
class vtkDataArray;
40
class vtkPolyData;
41
class vtkIntArray;
42
43
class vtkInformation;
class vtkInformationVector;
George Zagaris's avatar
George Zagaris committed
44

45
class VTK_AMR_EXPORT vtkAMRGhostExchange:
George Zagaris's avatar
George Zagaris committed
46
47
48
                      public vtkHierarchicalBoxDataSetAlgorithm
{
  public:
49
50
    static vtkAMRGhostExchange* New();
    vtkTypeMacro(vtkAMRGhostExchange,vtkHierarchicalBoxDataSetAlgorithm);
George Zagaris's avatar
George Zagaris committed
51
52
53
54
55
56
57
58
59
60
    void PrintSelf( std::ostream &oss, vtkIndent indent );

    // Inline setters & getters
    vtkSetNGetMacro(NumberOfGhostLayers,int);
    vtkSetNGetMacro(Controller,vtkMultiProcessController*);
    vtkSetNGetMacro(AMRDataSet,vtkHierarchicalBoxDataSet*);
    vtkSetNGetMacro(RemoteConnectivity,vtkAMRInterBlockConnectivity*);
    vtkSetNGetMacro(LocalConnectivity,vtkAMRInterBlockConnectivity*);
    vtkGetMacro(ExtrudedData,vtkHierarchicalBoxDataSet*);

61
62
63
64
65

  protected:
    vtkAMRGhostExchange();
    virtual ~vtkAMRGhostExchange();

George Zagaris's avatar
George Zagaris committed
66
67
    // Description:
    // Computes donor-receiver pairs and transfers the solution
68
    void Transfer( );
69
70

    // Description:
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
    // Writes the receivers. Mainly used for debugging purposes.
    void WriteReceivers();

    // Description:
    // Checks if the cell corresponding to cellIdx of the
    // given grid instance is a ghost cell or not.
    //
    // .SECTION Assumptions:
    // This method assumes that Ghost Cell information is attached to
    // the cell data of the given grid instance.
    bool IsGhostCell( vtkUniformGrid *ug, int cellIdx );

    // Description:
    // This method computes the center of the given cell.
    void ComputeCellCenter( vtkUniformGrid *ug, int cellIdx, double center[3] );

    // Description:
    // Extracts the receiver points from each grid on the extruded data-set.
    void GetReceivers();

91
92
93
94
95
96
97
98
99
100
101
    // Description:
    // Adds the receiver information arrays as point data.
    // Each receiver is associated with the following information:
    // <ul>
    //   <li> <b>DonorGridIdx</b>: the encoded donor grid index. </li>
    //   <li> <b>DonorCellIdx</b>: the cell index of the donor cell w.r.t. the
    //        donor grid. </li>
    //   <li> <b>DonorLevel</b>: the level from which the data is copied. </li>
    // </ul>
    void AddReceiverInformation( vtkPolyData *receivers );

102
103
104
    // Description:
    // Attaches point ownership information to the output AMR dataset.
    void AttachPointOwnershipInfo();
105
106
107
108
109
    void CheckOwnershipAtSameLevel(
        vtkIntArray *ownership, vtkUniformGrid *grid, int level, int dataIdx );
    void CheckOwnershipDownstream(
        vtkIntArray *ownership, vtkUniformGrid *grid,
        vtkHierarchicalBoxDataSet *amds,
110
        vtkIdType currentLevel );
111

112
113
    // Description:
    // Finds the donor cell for each receiver point
114
    void DonorSearch();
115
116
117
118
119
    void LocalDonorSearch();
    void FindDonors(
      const unsigned int receiverIdx,
      const int donorGridLevel,
      const int donorBlockIdx );
120
121

    // Description:
122
    // Transfers
123
    void DataTransfer();
124
    void LocalDataTransfer();
125

126
127
128
129
130
131
    // Standard pipeline routines
    virtual int RequestData(
        vtkInformation*,vtkInformationVector**,vtkInformationVector*);
    virtual int FillInputPortInformation(int port, vtkInformation *info);
    virtual int FillOutputPortInformation(int port, vtkInformation *info);

George Zagaris's avatar
George Zagaris committed
132
133
134
135
136
137
138
    int                          NumberOfGhostLayers;
    vtkHierarchicalBoxDataSet    *ExtrudedData;
    vtkMultiProcessController    *Controller;
    vtkHierarchicalBoxDataSet    *AMRDataSet;
    vtkAMRInterBlockConnectivity *RemoteConnectivity;
    vtkAMRInterBlockConnectivity *LocalConnectivity;

139
140
    vtkstd::map<unsigned int, vtkPolyData*> ReceiverList;

George Zagaris's avatar
George Zagaris committed
141
  private:
142
143
    vtkAMRGhostExchange(const vtkAMRGhostExchange&); // Not implemented
    vtkAMRGhostExchange& operator=(const vtkAMRGhostExchange&); // Not implemented
George Zagaris's avatar
George Zagaris committed
144
145
146

};

147
#endif /* vtkAMRGhostExchange_H_ */