MCPcopy Create free account
hub / github.com/Kitware/VTK / AttachPulseToGrid

Function AttachPulseToGrid

Examples/AMR/Cxx/Generate3DAMRDataSetWithPulse.cxx:87–113  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

85
86//------------------------------------------------------------------------------
87void AttachPulseToGrid(vtkUniformGrid* grid)
88{
89 assert("pre: grid is nullptr!" && (grid != nullptr));
90
91 vtkNew<vtkDoubleArray> xyz;
92 xyz->SetName("GaussianPulse");
93 xyz->SetNumberOfComponents(1);
94 xyz->SetNumberOfTuples(grid->GetNumberOfCells());
95
96 for (int cellIdx = 0; cellIdx < grid->GetNumberOfCells(); ++cellIdx)
97 {
98 double center[3];
99 AMRCommon::ComputeCellCenter(grid, cellIdx, center);
100
101 double r = 0.0;
102 for (int i = 0; i < 3; ++i)
103 {
104 double dx = center[i] - Pulse.origin[i];
105 r += (dx * dx) / (Pulse.width[i] * Pulse.width[i]);
106 }
107 double f = Pulse.amplitude * std::exp(-r);
108
109 xyz->SetTuple1(cellIdx, f);
110 } // END for all cells
111
112 grid->GetCellData()->AddArray(xyz);
113}
114//------------------------------------------------------------------------------
115vtkOverlappingAMR* GetAMRDataSet()
116{

Callers 1

GetAMRDataSetFunction · 0.70

Calls 10

SetTuple1Method · 0.80
ComputeCellCenterFunction · 0.70
assertFunction · 0.50
expFunction · 0.50
SetNameMethod · 0.45
SetNumberOfComponentsMethod · 0.45
SetNumberOfTuplesMethod · 0.45
GetNumberOfCellsMethod · 0.45
AddArrayMethod · 0.45
GetCellDataMethod · 0.45

Tested by

no test coverage detected