1 | /*! \file ContourToMeshx.c
|
---|
2 | */
|
---|
3 |
|
---|
4 | #include "./ContourToMeshx.h"
|
---|
5 |
|
---|
6 | #undef __FUNCT__
|
---|
7 | #define __FUNCT__ "ContourToMeshx"
|
---|
8 |
|
---|
9 | int ContourToMeshx( Vec* pin_nod,Vec* pin_elem, double* index, double* x, double* y,Contour** contours,int numcontours,char* interptype,int nel,int nods, int edgevalue) {
|
---|
10 |
|
---|
11 | int noerr=1;
|
---|
12 | int i;
|
---|
13 | int m,n;
|
---|
14 |
|
---|
15 | /*Contour:*/
|
---|
16 | Contour* contouri=NULL;
|
---|
17 | int numgrids;
|
---|
18 | double* xc=NULL;
|
---|
19 | double* yc=NULL;
|
---|
20 | double* in_nod_serial;
|
---|
21 | double value;
|
---|
22 |
|
---|
23 | /*output: */
|
---|
24 | Vec in_nod=NULL;
|
---|
25 | Vec in_elem=NULL;
|
---|
26 |
|
---|
27 | in_nod=NewVec(nods);
|
---|
28 | in_elem=NewVec(nel);
|
---|
29 |
|
---|
30 | /*Loop through all contours: */
|
---|
31 | for (i=0;i<numcontours;i++){
|
---|
32 | #ifdef _DEBUG_
|
---|
33 | printf("\nHandling contour %i/%i\n",i,numcontours);
|
---|
34 | #endif
|
---|
35 | contouri=*(contours+i);
|
---|
36 | numgrids=contouri->nods;
|
---|
37 | xc=contouri->x;
|
---|
38 | yc=contouri->y;
|
---|
39 | IsInPoly(in_nod,xc,yc,numgrids,x,y,nods,edgevalue);
|
---|
40 | }
|
---|
41 |
|
---|
42 | /*Get in_nod serialised for next operation: */
|
---|
43 | VecToMPISerial(&in_nod_serial,in_nod);
|
---|
44 |
|
---|
45 | /*Take care of the case where an element interpolation has been requested: */
|
---|
46 | if ((strcmp(interptype,"element")==0) || (strcmp(interptype,"element and node")==0)){
|
---|
47 | for (n=0;n<nel;n++){
|
---|
48 | if ( (in_nod_serial[ (int)*(index+3*n+0) -1] == 1) && (in_nod_serial[ (int)*(index+3*n+1) -1] == 1) && (in_nod_serial[ (int)*(index+3*n+2) -1] == 1) ){
|
---|
49 | value=1; VecSetValues(in_elem,1,&n,&value,INSERT_VALUES);
|
---|
50 | }
|
---|
51 | }
|
---|
52 | }
|
---|
53 |
|
---|
54 | /*Assemble vectors: */
|
---|
55 | VecAssemblyBegin(in_nod);
|
---|
56 | VecAssemblyEnd(in_nod);
|
---|
57 | VecAssemblyBegin(in_elem);
|
---|
58 | VecAssemblyEnd(in_elem);
|
---|
59 |
|
---|
60 | /*Assign output pointers: */
|
---|
61 | *pin_nod=in_nod;
|
---|
62 | *pin_elem=in_elem;
|
---|
63 |
|
---|
64 | /*Free ressources:*/
|
---|
65 | xfree((void**)&in_nod_serial);
|
---|
66 |
|
---|
67 | return noerr;
|
---|
68 | }
|
---|