/*!\file IsInPoly.c * \brief: from a contour, determine which nodes are in domain. */ #include #include "../../toolkits/toolkits.h" #include "./exp.h" #include "../shared.h" #ifdef HAVE_CONFIG_H #include "config.h" #else #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" #endif int IsInPoly(Vec in,double* xc,double* yc,int numgrids,double* x,double* y,int i0,int i1, int edgevalue){ int i; double x0,y0; double value; double xmin=xc[0]; double xmax=xc[0]; double ymin=yc[0]; double ymax=yc[0]; /*Get extrema*/ for (i=1;ixmax) xmax=xc[i]; if(yc[i]ymax) ymax=yc[i]; } /*Go through all grids of the mesh:*/ for (i=i0;i do not change it if != 0 VecGetValues(in,1,&i,&value); if (value){ /*this grid already is inside one of the contours, continue*/ continue; } /*pick up grid (x[i],y[i]) and figure out if located inside contour (xc,yc)*/ x0=x[i]; y0=y[i]; if(x0xmax || y0ymax){ value=0; } else{ value=pnpoly(numgrids,xc,yc,x0,y0,edgevalue); } VecSetValues(in,1,&i,&value,INSERT_VALUES); } return 1; } int IsOutsidePoly(Vec out,double* xc,double* yc,int numgrids,double* x,double* y,int nods,int edgevalue){ int i,j; double x0,y0; double value; /*Go through all grids of the mesh:*/ for (i=MPI_Lowerrow(nods);i