Fixed SPH smoothing. Fixlet for dinterpolate
This commit is contained in:
parent
afd706c1dc
commit
b18f06b606
3 changed files with 23 additions and 12 deletions
|
@ -3,14 +3,13 @@
|
|||
namespace CosmoTool {
|
||||
|
||||
template<typename ValType, int Ndims>
|
||||
SPHSmooth<ValType,Ndims>::SPHSmooth(SPHTree *tree, uint32_t Nsph, uint32_t deltaN)
|
||||
SPHSmooth<ValType,Ndims>::SPHSmooth(SPHTree *tree, uint32_t Nsph)
|
||||
{
|
||||
this->Nsph = Nsph;
|
||||
this->deltaNsph = deltaN;
|
||||
this->tree = tree;
|
||||
this->currentNgb = 0;
|
||||
|
||||
maxNgb = Nsph;
|
||||
this->maxNgb = Nsph;
|
||||
ngb = new SPHCell *[maxNgb];
|
||||
distances = new CoordType[maxNgb];
|
||||
}
|
||||
|
@ -43,7 +42,6 @@ template<typename ValType, int Ndims>
|
|||
void
|
||||
SPHSmooth<ValType,Ndims>::fetchNeighbours(const typename SPHTree::coords& c)
|
||||
{
|
||||
typename SPHTree::coords radius;
|
||||
ComputePrecision d2, max_dist = 0;
|
||||
uint32_t requested = Nsph;
|
||||
|
||||
|
@ -53,6 +51,7 @@ SPHSmooth<ValType,Ndims>::fetchNeighbours(const typename SPHTree::coords& c)
|
|||
currentNgb = 0;
|
||||
for (uint32_t i = 0; i < maxNgb && ngb[i] != 0; i++,currentNgb++)
|
||||
{
|
||||
distances[i] = sqrt(distances[i]);
|
||||
d2 = distances[i];
|
||||
if (d2 > max_dist)
|
||||
max_dist = d2;
|
||||
|
@ -66,18 +65,17 @@ void
|
|||
SPHSmooth<ValType,Ndims>::fetchNeighboursOnVolume(const typename SPHTree::coords& c,
|
||||
ComputePrecision radius)
|
||||
{
|
||||
typename SPHTree::coords allRadii = {radius,radius,radius};
|
||||
uint32_t numPart;
|
||||
ComputePrecision d2, max_dist = 0;
|
||||
|
||||
memcpy(currentCenter, c, sizeof(c));
|
||||
|
||||
numPart = tree->getIntersection(c, ngb, distances,
|
||||
currentNgb = tree->getIntersection(c, radius, ngb, distances,
|
||||
maxNgb);
|
||||
|
||||
currentNgb = 0;
|
||||
for (uint32_t i = 0; i < maxNgb && ngb[i] != 0; i++,currentNgb++)
|
||||
for (uint32_t i = 0; i < currentNgb; i++)
|
||||
{
|
||||
distances[i] = sqrt(distances[i]);
|
||||
d2 = distances[i];
|
||||
if (d2 > max_dist)
|
||||
max_dist = d2;
|
||||
|
@ -119,8 +117,8 @@ ComputePrecision SPHSmooth<ValType,Ndims>::computeInterpolatedValue(const typena
|
|||
|
||||
for (uint32_t i = 0; i < currentNgb; i++)
|
||||
{
|
||||
outputValue += computeWValue(c, ngb[i], distances[i], fun);
|
||||
weight += computeWValue(c, ngb[i], distances[i], interpolateOne);
|
||||
outputValue += computeWValue(c, *ngb[i], distances[i], fun);
|
||||
weight += computeWValue(c, *ngb[i], distances[i], interpolateOne);
|
||||
}
|
||||
|
||||
return (outputValue == 0) ? 0 : (outputValue / weight);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue