VTK  9.3.20240423
vtkAMRGaussianPulseSource.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
18#ifndef vtkAMRGaussianPulseSource_h
19#define vtkAMRGaussianPulseSource_h
20
21#include "vtkFiltersAMRModule.h" // For export macro
23
24#include <cmath> // For std::exp
25
26VTK_ABI_NAMESPACE_BEGIN
28class vtkUniformGrid;
29class vtkInformation;
31
32class VTKFILTERSAMR_EXPORT vtkAMRGaussianPulseSource : public vtkOverlappingAMRAlgorithm
33{
34public:
37 void PrintSelf(ostream& os, vtkIndent indent) override;
38
40
43 vtkSetMacro(Dimension, int);
45
47
50 vtkSetMacro(NumberOfLevels, int);
52
57 {
58 this->RefinmentRatio = r;
59 this->Modified();
60 }
61
63
66 void SetRootSpacing(double h0)
67 {
68 this->RootSpacing[0] = this->RootSpacing[1] = this->RootSpacing[2] = h0;
69 this->Modified();
70 }
72
74
77 vtkSetVector3Macro(PulseOrigin, double);
78 vtkGetVector3Macro(PulseOrigin, double);
79 void SetXPulseOrigin(double f)
80 {
81 this->PulseOrigin[0] = f;
82 this->Modified();
83 }
84 void SetYPulseOrigin(double f)
85 {
86 this->PulseOrigin[1] = f;
87 this->Modified();
88 }
89 void SetZPulseOrigin(double f)
90 {
91 this->PulseOrigin[2] = f;
92 this->Modified();
93 }
95
97
100 vtkSetVector3Macro(PulseWidth, double);
101 vtkGetVector3Macro(PulseWidth, double);
102 void SetXPulseWidth(double f)
103 {
104 this->PulseWidth[0] = f;
105 this->Modified();
106 }
107 void SetYPulseWidth(double f)
108 {
109 this->PulseWidth[1] = f;
110 this->Modified();
111 }
112 void SetZPulseWidth(double f)
113 {
114 this->PulseWidth[2] = f;
115 this->Modified();
116 }
118
120
123 vtkSetMacro(PulseAmplitude, double);
124 vtkGetMacro(PulseAmplitude, double);
126
127protected:
130
136 vtkInformationVector* outputVector) override;
137
139
143 double ComputePulseAt(const double x, const double y, const double z)
144 {
145 double xyz[3];
146 xyz[0] = x;
147 xyz[1] = y;
148 xyz[2] = z;
149 return (this->ComputePulseAt(xyz));
150 }
151 double ComputePulseAt(double pt[3])
152 {
153 double pulse = 0.0;
154 double r = 0.0;
155 for (int i = 0; i < this->Dimension; ++i)
156 {
157 double d = pt[i] - this->PulseOrigin[i];
158 double d2 = d * d;
159 double L2 = this->PulseWidth[i] * this->PulseWidth[i];
160 r += d2 / L2;
161 }
162 pulse = this->PulseAmplitude * std::exp(-r);
163 return (pulse);
164 }
166
171 void ComputeCellCenter(vtkUniformGrid* grid, vtkIdType cellIdx, double centroid[3]);
172
177
182 vtkUniformGrid* GetGrid(double origin[3], double h[3], int ndim[3]);
183
187 vtkUniformGrid* RefinePatch(vtkUniformGrid* parent, int patchExtent[6]);
188
190
196
197 double RootSpacing[3];
198 double PulseOrigin[3];
199 double PulseWidth[3];
204
205private:
207 void operator=(const vtkAMRGaussianPulseSource&) = delete;
208};
209
210VTK_ABI_NAMESPACE_END
211#endif /* vtkAMRGaussianPulseSource_h */
A source that generates sample AMR data with gaussian pulse field.
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...
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 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...
vtkUniformGrid * RefinePatch(vtkUniformGrid *parent, int patchExtent[6])
Constructs a refined patch from the given parent grid.
~vtkAMRGaussianPulseSource() override
void SetZPulseWidth(double f)
Set & Get macro for the pulse width.
void SetRootSpacing(double h0)
Set the root spacing.
static vtkAMRGaussianPulseSource * New()
void SetZPulseOrigin(double f)
Set & Get macro for the pulse origin.
void SetYPulseWidth(double f)
Set & Get macro for the pulse width.
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.
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:108
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:315