Ice Sheet System Model  4.18
Code documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Data Structures | Functions
ContourToMeshx.h File Reference
#include "../../shared/shared.h"
#include "../../classes/classes.h"

Go to the source code of this file.

Data Structures

struct  ContourToMeshxThreadStruct
 

Functions

int ContourToMeshx (double **pin_nods, double **pin_elem, double *index, double *x, double *y, Contours *contours, char *interptype, int nel, int nods, int edgevalue)
 
void * ContourToMeshxt (void *vContourToMeshxThreadStruct)
 

Function Documentation

◆ ContourToMeshx()

int ContourToMeshx ( double **  pin_nods,
double **  pin_elem,
double *  index,
double *  x,
double *  y,
Contours contours,
char *  interptype,
int  nel,
int  nods,
int  edgevalue 
)

Definition at line 12 of file ContourToMeshx.cpp.

12  {
13 
14  /*Contour:*/
15  double value;
16 
17  /*output: */
18  double* in_nod;
19  double* in_elem;
20  in_nod = xNewZeroInit<double>(nods);
21  in_elem = xNewZeroInit<double>(nel);
22 
23  /*initialize thread parameters: */
25  gate.contours = contours;
26  gate.nods = nods;
27  gate.edgevalue = edgevalue;
28  gate.in_nod = in_nod;
29  gate.x = x;
30  gate.y = y;
31 
32  /*launch the thread manager with ContourToMeshxt as a core: */
33  LaunchThread(ContourToMeshxt,(void*)&gate,_NUMTHREADS_);
34 
35  /*Take care of the case where an element interpolation has been requested: */
36  if ((strcmp(interptype,"element")==0) || (strcmp(interptype,"element and node")==0)){
37  for(int n=0;n<nel;n++){
38  if ( (in_nod[ (int)*(index+3*n+0) -1] == 1) && (in_nod[ (int)*(index+3*n+1) -1] == 1) && (in_nod[ (int)*(index+3*n+2) -1] == 1) ){
39  value=1.; in_elem[n]=value;
40  }
41  }
42  }
43 
44  /*Assign output pointers: */
45  *pin_nod=in_nod;
46  *pin_elem=in_elem;
47 
48  return 1;
49 }

◆ ContourToMeshxt()

void* ContourToMeshxt ( void *  vContourToMeshxThreadStruct)

Definition at line 13 of file ContourToMeshxt.cpp.

13  {
14 
15  /*gate variables :*/
16  ContourToMeshxThreadStruct *gate = NULL;
17  pthread_handle *handle = NULL;
18  int i,i1,i0;
19 
20  /*recover handle and gate: */
21  handle = (pthread_handle*)vpthread_handle;
22  gate = (ContourToMeshxThreadStruct*)handle->gate;
23  int my_thread = handle->id;
24  int num_threads = handle->num;
25 
26  /*recover parameters :*/
27  Contours* contours = gate->contours;
28  int nods = gate->nods;
29  int edgevalue = gate->edgevalue;
30  double *in_nod = gate->in_nod;
31  double *x = gate->x;
32  double *y = gate->y;
33 
34  /*distribute indices across threads :*/
35  PartitionRange(&i0,&i1,nods,num_threads,my_thread);
36 
37  /*Loop through all contours: */
38  for (i=0;i<contours->Size();i++){
39  Contour<double>* contour=(Contour<double>*)contours->GetObjectByOffset(i);
40  IsInPoly(in_nod,contour->x,contour->y,contour->nods,x,y,i0,i1,edgevalue);
41  }
42 
43  return NULL;
44 }
ContourToMeshxt
void * ContourToMeshxt(void *vContourToMeshxThreadStruct)
Definition: ContourToMeshxt.cpp:13
pthread_handle::id
int id
Definition: issm_threads.h:12
ContourToMeshxThreadStruct::contours
Contours * contours
Definition: ContourToMeshx.h:14
LaunchThread
void LaunchThread(void *function(void *), void *gate, int num_threads)
Definition: LaunchThread.cpp:25
pthread_handle::num
int num
Definition: issm_threads.h:13
Contours
Declaration of Contours class.
Definition: Contours.h:10
Contour
Definition: Contour.h:15
ContourToMeshxThreadStruct
Definition: ContourToMeshx.h:12
pthread_handle
Definition: issm_threads.h:10
ContourToMeshxThreadStruct::edgevalue
int edgevalue
Definition: ContourToMeshx.h:16
ContourToMeshxThreadStruct::nods
int nods
Definition: ContourToMeshx.h:15
PartitionRange
void PartitionRange(int *pi0, int *pi1, int num_el, int num_threads, int my_thread)
Definition: PartitionRange.cpp:13
Contour::nods
int nods
Definition: Contour.h:20
ContourToMeshxThreadStruct::x
double * x
Definition: ContourToMeshx.h:18
ContourToMeshxThreadStruct::y
double * y
Definition: ContourToMeshx.h:19
Contour::y
doubletype * y
Definition: Contour.h:22
Contour::x
doubletype * x
Definition: Contour.h:21
pthread_handle::gate
void * gate
Definition: issm_threads.h:11
ContourToMeshxThreadStruct::in_nod
double * in_nod
Definition: ContourToMeshx.h:17
IsInPoly
int IsInPoly(doubletype *in, double *xc, double *yc, int numvertices, double *x, double *y, int i0, int i1, int edgevalue)
Definition: exp.h:17