    

 ## On this page

  

 

 # rocky\_sph\_element

 Last update: 16.07.2025 

<a id="l00001" name="l00001"></a> 1// (C) 2024 ANSYS, Inc. Unauthorized use, distribution, or duplication is prohibited.

<a id="l00002" name="l00002"></a> 2\#pragma once

<a id="l00003" name="l00003"></a> 3 

<a id="l00004" name="l00004"></a> 4// Includes =======================================================================================

<a id="l00005" name="l00005"></a> 5\#include &lt;rocky20/api/device/api\_backend.hpp&gt;

<a id="l00006" name="l00006"></a> 6\#include &lt;rocky20/api/rocky\_particle.hpp&gt;

<a id="l00007" name="l00007"></a> 7\#include &lt;rocky20/device/device\_model.hpp&gt;

<a id="l00008" name="l00008"></a> 8\#include &lt;rocky20/sph/sph\_model.h&gt;

<a id="l00009" name="l00009"></a> 9 

<a id="l00010" name="l00010"></a> 10// ================================================================================================

<a id="l00011" name="l00011"></a> 11// RockySPHElement

<a id="l00012" name="l00012"></a> 12// ================================================================================================

<a id="l00013" name="l00013"></a> 13 

<a id="l00014" name="l00014"></a> 14struct RockySPHElement

