Changeset 13220
- Timestamp:
- 09/02/12 01:29:13 (13 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 4 deleted
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Makefile.am
r13216 r13220 46 46 ./classes/objects/Load.h\ 47 47 ./classes/objects/Contour.h\ 48 ./classes/objects/Contour.cpp\49 48 ./classes/objects/OptArgs.h\ 50 49 ./classes/objects/OptPars.h\ … … 62 61 ./classes/objects/Node.cpp\ 63 62 ./classes/objects/Segment.h\ 64 ./classes/objects/Segment.cpp\65 63 ./classes/objects/Vertex.h\ 66 64 ./classes/objects/Vertex.cpp\ … … 311 309 ./modules/UpdateConstraintsx/UpdateConstraintsx.h\ 312 310 ./modules/UpdateConstraintsx/UpdateConstraintsx.cpp\ 313 ./modules/MeshPartitionx/MeshPartitionx.cpp\314 311 ./modules/MeshPartitionx/MeshPartitionx.h\ 315 312 ./modules/Reducevectorgtofx/Reducevectorgtofx.cpp\ … … 844 841 ./shared/Exp/IsInPoly.cpp\ 845 842 ./shared/Exp/IsInPolySerial.cpp\ 846 ./shared/Exp/DomainOutlineRead.cpp\847 843 ./shared/Exp/DomainOutlineWrite.cpp\ 848 844 ./shared/TriMesh/trimesh.h\ … … 1014 1010 libISSMModules_a_SOURCES = $(module_sources) 1015 1011 libISSMModules_a_SOURCES += $(bamg_sources) 1012 if KRIGING 1016 1013 libISSMModules_a_SOURCES += $(kriging_sources) 1014 endif 1015 if KML 1017 1016 libISSMModules_a_SOURCES += $(kml_sources) 1017 endif 1018 1018 libISSMModules_a_CXXFLAGS = $(ALLCXXFLAGS) 1019 1019 libISSMModules_a_LIBADD = ./libISSMCore.a -
issm/trunk-jpl/src/c/classes/matrix/Matrix.h
r13216 r13220 78 78 /*FUNCTION Matrix(int M,int N,IssmDouble sparsity,int in_type){{{*/ 79 79 #ifdef _HAVE_PETSC_ 80 Matrix(int M,int N, IssmDouble sparsity,int in_type=PetscMatType){80 Matrix(int M,int N,double sparsity,int in_type=PetscMatType){ 81 81 #else 82 Matrix(int M,int N, IssmDouble sparsity,int in_type=SeqMatType){82 Matrix(int M,int N,double sparsity,int in_type=SeqMatType){ 83 83 #endif 84 84 … … 105 105 /*FUNCTION Matrix(IssmDouble* serial_mat, int M,int N,IssmDouble sparsity,int in_type){{{*/ 106 106 #ifdef _HAVE_PETSC_ 107 Matrix(Issm Double* serial_mat,int M,int N,IssmDouble sparsity,int in_type=PetscMatType){107 Matrix(IssmPDouble* serial_mat,int M,int N,IssmPDouble sparsity,int in_type=PetscMatType){ 108 108 #else 109 Matrix(Issm Double* serial_mat,int M,int N,IssmDouble sparsity,int in_type=SeqMatType){109 Matrix(IssmPDouble* serial_mat,int M,int N,IssmPDouble sparsity,int in_type=SeqMatType){ 110 110 #endif 111 111 -
issm/trunk-jpl/src/c/classes/objects/Contour.h
r12832 r13220 8 8 /*Headers:*/ 9 9 /*{{{*/ 10 #include "../../include/include.h" 11 #include "../../shared/Exceptions/exceptions.h" 12 #include "../../shared/Alloc/xNewDelete.h" 13 #include "../../shared/MemOps/xMemCpy.h" 14 #include "../../io/io.h" 15 #include "../../EnumDefinitions/EnumDefinitions.h" 10 16 #include "./Object.h" 11 #include "../../shared/Exceptions/exceptions.h"12 #include "../../toolkits/toolkits.h"13 #include "../../include/include.h"14 17 /*}}}*/ 15 18 19 template <class doubletype> 16 20 class Contour: public Object{ 17 21 … … 20 24 int id; 21 25 int nods; //number of vertices in the contour 22 IssmDouble* x;23 IssmDouble* y;26 doubletype* x; 27 doubletype* y; 24 28 bool closed; //is this contour closed? 25 29 26 /*Contour constructors, destructors {{{*/ 27 Contour(); 28 Contour(int id, int nods, IssmDouble* x, IssmDouble* y,bool closed); 29 ~Contour(); 30 /*Contour constructors, destructors :*/ 31 /*FUNCTION Contour() default constructor {{{*/ 32 Contour(){ 33 this->id=0; 34 this->nods=0; 35 this->x=NULL; 36 this->y=NULL; 37 this->closed=false; 38 } 30 39 /*}}}*/ 31 /*Object virtual functions{{{*/ 32 void Echo(void); 33 void DeepEcho(void); 34 int Id(void); 35 int MyRank(void); 36 int ObjectEnum(void); 37 Object* copy(void); 40 /*FUNCTION Contour(int pid, int nods, doubletype* x, doubletype* y,bool closed) {{{*/ 41 Contour(int pid,int pnods, doubletype* px, doubletype* py,bool pclosed){ 42 43 this->id=pid; 44 this->nods=pnods; 45 this->closed=pclosed; 46 if(nods){ 47 this->x=xNew<doubletype>(nods); 48 xMemCpy<doubletype>(this->x,px,nods); 49 this->y=xNew<doubletype>(nods); 50 xMemCpy<doubletype>(this->y,py,nods); 51 } 52 } 53 /*}}}*/ 54 /*FUNCTION Contour() default constructor {{{*/ 55 ~Contour(){ 56 xDelete<doubletype>(this->x); 57 xDelete<doubletype>(this->y); 58 } 38 59 /*}}}*/ 39 60 40 61 62 /*Object virtual function resolutoin: */ 63 /*FUNCTION Echo(){{{*/ 64 void Echo(void){ 65 66 int i; 67 68 _printLine_("Contour: " << id); 69 _printLine_(" nods: " << nods); 70 _printLine_(" closed: " << (closed?"true":"false")); 71 if(nods){ 72 _printLine_(" x,y:"); 73 for(i=0;i<nods;i++){ 74 _printLine_(i << ": " << x[i] << "|" << y[i]); 75 } 76 } 77 } 78 /*}}}*/ 79 /*FUNCTION DeepEcho(){{{*/ 80 void DeepEcho(void){ 81 this->Echo(); 82 } 83 /*}}}*/ 84 /*FUNCTION Id(){{{*/ 85 int Id(void){ 86 return id; 87 } 88 /*}}}*/ 89 /*FUNCTION MyRank{{{*/ 90 int MyRank(void){ 91 extern int my_rank; 92 93 return my_rank; 94 } 95 /*}}}*/ 96 /*FUNCTION ObjectEnum{{{*/ 97 int ObjectEnum(void){ 98 99 return ContourEnum; 100 101 } 102 /*}}}*/ 103 /*FUNCTION copy {{{*/ 104 Object* copy() { 105 106 return new Contour(*this); 107 108 } 109 /*}}}*/ 41 110 }; 42 111 -
issm/trunk-jpl/src/c/classes/objects/Segment.h
r12821 r13220 11 11 /*}}}*/ 12 12 13 template <class doubletype> 13 14 class Segment: public Object{ 14 15 15 16 public: 16 17 int eid; 17 IssmDouble x1;18 IssmDouble y1;19 IssmDouble x2;20 IssmDouble y2;18 doubletype x1; 19 doubletype y1; 20 doubletype x2; 21 doubletype y2; 21 22 22 /*Segment constructors, destructors {{{*/ 23 Segment(); 24 Segment(int eid,IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2); 25 ~Segment(); 23 24 /*Segment constructors, destructors :*/ 25 /*FUNCTION Segment() default constructor {{{*/ 26 Segment(){ 27 this->eid=UNDEF; 28 this->x1=UNDEF; 29 this->y1=UNDEF; 30 this->x2=UNDEF; 31 this->y2=UNDEF; 32 } 26 33 /*}}}*/ 27 /*Object virtual functions definitions:{{{ */ 28 void Echo(); 29 void DeepEcho(); 30 int Id(); 31 int MyRank(); 32 int ObjectEnum(); 33 Object* copy(); 34 /*FUNCTION Segment(int eid, doubletype x1,doubletype y1,doubletype x2, doubletype y2){{{*/ 35 Segment(int segment_eid, doubletype segment_x1,doubletype segment_y1,doubletype segment_x2, doubletype segment_y2){ 36 37 this->eid=segment_eid; 38 this->x1=segment_x1; 39 this->y1=segment_y1; 40 this->x2=segment_x2; 41 this->y2=segment_y2; 42 43 } 34 44 /*}}}*/ 45 /*FUNCTION ~Segment(){{{*/ 46 ~Segment(){ 47 } 48 /*}}}*/ 49 50 /*Object virtual functions definitions:*/ 51 /*FUNCTION Echo{{{*/ 52 void Echo(void){ 53 54 _printLine_("Segment:"); 55 _printLine_(" eid: " << eid); 56 _printLine_(" node 1: " << this->x1 << "|" << this->y1); 57 _printLine_(" node 2: " << this->x2 << "|" << this->y2); 58 59 } 60 /*}}}*/ 61 /*FUNCTION DeepEcho{{{*/ 62 void DeepEcho(void){ 63 this->Echo(); 64 } 65 /*}}}*/ 66 /*FUNCTION Id{{{*/ 67 int Id(void){ return eid; } 68 /*}}}*/ 69 /*FUNCTION MyRank{{{*/ 70 int MyRank(void){ 71 extern int my_rank; 72 73 return my_rank; 74 } 75 /*}}}*/ 76 /*FUNCTION ObjectEnum{{{*/ 77 int ObjectEnum(void){ 78 79 return SegmentEnum; 80 81 } 82 /*}}}*/ 83 /*FUNCTION copy {{{*/ 84 Object* copy() { 85 return new Segment(this->eid,this->x1,this->y1,this->x2,this->y2); 86 87 } 88 89 /*}}}*/ 90 35 91 }; 36 92 -
issm/trunk-jpl/src/c/modules/AddExternalResultx/AddExternalResultx.cpp
r12832 r13220 9 9 #include "../../classes/objects/objects.h" 10 10 11 void AddExternalResultx( DataSet* results, int enumtype, double value){11 void AddExternalResultx( DataSet* results, int enumtype, IssmDouble value){ 12 12 /* Add new result in into results*/ 13 13 results->AddObject(new DoubleExternalResult(results->Size()+1,enumtype,value,1,0)); 14 14 } 15 void AddExternalResultx( DataSet* results, int enumtype, double* value, int nraws){15 void AddExternalResultx( DataSet* results, int enumtype, IssmDouble* value, int nraws){ 16 16 /* Add new result in into results*/ 17 17 results->AddObject(new DoubleVecExternalResult(results->Size()+1,enumtype,value,nraws,1,0)); -
issm/trunk-jpl/src/c/modules/AddExternalResultx/AddExternalResultx.h
r4554 r13220 9 9 10 10 /* local prototypes: */ 11 void AddExternalResultx(DataSet* results, int type, double value);12 void AddExternalResultx(DataSet* results, int type, double* value, int nraws);11 void AddExternalResultx(DataSet* results, int type, IssmDouble value); 12 void AddExternalResultx(DataSet* results, int type, IssmDouble* value, int nraws); 13 13 14 14 #endif /* _ADDEXTERNALRESULT_H */ -
issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.cpp
r13216 r13220 11 11 #include "./ContourToMeshx.h" 12 12 13 int ContourToMeshx( Vector< IssmDouble>** pin_nod,Vector<IssmDouble>** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue) {13 int ContourToMeshx( Vector<double>** pin_nod,Vector<double>** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue) { 14 14 15 15 int noerr=1; … … 30 30 31 31 /*output: */ 32 Vector< IssmDouble>* in_nod=NULL;33 Vector< IssmDouble>* in_elem=NULL;32 Vector<double>* in_nod=NULL; 33 Vector<double>* in_elem=NULL; 34 34 35 in_nod=new Vector< IssmDouble>(nods);36 in_elem=new Vector< IssmDouble>(nel);35 in_nod=new Vector<double>(nods); 36 in_elem=new Vector<double>(nel); 37 37 38 38 /*initialize thread parameters: */ -
issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.h
r13216 r13220 16 16 int nods; 17 17 int edgevalue; 18 Vector< IssmDouble>* in_nod;18 Vector<double>* in_nod; 19 19 double* x; 20 20 double* y; … … 24 24 25 25 /* local prototypes: */ 26 int ContourToMeshx( Vector< IssmDouble>** pin_nods,Vector<IssmDouble>** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue);26 int ContourToMeshx( Vector<double>** pin_nods,Vector<double>** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue); 27 27 28 28 void* ContourToMeshxt(void* vContourToMeshxThreadStruct); -
issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp
r13216 r13220 33 33 double* x=NULL; 34 34 double* y=NULL; 35 Vector< IssmDouble>* in_nod=NULL;35 Vector<double>* in_nod=NULL; 36 36 37 37 … … 55 55 /*Loop through all contours: */ 56 56 for (i=0;i<contours->Size();i++){ 57 Contour * contour=(Contour*)contours->GetObjectByOffset(i);57 Contour<double>* contour=(Contour<double>*)contours->GetObjectByOffset(i); 58 58 IsInPoly(in_nod,contour->x,contour->y,contour->nods,x,y,i0,i1,edgevalue); 59 59 } -
issm/trunk-jpl/src/c/modules/ContourToNodesx/ContourToNodesx.cpp
r13216 r13220 4 4 #include "./ContourToNodesx.h" 5 5 6 int ContourToNodesx( Vector<Issm Double>** pflags,double* x, double* y, int nods, Contour** contours,int numcontours,int edgevalue){6 int ContourToNodesx( Vector<IssmPDouble>** pflags,double* x, double* y, int nods, Contour<IssmPDouble>** contours,int numcontours,int edgevalue){ 7 7 8 8 int i; … … 10 10 11 11 /*Contour:*/ 12 Contour * contouri=NULL;12 Contour<IssmPDouble>* contouri=NULL; 13 13 int numnodes; 14 14 double* xc=NULL; … … 17 17 18 18 /*output: */ 19 Vector<Issm Double>* flags=NULL;19 Vector<IssmPDouble>* flags=NULL; 20 20 21 flags=new Vector<Issm Double>(nods);21 flags=new Vector<IssmPDouble>(nods); 22 22 23 23 /*Loop through all contours: */ … … 39 39 } 40 40 41 int ContourToNodesx( Vector<Issm Double>** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue){41 int ContourToNodesx( Vector<IssmPDouble>** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue){ 42 42 43 43 int i; … … 45 45 46 46 /*Contour:*/ 47 Contour * contouri=NULL;47 Contour<IssmPDouble>* contouri=NULL; 48 48 int numnodes; 49 49 double* xc=NULL; … … 52 52 53 53 /*output: */ 54 Vector<Issm Double>* flags=NULL;54 Vector<IssmPDouble>* flags=NULL; 55 55 56 flags=new Vector<Issm Double>(nods);56 flags=new Vector<IssmPDouble>(nods); 57 57 58 58 /*Loop through all contours: */ 59 59 if(contours){ 60 60 for (i=0;i<contours->Size();i++){ 61 Contour * contour=(Contour*)contours->GetObjectByOffset(i);61 Contour<IssmPDouble>* contour=(Contour<IssmPDouble>*)contours->GetObjectByOffset(i); 62 62 IsInPoly(flags,contour->x,contour->y,contour->nods,x,y,0,nods,edgevalue); 63 63 } -
issm/trunk-jpl/src/c/modules/ContourToNodesx/ContourToNodesx.h
r13216 r13220 11 11 12 12 /* local prototypes: */ 13 int ContourToNodesx( Vector<Issm Double>** pflags,double* x, double* y, int nods, Contour** contours,int numcontours,int edgevalue);14 int ContourToNodesx( Vector<Issm Double>** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue);13 int ContourToNodesx( Vector<IssmPDouble>** pflags,double* x, double* y, int nods, Contour<IssmPDouble>** contours,int numcontours,int edgevalue); 14 int ContourToNodesx( Vector<IssmPDouble>** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue); 15 15 16 16 #endif /* _CONTOURTONODESX_H */ -
issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp
r13216 r13220 17 17 18 18 /*InterpFromGridToMeshx{{{*/ 19 int InterpFromGridToMeshx( Vector<Issm Double>** pdata_mesh,double* x_in, int x_rows, double* y_in, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods,double default_value, int interpenum){19 int InterpFromGridToMeshx( Vector<IssmPDouble>** pdata_mesh,double* x_in, int x_rows, double* y_in, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods,double default_value, int interpenum){ 20 20 21 21 /*output: */ 22 Vector<Issm Double>* data_mesh=NULL;22 Vector<IssmPDouble>* data_mesh=NULL; 23 23 24 24 /*Intermediary*/ … … 47 47 48 48 /*Allocate output vector: */ 49 data_mesh=new Vector<Issm Double>(nods);49 data_mesh=new Vector<IssmPDouble>(nods); 50 50 51 51 /*Find out what kind of coordinates (x_in,y_in) have been given is input*/ … … 127 127 double *y = gate->y; 128 128 int nods = gate->nods; 129 Vector<Issm Double>*data_mesh = gate->data_mesh;129 Vector<IssmPDouble>*data_mesh = gate->data_mesh; 130 130 double *data = gate->data; 131 131 double default_value = gate->default_value; … … 181 181 return NULL; /*WARNING: no error because it would blow up the multithreading!*/ 182 182 } 183 if(xIsNan<Issm Double>(data_value)) data_value=default_value;183 if(xIsNan<IssmPDouble>(data_value)) data_value=default_value; 184 184 } 185 185 else{ -
issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.h
r13216 r13220 24 24 double* x_mesh; 25 25 double* y_mesh; 26 Vector<Issm Double>* data_mesh;26 Vector<IssmPDouble>* data_mesh; 27 27 } InterpFromGridToMeshxThreadStruct; 28 28 29 int InterpFromGridToMeshx( Vector<Issm Double>** pdata_mesh,double* x, int x_rows, double* y, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods, double default_value, int interpenum=BilinearInterpEnum);29 int InterpFromGridToMeshx( Vector<IssmPDouble>** pdata_mesh,double* x, int x_rows, double* y, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods, double default_value, int interpenum=BilinearInterpEnum); 30 30 void* InterpFromGridToMeshxt(void* vInterpFromGridToMeshxThreadStruct); 31 31 bool findindices(int* pn,int* pm,double* x,int x_rows, double* y,int y_rows, double xgrid,double ygrid); -
issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp
r13216 r13220 10 10 #include "../modules.h" 11 11 12 int InterpFromMesh2dx( Vector<Issm Double>** pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime,13 double* default_values,int num_default_values,Contour ** contours,int numcontours){12 int InterpFromMesh2dx( Vector<IssmPDouble>** pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime, 13 double* default_values,int num_default_values,Contour<IssmPDouble>** contours,int numcontours){ 14 14 15 15 /*Output*/ 16 Vector<Issm Double>* data_prime=NULL;16 Vector<IssmPDouble>* data_prime=NULL; 17 17 18 18 /*Intermediary*/ … … 27 27 28 28 /*contours: */ 29 Vector<Issm Double>* vec_incontour=NULL;29 Vector<IssmPDouble>* vec_incontour=NULL; 30 30 double* incontour=NULL; 31 31 … … 71 71 72 72 /*Initialize output*/ 73 data_prime=new Vector<Issm Double>(nods_prime,false,SeqVecType);73 data_prime=new Vector<IssmPDouble>(nods_prime,false,SeqVecType); 74 74 if(num_default_values){ 75 75 if(num_default_values==1)for (i=0;i<nods_prime;i++) data_prime->SetValue(i,default_values[0],INS_VAL); -
issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.h
r13216 r13220 23 23 double ymin,ymax; 24 24 int nods_prime; 25 Vector<Issm Double>* data_prime;25 Vector<IssmPDouble>* data_prime; 26 26 double* x_prime; 27 27 double* y_prime; … … 33 33 } InterpFromMesh2dxThreadStruct; 34 34 35 int InterpFromMesh2dx( Vector<Issm Double>** pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime,36 double* default_values,int num_default_values,Contour ** contours,int numcontours);35 int InterpFromMesh2dx( Vector<IssmPDouble>** pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime, 36 double* default_values,int num_default_values,Contour<IssmPDouble>** contours,int numcontours); 37 37 38 38 void* InterpFromMesh2dxt(void* vInterpFromMesh2dxThreadStruct); -
issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp
r13216 r13220 32 32 double ymax = gate->ymax; 33 33 int nods_prime = gate->nods_prime; 34 Vector<Issm Double>* data_prime = gate->data_prime;34 Vector<IssmPDouble>* data_prime = gate->data_prime; 35 35 double *x_prime = gate->x_prime; 36 36 double *y_prime = gate->y_prime; … … 87 87 data_value=data[i]; 88 88 } 89 if (xIsNan<Issm Double>(data_value)){89 if (xIsNan<IssmPDouble>(data_value)){ 90 90 if(num_default_values==1) data_value=default_values[0]; 91 91 else data_value=default_values[j]; -
issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp
r13216 r13220 7 7 #include "../../include/include.h" 8 8 9 int InterpFromMeshToMesh3dx( Vector<Issm Double>** pdata_prime,double* index_data, double* x_data, double* y_data, double* z_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, double* z_prime, int nods_prime,double default_value) {9 int InterpFromMeshToMesh3dx( Vector<IssmPDouble>** pdata_prime,double* index_data, double* x_data, double* y_data, double* z_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, double* z_prime, int nods_prime,double default_value) { 10 10 11 11 /*Output*/ 12 Vector<Issm Double>* data_prime=NULL;12 Vector<IssmPDouble>* data_prime=NULL; 13 13 14 14 /*Intermediary*/ … … 54 54 55 55 /*Initialize output*/ 56 data_prime=new Vector<Issm Double>(nods_prime);56 data_prime=new Vector<IssmPDouble>(nods_prime); 57 57 for (i=0;i<nods_prime;i++) data_prime->SetValue(i,default_value,INS_VAL); 58 58 … … 124 124 data_value=data[i]; 125 125 } 126 if (xIsNan<Issm Double>(data_value)) data_value=default_value;126 if (xIsNan<IssmPDouble>(data_value)) data_value=default_value; 127 127 128 128 /*insert value and go to the next point*/ -
issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.h
r13216 r13220 9 9 #include "../../classes/objects/objects.h" 10 10 11 int InterpFromMeshToMesh3dx( Vector<Issm Double>** pdata_prime,double* index_data, double* x_data, double* y_data, double* z_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, double* z_prime, int nods_prime,double default_value);11 int InterpFromMeshToMesh3dx( Vector<IssmPDouble>** pdata_prime,double* index_data, double* x_data, double* y_data, double* z_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, double* z_prime, int nods_prime,double default_value); 12 12 13 13 #endif /* _INTERPFROMMESHTOMESH3DX_H */ -
issm/trunk-jpl/src/c/modules/MeshPartitionx/MeshPartitionx.h
r12470 r13220 7 7 8 8 #include "../../include/include.h" 9 #include "../../EnumDefinitions/EnumDefinitions.h" 10 9 11 10 12 /* local prototypes: */ 11 int MeshPartitionx(int** pepart, int** pnpart, int numberofelements,int numberofnodes,IssmDouble* elements, 12 int numberofelements2d,int numberofnodes2d,IssmDouble* elements2d,int numlayers,int elements_width, int dim,int numareas); 13 template <class doubletype> 14 int MeshPartitionx(int** pepart, int** pnpart, int numberofelements,int numberofnodes,doubletype* elements, 15 int numberofelements2d,int numberofnodes2d,doubletype* elements2d,int numlayers,int elements_width, int dim,int num_procs){ 16 17 int noerr=1; 18 int i,j; 19 20 /*Metis partitioning: */ 21 int* epart=NULL; 22 int* npart=NULL; 23 int* index=NULL; 24 25 int* epart2d=NULL; 26 int* npart2d=NULL; 27 int* index2d=NULL; 28 int count=0; 29 30 int etype=1; //tria mesh see metis/Programs/Io.c 31 int etype2d=1; //tria mesh see metis/Programs/Io.c 32 int numflag=0; 33 int edgecut=1; 34 35 if(dim==2){ 36 epart=xNew<int>(numberofelements); 37 npart=xNew<int>(numberofnodes); 38 index=xNew<int>(elements_width*numberofelements); 39 for (i=0;i<numberofelements;i++){ 40 for (j=0;j<elements_width;j++){ 41 *(index+elements_width*i+j)=reCast<int>(*(elements+elements_width*i+j))-1; //-1 for C indexing in Metis 42 } 43 } 44 45 /*Partition using Metis:*/ 46 if (num_procs>1){ 47 #ifdef _HAVE_METIS_ 48 METIS_PartMeshNodalPatch(&numberofelements,&numberofnodes, index, &etype, &numflag, &num_procs, &edgecut, epart, npart); 49 #endif 50 } 51 else if (num_procs==1){ 52 /*METIS does not know how to deal with one cpu only!*/ 53 for (i=0;i<numberofelements;i++) epart[i]=0; 54 for (i=0;i<numberofnodes;i++) npart[i]=0; 55 } 56 else _error_("At least one processor is required"); 57 } 58 else{ 59 /*We have a 3d mesh, made of a regularly extruded 2d mesh. We first partition the 2d mesh, then we extrude the partition: */ 60 61 /*First build concatenated 2d mesh from 2d_coll and 2d_noncoll: */ 62 epart2d=xNew<int>(numberofelements2d); 63 npart2d=xNew<int>(numberofnodes2d); 64 index2d=xNew<int>(3*numberofelements2d); 65 66 for (i=0;i<numberofelements2d;i++){ 67 for (j=0;j<3;j++){ 68 *(index2d+3*i+j)=reCast<int>(*(elements2d+3*i+j))-1; //-1 for C indexing in Metis 69 } 70 } 71 72 /*Partition using Metis:*/ 73 if (num_procs>1){ 74 #ifdef _HAVE_METIS_ 75 METIS_PartMeshNodalPatch(&numberofelements2d,&numberofnodes2d, index2d, &etype2d, &numflag, &num_procs, &edgecut, epart2d, npart2d); 76 #endif 77 } 78 else if (num_procs==1){ 79 /*METIS does not know how to deal with one cpu only!*/ 80 for (i=0;i<numberofelements2d;i++) epart2d[i]=0; 81 for (i=0;i<numberofnodes2d;i++) npart2d[i]=0; 82 } 83 else _error_("At least one processor is required"); 84 85 /*Extrude epart2d to epart, using numlayers: */ 86 epart=xNew<int>(numberofelements); 87 88 count=0; 89 for(i=0;i<(numlayers-1);i++){ 90 for(j=0;j<numberofelements2d;j++){ 91 epart[count]=epart2d[j]; 92 count++; 93 } 94 } 95 96 /*Extrude npart2d to npart, using numlayers: */ 97 npart=xNew<int>(numberofnodes); 98 99 count=0; 100 for(i=0;i<(numlayers);i++){ 101 for(j=0;j<numberofnodes2d;j++){ 102 npart[count]=npart2d[j]; 103 count++; 104 } 105 } 106 } 13 107 108 /*Assign output pointer:*/ 109 *pepart=epart; 110 *pnpart=npart; 111 112 /*Free ressources: */ 113 xDelete<int>(index); 114 xDelete<int>(epart2d); 115 xDelete<int>(npart2d); 116 xDelete<int>(index2d); 117 return noerr; 118 } 14 119 #endif /* _MESHPARTITIONX_H */ 15 120 -
issm/trunk-jpl/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp
r13056 r13220 55 55 yfinal[1]=ysegment[0]+coord2*(ysegment[1]-ysegment[0]); 56 56 57 segments_dataset->AddObject(new Segment (el+1,xfinal[0],yfinal[0],xfinal[1],yfinal[1]));57 segments_dataset->AddObject(new Segment<double>(el+1,xfinal[0],yfinal[0],xfinal[1],yfinal[1])); 58 58 } 59 59 else{ … … 83 83 yfinal[1]=ysegment[0]+coord2*(ysegment[1]-ysegment[0]); 84 84 85 segments_dataset->AddObject(new Segment (el+1,xfinal[0],yfinal[0],xfinal[1],yfinal[1]));85 segments_dataset->AddObject(new Segment<double>(el+1,xfinal[0],yfinal[0],xfinal[1],yfinal[1])); 86 86 } 87 87 else{ 88 88 /*No interesections, but the segment might be entirely inside this triangle!: */ 89 89 if ( (NodeInElement(xnodes,ynodes,xsegment[0],ysegment[0])) && (NodeInElement(xnodes,ynodes,xsegment[1],ysegment[1])) ){ 90 segments_dataset->AddObject(new Segment (el+1,xsegment[0],ysegment[0],xsegment[1],ysegment[1]));90 segments_dataset->AddObject(new Segment<double>(el+1,xsegment[0],ysegment[0],xsegment[1],ysegment[1])); 91 91 } 92 92 } -
issm/trunk-jpl/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp
r12450 r13220 4 4 #include "./MeshProfileIntersectionx.h" 5 5 6 void MeshProfileIntersectionx( double** psegments, int* pnumsegs, int* index, double* x, double* y, int nel, int nods, Contour ** contours,int numcontours){6 void MeshProfileIntersectionx( double** psegments, int* pnumsegs, int* index, double* x, double* y, int nel, int nods, Contour<IssmPDouble>** contours,int numcontours){ 7 7 8 8 int i,j,k; … … 10 10 11 11 /*Contour:*/ 12 Contour * contouri=NULL;12 Contour<IssmPDouble>* contouri=NULL; 13 13 int numnodes; 14 14 double* xc=NULL; -
issm/trunk-jpl/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.h
r12832 r13220 11 11 12 12 /* local prototypes: */ 13 void MeshProfileIntersectionx( double** psegments, int* pnumseg, int* index, double* x, double* y, int nel, int nods, Contour ** contours,int numcontours);13 void MeshProfileIntersectionx( double** psegments, int* pnumseg, int* index, double* x, double* y, int nel, int nods, Contour<IssmPDouble>** contours,int numcontours); 14 14 void MeshSegmentsIntersection(double** psegments, int* pnumsegs,int* index, double* x, double* y, int nel, int nods, double* xc, double* yc, int numnodes); 15 15 void ElementSegmentsIntersection(DataSet* segments_dataset,int el, double* xnodes,double* ynodes,double* xc,double* yc,int numnodes); -
issm/trunk-jpl/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp
r12450 r13220 10 10 /*output: */ 11 11 double* segments=NULL; 12 Segment * segment=NULL;12 Segment<double>* segment=NULL; 13 13 int numsegs; 14 14 … … 34 34 segments=xNew<double>(5*numsegs); 35 35 for(i=0;i<numsegs;i++){ 36 Segment * segment=(Segment*)segments_dataset->GetObjectByOffset(i);36 Segment<double>* segment=(Segment<double>*)segments_dataset->GetObjectByOffset(i); 37 37 38 38 /*x1,y1,x2,y2 then element_id: */ -
issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp
r13216 r13220 4 4 #include "./PointCloudFindNeighborsx.h" 5 5 6 int PointCloudFindNeighborsx( Vector<Issm Double>** pflags,double* x, double* y, int nods, double mindistance,double multithread){6 int PointCloudFindNeighborsx( Vector<IssmPDouble>** pflags,double* x, double* y, int nods, double mindistance,double multithread){ 7 7 8 8 /*output: */ 9 Vector<Issm Double>* flags=NULL;10 flags=new Vector<Issm Double>(nods);9 Vector<IssmPDouble>* flags=NULL; 10 flags=new Vector<IssmPDouble>(nods); 11 11 12 12 /*threading: */ -
issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h
r13216 r13220 11 11 12 12 /* local prototypes: */ 13 int PointCloudFindNeighborsx( Vector<Issm Double>** pflags,double* x, double* y, int nods, double mindistance,double multithread);13 int PointCloudFindNeighborsx( Vector<IssmPDouble>** pflags,double* x, double* y, int nods, double mindistance,double multithread); 14 14 15 15 /*threading: */ … … 20 20 int nods; 21 21 double mindistance; 22 Vector<Issm Double>* flags;22 Vector<IssmPDouble>* flags; 23 23 24 24 -
issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp
r13216 r13220 17 17 int nods; 18 18 double mindistance; 19 Vector<Issm Double>* flags;19 Vector<IssmPDouble>* flags; 20 20 21 21 /*recover handle and gate: */ -
issm/trunk-jpl/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp
r13216 r13220 15 15 int configuration_type; 16 16 int ssize; 17 double* yg_serial=NULL;17 IssmDouble* yg_serial=NULL; 18 18 19 19 /*first figure out ssize: */ … … 51 51 52 52 /*Free ressources:*/ 53 xDelete< double>(yg_serial);53 xDelete<IssmDouble>(yg_serial); 54 54 55 55 /*Assign output pointers:*/ -
issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.cpp
r13216 r13220 20 20 /*}}}*/ 21 21 22 void TriMeshx(Matrix<Issm Double>** pindex,Vector<IssmDouble>** px,Vector<IssmDouble>** py,Matrix<IssmDouble>** psegments,Vector<IssmDouble>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area){22 void TriMeshx(Matrix<IssmPDouble>** pindex,Vector<IssmPDouble>** px,Vector<IssmPDouble>** py,Matrix<IssmPDouble>** psegments,Vector<IssmPDouble>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area){ 23 23 24 24 /*indexing: */ … … 26 26 27 27 /*output: */ 28 double* index=NULL;29 Matrix<Issm Double>* index_matrix=NULL;28 IssmPDouble* index=NULL; 29 Matrix<IssmPDouble>* index_matrix=NULL; 30 30 double* x=NULL; 31 31 double* y=NULL; 32 32 double* segments=NULL; 33 Matrix<Issm Double>* segments_matrix=NULL;33 Matrix<IssmPDouble>* segments_matrix=NULL; 34 34 double* segmentmarkerlist=NULL; 35 35 36 36 /*intermediary: */ 37 37 int counter,counter2,backcounter; 38 Contour * contour=NULL;38 Contour<IssmPDouble>* contour=NULL; 39 39 40 40 /* Triangle structures needed to call Triangle library routines: */ … … 45 45 in.numberofpoints=0; 46 46 for (i=0;i<domain->Size();i++){ 47 contour=(Contour *)domain->GetObjectByOffset(i);47 contour=(Contour<IssmPDouble>*)domain->GetObjectByOffset(i); 48 48 in.numberofpoints+=contour->nods-1; 49 49 } 50 50 for (i=0;i<rifts->Size();i++){ 51 contour=(Contour *)rifts->GetObjectByOffset(i);51 contour=(Contour<IssmPDouble>*)rifts->GetObjectByOffset(i); 52 52 in.numberofpoints+=contour->nods; 53 53 } … … 61 61 counter=0; 62 62 for (i=0;i<domain->Size();i++){ 63 contour=(Contour *)domain->GetObjectByOffset(i);63 contour=(Contour<IssmPDouble>*)domain->GetObjectByOffset(i); 64 64 for (j=0;j<contour->nods-1;j++){ 65 65 in.pointlist[2*counter+0]=contour->x[j]; … … 69 69 } 70 70 for (i=0;i<rifts->Size();i++){ 71 contour=(Contour *)rifts->GetObjectByOffset(i);71 contour=(Contour<IssmPDouble>*)rifts->GetObjectByOffset(i); 72 72 for (j=0;j<contour->nods;j++){ 73 73 in.pointlist[2*counter+0]=contour->x[j]; … … 88 88 in.numberofsegments=0; 89 89 for (i=0;i<domain->Size();i++){ 90 contour=(Contour *)domain->GetObjectByOffset(i);90 contour=(Contour<IssmPDouble>*)domain->GetObjectByOffset(i); 91 91 in.numberofsegments+=contour->nods-1; 92 92 } 93 93 for(i=0;i<rifts->Size();i++){ 94 contour=(Contour *)rifts->GetObjectByOffset(i);94 contour=(Contour<IssmPDouble>*)rifts->GetObjectByOffset(i); 95 95 /*for rifts, we have one less segment as we have vertices*/ 96 96 in.numberofsegments+=contour->nods-1; … … 102 102 backcounter=0; 103 103 for (i=0;i<domain->Size();i++){ 104 contour=(Contour *)domain->GetObjectByOffset(i);104 contour=(Contour<IssmPDouble>*)domain->GetObjectByOffset(i); 105 105 for (j=0;j<contour->nods-2;j++){ 106 106 in.segmentlist[2*counter+0]=counter; … … 118 118 counter2=counter; 119 119 for (i=0;i<rifts->Size();i++){ 120 contour=(Contour *)rifts->GetObjectByOffset(i);120 contour=(Contour<IssmPDouble>*)rifts->GetObjectByOffset(i); 121 121 for (j=0;j<(contour->nods-1);j++){ 122 122 in.segmentlist[2*counter2+0]=counter; … … 137 137 in.holelist = xNew<REAL>(in.numberofholes*2); 138 138 for (i=0;i<domain->Size()-1;i++){ 139 contour=(Contour *)domain->GetObjectByOffset(i+1);139 contour=(Contour<IssmPDouble>*)domain->GetObjectByOffset(i+1); 140 140 GridInsideHole(&in.holelist[2*i+0],&in.holelist[2*i+1],contour->nods-1,contour->x,contour->y); 141 141 } … … 192 192 193 193 /*Output : */ 194 index_matrix=new Matrix<Issm Double>(index,out.numberoftriangles,3,1,SeqMatType);194 index_matrix=new Matrix<IssmPDouble>(index,out.numberoftriangles,3,1.0,SeqMatType); 195 195 *pindex=index_matrix; 196 196 197 segments_matrix=new Matrix<Issm Double>(segments,out.numberofsegments,3,1,SeqMatType);197 segments_matrix=new Matrix<IssmPDouble>(segments,out.numberofsegments,3,1.0,SeqMatType); 198 198 *psegments=segments_matrix; 199 199 200 *px=new Vector<Issm Double>(x,out.numberofpoints,SeqMatType);201 *py=new Vector<Issm Double>(y,out.numberofpoints,SeqMatType);202 *psegmentmarkerlist=new Vector<Issm Double>(segmentmarkerlist,out.numberofsegments,SeqMatType);200 *px=new Vector<IssmPDouble>(x,out.numberofpoints,SeqMatType); 201 *py=new Vector<IssmPDouble>(y,out.numberofpoints,SeqMatType); 202 *psegmentmarkerlist=new Vector<IssmPDouble>(segmentmarkerlist,out.numberofsegments,SeqMatType); 203 203 } -
issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.h
r13216 r13220 11 11 12 12 /* local prototypes: */ 13 void TriMeshx(Matrix<Issm Double>** pindex,Vector<IssmDouble>** px,Vector<IssmDouble>** py,Matrix<IssmDouble>** psegments,Vector<IssmDouble>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area);13 void TriMeshx(Matrix<IssmPDouble>** pindex,Vector<IssmPDouble>** px,Vector<IssmPDouble>** py,Matrix<IssmPDouble>** psegments,Vector<IssmPDouble>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area); 14 14 15 15 #endif /* _TRIMESHX_H */ -
issm/trunk-jpl/src/c/shared/Exp/IsInPoly.cpp
r13216 r13220 14 14 #endif 15 15 16 /*IsInPoly {{{*/17 int IsInPoly(Vector<IssmDouble>* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){18 19 int i;20 double x0,y0;21 double value;22 double xmin=xc[0];23 double xmax=xc[0];24 double ymin=yc[0];25 double ymax=yc[0];26 27 /*Get extrema*/28 for (i=1;i<numvertices;i++){29 if(xc[i]<xmin) xmin=xc[i];30 if(xc[i]>xmax) xmax=xc[i];31 if(yc[i]<ymin) ymin=yc[i];32 if(yc[i]>ymax) ymax=yc[i];33 }34 35 /*Go through all vertices of the mesh:*/36 for (i=i0;i<i1;i++){37 38 //Get current value of value[i] -> do not change it if != 039 in->GetValue(&value,i);40 if (value){41 /*this vertex already is inside one of the contours, continue*/42 continue;43 }44 45 /*pick up vertex (x[i],y[i]) and figure out if located inside contour (xc,yc)*/46 x0=x[i]; y0=y[i];47 if(x0<xmin || x0>xmax || y0<ymin || y0>ymax){48 value=0;49 }50 else{51 value=pnpoly(numvertices,xc,yc,x0,y0,edgevalue);52 }53 in->SetValue(i,value,INS_VAL);54 }55 return 1;56 }/*}}}*/57 /*IsOutsidePoly {{{*/58 int IsOutsidePoly(Vector<IssmDouble>* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){59 60 int i,j;61 double x0,y0;62 double value;63 double xmin=xc[0];64 double xmax=xc[0];65 double ymin=yc[0];66 double ymax=yc[0];67 68 /*Get extrema*/69 for (i=1;i<numvertices;i++){70 if(xc[i]<xmin) xmin=xc[i];71 if(xc[i]>xmax) xmax=xc[i];72 if(yc[i]<ymin) ymin=yc[i];73 if(yc[i]>ymax) ymax=yc[i];74 }75 76 /*Go through all vertices of the mesh:*/77 for (i=i0;i<i1;i++){78 79 //Get current value of value[i] -> do not change it if != 080 in->GetValue(&value,i);81 if (value){82 /*this vertex already is inside one of the contours, continue*/83 continue;84 }85 86 /*pick up vertex (x[i],y[i]) and figure out if located inside contour (xc,yc)*/87 x0=x[i]; y0=y[i];88 if(x0<xmin || x0>xmax || y0<ymin || y0>ymax){89 value=1;90 }91 else{92 value=1-pnpoly(numvertices,xc,yc,x0,y0,edgevalue);93 }94 in->SetValue(i,value,INS_VAL);95 }96 return 1;97 }/*}}}*/98 16 /*pnpoly{{{*/ 99 17 int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue) { -
issm/trunk-jpl/src/c/shared/Exp/exp.h
r13216 r13220 7 7 #define _EXP_H_ 8 8 9 #include "../../classes/objects/objects.h" 10 #include "../../toolkits/toolkits.h" 11 12 int IsInPoly(Vector<IssmDouble>* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue); 13 int IsOutsidePoly(Vector<IssmDouble>* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue); 9 #include "../../classes/objects/Contour.h" 10 #include "../../shared/Numerics/recast.h" 11 #include "../../Container/Container.h" 12 14 13 int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue); 15 14 int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname); 16 15 int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue); 17 16 18 int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname); 19 DataSet* DomainOutlineRead(char* domainname); 17 18 /*IsInPoly {{{*/ 19 template <class doubletype> 20 int IsInPoly(Vector<doubletype>* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){ 21 22 int i; 23 double x0,y0; 24 doubletype value; 25 double xmin=xc[0]; 26 double xmax=xc[0]; 27 double ymin=yc[0]; 28 double ymax=yc[0]; 29 30 /*Get extrema*/ 31 for (i=1;i<numvertices;i++){ 32 if(xc[i]<xmin) xmin=xc[i]; 33 if(xc[i]>xmax) xmax=xc[i]; 34 if(yc[i]<ymin) ymin=yc[i]; 35 if(yc[i]>ymax) ymax=yc[i]; 36 } 37 38 /*Go through all vertices of the mesh:*/ 39 for (i=i0;i<i1;i++){ 40 41 //Get current value of value[i] -> do not change it if != 0 42 in->GetValue(&value,i); 43 if (reCast<bool,doubletype>(value)){ 44 /*this vertex already is inside one of the contours, continue*/ 45 continue; 46 } 47 48 /*pick up vertex (x[i],y[i]) and figure out if located inside contour (xc,yc)*/ 49 x0=x[i]; y0=y[i]; 50 if(x0<xmin || x0>xmax || y0<ymin || y0>ymax){ 51 value=0; 52 } 53 else{ 54 value=pnpoly(numvertices,xc,yc,x0,y0,edgevalue); 55 } 56 in->SetValue(i,value,INS_VAL); 57 } 58 return 1; 59 }/*}}}*/ 60 /*IsOutsidePoly {{{*/ 61 template <class doubletype> 62 int IsOutsidePoly(Vector<doubletype>* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){ 63 64 int i,j; 65 double x0,y0; 66 doubletype value; 67 double xmin=xc[0]; 68 double xmax=xc[0]; 69 double ymin=yc[0]; 70 double ymax=yc[0]; 71 72 /*Get extrema*/ 73 for (i=1;i<numvertices;i++){ 74 if(xc[i]<xmin) xmin=xc[i]; 75 if(xc[i]>xmax) xmax=xc[i]; 76 if(yc[i]<ymin) ymin=yc[i]; 77 if(yc[i]>ymax) ymax=yc[i]; 78 } 79 80 /*Go through all vertices of the mesh:*/ 81 for (i=i0;i<i1;i++){ 82 83 //Get current value of value[i] -> do not change it if != 0 84 in->GetValue(&value,i); 85 if (reCast<bool,doubletype>(value)){ 86 /*this vertex already is inside one of the contours, continue*/ 87 continue; 88 } 89 90 /*pick up vertex (x[i],y[i]) and figure out if located inside contour (xc,yc)*/ 91 x0=x[i]; y0=y[i]; 92 if(x0<xmin || x0>xmax || y0<ymin || y0>ymax){ 93 value=1; 94 } 95 else{ 96 value=1-pnpoly(numvertices,xc,yc,x0,y0,edgevalue); 97 } 98 in->SetValue(i,value,INS_VAL); 99 } 100 return 1; 101 }/*}}}*/ 102 /*DomainOutlineRead{{{*/ 103 template <class doubletype> 104 int DomainOutlineRead(int* pnprof,int** pprofnvertices,doubletype*** ppprofx,doubletype*** ppprofy,bool** pclosed,char* domainname){ 105 106 /*indexing: */ 107 int i,counter; 108 109 /*I/O: */ 110 FILE *fid = NULL; 111 char chardummy[256]; 112 double ddummy; 113 114 /*output: */ 115 int nprof; //number of profiles in the domainname file 116 int *profnvertices = NULL; //array holding the number of vertices for the nprof profiles 117 doubletype **pprofx = NULL; //array of profiles x coordinates 118 doubletype **pprofy = NULL; //array of profiles y coordinates 119 bool *closed = NULL; //array holding closed flags for the nprof profiles 120 121 /*For each profile: */ 122 int n; 123 doubletype *x = NULL; 124 doubletype *y = NULL; 125 double xi,yi; 126 bool cl; 127 128 /*open domain outline file for reading: */ 129 if ((fid=fopen(domainname,"r"))==NULL){ 130 _error_("could not find domain file " << domainname); 131 } 132 133 /*Do a first pass through the domainname file, to figure out how many profiles 134 *we need to read: */ 135 nprof=1; 136 for(;;){ 137 fscanf(fid,"%256s %256s\n",chardummy,chardummy); 138 fscanf(fid,"%256s %256s\n",chardummy,chardummy); 139 fscanf(fid,"%256s %256s %256s %256s\n",chardummy,chardummy,chardummy,chardummy); 140 fscanf(fid,"%20u %256s\n",&n,chardummy); 141 fscanf(fid,"%256s %256s %256s %256s %256s\n",chardummy,chardummy,chardummy,chardummy,chardummy); 142 for (i=0;i<n;i++){ 143 fscanf(fid,"%20lf %20lf\n",&ddummy,&ddummy); 144 } 145 /*Ok, we have faked one profile reading, check whether we are at the end of the file, otherwise, keep fake reading next profile:*/ 146 if (feof(fid)){ 147 break; 148 } 149 nprof++; 150 } 151 152 /*Allocate and initialize all the profiles: */ 153 profnvertices=xNew<int>(nprof); 154 pprofx=xNew<doubletype*>(nprof); 155 pprofy=xNew<doubletype*>(nprof); 156 for (i=0;i<nprof;i++){ 157 pprofx[i]=NULL; 158 pprofy[i]=NULL; 159 } 160 closed=xNew<bool>(nprof); 161 162 /*Reaset file pointer to beginning of file: */ 163 fseek(fid,0,SEEK_SET); 164 165 /*Start reading profiles: */ 166 for(counter=0;counter<nprof;counter++){ 167 168 /*Skip header: */ 169 fscanf(fid,"%256s %256s\n",chardummy,chardummy); 170 fscanf(fid,"%256s %256s\n",chardummy,chardummy); 171 fscanf(fid,"%256s %256s %256s %256s\n",chardummy,chardummy,chardummy,chardummy); 172 173 /*Get number of profile vertices: */ 174 fscanf(fid,"%20u %256s\n",&n,chardummy); 175 176 /*Skip next line: */ 177 fscanf(fid,"%256s %256s %256s %256s %256s\n",chardummy,chardummy,chardummy,chardummy,chardummy); 178 179 /*Allocate vertices: */ 180 x=xNew<doubletype>(n); 181 y=xNew<doubletype>(n); 182 183 /*Read vertices: */ 184 for (i=0;i<n;i++){ 185 fscanf(fid,"%20lf %20lf\n",&xi,&yi); 186 x[i]=xi; y[i]=yi; 187 } 188 189 /*Now check that we are dealing with open contours: */ 190 cl=false; 191 if((x[0]==x[n-1]) && (y[0]==y[n-1])){ 192 cl=true; 193 } 194 195 /*Assign pointers: */ 196 profnvertices[counter]=n; 197 pprofx[counter]=x; 198 pprofy[counter]=y; 199 closed[counter]=cl; 200 } 201 202 /*close domain outline file: */ 203 fclose(fid); 204 205 /*Assign output pointers: */ 206 *pnprof=nprof; 207 *pprofnvertices=profnvertices; 208 *ppprofx=pprofx; 209 *ppprofy=pprofy; 210 if(pclosed) 211 *pclosed=closed; 212 else 213 xDelete<bool>(closed); 214 } /*}}}*/ 215 /*DataSet* DomainOutlineRead(char* domainname){{{*/ 216 template <class doubletype> 217 DataSet* DomainOutlineRead(char* domainname){ 218 219 /*intermediary: */ 220 int nprof; 221 int *profnvertices = NULL; 222 doubletype **pprofx = NULL; 223 doubletype **pprofy = NULL; 224 Contour<doubletype>* contour = NULL; 225 226 /*output: */ 227 DataSet* domain=NULL; 228 229 /*If domainname is an empty string, return empty dataset*/ 230 if (strcmp(domainname,"")==0){ 231 nprof=0; 232 } 233 else{ 234 DomainOutlineRead(&nprof,&profnvertices,&pprofx, &pprofy, NULL,domainname); 235 } 236 237 /*now create dataset of contours: */ 238 domain=new DataSet(0); 239 240 for(int i=0;i<nprof;i++){ 241 domain->AddObject(new Contour<doubletype>(i,profnvertices[i],pprofx[i],pprofy[i],1)); 242 } 243 return domain; 244 } /*}}}*/ 245 246 20 247 21 248 -
issm/trunk-jpl/src/modules/ContourToMesh/ContourToMesh.cpp
r13216 r13220 63 63 FetchData(&edgevalue,EDGEVALUE); 64 64 FetchData(&contourname,CONTOURNAME); 65 contours=DomainOutlineRead (contourname);65 contours=DomainOutlineRead<double>(contourname); 66 66 67 67 /*Fetch interptype: */ -
issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.cpp
r13216 r13220 41 41 mxArray* matlabstructure=NULL; 42 42 int numcontours; 43 Contour ** contours=NULL;44 Contour * contouri=NULL;43 Contour<double>** contours=NULL; 44 Contour<double>* contouri=NULL; 45 45 46 46 /*Boot module: */ … … 68 68 69 69 numcontours=mxGetNumberOfElements(matlabstructure); 70 contours=xNew<Contour *>(numcontours);70 contours=xNew<Contour<double>*>(numcontours); 71 71 for(i=0;i<numcontours;i++){ 72 72 //allocate 73 contouri=xNew<Contour >(1);73 contouri=xNew<Contour<double> >(1); 74 74 //retrieve dimension of this contour. 75 75 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
issm/trunk-jpl/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp
r13216 r13220 50 50 //contours 51 51 mxArray* matlabstructure=NULL; 52 Contour ** contours=NULL;52 Contour<double>** contours=NULL; 53 53 int numcontours; 54 Contour * contouri=NULL;54 Contour<double>* contouri=NULL; 55 55 int i; 56 56 … … 100 100 /*contours: */ 101 101 numcontours=mxGetNumberOfElements(matlabstructure); 102 contours=xNew<Contour *>(numcontours);102 contours=xNew<Contour<double> *>(numcontours); 103 103 for(i=0;i<numcontours;i++){ 104 104 //allocate 105 contouri=xNew<Contour >(1);105 contouri=xNew<Contour<double> >(1); 106 106 //retrieve dimension of this contour. 107 107 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
issm/trunk-jpl/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp
r13038 r13220 34 34 //contours 35 35 mxArray* matlabstructure=NULL; 36 Contour ** contours=NULL;36 Contour<double>** contours=NULL; 37 37 int numcontours; 38 Contour * contouri=NULL;38 Contour<double>* contouri=NULL; 39 39 40 40 /* output: */ … … 67 67 //contours 68 68 numcontours=mxGetNumberOfElements(matlabstructure); 69 contours=xNew<Contour *>(numcontours);69 contours=xNew<Contour<double>*>(numcontours); 70 70 for(i=0;i<numcontours;i++){ 71 71 //allocate 72 contouri=xNew<Contour >(1);72 contouri=xNew<Contour<double> >(1); 73 73 //retrieve dimension of this contour. 74 74 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
issm/trunk-jpl/src/modules/TriMesh/TriMesh.cpp
r13216 r13220 35 35 36 36 /*Read domain outline: */ 37 domain = DomainOutlineRead (domainname);38 rifts = DomainOutlineRead (riftsname);37 domain = DomainOutlineRead<double>(domainname); 38 rifts = DomainOutlineRead<double>(riftsname); 39 39 40 40 /*call x core: */
Note:
See TracChangeset
for help on using the changeset viewer.