VTK  9.2.6
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 class vtkOverlappingAMR;
39 class vtkUniformGrid;
40 class vtkInformation;
42 
43 class VTKFILTERSAMR_EXPORT vtkAMRGaussianPulseSource : public vtkOverlappingAMRAlgorithm
44 {
45 public:
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
51 
54  vtkSetMacro(Dimension, int);
56 
58 
61  vtkSetMacro(NumberOfLevels, int);
63 
67  void SetRefinementRatio(int r)
68  {
69  this->RefinmentRatio = r;
70  this->Modified();
71  }
72 
74 
77  void SetRootSpacing(double h0)
78  {
79  this->RootSpacing[0] = this->RootSpacing[1] = this->RootSpacing[2] = h0;
80  this->Modified();
81  }
83 
85 
88  vtkSetVector3Macro(PulseOrigin, double);
89  vtkGetVector3Macro(PulseOrigin, double);
90  void SetXPulseOrigin(double f)
91  {
92  this->PulseOrigin[0] = f;
93  this->Modified();
94  }
95  void SetYPulseOrigin(double f)
96  {
97  this->PulseOrigin[1] = f;
98  this->Modified();
99  }
100  void SetZPulseOrigin(double f)
101  {
102  this->PulseOrigin[2] = f;
103  this->Modified();
104  }
106 
108 
111  vtkSetVector3Macro(PulseWidth, double);
112  vtkGetVector3Macro(PulseWidth, double);
113  void SetXPulseWidth(double f)
114  {
115  this->PulseWidth[0] = f;
116  this->Modified();
117  }
118  void SetYPulseWidth(double f)
119  {
120  this->PulseWidth[1] = f;
121  this->Modified();
122  }
123  void SetZPulseWidth(double f)
124  {
125  this->PulseWidth[2] = f;
126  this->Modified();
127  }
129 
131 
134  vtkSetMacro(PulseAmplitude, double);
135  vtkGetMacro(PulseAmplitude, double);
137 
138 protected:
140  ~vtkAMRGaussianPulseSource() override;
141 
146  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
147  vtkInformationVector* outputVector) override;
148 
150 
154  double ComputePulseAt(const double x, const double y, const double z)
155  {
156  double xyz[3];
157  xyz[0] = x;
158  xyz[1] = y;
159  xyz[2] = z;
160  return (this->ComputePulseAt(xyz));
161  }
162  double ComputePulseAt(double pt[3])
163  {
164  double pulse = 0.0;
165  double r = 0.0;
166  for (int i = 0; i < this->Dimension; ++i)
167  {
168  double d = pt[i] - this->PulseOrigin[i];
169  double d2 = d * d;
170  double L2 = this->PulseWidth[i] * this->PulseWidth[i];
171  r += d2 / L2;
172  }
173  pulse = this->PulseAmplitude * std::exp(-r);
174  return (pulse);
175  }
177 
182  void ComputeCellCenter(vtkUniformGrid* grid, vtkIdType cellIdx, double centroid[3]);
183 
187  void GeneratePulseField(vtkUniformGrid* grid);
188 
193  vtkUniformGrid* GetGrid(double origin[3], double h[3], int ndim[3]);
194 
198  vtkUniformGrid* RefinePatch(vtkUniformGrid* parent, int patchExtent[6]);
199 
201 
204  void Generate2DDataSet(vtkOverlappingAMR* amr);
205  void Generate3DDataSet(vtkOverlappingAMR* amr);
207 
208  double RootSpacing[3];
209  double PulseOrigin[3];
210  double PulseWidth[3];
215 
216 private:
218  void operator=(const vtkAMRGaussianPulseSource&) = delete;
219 };
220 
221 #endif /* vtkAMRGaussianPulseSource_h */
void SetZPulseOrigin(double f)
Set & Get macro for the pulse origin.
void SetYPulseWidth(double f)
Set & Get macro for the pulse width.
A base class for all algorithms that take as input vtkOverlappingAMR and produce vtkOverlappingAMR.
Store vtkAlgorithm input/output information.
A source that generates sample AMR data with gaussian pulse field.
void SetXPulseWidth(double f)
Set & Get macro for the pulse width.
int vtkIdType
Definition: vtkType.h:332
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...
a simple class to control print indentation
Definition: vtkIndent.h:39
void SetRootSpacing(double h0)
Set the root spacing.
virtual void Modified()
Update the modification time for this object.
double ComputePulseAt(double pt[3])
Computes the gaussian pulse at the given location based on the user supplied parameters for pulse wid...
image data with blanking
void SetYPulseOrigin(double f)
Set & Get macro for the pulse origin.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
hierarchical dataset of vtkUniformGrids
void SetZPulseWidth(double f)
Set & Get macro for the pulse width.
Store zero or more vtkInformation instances.
void SetRefinementRatio(int r)
Set the refinement ratio.
void SetXPulseOrigin(double f)
Set & Get macro for the pulse origin.
static vtkOverlappingAMRAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.