    

 ## On this page

  

 

 # IRockySPHElement Struct Reference

 Last update: 16.07.2025 

`#include <<a class="el" href="rocky__sph__element__api_8hpp_source.xhtml">rocky_sph_element_api.hpp</a>>`

Inherited by [IRockySPHElementHost](structIRockySPHElementHost.xhtml).

## <a id="pub-methods" name="pub-methods"></a>Public Member Functions

ROCKY\_FUNCTIONS [IRockyParticle](structIRockyParticle.xhtml) [get\_linked\_dem\_particle](#a82b39eaf0e1f5b9f09367fcb994af3d9) ([IRockyDeviceModel](structIRockyDeviceModel.xhtml) &amp;model) const ROCKY\_FUNCTIONS void [add\_force](#a0d51cf017a85bd175db6d18538c9d2e0) (const float3 &amp;force) ROCKY\_FUNCTIONS void [add\_acceleration](#a2f90b3a2980c2fa73cd53e72ea277f76) (const float3 &amp;acceleration) ROCKY\_FUNCTIONS bool [is\_enabled](#af514a8db990dff91c80abef70c29d604) () const ROCKY\_FUNCTIONS void [set\_frozen](#a258ae430ddd628d1b3375680774fd748) (bool frozen) ROCKY\_FUNCTIONS bool [is\_frozen](#a8a513f4cacbb94a272332beb8c8a371c) () const ROCKY\_FUNCTIONS bool [is\_dem\_coupled](#a3cd85ecace2e2784572a2e01397237f3) () const ROCKY\_FUNCTIONS float [get\_density](#a630d5e1aaea6b7c2f8f51c30089e07cd) () const ROCKY\_FUNCTIONS float [get\_pressure](#a52f9c9ca275229c97e0fee6c2962e65f) () const ROCKY\_FUNCTIONS float [get\_temperature](#ae7191bebe8d701047d69b8bc9f590b16) () const ROCKY\_FUNCTIONS float [get\_release\_time](#a9be557e2ec8056dd05338a651f5da171) () const ROCKY\_FUNCTIONS float3 [get\_position](#a7bd5a61c05ac4a77a61d3a0fc09597c5) () const ROCKY\_FUNCTIONS float3 [get\_velocity](#ab57e961ebc05e415bacc7c2236749428) () const ROCKY\_FUNCTIONS float3 [get\_normal](#af2f5b34f666646f5d1f19207bac5cb2d) () const ROCKY\_FUNCTIONS float3 [get\_force](#ab81b9afbefc503f46027274878703a3c) () const ROCKY\_FUNCTIONS float3 [get\_acceleration](#a9bbac7594cfc7a8dd14fee220a59cc0d) () const ROCKY\_FUNCTIONS float [get\_kernel](#a0d1898e6d543bbe3af9cb951646491ee) (const float distance, const [IRockySPHElement](structIRockySPHElement.xhtml) &amp;near\_element) const ROCKY\_FUNCTIONS float [get\_kernel\_derivative](#a480a6f0abe070040e11affa55f24c43f) (const float distance, const [IRockySPHElement](structIRockySPHElement.xhtml) &amp;near\_element) const ROCKY\_FUNCTIONS float [get\_mass](#ac3520dd9ddfb74c066ba7aef4737a455) () const ROCKY\_FUNCTIONS float [get\_smoothing\_length](#a040d1e15607c23a673614e3506a2e971) () const ROCKY\_FUNCTIONS float [get\_size](#a38068aa228cc70686e89149e9aa4edb8) () const ROCKY\_FUNCTIONS [IRockySPHElementScalars](structIRockySPHElementScalars.xhtml) [get\_scalars](#a326bd60795936f9c4b77a9e000b1fa99) () ROCKY\_FUNCTIONS SymmetricTensor&lt; float &gt; [get\_strain\_rate\_tensor](#ac28f2f31caf98235f3281c9c9f417474) () ROCKY\_FUNCTIONS float [get\_molecular\_viscosity](#ac526f6d9758c69d4d7270317c327546a) () const ROCKY\_FUNCTIONS void [set\_molecular\_viscosity](#abc6efc9b72adc7c3b487e760a2c53534) (const float molecular\_viscosity) <a id="details" name="details"></a>## Detailed Description

`<a class="el" href="structIRockySPHElement.xhtml">IRockySPHElement</a>` is the code representation of an individual SPH element, which is the basic unit for representing the fluid flow in a SPH model. It has several methods to access the values of physical properties carried by the SPH elements, as well as  *SPH element scalars*, which are special variables that store custom property values per SPH element that are preserved between time iterations.



## Member Function Documentation

<a id="a2f90b3a2980c2fa73cd53e72ea277f76" name="a2f90b3a2980c2fa73cd53e72ea277f76"></a>## [◆ ](#a2f90b3a2980c2fa73cd53e72ea277f76)add\_acceleration()

 ROCKY\_FUNCTIONS void IRockySPHElement::add\_acceleration  ( const float3 &amp; *acceleration*) 

This method adds an acceleration component caused by an external force to the SPH element'sacceleration internally calculated by Rocky.Parameters accelerationThe added acceleration vector, expressed in Cartesian coordinates. 



<a id="a0d51cf017a85bd175db6d18538c9d2e0" name="a0d51cf017a85bd175db6d18538c9d2e0"></a>## [◆ ](#a0d51cf017a85bd175db6d18538c9d2e0)add\_force()

 ROCKY\_FUNCTIONS void IRockySPHElement::add\_force  ( const float3 &amp; *force*) 

This method adds a new force to the set of acting forces over the SPH element.Parameters forceThe added force vector, expressed in Cartesian coordinates. 



<a id="a9bbac7594cfc7a8dd14fee220a59cc0d" name="a9bbac7594cfc7a8dd14fee220a59cc0d"></a>## [◆ ](#a9bbac7594cfc7a8dd14fee220a59cc0d)get\_acceleration()

 ROCKY\_FUNCTIONS float3 IRockySPHElement::get\_acceleration  ( )  const

ReturnsThe current acceleration resultant vector of the SPH element, expressed in Cartesian coordinates. If this method is called before the stage of force calculation, a zero vector will be returned. 



<a id="a630d5e1aaea6b7c2f8f51c30089e07cd" name="a630d5e1aaea6b7c2f8f51c30089e07cd"></a>## [◆ ](#a630d5e1aaea6b7c2f8f51c30089e07cd)get\_density()

 ROCKY\_FUNCTIONS float IRockySPHElement::get\_density  ( )  const

ReturnsThe current value of density calculated for the SPH element. 



<a id="ab81b9afbefc503f46027274878703a3c" name="ab81b9afbefc503f46027274878703a3c"></a>## [◆ ](#ab81b9afbefc503f46027274878703a3c)get\_force()

 ROCKY\_FUNCTIONS float3 IRockySPHElement::get\_force  ( )  const

ReturnsThe resultant of the forces currently acting over the SPH element, expressed in Cartesian coordinates. If this method is called before the stage of force calculation, a zero vector will be returned. 



<a id="a0d1898e6d543bbe3af9cb951646491ee" name="a0d1898e6d543bbe3af9cb951646491ee"></a>## [◆ ](#a0d1898e6d543bbe3af9cb951646491ee)get\_kernel()

 ROCKY\_FUNCTIONS float IRockySPHElement::get\_kernel  ( const float *distance*,    const [IRockySPHElement](structIRockySPHElement.xhtml) &amp; *near\_element* ) const

ReturnsThe value of the kernel function evaluated at a point located at a given distance of the SPH element from which this method is called. The smoothing length considered is an average of the smoothing lengths of the pair formed by that element and a neighbor one.Parameters distanceThe distance from the SPH element to the point at which the kernel function will be evaluated.near\_elementThe near element used to calculate the average smoothing length. 



<a id="a480a6f0abe070040e11affa55f24c43f" name="a480a6f0abe070040e11affa55f24c43f"></a>## [◆ ](#a480a6f0abe070040e11affa55f24c43f)get\_kernel\_derivative()

 ROCKY\_FUNCTIONS float IRockySPHElement::get\_kernel\_derivative  ( const float *distance*,    const [IRockySPHElement](structIRockySPHElement.xhtml) &amp; *near\_element* ) const

ReturnsThe value of the derivative of the kernel function evaluated at a point located at a given distance of the SPH element from which this method is called. The smoothing length considered is an average of the smoothing lengths of the pair formed by that element and a neighbor one.Parameters distanceThe distance from the SPH element to the point at which the kernel function will be evaluated.near\_elementThe near element used to calculate the average smoothing length. 



<a id="a82b39eaf0e1f5b9f09367fcb994af3d9" name="a82b39eaf0e1f5b9f09367fcb994af3d9"></a>## [◆ ](#a82b39eaf0e1f5b9f09367fcb994af3d9)get\_linked\_dem\_particle()

 ROCKY\_FUNCTIONS [IRockyParticle](structIRockyParticle.xhtml) IRockySPHElement::get\_linked\_dem\_particle  ( [IRockyDeviceModel](structIRockyDeviceModel.xhtml) &amp; *model*)  const

ReturnsAn `<a class="el" href="structIRockyParticle.xhtml">IRockyParticle</a>` object representing the DEM particle linked to the SPH particle, if the latter is actually a DEM-coupled SPH element. 



<a id="ac3520dd9ddfb74c066ba7aef4737a455" name="ac3520dd9ddfb74c066ba7aef4737a455"></a>## [◆ ](#ac3520dd9ddfb74c066ba7aef4737a455)get\_mass()

 ROCKY\_FUNCTIONS float IRockySPHElement::get\_mass  ( )  const

ReturnsThe mass associated to the given SPH element. 



<a id="ac526f6d9758c69d4d7270317c327546a" name="ac526f6d9758c69d4d7270317c327546a"></a>## [◆ ](#ac526f6d9758c69d4d7270317c327546a)get\_molecular\_viscosity()

 ROCKY\_FUNCTIONS float IRockySPHElement::get\_molecular\_viscosity  ( )  const

ReturnsThe value of the molecular viscosity attributed to a given SPH element. 



<a id="af2f5b34f666646f5d1f19207bac5cb2d" name="af2f5b34f666646f5d1f19207bac5cb2d"></a>## [◆ ](#af2f5b34f666646f5d1f19207bac5cb2d)get\_normal()

 ROCKY\_FUNCTIONS float3 IRockySPHElement::get\_normal  ( )  const

ReturnsAn approximation of the normal vector to a free surface, if the SPH element is located near one, for use on the implementation of custom surface tension models. This vector is obtained by using the standard continuum approximation of interfaces, which is based on the gradient of the so called color function. In this approximation, an interface has a finite thickness over which the color function varies smoothly between zero and one. Because of this, a normal vector is calculated for every SPH element in the solution domain. However, only elements located near a free surface will have a normal vector with length significantly different from zero. It is worth noting that this vector is not normalized, therefore, its length will vary from one element to another. Moreover, these normal vectors are calculated internally only if a surface tension model is active in the simulation, therefore, a runtime error will be generated if this method is used otherwise. 



<a id="a7bd5a61c05ac4a77a61d3a0fc09597c5" name="a7bd5a61c05ac4a77a61d3a0fc09597c5"></a>## [◆ ](#a7bd5a61c05ac4a77a61d3a0fc09597c5)get\_position()

 ROCKY\_FUNCTIONS float3 IRockySPHElement::get\_position  ( )  const

ReturnsThe Cartesian coordinates of the point at which the SPH element is currently located. 



<a id="a52f9c9ca275229c97e0fee6c2962e65f" name="a52f9c9ca275229c97e0fee6c2962e65f"></a>## [◆ ](#a52f9c9ca275229c97e0fee6c2962e65f)get\_pressure()

 ROCKY\_FUNCTIONS float IRockySPHElement::get\_pressure  ( )  const

ReturnsThe current value of the pressure at the location coincident with the SPH element. 



<a id="a9be557e2ec8056dd05338a651f5da171" name="a9be557e2ec8056dd05338a651f5da171"></a>## [◆ ](#a9be557e2ec8056dd05338a651f5da171)get\_release\_time()

 ROCKY\_FUNCTIONS float IRockySPHElement::get\_release\_time  ( )  const

ReturnsThe time at which the SPH element entered into the simulation. 



<a id="a326bd60795936f9c4b77a9e000b1fa99" name="a326bd60795936f9c4b77a9e000b1fa99"></a>## [◆ ](#a326bd60795936f9c4b77a9e000b1fa99)get\_scalars()

 ROCKY\_FUNCTIONS [IRockySPHElementScalars](structIRockySPHElementScalars.xhtml) IRockySPHElement::get\_scalars  ( ) 

ReturnsAn `<a class="el" href="structIRockySPHElementScalars.xhtml">IRockySPHElementScalars</a>` object that gives access to all SPH element scalars variables defined in the project. 



<a id="a38068aa228cc70686e89149e9aa4edb8" name="a38068aa228cc70686e89149e9aa4edb8"></a>## [◆ ](#a38068aa228cc70686e89149e9aa4edb8)get\_size()

 ROCKY\_FUNCTIONS float IRockySPHElement::get\_size  ( )  const

ReturnsThe spacing between SPH elements when they enter into the simulation. This is a characteristic length considered in several expressions in the SPH model. 



<a id="a040d1e15607c23a673614e3506a2e971" name="a040d1e15607c23a673614e3506a2e971"></a>## [◆ ](#a040d1e15607c23a673614e3506a2e971)get\_smoothing\_length()

 ROCKY\_FUNCTIONS float IRockySPHElement::get\_smoothing\_length  ( )  const

ReturnsThe value of the smoothing length based on the size of the given SPH element. The radius of the support region of the kernel function is normally an integer multiple of the smoothing length. 



<a id="ac28f2f31caf98235f3281c9c9f417474" name="ac28f2f31caf98235f3281c9c9f417474"></a>## [◆ ](#ac28f2f31caf98235f3281c9c9f417474)get\_strain\_rate\_tensor()

 ROCKY\_FUNCTIONS SymmetricTensor&lt; float &gt; IRockySPHElement::get\_strain\_rate\_tensor  ( ) 

ReturnsA `SymmetricTensor<float>` object that represents the strain rate tensor of the element. To get strain rate, please enable the Gradient Velocity Scalars by calling `IRockySPHElementScalarsModel::enable_gradient_velocity()` at setup hook. 



<a id="ae7191bebe8d701047d69b8bc9f590b16" name="ae7191bebe8d701047d69b8bc9f590b16"></a>## [◆ ](#ae7191bebe8d701047d69b8bc9f590b16)get\_temperature()

 ROCKY\_FUNCTIONS float IRockySPHElement::get\_temperature  ( )  const

ReturnsThe current value of the temperature of the SPH element. 



<a id="ab57e961ebc05e415bacc7c2236749428" name="ab57e961ebc05e415bacc7c2236749428"></a>## [◆ ](#ab57e961ebc05e415bacc7c2236749428)get\_velocity()

 ROCKY\_FUNCTIONS float3 IRockySPHElement::get\_velocity  ( )  const

ReturnsThe velocity vector at which the SPH element is currently moving, expressed in Cartesian coordinates. 



<a id="a3cd85ecace2e2784572a2e01397237f3" name="a3cd85ecace2e2784572a2e01397237f3"></a>## [◆ ](#a3cd85ecace2e2784572a2e01397237f3)is\_dem\_coupled()

 ROCKY\_FUNCTIONS bool IRockySPHElement::is\_dem\_coupled  ( )  const

ReturnsTrue, if the SPH element is placed inside a DEM particle in order to model the interaction between the fluid flow and the DEM particles. False, otherwise. 



<a id="af514a8db990dff91c80abef70c29d604" name="af514a8db990dff91c80abef70c29d604"></a>## [◆ ](#af514a8db990dff91c80abef70c29d604)is\_enabled()

 ROCKY\_FUNCTIONS bool IRockySPHElement::is\_enabled  ( )  const

ReturnsTrue if the SPH element is enabled. False, otherwise. 



<a id="a8a513f4cacbb94a272332beb8c8a371c" name="a8a513f4cacbb94a272332beb8c8a371c"></a>## [◆ ](#a8a513f4cacbb94a272332beb8c8a371c)is\_frozen()

 ROCKY\_FUNCTIONS bool IRockySPHElement::is\_frozen  ( )  const

ReturnsTrue if the SPH element is frozen. False, otherwise. 



<a id="a258ae430ddd628d1b3375680774fd748" name="a258ae430ddd628d1b3375680774fd748"></a>## [◆ ](#a258ae430ddd628d1b3375680774fd748)set\_frozen()

 ROCKY\_FUNCTIONS void IRockySPHElement::set\_frozen  ( bool *frozen*) 

This method sets the frozen state of a SPH element. When the frozen state of an elementis set to `true`, the solution of the motion equations for it is skipped.Parameters frozenTrue if the particle should be frozen. False, otherwise. 



<a id="abc6efc9b72adc7c3b487e760a2c53534" name="abc6efc9b72adc7c3b487e760a2c53534"></a>## [◆ ](#abc6efc9b72adc7c3b487e760a2c53534)set\_molecular\_viscosity()

 ROCKY\_FUNCTIONS void IRockySPHElement::set\_molecular\_viscosity  ( const float *molecular\_viscosity*) 

This method sets the value of the molecular viscosity attributed to a given SPH element.