This commit is contained in:
Guilhem Lavaux 2022-11-16 16:48:31 +01:00
parent b538d4974d
commit 4633f6edc9

View File

@ -1,5 +1,5 @@
/*+ /*+
This is CosmoTool (./src/sphSmooth.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014) This is CosmoTool (./src/sphSmooth.hpp) -- Copyright (C) Guilhem Lavaux (2007-2022)
guilhem.lavaux@gmail.com guilhem.lavaux@gmail.com
@ -39,14 +39,11 @@ knowledge of the CeCILL license and that you accept its terms.
#include "config.hpp" #include "config.hpp"
#include "mykdtree.hpp" #include "mykdtree.hpp"
namespace CosmoTool namespace CosmoTool {
{
template <typename ValType, int Ndims = NUMDIMS> template <typename ValType, int Ndims = NUMDIMS>
class SPHSmooth class SPHSmooth {
{
public: public:
typedef struct typedef struct {
{
ComputePrecision weight; ComputePrecision weight;
ValType pValue; ValType pValue;
} FullType; } FullType;
@ -61,8 +58,7 @@ namespace CosmoTool
public: public:
typedef SPHCell *P_SPHCell; typedef SPHCell *P_SPHCell;
struct SPHState struct SPHState {
{
boost::shared_ptr<P_SPHCell[]> ngb; boost::shared_ptr<P_SPHCell[]> ngb;
boost::shared_ptr<CoordType[]> distances; boost::shared_ptr<CoordType[]> distances;
typename SPHTree::coords currentCenter; typename SPHTree::coords currentCenter;
@ -70,40 +66,34 @@ namespace CosmoTool
ComputePrecision smoothRadius; ComputePrecision smoothRadius;
}; };
SPHSmooth(SPHTree *tree, uint32_t Nsph); SPHSmooth(SPHTree *tree, uint32_t Nsph);
virtual ~SPHSmooth(); virtual ~SPHSmooth();
void fetchNeighbours(const typename SPHTree::coords& c, SPHState *state = 0); void
fetchNeighbours(const typename SPHTree::coords &c, SPHState *state = 0);
void fetchNeighbours(const typename SPHTree::coords &c, uint32_t newNsph); 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& getCurrentCenter() const const typename SPHTree::coords &c, ComputePrecision radius);
{ const typename SPHTree::coords &getCurrentCenter() const {
return internal.currentCenter; return internal.currentCenter;
} }
template <typename FuncT> template <typename FuncT>
ComputePrecision computeSmoothedValue(const typename SPHTree::coords& c, ComputePrecision computeSmoothedValue(
FuncT fun, SPHState *state = 0); const typename SPHTree::coords &c, FuncT fun, SPHState *state = 0);
template <typename FuncT> template <typename FuncT>
ComputePrecision computeInterpolatedValue(const typename SPHTree::coords& c, ComputePrecision computeInterpolatedValue(
FuncT fun, SPHState *state = 0); const typename SPHTree::coords &c, FuncT fun, SPHState *state = 0);
ComputePrecision getMaxDistance(const typename SPHTree::coords& c, ComputePrecision
SPHNode *node) const; getMaxDistance(const typename SPHTree::coords &c, SPHNode *node) const;
ComputePrecision getSmoothingLen() const ComputePrecision getSmoothingLen() const { return internal.smoothRadius; }
{
return internal.smoothRadius;
}
// TO USE WITH EXTREME CARE ! // TO USE WITH EXTREME CARE !
void setSmoothingLen(ComputePrecision len) void setSmoothingLen(ComputePrecision len) { internal.smoothRadius = len; }
{
internal.smoothRadius = len;
}
// END // END
template <typename FuncT> template <typename FuncT>
@ -135,20 +125,20 @@ namespace CosmoTool
SPHTree *tree; SPHTree *tree;
template <typename FuncT> template <typename FuncT>
ComputePrecision computeWValue(const typename SPHTree::coords & c, ComputePrecision computeWValue(
SPHCell& cell, const typename SPHTree::coords &c, SPHCell &cell, CoordType d,
CoordType d,
FuncT fun, SPHState *state); FuncT fun, SPHState *state);
template <typename FuncT> template <typename FuncT>
void runUnrollNode(SPHNode *node, void runUnrollNode(SPHNode *node, FuncT fun);
FuncT fun);
}; };
template <class ValType1, class ValType2, int Ndims> template <class ValType1, class ValType2, int Ndims>
bool operator<(const SPHSmooth<ValType1, Ndims>& s1, const SPHSmooth<ValType2, Ndims>& s2); bool operator<(
const SPHSmooth<ValType1, Ndims> &s1,
const SPHSmooth<ValType2, Ndims> &s2);
}; }; // namespace CosmoTool
#include "sphSmooth.tcc" #include "sphSmooth.tcc"