Merge branch 'master' of file:///home/guilhem/Dropbox/gitRoot/CosmoToolbox

This commit is contained in:
Guilhem Lavaux 2010-12-01 10:04:20 -05:00
commit 1d7ecf051c
2 changed files with 35 additions and 2 deletions

View File

@ -29,6 +29,7 @@ namespace CosmoTool
virtual ~SPHSmooth(); virtual ~SPHSmooth();
void fetchNeighbours(const typename SPHTree::coords& c); void fetchNeighbours(const typename SPHTree::coords& c);
void fetchNeighbours(const typename SPHTree::coords& c, uint32_t newNsph);
void fetchNeighboursOnVolume(const typename SPHTree::coords& c, ComputePrecision radius); void fetchNeighboursOnVolume(const typename SPHTree::coords& c, ComputePrecision radius);
const typename SPHTree::coords& getCurrentCenter() const const typename SPHTree::coords& getCurrentCenter() const
{ {

View File

@ -38,6 +38,38 @@ ComputePrecision SPHSmooth<ValType,Ndims>::computeWValue(const typename SPHTree:
return 0; return 0;
} }
template<typename ValType, int Ndims>
void
SPHSmooth<ValType,Ndims>::fetchNeighbours(const typename SPHTree::coords& c, uint32_t newNngb)
{
ComputePrecision d2, max_dist = 0;
uint32_t requested = newNngb;
if (requested > maxNgb)
{
delete[] ngb;
delete[] distances;
maxNgb = requested;
ngb = new SPHCell *[maxNgb];
distances = new CoordType[maxNgb];
}
memcpy(currentCenter, c, sizeof(c));
tree->getNearestNeighbours(c, requested, ngb, distances);
currentNgb = 0;
for (uint32_t i = 0; i < requested && ngb[i] != 0; i++,currentNgb++)
{
distances[i] = sqrt(distances[i]);
d2 = distances[i];
if (d2 > max_dist)
max_dist = d2;
}
smoothRadius = max_dist / 2;
}
template<typename ValType, int Ndims> template<typename ValType, int Ndims>
void void
SPHSmooth<ValType,Ndims>::fetchNeighbours(const typename SPHTree::coords& c) SPHSmooth<ValType,Ndims>::fetchNeighbours(const typename SPHTree::coords& c)
@ -46,10 +78,10 @@ SPHSmooth<ValType,Ndims>::fetchNeighbours(const typename SPHTree::coords& c)
uint32_t requested = Nsph; uint32_t requested = Nsph;
memcpy(currentCenter, c, sizeof(c)); memcpy(currentCenter, c, sizeof(c));
tree->getNearestNeighbours(c, maxNgb, ngb, distances); tree->getNearestNeighbours(c, requested, ngb, distances);
currentNgb = 0; currentNgb = 0;
for (uint32_t i = 0; i < maxNgb && ngb[i] != 0; i++,currentNgb++) for (uint32_t i = 0; i < requested && ngb[i] != 0; i++,currentNgb++)
{ {
distances[i] = sqrt(distances[i]); distances[i] = sqrt(distances[i]);
d2 = distances[i]; d2 = distances[i];