6template <
typename Particle>
10 return ::swift2::kernels::localParticleCanBeUpdatedInCellKernel(marker, localParticleIsContainedInCell, localParticle);
14template <
typename Particle>
22 marker.toString(), localParticle.toString(), activeParticle.toString()
24 return &localParticle != &activeParticle;
28template <
typename Particle>
31 Particle& localParticle,
32 const Particle& activeParticle
39 ), localParticle.toString(), activeParticle.toString()
45template <
typename Particle>
51 const int hydroDimensions = localParticle->getHydroDimensions();
52 const double alphaAV = localParticle->getAlphaAV();
53 double hydro_h_max = std::min(
54 localParticle->getSmlMax(),
55 localParticle->getSearchRadius() / kernel_gamma
59 const double rho_i = localParticle->getDensity();
60 const double m_i = localParticle->getMass();
61 const double h_i = localParticle->getSmoothingLength();
62 const double u_i = localParticle->getU();
64 const double h_inv = 1.0 / h_i;
67 const double fac_balsara_eps = 1.;
71 const double curl_v = std::sqrt(
72 localParticle->getRot_v() * localParticle->getRot_v()
79 const double abs_div_v =
tarch::la::abs(localParticle->getDiv_v());
82 const double P_i = eos::gas_pressure_from_internal_energy(rho_i, u_i);
83 assertion1(std::isfinite(P_i), localParticle->toString());
84 assertion1(P_i > 0., localParticle->toString());
87 const double soundspeed = legacy::eos::gas_soundspeed_from_pressure(
99 const double common_factor = h_i / hydroDimensions
100 / localParticle->getWcount();
104 if (h_i > 0.9999 * hydro_h_max) {
107 "hydro_prepare_force",
108 "h ~ h_max for particle x=" << localParticle->getX() <<
110 ", partID=" << localParticle->getPartid() <<
112 ", h = " << h_i <<
", h_max = " << hydro_h_max
115 const double grad_W_term = common_factor * localParticle->getWcount_dh();
116 if (grad_W_term < -0.9999) {
125 "hydro_prepare_force",
126 "grad_W_term very small for particle x="
127 << localParticle->getX() <<
129 ", partID=" << localParticle->getPartid() <<
131 ", h:" << h_i <<
", wcount:" << localParticle->getWcount()
132 <<
", wcount_dh:" << localParticle->getWcount_dh() <<
", grad_W_term:"
133 << grad_W_term <<
", common_factor:" << common_factor
136 grad_h_term = common_factor * localParticle->getRho_dh()
137 / (1. + grad_W_term);
144 = alphaAV * abs_div_v
145 / (abs_div_v + curl_v + 0.0001 * fac_balsara_eps *
soundspeed *
h_inv);
148 std::isfinite(balsara),
149 localParticle->toString(),
158 localParticle->setF(grad_h_term);
159 localParticle->setPressure(P_i);
161 localParticle->setBalsara(balsara);
164 localParticle->setForceNeighbourCount(0);
169template <
typename Particle>
174 localParticle->setA(0.0);
177 localParticle->setUDot(0.0);
178 localParticle->setHDot(0.0);
179 localParticle->setV_sig_AV(2.0 * localParticle->getSoundSpeed());
183template <
typename Particle>
188 const int hydroDimensions = localParticle->getHydroDimensions();
189 const double hydroDimensionsInv = 1. / (
double)hydroDimensions;
191 localParticle->setHDot(
192 localParticle->getHDot() * localParticle->getSmoothingLength()
196 std::isfinite(localParticle->getHDot()),
197 localParticle->toString(),
198 localParticle->getSmoothingLength()
224 if (localParticle->getDensityNeighbourCount() > localParticle->getForceNeighbourCount()) {
227 "Particle interacted with fewer particles in Force than in Density loop"
228 << localParticle->toString()
235template <
typename Particle>
237 Particle* localParticle,
238 const Particle* activeParticle
242 using namespace kernelHydro;
245 const int hydroDimensions = localParticle->getHydroDimensions();
246 const double alphaAV = localParticle->getAlphaAV();
247 const double betaAV = localParticle->getBetaAV();
250 const double fac_mu = 1.;
251 const double a2_Hubble = 0.;
256 dx = localParticle->getX() - activeParticle->getX();
259 const double r_inv =
r ? 1.0 /
r : 0.0;
262 const double h_i = localParticle->getSmoothingLength();
263 const double iactRi = kernel_gamma * h_i;
264 const double h_j = activeParticle->getSmoothingLength();
265 const double iactRj = kernel_gamma * h_j;
270 localParticle->setForceNeighbourCount(
271 localParticle->getForceNeighbourCount() + 1
276 const double m_i = localParticle->getMass();
277 const double m_j = activeParticle->getMass();
279 const double rho_i = localParticle->getDensity();
280 const double rho_j = activeParticle->getDensity();
282 const double P_i = localParticle->getPressure();
283 const double P_j = activeParticle->getPressure();
286 const double h_i_inv = 1. / h_i;
289 const double qi =
r * h_i_inv;
293 const double dwi_dr = dwi_dqi * h_i_inv_dp1;
296 const double h_j_inv = 1. / h_j;
299 const double qj =
r * h_j_inv;
303 const double dwj_dr = dwj_dqj * h_j_inv_dp1;
308 const double f_ij = 1.0 - localParticle->getF() / m_j;
309 const double f_ji = 1.0 - activeParticle->getF() / m_i;
312 const double P_over_rho2_i = P_i / (rho_i * rho_i) * f_ij;
313 const double P_over_rho2_j = P_j / (rho_j * rho_j) * f_ji;
317 (localParticle->getV() - activeParticle->getV()),
322 const double dvdr_Hubble =
dvdr + a2_Hubble *
r *
r;
325 const double omega_ij = std::min(dvdr_Hubble, 0.);
326 const double mu_ij = fac_mu *
r_inv * omega_ij;
329 const double v_sig = localParticle->getSoundSpeed()
330 + activeParticle->getSoundSpeed() - betaAV *
mu_ij;
333 const double balsara_i = localParticle->getBalsara();
334 const double balsara_j = activeParticle->getBalsara();
337 const double rho_ij = 0.5 * (rho_i + rho_j);
338 const double visc = -0.25 *
v_sig *
mu_ij * (balsara_i + balsara_j) / rho_ij;
341 const double visc_acc_term = 0.5 * visc * (dwi_dr * f_ij + dwj_dr * f_ji)
345 const double sph_acc_term = (P_over_rho2_i * dwi_dr + P_over_rho2_j * dwj_dr)
349 const double acc = sph_acc_term + visc_acc_term;
352 std::isfinite(visc_acc_term),
354 localParticle->toString(),
355 activeParticle->toString(),
364 std::isfinite(sph_acc_term),
366 localParticle->toString(),
367 activeParticle->toString()
372 localParticle->setA(localParticle->getA() - m_j * acc *
dx);
375 const double sph_du_term_i = P_over_rho2_i *
dvdr *
r_inv * dwi_dr;
378 const double visc_du_term = 0.5 * visc_acc_term * dvdr_Hubble;
381 const double du_dt_i = sph_du_term_i + visc_du_term;
384 localParticle->setUDot(localParticle->getUDot() + m_j * du_dt_i);
387 localParticle->setHDot(
388 localParticle->getHDot() - m_j *
dvdr *
r_inv / rho_j * dwi_dr * f_ij
392 localParticle->setV_sig_AV(std::max(localParticle->getV_sig_AV(),
v_sig));
395 not std::isnan(localParticle->getHDot()),
396 localParticle->toString(),
405 localParticle->toString(),
410 activeParticle->toString()
#define assertion2(expr, param0, param1)
#define assertion3(expr, param0, param1, param2)
#define assertion1(expr, param)
#define assertion9(expr, param0, param1, param2, param3, param4, param5, param6, param7, param8)
#define assertion6(expr, param0, param1, param2, param3, param4, param5)
#define logWarning(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
tarch::logging::Log _log("exahype2::fv")
File containing macro-riddled functions related to dimensions.
kernel_deval(ui, &wi, &wi_dx)
InlineMethod T pow_dimension_plus_one(T x)
returns x^{ndim+1}
void hydro_reset_acceleration(Particle *localParticle)
Reset acceleration fields of a particle.
void force_kernel(Particle *localParticle, const Particle *activeParticle)
The actual force kernel, which interacts a local particle and an active particle, and updates the loc...
bool forceKernelUpdateParticlePredicate(const peano4::datamanagement::CellMarker &marker, const bool &localParticleIsContainedInCell, const Particle &localParticle)
void hydro_end_force(Particle *localParticle)
Finishes the force calculation.
bool forceKernelEvaluatePairInteractionPredicate(const peano4::datamanagement::CellMarker &marker, const Particle &localParticle, const Particle &activeParticle)
void hydro_prepare_force(Particle *localParticle)
Prepare a particle for the force calculation.
void forceKernel(const peano4::datamanagement::CellMarker &marker, Particle &localParticle, const Particle &activeParticle)
Generic force kernel implementation.
bool localParticleCanBeUpdatedInCellKernelFromAnyOtherParticle(const peano4::datamanagement::CellMarker &marker, const Particle &localParticle, const Particle &activeParticle)
Can we do work on this particle during a cell kernel sweep stage?
Scalar dot(const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs)
Performs the dot (=inner) product of two vectors.
static InlineMethod bool smaller(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
Smaller operator for floating point values.
bool greater(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
constexpr double NUMERICAL_ZERO_DIFFERENCE
double abs(double value)
Returns the absolute value of a type by redirecting to std::abs.
int isEntryNan(const Vector< Size, Scalar > &vector)
Scalar norm2(const Vector< Size, Scalar > &vector)
Computes the 2-norm of the vector, i.e.
double relativeGrabOwnershipSpatialSortingTolerance(const ::peano4::datamanagement::VertexMarker &marker)
const struct part *restrict const struct part *restrict const float mu_ij
contains functions and definitions related to the equation of state of ideal gases.
Kernel functions for SPH.