VTK  9.2.20230320
vtkAMRGaussianPulseSource.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAMRGaussianPulseSource.h
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  =========================================================================*/
30 #ifndef vtkAMRGaussianPulseSource_h
31 #define vtkAMRGaussianPulseSource_h
32 
33 #include "vtkFiltersAMRModule.h" // For export macro
35 
36 #include <cmath> // For std::exp
37 
38 VTK_ABI_NAMESPACE_BEGIN
39 class vtkOverlappingAMR;
40 class vtkUniformGrid;
41 class vtkInformation;
43 
44 class VTKFILTERSAMR_EXPORT vtkAMRGaussianPulseSource : public vtkOverlappingAMRAlgorithm
45 {
46 public:
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
52 
55  vtkSetMacro(Dimension, int);
57 
59 
62  vtkSetMacro(NumberOfLevels, int);
64 
68  void SetRefinementRatio(int r)
69  {
70  this->RefinmentRatio = r;
71  this->Modified();
72  }
73 
75 
78  void SetRootSpacing(double h0)
79  {
80  this->RootSpacing[0] = this->RootSpacing[1] = this->RootSpacing[2] = h0;
81  this->Modified();
82  }
84 
86 
89  vtkSetVector3Macro(PulseOrigin, double);
90  vtkGetVector3Macro(PulseOrigin, double);
91  void SetXPulseOrigin(double f)
92  {
93  this->PulseOrigin[0] = f;
94  this->Modified();
95  }
96  void SetYPulseOrigin(double f)
97  {
98  this->PulseOrigin[1] = f;
99  this->Modified();
100  }
101  void SetZPulseOrigin(double f)
102  {
103  this->PulseOrigin[2] = f;
104  this->Modified();
105  }
107 
109 
112  vtkSetVector3Macro(PulseWidth, double);
113  vtkGetVector3Macro(PulseWidth, double);
114  void SetXPulseWidth(double f)
115  {
116  this->PulseWidth[0] = f;
117  this->Modified();
118  }
119  void SetYPulseWidth(double f)
120  {
121  this->PulseWidth[1] = f;
122  this->Modified();
123  }
124  void SetZPulseWidth(double f)
125  {
126  this->PulseWidth[2] = f;
127  this->Modified();
128  }
130 
132 
135  vtkSetMacro(PulseAmplitude, double);
136  vtkGetMacro(PulseAmplitude, double);
138 
139 protected:
142 
147  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
148  vtkInformationVector* outputVector) override;
149 
151 
155  double ComputePulseAt(const double x, const double y, const double z)
156  {
157  double xyz[3];
158  xyz[0] = x;
159  xyz[1] = y;
160  xyz[2] = z;
161  return (this->ComputePulseAt(xyz));
162  }
163  double ComputePulseAt(double pt[3])
164  {
165  double pulse = 0.0;
166  double r = 0.0;
167  for (int i = 0; i < this->Dimension; ++i)
168  {
169  double d = pt[i] - this->PulseOrigin[i];
170  double d2 = d * d;
171  double L2 = this->PulseWidth[i] * this->PulseWidth[i];
172  r += d2 / L2;
173  }
174  pulse = this->PulseAmplitude * std::exp(-r);
175  return (pulse);
176  }
178 
183  void ComputeCellCenter(vtkUniformGrid* grid, vtkIdType cellIdx, double centroid[3]);
184 
189 
194  vtkUniformGrid* GetGrid(double origin[3], double h[3], int ndim[3]);
195 
199  vtkUniformGrid* RefinePatch(vtkUniformGrid* parent, int patchExtent[6]);
200 
202 
208 
209  double RootSpacing[3];
210  double PulseOrigin[3];
211  double PulseWidth[3];
216 
217 private:
219  void operator=(const vtkAMRGaussianPulseSource&) = delete;
220 };
221 
222 VTK_ABI_NAMESPACE_END
223 #endif /* vtkAMRGaussianPulseSource_h */
A source that generates sample AMR data with gaussian pulse field.
vtkUniformGrid * RefinePatch(vtkUniformGrid *parent, int patchExtent[6])
Constructs a refined patch from the given parent grid.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
double ComputePulseAt(double pt[3])
Computes the gaussian pulse at the given location based on the user supplied parameters for pulse wid...
void Generate3DDataSet(vtkOverlappingAMR *amr)
Generate 2-D or 3-D DataSet.
double ComputePulseAt(const double x, const double y, const double z)
Computes the gaussian pulse at the given location based on the user supplied parameters for pulse wid...
~vtkAMRGaussianPulseSource() override
void SetZPulseWidth(double f)
Set & Get macro for the pulse width.
void SetRootSpacing(double h0)
Set the root spacing.
void SetZPulseOrigin(double f)
Set & Get macro for the pulse origin.
void SetYPulseWidth(double f)
Set & Get macro for the pulse width.
static vtkAMRGaussianPulseSource * New()
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
void SetYPulseOrigin(double f)
Set & Get macro for the pulse origin.
void SetRefinementRatio(int r)
Set the refinement ratio.
void Generate2DDataSet(vtkOverlappingAMR *amr)
Generate 2-D or 3-D DataSet.
vtkUniformGrid * GetGrid(double origin[3], double h[3], int ndim[3])
Constructs a uniform grid path with the given origin/spacing and node dimensions.
void SetXPulseOrigin(double f)
Set & Get macro for the pulse origin.
void GeneratePulseField(vtkUniformGrid *grid)
Generates a pulse field for the given uniform grid.
void SetXPulseWidth(double f)
Set & Get macro for the pulse width.
void ComputeCellCenter(vtkUniformGrid *grid, vtkIdType cellIdx, double centroid[3])
Given the cell index w.r.t.
a simple class to control print indentation
Definition: vtkIndent.h:120
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
virtual void Modified()
Update the modification time for this object.
A base class for all algorithms that take as input vtkOverlappingAMR and produce vtkOverlappingAMR.
hierarchical dataset of vtkUniformGrids
Computes the portion of a dataset which is inside a selection.
image data with blanking
int vtkIdType
Definition: vtkType.h:327