<a id="l00015" name="l00015"></a> 15{

<a id="l00016" name="l00016"></a> 16 inline ROCKY_FUNCTIONS bool is_dem_coupled() const

<a id="l00017" name="l00017"></a> 17 {

<a id="l00018" name="l00018"></a> 18 return this-&gt;get_linked_dem_index() &gt;= 0;

<a id="l00019" name="l00019"></a> 19 }

<a id="l00020" name="l00020"></a> 20 

<a id="l00021" name="l00021"></a> 21 inline ROCKY_FUNCTIONS int get_linked_dem_index() const

<a id="l00022" name="l00022"></a> 22 {

<a id="l00023" name="l00023"></a> 23 if (this-&gt;get_scalars()-&gt;is_dem_index_enabled())

<a id="l00024" name="l00024"></a> 24 return this-&gt;get_scalars()-&gt;get_dem_index(this-&gt;element_index);

<a id="l00025" name="l00025"></a> 25 return -1;

<a id="l00026" name="l00026"></a> 26 }

<a id="l00027" name="l00027"></a> 27 

<a id="l00028" name="l00028"></a> 28 inline ROCKY_FUNCTIONS void set_linked_dem_index(const int index)

<a id="l00029" name="l00029"></a> 29 {

<a id="l00030" name="l00030"></a> 30 this-&gt;get_scalars()-&gt;get_dem_index(this-&gt;element_index) = index;

<a id="l00031" name="l00031"></a> 31 }

<a id="l00032" name="l00032"></a> 32 

<a id="l00033" name="l00033"></a> 33 inline ROCKY_FUNCTIONS RockyParticle get_linked_dem_particle(SDeviceModel* model) const

<a id="l00034" name="l00034"></a> 34 {

<a id="l00035" name="l00035"></a> 35 return { model, this-&gt;get_linked_dem_index() };

<a id="l00036" name="l00036"></a> 36 }

<a id="l00037" name="l00037"></a> 37 

<a id="l00038" name="l00038"></a> 38 inline RockyParticle get_linked_dem_particle(cuda_host&amp; model) const

<a id="l00039" name="l00039"></a> 39 {

<a id="l00040" name="l00040"></a> 40 return { model, this-&gt;get_linked_dem_index() };

<a id="l00041" name="l00041"></a> 41 }

<a id="l00042" name="l00042"></a> 42 

<a id="l00043" name="l00043"></a> 43 inline ROCKY_FUNCTIONS int get_inlet_index() const

<a id="l00044" name="l00044"></a> 44 {

<a id="l00045" name="l00045"></a> 45 if (this-&gt;get_scalars()-&gt;is_inlet_index_enabled())

<a id="l00046" name="l00046"></a> 46 return this-&gt;get_scalars()-&gt;get_inlet_index(this-&gt;element_index);

<a id="l00047" name="l00047"></a> 47 return 0;

<a id="l00048" name="l00048"></a> 48 }

<a id="l00049" name="l00049"></a> 49 

<a id="l00050" name="l00050"></a> 50 inline ROCKY_FUNCTIONS void set_inlet_index(const int index)

<a id="l00051" name="l00051"></a> 51 {

<a id="l00052" name="l00052"></a> 52 this-&gt;get_scalars()-&gt;get_inlet_index(this-&gt;element_index) = short(index);

<a id="l00053" name="l00053"></a> 53 }

<a id="l00054" name="l00054"></a> 54 

<a id="l00055" name="l00055"></a> 55 inline ROCKY_FUNCTIONS float get_density() const

<a id="l00056" name="l00056"></a> 56 {

<a id="l00057" name="l00057"></a> 57 return this-&gt;get_scalars()-&gt;get_density(this-&gt;element_index);

<a id="l00058" name="l00058"></a> 58 }

<a id="l00059" name="l00059"></a> 59 

<a id="l00060" name="l00060"></a> 60 inline ROCKY_FUNCTIONS void set_density(const float density)

<a id="l00061" name="l00061"></a> 61 {

<a id="l00062" name="l00062"></a> 62 this-&gt;get_scalars()-&gt;get_density(this-&gt;element_index) = density;

<a id="l00063" name="l00063"></a> 63 }

<a id="l00064" name="l00064"></a> 64 

<a id="l00065" name="l00065"></a> 65 inline ROCKY_FUNCTIONS float get_pressure() const

<a id="l00066" name="l00066"></a> 66 {

<a id="l00067" name="l00067"></a> 67 const cuda_general_sph&amp; gen = *this-&gt;sph_model-&gt;gen_sph;

<a id="l00068" name="l00068"></a> 68 if (gen.is_solver_incompressible())

<a id="l00069" name="l00069"></a> 69 return this-&gt;get_scalars()-&gt;get_pressure(this-&gt;element_index);

<a id="l00070" name="l00070"></a> 70 else

<a id="l00071" name="l00071"></a> 71 return gen.get_pressure(this-&gt;get_density());

<a id="l00072" name="l00072"></a> 72 }

<a id="l00073" name="l00073"></a> 73 

<a id="l00077" name="l00077"></a> 77 inline ROCKY_FUNCTIONS void set_pressure(const float pressure)

<a id="l00078" name="l00078"></a> 78 {

<a id="l00079" name="l00079"></a> 79 this-&gt;get_scalars()-&gt;get_pressure(this-&gt;element_index) = pressure;

<a id="l00080" name="l00080"></a> 80 }

<a id="l00081" name="l00081"></a> 81 

<a id="l00082" name="l00082"></a> 82 inline ROCKY_FUNCTIONS float get_release_time() const

<a id="l00083" name="l00083"></a> 83 {

<a id="l00084" name="l00084"></a> 84 return this-&gt;get_scalars()-&gt;get_release_time(this-&gt;element_index);

<a id="l00085" name="l00085"></a> 85 }

<a id="l00086" name="l00086"></a> 86 

<a id="l00087" name="l00087"></a> 87 inline ROCKY_FUNCTIONS void set_release_time(float release_time)

<a id="l00088" name="l00088"></a> 88 {

<a id="l00089" name="l00089"></a> 89 this-&gt;get_scalars()-&gt;get_release_time(this-&gt;element_index) = release_time;

<a id="l00090" name="l00090"></a> 90 }

<a id="l00091" name="l00091"></a> 91 

<a id="l00092" name="l00092"></a> 92 inline ROCKY_FUNCTIONS float3 get_adjusted_coordinates(const double current_time) const

<a id="l00093" name="l00093"></a> 93 {

<a id="l00094" name="l00094"></a> 94 real_sph3 crd = this-&gt;get_coordinates();

<a id="l00095" name="l00095"></a> 95 if (!this-&gt;is_released())

<a id="l00096" name="l00096"></a> 96 crd = crd + this-&gt;get_velocity() * (float(current_time) - this-&gt;get_release_time());

<a id="l00097" name="l00097"></a> 97 return crd;

<a id="l00098" name="l00098"></a> 98 }

<a id="l00099" name="l00099"></a> 99 

<a id="l00100" name="l00100"></a> 100 inline ROCKY_FUNCTIONS const float3&amp; get_coordinates() const

<a id="l00101" name="l00101"></a> 101 {

<a id="l00102" name="l00102"></a> 102 return this-&gt;get_scalars()-&gt;get_coordinates(this-&gt;element_index);

<a id="l00103" name="l00103"></a> 103 }

<a id="l00104" name="l00104"></a> 104 

<a id="l00105" name="l00105"></a> 105 inline ROCKY_FUNCTIONS void set_coordinates(const float3&amp; coordinates)

<a id="l00106" name="l00106"></a> 106 {

<a id="l00107" name="l00107"></a> 107 this-&gt;get_scalars()-&gt;get_coordinates(this-&gt;element_index) = coordinates;

<a id="l00108" name="l00108"></a> 108 }

<a id="l00109" name="l00109"></a> 109 

<a id="l00110" name="l00110"></a> 110 inline ROCKY_FUNCTIONS const float3&amp; get_velocity() const

<a id="l00111" name="l00111"></a> 111 {

<a id="l00112" name="l00112"></a> 112 return this-&gt;get_scalars()-&gt;get_velocity(this-&gt;element_index);

<a id="l00113" name="l00113"></a> 113 }

<a id="l00114" name="l00114"></a> 114 

<a id="l00115" name="l00115"></a> 115 inline ROCKY_FUNCTIONS void set_velocity(const float3&amp; velocity)

<a id="l00116" name="l00116"></a> 116 {

<a id="l00117" name="l00117"></a> 117 this-&gt;get_scalars()-&gt;get_velocity(this-&gt;element_index) = velocity;

<a id="l00118" name="l00118"></a> 118 }

<a id="l00119" name="l00119"></a> 119 

<a id="l00133" name="l00133"></a> 133 inline ROCKY_FUNCTIONS const float3&amp; get_normal() const

<a id="l00134" name="l00134"></a> 134 {

<a id="l00135" name="l00135"></a> 135 return this-&gt;sph_model-&gt;nrm_sph[this-&gt;element_index];

<a id="l00136" name="l00136"></a> 136 }

<a id="l00137" name="l00137"></a> 137 

<a id="l00138" name="l00138"></a> 138 inline ROCKY_FUNCTIONS void set_normal(const float3&amp; normal)

<a id="l00139" name="l00139"></a> 139 {

<a id="l00140" name="l00140"></a> 140 this-&gt;sph_model-&gt;nrm_sph[this-&gt;element_index] = normal;

<a id="l00141" name="l00141"></a> 141 }

<a id="l00142" name="l00142"></a> 142 

<a id="l00143" name="l00143"></a> 143 inline ROCKY_FUNCTIONS void add_normal(const float3&amp; normal)

<a id="l00144" name="l00144"></a> 144 {

<a id="l00145" name="l00145"></a> 145 float3&amp; prt_normal = this-&gt;sph_model-&gt;nrm_sph[this-&gt;element_index];

<a id="l00146" name="l00146"></a> 146 backend::atomic_add(&amp;prt_normal, normal);

<a id="l00147" name="l00147"></a> 147 }

<a id="l00148" name="l00148"></a> 148 

<a id="l00149" name="l00149"></a> 149 inline ROCKY_FUNCTIONS float get_divergence() const

<a id="l00150" name="l00150"></a> 150 {

<a id="l00151" name="l00151"></a> 151 return this-&gt;sph_model-&gt;div_sph[this-&gt;element_index];

<a id="l00152" name="l00152"></a> 152 }

<a id="l00153" name="l00153"></a> 153 

<a id="l00154" name="l00154"></a> 154 inline ROCKY_FUNCTIONS void set_divergence(const float divergence)

<a id="l00155" name="l00155"></a> 155 {

<a id="l00156" name="l00156"></a> 156 this-&gt;sph_model-&gt;div_sph[this-&gt;element_index] = divergence;

<a id="l00157" name="l00157"></a> 157 }

<a id="l00158" name="l00158"></a> 158 

<a id="l00159" name="l00159"></a> 159 inline ROCKY_FUNCTIONS void add_divergence(const float divergence)

<a id="l00160" name="l00160"></a> 160 {

<a id="l00161" name="l00161"></a> 161 float&amp; prt_divergence = this-&gt;sph_model-&gt;div_sph[this-&gt;element_index];

<a id="l00162" name="l00162"></a> 162 backend::atomic_add(&amp;prt_divergence, divergence);

<a id="l00163" name="l00163"></a> 163 }

<a id="l00164" name="l00164"></a> 164 

<a id="l00165" name="l00165"></a> 165 inline ROCKY_FUNCTIONS const float3&amp; get_boundary_normal() const

<a id="l00166" name="l00166"></a> 166 {

<a id="l00167" name="l00167"></a> 167 return this-&gt;sph_model-&gt;nrb_sph[this-&gt;element_index];

<a id="l00168" name="l00168"></a> 168 }

<a id="l00169" name="l00169"></a> 169 

<a id="l00170" name="l00170"></a> 170 inline ROCKY_FUNCTIONS void set_boundary_normal(const float3&amp; boundary_normal)

<a id="l00171" name="l00171"></a> 171 {

<a id="l00172" name="l00172"></a> 172 this-&gt;sph_model-&gt;nrb_sph[this-&gt;element_index] = boundary_normal;

<a id="l00173" name="l00173"></a> 173 }

<a id="l00174" name="l00174"></a> 174 

<a id="l00175" name="l00175"></a> 175 inline ROCKY_FUNCTIONS void add_boundary_normal(const float3&amp; boundary_normal)

<a id="l00176" name="l00176"></a> 176 {

<a id="l00177" name="l00177"></a> 177 float3&amp; prt_boundary_normal = this-&gt;sph_model-&gt;nrb_sph[this-&gt;element_index];

<a id="l00178" name="l00178"></a> 178 backend::atomic_add(&amp;prt_boundary_normal, boundary_normal);

<a id="l00179" name="l00179"></a> 179 }

<a id="l00180" name="l00180"></a> 180 

<a id="l00181" name="l00181"></a> 181 inline ROCKY_FUNCTIONS float get_boundary_proximity() const

<a id="l00182" name="l00182"></a> 182 {

<a id="l00183" name="l00183"></a> 183 return this-&gt;sph_model-&gt;fbd_sph[this-&gt;element_index];

<a id="l00184" name="l00184"></a> 184 }

<a id="l00185" name="l00185"></a> 185 

<a id="l00186" name="l00186"></a> 186 inline ROCKY_FUNCTIONS void set_boundary_proximity(const float boundary_proximity)

<a id="l00187" name="l00187"></a> 187 {

<a id="l00188" name="l00188"></a> 188 this-&gt;sph_model-&gt;fbd_sph[this-&gt;element_index] = boundary_proximity;

<a id="l00189" name="l00189"></a> 189 }

<a id="l00190" name="l00190"></a> 190 

<a id="l00191" name="l00191"></a> 191 inline ROCKY_FUNCTIONS void add_boundary_proximity(const float boundary_proximity)

<a id="l00192" name="l00192"></a> 192 {

<a id="l00193" name="l00193"></a> 193 float&amp; prt_boundary_proximity = this-&gt;sph_model-&gt;fbd_sph[this-&gt;element_index];

<a id="l00194" name="l00194"></a> 194 backend::atomic_add(&amp;prt_boundary_proximity, boundary_proximity);

<a id="l00195" name="l00195"></a> 195 }

<a id="l00196" name="l00196"></a> 196 

<a id="l00197" name="l00197"></a> 197 inline ROCKY_FUNCTIONS float get_kernel_density() const

<a id="l00198" name="l00198"></a> 198 {

<a id="l00199" name="l00199"></a> 199 return this-&gt;sph_model-&gt;kernel_density[this-&gt;element_index];

<a id="l00200" name="l00200"></a> 200 }

<a id="l00201" name="l00201"></a> 201 

<a id="l00202" name="l00202"></a> 202 inline ROCKY_FUNCTIONS void set_kernel_density(const float kernel_density)

<a id="l00203" name="l00203"></a> 203 {

<a id="l00204" name="l00204"></a> 204 this-&gt;sph_model-&gt;kernel_density[this-&gt;element_index] = kernel_density;

<a id="l00205" name="l00205"></a> 205 }

<a id="l00206" name="l00206"></a> 206 

<a id="l00207" name="l00207"></a> 207 inline ROCKY_FUNCTIONS void add_kernel_density(const float kernel_density)

<a id="l00208" name="l00208"></a> 208 {

<a id="l00209" name="l00209"></a> 209 float&amp; prt_kernel_density = this-&gt;sph_model-&gt;kernel_density[this-&gt;element_index];

<a id="l00210" name="l00210"></a> 210 backend::atomic_add(&amp;prt_kernel_density, kernel_density);

<a id="l00211" name="l00211"></a> 211 }

<a id="l00212" name="l00212"></a> 212 

<a id="l00213" name="l00213"></a> 213 inline ROCKY_FUNCTIONS float get_predicted_density() const

<a id="l00214" name="l00214"></a> 214 {

<a id="l00215" name="l00215"></a> 215 return this-&gt;sph_model-&gt;predicted_density[this-&gt;element_index];

<a id="l00216" name="l00216"></a> 216 }

<a id="l00217" name="l00217"></a> 217 

<a id="l00218" name="l00218"></a> 218 inline ROCKY_FUNCTIONS void set_predicted_density(const float predicted_density)

<a id="l00219" name="l00219"></a> 219 {

<a id="l00220" name="l00220"></a> 220 this-&gt;sph_model-&gt;predicted_density[this-&gt;element_index] = predicted_density;

<a id="l00221" name="l00221"></a> 221 }

<a id="l00222" name="l00222"></a> 222 

<a id="l00223" name="l00223"></a> 223 inline ROCKY_FUNCTIONS void add_predicted_density(const float predicted_density)

<a id="l00224" name="l00224"></a> 224 {

<a id="l00225" name="l00225"></a> 225 float&amp; prt_predicted_density = this-&gt;sph_model-&gt;predicted_density[this-&gt;element_index];

<a id="l00226" name="l00226"></a> 226 backend::atomic_add(&amp;prt_predicted_density, predicted_density);

<a id="l00227" name="l00227"></a> 227 }

<a id="l00228" name="l00228"></a> 228 

<a id="l00229" name="l00229"></a> 229 inline ROCKY_FUNCTIONS float get_coefficients_a() const

<a id="l00230" name="l00230"></a> 230 {

<a id="l00231" name="l00231"></a> 231 return this-&gt;sph_model-&gt;coefficients_a[this-&gt;element_index];

<a id="l00232" name="l00232"></a> 232 }

<a id="l00233" name="l00233"></a> 233 

<a id="l00234" name="l00234"></a> 234 inline ROCKY_FUNCTIONS void set_coefficients_a(const float coefficients_a)

<a id="l00235" name="l00235"></a> 235 {

<a id="l00236" name="l00236"></a> 236 this-&gt;sph_model-&gt;coefficients_a[this-&gt;element_index] = coefficients_a;

<a id="l00237" name="l00237"></a> 237 }

<a id="l00238" name="l00238"></a> 238 

<a id="l00239" name="l00239"></a> 239 inline ROCKY_FUNCTIONS void add_coefficients_a(const float coefficients_a)

<a id="l00240" name="l00240"></a> 240 {

<a id="l00241" name="l00241"></a> 241 float&amp; prt_coefficients_a = this-&gt;sph_model-&gt;coefficients_a[this-&gt;element_index];

<a id="l00242" name="l00242"></a> 242 backend::atomic_add(&amp;prt_coefficients_a, coefficients_a);

<a id="l00243" name="l00243"></a> 243 }

<a id="l00244" name="l00244"></a> 244 

<a id="l00245" name="l00245"></a> 245 inline ROCKY_FUNCTIONS const float3&amp; get_coefficients_d() const

<a id="l00246" name="l00246"></a> 246 {

<a id="l00247" name="l00247"></a> 247 return this-&gt;sph_model-&gt;coefficients_d[this-&gt;element_index];

<a id="l00248" name="l00248"></a> 248 }

<a id="l00249" name="l00249"></a> 249 

<a id="l00250" name="l00250"></a> 250 inline ROCKY_FUNCTIONS void set_coefficients_d(const float3&amp; coefficients_d)

<a id="l00251" name="l00251"></a> 251 {

<a id="l00252" name="l00252"></a> 252 this-&gt;sph_model-&gt;coefficients_d[this-&gt;element_index] = coefficients_d;

<a id="l00253" name="l00253"></a> 253 }

<a id="l00254" name="l00254"></a> 254 

<a id="l00255" name="l00255"></a> 255 inline ROCKY_FUNCTIONS void add_coefficients_d(const float3&amp; coefficients_d)

<a id="l00256" name="l00256"></a> 256 {

<a id="l00257" name="l00257"></a> 257 float3&amp; prt_coefficients_d = this-&gt;sph_model-&gt;coefficients_d[this-&gt;element_index];

<a id="l00258" name="l00258"></a> 258 backend::atomic_add(&amp;prt_coefficients_d, coefficients_d);

<a id="l00259" name="l00259"></a> 259 }

<a id="l00260" name="l00260"></a> 260 

<a id="l00261" name="l00261"></a> 261 inline ROCKY_FUNCTIONS float3 get_force() const

<a id="l00262" name="l00262"></a> 262 {

<a id="l00263" name="l00263"></a> 263 // For SPH elements, the force vector actually holds acceleration in those elements.

<a id="l00264" name="l00264"></a> 264 // For the sake of uniformity throughout our SPH-DEM APIs, we return here a force.

<a id="l00265" name="l00265"></a> 265 return this-&gt;get_acceleration() * this-&gt;get_mass();

<a id="l00266" name="l00266"></a> 266 }

<a id="l00267" name="l00267"></a> 267 

<a id="l00268" name="l00268"></a> 268 inline ROCKY_FUNCTIONS const float3&amp; get_acceleration() const

<a id="l00269" name="l00269"></a> 269 {

<a id="l00270" name="l00270"></a> 270 // For SPH elements, the force vector actually holds acceleration in those elements.

<a id="l00271" name="l00271"></a> 271 return this-&gt;get_scalars()-&gt;get_acceleration(this-&gt;element_index);

<a id="l00272" name="l00272"></a> 272 }

<a id="l00273" name="l00273"></a> 273 

<a id="l00277" name="l00277"></a> 277 inline ROCKY_FUNCTIONS const float3&amp; get_position_correction_velocity() const

<a id="l00278" name="l00278"></a> 278 {

<a id="l00279" name="l00279"></a> 279 return this-&gt;get_acceleration();

<a id="l00280" name="l00280"></a> 280 }

<a id="l00281" name="l00281"></a> 281 

<a id="l00282" name="l00282"></a> 282 inline ROCKY_FUNCTIONS void add_force(const float3&amp; f)

<a id="l00283" name="l00283"></a> 283 {

<a id="l00284" name="l00284"></a> 284 // For SPH elements, the force vector actually holds acceleration in those elements.

<a id="l00285" name="l00285"></a> 285 // For the sake of uniformity throughout our SPH-DEM APIs, we receive here a force,

<a id="l00286" name="l00286"></a> 286 // and therefore must extract the acceleration from it.

<a id="l00287" name="l00287"></a> 287 this-&gt;add_acceleration(f / this-&gt;get_mass());

<a id="l00288" name="l00288"></a> 288 }

<a id="l00289" name="l00289"></a> 289 

<a id="l00290" name="l00290"></a> 290 inline ROCKY_FUNCTIONS float get_mass() const

<a id="l00291" name="l00291"></a> 291 {

<a id="l00292" name="l00292"></a> 292 return this-&gt;sph_model-&gt;gen_sph-&gt;get_mass(this-&gt;element_index, this-&gt;_refinement_count());

<a id="l00293" name="l00293"></a> 293 }

<a id="l00294" name="l00294"></a> 294 

<a id="l00295" name="l00295"></a> 295 inline ROCKY_FUNCTIONS void add_acceleration(const float3&amp; a)

<a id="l00296" name="l00296"></a> 296 {

<a id="l00297" name="l00297"></a> 297 // For SPH elements, the force vector actually holds acceleration in those elements.

<a id="l00298" name="l00298"></a> 298 float3&amp; prt_forces = this-&gt;get_scalars()-&gt;get_acceleration(this-&gt;element_index);

<a id="l00299" name="l00299"></a> 299 backend::atomic_add(&amp;prt_forces, a);

<a id="l00300" name="l00300"></a> 300 }

<a id="l00301" name="l00301"></a> 301 

<a id="l00302" name="l00302"></a> 302 inline ROCKY_FUNCTIONS void set_acceleration(const float3&amp; a)

<a id="l00303" name="l00303"></a> 303 {

<a id="l00304" name="l00304"></a> 304 this-&gt;get_scalars()-&gt;get_acceleration(this-&gt;element_index) = a;

<a id="l00305" name="l00305"></a> 305 }

<a id="l00306" name="l00306"></a> 306 

<a id="l00307" name="l00307"></a> 307 inline ROCKY_FUNCTIONS PeriodicPosition get_periodic_position() const

<a id="l00308" name="l00308"></a> 308 {

<a id="l00309" name="l00309"></a> 309 if (this-&gt;get_scalars()-&gt;is_periodic_position_enabled())

<a id="l00310" name="l00310"></a> 310 return this-&gt;get_scalars()-&gt;get_periodic_position(this-&gt;element_index);

<a id="l00311" name="l00311"></a> 311 return { PeriodicPosition::NoFlags };

<a id="l00312" name="l00312"></a> 312 }

<a id="l00313" name="l00313"></a> 313 

<a id="l00314" name="l00314"></a> 314 inline ROCKY_FUNCTIONS void set_periodic_position(const PeriodicPosition periodic)

<a id="l00315" name="l00315"></a> 315 {

<a id="l00316" name="l00316"></a> 316 this-&gt;get_scalars()-&gt;get_periodic_position(this-&gt;element_index) = periodic;

<a id="l00317" name="l00317"></a> 317 }

<a id="l00318" name="l00318"></a> 318 

<a id="l00319" name="l00319"></a> 319 inline ROCKY_FUNCTIONS void reset_periodic_position()

<a id="l00320" name="l00320"></a> 320 {

<a id="l00321" name="l00321"></a> 321 if (this-&gt;get_scalars()-&gt;is_periodic_position_enabled())

<a id="l00322" name="l00322"></a> 322 this-&gt;get_scalars()-&gt;get_periodic_position(this-&gt;element_index).reset();

<a id="l00323" name="l00323"></a> 323 }

<a id="l00324" name="l00324"></a> 324 

<a id="l00325" name="l00325"></a> 325 inline ROCKY_FUNCTIONS int get_gpu_id() const

<a id="l00326" name="l00326"></a> 326 {

<a id="l00327" name="l00327"></a> 327 if (this-&gt;get_scalars()-&gt;is_gpu_index_enabled())

<a id="l00328" name="l00328"></a> 328 return this-&gt;get_scalars()-&gt;get_gpu_index(this-&gt;element_index);

<a id="l00329" name="l00329"></a> 329 return 0;

<a id="l00330" name="l00330"></a> 330 }

<a id="l00331" name="l00331"></a> 331 

<a id="l00332" name="l00332"></a> 332 inline ROCKY_FUNCTIONS void set_gpu_id(const int gpu_id)

<a id="l00333" name="l00333"></a> 333 {

<a id="l00334" name="l00334"></a> 334 this-&gt;get_scalars()-&gt;get_gpu_index(this-&gt;element_index) = int8_t(gpu_id);

<a id="l00335" name="l00335"></a> 335 }

<a id="l00336" name="l00336"></a> 336 

<a id="l00337" name="l00337"></a> 337 inline ROCKY_FUNCTIONS int get_global_index() const

<a id="l00338" name="l00338"></a> 338 {

<a id="l00339" name="l00339"></a> 339 return this-&gt;get_scalars()-&gt;get_global_index(this-&gt;element_index);

<a id="l00340" name="l00340"></a> 340 }

<a id="l00341" name="l00341"></a> 341 

<a id="l00342" name="l00342"></a> 342 inline ROCKY_FUNCTIONS void set_global_index(const int index)

<a id="l00343" name="l00343"></a> 343 {

<a id="l00344" name="l00344"></a> 344 this-&gt;get_scalars()-&gt;get_global_index(this-&gt;element_index) = index;

<a id="l00345" name="l00345"></a> 345 }

<a id="l00346" name="l00346"></a> 346 

<a id="l00347" name="l00347"></a> 347 // General methods bindings --------------------------------------------------------------------

<a id="l00348" name="l00348"></a> 348 

<a id="l00349" name="l00349"></a> 349 inline ROCKY_FUNCTIONS float get_size() const

<a id="l00350" name="l00350"></a> 350 {

<a id="l00351" name="l00351"></a> 351 return this-&gt;sph_model-&gt;gen_sph-&gt;get_dist(

<a id="l00352" name="l00352"></a> 352 this-&gt;element_index, this-&gt;_refinement_kernel_base());

<a id="l00353" name="l00353"></a> 353 }

<a id="l00354" name="l00354"></a> 354 

<a id="l00355" name="l00355"></a> 355 inline ROCKY_FUNCTIONS float get_stiffness() const

<a id="l00356" name="l00356"></a> 356 {

<a id="l00357" name="l00357"></a> 357 return this-&gt;sph_model-&gt;gen_sph-&gt;get_stiff(

<a id="l00358" name="l00358"></a> 358 this-&gt;element_index, this-&gt;_refinement_kernel_base());

<a id="l00359" name="l00359"></a> 359 }

<a id="l00360" name="l00360"></a> 360 

<a id="l00361" name="l00361"></a> 361 inline ROCKY_FUNCTIONS float get_dissipation() const

<a id="l00362" name="l00362"></a> 362 {

<a id="l00363" name="l00363"></a> 363 return this-&gt;sph_model-&gt;gen_sph-&gt;get_diss(

<a id="l00364" name="l00364"></a> 364 this-&gt;element_index, this-&gt;_refinement_kernel_base(), this-&gt;_refinement_count());

<a id="l00365" name="l00365"></a> 365 }

<a id="l00366" name="l00366"></a> 366 

<a id="l00367" name="l00367"></a> 367 inline ROCKY_FUNCTIONS float get_minimum_distance() const

<a id="l00368" name="l00368"></a> 368 {

<a id="l00369" name="l00369"></a> 369 return this-&gt;sph_model-&gt;gen_sph-&gt;get_minimum_distance();

<a id="l00370" name="l00370"></a> 370 }

<a id="l00371" name="l00371"></a> 371 

<a id="l00372" name="l00372"></a> 372 inline ROCKY_FUNCTIONS float get_minimum_distance_squared() const

<a id="l00373" name="l00373"></a> 373 {

<a id="l00374" name="l00374"></a> 374 return this-&gt;sph_model-&gt;gen_sph-&gt;get_minimum_distance_squared();

<a id="l00375" name="l00375"></a> 375 }

<a id="l00376" name="l00376"></a> 376 

<a id="l00377" name="l00377"></a> 377 inline ROCKY_FUNCTIONS bool is_refinement_daughter() const

<a id="l00378" name="l00378"></a> 378 {

<a id="l00379" name="l00379"></a> 379 if (this-&gt;use_refinement &amp;&amp; (this-&gt;sph_model-&gt;gen_sph-&gt;nprt_refinement_daughters &gt; 0))

<a id="l00380" name="l00380"></a> 380 {

<a id="l00381" name="l00381"></a> 381 const int ig_diff =

<a id="l00382" name="l00382"></a> 382 this-&gt;get_global_index() - this-&gt;sph_model-&gt;gen_sph-&gt;refinement_daughters_start;

<a id="l00383" name="l00383"></a> 383 

<a id="l00384" name="l00384"></a> 384 return (

<a id="l00385" name="l00385"></a> 385 (ig_diff &gt;= 0) &amp;&amp; (ig_diff &lt; this-&gt;sph_model-&gt;gen_sph-&gt;nprt_refinement_daughters));

<a id="l00386" name="l00386"></a> 386 }

<a id="l00387" name="l00387"></a> 387 else

<a id="l00388" name="l00388"></a> 388 return false;

<a id="l00389" name="l00389"></a> 389 }

<a id="l00390" name="l00390"></a> 390 

<a id="l00391" name="l00391"></a> 391 inline ROCKY_FUNCTIONS real_sph get_kernel_refinement_multiplier() const

<a id="l00392" name="l00392"></a> 392 {

<a id="l00393" name="l00393"></a> 393 if (this-&gt;is_refinement_daughter())

<a id="l00394" name="l00394"></a> 394 {

<a id="l00395" name="l00395"></a> 395 return 1.0f + this-&gt;sph_model-&gt;gen_sph-&gt;refinement_blending_fraction;

<a id="l00396" name="l00396"></a> 396 }

<a id="l00397" name="l00397"></a> 397 else

<a id="l00398" name="l00398"></a> 398 return 1.0f;

<a id="l00399" name="l00399"></a> 399 }

<a id="l00400" name="l00400"></a> 400 

<a id="l00401" name="l00401"></a> 401 inline ROCKY_FUNCTIONS float get_kernel_base() const

<a id="l00402" name="l00402"></a> 402 {

<a id="l00403" name="l00403"></a> 403 return this-&gt;sph_model-&gt;gen_sph-&gt;get_kern_base_single(

<a id="l00404" name="l00404"></a> 404 this-&gt;element_index, this-&gt;get_kernel_refinement_multiplier(), this-&gt;_refinement_kernel_base());

<a id="l00405" name="l00405"></a> 405 }

<a id="l00406" name="l00406"></a> 406 

<a id="l00407" name="l00407"></a> 407 inline ROCKY_FUNCTIONS float get_kernel_base(const RockySPHElement&amp; near_element) const

<a id="l00408" name="l00408"></a> 408 {

<a id="l00409" name="l00409"></a> 409 return this-&gt;sph_model-&gt;gen_sph-&gt;get_kern_base_pair(

<a id="l00410" name="l00410"></a> 410 this-&gt;element_index,

<a id="l00411" name="l00411"></a> 411 near_element.element_index,

<a id="l00412" name="l00412"></a> 412 this-&gt;get_kernel_refinement_multiplier(),

<a id="l00413" name="l00413"></a> 413 near_element.get_kernel_refinement_multiplier(),

<a id="l00414" name="l00414"></a> 414 this-&gt;_refinement_kernel_base());

<a id="l00415" name="l00415"></a> 415 }

<a id="l00416" name="l00416"></a> 416 

<a id="l00417" name="l00417"></a> 417 inline ROCKY_FUNCTIONS float get_kernel(const float distance) const

<a id="l00418" name="l00418"></a> 418 {

<a id="l00419" name="l00419"></a> 419 return this-&gt;sph_model-&gt;gen_sph-&gt;get_kernel_single(

<a id="l00420" name="l00420"></a> 420 distance,

<a id="l00421" name="l00421"></a> 421 this-&gt;element_index,

<a id="l00422" name="l00422"></a> 422 this-&gt;get_kernel_refinement_multiplier(),

<a id="l00423" name="l00423"></a> 423 this-&gt;_refinement_kernel_base());

<a id="l00424" name="l00424"></a> 424 }

<a id="l00425" name="l00425"></a> 425 

<a id="l00426" name="l00426"></a> 426 inline ROCKY_FUNCTIONS float get_kernel(

<a id="l00427" name="l00427"></a> 427 const float distance, const RockySPHElement&amp; near_element) const

<a id="l00428" name="l00428"></a> 428 {

<a id="l00429" name="l00429"></a> 429 return this-&gt;sph_model-&gt;gen_sph-&gt;get_kernel_pair(

<a id="l00430" name="l00430"></a> 430 distance,

<a id="l00431" name="l00431"></a> 431 this-&gt;element_index,

<a id="l00432" name="l00432"></a> 432 near_element.element_index,

<a id="l00433" name="l00433"></a> 433 this-&gt;get_kernel_refinement_multiplier(),

<a id="l00434" name="l00434"></a> 434 near_element.get_kernel_refinement_multiplier(),

<a id="l00435" name="l00435"></a> 435 this-&gt;_refinement_kernel_base());

<a id="l00436" name="l00436"></a> 436 }

<a id="l00437" name="l00437"></a> 437 

<a id="l00438" name="l00438"></a> 438 inline ROCKY_FUNCTIONS float get_kernel_radius() const

<a id="l00439" name="l00439"></a> 439 {

<a id="l00440" name="l00440"></a> 440 return this-&gt;sph_model-&gt;gen_sph-&gt;get_kernel_radius_single(

<a id="l00441" name="l00441"></a> 441 this-&gt;element_index,

<a id="l00442" name="l00442"></a> 442 this-&gt;get_kernel_refinement_multiplier(),

<a id="l00443" name="l00443"></a> 443 this-&gt;_refinement_kernel_base());

<a id="l00444" name="l00444"></a> 444 }

<a id="l00445" name="l00445"></a> 445 

<a id="l00446" name="l00446"></a> 446 inline ROCKY_FUNCTIONS float get_kernel_radius(const RockySPHElement&amp; near_element) const

<a id="l00447" name="l00447"></a> 447 {

<a id="l00448" name="l00448"></a> 448 return this-&gt;sph_model-&gt;gen_sph-&gt;get_kernel_radius_pair(

<a id="l00449" name="l00449"></a> 449 this-&gt;element_index,

<a id="l00450" name="l00450"></a> 450 near_element.element_index,

<a id="l00451" name="l00451"></a> 451 this-&gt;get_kernel_refinement_multiplier(),

<a id="l00452" name="l00452"></a> 452 near_element.get_kernel_refinement_multiplier(),

<a id="l00453" name="l00453"></a> 453 this-&gt;_refinement_kernel_base());

<a id="l00454" name="l00454"></a> 454 }

<a id="l00455" name="l00455"></a> 455 

<a id="l00456" name="l00456"></a> 456 inline ROCKY_FUNCTIONS float get_squared_kernel_radius(

<a id="l00457" name="l00457"></a> 457 const RockySPHElement&amp; near_element, const real_sph eps = 0.f) const

<a id="l00458" name="l00458"></a> 458 {

<a id="l00459" name="l00459"></a> 459 return this-&gt;sph_model-&gt;gen_sph-&gt;get_squared_kernel_radius_pair(

<a id="l00460" name="l00460"></a> 460 this-&gt;element_index,

<a id="l00461" name="l00461"></a> 461 near_element.element_index,

<a id="l00462" name="l00462"></a> 462 this-&gt;get_kernel_refinement_multiplier(),

<a id="l00463" name="l00463"></a> 463 near_element.get_kernel_refinement_multiplier(),

<a id="l00464" name="l00464"></a> 464 this-&gt;_refinement_kernel_base(),

<a id="l00465" name="l00465"></a> 465 eps);

<a id="l00466" name="l00466"></a> 466 }

<a id="l00467" name="l00467"></a> 467 

<a id="l00468" name="l00468"></a> 468 inline ROCKY_FUNCTIONS float get_kernel_derivative(

<a id="l00469" name="l00469"></a> 469 const float distance, const RockySPHElement&amp; near_element) const

<a id="l00470" name="l00470"></a> 470 {

<a id="l00471" name="l00471"></a> 471 return this-&gt;sph_model-&gt;gen_sph-&gt;get_kernel_derivative(

<a id="l00472" name="l00472"></a> 472 distance,

<a id="l00473" name="l00473"></a> 473 this-&gt;element_index,

<a id="l00474" name="l00474"></a> 474 near_element.element_index,

<a id="l00475" name="l00475"></a> 475 this-&gt;get_kernel_refinement_multiplier(),

<a id="l00476" name="l00476"></a> 476 near_element.get_kernel_refinement_multiplier(),

<a id="l00477" name="l00477"></a> 477 this-&gt;_refinement_kernel_base());

<a id="l00478" name="l00478"></a> 478 }

<a id="l00479" name="l00479"></a> 479 

<a id="l00480" name="l00480"></a> 480 // Refinement ----------------------------------------------------------------------------------

<a id="l00481" name="l00481"></a> 481 inline ROCKY_FUNCTIONS int get_refinement_count() const

<a id="l00482" name="l00482"></a> 482 {

<a id="l00483" name="l00483"></a> 483 return this-&gt;get_scalars()-&gt;get_refinement_count()[this-&gt;element_index];

<a id="l00484" name="l00484"></a> 484 }

<a id="l00485" name="l00485"></a> 485 

<a id="l00486" name="l00486"></a> 486 inline ROCKY_FUNCTIONS void set_refinement_count(const int count)

<a id="l00487" name="l00487"></a> 487 {

<a id="l00488" name="l00488"></a> 488 this-&gt;get_scalars()-&gt;get_refinement_count()[this-&gt;element_index] = count;

<a id="l00489" name="l00489"></a> 489 }

<a id="l00490" name="l00490"></a> 490 

<a id="l00491" name="l00491"></a> 491 inline ROCKY_FUNCTIONS float get_refinement_kernel_base() const

<a id="l00492" name="l00492"></a> 492 {

<a id="l00493" name="l00493"></a> 493 return this-&gt;get_scalars()-&gt;get_refinement_kernel_base()[this-&gt;element_index];

<a id="l00494" name="l00494"></a> 494 }

<a id="l00495" name="l00495"></a> 495 

<a id="l00496" name="l00496"></a> 496 inline ROCKY_FUNCTIONS void set_refinement_kernel_base(const float base)

<a id="l00497" name="l00497"></a> 497 {

<a id="l00498" name="l00498"></a> 498 this-&gt;get_scalars()-&gt;get_refinement_kernel_base()[this-&gt;element_index] = base;

<a id="l00499" name="l00499"></a> 499 }

<a id="l00500" name="l00500"></a> 500 

<a id="l00501" name="l00501"></a> 501 // Scalars -----------------------------------------------------------------------------------

<a id="l00502" name="l00502"></a> 502 inline ROCKY_FUNCTIONS float get_turbulent_viscosity() const

<a id="l00503" name="l00503"></a> 503 {

<a id="l00504" name="l00504"></a> 504 return this-&gt;get_scalars()-&gt;get_turbulent_viscosity(this-&gt;element_index);

<a id="l00505" name="l00505"></a> 505 }

<a id="l00506" name="l00506"></a> 506 

<a id="l00507" name="l00507"></a> 507 inline ROCKY_FUNCTIONS void set_turbulent_viscosity(float turbulent_viscosity)

<a id="l00508" name="l00508"></a> 508 {

<a id="l00509" name="l00509"></a> 509 auto&amp; scalar = this-&gt;get_scalars()-&gt;get_turbulent_viscosity(this-&gt;element_index);

<a id="l00510" name="l00510"></a> 510 scalar = turbulent_viscosity;

<a id="l00511" name="l00511"></a> 511 }

<a id="l00512" name="l00512"></a> 512 

<a id="l00513" name="l00513"></a> 513 inline ROCKY_FUNCTIONS void add_turbulent_viscosity(float turbulent_viscosity)

<a id="l00514" name="l00514"></a> 514 {

<a id="l00515" name="l00515"></a> 515 auto&amp; scalar = this-&gt;get_scalars()-&gt;get_turbulent_viscosity(this-&gt;element_index);

<a id="l00516" name="l00516"></a> 516 backend::atomic_add(&amp;scalar, turbulent_viscosity);

<a id="l00517" name="l00517"></a> 517 }

<a id="l00518" name="l00518"></a> 518 

<a id="l00519" name="l00519"></a> 519 // Scalars -----------------------------------------------------------------------------------

<a id="l00520" name="l00520"></a> 520 inline ROCKY_FUNCTIONS float get_molecular_viscosity() const

<a id="l00521" name="l00521"></a> 521 {

<a id="l00522" name="l00522"></a> 522 if (this-&gt;get_scalars()-&gt;is_variable_molecular_viscosity_enabled())

<a id="l00523" name="l00523"></a> 523 return this-&gt;get_scalars()-&gt;get_molecular_viscosity(this-&gt;element_index);

<a id="l00524" name="l00524"></a> 524 else

<a id="l00525" name="l00525"></a> 525 return this-&gt;sph_model-&gt;gen_sph-&gt;visc;

<a id="l00526" name="l00526"></a> 526 }

<a id="l00527" name="l00527"></a> 527 

<a id="l00528" name="l00528"></a> 528 inline ROCKY_FUNCTIONS void set_molecular_viscosity(const float molecular_viscosity)

<a id="l00529" name="l00529"></a> 529 {

<a id="l00530" name="l00530"></a> 530 auto&amp; scalar = this-&gt;get_scalars()-&gt;get_molecular_viscosity(this-&gt;element_index);

<a id="l00531" name="l00531"></a> 531 scalar = molecular_viscosity;

<a id="l00532" name="l00532"></a> 532 }

<a id="l00533" name="l00533"></a> 533 

<a id="l00534" name="l00534"></a> 534 inline ROCKY_FUNCTIONS float get_temperature() const

<a id="l00535" name="l00535"></a> 535 {

<a id="l00536" name="l00536"></a> 536 return this-&gt;get_scalars()-&gt;get_temperature(this-&gt;element_index);

<a id="l00537" name="l00537"></a> 537 }

<a id="l00538" name="l00538"></a> 538 

<a id="l00539" name="l00539"></a> 539 inline ROCKY_FUNCTIONS void set_temperature(float temperature)

<a id="l00540" name="l00540"></a> 540 {

<a id="l00541" name="l00541"></a> 541 this-&gt;get_scalars()-&gt;get_temperature(this-&gt;element_index) = temperature;

<a id="l00542" name="l00542"></a> 542 }

<a id="l00543" name="l00543"></a> 543 

<a id="l00544" name="l00544"></a> 544 inline ROCKY_FUNCTIONS float3 get_implicit_viscosity_velocity_increment() const

<a id="l00545" name="l00545"></a> 545 {

<a id="l00546" name="l00546"></a> 546 return this-&gt;get_scalars()-&gt;get_implicit_viscosity_velocity_increment(this-&gt;element_index);

<a id="l00547" name="l00547"></a> 547 }

<a id="l00548" name="l00548"></a> 548 

<a id="l00549" name="l00549"></a> 549 inline ROCKY_FUNCTIONS void set_implicit_viscosity_velocity_increment(float3 velocity_increment)

<a id="l00550" name="l00550"></a> 550 {

<a id="l00551" name="l00551"></a> 551 auto&amp; scalar =

<a id="l00552" name="l00552"></a> 552 this-&gt;get_scalars()-&gt;get_implicit_viscosity_velocity_increment(this-&gt;element_index);

<a id="l00553" name="l00553"></a> 553 scalar = velocity_increment;

<a id="l00554" name="l00554"></a> 554 }

<a id="l00555" name="l00555"></a> 555 

<a id="l00556" name="l00556"></a> 556 inline ROCKY_FUNCTIONS const rocky20::SPHParticleScalars* get_scalars() const

<a id="l00557" name="l00557"></a> 557 {

<a id="l00558" name="l00558"></a> 558 return this-&gt;scalars;

<a id="l00559" name="l00559"></a> 559 }

<a id="l00560" name="l00560"></a> 560 

<a id="l00561" name="l00561"></a> 561 inline ROCKY_FUNCTIONS rocky20::SPHParticleScalars* get_scalars()

<a id="l00562" name="l00562"></a> 562 {

<a id="l00563" name="l00563"></a> 563 return this-&gt;scalars;

<a id="l00564" name="l00564"></a> 564 }

<a id="l00565" name="l00565"></a> 565 

<a id="l00566" name="l00566"></a> 566 inline ROCKY_FUNCTIONS SymmetricTensor&lt;float&gt; get_strain_rate_tensor()

<a id="l00567" name="l00567"></a> 567 {

<a id="l00568" name="l00568"></a> 568 auto element_scalars = this-&gt;get_scalars();

<a id="l00569" name="l00569"></a> 569 if (!element_scalars-&gt;is_velocity_gradient_enabled())

<a id="l00570" name="l00570"></a> 570 {

<a id="l00571" name="l00571"></a> 571 return {};

<a id="l00572" name="l00572"></a> 572 }

<a id="l00573" name="l00573"></a> 573 

<a id="l00574" name="l00574"></a> 574 // strain rate tensor = 0.5 \* (grad\_velocity + grad\_velocity\_transposed)

<a id="l00575" name="l00575"></a> 575 const auto&amp; grad_vx = element_scalars-&gt;get_velocity_gradient_x(this-&gt;element_index);

<a id="l00576" name="l00576"></a> 576 const auto&amp; grad_vy = element_scalars-&gt;get_velocity_gradient_y(this-&gt;element_index);

<a id="l00577" name="l00577"></a> 577 const auto&amp; grad_vz = element_scalars-&gt;get_velocity_gradient_z(this-&gt;element_index);

<a id="l00578" name="l00578"></a> 578 

<a id="l00579" name="l00579"></a> 579 return { { grad_vx.x, grad_vy.y, grad_vz.z },

<a id="l00580" name="l00580"></a> 580 { 0.5f * (grad_vx.y + grad_vy.x),

<a id="l00581" name="l00581"></a> 581 0.5f * (grad_vx.z + grad_vz.x),

<a id="l00582" name="l00582"></a> 582 0.5f * (grad_vy.z + grad_vz.y) } };

<a id="l00583" name="l00583"></a> 583 }

<a id="l00584" name="l00584"></a> 584 

<a id="l00585" name="l00585"></a> 585 // Flags --------------------------------------------------------------------------------------

<a id="l00586" name="l00586"></a> 586 

<a id="l00587" name="l00587"></a> 587 inline ROCKY_FUNCTIONS bool is_active() const

<a id="l00588" name="l00588"></a> 588 {

<a id="l00589" name="l00589"></a> 589 return this-&gt;_state().active();

<a id="l00590" name="l00590"></a> 590 }

<a id="l00591" name="l00591"></a> 591 

<a id="l00592" name="l00592"></a> 592 inline ROCKY_FUNCTIONS void set_active(const bool active = true)

<a id="l00593" name="l00593"></a> 593 {

<a id="l00594" name="l00594"></a> 594 this-&gt;_state().set_active(active);

<a id="l00595" name="l00595"></a> 595 }

<a id="l00596" name="l00596"></a> 596 

<a id="l00597" name="l00597"></a> 597 inline ROCKY_FUNCTIONS bool is_coupled_deactivated() const

<a id="l00598" name="l00598"></a> 598 {

<a id="l00599" name="l00599"></a> 599 return this-&gt;_state().coupled_deactivated();

<a id="l00600" name="l00600"></a> 600 }

<a id="l00601" name="l00601"></a> 601 

<a id="l00602" name="l00602"></a> 602 inline ROCKY_FUNCTIONS void set_coupled_deactivated(const bool coupled_deactivated = true)

<a id="l00603" name="l00603"></a> 603 {

<a id="l00604" name="l00604"></a> 604 this-&gt;_state().set_coupled_deactivated(coupled_deactivated);

<a id="l00605" name="l00605"></a> 605 }

<a id="l00606" name="l00606"></a> 606 

<a id="l00607" name="l00607"></a> 607 inline ROCKY_FUNCTIONS bool is_deactivate() const

<a id="l00608" name="l00608"></a> 608 {

<a id="l00609" name="l00609"></a> 609 return this-&gt;_state().deactivate();

<a id="l00610" name="l00610"></a> 610 }

<a id="l00611" name="l00611"></a> 611 

<a id="l00612" name="l00612"></a> 612 inline ROCKY_FUNCTIONS void set_deactivate(const bool deactivate = true)

<a id="l00613" name="l00613"></a> 613 {

<a id="l00614" name="l00614"></a> 614 this-&gt;_state().set_deactivate(deactivate);

<a id="l00615" name="l00615"></a> 615 }

<a id="l00616" name="l00616"></a> 616 

<a id="l00617" name="l00617"></a> 617 inline ROCKY_FUNCTIONS bool is_enabled() const

<a id="l00618" name="l00618"></a> 618 {

<a id="l00619" name="l00619"></a> 619 return this-&gt;_state().enabled();

<a id="l00620" name="l00620"></a> 620 }

<a id="l00621" name="l00621"></a> 621 

<a id="l00622" name="l00622"></a> 622 inline ROCKY_FUNCTIONS void set_enabled(const bool enabled = true)

<a id="l00623" name="l00623"></a> 623 {

<a id="l00624" name="l00624"></a> 624 this-&gt;_state().set_enabled(enabled);

<a id="l00625" name="l00625"></a> 625 }

<a id="l00626" name="l00626"></a> 626 

<a id="l00627" name="l00627"></a> 627 inline ROCKY_FUNCTIONS bool is_frozen() const

<a id="l00628" name="l00628"></a> 628 {

<a id="l00629" name="l00629"></a> 629 return this-&gt;_state().frozen();

<a id="l00630" name="l00630"></a> 630 }

<a id="l00631" name="l00631"></a> 631 

<a id="l00632" name="l00632"></a> 632 inline ROCKY_FUNCTIONS void set_frozen(bool _frozen = true)

<a id="l00633" name="l00633"></a> 633 {

<a id="l00634" name="l00634"></a> 634 if (!this-&gt;is_dem_coupled())

<a id="l00635" name="l00635"></a> 635 {

<a id="l00636" name="l00636"></a> 636 this-&gt;_state().set_frozen(_frozen);

<a id="l00637" name="l00637"></a> 637 if (_frozen)

<a id="l00638" name="l00638"></a> 638 // Zero velocities of frozen elements

<a id="l00639" name="l00639"></a> 639 this-&gt;set_velocity({});

<a id="l00640" name="l00640"></a> 640 }

<a id="l00641" name="l00641"></a> 641 }

<a id="l00642" name="l00642"></a> 642 

<a id="l00643" name="l00643"></a> 643 inline ROCKY_FUNCTIONS bool is_ghost() const

<a id="l00644" name="l00644"></a> 644 {

<a id="l00645" name="l00645"></a> 645 return this-&gt;_state().ghost();

<a id="l00646" name="l00646"></a> 646 }

<a id="l00647" name="l00647"></a> 647 

<a id="l00648" name="l00648"></a> 648 inline ROCKY_FUNCTIONS void set_ghost(const bool ghost = true)

<a id="l00649" name="l00649"></a> 649 {

<a id="l00650" name="l00650"></a> 650 this-&gt;_state().set_ghost(ghost);

<a id="l00651" name="l00651"></a> 651 }

<a id="l00652" name="l00652"></a> 652 

<a id="l00653" name="l00653"></a> 653 inline ROCKY_FUNCTIONS bool is_just_activated() const

<a id="l00654" name="l00654"></a> 654 {

<a id="l00655" name="l00655"></a> 655 return this-&gt;_state().just_activated();

<a id="l00656" name="l00656"></a> 656 }

<a id="l00657" name="l00657"></a> 657 

<a id="l00658" name="l00658"></a> 658 inline ROCKY_FUNCTIONS void set_just_activated(const bool just_activated = true)

<a id="l00659" name="l00659"></a> 659 {

<a id="l00660" name="l00660"></a> 660 this-&gt;_state().set_just_activated(just_activated);

<a id="l00661" name="l00661"></a> 661 }

<a id="l00662" name="l00662"></a> 662 

<a id="l00663" name="l00663"></a> 663 inline ROCKY_FUNCTIONS bool is_just_enabled() const

<a id="l00664" name="l00664"></a> 664 {

<a id="l00665" name="l00665"></a> 665 return this-&gt;_state().just_enabled();

<a id="l00666" name="l00666"></a> 666 }

<a id="l00667" name="l00667"></a> 667 

<a id="l00668" name="l00668"></a> 668 inline ROCKY_FUNCTIONS void set_just_enabled(const bool just_enabled = true)

<a id="l00669" name="l00669"></a> 669 {

<a id="l00670" name="l00670"></a> 670 this-&gt;_state().set_just_enabled(just_enabled);

<a id="l00671" name="l00671"></a> 671 }

<a id="l00672" name="l00672"></a> 672 

<a id="l00673" name="l00673"></a> 673 inline ROCKY_FUNCTIONS bool is_released() const

<a id="l00674" name="l00674"></a> 674 {

<a id="l00675" name="l00675"></a> 675 return this-&gt;_state().released();

<a id="l00676" name="l00676"></a> 676 }

<a id="l00677" name="l00677"></a> 677 

<a id="l00678" name="l00678"></a> 678 inline ROCKY_FUNCTIONS void set_released(const bool released = true)

<a id="l00679" name="l00679"></a> 679 {

<a id="l00680" name="l00680"></a> 680 this-&gt;_state().set_released(released);

<a id="l00681" name="l00681"></a> 681 }

<a id="l00682" name="l00682"></a> 682 

<a id="l00683" name="l00683"></a> 683 /\* A regular free element is one that:

<a id="l00684" name="l00684"></a> 684 \* is enabled (has been released)

<a id="l00685" name="l00685"></a> 685 \* is not dem-coupled

<a id="l00686" name="l00686"></a> 686 \* is not ghost

<a id="l00687" name="l00687"></a> 687 \* is not frozen \*/

<a id="l00688" name="l00688"></a> 688 inline ROCKY_FUNCTIONS bool is_regular_free() const

<a id="l00689" name="l00689"></a> 689 {

<a id="l00690" name="l00690"></a> 690 return this-&gt;is_enabled() &amp;&amp; !this-&gt;is_dem_coupled() &amp;&amp; !this-&gt;is_ghost()

<a id="l00691" name="l00691"></a> 691 &amp;&amp; !this-&gt;is_frozen();

<a id="l00692" name="l00692"></a> 692 }

<a id="l00693" name="l00693"></a> 693 

<a id="l00694" name="l00694"></a> 694 inline ROCKY_FUNCTIONS void set_removed_from_neighbors_search(const bool removed)

<a id="l00695" name="l00695"></a> 695 {

<a id="l00696" name="l00696"></a> 696 this-&gt;_state().set_removed_from_neighbors_search(removed);

<a id="l00697" name="l00697"></a> 697 }

<a id="l00698" name="l00698"></a> 698 

<a id="l00699" name="l00699"></a> 699 inline ROCKY_FUNCTIONS bool is_removed_from_neighbors_search() const

<a id="l00700" name="l00700"></a> 700 {

<a id="l00701" name="l00701"></a> 701 return this-&gt;_state().is_removed_from_neighbors_search();

<a id="l00702" name="l00702"></a> 702 }

<a id="l00703" name="l00703"></a> 703 

<a id="l00704" name="l00704"></a> 704 inline ROCKY_FUNCTIONS bool is_on_periphery() const

<a id="l00705" name="l00705"></a> 705 {

<a id="l00706" name="l00706"></a> 706 return this-&gt;_state().on_periphery();

<a id="l00707" name="l00707"></a> 707 }

<a id="l00708" name="l00708"></a> 708 

<a id="l00709" name="l00709"></a> 709 inline ROCKY_FUNCTIONS void set_on_periphery(const bool on_periphery = true)

<a id="l00710" name="l00710"></a> 710 {

<a id="l00711" name="l00711"></a> 711 this-&gt;_state().set_on_periphery(on_periphery);

<a id="l00712" name="l00712"></a> 712 }

<a id="l00713" name="l00713"></a> 713 

<a id="l00714" name="l00714"></a> 714 

<a id="l00715" name="l00715"></a> 715 // Setup data (non-resettable)

<a id="l00716" name="l00716"></a> 716 SPHDeviceModel* sph_model;

<a id="l00717" name="l00717"></a> 717 rocky20::SPHParticleScalars* scalars;

<a id="l00718" name="l00718"></a> 718 

<a id="l00719" name="l00719"></a> 719 // Particle data (resettable)

<a id="l00720" name="l00720"></a> 720 int element_index;

<a id="l00721" name="l00721"></a> 721 bool use_refinement;

<a id="l00722" name="l00722"></a> 722 

<a id="l00723" name="l00723"></a> 723 ROCKY_FUNCTIONS RockySPHElement(SPHDeviceModel* _sph_model, const int index)

<a id="l00724" name="l00724"></a> 724 : sph_model(_sph_model)

<a id="l00725" name="l00725"></a> 725 , scalars(_sph_model -&gt; sph_particle_scalars)

<a id="l00726" name="l00726"></a> 726 , element_index(index)

<a id="l00727" name="l00727"></a> 727 , use_refinement(_sph_model -&gt; gen_sph-&gt;use_refinement())

<a id="l00728" name="l00728"></a> 728 {

<a id="l00729" name="l00729"></a> 729 }

<a id="l00730" name="l00730"></a> 730 

<a id="l00731" name="l00731"></a> 731 RockySPHElement(SPHModel&amp; _sph_model, const int index)

<a id="l00732" name="l00732"></a> 732 : RockySPHElement(_sph_model.get_host_data(), index)

<a id="l00733" name="l00733"></a> 733 {

<a id="l00734" name="l00734"></a> 734 }

<a id="l00735" name="l00735"></a> 735 

<a id="l00736" name="l00736"></a> 736 RockySPHElement(std::unique_ptr&lt;SPHModel&gt;&amp; _sph_model, const int index)

<a id="l00737" name="l00737"></a> 737 : RockySPHElement(_sph_model-&gt;get_host_data(), index)

<a id="l00738" name="l00738"></a> 738 {

<a id="l00739" name="l00739"></a> 739 }

<a id="l00740" name="l00740"></a> 740 

<a id="l00741" name="l00741"></a> 741 inline ROCKY_FUNCTIONS void reset(const int index)

<a id="l00742" name="l00742"></a> 742 {

<a id="l00743" name="l00743"></a> 743 this-&gt;element_index = index;

<a id="l00744" name="l00744"></a> 744 }

<a id="l00745" name="l00745"></a> 745 

<a id="l00746" name="l00746"></a> 746 // Helper methods ------------------------------------------------------------------------------

<a id="l00747" name="l00747"></a> 747 

<a id="l00748" name="l00748"></a> 748 [[nodiscard]] inline ROCKY_FUNCTIONS const float* _refinement_kernel_base() const

<a id="l00749" name="l00749"></a> 749 {

<a id="l00750" name="l00750"></a> 750 if (this-&gt;use_refinement)

<a id="l00751" name="l00751"></a> 751 return this-&gt;get_scalars()-&gt;get_refinement_kernel_base();

<a id="l00752" name="l00752"></a> 752 return nullptr;

<a id="l00753" name="l00753"></a> 753 }

<a id="l00754" name="l00754"></a> 754 

<a id="l00755" name="l00755"></a> 755 [[nodiscard]] inline ROCKY_FUNCTIONS const int* _refinement_count() const

<a id="l00756" name="l00756"></a> 756 {

<a id="l00757" name="l00757"></a> 757 if (this-&gt;use_refinement)

<a id="l00758" name="l00758"></a> 758 return this-&gt;get_scalars()-&gt;get_refinement_count();

<a id="l00759" name="l00759"></a> 759 return nullptr;

<a id="l00760" name="l00760"></a> 760 }

<a id="l00761" name="l00761"></a> 761 

<a id="l00762" name="l00762"></a> 762 __forceinline__ ROCKY_FUNCTIONS const SSPHState&amp; _state() const

<a id="l00763" name="l00763"></a> 763 {

<a id="l00764" name="l00764"></a> 764 return this-&gt;get_scalars()-&gt;get_state(this-&gt;element_index);

<a id="l00765" name="l00765"></a> 765 }

<a id="l00766" name="l00766"></a> 766 

<a id="l00767" name="l00767"></a> 767 __forceinline__ ROCKY_FUNCTIONS SSPHState&amp; _state()

<a id="l00768" name="l00768"></a> 768 {

<a id="l00769" name="l00769"></a> 769 return this-&gt;get_scalars()-&gt;get_state(this-&gt;element_index);

<a id="l00770" name="l00770"></a> 770 }

<a id="l00771" name="l00771"></a> 771};