1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkSPHCubicKernel.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 =========================================================================*/ 15 /** 16 * @class vtkSPHCubicKernel 17 * @brief a cubic SPH interpolation kernel 18 * 19 * 20 * vtkSPHCubicKernel is an smooth particle hydrodynamics interpolation kernel as 21 * described by D.J. Price. This is a cubic formulation. 22 * 23 * @warning 24 * For more information see D.J. Price, Smoothed particle hydrodynamics and 25 * magnetohydrodynamics, J. Comput. Phys. 231:759-794, 2012. Especially 26 * equation 49. 27 * 28 * @par Acknowledgments: 29 * The following work has been generously supported by Altair Engineering 30 * and FluiDyna GmbH. Please contact Steve Cosgrove or Milos Stanic for 31 * more information. 32 * 33 * @sa 34 * vtkSPHKernel vtkSPHInterpolator 35 */ 36 37 #ifndef vtkSPHCubicKernel_h 38 #define vtkSPHCubicKernel_h 39 40 #include "vtkFiltersPointsModule.h" // For export macro 41 #include "vtkSPHKernel.h" 42 #include <algorithm> // For std::min() 43 44 class vtkIdList; 45 class vtkDoubleArray; 46 47 48 class VTKFILTERSPOINTS_EXPORT vtkSPHCubicKernel : public vtkSPHKernel 49 { 50 public: 51 //@{ 52 /** 53 * Standard methods for instantiation, obtaining type information, and printing. 54 */ 55 static vtkSPHCubicKernel *New(); 56 vtkTypeMacro(vtkSPHCubicKernel,vtkSPHKernel); 57 void PrintSelf(ostream& os, vtkIndent indent) override; 58 //@} 59 60 /** 61 * Produce the computational parameters for the kernel. Invoke this method 62 * after setting initial values like SpatialStep. 63 */ 64 void Initialize(vtkAbstractPointLocator *loc, vtkDataSet *ds, 65 vtkPointData *pd) override; 66 67 //@{ 68 /** 69 * Compute weighting factor given a normalized distance from a sample point. 70 */ ComputeFunctionWeight(const double d)71 double ComputeFunctionWeight(const double d) override 72 { 73 double tmp1 = 2.0 - std::min(d,2.0); 74 double tmp2 = 1.0 - std::min(d,1.0); 75 return (0.25*tmp1*tmp1*tmp1 - tmp2*tmp2*tmp2); 76 } 77 //@} 78 79 //@{ 80 /** 81 * Compute weighting factor for derivative quantities given a normalized 82 * distance from a sample point. 83 */ ComputeDerivWeight(const double d)84 double ComputeDerivWeight(const double d) override 85 { 86 double tmp1 = 2.0 - std::min(d,2.0); 87 double tmp2 = 1.0 - std::min(d,1.0); 88 return (-0.75*tmp1*tmp1 + 3.0*tmp2*tmp2); 89 } 90 //@} 91 92 protected: 93 vtkSPHCubicKernel(); 94 ~vtkSPHCubicKernel() override; 95 96 private: 97 vtkSPHCubicKernel(const vtkSPHCubicKernel&) = delete; 98 void operator=(const vtkSPHCubicKernel&) = delete; 99 }; 100 101 #endif 102