Ice Sheet System Model  4.18
Code documentation
Functions
PointCloudFindNeighborsxt.cpp File Reference
#include "./PointCloudFindNeighborsx.h"
#include "../../shared/shared.h"

Go to the source code of this file.

Functions

void * PointCloudFindNeighborsxt (void *vpthread_handle)
 

Function Documentation

◆ PointCloudFindNeighborsxt()

void* PointCloudFindNeighborsxt ( void *  vpthread_handle)

Definition at line 8 of file PointCloudFindNeighborsxt.cpp.

8  {
9 
10  /*gate variables :*/
12  pthread_handle* handle=NULL;
13  int my_thread;
14  int num_threads;
15  double* x;
16  double* y;
17  int nods;
18  double mindistance;
20 
21  /*recover handle and gate: */
22  handle=(pthread_handle*)vpthread_handle;
24  my_thread=handle->id;
25  num_threads=handle->num;
26 
27  /*recover parameters :*/
28  x=gate->x;
29  y=gate->y;
30  nods=gate->nods;
31  mindistance=gate->mindistance;
32  flags=gate->flags;
33 
34  /*intermediary: */
35  int i,j;
36  int i0,i1;
37  double distance;
38  bool* already=NULL;
39 
40  /*allocate: */
41  already=xNewZeroInit<bool>(nods);
42 
43  /*partition loop across threads: */
44  PartitionRange(&i0,&i1,nods,num_threads,my_thread);
45 
46  /*Loop over the nodes*/
47  for (i=i0;i<i1;i++){
48 
49  /*display current iteration*/
50  if (my_thread==0 && fmod((double)i,(double)100)==0)
51  _printf_("\r loop progress: "<<setw(6)<<setprecision(2)<<double(i-i0)/double(i1-i0)*100<<"% ");
52 
53  distance=mindistance+100; //make sure initialization respects min distance criterion.
54  for (j=0;j<nods;j++){
55 
56  /*skip himself: */
57  if (j==i)continue;
58  distance=sqrt(pow(x[i]-x[j],2)+ pow(y[i]-y[j],2));
59 
60  if(distance<=mindistance){
61 
62  /*insert value and go to the next point*/
63  if(!already[i]) flags->SetValue(i,1,INS_VAL);
64  if(!already[j]) flags->SetValue(j,2,INS_VAL);
65  already[i]=true;
66  already[j]=true;
67  break;
68  }
69  }
70  }
71  if (my_thread==0)
72  _printf_("\r loop progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"% \n");
73 
74  /*Free ressources:*/
75  xDelete<bool>(already);
76 
77  return NULL;
78 }
pthread_handle::id
int id
Definition: issm_threads.h:12
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
PointCloudFindNeighborsThreadStruct::mindistance
double mindistance
Definition: PointCloudFindNeighborsx.h:20
pthread_handle::num
int num
Definition: issm_threads.h:13
IssmSeqVec< IssmPDouble >
IssmSeqVec::SetValue
void SetValue(int dof, doubletype value, InsMode mode)
Definition: IssmSeqVec.h:115
PointCloudFindNeighborsThreadStruct::x
double * x
Definition: PointCloudFindNeighborsx.h:17
PointCloudFindNeighborsThreadStruct::nods
int nods
Definition: PointCloudFindNeighborsx.h:19
pthread_handle
Definition: issm_threads.h:10
PointCloudFindNeighborsThreadStruct::y
double * y
Definition: PointCloudFindNeighborsx.h:18
PartitionRange
void PartitionRange(int *pi0, int *pi1, int num_el, int num_threads, int my_thread)
Definition: PartitionRange.cpp:13
INS_VAL
@ INS_VAL
Definition: toolkitsenums.h:14
PointCloudFindNeighborsThreadStruct
Definition: PointCloudFindNeighborsx.h:15
pthread_handle::gate
void * gate
Definition: issm_threads.h:11
PointCloudFindNeighborsThreadStruct::flags
IssmSeqVec< IssmPDouble > * flags
Definition: PointCloudFindNeighborsx.h:21