Page MenuHomec4science

Particle_8hpp_source.html
No OneTemporary

File Metadata

Created
Sun, Nov 24, 21:48

Particle_8hpp_source.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>PHPC - nBody project: /media/lmunier/Data/EPFL/Master/2eme_annee/Semestre_2/Parallel_and_High_Performance_Computing/phpc_submit_nbody/src/Particle.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">PHPC - nBody project
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.16 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">Particle.hpp</div> </div>
</div><!--header-->
<div class="contents">
<a href="Particle_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160; </div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="preprocessor">#ifndef PHPC_NBODY_PARTICLE_HPP</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;<span class="preprocessor">#define PHPC_NBODY_PARTICLE_HPP</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160; </div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="constants_8hpp.html">constants.hpp</a>&quot;</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="Vector_8hpp.html">Vector.hpp</a>&quot;</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="Tree_8hpp.html">Tree.hpp</a>&quot;</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160; </div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160;<span class="keyword">using namespace </span><a class="code" href="namespacestd.html">std</a>;</div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160; </div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceTree.html">Tree</a> {</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160; <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Type&gt;</div><div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="classTree_1_1Particle.html"> 40</a></span>&#160; <span class="keyword">class </span><a class="code" href="classTree_1_1Particle.html">Particle</a> : <span class="keyword">public</span> <a class="code" href="classTree_1_1AbstractType.html">AbstractType</a>&lt;Type&gt; {</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00048"></a><span class="lineno"><a class="line" href="classTree_1_1Particle.html#acf5241af5d99f4c9fc7a5108f682b583"> 48</a></span>&#160; <span class="keyword">explicit</span> <a class="code" href="classTree_1_1Particle.html#acf5241af5d99f4c9fc7a5108f682b583">Particle</a>(<span class="keywordtype">float</span> mass = 0.0f, Type pos = Type()) : _pos(pos) {</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160; this-&gt;set_mass(mass);</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160; }</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; </div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; ~<a class="code" href="classTree_1_1Particle.html">Particle</a>() = <span class="keywordflow">default</span>;</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160; </div><div class="line"><a name="l00066"></a><span class="lineno"><a class="line" href="classTree_1_1Particle.html#a9e9ca29ec750d707066e95318554928f"> 66</a></span>&#160; Type <a class="code" href="classTree_1_1Particle.html#a9e9ca29ec750d707066e95318554928f">get</a>(property p)<span class="keyword"> override </span>{</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; <span class="keywordflow">switch</span> (p) {</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; <span class="keywordflow">case</span> POS :</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160; <span class="keywordflow">return</span> this-&gt;_pos;</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160; <span class="keywordflow">case</span> VEL :</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160; <span class="keywordflow">return</span> this-&gt;_vel;</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; <span class="keywordflow">case</span> LOAD :</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160; <span class="keywordflow">return</span> this-&gt;_load;</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span>&#160; <span class="keywordflow">default</span>:</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; <span class="keywordflow">return</span> Type();</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; <span class="keywordflow">break</span>;</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; }</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160; }</div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160; </div><div class="line"><a name="l00089"></a><span class="lineno"><a class="line" href="classTree_1_1Particle.html#a68961ce42ef677f22eadcd528b86ef6c"> 89</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classTree_1_1Particle.html#a68961ce42ef677f22eadcd528b86ef6c">set</a>(property p, Type vec)<span class="keyword"> override </span>{</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160; <span class="keywordflow">switch</span> (p) {</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160; <span class="keywordflow">case</span> POS :</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; this-&gt;_pos = vec;</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; <span class="keywordflow">break</span>;</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160; <span class="keywordflow">case</span> VEL :</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span>&#160; this-&gt;_vel = vec;</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160; <span class="keywordflow">break</span>;</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; <span class="keywordflow">case</span> LOAD :</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; this-&gt;_load = vec;</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160; <span class="keywordflow">break</span>;</div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; <span class="keywordflow">default</span>:</div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160; <span class="keywordflow">break</span>;</div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160; }</div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160; }</div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span>&#160; </div><div class="line"><a name="l00108"></a><span class="lineno"><a class="line" href="classTree_1_1Particle.html#ae4750d1d5cfcd897d9d63379a206483e"> 108</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classTree_1_1Particle.html#ae4750d1d5cfcd897d9d63379a206483e">update_vel_pos</a>()<span class="keyword"> override </span>{</div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>&#160; Type new_velocity = this-&gt;get(LOAD) * (<a class="code" href="constants_8hpp.html#a5400b1f2028d38732e4377be4f32b255">DELTA_T</a> / this-&gt;get_mass()) + this-&gt;get(VEL);</div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>&#160; Type new_position = new_velocity * <a class="code" href="constants_8hpp.html#a5400b1f2028d38732e4377be4f32b255">DELTA_T</a> + this-&gt;get(POS);</div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span>&#160; </div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span>&#160; this-&gt;set(VEL, new_velocity);</div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span>&#160; this-&gt;set(POS, new_position);</div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span>&#160; this-&gt;set(LOAD, Type());</div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span>&#160; }</div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span>&#160; </div><div class="line"><a name="l00122"></a><span class="lineno"><a class="line" href="classTree_1_1Particle.html#aeefc278f82fed8e7681c20fc5def377e"> 122</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classTree_1_1Particle.html#aeefc278f82fed8e7681c20fc5def377e">is_out_boundaries</a>(Type dim) {</div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span>&#160; Type pos = this-&gt;get(POS);</div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>&#160; </div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>&#160; <span class="keywordflow">if</span> (abs(pos.x) &gt; 0.5 * dim.x)</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span>&#160; <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>&#160; </div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>&#160; <span class="keywordflow">if</span> (abs(pos.y) &gt; 0.5 * dim.y)</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span>&#160; <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span>&#160; </div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>&#160;<span class="preprocessor">#if NB_DIM == DIM_3</span></div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>&#160; <span class="keywordflow">if</span> (abs(pos.z) &gt; 0.5 * dim.z)</div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>&#160; <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>&#160; <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>&#160; }</div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>&#160; </div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160; Type _pos; </div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160; Type _vel; </div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>&#160; Type _load; </div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>&#160; };</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>&#160;}</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>&#160; </div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>&#160; </div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>&#160;<span class="preprocessor">#endif //PHPC_NBODY_PARTICLE_HPP</span></div></div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aconstants_8hpp_html_a5400b1f2028d38732e4377be4f32b255"><div class="ttname"><a href="constants_8hpp.html#a5400b1f2028d38732e4377be4f32b255">DELTA_T</a></div><div class="ttdeci">#define DELTA_T</div><div class="ttdef"><b>Definition:</b> constants.hpp:45</div></div>
<div class="ttc" id="aclassTree_1_1Particle_html_aeefc278f82fed8e7681c20fc5def377e"><div class="ttname"><a href="classTree_1_1Particle.html#aeefc278f82fed8e7681c20fc5def377e">Tree::Particle::is_out_boundaries</a></div><div class="ttdeci">bool is_out_boundaries(Type dim)</div><div class="ttdef"><b>Definition:</b> Particle.hpp:122</div></div>
<div class="ttc" id="aclassTree_1_1AbstractType_html"><div class="ttname"><a href="classTree_1_1AbstractType.html">Tree::AbstractType</a></div><div class="ttdef"><b>Definition:</b> Tree.hpp:37</div></div>
<div class="ttc" id="aclassTree_1_1Particle_html"><div class="ttname"><a href="classTree_1_1Particle.html">Tree::Particle</a></div><div class="ttdef"><b>Definition:</b> Particle.hpp:40</div></div>
<div class="ttc" id="aTree_8hpp_html"><div class="ttname"><a href="Tree_8hpp.html">Tree.hpp</a></div></div>
<div class="ttc" id="aclassTree_1_1Particle_html_a68961ce42ef677f22eadcd528b86ef6c"><div class="ttname"><a href="classTree_1_1Particle.html#a68961ce42ef677f22eadcd528b86ef6c">Tree::Particle::set</a></div><div class="ttdeci">void set(property p, Type vec) override</div><div class="ttdef"><b>Definition:</b> Particle.hpp:89</div></div>
<div class="ttc" id="aclassTree_1_1Particle_html_ae4750d1d5cfcd897d9d63379a206483e"><div class="ttname"><a href="classTree_1_1Particle.html#ae4750d1d5cfcd897d9d63379a206483e">Tree::Particle::update_vel_pos</a></div><div class="ttdeci">void update_vel_pos() override</div><div class="ttdef"><b>Definition:</b> Particle.hpp:108</div></div>
<div class="ttc" id="aconstants_8hpp_html"><div class="ttname"><a href="constants_8hpp.html">constants.hpp</a></div></div>
<div class="ttc" id="anamespaceTree_html"><div class="ttname"><a href="namespaceTree.html">Tree</a></div></div>
<div class="ttc" id="aclassTree_1_1Particle_html_acf5241af5d99f4c9fc7a5108f682b583"><div class="ttname"><a href="classTree_1_1Particle.html#acf5241af5d99f4c9fc7a5108f682b583">Tree::Particle::Particle</a></div><div class="ttdeci">Particle(float mass=0.0f, Type pos=Type())</div><div class="ttdef"><b>Definition:</b> Particle.hpp:48</div></div>
<div class="ttc" id="anamespacestd_html"><div class="ttname"><a href="namespacestd.html">std</a></div></div>
<div class="ttc" id="aclassTree_1_1Particle_html_a9e9ca29ec750d707066e95318554928f"><div class="ttname"><a href="classTree_1_1Particle.html#a9e9ca29ec750d707066e95318554928f">Tree::Particle::get</a></div><div class="ttdeci">Type get(property p) override</div><div class="ttdef"><b>Definition:</b> Particle.hpp:66</div></div>
<div class="ttc" id="aVector_8hpp_html"><div class="ttname"><a href="Vector_8hpp.html">Vector.hpp</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.16
</small></address>
</body>
</html>

Event Timeline