forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkAMRGaussianPulseSource.h
198 lines (171 loc) · 5.12 KB
/
vtkAMRGaussianPulseSource.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*=========================================================================
Program: Visualization Toolkit
Module: vtkAMRGaussianPulseSource.h
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.
=========================================================================*/
/**
* @class vtkAMRGaussianPulseSource
*
*
* A source that generates sample AMR data with gaussian pulse field. The user
* can control the refinement ratio as well as the pulse attributes such as
* the pulse origin, length and amplitude.
*
* @sa
* vtkOverlappingAMR
*/
#ifndef vtkAMRGaussianPulseSource_h
#define vtkAMRGaussianPulseSource_h
#include "vtkFiltersAMRModule.h" // For export macro
#include "vtkOverlappingAMRAlgorithm.h"
#include <cmath> // For std::exp
class vtkOverlappingAMR;
class vtkUniformGrid;
class vtkInformation;
class vtkInformationVector;
class VTKFILTERSAMR_EXPORT vtkAMRGaussianPulseSource :
public vtkOverlappingAMRAlgorithm
{
public:
static vtkAMRGaussianPulseSource* New();
vtkTypeMacro(vtkAMRGaussianPulseSource, vtkOverlappingAMRAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
//@{
/**
* Sets the dimension of the AMR dataset to generate
*/
vtkSetMacro(Dimension,int);
//@}
//@{
/**
* Sets the number of levels to generate
*/
vtkSetMacro(NumberOfLevels,int);
//@}
/**
* Set the refinement ratio
*/
void SetRefinementRatio(int r)
{this->RefinmentRatio=r;this->Modified();}
//@{
/**
* Set the root spacing
*/
void SetRootSpacing(double h0)
{
this->RootSpacing[0]=this->RootSpacing[1]=this->RootSpacing[2]=h0;
this->Modified();
}
//@}
//@{
/**
* Set & Get macro for the pulse origin
*/
vtkSetVector3Macro(PulseOrigin,double);
vtkGetVector3Macro(PulseOrigin,double);
void SetXPulseOrigin(double f)
{this->PulseOrigin[0]=f;this->Modified();}
void SetYPulseOrigin(double f)
{this->PulseOrigin[1]=f;this->Modified();}
void SetZPulseOrigin(double f)
{this->PulseOrigin[2]=f;this->Modified();}
//@}
//@{
/**
* Set & Get macro for the pulse width
*/
vtkSetVector3Macro(PulseWidth,double);
vtkGetVector3Macro(PulseWidth,double);
void SetXPulseWidth(double f)
{this->PulseWidth[0]=f;this->Modified();}
void SetYPulseWidth(double f)
{this->PulseWidth[1]=f;this->Modified();}
void SetZPulseWidth(double f)
{this->PulseWidth[2]=f;this->Modified();}
//@}
//@{
/**
* Set & Get macro for the pulse amplitude
*/
vtkSetMacro(PulseAmplitude,double);
vtkGetMacro(PulseAmplitude,double);
//@}
protected:
vtkAMRGaussianPulseSource();
virtual ~vtkAMRGaussianPulseSource();
/**
* This is called by the superclass.
* This is the method you should override.
*/
virtual int RequestData(vtkInformation *request,
vtkInformationVector **inputVector,
vtkInformationVector *outputVector);
//@{
/**
* Computes the gaussian pulse at the given location based on the user
* supplied parameters for pulse width and origin.
*/
double ComputePulseAt(const double x, const double y, const double z)
{
double xyz[3]; xyz[0]=x; xyz[1]=y; xyz[2]=z;
return( this->ComputePulseAt(xyz) );
}
double ComputePulseAt( double pt[3] )
{
double pulse = 0.0;
double r = 0.0;
for( int i=0; i < this->Dimension; ++i )
{
double d = pt[i]-this->PulseOrigin[i];
double d2 = d*d;
double L2 = this->PulseWidth[i]*this->PulseWidth[i];
r += d2/L2;
}
pulse = this->PulseAmplitude*std::exp( -r );
return( pulse );
}
//@}
/**
* Given the cell index w.r.t. to a uniform grid, this method computes the
* cartesian coordinates of the centroid of the cell.
*/
void ComputeCellCenter(vtkUniformGrid *grid,
vtkIdType cellIdx,
double centroid[3] );
/**
* Generates a pulse field for the given uniform grid
*/
void GeneratePulseField(vtkUniformGrid *grid);
/**
* Constructs a uniform grid path with the given origin/spacing and node
* dimensions. The return grid serves as the root grid for the domain.
*/
vtkUniformGrid* GetGrid( double origin[3], double h[3], int ndim[3] );
/**
* Constructs a refined patch from the given parent grid.
*/
vtkUniformGrid* RefinePatch(vtkUniformGrid* parent, int patchExtent[6]);
//@{
/**
* Generate 2-D or 3-D DataSet
*/
void Generate2DDataSet(vtkOverlappingAMR* amr);
void Generate3DDataSet(vtkOverlappingAMR* amr);
//@}
double RootSpacing[3];
double PulseOrigin[3];
double PulseWidth[3];
double PulseAmplitude;
int RefinmentRatio;
int Dimension;
int NumberOfLevels;
private:
vtkAMRGaussianPulseSource(const vtkAMRGaussianPulseSource&) VTK_DELETE_FUNCTION;
void operator=(const vtkAMRGaussianPulseSource&) VTK_DELETE_FUNCTION;
};
#endif /* vtkAMRGaussianPulseSource_h */