47 const Float youngModulus = mu * 9._f * A / (3._f * A + mu);
52 const Float cg = cgFactor *
sqrt((A + 4._f / 3._f * mu) / rho0);
56 for (
Size i = 0; i < size; ++i) {
61 for (
Size i = 0; i < size; ++i) {
76 const Float p_max = size * log(size);
77 const Float mult =
exp(p_max / size) - 1._f;
78 for (
Size i = 0; i < size; ++i) {
83 const Float p2 =
Float(size) * log(1._f + x * mult);
85 eps_min[i] = denom *
std::pow(p1, 1._f / m_weibull);
86 eps_max[i] = denom *
std::pow(
max(p1, p2), 1._f / m_weibull);
87 SPH_ASSERT(eps_min[i] > 0 && eps_min[i] <= eps_max[i], eps_min[i], eps_max[i]);
90 const Float mu = log(size);
95 eps_max[i] =
min(eps_max[i], n_flaws[i] * eps_min[i]);
96 SPH_ASSERT(n_flaws[i] >= eps_max[i] / eps_min[i]);
99 Size flawedCnt = 0, p = 1;
100 while (flawedCnt < size) {
104 if (n_flaws[i] == 0) {
114 for (
Size i = 0; i < size; ++i) {
115 if (n_flaws[i] == 1) {
119 const Float ratio = eps_max[i] / eps_min[i];
120 SPH_ASSERT(ratio >= 1._f, eps_min[i], eps_max[i]);
122 m_zero[i] = log(n_flaws[i]) / log(ratio);
123 SPH_ASSERT(m_zero[i] >= 0.95_f, m_zero[i], n_flaws[i], eps_min[i], eps_max[i]);
135 tie(eps_min, m_zero, growth) =
144 const Interval range = material->range(QuantityId::DAMAGE);
146 if (damage[i] >= range.upper()) {
155 Float sig1, sig2, sig3;
157 const Float sigMax =
max(sig1, sig2, sig3);
160 const Float young_red =
max((1._f -
pow<3>(damage[i])) * young, 1.e-20_f);
161 const Float strain = sigMax / young_red;
162 const Float ratio = strain / eps_min[i];
INLINE bool isReal(const AntisymmetricTensor &t)
#define SPH_ASSERT(x,...)
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Base class for all particle materials.
Logging routines of the run.
#define VERBOSE_LOG
Helper macro, creating.
constexpr INLINE T max(const T &f1, const T &f2)
NAMESPACE_SPH_BEGIN constexpr INLINE T min(const T &f1, const T &f2)
Minimum & Maximum value.
INLINE T sqrt(const T f)
Return a squared root of a value.
constexpr INLINE Float pow< 3 >(const Float v)
constexpr INLINE Float pow(const Float v)
Power for floats.
INLINE Float root< 3 >(const Float f)
#define NAMESPACE_SPH_END
@ M_ZERO
Coefficient M_0 of the stretched Weibull distribution.
@ EXPLICIT_GROWTH
Explicit growth of fractures.
@ DEVIATORIC_STRESS
Deviatoric stress tensor, always a traceless tensor.
@ PRESSURE
Pressure, affected by yielding and fragmentation model, always a scalar quantity.
@ N_FLAWS
Number of explicit flaws per particle.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ DENSITY
Density, always a scalar quantity.
@ MASS
Paricles masses, always a scalar quantity.
@ EPS_MIN
Activation strait rate.
Holder of quantity values and their temporal derivatives.
@ FIRST
Quantity with 1st derivative.
@ ZERO
Quantity without derivatives, or "zero order" of quantity.
Random number generators.
INLINE Size samplePoissonDistribution(TRng &rng, const Float lambda)
Generates a random integer from Poisson distribution.
INLINE Float sampleDistribution(TRng &rng, const Interval &range, const Float upperBound, const TFunc &func)
Generates a random number from a generic distribution, using rejection sampling.
Interface for executing tasks (potentially) asynchronously.
INLINE void parallelFor(IScheduler &scheduler, const Size from, const Size to, TFunctor &&functor)
Executes a functor concurrently from all available threads.
StaticArray< T0 &, sizeof...(TArgs)+1 > tie(T0 &t0, TArgs &... rest)
Creates a static array from a list of l-value references.
Container for storing particle quantities and materials.
INLINE StaticArray< Float, 3 > findEigenvalues(const SymmetricTensor &t)
Returns three eigenvalue of symmetric matrix.
Material settings and functions specific for one material.
INLINE TValue getParam(const BodySettingsId paramIdx) const
Returns a parameter associated with given particle.
INLINE IMaterial & setParam(const BodySettingsId paramIdx, TValue &&value)
void setRange(const QuantityId id, const Interval &range, const Float minimal)
Sets the timestepping parameters of given quantity.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Non-owning wrapper of a material and particles with this material.
INLINE IndexSequence sequence()
Returns iterable index sequence.
virtual void setFlaws(Storage &storage, IMaterial &material, const MaterialInitialContext &context) const override
Sets up all the necessary quantities in the storage given material settings.
virtual void integrate(IScheduler &scheduler, Storage &storage, const MaterialView material) override
Compute damage derivatives.
virtual void integrate(IScheduler &scheduler, Storage &storage, const MaterialView material) override
Compute damage derivatives.
virtual void setFlaws(Storage &storage, IMaterial &material, const MaterialInitialContext &context) const override
Sets up all the necessary quantities in the storage given material settings.
Container storing all quantities used within the simulations.
Size getMaterialCnt() const
Return the number of materials in the storage.
Quantity & insert(const QuantityId key, const OrderEnum order, const TValue &defaultValue)
Creates a quantity in the storage, given its key, value type and order.
StaticArray< Array< TValue > &, 3 > getAll(const QuantityId key)
Retrieves quantity buffers from the storage, given its key and value type.
Array< TValue > & getDt(const QuantityId key)
Retrieves a quantity derivative from the storage, given its key and value type.
Size getParticleCnt() const
Returns the number of particles.
auto getValues(const QuantityId first, const QuantityId second, const TArgs... others)
Retrieves an array of quantities from the key.
bool has(const QuantityId key) const
Checks if the storage contains quantity with given key.
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
Symmetric tensor of 2nd order.
static INLINE SymmetricTensor identity()
Returns an identity tensor.
virtual void setFlaws(Storage &storage, IMaterial &material, const MaterialInitialContext &context) const override
Sets up all the necessary quantities in the storage given material settings.
virtual void integrate(IScheduler &scheduler, Storage &storage, const MaterialView material) override
Compute damage derivatives.
Symmetric traceless 2nd order tensor.
Creating code components based on values from settings.
@ WEIBULL_EXPONENT
Exponent of the Weibull distribution of flaws.
@ DAMAGE_MIN
Estimate minimal value of damage used to determine timestepping error.
@ DAMAGE
Initial damage of the body.
@ SHEAR_MODULUS
Shear modulus mu (a.k.a Lame's second parameter) of the material.
@ YOUNG_MODULUS
Young modulus of the material.
@ BULK_MODULUS
Bulk modulus of the material.
@ DENSITY
Density at zero pressure.
@ WEIBULL_COEFFICIENT
Coefficient (multiplier) of the Weibull distribution of flaws.
@ RAYLEIGH_SOUND_SPEED
Speed of crack growth, in units of local sound speed.
@ DAMAGE_RANGE
Allowed range of damage.
@ WEIBULL_SAMPLE_DISTRIBUTIONS
Shared data used when creating all bodies in the simulation.
Float kernelRadius
Kernel radius in units of smoothing length.
AutoPtr< IRng > rng
Random number generator.