How to get position of floating particles
I am reading through to understand the source code for DualSPHysics. Can someone help me understand where the positions of the floating particles are stored. Where I think the variables are stored do not give me the values I would expect to see. I added a few print statements just after the for loop at line 940 of JSphCpuSingle.cpp. below is the full modified loop.
int fxav = 0;
int fyav = 0;
int fzav = 0;
int psize = 0;
for(unsigned fp=fpini;fp<fpfin;fp++){
printf("Particle: %d x: %f y:%f z:%f\n",fp,Posc[fp].x, Posc[fp].y, Posc[fp].z);
fxav += Posc[fp].x;
fyav += Posc[fp].y;
fzav += Posc[fp].z;
psize++;
const int p=FtRidp[fp];
if(p!=UINT_MAX){
tfloat4 *velrhop=Velrhopc+p;
//-Compute and record position displacement. | Calcula y graba desplazamiento de posicion.
const double dx=dt*double(velrhop->x);
const double dy=dt*double(velrhop->y);
const double dz=dt*double(velrhop->z);
UpdatePos(Posc[p],dx,dy,dz,false,p,Posc,Dcellc,Codec);
//-Compute and record new velocity. | Calcula y graba nueva velocidad.
tfloat3 dist=(PeriActive? FtPeriodicDist(Posc[p],fcenter,fradius): ToTFloat3(Posc[p]-fcenter));
velrhop->x=fvel.x+(fomega.y*dist.z-fomega.z*dist.y);
velrhop->y=fvel.y+(fomega.z*dist.x-fomega.x*dist.z);
velrhop->z=fvel.z+(fomega.x*dist.y-fomega.y*dist.x);
}
}
fxav = fxav/psize;
fyav = fyav/psize;
fzav = fzav/psize;
printf("Average Floating Particle Position: \n x: %f y: %f z: %f\n",fxav, fyav, fzav);
Here is the output:
Particle: 0 x: -0.500000 y:-0.500000 z:-0.250000
Particle: 1 x: -0.500000 y:-0.500000 z:-0.240000
Particle: 2 x: -0.500000 y:-0.500000 z:-0.230000
Particle: 3 x: -0.500000 y:-0.500000 z:-0.220000
Particle: 4 x: -0.500000 y:-0.490000 z:-0.250000
.......
Particle: 176 x: -0.270000 y:-0.470000 z:-0.250000
Particle: 177 x: -0.260000 y:-0.500000 z:-0.250000
Particle: 178 x: -0.260000 y:-0.500000 z:-0.240000
Average Floating Particle Position:
x: -0.260000 y: -0.500000 z: -0.240000
Here is a snippit of my case setup that shows sphere and floating settings:
<setmkbound mk="2"/>
<setdrawmode mode="full"/>
<drawsphere radius="0.025" objname="Sphere">
<point x="0.3" y="-0.3" z="0.0" />
</drawsphere>
<shapeout file="" />
</mainlist>
</commands>
</geometry>
<floatings>
<floating mkbound="2" rhopbody="800.0">
</floating>
</floatings>
So... the average position of the floating ball should be around .3 in the x and -.3 in the y, but this is not that values I am getting at the start of the sim. How do I figure out the position of the floating particles? can anyone give me some guidance? Obviously my understanding is wrong.
Debug Trace
Notice |
rich is deprecated. Use FormatService::renderHtml($content, Formats\RichFormat::FORMAT_KEY) instead. #0 [internal function]: gdn_ErrorHandler(16384, 'rich is depreca...', '/var/www/forums...', 950, Array) #1 /var/www/forums-dual-sphysics-org/library/core/functions.general.php(950): trigger_error('rich is depreca...', 16384) #2 /var/www/forums-dual-sphysics-org/library/core/class.format.php(1729): deprecated('rich', 'FormatService::...') #3 /var/www/forums-dual-sphysics-org/library/core/class.format.php(1479): Gdn_Format::rich('[{"insert":"I a...') #4 /var/www/forums-dual-sphysics-org/applications/vanilla/controllers/class.discussioncontroller.php(197): Gdn_Format::to('[{"insert":"I a...', 'Rich') #5 /var/www/forums-dual-sphysics-org/library/core/class.dispatcher.php(862): DiscussionController->index('2148', 'how-to-get-posi...', '') #6 /var/www/forums-dual-sphysics-org/library/core/class.dispatcher.php(279): Gdn_Dispatcher->dispatchController(Object(Gdn_Request), Array) #7 /var/www/forums-dual-sphysics-org/index.php(29): Gdn_Dispatcher->dispatch() #8 {main} |
Notice |
rich is deprecated. Use FormatService::renderHtml($content, Formats\RichFormat::FORMAT_KEY) instead. #0 [internal function]: gdn_ErrorHandler(16384, 'rich is depreca...', '/var/www/forums...', 950, Array) #1 /var/www/forums-dual-sphysics-org/library/core/functions.general.php(950): trigger_error('rich is depreca...', 16384) #2 /var/www/forums-dual-sphysics-org/library/core/class.format.php(1729): deprecated('rich', 'FormatService::...') #3 /var/www/forums-dual-sphysics-org/library/core/class.format.php(1479): Gdn_Format::rich('[{"insert":"I a...') #4 /var/www/forums-dual-sphysics-org/applications/vanilla/views/discussion/helper_functions.php(24): Gdn_Format::to('[{"insert":"I a...', 'Rich') #5 /var/www/forums-dual-sphysics-org/applications/vanilla/views/discussion/discussion.php(89): formatBody(Object(stdClass)) #6 /var/www/forums-dual-sphysics-org/applications/vanilla/views/discussion/index.php(31): include('/var/www/forums...') #7 /var/www/forums-dual-sphysics-org/library/core/class.controller.php(778): include('/var/www/forums...') #8 /var/www/forums-dual-sphysics-org/library/core/class.controller.php(1382): Gdn_Controller->fetchView('', false, false) #9 /var/www/forums-dual-sphysics-org/library/core/class.pluggable.php(217): Gdn_Controller->xRender() #10 /var/www/forums-dual-sphysics-org/applications/vanilla/controllers/class.discussioncontroller.php(310): Gdn_Pluggable->__call('render', Array) #11 /var/www/forums-dual-sphysics-org/library/core/class.dispatcher.php(862): DiscussionController->index('2148', 'how-to-get-posi...', '') #12 /var/www/forums-dual-sphysics-org/library/core/class.dispatcher.php(279): Gdn_Dispatcher->dispatchController(Object(Gdn_Request), Array) #13 /var/www/forums-dual-sphysics-org/index.php(29): Gdn_Dispatcher->dispatch() #14 {main} |
Notice |
rich is deprecated. Use FormatService::renderHtml($content, Formats\RichFormat::FORMAT_KEY) instead. #0 [internal function]: gdn_ErrorHandler(16384, 'rich is depreca...', '/var/www/forums...', 950, Array) #1 /var/www/forums-dual-sphysics-org/library/core/functions.general.php(950): trigger_error('rich is depreca...', 16384) #2 /var/www/forums-dual-sphysics-org/library/core/class.format.php(1729): deprecated('rich', 'FormatService::...') #3 /var/www/forums-dual-sphysics-org/library/core/class.format.php(1479): Gdn_Format::rich('[{"insert":"Ok ...') #4 /var/www/forums-dual-sphysics-org/applications/vanilla/views/discussion/helper_functions.php(24): Gdn_Format::to('[{"insert":"Ok ...', 'Rich') #5 /var/www/forums-dual-sphysics-org/applications/vanilla/views/discussion/helper_functions.php(170): formatBody(Object(stdClass)) #6 /var/www/forums-dual-sphysics-org/applications/vanilla/views/discussion/comments.php(19): writeComment(Object(stdClass), Object(DiscussionController), Object(Gdn_Session), 1) #7 /var/www/forums-dual-sphysics-org/applications/vanilla/views/discussion/index.php(53): include('/var/www/forums...') #8 /var/www/forums-dual-sphysics-org/library/core/class.controller.php(778): include('/var/www/forums...') #9 /var/www/forums-dual-sphysics-org/library/core/class.controller.php(1382): Gdn_Controller->fetchView('', false, false) #10 /var/www/forums-dual-sphysics-org/library/core/class.pluggable.php(217): Gdn_Controller->xRender() #11 /var/www/forums-dual-sphysics-org/applications/vanilla/controllers/class.discussioncontroller.php(310): Gdn_Pluggable->__call('render', Array) #12 /var/www/forums-dual-sphysics-org/library/core/class.dispatcher.php(862): DiscussionController->index('2148', 'how-to-get-posi...', '') #13 /var/www/forums-dual-sphysics-org/library/core/class.dispatcher.php(279): Gdn_Dispatcher->dispatchController(Object(Gdn_Request), Array) #14 /var/www/forums-dual-sphysics-org/index.php(29): Gdn_Dispatcher->dispatch() #15 {main} |
Notice |
rich is deprecated. Use FormatService::renderHtml($content, Formats\RichFormat::FORMAT_KEY) instead. #0 [internal function]: gdn_ErrorHandler(16384, 'rich is depreca...', '/var/www/forums...', 950, Array) #1 /var/www/forums-dual-sphysics-org/library/core/functions.general.php(950): trigger_error('rich is depreca...', 16384) #2 /var/www/forums-dual-sphysics-org/library/core/class.format.php(1729): deprecated('rich', 'FormatService::...') #3 /var/www/forums-dual-sphysics-org/library/core/class.format.php(1479): Gdn_Format::rich('[{"insert":"The...') #4 /var/www/forums-dual-sphysics-org/applications/vanilla/views/discussion/helper_functions.php(24): Gdn_Format::to('[{"insert":"The...', 'Rich') #5 /var/www/forums-dual-sphysics-org/applications/vanilla/views/discussion/helper_functions.php(170): formatBody(Object(stdClass)) #6 /var/www/forums-dual-sphysics-org/applications/vanilla/views/discussion/comments.php(19): writeComment(Object(stdClass), Object(DiscussionController), Object(Gdn_Session), 2) #7 /var/www/forums-dual-sphysics-org/applications/vanilla/views/discussion/index.php(53): include('/var/www/forums...') #8 /var/www/forums-dual-sphysics-org/library/core/class.controller.php(778): include('/var/www/forums...') #9 /var/www/forums-dual-sphysics-org/library/core/class.controller.php(1382): Gdn_Controller->fetchView('', false, false) #10 /var/www/forums-dual-sphysics-org/library/core/class.pluggable.php(217): Gdn_Controller->xRender() #11 /var/www/forums-dual-sphysics-org/applications/vanilla/controllers/class.discussioncontroller.php(310): Gdn_Pluggable->__call('render', Array) #12 /var/www/forums-dual-sphysics-org/library/core/class.dispatcher.php(862): DiscussionController->index('2148', 'how-to-get-posi...', '') #13 /var/www/forums-dual-sphysics-org/library/core/class.dispatcher.php(279): Gdn_Dispatcher->dispatchController(Object(Gdn_Request), Array) #14 /var/www/forums-dual-sphysics-org/index.php(29): Gdn_Dispatcher->dispatch() #15 {main} |
Comments
Ok I Figured out how to get the centre of a floating object... It is given in FtObjs[cf].center...
The post-processing tool FloatingInfo already gives you all that information