Changeset 3314
- Timestamp:
- 03/22/10 10:42:43 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/io/WriteData.cpp
r2316 r3314 19 19 20 20 #include <mex.h> 21 21 #include <assert.h> 22 22 23 23 /*Several prototypes for WriteData, according to type: */ … … 180 180 } 181 181 182 void WriteData(mxArray** pbamgmesh_mat,BamgMesh* bm){ 183 184 /*Output*/ 185 mxArray* bamgmesh_mat=NULL; 186 187 /*Intermediary*/ 188 int i,j; 189 mxArray* pfield=NULL; 190 mxArray* pfield2=NULL; 191 int numfields=15; 192 const char* fnames[numfields]; 193 int fsize[numfields][2]; 194 double** fpointer[numfields]; 195 mwSize ndim=2; 196 mwSize dimensions[2]={1,1}; 197 198 /*Build fnames and fsize names and sizes of each field*/ 199 i=-1; 200 fnames[++i] = "Triangles"; fsize[i][0]=bm->TrianglesSize[0]; fsize[i][1]=bm->TrianglesSize[1]; fpointer[i]=&bm->Triangles; 201 fnames[++i] = "Vertices"; fsize[i][0]=bm->VerticesSize[0]; fsize[i][1]=bm->VerticesSize[1]; fpointer[i]=&bm->Vertices; 202 fnames[++i] = "Edges"; fsize[i][0]=bm->EdgesSize[0]; fsize[i][1]=bm->EdgesSize[1]; fpointer[i]=&bm->Edges; 203 fnames[++i] = "Segments"; fsize[i][0]=bm->SegmentsSize[0]; fsize[i][1]=bm->SegmentsSize[1]; fpointer[i]=&bm->Segments; 204 fnames[++i] = "ElementEdges"; fsize[i][0]=bm->ElementEdgesSize[0]; fsize[i][1]=bm->ElementEdgesSize[1]; fpointer[i]=&bm->ElementEdges; 205 fnames[++i] = "CrackedEdges"; fsize[i][0]=bm->CrackedEdgesSize[0]; fsize[i][1]=bm->CrackedEdgesSize[1]; fpointer[i]=&bm->CrackedEdges; 206 fnames[++i] = "Quadrilaterals"; fsize[i][0]=bm->QuadrilateralsSize[0]; fsize[i][1]=bm->QuadrilateralsSize[1]; fpointer[i]=&bm->Quadrilaterals; 207 fnames[++i] = "VerticesOnGeometricVertex";fsize[i][0]=bm->VerticesOnGeometricVertexSize[0]; fsize[i][1]=bm->VerticesOnGeometricVertexSize[1];fpointer[i]=&bm->VerticesOnGeometricVertex; 208 fnames[++i] = "VerticesOnGeometricEdge"; fsize[i][0]=bm->VerticesOnGeometricEdgeSize[0]; fsize[i][1]=bm->VerticesOnGeometricEdgeSize[1]; fpointer[i]=&bm->VerticesOnGeometricEdge; 209 fnames[++i] = "EdgesOnGeometricEdge"; fsize[i][0]=bm->EdgesOnGeometricEdgeSize[0]; fsize[i][1]=bm->EdgesOnGeometricEdgeSize[1]; fpointer[i]=&bm->EdgesOnGeometricEdge; 210 fnames[++i] = "SubDomains"; fsize[i][0]=bm->SubDomainsSize[0]; fsize[i][1]=bm->SubDomainsSize[1]; fpointer[i]=&bm->SubDomains; 211 fnames[++i] = "SubDomainsFromGeom"; fsize[i][0]=bm->SubDomainsFromGeomSize[0]; fsize[i][1]=bm->SubDomainsFromGeomSize[1]; fpointer[i]=&bm->SubDomainsFromGeom; 212 fnames[++i] = "ElementConnectivity"; fsize[i][0]=bm->ElementConnectivitySize[0]; fsize[i][1]=bm->ElementConnectivitySize[1]; fpointer[i]=&bm->ElementConnectivity; 213 fnames[++i] = "NodalConnectivity"; fsize[i][0]=bm->NodalConnectivitySize[0]; fsize[i][1]=bm->NodalConnectivitySize[1]; fpointer[i]=&bm->NodalConnectivity; 214 fnames[++i] = "NodalElementConnectivity"; fsize[i][0]=bm->NodalElementConnectivitySize[0]; fsize[i][1]=bm->NodalElementConnectivitySize[1]; fpointer[i]=&bm->NodalElementConnectivity; 215 assert(i==numfields-1); 216 217 /*Initialize Matlab structure*/ 218 bamgmesh_mat=mxCreateStructArray(ndim,dimensions,numfields,fnames); 219 220 /*Add every field to structure*/ 221 for(i=0;i<numfields;i++){ 222 pfield=mxCreateDoubleMatrix(0,0,mxREAL); 223 mxSetM(pfield,fsize[i][1]); 224 mxSetN(pfield,fsize[i][0]); 225 mxSetPr(pfield,*(fpointer[i])); 226 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose 227 mxSetField(bamgmesh_mat,0,fnames[i],pfield2); 228 } 229 230 /*Assign output pointer*/ 231 *pbamgmesh_mat=bamgmesh_mat; 232 } 233 234 void WriteData(mxArray** pbamggeom_mat, BamgGeom* bg){ 235 236 /*Output*/ 237 mxArray* bamggeom_mat=NULL; 238 239 /*Intermediary*/ 240 int i,j; 241 mxArray* pfield=NULL; 242 mxArray* pfield2=NULL; 243 int numfields=7; 244 const char* fnames[numfields]; 245 int fsize[numfields][2]; 246 double** fpointer[numfields]; 247 mwSize ndim=2; 248 mwSize dimensions[2]={1,1}; 249 250 /*Build fnames and fsize names and sizes of each field*/ 251 i=-1; 252 fnames[++i] = "Vertices"; fsize[i][0]=bg->VerticesSize[0]; fsize[i][1]=bg->VerticesSize[1]; fpointer[i]=&bg->Vertices; 253 fnames[++i] = "Edges"; fsize[i][0]=bg->EdgesSize[0]; fsize[i][1]=bg->EdgesSize[1]; fpointer[i]=&bg->Edges; 254 fnames[++i] = "TangentAtEdges"; fsize[i][0]=bg->TangentAtEdgesSize[0]; fsize[i][1]=bg->TangentAtEdgesSize[1]; fpointer[i]=&bg->TangentAtEdges; 255 fnames[++i] = "RequiredVertices";fsize[i][0]=bg->RequiredVerticesSize[0];fsize[i][1]=bg->RequiredVerticesSize[1];fpointer[i]=&bg->RequiredVertices; 256 fnames[++i] = "RequiredEdges"; fsize[i][0]=bg->RequiredEdgesSize[0]; fsize[i][1]=bg->RequiredEdgesSize[1]; fpointer[i]=&bg->RequiredEdges; 257 fnames[++i] = "CrackedEdges"; fsize[i][0]=bg->CrackedEdgesSize[0]; fsize[i][1]=bg->CrackedEdgesSize[1]; fpointer[i]=&bg->CrackedEdges; 258 fnames[++i] = "SubDomains"; fsize[i][0]=bg->SubDomainsSize[0]; fsize[i][1]=bg->SubDomainsSize[1]; fpointer[i]=&bg->SubDomains; 259 assert(i==numfields-1); 260 261 /*Initialize Matlab structure*/ 262 bamggeom_mat=mxCreateStructArray(ndim,dimensions,numfields,fnames); 263 264 /*Add every field tu structure*/ 265 for(i=0;i<numfields;i++){ 266 pfield=mxCreateDoubleMatrix(0,0,mxREAL); 267 mxSetM(pfield,fsize[i][1]); 268 mxSetN(pfield,fsize[i][0]); 269 mxSetPr(pfield,*(fpointer[i])); 270 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose 271 mxSetField(bamggeom_mat,0,fnames[i],pfield2); 272 } 273 274 /*Assign output pointer*/ 275 *pbamggeom_mat=bamggeom_mat; 276 } 277 182 278 #else 183 279 void WriteData(int* pdummy,void* data,char* data_type){ -
issm/trunk/src/c/io/io.h
r2333 r3314 8 8 #include "../objects/NodeSets.h" 9 9 #include "../objects/DofVec.h" 10 #include "../objects/BamgMesh.h" 11 #include "../objects/BamgGeom.h" 10 12 #include "../DataSet/DataSet.h" 11 13 #include "../include/types.h" … … 27 29 void WriteData(mxArray** pdataref,char* string); 28 30 void WriteData(mxArray** pdataref,DofVec* vector); 31 void WriteData(mxArray** pdataref,BamgMesh* bm); 32 void WriteData(mxArray** pdataref,BamgGeom* bg); 29 33 30 34 void WriteNodeSets(DataHandle* pdataref,NodeSets* nodesets); -
issm/trunk/src/c/objects/BamgGeom.cpp
r3312 r3314 17 17 18 18 } 19 20 #ifdef _SERIAL_21 void BamgGeomWrite(mxArray** pbamggeom_mat, BamgGeom* bamggeom){22 23 /*Output*/24 mxArray* bamggeom_mat=NULL;25 26 /*Intermediary*/27 int i,j;28 mxArray* pfield=NULL;29 mxArray* pfield2=NULL;30 int numfields=7;31 const char* fnames[numfields];32 mwSize ndim=2;33 mwSize dimensions[2]={1,1};34 35 fnames[0] = "Vertices";36 fnames[1] = "Edges";37 fnames[2] = "TangentAtEdges";38 fnames[3] = "RequiredVertices";39 fnames[4] = "RequiredEdges";40 fnames[5] = "CrackedEdges";41 fnames[6] = "SubDomains";42 43 bamggeom_mat=mxCreateStructArray(ndim,dimensions,numfields,fnames);44 45 pfield=mxCreateDoubleMatrix(0,0,mxREAL);46 mxSetM(pfield,bamggeom->VerticesSize[1]);47 mxSetN(pfield,bamggeom->VerticesSize[0]);48 mxSetPr(pfield,bamggeom->Vertices);49 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose50 mxSetField(bamggeom_mat,0,"Vertices",pfield2);51 52 pfield=mxCreateDoubleMatrix(0,0,mxREAL);53 mxSetM(pfield,bamggeom->EdgesSize[1]);54 mxSetN(pfield,bamggeom->EdgesSize[0]);55 mxSetPr(pfield,bamggeom->Edges);56 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose57 mxSetField(bamggeom_mat,0,"Edges",pfield2);58 59 pfield=mxCreateDoubleMatrix(0,0,mxREAL);60 mxSetM(pfield,bamggeom->TangentAtEdgesSize[1]);61 mxSetN(pfield,bamggeom->TangentAtEdgesSize[0]);62 mxSetPr(pfield,bamggeom->TangentAtEdges);63 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose64 mxSetField(bamggeom_mat,0,"TangentAtEdges",pfield2);65 66 pfield=mxCreateDoubleMatrix(0,0,mxREAL);67 mxSetM(pfield,bamggeom->RequiredVerticesSize[1]);68 mxSetN(pfield,bamggeom->RequiredVerticesSize[0]);69 mxSetPr(pfield,bamggeom->RequiredVertices);70 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose71 mxSetField(bamggeom_mat,0,"RequiredVertices",pfield2);72 73 pfield=mxCreateDoubleMatrix(0,0,mxREAL);74 mxSetM(pfield,bamggeom->RequiredEdgesSize[1]);75 mxSetN(pfield,bamggeom->RequiredEdgesSize[0]);76 mxSetPr(pfield,bamggeom->RequiredEdges);77 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose78 mxSetField(bamggeom_mat,0,"RequiredEdges",pfield2);79 80 pfield=mxCreateDoubleMatrix(0,0,mxREAL);81 mxSetM(pfield,bamggeom->CrackedEdgesSize[1]);82 mxSetN(pfield,bamggeom->CrackedEdgesSize[0]);83 mxSetPr(pfield,bamggeom->CrackedEdges);84 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose85 mxSetField(bamggeom_mat,0,"CrackedEdges",pfield2);86 87 pfield=mxCreateDoubleMatrix(0,0,mxREAL);88 mxSetM(pfield,bamggeom->SubDomainsSize[1]);89 mxSetN(pfield,bamggeom->SubDomainsSize[0]);90 mxSetPr(pfield,bamggeom->SubDomains);91 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose92 mxSetField(bamggeom_mat,0,"SubDomains",pfield2);93 94 /*Assign output pointer*/95 *pbamggeom_mat=bamggeom_mat;96 97 }98 #endif -
issm/trunk/src/c/objects/BamgGeom.h
r3312 r3314 38 38 void BamgGeomInit(BamgGeom* bamggeom); 39 39 40 #ifdef _SERIAL_41 #include "mex.h"42 void BamgGeomWrite(mxArray** bamggeom_mat,BamgGeom* bamggeom);43 40 #endif 44 45 #endif -
issm/trunk/src/c/objects/BamgMesh.cpp
r3312 r3314 22 22 23 23 } 24 25 #ifdef _SERIAL_26 void BamgMeshWrite(mxArray** pbamgmesh_mat, BamgMesh* bamgmesh){27 28 /*Output*/29 mxArray* bamgmesh_mat=NULL;30 31 /*Intermediary*/32 int i,j;33 mxArray* pfield=NULL;34 mxArray* pfield2=NULL;35 int numfields=15;36 const char* fnames[numfields];37 mwSize ndim=2;38 mwSize dimensions[2]={1,1};39 40 fnames[0] = "Triangles";41 fnames[1] = "Vertices";42 fnames[2] = "Edges";43 fnames[3] = "Segments";44 fnames[4] = "AllEdges";45 fnames[5] = "CrackedEdges";46 fnames[6] = "Quadrilaterals";47 fnames[7] = "VerticesOnGeometricVertex";48 fnames[8] = "VerticesOnGeometricEdge";49 fnames[9] = "EdgesOnGeometricEdge";50 fnames[10]= "SubDomains";51 fnames[11]= "SubDomainsFromGeom";52 fnames[12]= "ElementConnectivity";53 fnames[13]= "NodalConnectivity";54 fnames[14]= "NodalElementConnectivity";55 56 bamgmesh_mat=mxCreateStructArray(ndim,dimensions,numfields,fnames);57 58 pfield=mxCreateDoubleMatrix(0,0,mxREAL);59 mxSetM(pfield,bamgmesh->TrianglesSize[1]);60 mxSetN(pfield,bamgmesh->TrianglesSize[0]);61 mxSetPr(pfield,bamgmesh->Triangles);62 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");63 mxSetField(bamgmesh_mat,0,"Triangles",pfield2);64 65 pfield=mxCreateDoubleMatrix(0,0,mxREAL);66 mxSetM(pfield,bamgmesh->VerticesSize[1]);67 mxSetN(pfield,bamgmesh->VerticesSize[0]);68 mxSetPr(pfield,bamgmesh->Vertices);69 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");70 mxSetField(bamgmesh_mat,0,"Vertices",pfield2);71 72 pfield=mxCreateDoubleMatrix(0,0,mxREAL);73 mxSetM(pfield,bamgmesh->EdgesSize[1]);74 mxSetN(pfield,bamgmesh->EdgesSize[0]);75 mxSetPr(pfield,bamgmesh->Edges);76 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");77 mxSetField(bamgmesh_mat,0,"Edges",pfield2);78 79 pfield=mxCreateDoubleMatrix(0,0,mxREAL);80 mxSetM(pfield,bamgmesh->SegmentsSize[1]);81 mxSetN(pfield,bamgmesh->SegmentsSize[0]);82 mxSetPr(pfield,bamgmesh->Segments);83 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");84 mxSetField(bamgmesh_mat,0,"Segments",pfield2);85 86 pfield=mxCreateDoubleMatrix(0,0,mxREAL);87 mxSetM(pfield,bamgmesh->ElementEdgesSize[1]);88 mxSetN(pfield,bamgmesh->ElementEdgesSize[0]);89 mxSetPr(pfield,bamgmesh->ElementEdges);90 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");91 mxSetField(bamgmesh_mat,0,"AllEdges",pfield2);92 93 pfield=mxCreateDoubleMatrix(0,0,mxREAL);94 mxSetM(pfield,bamgmesh->CrackedEdgesSize[1]);95 mxSetN(pfield,bamgmesh->CrackedEdgesSize[0]);96 mxSetPr(pfield,bamgmesh->CrackedEdges);97 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");98 mxSetField(bamgmesh_mat,0,"CrackedEdges",pfield2);99 100 pfield=mxCreateDoubleMatrix(0,0,mxREAL);101 mxSetM(pfield,bamgmesh->QuadrilateralsSize[1]);102 mxSetN(pfield,bamgmesh->QuadrilateralsSize[0]);103 mxSetPr(pfield,bamgmesh->Quadrilaterals);104 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");105 mxSetField(bamgmesh_mat,0,"Quadrilaterals",pfield2);106 107 pfield=mxCreateDoubleMatrix(0,0,mxREAL);108 mxSetM(pfield,bamgmesh->VerticesOnGeometricVertexSize[1]);109 mxSetN(pfield,bamgmesh->VerticesOnGeometricVertexSize[0]);110 mxSetPr(pfield,bamgmesh->VerticesOnGeometricVertex);111 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose112 mxSetField(bamgmesh_mat,0,"VerticesOnGeometricVertex",pfield2);113 114 pfield=mxCreateDoubleMatrix(0,0,mxREAL);115 mxSetM(pfield,bamgmesh->VerticesOnGeometricEdgeSize[1]);116 mxSetN(pfield,bamgmesh->VerticesOnGeometricEdgeSize[0]);117 mxSetPr(pfield,bamgmesh->VerticesOnGeometricEdge);118 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose119 mxSetField(bamgmesh_mat,0,"VerticesOnGeometricEdge",pfield2);120 121 pfield=mxCreateDoubleMatrix(0,0,mxREAL);122 mxSetM(pfield,bamgmesh->EdgesOnGeometricEdgeSize[1]);123 mxSetN(pfield,bamgmesh->EdgesOnGeometricEdgeSize[0]);124 mxSetPr(pfield,bamgmesh->EdgesOnGeometricEdge);125 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose126 mxSetField(bamgmesh_mat,0,"EdgesOnGeometricEdge",pfield2);127 128 pfield=mxCreateDoubleMatrix(0,0,mxREAL);129 mxSetM(pfield,bamgmesh->SubDomainsSize[1]);130 mxSetN(pfield,bamgmesh->SubDomainsSize[0]);131 mxSetPr(pfield,bamgmesh->SubDomains);132 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose133 mxSetField(bamgmesh_mat,0,"SubDomains",pfield2);134 135 pfield=mxCreateDoubleMatrix(0,0,mxREAL);136 mxSetM(pfield,bamgmesh->SubDomainsFromGeomSize[1]);137 mxSetN(pfield,bamgmesh->SubDomainsFromGeomSize[0]);138 mxSetPr(pfield,bamgmesh->SubDomainsFromGeom);139 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose140 mxSetField(bamgmesh_mat,0,"SubDomainsFromGeom",pfield2);141 142 pfield=mxCreateDoubleMatrix(0,0,mxREAL);143 mxSetM(pfield,bamgmesh->ElementConnectivitySize[1]);144 mxSetN(pfield,bamgmesh->ElementConnectivitySize[0]);145 mxSetPr(pfield,bamgmesh->ElementConnectivity);146 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose147 mxSetField(bamgmesh_mat,0,"ElementConnectivity",pfield2);148 149 pfield=mxCreateDoubleMatrix(0,0,mxREAL);150 mxSetM(pfield,bamgmesh->NodalConnectivitySize[1]);151 mxSetN(pfield,bamgmesh->NodalConnectivitySize[0]);152 mxSetPr(pfield,bamgmesh->NodalConnectivity);153 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose154 mxSetField(bamgmesh_mat,0,"NodalConnectivity",pfield2);155 156 pfield=mxCreateDoubleMatrix(0,0,mxREAL);157 mxSetM(pfield,bamgmesh->NodalElementConnectivitySize[1]);158 mxSetN(pfield,bamgmesh->NodalElementConnectivitySize[0]);159 mxSetPr(pfield,bamgmesh->NodalElementConnectivity);160 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose161 mxSetField(bamgmesh_mat,0,"NodalElementConnectivity",pfield2);162 163 /*Assign output pointer*/164 *pbamgmesh_mat=bamgmesh_mat;165 }166 #endif -
issm/trunk/src/c/objects/BamgMesh.h
r3312 r3314 57 57 void BamgMeshInit(BamgMesh* bamgmesh); 58 58 59 #ifdef _SERIAL_60 #include "mex.h"61 void BamgMeshWrite(mxArray** bamgmesh_mat,BamgMesh* bamgmesh);62 59 #endif 63 64 #endif -
issm/trunk/src/mex/Bamg/Bamg.cpp
r3313 r3314 87 87 88 88 /*Generate output Matlab Structures*/ 89 BamgMeshWrite(&bamgmesh_mat,&bamgmesh_out);90 BamgGeomWrite(&bamggeom_mat,&bamggeom_out);89 WriteData(&bamgmesh_mat,&bamgmesh_out); 90 WriteData(&bamggeom_mat,&bamggeom_out); 91 91 92 92 /*assign output datasets: */
Note:
See TracChangeset
for help on using the changeset viewer.