Add and fix support for parallel SPH state
This commit is contained in:
parent
f03751907b
commit
b538d4974d
@ -108,6 +108,7 @@ namespace CosmoTool
|
||||
|
||||
template<typename FuncT>
|
||||
void runForEachNeighbour(FuncT fun, SPHState *state = 0);
|
||||
void addGridSite(const typename SPHTree::coords& c, SPHState *state);
|
||||
void addGridSite(const typename SPHTree::coords& c);
|
||||
|
||||
bool hasNeighbours() const;
|
||||
|
@ -86,7 +86,7 @@ void SPHSmooth<ValType,Ndims>::fetchNeighbours(const typename SPHTree::coords& c
|
||||
state->currentNgb = 0;
|
||||
for (uint32_t i = 0; i < requested && state->ngb[i] != 0; i++,state->currentNgb++)
|
||||
{
|
||||
d2 = internal.distances[i] = sqrt(internal.distances[i]);
|
||||
d2 = state->distances[i] = sqrt(state->distances[i]);
|
||||
if (d2 > max_dist)
|
||||
max_dist = d2;
|
||||
}
|
||||
@ -179,23 +179,27 @@ void SPHSmooth<ValType,Ndims>::runForEachNeighbour(FuncT fun, SPHState *state)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename ValType, int Ndims>
|
||||
void SPHSmooth<ValType,Ndims>::addGridSite(const typename SPHTree::coords& c, SPHState *state)
|
||||
{
|
||||
ComputePrecision outputValue = 0;
|
||||
ComputePrecision max_dist = 0;
|
||||
ComputePrecision r3 = cube(state->smoothRadius);
|
||||
|
||||
for (uint32_t i = 0; i < state->currentNgb; i++)
|
||||
{
|
||||
ComputePrecision d = state->distances[i];
|
||||
SPHCell& cell = *(state->ngb[i]);
|
||||
double kernel_value = getKernel(d/state->smoothRadius) / r3;
|
||||
#pragma omp atomic
|
||||
cell.val.weight += kernel_value;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename ValType, int Ndims>
|
||||
void SPHSmooth<ValType,Ndims>::addGridSite(const typename SPHTree::coords& c)
|
||||
{
|
||||
ComputePrecision outputValue = 0;
|
||||
ComputePrecision max_dist = 0;
|
||||
|
||||
ComputePrecision r3 = cube(internal.smoothRadius);
|
||||
|
||||
for (uint32_t i = 0; i < internal.currentNgb; i++)
|
||||
{
|
||||
ComputePrecision d = internal.distances[i];
|
||||
SPHCell& cell = *(internal.ngb[i]);
|
||||
double kernel_value = getKernel(d/internal.smoothRadius) / r3;
|
||||
#pragma omp atomic
|
||||
cell.val.weight += kernel_value;
|
||||
}
|
||||
addGridSite(c, &internal);
|
||||
}
|
||||
|
||||
template<typename ValType, int Ndims>
|
||||
|
Loading…
Reference in New Issue
Block a user