Changeset 12330 for issm/trunk
- Timestamp:
- 06/01/12 17:26:03 (13 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 13 deleted
- 248 edited
- 57 copied
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Container/Constraints.cpp
r10522 r12330 48 48 49 49 /*figure out total number of constraints combining all the cpus (no clones here)*/ 50 #ifdef _ PARALLEL_51 MPI_Reduce(&localconstraints,&numberofconstraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );52 MPI_Bcast(&numberofconstraints,1,MPI_INT,0,MPI_COMM_WORLD);50 #ifdef _HAVE_MPI_ 51 MPI_Reduce(&localconstraints,&numberofconstraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 52 MPI_Bcast(&numberofconstraints,1,MPI_INT,0,MPI_COMM_WORLD); 53 53 #else 54 numberofconstraints=localconstraints;54 numberofconstraints=localconstraints; 55 55 #endif 56 56 57 57 58 return numberofconstraints; -
issm/trunk/src/c/Container/DataSet.cpp
r11995 r12330 11 11 #endif 12 12 13 #include <cstring> 13 14 #include <vector> 14 15 #include <functional> … … 84 85 /*}}}*/ 85 86 86 /*I/O*/87 #ifdef _SERIAL_88 /*FUNCTION DataSet::Marshall{{{1*/89 char* DataSet::Marshall(){90 91 vector<Object*>::iterator object;92 int object_size;93 int marshalled_dataset_size=0;94 char* marshalled_dataset=NULL;95 char* old_marshalled_dataset=NULL;96 97 /*First get size of marshalled dataset: */98 object_size=(int)objects.size();99 100 marshalled_dataset_size=MarshallSize();101 102 /*Allocate marshalled dataset: */103 marshalled_dataset=(char*)xmalloc(marshalled_dataset_size*sizeof(char));104 105 /*Keep track of old_marshalled_dataset: */106 old_marshalled_dataset=marshalled_dataset;107 108 /*Store internals of dataset first: */109 memcpy(marshalled_dataset,&object_size,sizeof(int)); marshalled_dataset+=sizeof(int);110 memcpy(marshalled_dataset,&sorted,sizeof(int)); marshalled_dataset+=sizeof(int);111 if(sorted){112 if(object_size)memcpy(marshalled_dataset,sorted_ids,object_size*sizeof(int)); marshalled_dataset+=object_size*sizeof(int);113 if(object_size)memcpy(marshalled_dataset,id_offsets,object_size*sizeof(int)); marshalled_dataset+=object_size*sizeof(int);114 }115 116 for ( object=objects.begin() ; object < objects.end(); object++ ){117 (*object)->Marshall(&marshalled_dataset);118 }119 120 /* Ok, marshalled_dataset now points to the end of the original marshalled_dataset pointer121 * before we started the loop on objects. Get object to point right again: */122 marshalled_dataset-=marshalled_dataset_size;123 124 /*We should be back to old_marshalled_dataset: check and abort if that's not the case,125 * because this is a nasty error: */126 if (marshalled_dataset!=old_marshalled_dataset){127 _error_("final marshalled dataset \"%s\" is different from initial one!",EnumToStringx(enum_type));128 abort();129 }130 131 /*Return: */132 return marshalled_dataset;133 }134 /*}}}*/135 /*FUNCTION DataSet::MarshallSize{{{1*/136 int DataSet::MarshallSize(){137 138 vector<Object*>::iterator object;139 int marshalled_dataset_size=0;140 141 142 for ( object=objects.begin() ; object < objects.end(); object++ ){143 marshalled_dataset_size+= (*object)->MarshallSize();144 }145 146 marshalled_dataset_size+=sizeof(int); //objects size147 marshalled_dataset_size+=sizeof(int); //sorted size148 if(sorted){149 marshalled_dataset_size+=(int)objects.size()*sizeof(int); //sorted ids150 marshalled_dataset_size+=(int)objects.size()*sizeof(int); //id offsets151 }152 153 return marshalled_dataset_size;154 }155 /*}}}*/156 /*FUNCTION DataSet::Demarshall{{{1*/157 DataSet* DataSetDemarshall(char* marshalled_dataset){158 159 return DataSetDemarshallRaw(&marshalled_dataset);160 161 }162 /*}}}*/163 /*FUNCTION DataSet::DemarshallRaw{{{1*/164 DataSet* DataSetDemarshallRaw(char** pmarshalled_dataset){165 166 int i;167 168 DataSet* dataset=NULL;169 int numobjects=0;170 int enum_type;171 Object* object=NULL;172 int sorted;173 int* sorted_ids=NULL;174 int* id_offsets=NULL;175 char* marshalled_dataset=NULL;176 177 /*recover marshalled_dataset pointer: */178 marshalled_dataset=*pmarshalled_dataset;179 180 /*initialize dataset: */181 dataset=new DataSet();182 183 /*Get internals first: */184 memcpy(&numobjects,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);185 memcpy(&sorted,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);186 if(sorted){187 if(numobjects){188 sorted_ids=(int*)xmalloc(numobjects*sizeof(int));189 id_offsets=(int*)xmalloc(numobjects*sizeof(int));190 memcpy(sorted_ids,marshalled_dataset,numobjects*sizeof(int)); marshalled_dataset+=numobjects*sizeof(int);191 memcpy(id_offsets,marshalled_dataset,numobjects*sizeof(int)); marshalled_dataset+=numobjects*sizeof(int);192 }193 dataset->SetSorting(sorted_ids,id_offsets);194 }195 196 for(i=0;i<numobjects;i++){197 198 /*get enum type of object: */199 memcpy(&enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);200 201 switch(enum_type){202 case NodeEnum:{203 Node* node=NULL;204 node=new Node();205 node->Demarshall(&marshalled_dataset);206 dataset->AddObject(node);}207 break;208 case VertexEnum:{209 Vertex* vertex=NULL;210 vertex=new Vertex();211 vertex->Demarshall(&marshalled_dataset);212 dataset->AddObject(vertex);}213 break;214 case DoubleParamEnum:{215 DoubleParam* doubleparam=NULL;216 doubleparam=new DoubleParam();217 doubleparam->Demarshall(&marshalled_dataset);218 dataset->AddObject(doubleparam);}219 break;220 case TriaEnum:{221 Tria* tria=NULL;222 tria=new Tria();223 tria->Demarshall(&marshalled_dataset);224 dataset->AddObject(tria);}225 break;226 case TriaP1InputEnum:{227 TriaP1Input* triavertexinput=NULL;228 triavertexinput=new TriaP1Input();229 triavertexinput->Demarshall(&marshalled_dataset);230 dataset->AddObject(triavertexinput);}231 break;232 #ifdef _HAVE_3D_233 case PentaP1InputEnum:{234 PentaP1Input* pentavertexinput=NULL;235 pentavertexinput=new PentaP1Input();236 pentavertexinput->Demarshall(&marshalled_dataset);237 dataset->AddObject(pentavertexinput);}238 break;239 #endif240 case TransientInputEnum:{241 TransientInput* transientinput=NULL;242 transientinput=new TransientInput();243 transientinput->Demarshall(&marshalled_dataset);244 dataset->AddObject(transientinput);}245 break;246 #ifdef _HAVE_CONTROL_247 case ControlInputEnum:{248 ControlInput* controlinputinput=NULL;249 controlinputinput=new ControlInput();250 controlinputinput->Demarshall(&marshalled_dataset);251 dataset->AddObject(controlinputinput);}252 break;253 #endif254 case DatasetInputEnum:{255 DatasetInput* datasetinputinput=NULL;256 datasetinputinput=new DatasetInput();257 datasetinputinput->Demarshall(&marshalled_dataset);258 dataset->AddObject(datasetinputinput);}259 break;260 case TriaP1ElementResultEnum:{261 TriaP1ElementResult* triavertexelementresult=NULL;262 triavertexelementresult=new TriaP1ElementResult();263 triavertexelementresult->Demarshall(&marshalled_dataset);264 dataset->AddObject(triavertexelementresult);}265 break;266 #ifdef _HAVE_3D_267 case PentaP1ElementResultEnum:{268 PentaP1ElementResult* pentavertexelementresult=NULL;269 pentavertexelementresult=new PentaP1ElementResult();270 pentavertexelementresult->Demarshall(&marshalled_dataset);271 dataset->AddObject(pentavertexelementresult);}272 break;273 case PentaEnum:{274 Penta* penta=NULL;275 penta=new Penta();276 penta->Demarshall(&marshalled_dataset);277 dataset->AddObject(penta);}278 break;279 #endif280 case MaticeEnum:{281 Matice* matice=NULL;282 matice=new Matice();283 matice->Demarshall(&marshalled_dataset);284 dataset->AddObject(matice);}285 break;286 case MatparEnum:{287 Matpar* matpar=NULL;288 matpar=new Matpar();289 matpar->Demarshall(&marshalled_dataset);290 dataset->AddObject(matpar);}291 break;292 case SpcStaticEnum:{293 SpcStatic* spcstatic=NULL;294 spcstatic=new SpcStatic();295 spcstatic->Demarshall(&marshalled_dataset);296 dataset->AddObject(spcstatic);}297 break;298 case SpcDynamicEnum:{299 SpcDynamic* spcdynamic=NULL;300 spcdynamic=new SpcDynamic();301 spcdynamic->Demarshall(&marshalled_dataset);302 dataset->AddObject(spcdynamic);}303 break;304 case SpcTransientEnum:{305 SpcTransient* spctransient=NULL;306 spctransient=new SpcTransient();307 spctransient->Demarshall(&marshalled_dataset);308 dataset->AddObject(spctransient);}309 break;310 case PengridEnum:{311 Pengrid* pengrid=NULL;312 pengrid=new Pengrid();313 pengrid->Demarshall(&marshalled_dataset);314 dataset->AddObject(pengrid);}315 break;316 case PenpairEnum:{317 Penpair* penpair=NULL;318 penpair=new Penpair();319 penpair->Demarshall(&marshalled_dataset);320 dataset->AddObject(penpair);}321 break;322 case IcefrontEnum:{323 Icefront* icefront=NULL;324 icefront=new Icefront();325 icefront->Demarshall(&marshalled_dataset);326 dataset->AddObject(icefront);}327 break;328 case NumericalfluxEnum:{329 Numericalflux* numericalflux=NULL;330 numericalflux=new Numericalflux();331 numericalflux->Demarshall(&marshalled_dataset);332 dataset->AddObject(numericalflux);}333 break;334 #ifdef _HAVE_RIFTS_335 case RiftfrontEnum:{336 Riftfront* riftfront=NULL;337 riftfront=new Riftfront();338 riftfront->Demarshall(&marshalled_dataset);339 dataset->AddObject(riftfront);}340 break;341 #endif342 case DoubleInputEnum:{343 DoubleInput* doubleinput=NULL;344 doubleinput=new DoubleInput();345 doubleinput->Demarshall(&marshalled_dataset);346 dataset->AddObject(doubleinput);}347 break;348 case IntInputEnum:{349 IntInput* intinput=NULL;350 intinput=new IntInput();351 intinput->Demarshall(&marshalled_dataset);352 dataset->AddObject(intinput);}353 break;354 case BoolInputEnum:{355 BoolInput* boolinput=NULL;356 boolinput=new BoolInput();357 boolinput->Demarshall(&marshalled_dataset);358 dataset->AddObject(boolinput);}359 break;360 case IntParamEnum:{361 IntParam* intparam=NULL;362 intparam=new IntParam();363 intparam->Demarshall(&marshalled_dataset);364 dataset->AddObject(intparam);}365 break;366 case BoolParamEnum:{367 BoolParam* boolparam=NULL;368 boolparam=new BoolParam();369 boolparam->Demarshall(&marshalled_dataset);370 dataset->AddObject(boolparam);}371 break;372 case StringParamEnum:{373 StringParam* stringparam=NULL;374 stringparam=new StringParam();375 stringparam->Demarshall(&marshalled_dataset);376 dataset->AddObject(stringparam);}377 break;378 case DoubleVecExternalResultEnum:{379 DoubleVecExternalResult* doublevecexternalresult=NULL;380 doublevecexternalresult=new DoubleVecExternalResult();381 doublevecexternalresult->Demarshall(&marshalled_dataset);382 dataset->AddObject(doublevecexternalresult);}383 break;384 case DoubleExternalResultEnum:{385 DoubleExternalResult* doubleexternalresult=NULL;386 doubleexternalresult=new DoubleExternalResult();387 doubleexternalresult->Demarshall(&marshalled_dataset);388 dataset->AddObject(doubleexternalresult);}389 break;390 #ifdef _HAVE_GROUNDINGLINE_391 case BoolElementResultEnum:{392 BoolElementResult* boolelementresult=NULL;393 boolelementresult=new BoolElementResult();394 boolelementresult->Demarshall(&marshalled_dataset);395 dataset->AddObject(boolelementresult);}396 break;397 #endif398 default:399 _error_("could not recognize enum type: %s",EnumToStringx(enum_type));400 }401 }402 403 /*Assign output pointers:*/404 *pmarshalled_dataset=marshalled_dataset;405 406 return dataset;407 }408 /*}}}*/409 #endif410 411 87 /*Specific methods*/ 412 88 /*FUNCTION DataSet::AddObject{{{1*/ -
issm/trunk/src/c/Container/DataSet.h
r9777 r12330 49 49 void Echo(); 50 50 void DeepEcho(); 51 #ifdef _SERIAL_52 char* Marshall();53 int MarshallSize();54 #endif55 51 int AddObject(Object* object); 56 52 int DeleteObject(int id); … … 69 65 }; 70 66 71 /*This routine cannot be object oriented, but need for demarshalling: */72 #ifdef _SERIAL_73 DataSet* DataSetDemarshall(char* marshalled_dataset);74 DataSet* DataSetDemarshallRaw(char** pmarshalled_dataset);75 67 #endif 76 77 78 79 #endif -
issm/trunk/src/c/Container/Elements.cpp
r11995 r12330 124 124 } 125 125 126 #ifdef _PARALLEL_127 126 /*Synchronize across cluster, so as to not end up with different sizes for each patch on each cpu: */ 127 #ifdef _HAVE_MPI_ 128 128 MPI_Reduce (&numvertices,&max_numvertices,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD ); 129 129 MPI_Bcast(&max_numvertices,1,MPI_INT,0,MPI_COMM_WORLD); … … 193 193 194 194 /*Get rank of first cpu that has results*/ 195 #ifdef _HAVE_MPI_ 195 196 if(this->Size()) rank=my_rank; 196 197 else rank=num_procs; 197 198 MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN,MPI_COMM_WORLD); 199 #else 200 minrank=my_rank; 201 #endif 198 202 199 203 /*see what the first element of this partition has in stock (this is common to all partitions)*/ … … 203 207 element->ListResultsInfo(&resultsenums,&resultssizes,&resultstimes,&resultssteps,&numberofresults); 204 208 } 209 #ifdef _HAVE_MPI_ 205 210 MPI_Bcast(&numberofresults,1,MPI_DOUBLE,minrank,MPI_COMM_WORLD); 211 #endif 206 212 207 213 /*Get out if there is no results. Otherwise broadcast info*/ 208 214 if(!numberofresults) return; 215 #ifdef _HAVE_MPI_ 209 216 if(my_rank!=minrank){ 210 217 resultsenums=(int*)xmalloc(numberofresults*sizeof(int)); … … 217 224 MPI_Bcast(resultstimes,numberofresults,MPI_DOUBLE,minrank,MPI_COMM_WORLD); 218 225 MPI_Bcast(resultssteps,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD); 226 #endif 219 227 220 228 /*Loop over all results and get nodal vector*/ … … 250 258 251 259 /*Gather onto master cpu 0, if needed: */ 252 #ifdef _PARALLEL_253 260 if(io_gather)patch->Gather(); 254 #endif255 261 256 262 /*create result object and add to results dataset:*/ … … 276 282 int numberofelements; 277 283 278 #ifdef _PARALLEL_279 284 local_nelem=this->Size(); 285 #ifdef _HAVE_MPI_ 280 286 MPI_Allreduce ( (void*)&local_nelem,(void*)&numberofelements,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); 281 287 #else 282 numberofelements= this->Size();288 numberofelements=local_nelem; 283 289 #endif 284 290 -
issm/trunk/src/c/Container/Loads.cpp
r10522 r12330 63 63 64 64 /*figure out total number of loads combining all the cpus (no clones here)*/ 65 #ifdef _ PARALLEL_65 #ifdef _HAVE_MPI_ 66 66 MPI_Reduce(&localloads,&numberofloads,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 67 67 MPI_Bcast(&numberofloads,1,MPI_INT,0,MPI_COMM_WORLD); … … 69 69 numberofloads=localloads; 70 70 #endif 71 71 72 72 73 return numberofloads; -
issm/trunk/src/c/Container/Nodes.cpp
r11527 r12330 83 83 * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of eache 84 84 * cpus by the total last dofs of the previus cpu, starting from 0. 85 * First: bet number of dofs for each cpu*/85 * First: get number of dofs for each cpu*/ 86 86 alldofcount=(int*)xmalloc(num_procs*sizeof(int)); 87 #ifdef _HAVE_MPI_ 87 88 MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD); 88 89 MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD); 90 #else 91 alldofcount[0]=dofcount; 92 #endif 89 93 90 94 /* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/ … … 119 123 } 120 124 } 121 MPI_Allreduce ( (void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 125 126 #ifdef _HAVE_MPI_ 127 MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 128 #else 129 for(i=0;i<numnodes*maxdofspernode;i++)alltruedofs[i]=truedofs[i]; 130 #endif 122 131 123 132 /* Now every cpu knows the true dofs of everyone else that is not a clone*/ … … 145 154 int numnodes; 146 155 147 148 156 /*Figure out number of nodes for this analysis: */ 149 157 numnodes=this->NumberOfNodes(analysis_type); … … 162 170 * dealt with by another cpu. We take the minimum because we are going to manage dof assignment in increasing 163 171 * order of cpu rank. This is also why we initialized this array to num_procs.*/ 172 #ifdef _HAVE_MPI_ 164 173 MPI_Allreduce ( (void*)ranks,(void*)minranks,numnodes,MPI_INT,MPI_MIN,MPI_COMM_WORLD); 174 #else 175 for(i=0;i<numnodes;i++)minranks[i]=ranks[i]; 176 #endif 165 177 166 178 /*Now go through all objects, and use minranks to flag which objects are cloned: */ … … 204 216 } 205 217 206 #ifdef _PARALLEL_207 218 /*Grab max of all cpus: */ 219 #ifdef _HAVE_MPI_ 208 220 MPI_Allreduce ( (void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 209 221 max=allmax; 210 #endif222 #endif 211 223 212 224 return max; … … 239 251 240 252 /*Gather from all cpus: */ 253 #ifdef _HAVE_MPI_ 241 254 MPI_Allreduce ( (void*)&numdofs,(void*)&allnumdofs,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); 255 #else 256 allnumdofs=numdofs; 257 #endif 242 258 return allnumdofs; 243 259 } … … 262 278 263 279 /*Gather from all cpus: */ 280 #ifdef _HAVE_MPI_ 264 281 MPI_Allreduce ( (void*)&numnodes,(void*)&allnumnodes,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); 282 #else 283 allnumnodes=numnodes; 284 #endif 265 285 266 286 return allnumnodes; … … 288 308 } 289 309 290 #ifdef _ PARALLEL_291 292 293 294 #endif 310 #ifdef _HAVE_MPI_ 311 MPI_Reduce (&max_sid,&node_max_sid,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD ); 312 MPI_Bcast(&node_max_sid,1,MPI_INT,0,MPI_COMM_WORLD); 313 max_sid=node_max_sid; 314 #endif 295 315 296 316 if(max_sid==1){ -
issm/trunk/src/c/Container/Options.cpp
r11995 r12330 13 13 #include <vector> 14 14 #include <algorithm> 15 #include <cstring> 15 16 16 17 #include "./DataSet.h" … … 20 21 #include "../shared/shared.h" 21 22 #include "../EnumDefinitions/EnumDefinitions.h" 22 #if _SERIAL_23 23 #include "../io/io.h" 24 #endif25 24 /*}}}*/ 26 25 … … 31 30 } 32 31 /*}}}*/ 33 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)34 /*FUNCTION Options::Options(int istart, int nrhs, const mxArray* prhs[]){{{1*/35 Options::Options(int istart, int nrhs, const mxArray* prhs[]){36 37 int i;38 char *name = NULL;39 Option *option = NULL;40 41 /*loop over each name and value*/42 for (i=istart; i<nrhs; i=i+2){43 if (!mxIsClass(prhs[i],"char")) _error_("Argument %d must be name of option.",i+1);44 45 FetchData(&name,prhs[i]);46 if (i+1 == nrhs) _error_("Argument %d must exist and be value of option \"%s\".",i+2,name);47 48 //_printf_(true," Processing option \"%s\" of class \"%s\".\n",name,mxGetClassName(prhs[i+1]));49 option=(Option*)OptionParse(name,&prhs[i+1]);50 this->AddOption(option);51 option=NULL;52 }53 54 /*echo the dataset */55 //if (this->Size()) for(i=0;i<this->Size();i++) ((Option*)this->GetObjectByOffset(i))->Echo();56 }57 /*}}}*/58 #endif59 32 /*FUNCTION Options::~Options(){{{1*/ 60 33 Options::~Options(){ … … 93 66 94 67 return 1; 68 } 69 /*}}}*/ 70 /*FUNCTION Options::Get(int* pvalue, char* name){{{1*/ 71 void Options::Get(int* pvalue,const char* name){ 72 73 vector<Object*>::iterator object; 74 Option* option=NULL; 75 76 /*Get option*/ 77 option=GetOption(name); 78 79 /*If the pointer is not NULL, the option has been found*/ 80 if(option){ 81 option->Get(pvalue); 82 } 83 /*Else, the Option does not exist, no default provided*/ 84 else{ 85 _error_("option of name \"%s\" not found, and no default value has been provided",name); 86 } 87 } 88 /*}}}*/ 89 /*FUNCTION Options::Get(int* pvalue, char* name,int default_value){{{1*/ 90 void Options::Get(int* pvalue,const char* name,int default_value){ 91 92 vector<Object*>::iterator object; 93 Option* option=NULL; 94 95 /*Get option*/ 96 option=GetOption(name); 97 98 /*If the pointer is not NULL, the option has been found*/ 99 if(option){ 100 option->Get(pvalue); 101 } 102 /*Else, the Option does not exist, a default is provided here*/ 103 else{ 104 *pvalue=default_value; 105 } 95 106 } 96 107 /*}}}*/ -
issm/trunk/src/c/Container/Options.h
r11995 r12330 15 15 /*constructors, destructors*/ 16 16 Options(); 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 Options(int istart, int nrhs, const mxArray* prhs[]);19 #endif20 17 ~Options(); 21 18 … … 25 22 void Get(double* pvalue,const char* name); 26 23 void Get(double* pvalue,const char* name,double default_value); 24 void Get(int* pvalue,const char* name); 25 void Get(int* pvalue,const char* name,int default_value); 27 26 void Get(bool* pvalue,const char* name); 28 27 void Get(bool* pvalue,const char* name,bool default_value); -
issm/trunk/src/c/Container/Parameters.h
r11995 r12330 5 5 #ifndef _CONTAINER_PARAMETERS_H_ 6 6 #define _CONTAINER_PARAMETERS_H_ 7 #include <stdio.h> 7 8 8 9 /*forward declarations */ -
issm/trunk/src/c/Container/Results.cpp
r11995 r12330 65 65 /*}}}*/ 66 66 /*FUNCTION Results::Write{{{1*/ 67 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)68 void Results::Write(mxArray** pdataref){69 70 int i,j;71 int count;72 73 /*output: */74 mxArray* dataref=NULL;75 mxArray* processeddataref=NULL;76 mwSize nfields;77 mwSize maxfields;78 mwSize nsteps;79 mwSize step;80 const char **fnames = NULL;81 int *enums = NULL;82 int baseenum;83 mwSize onebyone[2] = {1,1};84 mwSize ndim = 2;85 86 /*How many time steps do we have? : */87 nsteps=0;88 for(i=0;i<this->Size();i++){89 ExternalResult* result=(ExternalResult*)this->GetObjectByOffset(i);90 step=result->GetStep();91 if(step>nsteps)nsteps=step;92 }93 onebyone[0]=nsteps;94 95 /*How many field names do we have. First, figure out how many result types we have: */96 maxfields=(mwSize)this->Size();97 enums=(int*)xmalloc(maxfields*sizeof(int));98 for(i=0;i<maxfields;i++){99 ExternalResult* result=(ExternalResult*)this->GetObjectByOffset(i);100 enums[i]=result->InstanceEnum();101 }102 /*Now, make result types unique: */103 for(i=0;i<maxfields;i++){104 if(enums[i]>=0){//if <0, it means this enum was found to replicate another one previously105 baseenum=enums[i];106 /*is the baseenum repeated later on?:*/107 for(j=i+1;j<maxfields;j++){108 if (enums[j]==baseenum)enums[j]=-1;109 }110 }111 else continue;112 }113 114 /*Now, go through enums, and whatever is not null is a non repeated field name: */115 nfields=0;116 for(i=0;i<maxfields;i++)if(enums[i]>0)nfields++;117 118 /*Add 2 fields for time and step: */119 nfields=nfields+2;120 121 /*Fill the names of the structure field: */122 fnames=(const char**)xmalloc(nfields*sizeof(char*));123 count=0;124 for(i=0;i<maxfields;i++){125 if (enums[i]>0){126 fnames[count]=EnumToStringx(enums[i]);127 count++;128 }129 }130 /*don't forget the extra fields "time" and "step":*/131 fnames[nfields-2]="time";132 fnames[nfields-1]="step";133 134 /*Initialize structure: */135 dataref=mxCreateStructArray( ndim,onebyone,nfields,fnames);136 137 /*Fill each field: */138 for(i=0;i<this->Size();i++){ //do not include the last one used for time139 ExternalResult* result=(ExternalResult*)this->GetObjectByOffset(i);140 result->SetMatlabField(dataref);141 }142 143 /*Now, process the patch in the dataref structure, by calling MatlabProcessPatch.m144 *on the current dataref structure: */145 mexCallMATLAB(1,&processeddataref,1,&dataref, "MatlabProcessPatch");146 147 /*Assign output pointers:*/148 *pdataref=processeddataref;149 }150 #else151 67 void Results::Write(Parameters* parameters){ 152 68 … … 167 83 168 84 } 169 #endif170 85 /*}}}*/ -
issm/trunk/src/c/Container/Results.h
r11995 r12330 26 26 /*numerics: {{{1*/ 27 27 Results* SpawnTriaResults(int* indices); 28 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)29 void Write(mxArray** pdataref);30 #else31 28 void Write(Parameters* parameters); 32 #endif33 29 /*}}}*/ 34 30 }; -
issm/trunk/src/c/Container/Vertices.cpp
r11527 r12330 61 61 * First: bet number of dofs for each cpu*/ 62 62 alldofcount=(int*)xmalloc(num_procs*sizeof(int)); 63 #ifdef _HAVE_MPI_ 63 64 MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD); 64 65 MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD); 66 #else 67 alldofcount[0]=dofcount; 68 #endif 65 69 66 70 /* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/ … … 85 89 vertex->ShowTrueDofs(truedofs); 86 90 } 91 #ifdef _HAVE_MPI_ 87 92 MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numberofobjects*numberofdofsperobject,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 93 #else 94 for(i=0;i<numberofobjects*numberofdofsperobject;i++)alltruedofs[i]=truedofs[i]; 95 #endif 88 96 89 97 /* Now every cpu knows the true dofs of everyone else that is not a clone*/ … … 121 129 * dealt with by another cpu. We take the minimum because we are going to manage dof assignment in increasing 122 130 * order of cpu rank. This is also why we initialized this array to num_procs.*/ 131 #ifdef _HAVE_MPI_ 123 132 MPI_Allreduce ( (void*)ranks,(void*)minranks,numberofobjects,MPI_INT,MPI_MIN,MPI_COMM_WORLD); 133 #else 134 for(i=0;i<numberofobjects;i++)minranks[i]=ranks[i]; 135 #endif 124 136 125 137 /*Now go through all objects, and use minranks to flag which objects are cloned: */ … … 149 161 } 150 162 151 #ifdef _ PARALLEL_163 #ifdef _HAVE_MPI_ 152 164 MPI_Reduce (&max_sid,&vertex_max_sid,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD ); 153 165 MPI_Bcast(&vertex_max_sid,1,MPI_INT,0,MPI_COMM_WORLD); -
issm/trunk/src/c/Container/Vertices.h
r10522 r12330 32 32 }; 33 33 34 35 36 34 #endif //ifndef _VERTICES_H_ 37 -
issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
r12301 r12330 153 153 PetscProfilingCurrentFlopsEnum, 154 154 PetscProfilingSolutionTimeEnum, 155 MaxIterationConvergenceFlagEnum, 155 156 SteadystateMaxiterEnum, 156 157 SteadystateNumRequestedOutputsEnum, -
issm/trunk/src/c/EnumDefinitions/Synchronize.sh
r11995 r12330 2 2 #Synchronize EnumToStringx.cpp and StringToEnumx.cpp and matlab Enums 3 3 4 #Get all lines of EnumDefinitions2.h which hold Enum | remove all comas | add line number in the first column> put everything in file temp5 cat EnumDefinitions.h | grep -e "[0-9]Enum," -e "[a-zA-Z]Enum," | grep -v include | sed -e "s/,/ /g" | awk '{ printf "%s %s\n", NR, $0}' > temp4 #Get all lines of EnumDefinitions2.h which hold Enum | remove all comas > put everything in file temp 5 cat EnumDefinitions.h | grep -e "[0-9]Enum," -e "[a-zA-Z]Enum," | grep -v include | sed -e "s/,/ /g" | awk '{print $1}' > temp 6 6 7 7 #Removed existing files 8 rm $ISSM_ TIER/src/m/enum/*.m9 rm $ISSM_ TIER/src/c/modules/EnumToStringx/EnumToStringx.cpp10 rm $ISSM_ TIER/src/c/modules/StringToEnumx/StringToEnumx.cpp8 rm $ISSM_DIR/src/m/enum/*.m 9 rm $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp 10 rm $ISSM_DIR/src/c/modules/StringToEnumx/StringToEnumx.cpp 11 11 12 12 #Get number of enums 13 13 NUMENUMS=$(wc -l temp | awk '{printf("%s",$1);}'); 14 14 15 #Build EnumToStringx.cpp {{{ 115 #Build EnumToStringx.cpp {{{ 16 16 #Header 17 cat <<END > $ISSM_ TIER/src/c/modules/EnumToStringx/EnumToStringx.cpp17 cat <<END > $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp 18 18 /* 19 19 * \file EnumToStringx.cpp: … … 35 35 END 36 36 #core 37 cat temp | awk '{print "\t\t" "case " $ 2" : return \"" substr($2,1,length($2)-4) "\";"}' >> $ISSM_TIER/src/c/modules/EnumToStringx/EnumToStringx.cpp37 cat temp | awk '{print "\t\t" "case " $1" : return \"" substr($1,1,length($1)-4) "\";"}' >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp 38 38 #Footer 39 cat <<END >> $ISSM_ TIER/src/c/modules/EnumToStringx/EnumToStringx.cpp39 cat <<END >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp 40 40 default : return "unknown"; 41 41 … … 57 57 #Build StringToEnumx.cpp {{{1 58 58 #Header 59 cat <<END > $ISSM_ TIER/src/c/modules/StringToEnumx/StringToEnumx.cpp59 cat <<END > $ISSM_DIR/src/c/modules/StringToEnumx/StringToEnumx.cpp 60 60 /* 61 61 * \file StringToEnumx.cpp: … … 81 81 i2=120; 82 82 for (( i=1 ; i<=100 ; i++ )); do 83 echo " if(stage==$i){" >> $ISSM_ TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp83 echo " if(stage==$i){" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp 84 84 awk -v i1=$i1 -v i2=$i2 '{if(NR>=i1 && NR<=i2) print $0 }' temp | 85 awk '{print "\t" ((NR==1)?" if":" else if") " (strcmp(name,\"" substr($ 2,1,length($2)-4) "\")==0) return " $2 ";"}' >> $ISSM_TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp86 echo " else stage=$(($i+1));" >> $ISSM_ TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp87 echo " }" >> $ISSM_ TIER//src/c/modules/StringToEnumx/StringToEnumx.cpp85 awk '{print "\t" ((NR==1)?" if":" else if") " (strcmp(name,\"" substr($1,1,length($1)-4) "\")==0) return " $1 ";"}' >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp 86 echo " else stage=$(($i+1));" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp 87 echo " }" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp 88 88 89 89 if [ $i2 -ge $NUMENUMS ]; then break; fi … … 93 93 94 94 #footer 95 cat <<END >> $ISSM_ TIER/src/c/modules/StringToEnumx/StringToEnumx.cpp95 cat <<END >> $ISSM_DIR/src/c/modules/StringToEnumx/StringToEnumx.cpp 96 96 /*If we reach this point, the string provided has not been found*/ 97 97 _error_("Enum %s not found",name); … … 101 101 102 102 # go through the lines of temp 103 for (( i=1 ; i<=$NUMENUMS ; i++ )); do 103 ENUM=0; 104 for NAMEENUM in $(cat temp); do 104 105 105 106 #Get name and enum of the line i 106 NAMEENUM=$(cat temp | grep "^[ ]*$i " | awk '{printf("%s",$2);}');107 107 NAME=$(echo $NAMEENUM | sed -e "s/Enum//g") 108 ENUM=$i;109 108 #offset Enum by one (Enum begins with 0 and not 1!) 110 let ENUM=$ENUM -1109 let ENUM=$ENUM+1 111 110 112 111 #print info {{{ 113 if [ $ i-lt 10 ]112 if [ $ENUM -lt 10 ] 114 113 then 115 114 printf "\r " 116 printf "\r $ i/$NUMENUMS Adding "$NAME"..."115 printf "\r $ENUM/$NUMENUMS Adding "$NAME"..." 117 116 else 118 if [ $ i-lt 100 ]117 if [ $ENUM -lt 100 ] 119 118 then 120 119 printf "\r " 121 printf "\r $ i/$NUMENUMS Adding "$NAME"..."120 printf "\r $ENUM/$NUMENUMS Adding "$NAME"..." 122 121 else 123 122 printf "\r " 124 printf "\r$ i/$NUMENUMS Adding "$NAME"..."123 printf "\r$ENUM/$NUMENUMS Adding "$NAME"..." 125 124 fi 126 125 fi 127 126 #}}} 128 127 #Add case to matlabenum file{{{ 129 cat <<END > $ISSM_ TIER"/src/m/enum/"$(echo $NAMEENUM".m")128 cat <<END > $ISSM_DIR"/src/m/enum/"$(echo $NAMEENUM".m") 130 129 function macro=$(echo $NAMEENUM)() 131 130 %$(echo $NAMEENUM | awk {'print toupper($1)'}) - Enum of $(echo $NAME) … … 143 142 144 143 done 144 #MaximumNumberOfEnums{{{ 145 cat <<END > $ISSM_DIR/src/m/enum/MaximumNumberOfEnums.m 146 function macro=MaximumNumberOfEnums() 147 %$(echo "MaximumNumberOfEnums" | awk {'print toupper($1)'}) - Enum of MaximumNumberOfEnums 148 % 149 % WARNING: DO NOT MODIFY THIS FILE 150 % this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh 151 % Please read src/c/EnumDefinitions/README for more information 152 % 153 % Usage: 154 % macro=MaximumNumberOfEnums() 155 156 macro=$(cat EnumDefinitions.h | grep -e "[0-9]Enum" -e "[a-zA-Z]Enum" | grep -v include \ 157 | awk '{ printf "%s %s\n", NR-1, $0 }' \ 158 | grep "MaximumNumberOfEnums" | awk '{print $1}'); 159 END 160 #}}} 145 161 146 162 #clean up{{{ -
issm/trunk/src/c/Makefile.am
r11995 r12330 4 4 5 5 #Library declaration {{{1 6 #Compile serial library, and then try and compile parallel library 7 if NOSERIAL 8 if NOPARALLEL 9 lib_LIBRARIES = 10 else 11 lib_LIBRARIES = libpISSM.a libOverload.a 12 endif 13 else 14 if NOPARALLEL 15 lib_LIBRARIES = libISSM.a libOverload.a 16 else 17 lib_LIBRARIES = libISSM.a libpISSM.a libOverload.a 18 endif 6 lib_LIBRARIES = libISSMCore.a libISSMOverload.a 7 if PYTHON 8 lib_LIBRARIES += libISSMPython.a 9 endif 10 if MATLAB 11 lib_LIBRARIES += libISSMMatlab.a 12 endif 13 if MODULES 14 lib_LIBRARIES += libISSMModules.a 19 15 endif 20 16 #}}} … … 22 18 #sources 23 19 #Core sources{{{1 24 core_sources = ./include/macros.h\ 20 core_sources = ./issm.h\ 21 ./issm-binding.h\ 22 ./include/macros.h\ 25 23 ./include/typedefs.h\ 26 24 ./include/types.h\ … … 211 209 ./shared/Wrapper/ModuleBoot.cpp\ 212 210 ./shared/Wrapper/ModuleEnd.cpp\ 213 ./toolkits/mpi/mpiincludes.h\214 ./toolkits/mpi/patches/mpipatches.h\215 ./toolkits/mpi/patches/DetermineLocalSize.cpp\216 ./toolkits/mpi/patches/MPI_Upperrow.cpp\217 ./toolkits/mpi/patches/MPI_Lowerrow.cpp\218 ./toolkits/mpi/patches/MPI_Boundariesfromrange.cpp\219 211 ./toolkits/metis/metisincludes.h\ 220 212 ./toolkits/issm/issmtoolkit.h\ … … 223 215 ./toolkits/issm/SeqMat.h\ 224 216 ./toolkits/issm/SeqMat.cpp\ 225 ./toolkits/metis/patches/metispatches.h\226 ./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp\227 217 ./toolkits/triangle/triangleincludes.h\ 228 218 ./toolkitsenums.h\ … … 362 352 ./modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp\ 363 353 ./modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp\ 364 ./modules/AverageOntoPartitionx/AverageOntoPartitionx.h 365 dakota_psources=./modules/Dakotax/SpawnCoreParallel.cpp354 ./modules/AverageOntoPartitionx/AverageOntoPartitionx.h\ 355 ./modules/Dakotax/SpawnCoreParallel.cpp 366 356 #}}} 367 357 #Transient sources {{{1 368 transient_sources = ./modules/ModelProcessorx/Transient/UpdateElementsTransient.cpp 369 transient_psources =./solutions/transient_core.cpp358 transient_sources = ./modules/ModelProcessorx/Transient/UpdateElementsTransient.cpp \ 359 ./solutions/transient_core.cpp 370 360 #}}} 371 361 #Steadystate sources {{{1 372 steadystate_ psources = ./solutions/steadystate_core.cpp\373 362 steadystate_sources = ./solutions/steadystate_core.cpp\ 363 ./solutions/steadystateconvergence.cpp 374 364 #}}} 375 365 #Prognostic sources {{{1 … … 377 367 ./modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp\ 378 368 ./modules/ModelProcessorx/Prognostic/CreateConstraintsPrognostic.cpp\ 379 ./modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp 380 prognostic_psources =./solutions/prognostic_core.cpp369 ./modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp\ 370 ./solutions/prognostic_core.cpp 381 371 #}}} 382 372 #Thermal sources {{{1 … … 395 385 ./modules/ConstraintsStatex/ThermalConstraintsState.cpp\ 396 386 ./modules/ConstraintsStatex/ThermalIsPresent.cpp\ 397 ./modules/ResetConstraintsx/ThermalConstraintsReset.cpp 398 399 thermal_psources = ./solutions/thermal_core.cpp\ 400 ./solutions/enthalpy_core.cpp\ 401 ./solvers/solver_thermal_nonlinear.cpp 387 ./modules/ResetConstraintsx/ThermalConstraintsReset.cpp \ 388 ./solutions/thermal_core.cpp\ 389 ./solutions/enthalpy_core.cpp\ 390 ./solvers/solver_thermal_nonlinear.cpp 402 391 #}}} 403 392 #Control sources {{{1 … … 443 432 ./objects/Inputs/ControlInput.cpp\ 444 433 ./shared/Numerics/BrentSearch.cpp\ 445 ./shared/Numerics/OptimalSearch.cpp\ 446 ./shared/Numerics/OptFunc.cpp 447 448 control_psources=./solutions/control_core.cpp\ 434 ./shared/Numerics/OptimalSearch.cpp \ 435 ./solutions/control_core.cpp\ 449 436 ./solutions/controltao_core.cpp\ 450 437 ./solutions/controlrestart.cpp\ … … 462 449 ./modules/ModelProcessorx/Hydrology/CreateNodesHydrology.cpp\ 463 450 ./modules/ModelProcessorx/Hydrology/CreateConstraintsHydrology.cpp\ 464 ./modules/ModelProcessorx/Hydrology/CreateLoadsHydrology.cpp 465 466 hydrology_psources = ./solutions/hydrology_core.cpp\ 467 ./solutions/hydrology_core_step.cpp 451 ./modules/ModelProcessorx/Hydrology/CreateLoadsHydrology.cpp \ 452 ./solutions/hydrology_core.cpp\ 453 ./solutions/hydrology_core_step.cpp 468 454 #}}} 469 455 #Diagnostic sources {{{1 … … 480 466 ./modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp \ 481 467 ./modules/ModelProcessorx/DiagnosticHutter/CreateLoadsDiagnosticHutter.cpp \ 482 483 484 485 486 ./shared/Elements/TransformSolutionCoord.cpp487 diagnostic_psources =./solutions/diagnostic_core.cpp\488 468 ./shared/Elements/CoordinateSystemTransform.cpp\ 469 ./shared/Elements/TransformLoadVectorCoord.cpp \ 470 ./shared/Elements/TransformStiffnessMatrixCoord.cpp \ 471 ./shared/Elements/TransformInvStiffnessMatrixCoord.cpp \ 472 ./shared/Elements/TransformSolutionCoord.cpp\ 473 ./solutions/diagnostic_core.cpp\ 474 ./solvers/solver_stokescoupling_nonlinear.cpp 489 475 #}}} 490 476 #Balanced sources {{{1 … … 492 478 ./modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp\ 493 479 ./modules/ModelProcessorx/Balancethickness/CreateConstraintsBalancethickness.cpp\ 494 ./modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp495 balanced_psources =./solutions/balancethickness_core.cpp480 ./modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp\ 481 ./solutions/balancethickness_core.cpp 496 482 #}}} 497 483 #Responses sources {{{1 … … 533 519 ./modules/ModelProcessorx/SurfaceSlope/CreateNodesSurfaceSlope.cpp \ 534 520 ./modules/ModelProcessorx/SurfaceSlope/CreateConstraintsSurfaceSlope.cpp\ 535 ./modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp 536 slope_psources =./solutions/surfaceslope_core.cpp\521 ./modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp\ 522 ./solutions/surfaceslope_core.cpp\ 537 523 ./solutions/bedslope_core.cpp 538 524 #}}} … … 589 575 ./objects/Bamg/Metric.cpp\ 590 576 ./objects/Bamg/Metric.h\ 591 ./objects/Bamg/ QuadTree.cpp\592 ./objects/Bamg/ QuadTree.h\577 ./objects/Bamg/BamgQuadtree.cpp\ 578 ./objects/Bamg/BamgQuadtree.h\ 593 579 ./objects/Bamg/R2.h\ 594 580 ./objects/Bamg/SetOfE4.cpp\ … … 625 611 ./modules/BamgTriangulatex/BamgTriangulatex.cpp\ 626 612 ./modules/BamgTriangulatex/BamgTriangulatex.h 613 #}}} 614 #Kriging sources {{{1 615 kriging_sources = ./Container/Observations.h\ 616 ./Container/Observations.cpp\ 617 ./objects/Kriging/Variogram.h \ 618 ./objects/Kriging/GaussianVariogram.h\ 619 ./objects/Kriging/GaussianVariogram.cpp\ 620 ./objects/Kriging/ExponentialVariogram.h\ 621 ./objects/Kriging/ExponentialVariogram.cpp\ 622 ./objects/Kriging/SphericalVariogram.h\ 623 ./objects/Kriging/SphericalVariogram.cpp\ 624 ./objects/Kriging/PowerVariogram.h\ 625 ./objects/Kriging/PowerVariogram.cpp\ 626 ./objects/Kriging/Quadtree.h\ 627 ./objects/Kriging/Quadtree.cpp\ 628 ./objects/Kriging/Observation.h\ 629 ./objects/Kriging/Observation.cpp\ 630 ./modules/Krigingx/Krigingx.cpp\ 631 ./modules/Krigingx/Krigingx.h 632 627 633 #}}} 628 634 #Kml sources {{{1 … … 694 700 ./objects/KML/KMLFileReadUtils.h 695 701 #}}} 696 #Matlab sources {{{1697 matlab_sources= ./toolkits/matlab/matlabincludes.h\698 ./toolkits/matlab/MatlabNArrayToNArray.cpp\699 ./toolkits/double/MatlabVectorToDoubleVector.cpp\700 ./toolkits/double/double.h\701 ./toolkits/double/MatlabMatrixToDoubleMatrix.cpp\702 ./io/Matlab/matlabio.h\703 ./io/Matlab/CheckNumMatlabArguments.cpp\704 ./io/Matlab/mxGetAssignedField.cpp\705 ./io/Matlab/WriteMatlabData.cpp\706 ./io/Matlab/FetchMatlabData.cpp\707 ./io/Matlab/OptionParse.cpp708 #}}}709 #Python sources {{{1710 python_sources= ./io/Python/pythonio.h\711 ./io/Python/WritePythonData.cpp\712 ./io/Python/CheckNumPythonArguments.cpp\713 ./io/Python/FetchPythonData.cpp714 #}}}715 702 #Petsc sources {{{1 716 703 petsc_sources= ./toolkits/petsc\ … … 718 705 ./toolkits/petsc/patches/SolverEnum.h\ 719 706 ./toolkits/petsc/patches/petscpatches.h\ 720 ./toolkits/petsc/patches/MatlabMatrixToPetscMatrix.cpp\721 ./toolkits/petsc/patches/MatlabVectorToPetscVector.cpp\722 ./toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp\723 ./toolkits/petsc/patches/PetscVectorToMatlabVector.cpp\724 707 ./toolkits/petsc/patches/VecTranspose.cpp\ 725 708 ./toolkits/petsc/patches/VecToMPISerial.cpp\ … … 732 715 ./toolkits/petsc/patches/SerialToVec.cpp\ 733 716 ./toolkits/petsc/patches/VecFree.cpp\ 717 ./toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp\ 718 ./toolkits/petsc/patches/PetscVectorToDoubleVector.cpp\ 734 719 ./toolkits/petsc/patches/VecDuplicatePatch.cpp\ 735 720 ./toolkits/petsc/patches/KSPFree.cpp\ … … 754 739 755 740 #}}} 756 #Serialsources {{{1 757 serial_sources= ./objects/Options/Option.cpp\ 741 #Mpi sources {{{1 742 mpi_sources= ./toolkits/mpi/mpiincludes.h\ 743 ./toolkits/mpi/patches/mpipatches.h\ 744 ./toolkits/mpi/patches/DetermineLocalSize.cpp\ 745 ./toolkits/mpi/patches/MPI_Upperrow.cpp\ 746 ./toolkits/mpi/patches/MPI_Lowerrow.cpp\ 747 ./toolkits/mpi/patches/MPI_Boundariesfromrange.cpp 748 #}}} 749 #Metis sources {{{1 750 metis_sources= ./toolkits/metis/patches/metispatches.h\ 751 ./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp 752 #}}} 753 #Python sources {{{1 754 python_sources= ./python/io/pythonio.h\ 755 ./python/python-binding.h\ 756 ./python/io/WritePythonData.cpp\ 757 ./python/io/CheckNumPythonArguments.cpp\ 758 ./python/io/FetchPythonData.cpp 759 760 #}}} 761 #Matlab sources {{{1 762 matlab_sources= ./toolkits/matlab/matlabincludes.h\ 763 ./matlab/matlab-binding.h\ 764 ./matlab/io/matlabio.h\ 765 ./matlab/io/MatlabNArrayToNArray.cpp\ 766 ./matlab/io/CheckNumMatlabArguments.cpp\ 767 ./matlab/io/mxGetAssignedField.cpp\ 768 ./matlab/io/WriteMatlabData.cpp\ 769 ./matlab/io/FetchMatlabData.cpp\ 770 ./matlab/io/OptionParse.cpp\ 771 ./matlab/io/MatlabMatrixToMatrix.cpp\ 772 ./matlab/io/MatlabVectorToVector.cpp\ 773 ./matlab/io/MatlabVectorToDoubleVector.cpp\ 774 ./matlab/io/MatlabMatrixToDoubleMatrix.cpp\ 775 ./matlab/io/MatlabMatrixToSeqMat.cpp\ 776 ./matlab/io/MatlabVectorToSeqVec.cpp 777 #}}} 778 #Matlab and Petsc sources {{{1 779 matlabpetsc_sources= ./matlab/io/MatlabMatrixToPetscMatrix.cpp\ 780 ./matlab/io/MatlabVectorToPetscVector.cpp 781 782 #}}} 783 #Modules sources{{{1 784 module_sources= ./objects/Options/Option.cpp\ 758 785 ./objects/Options/Option.h\ 759 786 ./objects/Options/OptionDouble.cpp\ … … 769 796 ./objects/Options/OptionUtilities.cpp\ 770 797 ./objects/Options/OptionUtilities.h\ 798 ./shared/Alloc/alloc_module.h\ 799 ./shared/Alloc/alloc_module.cpp\ 771 800 ./shared/Threads/issm_threads.h\ 772 801 ./shared/Threads/LaunchThread.cpp\ … … 790 819 ./modules/Chacox/chaco_seconds.cpp\ 791 820 ./modules/Chacox/user_params.cpp\ 792 ./modules/Dakotax/SpawnCoreSerial.cpp\793 821 ./modules/TriaSearchx/TriaSearchx.h\ 794 822 ./modules/TriaSearchx/TriaSearchx.cpp\ … … 841 869 #}}} 842 870 871 #{{{1 Conditional build-up of sources 843 872 #ISSM sources are a combination of core sources and sources related to specific capabilities (which can 844 873 #be activated by autotools conditionals 845 #{{{1 874 846 875 847 876 #First the core 848 877 issm_sources = $(core_sources) 849 issm_psources =850 878 851 879 #Now the optional source 852 880 if DAKOTA 853 881 issm_sources += $(dakota_sources) 854 issm_psources += $(dakota_psources)855 882 endif 856 883 857 884 if PETSC 858 885 issm_sources += $(petsc_sources) 859 issm_psources += $(petsc_psources)860 886 endif 861 887 862 888 if GSL 863 889 issm_sources += $(gsl_sources) 864 issm_psources += $(gsl_psources) 865 endif 866 890 endif 867 891 868 892 if TRANSIENT 869 893 issm_sources += $(transient_sources) 870 issm_psources += $(transient_psources)871 894 endif 872 895 873 896 if STEADYSTATE 874 897 issm_sources += $(steadystate_sources) 875 issm_psources += $(steadystate_psources)876 898 endif 877 899 878 900 if PROGNOSTIC 879 901 issm_sources += $(prognostic_sources) 880 issm_psources += $(prognostic_psources)881 902 endif 882 903 883 904 if THERMAL 884 905 issm_sources += $(thermal_sources) 885 issm_psources += $(thermal_psources)886 906 endif 887 907 888 908 if CONTROL 889 909 issm_sources += $(control_sources) 890 issm_psources += $(control_psources)891 910 endif 892 911 893 912 if HYDROLOGY 894 913 issm_sources += $(hydrology_sources) 895 issm_psources += $(hydrology_psources)896 914 endif 897 915 898 916 if DIAGNOSTIC 899 917 issm_sources += $(diagnostic_sources) 900 issm_psources += $(diagnostic_psources)901 918 endif 902 919 903 920 if BALANCED 904 921 issm_sources += $(balanced_sources) 905 issm_psources += $(balanced_psources)906 922 endif 907 923 … … 912 928 if SLOPE 913 929 issm_sources += $(slope_sources) 914 issm_psources += $(slope_psources)915 930 endif 916 931 … … 926 941 issm_sources += $(threed_sources) 927 942 endif 928 #}}} 929 930 #ISSM serial library {{{1 931 if SERIAL 932 libISSM_a_SOURCES = $(issm_sources) 933 libISSM_a_SOURCES += $(serial_sources) 934 libISSM_a_SOURCES += $(bamg_sources) 935 libISSM_a_SOURCES += $(kml_sources) 936 libISSM_a_CXXFLAGS = -fPIC -D_SERIAL_ -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_ $(CXXFLAGS) $(CXXOPTFLAGS) 937 #libISSM_a_CXXFLAGS = -D_SERIAL_ -DTRILIBRARY -DANSI_DECLARATORS -DNO_TIMER $(CXXFLAGS) $(CXXOPTFLAGS) 943 944 if MPI 945 issm_sources += $(mpi_sources) 946 endif 947 948 if METIS 949 issm_sources += $(metis_sources) 950 endif 951 952 if PETSC 953 if MATLAB 954 issm_sources += $(matlabpetsc_sources) 955 endif 956 endif 957 958 959 #}}} 960 #Library flags and sources {{{1 961 ALLCXXFLAGS= -fPIC -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_ $(CXXFLAGS) $(CXXOPTFLAGS) 962 963 libISSMCore_a_SOURCES = $(issm_sources) 964 libISSMCore_a_CXXFLAGS = $(ALLCXXFLAGS) 965 966 if MODULES 967 libISSMModules_a_SOURCES = $(module_sources) 968 libISSMModules_a_SOURCES += $(bamg_sources) 969 libISSMModules_a_SOURCES += $(kriging_sources) 970 libISSMModules_a_SOURCES += $(kml_sources) 971 libISSMModules_a_CXXFLAGS = $(ALLCXXFLAGS) 972 endif 938 973 939 974 if PYTHON 940 libISSM _a_CXXFLAGS+= -DNPY_NO_DEPRECATED_API941 libISSM _a_SOURCES += $(python_sources)975 libISSMPython_a_SOURCES = $(python_sources) 976 libISSMPython_a_CXXFLAGS= $(ALLCXXFLAGS) 942 977 endif 943 978 944 979 if MATLAB 945 libISSM_a_SOURCES += $(matlab_sources) 946 endif 947 948 endif 949 #}}} 950 #ISSM parallel library {{{1 951 if PARALLEL 952 libpISSM_a_SOURCES = $(issm_sources) 953 libpISSM_a_SOURCES += $(issm_psources) 954 libpISSM_a_CXXFLAGS = -fPIC -D_PARALLEL_ -D_C_ $(CXXFLAGS) $(CXXOPTFLAGS) 955 endif 980 libISSMMatlab_a_SOURCES = $(matlab_sources) 981 libISSMMatlab_a_CXXFLAGS= $(ALLCXXFLAGS) 982 endif 983 956 984 #}}} 957 985 #Overload library, to overload any non-standard symbols. {{{1 958 lib Overload_a_SOURCES = ./shared/String/stricmp.c959 lib Overload_a_CFLAGS = -fPIC -D_PARALLEL_-D_C_ $(COPTFLAGS) $(CFLAGS)986 libISSMOverload_a_SOURCES = ./shared/String/stricmp.c 987 libISSMOverload_a_CFLAGS = -fPIC -D_C_ $(COPTFLAGS) $(CFLAGS) 960 988 #}}} 961 989 962 990 #Executable {{{1 963 if NOPARALLEL964 bin_PROGRAMS =965 else966 991 bin_PROGRAMS = issm 967 endif968 992 969 993 #Standard libraries 970 LDADD = ./lib pISSM.a ./libOverload.a994 LDADD = ./libISSMCore.a ./libISSMOverload.a 971 995 972 996 #External packages 973 LDADD += $(PETSCLIB) $(TAOLIB) $(FLIBS) $(PLAPACKLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB) 997 LDADD += $(PETSCLIB) $(TAOLIB) $(PLAPACKLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB) 998 999 if FORTRAN 1000 LDADD += $(FLIBS) 1001 endif 974 1002 975 1003 issm_SOURCES = solutions/issm.cpp 976 issm_CXXFLAGS= -fPIC -D_PARALLEL_$(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS)1004 issm_CXXFLAGS= -fPIC $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) 977 1005 #}}} 978 1006 #Automatic differentiation: append this fold to the end of the src/c/Makefile.am to get this Makefile.am {{{ 979 1007 if ADIC2 980 lib_LIBRARIES += libAD.a lib pISSMRose.a1008 lib_LIBRARIES += libAD.a libISSMRose.a 981 1009 982 1010 #ADIC2 library, for automatic differentiation 983 1011 #libAD_a_SOURCES = ./mini1.ad.c 984 1012 libAD_a_SOURCES = 985 libAD_a_CFLAGS = -fPIC -D_PARALLEL_ -D_C_ $(COPTFLAGS) 986 1013 libAD_a_CFLAGS = -fPIC -D_C_ $(COPTFLAGS) 987 1014 988 1015 989 1016 #test rose preprocessing 990 1017 %.r2cpp.cpp : %.cpp 991 testTranslator -rose:o $@ -rose:skipfinalCompileStep -DHAVE_CONFIG_H -D_ PARALLEL_ -D_C_ -I. -I../.. $(INCLUDES) $<992 lib pISSMRose_a_SOURCES = $(libpISSM_a_SOURCES:.cpp=.r2cpp.cpp)993 lib pISSMRose_a_CXXFLAGS= -fPIC -D_PARALLEL_-D_C_ $(CXXOPTFLAGS)1018 testTranslator -rose:o $@ -rose:skipfinalCompileStep -DHAVE_CONFIG_H -D_C_ -I. -I../.. $(INCLUDES) $< 1019 libISSMRose_a_SOURCES = $(libISSMCore_a_SOURCES:.cpp=.r2cpp.cpp) 1020 libISSMRose_a_CXXFLAGS= -fPIC -D_C_ $(CXXOPTFLAGS) 994 1021 995 1022 … … 1003 1030 #Executable 1004 1031 bin_PROGRAMS += issmRose.exe 1005 issmRose_exe_LDADD = ./lib pISSMRose.a $(LDADD)1032 issmRose_exe_LDADD = ./libISSMRose.a $(LDADD) 1006 1033 issmRose_exe_SOURCES = solutions/issm.cpp 1007 issmRose_exe_CXXFLAGS= -fPIC -D_PARALLEL_$(CXXOPTFLAGS) $(COPTFLAGS)1034 issmRose_exe_CXXFLAGS= -fPIC $(CXXOPTFLAGS) $(COPTFLAGS) 1008 1035 LDADD += $(ADIC2LIB) 1009 1036 -
issm/trunk/src/c/include/macros.h
r11995 r12330 40 40 #endif 41 41 /*}}}*/ 42 43 /* MODULEBOOT/MODULEEND {{{1*/ 42 /* ISSMBOOT/ISSMEND {{{1*/ 44 43 45 44 /*The following macros hide the error exception handling in a matlab module. Just put 46 * MODULEBOOT(); and MODULEEND(); at the beginning and end of a module, and c++ exceptions45 * ISSMBOOT(); and ISSMEND(); at the beginning and end of a module, and c++ exceptions 47 46 * will be trapped. Really nifty!*/ 48 47 49 #ifdef _SERIAL_ 50 #ifdef _HAVE_MATLAB_ //{{{2 51 #define MODULEBOOT(); ModuleBoot(); \ 48 #define ISSMBOOT(); \ 52 49 try{ 53 50 54 #define MODULEEND(); ModuleEnd(); }\ 55 catch(ErrorException &exception){\ 56 exception.Report(); \ 57 mexErrMsgTxt(""); \ 58 }\ 59 catch (exception& e) {\ 60 _printf_(true,"Standard exception: %s\n",e.what());\ 61 mexErrMsgTxt(" ");\ 62 } 63 #endif //}}} 64 #ifdef _HAVE_PYTHON_ //{{{2 65 #define MODULEBOOT(); ModuleBoot(); \ 66 PyObject* output = PyTuple_New(NLHS); if (!output) return NULL; 67 68 #define MODULEEND(); ModuleEnd(); \ 69 return output; 70 #endif //}}} 71 #else 72 //{{{2 73 #define MODULEBOOT(); \ 74 try{ 75 76 #define MODULEEND(); }\ 51 #define ISSMEND(); }\ 77 52 catch(ErrorException &exception){\ 78 53 exception.Report(); \ … … 82 57 _printf_(true,"Standard exception: %s\n",e.what());\ 83 58 return 1;\ 59 }\ 60 catch(...){\ 61 _printf_(true,"An unexpected error occurred");\ 84 62 } 85 //}}}86 #endif87 63 /*}}}*/ 88 /* WRAPPER {{{1*/89 #ifdef _HAVE_MATLAB_90 #define WRAPPER(modulename,...) void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])91 #endif92 #ifdef _HAVE_PYTHON_93 #define WRAPPER(modulename,...) \94 \95 static PyObject* modulename(PyObject* self,PyObject* args);\96 static PyMethodDef modulename##_funcs[] = {\97 {#modulename, (PyCFunction)modulename, METH_VARARGS, ""},\98 {NULL,NULL,0,NULL}\99 };\100 \101 static struct PyModuleDef modulename##module= {\102 PyModuleDef_HEAD_INIT,\103 #modulename, /* name of module */\104 NULL, /* module documentation, may be NULL */\105 -1, /* size of per-interpreter state of the module,\106 or -1 if the module keeps state in global variables. */\107 modulename##_funcs\108 };\109 \110 PyMODINIT_FUNC PyInit_##modulename(void){\111 \112 import_array();\113 return PyModule_Create(&modulename##module);\114 }\115 \116 static PyObject* modulename(PyObject* self,PyObject* args)117 64 118 65 #endif 119 120 /*}}}*/121 /* CHECKARGUMENTS {{{1*/122 #ifdef _HAVE_MATLAB_123 #define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,functionpointer)124 #endif125 #ifdef _HAVE_PYTHON_126 #define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumPythonArguments(args, NRHS,functionpointer)127 #endif128 /*}}}*/129 130 131 #endif -
issm/trunk/src/c/include/types.h
r11995 r12330 16 16 17 17 /*Define abstract type for I/O: */ 18 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)19 #include <mex.h>20 typedef const mxArray* ConstDataHandle; //serially, we are reading data from a matlab array.21 typedef mxArray* DataHandle;22 #else23 typedef FILE* ConstDataHandle; //in parallel, we are reading data from a file.24 typedef FILE* DataHandle;25 #endif26 18 enum param_type { STRING, INTEGER, STRINGARRAY, DOUBLE, DOUBLEVEC, DOUBLEMAT, PETSCVEC, PETSCMAT }; 27 19 … … 35 27 #endif 36 28 37 typedef double IssmDouble; 29 #ifdef _HAVE_ADOLC_ 30 typedef adouble IssmDouble; 31 #else 32 typedef double IssmDouble; 33 #endif 34 38 35 typedef bool IssmBool; 39 36 -
issm/trunk/src/c/io/PrintfFunction.cpp
r11995 r12330 8 8 #include "../shared/shared.h" 9 9 #include "../include/include.h" 10 11 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)12 #include "mex.h"13 #endif14 10 15 11 int PrintfFunction(const char* format,...){ … … 53 49 54 50 /*Ok, if we are running in parallel, get node 0 to print*/ 55 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)56 mexPrintf(buffer);57 #else58 51 if(my_rank==0)printf(buffer); 59 #endif60 52 61 53 /*Clean up and return*/ -
issm/trunk/src/c/io/io.h
r11995 r12330 15 15 #include "./Disk/diskio.h" 16 16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include "./Matlab/matlabio.h"19 #endif20 21 #if defined(_HAVE_PYTHON_) && defined(_SERIAL_)22 #include "./Python/pythonio.h"23 #endif24 25 17 /*printf: */ 26 18 int PrintfFunction(const char* format,...); -
issm/trunk/src/c/modules/Bamgx/Bamgx.cpp
r11995 r12330 92 92 93 93 //Make Quadtree from background mesh 94 BTh.Make QuadTree();94 BTh.MakeBamgQuadtree(); 95 95 96 96 //Bound hmin and hmax -
issm/trunk/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp
r9761 r12330 32 32 } 33 33 34 #ifdef _ PARALLEL_34 #ifdef _HAVE_MPI_ 35 35 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 36 36 MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD); … … 95 95 } 96 96 97 #ifdef _ PARALLEL_97 #ifdef _HAVE_MPI_ 98 98 MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 99 99 MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD); … … 135 135 136 136 /*Is there just one found? that would mean we have frozen! : */ 137 #ifdef _ PARALLEL_137 #ifdef _HAVE_MPI_ 138 138 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD ); 139 139 MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD); … … 195 195 } 196 196 197 #ifdef _ PARALLEL_197 #ifdef _HAVE_MPI_ 198 198 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 199 199 MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD); … … 228 228 } 229 229 230 #ifdef _ PARALLEL_230 #ifdef _HAVE_MPI_ 231 231 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 232 232 MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD); … … 289 289 } 290 290 291 #ifdef _ PARALLEL_291 #ifdef _HAVE_MPI_ 292 292 MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 293 293 MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD); … … 329 329 } 330 330 331 #ifdef _ PARALLEL_331 #ifdef _HAVE_MPI_ 332 332 MPI_Reduce (&max_penetration,&mpi_max_penetration,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD ); 333 333 MPI_Bcast(&mpi_max_penetration,1,MPI_DOUBLE,0,MPI_COMM_WORLD); … … 368 368 } 369 369 370 #ifdef _ PARALLEL_370 #ifdef _HAVE_MPI_ 371 371 MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 372 372 MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp
r9883 r12330 36 36 } 37 37 38 #ifdef _ PARALLEL_38 #ifdef _HAVE_MPI_ 39 39 MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 40 40 MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp
r9883 r12330 28 28 } 29 29 30 #ifdef _ PARALLEL_30 #ifdef _HAVE_MPI_ 31 31 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 32 32 MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.cpp
r11995 r12330 11 11 #include "./ContourToMeshx.h" 12 12 13 int ContourToMeshx( Vector** pin_nod,Vector** pin_elem, double* index, double* x, double* y, Contour** contours,int numcontours,char* interptype,int nel,int nods, int edgevalue) {13 int ContourToMeshx( Vector** pin_nod,Vector** 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; … … 37 37 38 38 /*initialize thread parameters: */ 39 gate.numcontours=numcontours;40 39 gate.contours=contours; 41 40 gate.nods=nods; -
issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.h
r11995 r12330 13 13 typedef struct{ 14 14 15 int numcontours; 16 Contour** contours; 15 DataSet* contours; 17 16 int nods; 18 17 int edgevalue; … … 25 24 26 25 /* local prototypes: */ 27 int ContourToMeshx( Vector** pin_nods,Vector** pin_elem, double* index, double* x, double* y, Contour** contours,int numcontours,char* interptype,int nel,int nods, int edgevalue);26 int ContourToMeshx( Vector** pin_nods,Vector** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue); 28 27 29 28 void* ContourToMeshxt(void* vContourToMeshxThreadStruct); -
issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp
r11995 r12330 26 26 27 27 /*Contour:*/ 28 Contour* contouri=NULL; 29 int numnodes; 30 double* xc=NULL; 31 double* yc=NULL; 32 28 DataSet* contours=NULL; 33 29 34 30 /*parameters: */ 35 int numcontours;36 Contour** contours=NULL;37 31 int nods; 38 32 int edgevalue; … … 49 43 50 44 /*recover parameters :*/ 51 numcontours=gate->numcontours;52 45 contours=gate->contours; 53 46 nods=gate->nods; … … 61 54 62 55 /*Loop through all contours: */ 63 for (i=0;i<numcontours;i++){ 64 contouri=*(contours+i); 65 numnodes=contouri->nods; 66 xc=contouri->x; 67 yc=contouri->y; 68 IsInPoly(in_nod,xc,yc,numnodes,x,y,i0,i1,edgevalue); 56 for (i=0;i<contours->Size();i++){ 57 Contour* contour=(Contour*)contours->GetObjectByOffset(i); 58 IsInPoly(in_nod,contour->x,contour->y,contour->nods,x,y,i0,i1,edgevalue); 69 59 } 70 60 -
issm/trunk/src/c/modules/ContourToNodesx/ContourToNodesx.cpp
r11995 r12330 38 38 return 1; 39 39 } 40 41 int ContourToNodesx( Vector** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue){ 42 43 int i; 44 int m,n; 45 46 /*Contour:*/ 47 Contour* contouri=NULL; 48 int numnodes; 49 double* xc=NULL; 50 double* yc=NULL; 51 double value; 52 53 /*output: */ 54 Vector* flags=NULL; 55 56 flags=new Vector(nods); 57 58 /*Loop through all contours: */ 59 if(contours){ 60 for (i=0;i<contours->Size();i++){ 61 Contour* contour=(Contour*)contours->GetObjectByOffset(i); 62 IsInPoly(flags,contour->x,contour->y,contour->nods,x,y,0,nods,edgevalue); 63 } 64 } 65 66 /*Assemble vector: */ 67 flags->Assemble(); 68 69 /*Assign output pointers: */ 70 *pflags=flags; 71 72 return 1; 73 } -
issm/trunk/src/c/modules/ContourToNodesx/ContourToNodesx.h
r11995 r12330 12 12 /* local prototypes: */ 13 13 int ContourToNodesx( Vector** pflags,double* x, double* y, int nods, Contour** contours,int numcontours,int edgevalue); 14 int ContourToNodesx( Vector** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue); 14 15 15 16 #endif /* _CONTOURTONODESX_H */ -
issm/trunk/src/c/modules/Dakotax/Dakotax.cpp
r11995 r12330 51 51 #endif 52 52 53 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)54 void Dakotax(mxArray* femmodel){55 #else56 53 void Dakotax(FemModel* femmodel){ 57 #endif58 54 59 55 … … 69 65 70 66 /*Retrieve parameters: */ 71 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)72 FetchData((Parameters**)¶meters,mxGetField((mxArray*)femmodel,0,"parameters"));73 #else74 67 parameters=femmodel->parameters; 75 #endif76 68 77 69 /*Recover dakota_input_file, dakota_output_file and dakota_error_file, in the parameters dataset in parallel */ … … 80 72 parameters->FindParam(&dakota_error_file,QmuErrNameEnum); 81 73 82 #ifdef _PARALLEL_83 74 if(my_rank==0){ 84 #endif85 75 86 76 // Instantiate/initialize the parallel library and problem description 87 77 // database objects. 88 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_) 89 Dakota::ParallelLibrary parallel_lib; //use Dakota's standard library mode constructor 90 #else 91 Dakota::ParallelLibrary parallel_lib("serial"); //use our own ISSM Dakota library mode constructor, which only fires up Dakota on CPU 0. 92 #endif 78 Dakota::ParallelLibrary parallel_lib("serial"); //use our own ISSM Dakota library mode constructor, which only fires up Dakota on CPU 0. 93 79 Dakota::ProblemDescDB problem_db(parallel_lib); 94 80 … … 123 109 selected_strategy.run_strategy(); 124 110 125 #ifdef _PARALLEL_126 111 //Warn other cpus that we are done running the dakota iterator, by setting the counter to -1: 127 112 SpawnCore(NULL,0, NULL,NULL,0,femmodel,-1); 128 #endif129 113 130 #ifdef _PARALLEL_131 114 } 132 115 else{ … … 136 119 } 137 120 } 138 #endif //#ifdef _PARALLEL_139 121 140 122 /*Free ressources:*/ … … 143 125 xfree((void**)&dakota_output_file); 144 126 145 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)146 delete parameters;147 #endif148 149 127 #endif //#ifdef _HAVE_DAKOTA_ 150 128 } -
issm/trunk/src/c/modules/Dakotax/Dakotax.h
r11995 r12330 10 10 11 11 /* local prototypes: */ 12 int SpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter);12 int SpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter); 13 13 int DescriptorIndex(char* root, int* pindex,char* descriptor); 14 14 15 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)16 void Dakotax(mxArray* femmodel);17 void SpawnCoreSerial(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, mxArray* femmodel,int counter);18 #else19 15 void Dakotax(FemModel* femmodel); 20 16 void SpawnCoreParallel(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, FemModel* femmodel,int counter); 21 #endif22 17 void DakotaResponses(double* responses,char** responses_descriptors,int numresponses,FemModel* femmodel); 23 18 void DakotaMPI_Bcast(double** pvariables, char*** pvariables_descriptors,int* pnumvariables, int* pnumresponses); -
issm/trunk/src/c/modules/Dakotax/SpawnCore.cpp
r11995 r12330 21 21 /*Branch into a serial SpawnCore and a parallel SpawnCore: */ 22 22 23 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_) 24 SpawnCoreSerial(responses, numresponses, variables, variables_descriptors,numvariables, (mxArray*)femmodel, counter); 25 #else 26 /*Call SpawnCoreParallel unless counter=-1 on cpu0, in which case, bail out and return 0: */ 27 MPI_Bcast(&counter,1,MPI_INT,0,MPI_COMM_WORLD); 28 if(counter==-1)return 0; 29 SpawnCoreParallel(responses, numresponses, variables, variables_descriptors,numvariables, (FemModel*)femmodel,counter); 30 #endif 23 /*Call SpawnCoreParallel unless counter=-1 on cpu0, in which case, bail out and return 0: */ 24 MPI_Bcast(&counter,1,MPI_INT,0,MPI_COMM_WORLD); 25 if(counter==-1)return 0; 26 27 SpawnCoreParallel(responses, numresponses, variables, variables_descriptors,numvariables, (FemModel*)femmodel,counter); 31 28 return 1; 32 29 } -
issm/trunk/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp
r8608 r12330 27 27 28 28 /*Sum all J from all cpus of the cluster:*/ 29 #ifdef _HAVE_MPI_ 29 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD ); 30 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 31 32 J=J_sum; 33 #endif 32 34 33 35 /*Assign output pointers: */ -
issm/trunk/src/c/modules/ElementResponsex/ElementResponsex.cpp
r10703 r12330 37 37 38 38 /*Broadcast whether we found the element: */ 39 #ifdef _HAVE_MPI_ 39 40 MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); 40 41 if(!sumfound)_error_("%s%i%s","could not find material with id",index," to compute ElementResponse"); 42 #endif 41 43 42 44 /*Ok, we found the element, compute responseocity: */ … … 46 48 47 49 /*Broadcast and plug into response: */ 50 #ifdef _HAVE_MPI_ 48 51 MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 49 52 MPI_Bcast(&response,1,MPI_DOUBLE,cpu_found,MPI_COMM_WORLD); 53 #endif 50 54 51 55 *presponse=response; -
issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp
r12301 r12330 157 157 case PetscProfilingCurrentFlopsEnum : return "PetscProfilingCurrentFlops"; 158 158 case PetscProfilingSolutionTimeEnum : return "PetscProfilingSolutionTime"; 159 case MaxIterationConvergenceFlagEnum : return "MaxIterationConvergenceFlag"; 159 160 case SteadystateMaxiterEnum : return "SteadystateMaxiter"; 160 161 case SteadystateNumRequestedOutputsEnum : return "SteadystateNumRequestedOutputs"; -
issm/trunk/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp
r11995 r12330 61 61 /* read exp file */ 62 62 63 if (!DomainOutlineRead(&nprof,&pnvert,&pprofx,&pprofy,&closed,filexp ,true))63 if (!DomainOutlineRead(&nprof,&pnvert,&pprofx,&pprofy,&closed,filexp)) 64 64 _error_("Error reading exp file."); 65 65 _printf_(true,"Exp2Kmlx -- Reading %d exp profiles from file \"%s\".\n",nprof,filexp); -
issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
r11995 r12330 156 156 vec_nodes_on_floatingice->Assemble(); 157 157 158 #ifdef _HAVE_MPI_ 158 159 MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); 159 160 _printf_(VerboseConvergence()," Additional number of vertices allowed to unground: %i\n",nflipped); 161 #else 162 nflipped=local_nflipped; 163 #endif 160 164 161 165 /*Avoid leaks: */ -
issm/trunk/src/c/modules/IceVolumex/IceVolumex.cpp
r9880 r12330 19 19 local_ice_volume+=element->IceVolume(); 20 20 } 21 #ifdef _HAVE_MPI_ 21 22 MPI_Reduce(&local_ice_volume,&total_ice_volume,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD ); 22 23 MPI_Bcast(&total_ice_volume,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 24 #else 25 total_ice_volume=local_ice_volume; 26 #endif 23 27 24 28 /*Assign output pointers: */ -
issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.cpp
r9761 r12330 30 30 31 31 /*In parallel, we need to gather the converged status: */ 32 #ifdef _ PARALLEL_32 #ifdef _HAVE_MPI_ 33 33 MPI_Allreduce ( (void*)&num_notconverged,(void*)&total_notconverged,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); 34 34 num_notconverged=total_notconverged; -
issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
r11995 r12330 14 14 15 15 int InterpFromMeshToMesh2dx(double** pdata_interp,double* index_data,double* x_data,double* y_data,int nods_data,int nels_data, 16 double* data,int data_rows,int data_cols,double* x_interp,double* y_interp,int nods_interp,double* default_values,int num_default_values, Contour** contours, int numcontours){16 double* data,int data_rows,int data_cols,double* x_interp,double* y_interp,int nods_interp,double* default_values,int num_default_values, DataSet* contours){ 17 17 18 18 /*Output*/ … … 36 36 bool skip_bamg=false; 37 37 38 39 38 /*Checks*/ 40 39 if (data_cols<=0){ … … 50 49 /*If default values supplied, figure out which nodes are inside the contour, including the border of the contour: */ 51 50 if(num_default_values){ 52 ContourToNodesx( &vec_incontour,x_interp,y_interp,nods_interp,contours, numcontours,1);51 ContourToNodesx( &vec_incontour,x_interp,y_interp,nods_interp,contours,1); 53 52 incontour=vec_incontour->ToMPISerial(); 54 53 } -
issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h
r5032 r12330 10 10 /* local prototypes: */ 11 11 int InterpFromMeshToMesh2dx(double** pdata_interp,double* index_data,double* x_data,double* y_data,int nods_data,int nels_data, 12 double* data,int data_rows,int data_cols,double* x_interp,double* y_interp,int nods_interp,double* default_values,int num_default_values, Contour** contours, int numcontours);12 double* data,int data_rows,int data_cols,double* x_interp,double* y_interp,int nods_interp,double* default_values,int num_default_values,DataSet* contours); 13 13 14 14 #endif -
issm/trunk/src/c/modules/MassFluxx/MassFluxx.cpp
r8263 r12330 59 59 } 60 60 61 #ifdef _ PARALLEL_61 #ifdef _HAVE_MPI_ 62 62 MPI_Allreduce ( (void*)&mass_flux,(void*)&all_mass_flux,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD); 63 63 mass_flux=all_mass_flux; -
issm/trunk/src/c/modules/MaxAbsVxx/MaxAbsVxx.cpp
r5870 r12330 31 31 } 32 32 33 #ifdef _PARALLEL_34 33 /*Figure out maximum across the cluster: */ 34 #ifdef _HAVE_MPI_ 35 35 MPI_Reduce (&maxabsvx,&node_maxabsvx,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD ); 36 36 MPI_Bcast(&node_maxabsvx,1,MPI_DOUBLE,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/MaxAbsVyx/MaxAbsVyx.cpp
r5871 r12330 32 32 } 33 33 34 #ifdef _PARALLEL_35 34 /*Figure out maximum across the cluster: */ 35 #ifdef _HAVE_MPI_ 36 36 MPI_Reduce (&maxabsvy,&node_maxabsvy,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD ); 37 37 MPI_Bcast(&node_maxabsvy,1,MPI_DOUBLE,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/MaxAbsVzx/MaxAbsVzx.cpp
r5414 r12330 31 31 } 32 32 33 #ifdef _PARALLEL_34 33 /*Figure out minimum across the cluster: */ 34 #ifdef _HAVE_MPI_ 35 35 MPI_Reduce (&maxabsvz,&node_maxabsvz,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD ); 36 36 MPI_Bcast(&node_maxabsvz,1,MPI_DOUBLE,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/MaxVelx/MaxVelx.cpp
r5414 r12330 32 32 } 33 33 34 #ifdef _PARALLEL_35 34 /*Figure out maximum across the cluster: */ 35 #ifdef _HAVE_MPI_ 36 36 MPI_Reduce (&maxvel,&node_maxvel,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD ); 37 37 MPI_Bcast(&node_maxvel,1,MPI_DOUBLE,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/MaxVxx/MaxVxx.cpp
r5414 r12330 31 31 } 32 32 33 #ifdef _PARALLEL_34 33 /*Figure out minimum across the cluster: */ 34 #ifdef _HAVE_MPI_ 35 35 MPI_Reduce (&maxvx,&node_maxvx,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD ); 36 36 MPI_Bcast(&node_maxvx,1,MPI_DOUBLE,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/MaxVyx/MaxVyx.cpp
r5414 r12330 31 31 } 32 32 33 #ifdef _PARALLEL_34 33 /*Figure out minimum across the cluster: */ 34 #ifdef _HAVE_MPI_ 35 35 MPI_Reduce (&maxvy,&node_maxvy,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD ); 36 36 MPI_Bcast(&node_maxvy,1,MPI_DOUBLE,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/MaxVzx/MaxVzx.cpp
r5414 r12330 32 32 } 33 33 34 #ifdef _PARALLEL_35 34 /*Figure out minimum across the cluster: */ 35 #ifdef _HAVE_MPI_ 36 36 MPI_Reduce (&maxvz,&node_maxvz,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD ); 37 37 MPI_Bcast(&node_maxvz,1,MPI_DOUBLE,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.cpp
r10000 r12330 42 42 /*Partition using Metis:*/ 43 43 if (num_procs>1){ 44 #ifdef _HAVE_METIS_ 44 45 METIS_PartMeshNodalPatch(&numberofelements,&numberofnodes, index, &etype, &numflag, &num_procs, &edgecut, epart, npart); 46 #endif 45 47 } 46 48 else if (num_procs==1){ … … 67 69 /*Partition using Metis:*/ 68 70 if (num_procs>1){ 71 #ifdef _HAVE_METIS_ 69 72 METIS_PartMeshNodalPatch(&numberofelements2d,&numberofnodes2d, index2d, &etype2d, &numflag, &num_procs, &edgecut, epart2d, npart2d); 73 #endif 70 74 } 71 75 else if (num_procs==1){ -
issm/trunk/src/c/modules/MeshProfileIntersectionx/SegmentIntersect.cpp
r11237 r12330 6 6 int SegmentIntersect(double* palpha, double* pbeta, double* x1, double* y1, double* x2, double* y2){ 7 7 8 /*See ISSM_ TIER/src/m/utils/Geometry/SegIntersect.m for matlab routine from which we take this routine: */8 /*See ISSM_DIR/src/m/utils/Geometry/SegIntersect.m for matlab routine from which we take this routine: */ 9 9 10 10 /*output: */ -
issm/trunk/src/c/modules/MinVelx/MinVelx.cpp
r5414 r12330 32 32 } 33 33 34 #ifdef _PARALLEL_35 34 /*Figure out minimum across the cluster: */ 35 #ifdef _HAVE_MPI_ 36 36 MPI_Reduce (&minvel,&node_minvel,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD ); 37 37 MPI_Bcast(&node_minvel,1,MPI_DOUBLE,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/MinVxx/MinVxx.cpp
r5414 r12330 31 31 } 32 32 33 #ifdef _PARALLEL_34 33 /*Figure out minimum across the cluster: */ 34 #ifdef _HAVE_MPI_ 35 35 MPI_Reduce (&minvx,&node_minvx,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD ); 36 36 MPI_Bcast(&node_minvx,1,MPI_DOUBLE,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/MinVyx/MinVyx.cpp
r5414 r12330 31 31 } 32 32 33 #ifdef _PARALLEL_34 33 /*Figure out minimum across the cluster: */ 34 #ifdef _HAVE_MPI_ 35 35 MPI_Reduce (&minvy,&node_minvy,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD ); 36 36 MPI_Bcast(&node_minvy,1,MPI_DOUBLE,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/MinVzx/MinVzx.cpp
r5414 r12330 31 31 } 32 32 33 #ifdef _PARALLEL_34 33 /*Figure out minimum across the cluster: */ 34 #ifdef _HAVE_MPI_ 35 35 MPI_Reduce (&minvz,&node_minvz,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD ); 36 36 MPI_Bcast(&node_minvz,1,MPI_DOUBLE,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
r9733 r12330 63 63 else elements_width=6; //penta elements 64 64 65 #ifdef _PARALLEL_66 65 /*Determine parallel partitioning of elements: we use Metis for now. First load the data, then partition*/ 67 66 if(dim==2){ … … 79 78 xfree((void**)&elements); 80 79 xfree((void**)&elements2d); 81 82 #else83 /*In serial mode, epart is full of 0: all elements belong to cpu 0: */84 epart=(int*)xcalloc(numberofelements,sizeof(int));85 #endif86 80 87 81 /*Deal with rifts, they have to be included into one partition only, not several: */ -
issm/trunk/src/c/modules/NodalValuex/NodalValuex.cpp
r9206 r12330 36 36 37 37 /*Broadcast whether we found the element: */ 38 #ifdef _HAVE_MPI_ 38 39 MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); 39 40 if(!sumfound)_error_("%s%i%s%s","could not find element with vertex with id",index," to compute nodal value ",EnumToStringx(natureofdataenum)); 41 #endif 40 42 41 43 /*Broadcast and plug into response: */ 44 #ifdef _HAVE_MPI_ 42 45 MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 43 46 MPI_Bcast(&value,1,MPI_DOUBLE,cpu_found,MPI_COMM_WORLD); 47 #else 48 value=cpu_found; 49 #endif 44 50 45 51 *pnodalvalue=value; -
issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp
r11995 r12330 16 16 #include "../../objects/objects.h" 17 17 18 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)19 void OutputResultsx(mxArray** pdataref, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Results* results){20 #else21 18 void OutputResultsx( Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Results* results){ 22 #endif23 19 24 20 extern int my_rank; … … 31 27 bool dakota_analysis = false; 32 28 33 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)34 const char **fnames = NULL;35 mwSize onebyone[2] = {0,0};36 mwSize ndim = 2;37 int nfields=0;38 #endif39 40 29 /*retrieve parameters: */ 41 30 parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum); … … 43 32 if(dakota_analysis){ 44 33 //no need to output anything, Dakota analysis has different outputs 45 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)46 *pdataref=mxCreateStructArray( ndim,onebyone,nfields,fnames);47 #endif48 34 return; 49 35 } … … 56 42 /*Results do not include the type of solution being run . In parallel, we output results to a filename, 57 43 *therefore, we need to include the solutiontype into the filename: */ 58 #ifdef _PARALLEL_59 44 if(my_rank==0){ 60 45 parameters->FindParam(&solutiontype,SolutionTypeEnum); … … 88 73 parameters->SetParam(fid,OutputFilePointerEnum); 89 74 } 90 #endif91 75 92 /*Write results to disk (in parallel), or to memory (in serial mode): */ 93 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_) 94 results->Write(pdataref); 95 #else 96 results->Write(parameters); 97 #endif 76 /*Write results to disk: */ 77 results->Write(parameters); 98 78 99 79 /*Delete and reinitialize results, in parallel: */ 100 #ifdef _PARALLEL_ 101 results->clear(); 80 results->clear(); 102 81 103 /*Close output file? :*/ 104 /*WARNING: issm.cpp is taking care of it for now (quick fix) 105 if((step==1) && (time==0)){ 106 if(io_gather){ 107 if(my_rank==0) pfclose(fid,outputfilename); 108 } 109 else pfclose(fid,cpu_outputfilename); 110 } 111 */ 112 #endif 82 /*Close output file? :*/ 83 /*WARNING: issm.cpp is taking care of it for now (quick fix) 84 if((step==1) && (time==0)){ 85 if(io_gather){ 86 if(my_rank==0) pfclose(fid,outputfilename); 87 } 88 else pfclose(fid,cpu_outputfilename); 89 } 90 */ 113 91 } -
issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.h
r11995 r12330 14 14 #include "../../Container/Container.h" 15 15 16 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)17 #include <mex.h>18 void OutputResultsx(mxArray** pdataref, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, Results* results);19 #else20 16 void OutputResultsx(Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, Results* results); 21 #endif22 17 23 18 #endif /* _OUTPUTRESULTS_H */ -
issm/trunk/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp
r11995 r12330 10 10 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 11 11 #endif 12 13 #include <cstring> 12 14 13 15 #include "./ParsePetscOptionsx.h" … … 92 94 } 93 95 94 #ifdef _PARALLEL_95 96 /*Ok, broadcast to other cpus: */ 97 #ifdef _HAVE_MPI_ 96 98 MPI_Bcast(&numanalyses,1,MPI_INT,0,MPI_COMM_WORLD); 97 99 if(my_rank!=0){ … … 100 102 } 101 103 MPI_Bcast(analyses,numanalyses,MPI_DOUBLE,0,MPI_COMM_WORLD); 104 #endif 102 105 for(i=0;i<numanalyses;i++){ 103 106 char* string=strings[i]; … … 106 109 } 107 110 if(my_rank==0)stringlength=(strlen(string)+1)*sizeof(char); 111 #ifdef _HAVE_MPI_ 108 112 MPI_Bcast(&stringlength,1,MPI_INT,0,MPI_COMM_WORLD); 109 113 if(my_rank!=0)string=(char*)xmalloc(stringlength); 110 114 MPI_Bcast(string,stringlength,MPI_CHAR,0,MPI_COMM_WORLD); 111 115 if(my_rank!=0)strings[i]=string; 116 #endif 112 117 } 113 #endif114 118 115 119 /*Ok, out of strings and analyses and numanalyses, create parameters, and plug them into parameters container: */ -
issm/trunk/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp
r8608 r12330 27 27 28 28 /*Sum all J from all cpus of the cluster:*/ 29 #ifdef _HAVE_MPI_ 29 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD ); 30 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 31 32 J=J_sum; 33 #endif 32 34 33 35 /*Assign output pointers: */ -
issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.h
r10380 r12330 22 22 23 23 /* local prototypes: */ 24 int Shp2Kmlx(char* filshp,char* filkml, 25 int sgn); 26 int Shp2Kmlx(char* filshp,char* filkml, 27 int sgn,double cm,double sp); 24 int Shp2Kmlx(char* filshp,char* filkml, int sgn); 25 int Shp2Kmlx(char* filshp,char* filkml, int sgn,double cm,double sp); 28 26 29 27 #endif /* _SHP2KMLX_H */ -
issm/trunk/src/c/modules/Solverx/Solverx.cpp
r11995 r12330 34 34 35 35 /*In serial mode, the Petsc Options database has not been initialized properly: */ 36 #ifdef _SERIAL_37 parameters->FindParam(&analysis_type,AnalysisTypeEnum);38 PetscOptionsFromAnalysis(parameters,analysis_type);39 #endif40 36 41 37 SolverxPetsc(&uf_vector,Kff->matrix,pf->vector,uf0_vector,df_vector,parameters); -
issm/trunk/src/c/modules/Solverx/SolverxPetsc.cpp
r11995 r12330 43 43 #endif 44 44 45 46 45 /*Display message*/ 47 46 _printf_(VerboseModule()," Solving\n"); … … 52 51 #endif 53 52 54 /*First, check that f-set is not NULL, i.e. model is fully constrained: {{{*/53 /*First, check that f-set is not NULL, i.e. model is fully constrained:*/ 55 54 _assert_(Kff); 56 55 MatGetSize(Kff,&global_m,&global_n); _assert_(global_m==global_m); … … 58 57 *puf=NULL; return; 59 58 } 60 /*}}}*/ 61 /*Initial guess logic here: {{{1*/59 60 /*Initial guess */ 62 61 /*Now, check that we are not giving an initial guess to the solver, if we are running a direct solver: */ 63 62 #if _PETSC_MAJOR_ >= 3 … … 74 73 MatGetLocalSize(Kff,&local_m,&local_n);uf=NewVec(local_n,fromlocalsize); 75 74 } 76 /*}}}*/ 77 /*Process petsc options to see if we are using special types of external solvers : {{{1*/75 76 /*Process petsc options to see if we are using special types of external solvers*/ 78 77 PetscOptionsDetermineSolverType(&solver_type); 79 78 80 /* In serial mode, the matrices have been loaded as MPIAIJ or AIJ matrices.81 We need to convert them if we are going to run the solvers successfully: */82 #ifdef _SERIAL_83 #if _PETSC_MAJOR_ == 284 if (solver_type==MUMPSPACKAGE_LU){85 /*Convert Kff to MATTAIJMUMPS: */86 MatConvert(Kff,MATAIJMUMPS,MAT_REUSE_MATRIX,&Kff);79 /*Check the solver is available*/ 80 if(solver_type==MUMPSPACKAGE_LU || solver_type==MUMPSPACKAGE_CHOL){ 81 #if _PETSC_MAJOR_ >=3 82 #ifndef _HAVE_MUMPS_ 83 _error_("requested MUMPS solver, which was not compiled into ISSM!\n"); 84 #endif 85 #endif 87 86 } 88 if (solver_type==MUMPSPACKAGE_CHOL){89 /*Convert Kff to MATTSBAIJMUMPS: */90 MatConvert(Kff,MATSBAIJMUMPS,MAT_REUSE_MATRIX,&Kff);91 }92 if (solver_type==SPOOLESPACKAGE_LU){93 /*Convert Kff to MATTSBAIJMUMPS: */94 MatConvert(Kff,MATAIJSPOOLES,MAT_REUSE_MATRIX,&Kff);95 }96 if (solver_type==SPOOLESPACKAGE_CHOL){97 /*Convert Kff to MATTSBAIJMUMPS: */98 MatConvert(Kff,MATSBAIJSPOOLES,MAT_REUSE_MATRIX,&Kff);99 }100 if (solver_type==SUPERLUDISTPACKAGE){101 /*Convert Kff to MATTSBAIJMUMPS: */102 MatConvert(Kff,MATSUPERLU_DIST,MAT_REUSE_MATRIX,&Kff);103 }104 if (solver_type==StokesSolverEnum){105 _error_("Petsc 2 does not support multi-physics solvers");106 }107 #endif108 #endif109 /*}}}*/110 /*Check the solver is available: {{{1*/111 if(solver_type==MUMPSPACKAGE_LU || solver_type==MUMPSPACKAGE_CHOL){112 #if _PETSC_MAJOR_ >=3113 #ifndef _HAVE_MUMPS_114 _error_("requested MUMPS solver, which was not compiled into ISSM!\n");115 #endif116 87 117 #endif 118 } 119 /*}}}*/ 120 /*Prepare solver:{{{1*/ 88 /*Prepare solver*/ 121 89 KSPCreate(MPI_COMM_WORLD,&ksp); 122 90 KSPSetOperators(ksp,Kff,Kff,DIFFERENT_NONZERO_PATTERN); 123 91 KSPSetFromOptions(ksp); 124 92 125 #if defined(_SERIAL_) &&_PETSC_MAJOR_==393 #if _PETSC_MAJOR_==3 126 94 /*Specific solver?: */ 127 95 KSPGetPC(ksp,&pc); … … 133 101 #endif 134 102 } 135 #endif136 103 137 #if defined(_PARALLEL_) && _PETSC_MAJOR_==3138 104 /*Stokes: */ 139 105 if (solver_type==StokesSolverEnum){ … … 155 121 #endif 156 122 157 /*}}}*/ 158 /*If there is an initial guess for the solution, use it, except if we are using the MUMPS direct solver, where any initial guess will crash Petsc: {{{1*/ 123 /*If there is an initial guess for the solution, use it 124 * except if we are using the MUMPS direct solver 125 * where any initial guess will crash Petsc*/ 159 126 if (uf0){ 160 if( 127 if((solver_type!=MUMPSPACKAGE_LU) && (solver_type!=MUMPSPACKAGE_CHOL) && (solver_type!=SPOOLESPACKAGE_LU) && (solver_type!=SPOOLESPACKAGE_CHOL) && (solver_type!=SUPERLUDISTPACKAGE)){ 161 128 KSPSetInitialGuessNonzero(ksp,PETSC_TRUE); 162 129 } 163 130 } 164 /*}}}*/165 166 if(VerboseSolver())KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD);167 131 168 132 /*Solve: */ 133 if(VerboseSolver())KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD); 169 134 KSPSolve(ksp,pf,uf); 170 135 -
issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp
r12301 r12330 161 161 else if (strcmp(name,"PetscProfilingCurrentFlops")==0) return PetscProfilingCurrentFlopsEnum; 162 162 else if (strcmp(name,"PetscProfilingSolutionTime")==0) return PetscProfilingSolutionTimeEnum; 163 else if (strcmp(name,"MaxIterationConvergenceFlag")==0) return MaxIterationConvergenceFlagEnum; 163 164 else if (strcmp(name,"SteadystateMaxiter")==0) return SteadystateMaxiterEnum; 164 165 else if (strcmp(name,"SteadystateNumRequestedOutputs")==0) return SteadystateNumRequestedOutputsEnum; … … 259 260 else if (strcmp(name,"Input")==0) return InputEnum; 260 261 else if (strcmp(name,"IntInput")==0) return IntInputEnum; 261 else if (strcmp(name,"IntParam")==0) return IntParamEnum;262 262 else stage=3; 263 263 } 264 264 if(stage==3){ 265 if (strcmp(name,"IntVecParam")==0) return IntVecParamEnum; 265 if (strcmp(name,"IntParam")==0) return IntParamEnum; 266 else if (strcmp(name,"IntVecParam")==0) return IntVecParamEnum; 266 267 else if (strcmp(name,"MacAyeal2dIceFront")==0) return MacAyeal2dIceFrontEnum; 267 268 else if (strcmp(name,"MacAyeal3dIceFront")==0) return MacAyeal3dIceFrontEnum; … … 382 383 else if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum; 383 384 else if (strcmp(name,"StressTensorzz")==0) return StressTensorzzEnum; 384 else if (strcmp(name,"IceVolume")==0) return IceVolumeEnum;385 385 else stage=4; 386 386 } 387 387 if(stage==4){ 388 if (strcmp(name,"P0")==0) return P0Enum; 388 if (strcmp(name,"IceVolume")==0) return IceVolumeEnum; 389 else if (strcmp(name,"P0")==0) return P0Enum; 389 390 else if (strcmp(name,"P1")==0) return P1Enum; 390 391 else if (strcmp(name,"P1DG")==0) return P1DGEnum; -
issm/trunk/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp
r8607 r12330 27 27 28 28 /*Sum all J from all cpus of the cluster:*/ 29 #ifdef _HAVE_MPI_ 29 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD ); 30 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 31 32 J=J_sum; 33 #endif 32 34 33 35 /*Assign output pointers: */ -
issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.cpp
r5414 r12330 28 28 29 29 /*Sum all J from all cpus of the cluster:*/ 30 MPI_Reduce (&S,&S_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD ); 30 #ifdef _HAVE_MPI_ 31 MPI_Reduce (&S,&S_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD ); 31 32 MPI_Bcast(&S_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 32 33 S=S_sum; 34 #endif 33 35 34 36 /*add surface area to element inputs:*/ -
issm/trunk/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp
r8607 r12330 31 31 32 32 /*Sum all J from all cpus of the cluster:*/ 33 #ifdef _HAVE_MPI_ 33 34 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD ); 34 35 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 35 36 J=J_sum; 37 #endif 36 38 37 39 /*Assign output pointers: */ -
issm/trunk/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp
r8607 r12330 27 27 28 28 /*Sum all J from all cpus of the cluster:*/ 29 #ifdef _HAVE_MPI_ 29 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD ); 30 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 31 32 J=J_sum; 33 #endif 32 34 33 35 /*Assign output pointers: */ -
issm/trunk/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp
r8607 r12330 27 27 28 28 /*Sum all J from all cpus of the cluster:*/ 29 #ifdef _HAVE_MPI_ 29 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD ); 30 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 31 32 J=J_sum; 33 #endif 32 34 33 35 /*Assign output pointers: */ -
issm/trunk/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp
r8607 r12330 27 27 28 28 /*Sum all J from all cpus of the cluster:*/ 29 #ifdef _HAVE_MPI_ 29 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD ); 30 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 31 32 J=J_sum; 33 #endif 32 34 33 35 /*Assign output pointers: */ -
issm/trunk/src/c/modules/ThicknessAbsGradientx/ThicknessAbsGradientx.cpp
r8608 r12330 27 27 28 28 /*Sum all J from all cpus of the cluster:*/ 29 #ifdef _HAVE_MPI_ 29 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD ); 30 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 31 32 J=J_sum; 33 #endif 32 34 33 35 /*Assign output pointers: */ -
issm/trunk/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp
r8607 r12330 27 27 28 28 /*Sum all J from all cpus of the cluster:*/ 29 #ifdef _HAVE_MPI_ 29 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD ); 30 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 31 32 J=J_sum; 33 #endif 32 34 33 35 /*Assign output pointers: */ -
issm/trunk/src/c/modules/TimeAdaptx/TimeAdaptx.cpp
r6130 r12330 31 31 } 32 32 33 #ifdef _PARALLEL_34 33 /*Figure out minimum across the cluster: */ 34 #ifdef _HAVE_MPI_ 35 35 MPI_Reduce (&min_dt,&node_min_dt,1,MPI_DOUBLE,MPI_MIN,0,MPI_COMM_WORLD ); 36 36 MPI_Bcast(&node_min_dt,1,MPI_DOUBLE,0,MPI_COMM_WORLD); -
issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp
r11995 r12330 10 10 #include "../../toolkits/toolkits.h" 11 11 #include "../../EnumDefinitions/EnumDefinitions.h" 12 /*ANSI_DECLARATORS needed to call triangle library: */ 13 #ifndef ANSI_DECLARATORS 14 #define ANSI_DECLARATORS 15 #include "triangle.h" 16 #undef ANSI_DECLARATORS 17 #else 18 #include "triangle.h" 19 #endif 12 20 /*}}}*/ 13 21 14 15 void TriMeshx(Matrix** pindex,Vector** px,Vector** py,Matrix** psegments,Vector** psegmentmarkerlist,DataSet* domain,double area,bool order){ 22 void TriMeshx(Matrix** pindex,Vector** px,Vector** py,Matrix** psegments,Vector** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area){ 16 23 17 24 /*indexing: */ … … 28 35 29 36 /*intermediary: */ 30 int counter, backcounter;37 int counter,counter2,backcounter; 31 38 Contour* contour=NULL; 32 39 … … 39 46 for (i=0;i<domain->Size();i++){ 40 47 contour=(Contour*)domain->GetObjectByOffset(i); 48 in.numberofpoints+=contour->nods-1; 49 } 50 for (i=0;i<rifts->Size();i++){ 51 contour=(Contour*)rifts->GetObjectByOffset(i); 41 52 in.numberofpoints+=contour->nods; 42 53 } 54 43 55 /*number of point attributes: */ 44 56 in.numberofpointattributes=1; … … 50 62 for (i=0;i<domain->Size();i++){ 51 63 contour=(Contour*)domain->GetObjectByOffset(i); 64 for (j=0;j<contour->nods-1;j++){ 65 in.pointlist[2*counter+0]=contour->x[j]; 66 in.pointlist[2*counter+1]=contour->y[j]; 67 counter++; 68 } 69 } 70 for (i=0;i<rifts->Size();i++){ 71 contour=(Contour*)rifts->GetObjectByOffset(i); 52 72 for (j=0;j<contour->nods;j++){ 53 73 in.pointlist[2*counter+0]=contour->x[j]; … … 58 78 59 79 /*fill in the point attribute list: */ 60 in.pointattributelist = (REAL *) xmalloc(in.numberofpoints * in.numberofpointattributes *sizeof(REAL));80 in.pointattributelist = (REAL*)xmalloc(in.numberofpoints*in.numberofpointattributes*sizeof(REAL)); 61 81 for (i=0;i<in.numberofpoints;i++) in.pointattributelist[i] = 0.0; 62 82 … … 65 85 for(i=0;i<in.numberofpoints;i++) in.pointmarkerlist[i] = 0; 66 86 67 68 87 /*Build segments. First figure out number of segments: holes and closed outlines have as many segments as vertices: */ 69 88 in.numberofsegments=0; 70 89 for (i=0;i<domain->Size();i++){ 71 90 contour=(Contour*)domain->GetObjectByOffset(i); 72 in.numberofsegments+=contour->nods; 91 in.numberofsegments+=contour->nods-1; 92 } 93 for(i=0;i<rifts->Size();i++){ 94 contour=(Contour*)rifts->GetObjectByOffset(i); 95 /*for rifts, we have one less segment as we have vertices*/ 96 in.numberofsegments+=contour->nods-1; 73 97 } 74 98 … … 79 103 for (i=0;i<domain->Size();i++){ 80 104 contour=(Contour*)domain->GetObjectByOffset(i); 81 for (j=0;j<contour->nods- 1;j++){105 for (j=0;j<contour->nods-2;j++){ 82 106 in.segmentlist[2*counter+0]=counter; 83 107 in.segmentlist[2*counter+1]=counter+1; … … 92 116 backcounter=counter; 93 117 } 94 118 counter2=counter; 119 for (i=0;i<rifts->Size();i++){ 120 contour=(Contour*)rifts->GetObjectByOffset(i); 121 for (j=0;j<(contour->nods-1);j++){ 122 in.segmentlist[2*counter2+0]=counter; 123 in.segmentlist[2*counter2+1]=counter+1; 124 in.segmentmarkerlist[counter2]=2+i; 125 counter2++; 126 counter++; 127 } 128 counter++; 129 } 95 130 96 131 /*Build regions: */ … … 103 138 for (i=0;i<domain->Size()-1;i++){ 104 139 contour=(Contour*)domain->GetObjectByOffset(i+1); 105 GridInsideHole(&in.holelist[2*i+0],&in.holelist[2*i+1],contour->nods ,contour->x,contour->y);140 GridInsideHole(&in.holelist[2*i+0],&in.holelist[2*i+1],contour->nods-1,contour->x,contour->y); 106 141 } 107 142 } 108 143 109 144 /* Make necessary initializations so that Triangle can return a triangulation in `out': */ 110 111 out.pointlist = (REAL *) NULL; 112 out.pointattributelist = (REAL *) NULL; 113 out.pointmarkerlist = (int *) NULL; 114 out.trianglelist = (int *) NULL; 115 out.triangleattributelist = (REAL *) NULL; 116 out.neighborlist = (int *) NULL; 117 out.segmentlist = (int *) NULL; 118 out.segmentmarkerlist = (int *) NULL; 119 out.edgelist = (int *) NULL; 120 out.edgemarkerlist = (int *) NULL; 145 out.pointlist = (REAL*)NULL; 146 out.pointattributelist = (REAL*)NULL; 147 out.pointmarkerlist = (int *)NULL; 148 out.trianglelist = (int *)NULL; 149 out.triangleattributelist = (REAL*)NULL; 150 out.neighborlist = (int *)NULL; 151 out.segmentlist = (int *)NULL; 152 out.segmentmarkerlist = (int *)NULL; 153 out.edgelist = (int *)NULL; 154 out.edgemarkerlist = (int *)NULL; 121 155 122 156 /* Triangulate the points:. Switches are chosen to read and write a */ … … 125 159 /* produce an edge list (e), a Voronoi diagram (v), and a triangle */ 126 160 /* neighbor list (n). */ 127 128 161 sprintf(options,"%s%lf","pQzDq30ia",area); /*replace V by Q to quiet down the logging*/ 129 130 131 162 triangulate(options, &in, &out, NULL); 132 133 163 /*report(&out, 0, 1, 1, 1, 1, 0);*/ 134 135 164 136 165 /*Allocate index, x and y: */ … … 141 170 segmentmarkerlist=(double*)xmalloc(out.numberofsegments*sizeof(double)); 142 171 143 for (i = 0; i 172 for (i = 0; i< out.numberoftriangles; i++) { 144 173 for (j = 0; j < out.numberofcorners; j++) { 145 *(index+3*i+j)=(double)out.trianglelist[i * out.numberofcorners + j]+1; 146 } 147 } 148 for (i = 0; i < out.numberofpoints; i++) { 149 x[i]=out.pointlist[i * 2 + 0]; 150 y[i]=out.pointlist[i * 2 + 1]; 151 } 152 153 for (i = 0; i < out.numberofsegments; i++) { 174 index[3*i+j]=(double)out.trianglelist[i*out.numberofcorners+j]+1; 175 } 176 } 177 for (i = 0; i< out.numberofpoints; i++){ 178 x[i]=out.pointlist[i*2+0]; 179 y[i]=out.pointlist[i*2+1]; 180 } 181 for (i = 0; i<out.numberofsegments;i++){ 154 182 segments[3*i+0]=(double)out.segmentlist[i*2+0]+1; 155 183 segments[3*i+1]=(double)out.segmentlist[i*2+1]+1; … … 157 185 } 158 186 159 160 161 187 /*Associate elements with segments: */ 162 188 AssociateSegmentToElement(&segments,out.numberofsegments,index,out.numberoftriangles); 163 189 164 190 /*Order segments so that their normals point outside the domain: */ 165 if(order){ 166 OrderSegments(&segments,out.numberofsegments, index,out.numberoftriangles); 167 } 168 191 OrderSegments(&segments,out.numberofsegments, index,out.numberoftriangles); 169 192 170 193 /*Output : */ … … 179 202 *py=new Vector(y,out.numberofpoints); 180 203 *psegmentmarkerlist=new Vector(segmentmarkerlist,out.numberofsegments); 181 182 204 } -
issm/trunk/src/c/modules/TriMeshx/TriMeshx.h
r11995 r12330 6 6 #define _TRIMESHX_H_ 7 7 8 9 10 /*ANSI_DECLARATORS needed to call triangle library: */11 #ifndef ANSI_DECLARATORS12 #define ANSI_DECLARATORS13 #include "triangle.h"14 #undef ANSI_DECLARATORS15 #else16 #include "triangle.h"17 #endif18 19 8 #include "string.h" 20 21 9 #include "../../Container/Container.h" 22 10 #include "../../objects/objects.h" 23 11 24 12 /* local prototypes: */ 25 void TriMeshx(Matrix** pindex,Vector** px,Vector** py,Matrix** psegments,Vector** psegmentmarkerlist,DataSet* domain, double area,bool order);13 void TriMeshx(Matrix** pindex,Vector** px,Vector** py,Matrix** psegments,Vector** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area); 26 14 27 15 #endif /* _TRIMESHX_H */ -
issm/trunk/src/c/modules/modules.h
r12296 r12330 62 62 #include "./Exp2Kmlx/Exp2Kmlx.h" 63 63 #include "./Kml2Expx/Kml2Expx.h" 64 #include "./Krigingx/Krigingx.h" 64 65 #include "./Shp2Kmlx/Shp2Kmlx.h" 65 66 #include "./MassFluxx/MassFluxx.h" … … 112 113 #include "./TimeAdaptx/TimeAdaptx.h" 113 114 #include "./TriaSearchx/TriaSearchx.h" 114 #ifdef _SERIAL_115 115 #include "./TriMeshx/TriMeshx.h" 116 #endif117 116 #include "./ThicknessAbsMisfitx/ThicknessAbsMisfitx.h" 118 117 #include "./ThicknessAbsGradientx/ThicknessAbsGradientx.h" -
issm/trunk/src/c/objects/Bamg/BamgGeom.cpp
r11995 r12330 19 19 } 20 20 /*}}}*/ 21 /*FUNCTION BamgGeom::BamgGeom(mxArray* matlab_struct){{{1*/22 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)23 BamgGeom::BamgGeom(mxArray* matlab_struct){24 25 FetchData(&this->Vertices, &this->VerticesSize[0], &this->VerticesSize[1], mxGetAssignedField(matlab_struct,0,"Vertices"));26 FetchData(&this->Edges, &this->EdgesSize[0], &this->EdgesSize[1], mxGetAssignedField(matlab_struct,0,"Edges"));27 this->TangentAtEdgesSize[0]=0, this->TangentAtEdgesSize[1]=0; this->TangentAtEdges=NULL;28 FetchData(&this->Corners, &this->CornersSize[0], &this->CornersSize[1], mxGetAssignedField(matlab_struct,0,"Corners"));29 FetchData(&this->RequiredVertices,&this->RequiredVerticesSize[0],&this->RequiredVerticesSize[1],mxGetAssignedField(matlab_struct,0,"RequiredVertices"));30 FetchData(&this->RequiredEdges, &this->RequiredEdgesSize[0], &this->RequiredEdgesSize[1], mxGetAssignedField(matlab_struct,0,"RequiredEdges"));31 FetchData(&this->CrackedEdges, &this->CrackedEdgesSize[0], &this->CrackedEdgesSize[1], mxGetAssignedField(matlab_struct,0,"CrackedEdges"));32 FetchData(&this->SubDomains, &this->SubDomainsSize[0], &this->SubDomainsSize[1], mxGetAssignedField(matlab_struct,0,"SubDomains"));33 34 }35 #endif36 /*}}}*/37 21 /*FUNCTION BamgGeom::~BamgGeom(){{{1*/ 38 22 BamgGeom::~BamgGeom(){ … … 49 33 } 50 34 /*}}}*/ 51 52 /*Methods*/53 /*FUNCTION BamgGeom::SetMatlabStructureFields{{{1*/54 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)55 void BamgGeom::SetMatlabStructureFields(mxArray** matlab_struct){56 57 /*Intermediary*/58 int i;59 mxArray* output=NULL;60 const int numfields=7;61 const char* fnames[numfields];62 mwSize ndim=2;63 mwSize dimensions[2]={1,1};64 65 /*Initialize field names*/66 i=0;67 fnames[i++] = "Vertices";68 fnames[i++] = "Edges";69 fnames[i++] = "TangentAtEdges";70 fnames[i++] = "RequiredVertices";71 fnames[i++] = "RequiredEdges";72 fnames[i++] = "CrackedEdges";73 fnames[i++] = "SubDomains";74 _assert_(i==numfields);75 76 /*Initialize Matlab structure*/77 output=mxCreateStructArray(ndim,dimensions,numfields,fnames);78 79 /*set each matlab each field*/80 i=0;81 i++; SetMatlabStructureField(output,"Vertices", this->VerticesSize[0], this->VerticesSize[1], this->Vertices);82 i++; SetMatlabStructureField(output,"Edges", this->EdgesSize[0], this->EdgesSize[1], this->Edges);83 i++; SetMatlabStructureField(output,"TangentAtEdges", this->TangentAtEdgesSize[0], this->TangentAtEdgesSize[1], this->TangentAtEdges);84 i++; SetMatlabStructureField(output,"RequiredVertices",this->RequiredVerticesSize[0],this->RequiredVerticesSize[1],this->RequiredVertices);85 i++; SetMatlabStructureField(output,"RequiredEdges", this->RequiredEdgesSize[0], this->RequiredEdgesSize[1], this->RequiredEdges);86 i++; SetMatlabStructureField(output,"CrackedEdges", this->CrackedEdgesSize[0], this->CrackedEdgesSize[1], this->CrackedEdges);87 i++; SetMatlabStructureField(output,"SubDomains", this->SubDomainsSize[0], this->SubDomainsSize[1], this->SubDomains);88 _assert_(i==numfields);89 90 /*Assign output*/91 *matlab_struct=output;92 93 }94 #endif95 /*}}}*/96 /*FUNCTION BamgGeom::SetMatlabStructureField{{{1*/97 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)98 void BamgGeom::SetMatlabStructureField(mxArray* matlab_struct,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer){99 100 /*Intermediary*/101 int i1,i2;102 mxArray* pfield=NULL;103 mxArray* pfield2=NULL;104 105 /*Copy field*/106 double* fieldcopy=NULL;107 if (fieldrows*fieldcols){108 fieldcopy=(double*)xmalloc(fieldrows*fieldcols*sizeof(double));109 for(i1=0;i1<fieldrows;i1++){110 for(i2=0;i2<fieldcols;i2++){111 fieldcopy[fieldcols*i1+i2]=fieldpointer[fieldcols*i1+i2];112 }113 }114 }115 116 /*Set matlab field*/117 pfield=mxCreateDoubleMatrix(0,0,mxREAL);118 mxSetM(pfield,fieldcols);119 mxSetN(pfield,fieldrows);120 mxSetPr(pfield,fieldcopy);121 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose122 mxSetField(matlab_struct,0,fieldname,pfield2);123 }124 #endif125 /*}}}*/ -
issm/trunk/src/c/objects/Bamg/BamgGeom.h
r11995 r12330 4 4 #ifndef _BAMGGEOM_H_ 5 5 #define _BAMGGEOM_H_ 6 7 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)8 #include <mex.h>9 #endif10 6 11 7 class BamgGeom{ … … 30 26 31 27 BamgGeom(); 32 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)33 BamgGeom(mxArray* matlab_struct);34 #endif35 28 ~BamgGeom(); 36 37 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)38 void SetMatlabStructureFields(mxArray** matlab_struct);39 void SetMatlabStructureField(mxArray* matlab_struct,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer);40 #endif41 29 }; 42 30 -
issm/trunk/src/c/objects/Bamg/BamgMesh.cpp
r11995 r12330 18 18 this->CrackedEdgesSize[0]=0, this->CrackedEdgesSize[1]=0; this->CrackedEdges=NULL; 19 19 20 this->VerticesOnGeomVertexSize[0]=0, this->VerticesOnGeomVertexSize[1]=0;this->VerticesOnGeomVertex=NULL;21 this->VerticesOnGeomEdgeSize[0]=0, this->VerticesOnGeomEdgeSize[1]=0;this->VerticesOnGeomEdge=NULL;22 this->EdgesOnGeomEdgeSize[0]=0, this->EdgesOnGeomEdgeSize[1]=0;this->EdgesOnGeomEdge=NULL;20 this->VerticesOnGeomVertexSize[0]=0, this->VerticesOnGeomVertexSize[1]=0; this->VerticesOnGeomVertex=NULL; 21 this->VerticesOnGeomEdgeSize[0]=0, this->VerticesOnGeomEdgeSize[1]=0; this->VerticesOnGeomEdge=NULL; 22 this->EdgesOnGeomEdgeSize[0]=0, this->EdgesOnGeomEdgeSize[1]=0; this->EdgesOnGeomEdge=NULL; 23 23 24 24 this->IssmEdgesSize[0]=0, this->IssmEdgesSize[1]=0; this->IssmEdges=NULL; … … 28 28 this->NodalConnectivitySize[0]=0, this->NodalConnectivitySize[1]=0; this->NodalConnectivity=NULL; 29 29 this->NodalElementConnectivitySize[0]=0, this->NodalElementConnectivitySize[1]=0; this->NodalElementConnectivity=NULL; 30 31 32 30 } 33 /*}}}*/34 /*FUNCTION BamgMesh::BamgMesh(mxArray* matlab_struct){{{1*/35 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)36 BamgMesh::BamgMesh(mxArray* matlab_struct){37 38 int lines,cols;39 40 FetchData(&this->Vertices, &this->VerticesSize[0], &this->VerticesSize[1], mxGetAssignedField(matlab_struct,0,"Vertices"));41 FetchData(&this->Edges, &this->EdgesSize[0], &this->EdgesSize[1], mxGetAssignedField(matlab_struct,0,"Edges"));42 FetchData(&this->Triangles, &this->TrianglesSize[0], &this->TrianglesSize[1], mxGetAssignedField(matlab_struct,0,"Triangles"));43 this->QuadrilateralsSize[0]=0, this->QuadrilateralsSize[1]=0; this->Quadrilaterals=NULL;44 45 this->SubDomainsSize[0]=0, this->SubDomainsSize[1]=0; this->SubDomains=NULL;46 this->SubDomainsFromGeomSize[0]=0, this->SubDomainsFromGeomSize[1]=0; this->SubDomainsFromGeom=NULL;47 this->CrackedVerticesSize[0]=0, this->CrackedVerticesSize[1]=0; this->CrackedVertices=NULL;48 FetchData(&this->CrackedEdges, &this->CrackedEdgesSize[0], &this->CrackedEdgesSize[1], mxGetAssignedField(matlab_struct,0,"CrackedEdges"));49 50 FetchData(&this->VerticesOnGeomEdge, &this->VerticesOnGeomEdgeSize[0], &this->VerticesOnGeomEdgeSize[1], mxGetAssignedField(matlab_struct,0,"VerticesOnGeomEdge"));51 FetchData(&this->VerticesOnGeomVertex,&this->VerticesOnGeomVertexSize[0],&this->VerticesOnGeomVertexSize[1],mxGetAssignedField(matlab_struct,0,"VerticesOnGeomVertex"));52 FetchData(&this->EdgesOnGeomEdge, &this->EdgesOnGeomEdgeSize[0], &this->EdgesOnGeomEdgeSize[1], mxGetAssignedField(matlab_struct,0,"EdgesOnGeomEdge"));53 54 this->IssmEdgesSize[0]=0, this->IssmEdgesSize[1]=0; this->IssmEdges=NULL;55 FetchData(&this->IssmSegments, &this->IssmSegmentsSize[0], &this->IssmSegmentsSize[1], mxGetAssignedField(matlab_struct,0,"IssmSegments"));56 57 this->ElementConnectivitySize[0]=0, this->ElementConnectivitySize[1]=0; this->ElementConnectivity=NULL;58 this->NodalConnectivitySize[0]=0, this->NodalConnectivitySize[1]=0; this->NodalConnectivity=NULL;59 this->NodalElementConnectivitySize[0]=0, this->NodalElementConnectivitySize[1]=0; this->NodalElementConnectivity=NULL;60 61 }62 #endif63 31 /*}}}*/ 64 32 /*FUNCTION BamgMesh::~BamgMesh(){{{1*/ … … 89 57 } 90 58 /*}}}*/ 91 92 /*Methods*/93 /*FUNCTION BamgMesh::SetMatlabStructureFields{{{1*/94 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)95 void BamgMesh::SetMatlabStructureFields(mxArray** matlab_struct){96 97 /*Intermediary*/98 int i;99 mxArray* output=NULL;100 const int numfields=16;101 const char* fnames[numfields];102 mwSize ndim=2;103 mwSize dimensions[2]={1,1};104 105 /*Initialize field names*/106 i=0;107 fnames[i++] = "Triangles";108 fnames[i++] = "Vertices";109 fnames[i++] = "Edges";110 fnames[i++] = "IssmSegments";111 fnames[i++] = "IssmEdges";112 fnames[i++] = "Quadrilaterals";113 fnames[i++] = "VerticesOnGeomVertex";114 fnames[i++] = "VerticesOnGeomEdge";115 fnames[i++] = "EdgesOnGeomEdge";116 fnames[i++] = "SubDomains";117 fnames[i++] = "SubDomainsFromGeom";118 fnames[i++] = "ElementConnectivity";119 fnames[i++] = "NodalConnectivity";120 fnames[i++] = "NodalElementConnectivity";121 fnames[i++] = "CrackedVertices";122 fnames[i++] = "CrackedEdges";123 _assert_(i==numfields);124 125 /*Initialize Matlab structure*/126 output=mxCreateStructArray(ndim,dimensions,numfields,fnames);127 128 /*set each matlab each field*/129 i=0;130 i++; SetMatlabStructureField(output,"Triangles", this->TrianglesSize[0], this->TrianglesSize[1], this->Triangles);131 i++; SetMatlabStructureField(output,"Vertices", this->VerticesSize[0], this->VerticesSize[1], this->Vertices);132 i++; SetMatlabStructureField(output,"Edges", this->EdgesSize[0], this->EdgesSize[1], this->Edges);133 i++; SetMatlabStructureField(output,"IssmSegments", this->IssmSegmentsSize[0], this->IssmSegmentsSize[1], this->IssmSegments);134 i++; SetMatlabStructureField(output,"IssmEdges", this->IssmEdgesSize[0], this->IssmEdgesSize[1], this->IssmEdges);135 i++; SetMatlabStructureField(output,"Quadrilaterals", this->QuadrilateralsSize[0], this->QuadrilateralsSize[1], this->Quadrilaterals);136 i++; SetMatlabStructureField(output,"VerticesOnGeomVertex",this->VerticesOnGeomVertexSize[0],this->VerticesOnGeomVertexSize[1], this->VerticesOnGeomVertex);137 i++; SetMatlabStructureField(output,"VerticesOnGeomEdge", this->VerticesOnGeomEdgeSize[0], this->VerticesOnGeomEdgeSize[1], this->VerticesOnGeomEdge);138 i++; SetMatlabStructureField(output,"EdgesOnGeomEdge", this->EdgesOnGeomEdgeSize[0], this->EdgesOnGeomEdgeSize[1], this->EdgesOnGeomEdge);139 i++; SetMatlabStructureField(output,"SubDomains", this->SubDomainsSize[0], this->SubDomainsSize[1], this->SubDomains);140 i++; SetMatlabStructureField(output,"SubDomainsFromGeom", this->SubDomainsFromGeomSize[0], this->SubDomainsFromGeomSize[1], this->SubDomainsFromGeom);141 i++; SetMatlabStructureField(output,"ElementConnectivity", this->ElementConnectivitySize[0], this->ElementConnectivitySize[1], this->ElementConnectivity);142 i++; SetMatlabStructureField(output,"NodalConnectivity", this->NodalConnectivitySize[0], this->NodalConnectivitySize[1], this->NodalConnectivity);143 i++; SetMatlabStructureField(output,"NodalElementConnectivity", this->NodalElementConnectivitySize[0], this->NodalElementConnectivitySize[1], this->NodalElementConnectivity);144 i++; SetMatlabStructureField(output,"CrackedVertices", this->CrackedVerticesSize[0], this->CrackedVerticesSize[1], this->CrackedVertices);145 i++; SetMatlabStructureField(output,"CrackedEdges", this->CrackedEdgesSize[0], this->CrackedEdgesSize[1], this->CrackedEdges);146 _assert_(i==numfields);147 148 /*Assign output*/149 *matlab_struct=output;150 151 }152 #endif153 /*}}}*/154 /*FUNCTION BamgMesh::SetMatlabStructureField{{{1*/155 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)156 void BamgMesh::SetMatlabStructureField(mxArray* matlab_struct,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer){157 158 /*Intermediary*/159 int i1,i2;160 mxArray* pfield=NULL;161 mxArray* pfield2=NULL;162 163 /*Copy field*/164 double* fieldcopy=NULL;165 if (fieldrows*fieldcols){166 fieldcopy=(double*)xmalloc(fieldrows*fieldcols*sizeof(double));167 for(i1=0;i1<fieldrows;i1++){168 for(i2=0;i2<fieldcols;i2++){169 fieldcopy[fieldcols*i1+i2]=fieldpointer[fieldcols*i1+i2];170 }171 }172 }173 174 /*Set matlab field*/175 pfield=mxCreateDoubleMatrix(0,0,mxREAL);176 mxSetM(pfield,fieldcols);177 mxSetN(pfield,fieldrows);178 mxSetPr(pfield,fieldcopy);179 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose180 mxSetField(matlab_struct,0,fieldname,pfield2);181 }182 #endif183 /*}}}*/ -
issm/trunk/src/c/objects/Bamg/BamgMesh.h
r11995 r12330 4 4 #ifndef _BAMGMESH_H_ 5 5 #define _BAMGMESH_H_ 6 7 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)8 #include <mex.h>9 #endif10 6 11 7 class BamgMesh{ … … 51 47 52 48 BamgMesh(); 53 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)54 BamgMesh(mxArray* matlab_struct);55 #endif56 49 ~BamgMesh(); 57 58 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)59 void SetMatlabStructureFields(mxArray** matlab_struct);60 void SetMatlabStructureField(mxArray* matlab_struct,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer);61 #endif62 63 50 }; 64 51 -
issm/trunk/src/c/objects/Bamg/BamgOpts.cpp
r11995 r12330 40 40 41 41 } 42 /*}}}*/43 /*FUNCTION BamgOpts::BamgOpts(mxArray* matlab_struct){{{1*/44 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)45 BamgOpts::BamgOpts(mxArray* matlab_struct){46 47 FetchData(&this->anisomax,mxGetField(matlab_struct,0,"anisomax"));48 FetchData(&this->cutoff,mxGetField(matlab_struct,0,"cutoff"));49 FetchData(&this->coeff,mxGetField(matlab_struct,0,"coeff"));50 FetchData(&this->errg,mxGetField(matlab_struct,0,"errg"));51 FetchData(&this->gradation,mxGetField(matlab_struct,0,"gradation"));52 FetchData(&this->Hessiantype,mxGetField(matlab_struct,0,"Hessiantype"));53 FetchData(&this->MaxCornerAngle,mxGetField(matlab_struct,0,"MaxCornerAngle"));54 FetchData(&this->maxnbv,mxGetField(matlab_struct,0,"maxnbv"));55 FetchData(&this->maxsubdiv,mxGetField(matlab_struct,0,"maxsubdiv"));56 FetchData(&this->Metrictype,mxGetField(matlab_struct,0,"Metrictype"));57 FetchData(&this->nbjacobi,mxGetField(matlab_struct,0,"nbjacobi"));58 FetchData(&this->nbsmooth,mxGetField(matlab_struct,0,"nbsmooth"));59 FetchData(&this->omega,mxGetField(matlab_struct,0,"omega"));60 FetchData(&this->power,mxGetField(matlab_struct,0,"power"));61 FetchData(&this->verbose,mxGetField(matlab_struct,0,"verbose"));62 63 FetchData(&this->Crack,mxGetField(matlab_struct,0,"Crack"));64 FetchData(&this->geometricalmetric,mxGetField(matlab_struct,0,"geometricalmetric"));65 FetchData(&this->KeepVertices,mxGetField(matlab_struct,0,"KeepVertices"));66 FetchData(&this->splitcorners,mxGetField(matlab_struct,0,"splitcorners"));67 68 FetchData(&this->hmin,mxGetField(matlab_struct,0,"hmin"));69 FetchData(&this->hmax,mxGetField(matlab_struct,0,"hmax"));70 FetchData(&this->hminVertices,&this->hminVerticesSize[0],&this->hminVerticesSize[1],mxGetField(matlab_struct,0,"hminVertices"));71 FetchData(&this->hmaxVertices,&this->hmaxVerticesSize[0],&this->hmaxVerticesSize[1],mxGetField(matlab_struct,0,"hmaxVertices"));72 FetchData(&this->hVertices,&this->hVerticesSize[0],&this->hVerticesSize[1],mxGetField(matlab_struct,0,"hVertices"));73 FetchData(&this->metric,&this->metricSize[0],&this->metricSize[1],mxGetField(matlab_struct,0,"metric"));74 FetchData(&this->field,&this->fieldSize[0],&this->fieldSize[1],mxGetField(matlab_struct,0,"field"));75 FetchData(&this->err,&this->errSize[0],&this->errSize[1],mxGetField(matlab_struct,0,"err"));76 77 /*Additional checks*/78 this->Check();79 80 }81 #endif82 42 /*}}}*/ 83 43 /*FUNCTION BamgOpts::~BamgOpts() {{{1*/ -
issm/trunk/src/c/objects/Bamg/BamgOpts.h
r11995 r12330 5 5 #ifndef _BAMGOPTS_H_ 6 6 #define _BAMGOPTS_H_ 7 8 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)9 #include <mex.h>10 #endif11 7 12 8 class BamgOpts{ … … 54 50 55 51 BamgOpts(); 56 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)57 BamgOpts(mxArray* matlab_struct);58 #endif59 52 ~BamgOpts(); 60 53 -
issm/trunk/src/c/objects/Bamg/Geometry.cpp
r9309 r12330 505 505 float *eangle = new float[nbe]; 506 506 double eps = 1e-20; 507 QuadTree quadtree; // build quadtree to find duplicates507 BamgQuadtree quadtree; // build quadtree to find duplicates 508 508 BamgVertex *v0 = vertices; 509 509 GeomVertex *v0g = (GeomVertex*) (void*)v0; -
issm/trunk/src/c/objects/Bamg/Geometry.h
r5573 r12330 12 12 13 13 class Triangle; 14 class QuadTree;14 class BamgQuadtree; 15 15 class GeomSubDomain; 16 16 class Edge; … … 20 20 public: 21 21 22 long NbRef;// counter of ref on the this class if 0 we can delete23 long nbv;// number of vertices24 long nbe;// number of edges25 long 26 long 22 long NbRef; // counter of ref on the this class if 0 we can delete 23 long nbv; // number of vertices 24 long nbe; // number of edges 25 long nbsubdomains; 26 long nbcurves; 27 27 GeomVertex *vertices; 28 28 GeomEdge *edges; 29 QuadTree*quadtree;29 BamgQuadtree *quadtree; 30 30 GeomSubDomain *subdomains; 31 Curve 32 R2 pmin,pmax;// domain extrema coordinates33 double coefIcoor;// coef to integer Icoor1;34 double 31 Curve *curves; 32 R2 pmin,pmax; // domain extrema coordinates 33 double coefIcoor; // coef to integer Icoor1; 34 double MaxCornerAngle; 35 35 36 36 //Constructor/Destructors … … 44 44 GeomVertex &operator[](long i) { return vertices[i]; }; 45 45 const GeomEdge &operator()(long i) const { return edges[i]; }; 46 GeomEdge &operator()(long i) { return edges[i]; 46 GeomEdge &operator()(long i) { return edges[i]; }; 47 47 48 48 //Methods -
issm/trunk/src/c/objects/Bamg/Mesh.cpp
r11995 r12330 2885 2885 2886 2886 //build quadtree 2887 if (!quadtree) quadtree = new QuadTree(this,0);2887 if (!quadtree) quadtree = new BamgQuadtree(this,0); 2888 2888 quadtree->Add(*v0); 2889 2889 quadtree->Add(*v1); … … 3107 3107 } 3108 3108 /*}}}1*/ 3109 /*FUNCTION Mesh::Make QuadTree{{{1*/3110 void Mesh::Make QuadTree() {3111 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Make QuadTree)*/3109 /*FUNCTION Mesh::MakeBamgQuadtree{{{1*/ 3110 void Mesh::MakeBamgQuadtree() { 3111 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/MakeBamgQuadtree)*/ 3112 3112 3113 3113 long int verbose=0; 3114 if ( !quadtree ) quadtree = new QuadTree(this);3114 if ( !quadtree ) quadtree = new BamgQuadtree(this); 3115 3115 3116 3116 } … … 3622 3622 3623 3623 if (!quadtree) delete quadtree; //ReInitialise; 3624 quadtree = new QuadTree(this,0);3624 quadtree = new BamgQuadtree(this,0); 3625 3625 quadtree->Add(*v0); 3626 3626 quadtree->Add(*v1); … … 3900 3900 if (quadtree){ 3901 3901 delete quadtree; 3902 quadtree = new QuadTree(this);3902 quadtree = new BamgQuadtree(this); 3903 3903 } 3904 3904 … … 4116 4116 4117 4117 delete [] tstart; 4118 if (quadtree) quadtree= new QuadTree(this);4118 if (quadtree) quadtree= new BamgQuadtree(this); 4119 4119 } 4120 4120 /*}}}1*/ -
issm/trunk/src/c/objects/Bamg/Mesh.h
r10205 r12330 17 17 class Geometry; 18 18 class CrackedEdge; 19 class QuadTree;19 class BamgQuadtree; 20 20 class SubDomain; 21 21 … … 29 29 Triangle *triangles; 30 30 Edge *edges; 31 QuadTree*quadtree;31 BamgQuadtree *quadtree; 32 32 BamgVertex **orderedvertices; 33 33 SubDomain *subdomains; … … 94 94 void MakeQuadrangles(double costheta); 95 95 int SplitElement(int choice); 96 void Make QuadTree();96 void MakeBamgQuadtree(); 97 97 void NewPoints(Mesh &,BamgOpts* bamgopts,int KeepVertices=1); 98 98 long InsertNewPoints(long nbvold,long & NbTSwap) ; -
issm/trunk/src/c/objects/Bamg/Metric.h
r9690 r12330 5 5 #include "../../shared/Bamg/shared.h" 6 6 #include "R2.h" 7 #include <math.h> 7 8 8 9 namespace bamg { -
issm/trunk/src/c/objects/Constraints/Constraint.h
r9285 r12330 11 11 /*Headers:*/ 12 12 /*{{{1*/ 13 class Nodes; 13 14 #include "../Object.h" 14 15 class Nodes;16 17 15 #include "../../toolkits/toolkits.h" 18 16 /*}}}*/ -
issm/trunk/src/c/objects/Constraints/SpcDynamic.cpp
r9883 r12330 72 72 } 73 73 /*}}}1*/ 74 #ifdef _SERIAL_75 /*FUNCTION SpcDynamic::Marshall {{{1*/76 void SpcDynamic::Marshall(char** pmarshalled_dataset){77 78 char* marshalled_dataset=NULL;79 int enum_type=0;80 81 /*recover marshalled_dataset: */82 marshalled_dataset=*pmarshalled_dataset;83 84 /*get enum type of SpcDynamic: */85 enum_type=SpcDynamicEnum;86 87 /*marshall enum: */88 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);89 90 /*marshall SpcDynamic data: */91 memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);92 memcpy(marshalled_dataset,&nodeid,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);93 memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof);94 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);95 memcpy(marshalled_dataset,&isset,sizeof(isset));marshalled_dataset+=sizeof(isset);96 memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);97 98 *pmarshalled_dataset=marshalled_dataset;99 return;100 }101 /*}}}1*/102 /*FUNCTION SpcDynamic::MarshallSize {{{1*/103 int SpcDynamic::MarshallSize(){104 105 return sizeof(sid)106 +sizeof(nodeid)107 +sizeof(dof)108 +sizeof(value)109 +sizeof(isset)110 +sizeof(analysis_type)111 +sizeof(int); //sizeof(int) for enum type112 }113 /*}}}1*/114 /*FUNCTION SpcDynamic::Demarshall {{{1*/115 void SpcDynamic::Demarshall(char** pmarshalled_dataset){116 117 char* marshalled_dataset=NULL;118 119 /*recover marshalled_dataset: */120 marshalled_dataset=*pmarshalled_dataset;121 122 /*this time, no need to get enum type, the pointer directly points to the beginning of the123 *object data (thanks to DataSet::Demarshall):*/124 125 memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);126 memcpy(&nodeid,marshalled_dataset,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);127 memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof);128 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);129 memcpy(&isset,marshalled_dataset,sizeof(isset));marshalled_dataset+=sizeof(isset);130 memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);131 132 /*return: */133 *pmarshalled_dataset=marshalled_dataset;134 return;135 }136 /*}}}1*/137 #endif138 74 /*FUNCTION SpcDynamic::ObjectEnum{{{1*/ 139 75 int SpcDynamic::ObjectEnum(void){ -
issm/trunk/src/c/objects/Constraints/SpcDynamic.h
r9883 r12330 34 34 int Id(); 35 35 int MyRank(); 36 #ifdef _SERIAL_37 void Marshall(char** pmarshalled_dataset);38 int MarshallSize();39 void Demarshall(char** pmarshalled_dataset);40 #endif41 36 int ObjectEnum(); 42 37 Object* copy(); -
issm/trunk/src/c/objects/Constraints/SpcStatic.cpp
r9883 r12330 75 75 } 76 76 /*}}}1*/ 77 #ifdef _SERIAL_78 /*FUNCTION SpcStatic::Marshall {{{1*/79 void SpcStatic::Marshall(char** pmarshalled_dataset){80 81 char* marshalled_dataset=NULL;82 int enum_type=0;83 84 /*recover marshalled_dataset: */85 marshalled_dataset=*pmarshalled_dataset;86 87 /*get enum type of SpcStatic: */88 enum_type=SpcStaticEnum;89 90 /*marshall enum: */91 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);92 93 /*marshall SpcStatic data: */94 memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);95 memcpy(marshalled_dataset,&nodeid,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);96 memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof);97 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);98 memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);99 100 *pmarshalled_dataset=marshalled_dataset;101 return;102 }103 /*}}}1*/104 /*FUNCTION SpcStatic::MarshallSize {{{1*/105 int SpcStatic::MarshallSize(){106 107 return sizeof(sid)108 +sizeof(nodeid)109 +sizeof(dof)110 +sizeof(value)111 +sizeof(analysis_type)112 +sizeof(int); //sizeof(int) for enum type113 }114 /*}}}1*/115 /*FUNCTION SpcStatic::Demarshall {{{1*/116 void SpcStatic::Demarshall(char** pmarshalled_dataset){117 118 char* marshalled_dataset=NULL;119 120 /*recover marshalled_dataset: */121 marshalled_dataset=*pmarshalled_dataset;122 123 /*this time, no need to get enum type, the pointer directly points to the beginning of the124 *object data (thanks to DataSet::Demarshall):*/125 126 memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);127 memcpy(&nodeid,marshalled_dataset,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);128 memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof);129 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);130 memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);131 132 /*return: */133 *pmarshalled_dataset=marshalled_dataset;134 return;135 }136 /*}}}1*/137 #endif138 77 /*FUNCTION SpcStatic::ObjectEnum{{{1*/ 139 78 int SpcStatic::ObjectEnum(void){ -
issm/trunk/src/c/objects/Constraints/SpcStatic.h
r9883 r12330 33 33 int Id(); 34 34 int MyRank(); 35 #ifdef _SERIAL_36 void Marshall(char** pmarshalled_dataset);37 int MarshallSize();38 void Demarshall(char** pmarshalled_dataset);39 #endif40 35 int ObjectEnum(); 41 36 Object* copy(); -
issm/trunk/src/c/objects/Constraints/SpcTransient.cpp
r9883 r12330 87 87 } 88 88 /*}}}1*/ 89 #ifdef _SERIAL_90 /*FUNCTION SpcTransient::Marshall {{{1*/91 void SpcTransient::Marshall(char** pmarshalled_dataset){92 93 char* marshalled_dataset=NULL;94 int enum_type=0;95 96 /*recover marshalled_dataset: */97 marshalled_dataset=*pmarshalled_dataset;98 99 /*get enum type of SpcTransient: */100 enum_type=SpcTransientEnum;101 102 /*marshall enum: */103 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);104 105 /*marshall SpcTransient data: */106 memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);107 memcpy(marshalled_dataset,&nodeid,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);108 memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof);109 memcpy(marshalled_dataset,&nsteps,sizeof(nsteps));marshalled_dataset+=sizeof(nsteps);110 memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);111 if(nsteps){112 memcpy(marshalled_dataset,values,nsteps*sizeof(double));marshalled_dataset+=nsteps*sizeof(double);113 memcpy(marshalled_dataset,times,nsteps*sizeof(double));marshalled_dataset+=nsteps*sizeof(double);114 }115 116 *pmarshalled_dataset=marshalled_dataset;117 return;118 }119 /*}}}1*/120 /*FUNCTION SpcTransient::MarshallSize {{{1*/121 int SpcTransient::MarshallSize(){122 123 return sizeof(sid)124 +sizeof(nodeid)125 +sizeof(dof)126 +sizeof(nsteps)127 +nsteps*2*sizeof(double)128 +sizeof(analysis_type)129 +sizeof(int); //sizeof(int) for enum type130 }131 /*}}}1*/132 /*FUNCTION SpcTransient::Demarshall {{{1*/133 void SpcTransient::Demarshall(char** pmarshalled_dataset){134 135 char* marshalled_dataset=NULL;136 137 /*recover marshalled_dataset: */138 marshalled_dataset=*pmarshalled_dataset;139 140 /*this time, no need to get enum type, the pointer directly points to the beginning of the141 *object data (thanks to DataSet::Demarshall):*/142 143 memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);144 memcpy(&nodeid,marshalled_dataset,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);145 memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof);146 memcpy(&nsteps,marshalled_dataset,sizeof(nsteps));marshalled_dataset+=sizeof(nsteps);147 memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);148 if(nsteps){149 values=(double*)xmalloc(nsteps*sizeof(double));150 times=(double*)xmalloc(nsteps*sizeof(double));151 memcpy(values,marshalled_dataset,nsteps*sizeof(double));marshalled_dataset+=nsteps*sizeof(double);152 memcpy(times,marshalled_dataset,nsteps*sizeof(double));marshalled_dataset+=nsteps*sizeof(double);153 }154 155 /*return: */156 *pmarshalled_dataset=marshalled_dataset;157 return;158 }159 /*}}}1*/160 #endif161 89 /*FUNCTION SpcTransient::ObjectEnum{{{1*/ 162 90 int SpcTransient::ObjectEnum(void){ -
issm/trunk/src/c/objects/Constraints/SpcTransient.h
r9883 r12330 35 35 int Id(); 36 36 int MyRank(); 37 #ifdef _SERIAL_38 void Marshall(char** pmarshalled_dataset);39 int MarshallSize();40 void Demarshall(char** pmarshalled_dataset);41 #endif42 37 int ObjectEnum(); 43 38 Object* copy(); -
issm/trunk/src/c/objects/Contour.cpp
r11995 r12330 9 9 #endif 10 10 11 #include <string.h> 11 12 #include "./objects.h" 12 13 #include "../include/include.h" … … 79 80 } 80 81 /*}}}*/ 81 #ifdef _SERIAL_82 /*FUNCTION Contour::Marshall{{{1*/83 void Contour::Marshall(char** pmarshalled_dataset){84 85 char* marshalled_dataset=NULL;86 int enum_type=0;87 char* marshalled_inputs=NULL;88 int marshalled_inputssize;89 90 /*recover marshalled_dataset: */91 marshalled_dataset=*pmarshalled_dataset;92 93 /*get enum type of Contour: */94 enum_type=ContourEnum;95 96 /*marshall enum: */97 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);98 99 /*marshall Contour data: */100 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);101 memcpy(marshalled_dataset,&nods,sizeof(nods));marshalled_dataset+=sizeof(nods);102 memcpy(marshalled_dataset,&closed,sizeof(closed));marshalled_dataset+=sizeof(closed);103 memcpy(marshalled_dataset,x,nods*sizeof(double));marshalled_dataset+=nods*sizeof(double);104 memcpy(marshalled_dataset,y,nods*sizeof(double));marshalled_dataset+=nods*sizeof(double);105 106 *pmarshalled_dataset=marshalled_dataset;107 return;108 }109 /*}}}*/110 /*FUNCTION Contour::MarshallSize{{{1*/111 int Contour::MarshallSize(){112 113 return sizeof(id)+114 sizeof(nods)+115 sizeof(closed)+116 2*nods*sizeof(double)+117 sizeof(int); //sizeof(int) for enum type118 }119 /*}}}*/120 /*FUNCTION Contour::Demarshall{{{1*/121 void Contour::Demarshall(char** pmarshalled_dataset){122 123 char* marshalled_dataset=NULL;124 125 /*recover marshalled_dataset: */126 marshalled_dataset=*pmarshalled_dataset;127 128 /*this time, no need to get enum type, the pointer directly points to the beginning of the129 *object data (thanks to DataSet::Demarshall):*/130 131 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);132 memcpy(&nods,marshalled_dataset,sizeof(nods));marshalled_dataset+=sizeof(nods);133 memcpy(&closed,marshalled_dataset,sizeof(closed));marshalled_dataset+=sizeof(closed);134 135 if(nods){136 this->x=(double*)xmalloc(nods*sizeof(double));137 this->y=(double*)xmalloc(nods*sizeof(double));138 memcpy(x,marshalled_dataset,nods*sizeof(double));marshalled_dataset+=nods*sizeof(double);139 memcpy(y,marshalled_dataset,nods*sizeof(double));marshalled_dataset+=nods*sizeof(double);140 }141 142 /*return: */143 *pmarshalled_dataset=marshalled_dataset;144 return;145 }146 /*}}}*/147 #endif148 82 /*FUNCTION Contour::ObjectEnum{{{1*/ 149 83 int Contour::ObjectEnum(void){ -
issm/trunk/src/c/objects/Contour.h
r11995 r12330 20 20 int id; 21 21 int nods; //number of vertices in the contour 22 double* x;23 double* y;22 IssmDouble* x; 23 IssmDouble* y; 24 24 bool closed; //is this contour closed? 25 25 26 26 /*Contour constructors, destructors {{{1*/ 27 27 Contour(); 28 Contour(int id, int nods, double* x, double* y,bool closed);28 Contour(int id, int nods, IssmDouble* x, IssmDouble* y,bool closed); 29 29 ~Contour(); 30 30 /*}}}*/ … … 34 34 int Id(void); 35 35 int MyRank(void); 36 #ifdef _SERIAL_37 void Marshall(char** pmarshalled_dataset);38 int MarshallSize(void);39 void Demarshall(char** pmarshalled_dataset);40 #endif41 36 int ObjectEnum(void); 42 37 Object* copy(void); -
issm/trunk/src/c/objects/DofIndexing.cpp
r9777 r12330 208 208 } 209 209 /*}}}*/ 210 #ifdef _SERIAL_ 211 /*FUNCTION DofIndexing::Marshall{{{1*/ 212 void DofIndexing::Marshall(char** pmarshalled_dataset){ 213 214 char* marshalled_dataset=NULL; 215 int enum_type=0; 216 bool flagdoftype; //to indicate if there are some doftype or if NULL 217 218 /*recover marshalled_dataset: */ 219 marshalled_dataset=*pmarshalled_dataset; 220 221 /*preliminary: */ 222 if(this->doftype)flagdoftype=true; 223 else flagdoftype=false; 224 225 /*get enum type of DofIndexing: */ 226 enum_type=DofIndexingEnum; 227 228 /*marshall enum: */ 229 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 230 231 /*marshall DofIndexing data: */ 232 memcpy(marshalled_dataset,&gsize,sizeof(gsize));marshalled_dataset+=sizeof(gsize); 233 memcpy(marshalled_dataset,&fsize,sizeof(fsize));marshalled_dataset+=sizeof(fsize); 234 memcpy(marshalled_dataset,&ssize,sizeof(ssize));marshalled_dataset+=sizeof(ssize); 235 memcpy(marshalled_dataset,&flagdoftype,sizeof(flagdoftype));marshalled_dataset+=sizeof(flagdoftype); 236 memcpy(marshalled_dataset,&clone,sizeof(clone));marshalled_dataset+=sizeof(clone); 237 238 if(this->gsize>0){ 239 memcpy(marshalled_dataset,f_set,gsize*sizeof(bool));marshalled_dataset+=gsize*sizeof(bool); 240 memcpy(marshalled_dataset,s_set,gsize*sizeof(bool));marshalled_dataset+=gsize*sizeof(bool); 241 memcpy(marshalled_dataset,svalues,gsize*sizeof(double)); marshalled_dataset+=gsize*sizeof(double); 242 if(flagdoftype){ memcpy(marshalled_dataset,doftype,gsize*sizeof(int)); marshalled_dataset+=gsize*sizeof(int); } 243 memcpy(marshalled_dataset,gdoflist,gsize*sizeof(int)); marshalled_dataset+=gsize*sizeof(int); 244 } 245 if(this->fsize>0 && this->fsize!=UNDEF){ memcpy(marshalled_dataset,fdoflist,fsize*sizeof(int)); marshalled_dataset+=fsize*sizeof(int);} 246 if(this->ssize>0 && this->ssize!=UNDEF){ memcpy(marshalled_dataset,sdoflist,ssize*sizeof(int)); marshalled_dataset+=ssize*sizeof(int);} 247 248 *pmarshalled_dataset=marshalled_dataset; 249 return; 250 } 251 /*}}}*/ 252 /*FUNCTION DofIndexing::MarshallSize{{{1*/ 253 int DofIndexing::MarshallSize(){ 254 255 int size=0; 256 257 size+=4*sizeof(int)+sizeof(bool); 258 if(this->gsize>0){ 259 size+= 2*this->gsize*sizeof(bool)+ 260 this->gsize*sizeof(double)+ 261 this->gsize*sizeof(int); 262 if(this->doftype)size+=this->gsize*sizeof(int); 263 } 264 if(this->fsize>0 && this->fsize!=UNDEF)size+=this->fsize*sizeof(int); 265 if(this->ssize>0 && this->ssize!=UNDEF)size+=this->ssize*sizeof(int); 266 267 size+=sizeof(int); //sizeof(int) for enum type 268 269 return size; 270 } 271 /*}}}*/ 272 /*FUNCTION DofIndexing::Demarshall{{{1*/ 273 void DofIndexing::Demarshall(char** pmarshalled_dataset){ 274 275 char* marshalled_dataset=NULL; 276 int enum_type; 277 bool flagdoftype; 278 279 /*recover marshalled_dataset: */ 280 marshalled_dataset=*pmarshalled_dataset; 281 282 /*get enum type of object since DofIndexing is not directly called by DataSet: */ 283 memcpy(&enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int); 284 285 /*easy part: */ 286 memcpy(&gsize,marshalled_dataset,sizeof(gsize));marshalled_dataset+=sizeof(gsize); 287 memcpy(&fsize,marshalled_dataset,sizeof(fsize));marshalled_dataset+=sizeof(fsize); 288 memcpy(&ssize,marshalled_dataset,sizeof(ssize));marshalled_dataset+=sizeof(ssize); 289 memcpy(&flagdoftype,marshalled_dataset,sizeof(flagdoftype));marshalled_dataset+=sizeof(flagdoftype); 290 memcpy(&clone,marshalled_dataset,sizeof(clone));marshalled_dataset+=sizeof(clone); 291 292 /*Allocate: */ 293 if(this->gsize>0){ 294 this->f_set=(bool*)xmalloc(this->gsize*sizeof(bool)); 295 this->s_set=(bool*)xmalloc(this->gsize*sizeof(bool)); 296 this->svalues=(double*)xmalloc(this->gsize*sizeof(double)); 297 if(flagdoftype)this->doftype=(int*)xmalloc(this->gsize*sizeof(int)); 298 else this->doftype=NULL; 299 this->gdoflist=(int*)xmalloc(this->gsize*sizeof(int)); 300 } 301 else{ 302 this->f_set=NULL; 303 this->s_set=NULL; 304 this->svalues=NULL; 305 this->doftype=NULL; 306 this->gdoflist=NULL; 307 } 308 if(this->fsize>0) 309 this->fdoflist=(int*)xmalloc(this->fsize*sizeof(int)); 310 else 311 this->fdoflist=NULL; 312 if(this->ssize>0) 313 this->sdoflist=(int*)xmalloc(this->ssize*sizeof(int)); 314 else 315 this->sdoflist=NULL; 316 317 /*Copy arrays: */ 318 if(this->gsize>0){ 319 memcpy(f_set,marshalled_dataset,gsize*sizeof(bool));marshalled_dataset+=gsize*sizeof(bool); 320 memcpy(s_set,marshalled_dataset,gsize*sizeof(bool));marshalled_dataset+=gsize*sizeof(bool); 321 memcpy(svalues,marshalled_dataset,gsize*sizeof(double));marshalled_dataset+=gsize*sizeof(double); 322 if(flagdoftype){memcpy(doftype,marshalled_dataset,gsize*sizeof(int));marshalled_dataset+=gsize*sizeof(int); } 323 memcpy(gdoflist,marshalled_dataset,gsize*sizeof(int));marshalled_dataset+=gsize*sizeof(int); 324 } 325 326 if(this->fsize>0 && this->fsize!=UNDEF){ memcpy(this->fdoflist,marshalled_dataset,this->fsize*sizeof(int));marshalled_dataset+=this->fsize*sizeof(int); } 327 if(this->ssize>0 && this->ssize!=UNDEF){ memcpy(this->sdoflist,marshalled_dataset,this->ssize*sizeof(int));marshalled_dataset+=this->ssize*sizeof(int); } 328 329 /*return: */ 330 *pmarshalled_dataset=marshalled_dataset; 331 return; 332 } 333 /*}}}*/ 334 #endif 335 210 -
issm/trunk/src/c/objects/DofIndexing.h
r9777 r12330 5 5 #ifndef _DOFINDEXING_H_ 6 6 #define _DOFINDEXING_H_ 7 8 #include "../include/include.h" 7 9 8 10 class DofIndexing{ … … 21 23 bool* f_set; //is dof on f-set (on which we solve) 22 24 bool* s_set; //is dof on s-set (on which boundary conditions -dirichlet- are applied) 23 double* svalues; //list of constraint values. size g_size, for ease of use.25 IssmDouble* svalues; //list of constraint values. size g_size, for ease of use. 24 26 25 27 /*types of dofs: */ … … 43 45 void Echo(void); 44 46 void DeepEcho(void); 45 #ifdef _SERIAL_46 void Marshall(char** pmarshalled_dataset);47 int MarshallSize();48 void Demarshall(char** pmarshalled_dataset);49 #endif50 47 void copy(DofIndexing* properties); 51 48 /*}}}*/ -
issm/trunk/src/c/objects/ElementResults/BoolElementResult.cpp
r11995 r12330 64 64 } 65 65 /*}}}*/ 66 #ifdef _SERIAL_67 /*FUNCTION BoolElementResult::Marshall{{{1*/68 void BoolElementResult::Marshall(char** pmarshalled_dataset){69 70 char* marshalled_dataset=NULL;71 int enum_value=0;72 73 /*recover marshalled_dataset: */74 marshalled_dataset=*pmarshalled_dataset;75 76 /*get enum value of BoolElementResult: */77 enum_value=BoolElementResultEnum;78 79 /*marshall enum: */80 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);81 82 /*marshall BoolElementResult data: */83 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);84 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);85 memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);86 memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);87 88 *pmarshalled_dataset=marshalled_dataset;89 }90 /*}}}*/91 /*FUNCTION BoolElementResult::Demarshall{{{1*/92 void BoolElementResult::Demarshall(char** pmarshalled_dataset){93 94 char* marshalled_dataset=NULL;95 int i;96 97 /*recover marshalled_dataset: */98 marshalled_dataset=*pmarshalled_dataset;99 100 /*this time, no need to get enum type, the pointer directly points to the beginning of the101 *object data (thanks to DataSet::Demarshall):*/102 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);103 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);104 memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);105 memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);106 107 /*return: */108 *pmarshalled_dataset=marshalled_dataset;109 return;110 }111 /*}}}*/112 /*FUNCTION BoolElementResult::MarshallSize{{{1*/113 int BoolElementResult::MarshallSize(){114 115 return sizeof(value)+116 +sizeof(enum_type)117 +sizeof(time)118 +sizeof(step)119 +sizeof(int); //sizeof(int) for enum value120 }121 /*}}}*/122 #endif123 66 /*FUNCTION BoolElementResult::ObjectEnum{{{1*/ 124 67 int BoolElementResult::ObjectEnum(void){ -
issm/trunk/src/c/objects/ElementResults/BoolElementResult.h
r11995 r12330 35 35 int Id(); 36 36 int MyRank(); 37 #ifdef _SERIAL_38 void Marshall(char** pmarshalled_dataset);39 int MarshallSize();40 void Demarshall(char** pmarshalled_dataset);41 #endif42 37 int ObjectEnum(); 43 38 Object* copy(); -
issm/trunk/src/c/objects/ElementResults/DoubleElementResult.cpp
r9883 r12330 64 64 } 65 65 /*}}}*/ 66 #ifdef _SERIAL_67 /*FUNCTION DoubleElementResult::Marshall{{{1*/68 void DoubleElementResult::Marshall(char** pmarshalled_dataset){69 70 char* marshalled_dataset=NULL;71 int enum_value=0;72 73 /*recover marshalled_dataset: */74 marshalled_dataset=*pmarshalled_dataset;75 76 /*get enum value of DoubleElementResult: */77 enum_value=DoubleElementResultEnum;78 79 /*marshall enum: */80 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);81 82 /*marshall DoubleElementResult data: */83 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);84 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);85 memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);86 memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);87 88 *pmarshalled_dataset=marshalled_dataset;89 }90 /*}}}*/91 /*FUNCTION DoubleElementResult::Demarshall{{{1*/92 void DoubleElementResult::Demarshall(char** pmarshalled_dataset){93 94 char* marshalled_dataset=NULL;95 int i;96 97 /*recover marshalled_dataset: */98 marshalled_dataset=*pmarshalled_dataset;99 100 /*this time, no need to get enum type, the pointer directly points to the beginning of the101 *object data (thanks to DataSet::Demarshall):*/102 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);103 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);104 memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);105 memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);106 107 /*return: */108 *pmarshalled_dataset=marshalled_dataset;109 return;110 }111 /*}}}*/112 /*FUNCTION DoubleElementResult::MarshallSize{{{1*/113 int DoubleElementResult::MarshallSize(){114 115 return sizeof(value)+116 +sizeof(enum_type)117 +sizeof(time)118 +sizeof(step)119 +sizeof(int); //sizeof(int) for enum value120 }121 /*}}}*/122 #endif123 66 /*FUNCTION DoubleElementResult::ObjectEnum{{{1*/ 124 67 int DoubleElementResult::ObjectEnum(void){ -
issm/trunk/src/c/objects/ElementResults/DoubleElementResult.h
r11995 r12330 35 35 int Id(); 36 36 int MyRank(); 37 #ifdef _SERIAL_38 void Marshall(char** pmarshalled_dataset);39 int MarshallSize();40 void Demarshall(char** pmarshalled_dataset);41 #endif42 37 int ObjectEnum(); 43 38 Object* copy(); -
issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.cpp
r11995 r12330 67 67 } 68 68 /*}}}*/ 69 #ifdef _SERIAL_70 /*FUNCTION PentaP1ElementResult::Marshall{{{1*/71 void PentaP1ElementResult::Marshall(char** pmarshalled_dataset){72 73 char* marshalled_dataset=NULL;74 int enum_value=0;75 76 /*recover marshalled_dataset: */77 marshalled_dataset=*pmarshalled_dataset;78 79 /*get enum value of PentaP1ElementResult: */80 enum_value=PentaP1ElementResultEnum;81 82 /*marshall enum: */83 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);84 85 /*marshall PentaP1ElementResult data: */86 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);87 memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);88 memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);89 memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);90 91 *pmarshalled_dataset=marshalled_dataset;92 }93 /*}}}*/94 /*FUNCTION PentaP1ElementResult::MarshallSize{{{1*/95 int PentaP1ElementResult::MarshallSize(){96 97 return sizeof(values)+98 +sizeof(enum_type)99 +sizeof(time)100 +sizeof(step)101 +sizeof(int); //sizeof(int) for enum value102 }103 /*}}}*/104 /*FUNCTION PentaP1ElementResult::Demarshall{{{1*/105 void PentaP1ElementResult::Demarshall(char** pmarshalled_dataset){106 107 char* marshalled_dataset=NULL;108 int i;109 110 /*recover marshalled_dataset: */111 marshalled_dataset=*pmarshalled_dataset;112 113 /*this time, no need to get enum type, the pointer directly points to the beginning of the114 *object data (thanks to DataSet::Demarshall):*/115 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);116 memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);117 memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);118 memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);119 120 /*return: */121 *pmarshalled_dataset=marshalled_dataset;122 return;123 }124 /*}}}*/125 #endif126 69 /*FUNCTION PentaP1ElementResult::ObjectEnum{{{1*/ 127 70 int PentaP1ElementResult::ObjectEnum(void){ -
issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.h
r11995 r12330 34 34 int Id(); 35 35 int MyRank(); 36 #ifdef _SERIAL_37 void Marshall(char** pmarshalled_dataset);38 int MarshallSize();39 void Demarshall(char** pmarshalled_dataset);40 #endif41 36 int ObjectEnum(); 42 37 Object* copy(); -
issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.cpp
r11995 r12330 66 66 } 67 67 /*}}}*/ 68 #ifdef _SERIAL_69 /*FUNCTION TriaP1ElementResult::Marshall{{{1*/70 void TriaP1ElementResult::Marshall(char** pmarshalled_dataset){71 72 char* marshalled_dataset=NULL;73 int enum_value=0;74 75 76 /*recover marshalled_dataset: */77 marshalled_dataset=*pmarshalled_dataset;78 79 /*get enum value of TriaP1ElementResult: */80 enum_value=TriaP1ElementResultEnum;81 82 /*marshall enum: */83 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);84 85 /*marshall TriaP1ElementResult data: */86 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);87 memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);88 memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);89 memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);90 91 *pmarshalled_dataset=marshalled_dataset;92 }93 /*}}}*/94 /*FUNCTION TriaP1ElementResult::MarshallSize{{{1*/95 int TriaP1ElementResult::MarshallSize(){96 97 return sizeof(values)98 +sizeof(enum_type)99 +sizeof(time)100 +sizeof(step)101 +sizeof(int); //sizeof(int) for enum value102 }103 /*}}}*/104 /*FUNCTION TriaP1ElementResult::Demarshall{{{1*/105 void TriaP1ElementResult::Demarshall(char** pmarshalled_dataset){106 107 char* marshalled_dataset=NULL;108 int i;109 110 /*recover marshalled_dataset: */111 marshalled_dataset=*pmarshalled_dataset;112 113 /*this time, no need to get enum type, the pointer directly points to the beginning of the114 *object data (thanks to DataSet::Demarshall):*/115 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);116 memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);117 memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);118 memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);119 120 /*return: */121 *pmarshalled_dataset=marshalled_dataset;122 return;123 }124 /*}}}*/125 #endif126 68 /*FUNCTION TriaP1ElementResult::ObjectEnum{{{1*/ 127 69 int TriaP1ElementResult::ObjectEnum(void){ -
issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.h
r11995 r12330 33 33 int Id(); 34 34 int MyRank(); 35 #ifdef _SERIAL_36 void Marshall(char** pmarshalled_dataset);37 int MarshallSize();38 void Demarshall(char** pmarshalled_dataset);39 #endif40 35 int ObjectEnum(); 41 36 Object* copy(); -
issm/trunk/src/c/objects/Elements/Penta.cpp
r12294 r12330 142 142 } 143 143 /*}}}*/ 144 145 /*Marshall*/146 #ifdef _SERIAL_147 /*FUNCTION Penta::Marshall {{{1*/148 void Penta::Marshall(char** pmarshalled_dataset){149 150 int i;151 char* marshalled_dataset=NULL;152 int enum_type=0;153 char* marshalled_inputs=NULL;154 int marshalled_inputs_size;155 char* marshalled_results=NULL;156 int marshalled_results_size;157 int flaghook; //to indicate if hook is NULL or exists158 159 /*recover marshalled_dataset: */160 marshalled_dataset=*pmarshalled_dataset;161 162 /*get enum type of Penta: */163 enum_type=PentaEnum;164 165 /*marshall enum: */166 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);167 168 /*marshall Penta data: */169 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);170 memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);171 memcpy(marshalled_dataset,&numanalyses,sizeof(numanalyses));marshalled_dataset+=sizeof(numanalyses);172 173 /*Mershall Ref: */174 for(i=0;i<numanalyses;i++){175 memcpy(marshalled_dataset,&element_type_list[i],sizeof(element_type_list[i]));marshalled_dataset+=sizeof(element_type_list[i]);176 }177 178 /*Marshall hooks: */179 for(i=0;i<numanalyses;i++){180 if(hnodes[i]){181 /*Set flag to 1 as there is a hook */182 flaghook=1;183 memcpy(marshalled_dataset,&flaghook,sizeof(flaghook));marshalled_dataset+=sizeof(flaghook);184 hnodes[i]->Marshall(&marshalled_dataset);185 }186 else{187 /*Set flag to 0 and do not marshall flag as there is no Hook */188 flaghook=0;189 memcpy(marshalled_dataset,&flaghook,sizeof(flaghook));marshalled_dataset+=sizeof(flaghook);190 }191 }192 hmatice->Marshall(&marshalled_dataset);193 hmatpar->Marshall(&marshalled_dataset);194 hneighbors->Marshall(&marshalled_dataset);195 196 /*Marshall inputs and results: */197 marshalled_inputs_size=inputs->MarshallSize();198 marshalled_inputs=inputs->Marshall();199 memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));200 marshalled_dataset+=marshalled_inputs_size;201 202 marshalled_results_size=results->MarshallSize();203 marshalled_results=results->Marshall();204 memcpy(marshalled_dataset,marshalled_results,marshalled_results_size*sizeof(char));205 marshalled_dataset+=marshalled_results_size;206 207 /*parameters: don't do anything about it. parameters are marshalled somewhere else!*/208 209 xfree((void**)&marshalled_inputs);210 xfree((void**)&marshalled_results);211 212 /*marshall horizontal neighbors: */213 memcpy(marshalled_dataset,horizontalneighborsids,3*sizeof(int));marshalled_dataset+=3*sizeof(int);214 215 *pmarshalled_dataset=marshalled_dataset;216 return;217 }218 /*}}}*/219 /*FUNCTION Penta::MarshallSize {{{1*/220 int Penta::MarshallSize(){221 222 int i;223 int hnodes_size=0;;224 225 for(i=0;i<numanalyses;i++){226 hnodes_size+=sizeof(int); //Flag 0 or 1227 if (hnodes[i]) hnodes_size+=hnodes[i]->MarshallSize();228 }229 230 return sizeof(id)231 +sizeof(sid)232 +hnodes_size233 +sizeof(numanalyses)234 +numanalyses*sizeof(int) //element_type_lists235 +hmatice->MarshallSize()236 +hmatpar->MarshallSize()237 +hneighbors->MarshallSize()238 +inputs->MarshallSize()239 +results->MarshallSize()240 +3*sizeof(int)241 +sizeof(int); //sizeof(int) for enum type242 }243 /*}}}*/244 /*FUNCTION Penta::Demarshall {{{1*/245 void Penta::Demarshall(char** pmarshalled_dataset){246 247 char* marshalled_dataset=NULL;248 int i;249 int flaghook;250 251 /*recover marshalled_dataset: */252 marshalled_dataset=*pmarshalled_dataset;253 254 /*this time, no need to get enum type, the pointer directly points to the beginning of the255 *object data (thanks to DataSet::Demarshall):*/256 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);257 memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);258 memcpy(&numanalyses,marshalled_dataset,sizeof(numanalyses));marshalled_dataset+=sizeof(numanalyses);259 260 /*demarshall Ref: */261 this->element_type_list=(int*)xmalloc(this->numanalyses*sizeof(int));262 for(i=0;i<numanalyses;i++){ memcpy(&element_type_list[i],marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);}263 264 /*allocate dynamic memory: */265 this->hnodes=new Hook*[this->numanalyses];266 /*demarshall hooks: */267 for(i=0;i<numanalyses;i++){268 memcpy(&flaghook,marshalled_dataset,sizeof(flaghook));marshalled_dataset+=sizeof(flaghook);269 if(flaghook){ // there is a hook so demarshall it270 hnodes[i]=new Hook();271 hnodes[i]->Demarshall(&marshalled_dataset);272 }273 else hnodes[i]=NULL; //There is no hook so it is NULL274 }275 hmatice=new Hook(); hmatice->Demarshall(&marshalled_dataset);276 hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);277 hneighbors=new Hook(); hneighbors->Demarshall(&marshalled_dataset);278 279 /*pointers are garbage, until configuration is carried out: */280 nodes=NULL;281 matice=NULL;282 matpar=NULL;283 verticalneighbors=NULL;284 285 /*demarshall inputs and results: */286 inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);287 results=(Results*)DataSetDemarshallRaw(&marshalled_dataset);288 289 /*parameters: may not exist even yet, so let Configure handle it: */290 this->parameters=NULL;291 292 /*neighbors: */293 memcpy(&this->horizontalneighborsids,marshalled_dataset,3*sizeof(int));marshalled_dataset+=3*sizeof(int);294 295 /*return: */296 *pmarshalled_dataset=marshalled_dataset;297 return;298 }299 /*}}}*/300 #endif301 144 302 145 /*Other*/ -
issm/trunk/src/c/objects/Elements/Penta.h
r11995 r12330 55 55 int ObjectEnum(); 56 56 int Id(); 57 #ifdef _SERIAL_58 void Marshall(char** pmarshalled_dataset);59 int MarshallSize();60 void Demarshall(char** pmarshalled_dataset);61 #endif62 57 int MyRank(); 63 58 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Tria.cpp
r12301 r12330 122 122 } 123 123 /*}}}*/ 124 125 /*Marshall*/126 #ifdef _SERIAL_127 /*FUNCTION Tria::Marshall {{{1*/128 void Tria::Marshall(char** pmarshalled_dataset){129 130 int i;131 char* marshalled_dataset=NULL;132 int enum_type=0;133 char* marshalled_inputs=NULL;134 int marshalled_inputs_size;135 char* marshalled_results=NULL;136 int marshalled_results_size;137 int flaghook; //to indicate if hook is NULL or exists138 139 /*recover marshalled_dataset: */140 marshalled_dataset=*pmarshalled_dataset;141 142 /*get enum type of Tria: */143 enum_type=TriaEnum;144 145 /*marshall enum: */146 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);147 148 /*marshall Tria data: */149 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);150 memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);151 memcpy(marshalled_dataset,&numanalyses,sizeof(numanalyses));marshalled_dataset+=sizeof(numanalyses);152 153 /*Mershall Ref: */154 for(i=0;i<numanalyses;i++){155 memcpy(marshalled_dataset,&element_type_list[i],sizeof(element_type_list[i]));marshalled_dataset+=sizeof(element_type_list[i]);156 }157 158 /*Marshall hooks: */159 for(i=0;i<numanalyses;i++){160 if(hnodes[i]){161 /*Set flag to 1 as there is a hook */162 flaghook=1;163 memcpy(marshalled_dataset,&flaghook,sizeof(flaghook));marshalled_dataset+=sizeof(flaghook);164 hnodes[i]->Marshall(&marshalled_dataset);165 }166 else{167 /*Set flag to 0 and do not marshall flag as there is no Hook */168 flaghook=0;169 memcpy(marshalled_dataset,&flaghook,sizeof(flaghook));marshalled_dataset+=sizeof(flaghook);170 }171 }172 hmatice->Marshall(&marshalled_dataset);173 hmatpar->Marshall(&marshalled_dataset);174 175 /*Marshall inputs: */176 marshalled_inputs_size=inputs->MarshallSize();177 marshalled_inputs=inputs->Marshall();178 memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));179 marshalled_dataset+=marshalled_inputs_size;180 181 /*Marshall results: */182 marshalled_results_size=results->MarshallSize();183 marshalled_results=results->Marshall();184 memcpy(marshalled_dataset,marshalled_results,marshalled_results_size*sizeof(char));185 marshalled_dataset+=marshalled_results_size;186 187 /*parameters: don't do anything about it. parameters are marshalled somewhere else!*/188 189 xfree((void**)&marshalled_inputs);190 xfree((void**)&marshalled_results);191 192 /*marshall horizontal neighbors: */193 memcpy(marshalled_dataset,horizontalneighborsids,3*sizeof(int));marshalled_dataset+=3*sizeof(int);194 195 *pmarshalled_dataset=marshalled_dataset;196 return;197 }198 /*}}}*/199 /*FUNCTION Tria::MarshallSize {{{1*/200 int Tria::MarshallSize(){201 202 int i;203 int hnodes_size=0;;204 205 for(i=0;i<numanalyses;i++){206 hnodes_size+=sizeof(int); //Flag 0 or 1207 if (hnodes[i]) hnodes_size+=hnodes[i]->MarshallSize();208 }209 210 return sizeof(id)211 +sizeof(sid)212 +hnodes_size213 +sizeof(numanalyses)214 +numanalyses*sizeof(int) //element_type_lists215 +hmatice->MarshallSize()216 +hmatpar->MarshallSize()217 +inputs->MarshallSize()218 +results->MarshallSize()219 +3*sizeof(int)220 +sizeof(int); //sizeof(int) for enum type221 }222 /*}}}*/223 /*FUNCTION Tria::Demarshall {{{1*/224 void Tria::Demarshall(char** pmarshalled_dataset){225 226 char* marshalled_dataset=NULL;227 int i;228 int flaghook;229 230 /*recover marshalled_dataset: */231 marshalled_dataset=*pmarshalled_dataset;232 233 /*this time, no need to get enum type, the pointer directly points to the beginning of the234 *object data (thanks to DataSet::Demarshall):*/235 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);236 memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);237 memcpy(&numanalyses,marshalled_dataset,sizeof(numanalyses));marshalled_dataset+=sizeof(numanalyses);238 239 /*demarshall Ref: */240 this->element_type_list=(int*)xmalloc(this->numanalyses*sizeof(int));241 for(i=0;i<numanalyses;i++){ memcpy(&element_type_list[i],marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);}242 243 /*allocate dynamic memory: */244 this->hnodes=new Hook*[this->numanalyses];245 /*demarshall hooks: */246 for(i=0;i<numanalyses;i++){247 memcpy(&flaghook,marshalled_dataset,sizeof(flaghook));marshalled_dataset+=sizeof(flaghook);248 if(flaghook){ // there is a hook so demarshall it249 hnodes[i]=new Hook();250 hnodes[i]->Demarshall(&marshalled_dataset);251 }252 else hnodes[i]=NULL; //There is no hook so it is NULL253 }254 hmatice=new Hook(); hmatice->Demarshall(&marshalled_dataset);255 hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);256 257 /*pointers are garbabe, until configuration is carried out: */258 nodes=NULL;259 matice=NULL;260 matpar=NULL;261 262 /*demarshall inputs: */263 inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);264 results=(Results*)DataSetDemarshallRaw(&marshalled_dataset);265 266 /*parameters: may not exist even yet, so let Configure handle it: */267 this->parameters=NULL;268 269 /*neighbors: */270 memcpy(&this->horizontalneighborsids,marshalled_dataset,3*sizeof(int));marshalled_dataset+=3*sizeof(int);271 272 /*return: */273 *pmarshalled_dataset=marshalled_dataset;274 return;275 }276 /*}}}*/277 #endif278 124 279 125 /*Other*/ … … 783 629 basal_melting_input->GetInputValue(&basal_melting_g,gauss); 784 630 thickness_input->GetInputValue(&thickness_g,gauss); 785 if(basal_melting_correction_input) basal_melting_correction_input->GetInputValue(&basal_melting_correction_g,gauss); 631 if(basal_melting_correction_input) 632 basal_melting_correction_input->GetInputValue(&basal_melting_correction_g,gauss); 633 else 634 basal_melting_correction_g=0.; 786 635 787 636 for(i=0;i<numdof;i++) pe->values[i]+=Jdettria*gauss->weight*(thickness_g+dt*(surface_mass_balance_g-basal_melting_g-basal_melting_correction_g))*L[i]; -
issm/trunk/src/c/objects/Elements/Tria.h
r11995 r12330 51 51 int Id(); 52 52 int MyRank(); 53 #ifdef _SERIAL_54 void Marshall(char** pmarshalled_dataset);55 int MarshallSize();56 void Demarshall(char** pmarshalled_dataset);57 #endif58 53 int ObjectEnum(); 59 54 Object* copy(); -
issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.cpp
r11995 r12330 68 68 } 69 69 /*}}}*/ 70 #ifdef _SERIAL_71 /*FUNCTION BoolExternalResult::Marshall{{{1*/72 void BoolExternalResult::Marshall(char** pmarshalled_dataset){73 74 char* marshalled_dataset=NULL;75 int enum_value=0;76 77 /*recover marshalled_dataset: */78 marshalled_dataset=*pmarshalled_dataset;79 80 /*get enum value of BoolExternalResult: */81 enum_value=BoolExternalResultEnum;82 83 /*marshall enum: */84 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);85 86 /*marshall BoolExternalResult data: */87 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);88 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);89 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);90 memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);91 memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);92 93 *pmarshalled_dataset=marshalled_dataset;94 }95 /*}}}*/96 /*FUNCTION BoolExternalResult::MarshallSize{{{1*/97 int BoolExternalResult::MarshallSize(){98 99 return sizeof(value)+100 +sizeof(id)101 +sizeof(enum_type)102 +sizeof(step)103 +sizeof(time)104 +sizeof(int); //sizeof(int) for enum value105 }106 /*}}}*/107 /*FUNCTION BoolExternalResult::Demarshall{{{1*/108 void BoolExternalResult::Demarshall(char** pmarshalled_dataset){109 110 char* marshalled_dataset=NULL;111 int i;112 113 /*recover marshalled_dataset: */114 marshalled_dataset=*pmarshalled_dataset;115 116 /*this time, no need to get enum type, the pointer directly points to the beginning of the117 *object data (thanks to DataSet::Demarshall):*/118 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);119 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);120 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);121 memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);122 memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);123 124 /*return: */125 *pmarshalled_dataset=marshalled_dataset;126 return;127 }128 /*}}}*/129 #endif130 70 /*FUNCTION BoolExternalResult::ObjectEnum{{{1*/ 131 71 int BoolExternalResult::ObjectEnum(void){ … … 185 125 } 186 126 /*}}}*/ 187 /*FUNCTION BoolExternalResult::SetMatlabField{{{1*/188 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)189 void BoolExternalResult::SetMatlabField(mxArray* dataref){190 191 char* name=NULL;192 this->GetResultName(&name);193 194 mxSetField( dataref, this->step-1, name,mxCreateDoubleScalar((double)value));195 mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time));196 mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step));197 }198 #endif199 /*}}}*/200 127 /*FUNCTION BoolExternalResult::GetStep{{{1*/ 201 128 int BoolExternalResult::GetStep(void){ -
issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.h
r11995 r12330 15 15 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 16 16 #endif 17 18 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)19 #include <mex.h>20 #endif21 22 17 23 18 #include "./ExternalResult.h" … … 47 42 int Id(); 48 43 int MyRank(); 49 #ifdef _SERIAL_50 void Marshall(char** pmarshalled_dataset);51 int MarshallSize();52 void Demarshall(char** pmarshalled_dataset);53 #endif54 44 int ObjectEnum(); 55 45 Object* copy(); … … 59 49 void WriteData(FILE* fid,bool io_gather); 60 50 void GetResultName(char**); 61 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)62 void SetMatlabField(mxArray* dataref);63 #endif64 51 int GetStep(void); 65 52 /*}}}*/ 66 53 }; 67 #endif /* _BOOLEXTERNALRESULT_H */54 #endif -
issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.cpp
r11995 r12330 68 68 } 69 69 /*}}}*/ 70 #ifdef _SERIAL_71 /*FUNCTION DoubleExternalResult::Marshall{{{1*/72 void DoubleExternalResult::Marshall(char** pmarshalled_dataset){73 74 char* marshalled_dataset=NULL;75 int enum_value=0;76 77 /*recover marshalled_dataset: */78 marshalled_dataset=*pmarshalled_dataset;79 80 /*get enum value of DoubleExternalResult: */81 enum_value=DoubleExternalResultEnum;82 83 /*marshall enum: */84 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);85 86 /*marshall DoubleExternalResult data: */87 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);88 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);89 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);90 memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);91 memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);92 93 *pmarshalled_dataset=marshalled_dataset;94 }95 /*}}}*/96 /*FUNCTION DoubleExternalResult::MarshallSize{{{1*/97 int DoubleExternalResult::MarshallSize(){98 99 return sizeof(value)+100 +sizeof(id)101 +sizeof(enum_type)102 +sizeof(step)103 +sizeof(time)104 +sizeof(int); //sizeof(int) for enum value105 }106 /*}}}*/107 /*FUNCTION DoubleExternalResult::Demarshall{{{1*/108 void DoubleExternalResult::Demarshall(char** pmarshalled_dataset){109 110 char* marshalled_dataset=NULL;111 int i;112 113 /*recover marshalled_dataset: */114 marshalled_dataset=*pmarshalled_dataset;115 116 /*this time, no need to get enum type, the pointer directly points to the beginning of the117 *object data (thanks to DataSet::Demarshall):*/118 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);119 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);120 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);121 memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);122 memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);123 124 /*return: */125 *pmarshalled_dataset=marshalled_dataset;126 return;127 }128 /*}}}*/129 #endif130 70 /*FUNCTION DoubleExternalResult::ObjectEnum{{{1*/ 131 71 int DoubleExternalResult::ObjectEnum(void){ … … 181 121 } 182 122 /*}}}*/ 183 /*FUNCTION DoubleExternalResult::SetMatlabField{{{1*/184 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)185 void DoubleExternalResult::SetMatlabField(mxArray* dataref){186 187 char* name=NULL;188 this->GetResultName(&name);189 mxSetField( dataref,this->step-1, name,mxCreateDoubleScalar(value));190 mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time));191 mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step));192 193 }194 #endif195 /*}}}*/196 123 /*FUNCTION DoubleExternalResult::GetStep{{{1*/ 197 124 int DoubleExternalResult::GetStep(void){ -
issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.h
r11995 r12330 14 14 #else 15 15 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 16 #endif17 18 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)19 #include <mex.h>20 16 #endif 21 17 … … 48 44 int Id(); 49 45 int MyRank(); 50 #ifdef _SERIAL_51 void Marshall(char** pmarshalled_dataset);52 int MarshallSize();53 void Demarshall(char** pmarshalled_dataset);54 #endif55 46 int ObjectEnum(); 56 47 Object* copy(); … … 60 51 void WriteData(FILE* fid,bool io_gather); 61 52 void GetResultName(char**); 62 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)63 void SetMatlabField(mxArray* dataref);64 #endif65 53 int GetStep(void); 66 54 /*}}}*/ -
issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.cpp
r11995 r12330 96 96 } 97 97 /*}}}*/ 98 #ifdef _SERIAL_99 /*FUNCTION DoubleMatExternalResult::Marshall{{{1*/100 void DoubleMatExternalResult::Marshall(char** pmarshalled_dataset){101 102 char* marshalled_dataset=NULL;103 int enum_value=0;104 105 /*recover marshalled_dataset: */106 marshalled_dataset=*pmarshalled_dataset;107 108 /*get enum value of DoubleMatExternalResult: */109 enum_value=DoubleMatExternalResultEnum;110 111 /*marshall enum: */112 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);113 114 /*marshall DoubleMatExternalResult data: */115 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);116 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);117 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);118 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);119 memcpy(marshalled_dataset,values,M*sizeof(double));marshalled_dataset+=M*sizeof(double);120 memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);121 memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);122 123 *pmarshalled_dataset=marshalled_dataset;124 }125 /*}}}*/126 /*FUNCTION DoubleMatExternalResult::MarshallSize{{{1*/127 int DoubleMatExternalResult::MarshallSize(){128 129 return sizeof(M)130 +sizeof(N)131 +M*N*sizeof(double)132 +sizeof(id)133 +sizeof(enum_type)134 +sizeof(step)135 +sizeof(time)136 +sizeof(int); //sizeof(int) for enum value137 }138 /*}}}*/139 /*FUNCTION DoubleMatExternalResult::Demarshall{{{1*/140 void DoubleMatExternalResult::Demarshall(char** pmarshalled_dataset){141 142 char* marshalled_dataset=NULL;143 int i;144 145 /*recover marshalled_dataset: */146 marshalled_dataset=*pmarshalled_dataset;147 148 /*this time, no need to get enum type, the pointer directly points to the beginning of the149 *object data (thanks to DataSet::Demarshall):*/150 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);151 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);152 153 /*data: */154 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);155 memcpy(&N,marshalled_dataset,sizeof(N));marshalled_dataset+=sizeof(N);156 values=(double*)xmalloc(M*N*sizeof(double));157 memcpy(values,marshalled_dataset,M*N*sizeof(double));marshalled_dataset+=M*N*sizeof(double);158 memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);159 memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);160 161 /*return: */162 *pmarshalled_dataset=marshalled_dataset;163 return;164 }165 /*}}}*/166 #endif167 98 /*FUNCTION DoubleMatExternalResult::ObjectEnum{{{1*/ 168 99 int DoubleMatExternalResult::ObjectEnum(void){ … … 222 153 } 223 154 /*}}}*/ 224 /*FUNCTION DoubleMatExternalResult::SetMatlabField{{{1*/225 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)226 void DoubleMatExternalResult::SetMatlabField(mxArray* dataref){227 228 mxArray* pfield=NULL;229 mxArray* pfield2=NULL;230 char* name=NULL;231 double* doublemat=NULL;232 233 /*Make a copy of the value, to be used by matlab: */234 doublemat=(double*)xmalloc(M*N*sizeof(double));235 memcpy(doublemat,values,M*N*sizeof(double));236 237 /*recover name: */238 this->GetResultName(&name);239 240 /*create matlab matrix: */241 pfield=mxCreateDoubleMatrix(0,0,mxREAL);242 mxSetM(pfield,N);243 mxSetN(pfield,M);244 mxSetPr(pfield,doublemat);245 246 /*transpose the matrix, from c to matlab format */247 mexCallMATLAB(1,&pfield2, 1, &pfield, "transpose");248 249 /*set tranpose matrix inside the dataref structure: */250 mxSetField( dataref, this->step-1, name,pfield2);251 mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time));252 mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step));253 254 }255 #endif256 /*}}}*/257 155 /*FUNCTION DoubleMatExternalResult::GetStep{{{1*/ 258 156 int DoubleMatExternalResult::GetStep(void){ -
issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.h
r11995 r12330 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 15 #endif 16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 #endif20 21 16 22 17 #include "./ExternalResult.h" … … 49 44 int Id(); 50 45 int MyRank(); 51 #ifdef _SERIAL_52 void Marshall(char** pmarshalled_dataset);53 int MarshallSize();54 void Demarshall(char** pmarshalled_dataset);55 #endif56 46 int ObjectEnum(); 57 47 Object* copy(); … … 61 51 void WriteData(FILE* fid,bool io_gather); 62 52 void GetResultName(char**); 63 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)64 void SetMatlabField(mxArray* dataref);65 #endif66 53 int GetStep(void); 67 54 /*}}}*/ -
issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.cpp
r11995 r12330 87 87 } 88 88 /*}}}*/ 89 #ifdef _SERIAL_90 /*FUNCTION DoubleVecExternalResult::Marshall{{{1*/91 void DoubleVecExternalResult::Marshall(char** pmarshalled_dataset){92 93 char* marshalled_dataset=NULL;94 int enum_value=0;95 96 /*recover marshalled_dataset: */97 marshalled_dataset=*pmarshalled_dataset;98 99 /*get enum value of DoubleVecExternalResult: */100 enum_value=DoubleVecExternalResultEnum;101 102 /*marshall enum: */103 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);104 105 /*marshall DoubleVecExternalResult data: */106 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);107 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);108 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);109 memcpy(marshalled_dataset,values,M*sizeof(double));marshalled_dataset+=M*sizeof(double);110 memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);111 memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);112 113 *pmarshalled_dataset=marshalled_dataset;114 }115 /*}}}*/116 /*FUNCTION DoubleVecExternalResult::MarshallSize{{{1*/117 int DoubleVecExternalResult::MarshallSize(){118 119 return sizeof(M)120 +M*sizeof(double)121 +sizeof(id)122 +sizeof(enum_type)123 +sizeof(step)124 +sizeof(time)125 +sizeof(int); //sizeof(int) for enum value126 }127 /*}}}*/128 /*FUNCTION DoubleVecExternalResult::Demarshall{{{1*/129 void DoubleVecExternalResult::Demarshall(char** pmarshalled_dataset){130 131 char* marshalled_dataset=NULL;132 int i;133 134 /*recover marshalled_dataset: */135 marshalled_dataset=*pmarshalled_dataset;136 137 /*this time, no need to get enum type, the pointer directly points to the beginning of the138 *object data (thanks to DataSet::Demarshall):*/139 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);140 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);141 142 /*data: */143 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);144 values=(double*)xmalloc(M*sizeof(double));145 memcpy(values,marshalled_dataset,M*sizeof(double));marshalled_dataset+=M*sizeof(double);146 memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);147 memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);148 149 /*return: */150 *pmarshalled_dataset=marshalled_dataset;151 return;152 }153 /*}}}*/154 #endif155 89 /*FUNCTION DoubleVecExternalResult::ObjectEnum{{{1*/ 156 90 int DoubleVecExternalResult::ObjectEnum(void){ … … 206 140 } 207 141 /*}}}*/ 208 /*FUNCTION DoubleVecExternalResult::SetMatlabField{{{1*/209 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)210 void DoubleVecExternalResult::SetMatlabField(mxArray* dataref){211 212 mxArray *pfield = NULL;213 double *doublemat = NULL;214 char *name = NULL;215 double *doublevec = NULL;216 217 /*Make a copy of the value, to be used by matlab: */218 doublevec=(double*)xmalloc(M*sizeof(double));219 memcpy(doublevec,values,M*sizeof(double));220 221 /*recover name: */222 this->GetResultName(&name);223 224 /*create matlab matrix: */225 pfield=mxCreateDoubleMatrix(0,0,mxREAL);226 mxSetM(pfield,M);227 mxSetN(pfield,1);228 mxSetPr(pfield,doublevec);229 230 mxSetField( dataref, this->step-1, name,pfield);231 mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time));232 mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step));233 }234 #endif235 /*}}}*/236 142 /*FUNCTION DoubleVecExternalResult::GetStep{{{1*/ 237 143 int DoubleVecExternalResult::GetStep(void){ -
issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.h
r11995 r12330 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 15 #endif 16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 #endif20 21 16 22 17 #include "./ExternalResult.h" … … 48 43 int Id(); 49 44 int MyRank(); 50 #ifdef _SERIAL_51 void Marshall(char** pmarshalled_dataset);52 int MarshallSize();53 void Demarshall(char** pmarshalled_dataset);54 #endif55 45 int ObjectEnum(); 56 46 Object* copy(); … … 60 50 void WriteData(FILE* fid,bool io_gather); 61 51 void GetResultName(char**); 62 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)63 void SetMatlabField(mxArray* dataref);64 #endif65 52 int GetStep(void); 66 53 /*}}}*/ -
issm/trunk/src/c/objects/ExternalResults/ExternalResult.h
r11995 r12330 16 16 #endif 17 17 18 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)19 #include <mex.h>20 #endif21 22 18 #include "../Object.h" 23 19 #include "../Node.h" … … 33 29 virtual void WriteData(FILE* fid,bool io_gather)=0; 34 30 virtual void GetResultName(char**)=0; 35 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)36 virtual void SetMatlabField(mxArray* dataref)=0;37 #endif38 31 virtual int GetStep(void)=0; 39 32 /*}}}*/ -
issm/trunk/src/c/objects/ExternalResults/IntExternalResult.cpp
r11995 r12330 68 68 } 69 69 /*}}}*/ 70 #ifdef _SERIAL_71 /*FUNCTION IntExternalResult::Marshall{{{1*/72 void IntExternalResult::Marshall(char** pmarshalled_dataset){73 74 char* marshalled_dataset=NULL;75 int enum_value=0;76 77 /*recover marshalled_dataset: */78 marshalled_dataset=*pmarshalled_dataset;79 80 /*get enum value of IntExternalResult: */81 enum_value=IntExternalResultEnum;82 83 /*marshall enum: */84 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);85 86 /*marshall IntExternalResult data: */87 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);88 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);89 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);90 memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);91 memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);92 93 *pmarshalled_dataset=marshalled_dataset;94 }95 /*}}}*/96 /*FUNCTION IntExternalResult::MarshallSize{{{1*/97 int IntExternalResult::MarshallSize(){98 99 return sizeof(value)+100 +sizeof(id)101 +sizeof(enum_type)102 +sizeof(step)103 +sizeof(time)104 +sizeof(int); //sizeof(int) for enum value105 }106 /*}}}*/107 /*FUNCTION IntExternalResult::Demarshall{{{1*/108 void IntExternalResult::Demarshall(char** pmarshalled_dataset){109 110 char* marshalled_dataset=NULL;111 int i;112 113 /*recover marshalled_dataset: */114 marshalled_dataset=*pmarshalled_dataset;115 116 /*this time, no need to get enum type, the pointer directly points to the beginning of the117 *object data (thanks to DataSet::Demarshall):*/118 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);119 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);120 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);121 memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);122 memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);123 124 /*return: */125 *pmarshalled_dataset=marshalled_dataset;126 return;127 }128 /*}}}*/129 #endif130 70 /*FUNCTION IntExternalResult::ObjectEnum{{{1*/ 131 71 int IntExternalResult::ObjectEnum(void){ … … 185 125 } 186 126 /*}}}*/ 187 /*FUNCTION IntExternalResult::SetMatlabField{{{1*/188 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)189 void IntExternalResult::SetMatlabField(mxArray* dataref){190 191 char* name=NULL;192 this->GetResultName(&name);193 194 mxSetField( dataref, this->step-1, name,mxCreateDoubleScalar(value));195 mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time));196 mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step));197 198 }199 #endif200 /*}}}*/201 127 /*FUNCTION IntExternalResult::GetStep{{{1*/ 202 128 int IntExternalResult::GetStep(void){ -
issm/trunk/src/c/objects/ExternalResults/IntExternalResult.h
r11995 r12330 14 14 #else 15 15 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 16 #endif17 18 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)19 #include <mex.h>20 16 #endif 21 17 … … 46 42 int Id(); 47 43 int MyRank(); 48 #ifdef _SERIAL_49 void Marshall(char** pmarshalled_dataset);50 int MarshallSize();51 void Demarshall(char** pmarshalled_dataset);52 #endif53 44 int ObjectEnum(); 54 45 Object* copy(); … … 58 49 void WriteData(FILE* fid,bool io_gather); 59 50 void GetResultName(char**); 60 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)61 void SetMatlabField(mxArray* dataref);62 #endif63 51 int GetStep(void); 64 52 /*}}}*/ -
issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.cpp
r11995 r12330 80 80 } 81 81 /*}}}*/ 82 #ifdef _SERIAL_83 /*FUNCTION PetscVecExternalResult::Marshall{{{1*/84 void PetscVecExternalResult::Marshall(char** pmarshalled_dataset){85 86 char* marshalled_dataset=NULL;87 int enum_value=0;88 int M;89 double* serial_value=NULL;90 91 /*recover marshalled_dataset: */92 marshalled_dataset=*pmarshalled_dataset;93 94 /*get enum value of PetscVecExternalResult: */95 enum_value=PetscVecExternalResultEnum;96 97 /*marshall enum: */98 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);99 100 /*marshall PetscVecExternalResult data: */101 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);102 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);103 memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);104 memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);105 106 if(value){107 VecGetSize(value,&M);108 VecToMPISerial(&serial_value,value);109 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);110 memcpy(marshalled_dataset,serial_value,M*sizeof(double));marshalled_dataset+=(M*sizeof(double));111 }112 else{113 M=0;114 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);115 }116 /*Free ressources:*/117 xfree((void**)&serial_value);118 119 /*return:*/120 *pmarshalled_dataset=marshalled_dataset;121 }122 /*}}}*/123 /*FUNCTION PetscVecExternalResult::MarshallSize{{{1*/124 int PetscVecExternalResult::MarshallSize(){125 126 int M=0;127 if(value)VecGetSize(value,&M);128 129 return sizeof(M)+M*sizeof(double)130 +sizeof(id)131 +sizeof(enum_type)132 +sizeof(step)133 +sizeof(time)134 +sizeof(int); //sizeof(int) for enum value135 }136 /*}}}*/137 /*FUNCTION PetscVecExternalResult::Demarshall{{{1*/138 void PetscVecExternalResult::Demarshall(char** pmarshalled_dataset){139 140 char* marshalled_dataset=NULL;141 int i;142 int M;143 double* serial_vec=NULL;144 int* idxm=NULL;145 146 /*recover marshalled_dataset: */147 marshalled_dataset=*pmarshalled_dataset;148 149 /*this time, no need to get enum type, the pointer directly points to the beginning of the150 *object data (thanks to DataSet::Demarshall):*/151 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);152 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);153 154 /*data: */155 memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);156 memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);157 158 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);159 if(M){160 serial_vec=(double*)xmalloc(M*sizeof(double));161 memcpy(serial_vec,marshalled_dataset,M*sizeof(double));marshalled_dataset+=(M*sizeof(double));162 163 value=NewVec(M);164 idxm=(int*)xmalloc(M*sizeof(int));165 for(i=0;i<M;i++)idxm[i]=i;166 VecSetValues(value,M,idxm,serial_vec,INSERT_VALUES);167 168 VecAssemblyBegin(value);169 VecAssemblyEnd(value);170 171 172 }173 else{174 value=NULL;175 }176 177 /*Free ressources:*/178 xfree((void**)&serial_vec);179 xfree((void**)&idxm);180 181 /*return: */182 *pmarshalled_dataset=marshalled_dataset;183 }184 /*}}}*/185 #endif186 82 /*FUNCTION PetscVecExternalResult::ObjectEnum{{{1*/ 187 83 int PetscVecExternalResult::ObjectEnum(void){ … … 244 140 } 245 141 /*}}}*/ 246 /*FUNCTION PetscVecExternalResult::SetMatlabField{{{1*/247 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)248 void PetscVecExternalResult::SetMatlabField(mxArray* dataref){249 250 mxArray* pfield=NULL;251 char* name=NULL;252 double* doublevec=NULL;253 int M;254 255 VecToMPISerial(&doublevec,value);256 VecGetSize(value,&M);257 this->GetResultName(&name);258 259 pfield=mxCreateDoubleMatrix(0,0,mxREAL);260 mxSetM(pfield,M);261 mxSetN(pfield,1);262 mxSetPr(pfield,doublevec);263 264 mxSetField( dataref, this->step-1, name, pfield);265 mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time));266 mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step));267 268 }269 #endif270 /*}}}*/271 142 /*FUNCTION PetscVecExternalResult::GetStep{{{1*/ 272 143 int PetscVecExternalResult::GetStep(void){ -
issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.h
r11995 r12330 15 15 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 16 16 #endif 17 18 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)19 #include <mex.h>20 #endif21 22 17 23 18 #include "./ExternalResult.h" … … 48 43 int Id(); 49 44 int MyRank(); 50 #ifdef _SERIAL_51 void Marshall(char** pmarshalled_dataset);52 int MarshallSize();53 void Demarshall(char** pmarshalled_dataset);54 #endif55 45 int ObjectEnum(); 56 46 Object* copy(); … … 60 50 void WriteData(FILE* fid,bool io_gather); 61 51 void GetResultName(char**); 62 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)63 void SetMatlabField(mxArray* dataref);64 #endif65 52 int GetStep(void); 66 53 /*}}}*/ -
issm/trunk/src/c/objects/ExternalResults/StringExternalResult.cpp
r11995 r12330 71 71 } 72 72 /*}}}*/ 73 #ifdef _SERIAL_74 /*FUNCTION StringExternalResult::Marshall{{{1*/75 void StringExternalResult::Marshall(char** pmarshalled_dataset){76 77 char* marshalled_dataset=NULL;78 int enum_value=0;79 int stringsize;80 81 /*recover marshalled_dataset: */82 marshalled_dataset=*pmarshalled_dataset;83 84 /*get enum value of StringExternalResult: */85 enum_value=StringExternalResultEnum;86 87 /*marshall enum: */88 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);89 90 /*marshall data: */91 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);92 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);93 stringsize=strlen(this->value)+1;94 95 memcpy(marshalled_dataset,&stringsize,sizeof(stringsize));marshalled_dataset+=sizeof(stringsize);96 memcpy(marshalled_dataset,this->value,stringsize*sizeof(char));marshalled_dataset+=stringsize*sizeof(char);97 memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);98 memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);99 100 *pmarshalled_dataset=marshalled_dataset;101 }102 /*}}}*/103 /*FUNCTION StringExternalResult::MarshallSize{{{1*/104 int StringExternalResult::MarshallSize(){105 106 int stringsize;107 stringsize=strlen(this->value)+1;108 109 return sizeof(int)+110 +stringsize*sizeof(char)111 +sizeof(id)112 +sizeof(enum_type)113 +sizeof(step)114 +sizeof(time)115 +sizeof(int); //sizeof(int) for enum value116 }117 /*}}}*/118 /*FUNCTION StringExternalResult::Demarshall{{{1*/119 void StringExternalResult::Demarshall(char** pmarshalled_dataset){120 121 char* marshalled_dataset=NULL;122 int i;123 int stringsize;124 125 /*recover marshalled_dataset: */126 marshalled_dataset=*pmarshalled_dataset;127 128 /*this time, no need to get enum type, the pointer directly points to the beginning of the129 *object data (thanks to DataSet::Demarshall):*/130 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);131 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);132 133 memcpy(&stringsize,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);134 135 this->value=(char*)xmalloc(stringsize*sizeof(char));136 memcpy(value,marshalled_dataset,stringsize*sizeof(char));marshalled_dataset+=stringsize*sizeof(char);137 memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);138 memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);139 140 /*return: */141 *pmarshalled_dataset=marshalled_dataset;142 return;143 }144 /*}}}*/145 #endif146 73 /*FUNCTION StringExternalResult::ObjectEnum{{{1*/ 147 74 int StringExternalResult::ObjectEnum(void){ … … 197 124 } 198 125 /*}}}*/ 199 /*FUNCTION StringExternalResult::SetMatlabField{{{1*/200 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)201 void StringExternalResult::SetMatlabField(mxArray* dataref){202 203 char* name=NULL;204 205 this->GetResultName(&name);206 207 mxSetField( dataref, this->step-1, name, mxCreateString(value));208 mxSetField( dataref, this->step-1, "time",mxCreateDoubleScalar((double)this->time));209 mxSetField( dataref, this->step-1, "step",mxCreateDoubleScalar((double)this->step));210 211 }212 #endif213 /*}}}*/214 126 /*FUNCTION StringExternalResult::GetStep{{{1*/ 215 127 int StringExternalResult::GetStep(void){ -
issm/trunk/src/c/objects/ExternalResults/StringExternalResult.h
r11995 r12330 15 15 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 16 16 #endif 17 18 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)19 #include <mex.h>20 #endif21 22 17 23 18 #include "./ExternalResult.h" … … 48 43 int Id(); 49 44 int MyRank(); 50 #ifdef _SERIAL_51 void Marshall(char** pmarshalled_dataset);52 int MarshallSize();53 void Demarshall(char** pmarshalled_dataset);54 #endif55 45 int ObjectEnum(); 56 46 Object* copy(); … … 60 50 void WriteData(FILE* fid,bool io_gather); 61 51 void GetResultName(char**); 62 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)63 void SetMatlabField(mxArray* dataref);64 #endif65 52 int GetStep(void); 66 53 /*}}}*/ -
issm/trunk/src/c/objects/FemModel.cpp
r11995 r12330 22 22 /*FUNCTION FemModel::constructor {{{1*/ 23 23 FemModel::FemModel(char* inputfilename, char* outputfilename, const int in_solution_type,const int* analyses,const int nummodels){ 24 #ifdef _PARALLEL_25 24 26 25 /*intermediary*/ … … 75 74 /*Add output file name to parameters: */ 76 75 this->parameters->AddObject(new StringParam(OutputfilenameEnum,outputfilename)); 77 78 #endif79 76 80 77 } -
issm/trunk/src/c/objects/Hook.cpp
r9777 r12330 118 118 } 119 119 /*}}}*/ 120 #ifdef _SERIAL_121 /*FUNCTION Hook::Marshall{{{1*/122 void Hook::Marshall(char** pmarshalled_dataset){123 124 char* marshalled_dataset=NULL;125 int enum_type=0;126 int i;127 128 /*recover marshalled_dataset: */129 marshalled_dataset=*pmarshalled_dataset;130 131 /*get enum type of Hook: */132 enum_type=HookEnum;133 134 /*marshall enum: */135 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);136 137 /*marshall Hook data: */138 memcpy(marshalled_dataset,&num,sizeof(num));marshalled_dataset+=sizeof(num);139 for(i=0;i<num;i++){140 memcpy(marshalled_dataset,&this->ids[i],sizeof(int));marshalled_dataset+=sizeof(int);141 memcpy(marshalled_dataset,&this->offsets[i],sizeof(int));marshalled_dataset+=sizeof(int);142 }143 144 *pmarshalled_dataset=marshalled_dataset;145 return;146 }147 /*}}}*/148 /*FUNCTION Hook::MarshallSize{{{1*/149 int Hook::MarshallSize(){150 151 return152 sizeof(num)+153 num*sizeof(int)+154 num*sizeof(int)+155 sizeof(int); //sizeof(int) for enum type156 }157 /*}}}*/158 /*FUNCTION Hook::Demarshall{{{1*/159 void Hook::Demarshall(char** pmarshalled_dataset){160 161 char* marshalled_dataset=NULL;162 int i;163 int enum_type;164 165 /*recover marshalled_dataset: */166 marshalled_dataset=*pmarshalled_dataset;167 168 /*get enum type of object since Hook is not directly called by DataSet: */169 memcpy(&enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);170 171 memcpy(&num,marshalled_dataset,sizeof(num));marshalled_dataset+=sizeof(num);172 173 /*allocate: */174 if (num<0){175 _error_("cannot demarshall Hook as num<=0");176 }177 else if (num==0){178 this->ids=NULL;179 this->offsets=NULL;180 this->objects=NULL;181 }182 else{183 184 this->ids=(int*)xmalloc(num*sizeof(int));185 this->offsets=(int*)xmalloc(num*sizeof(int));186 187 /*demarshall allocated ids and offsets: */188 _assert_(num<1000);189 for (i=0;i<num;i++){190 memcpy(&this->ids[i],marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);191 memcpy(&this->offsets[i],marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);192 }193 194 /*nullify object pointers */195 this->objects=(Object**)xmalloc(num*sizeof(Object*));196 for (i=0;i<num;i++){197 this->objects[i]=NULL;198 }199 }200 201 /*return: */202 *pmarshalled_dataset=marshalled_dataset;203 return;204 }205 /*}}}*/206 #endif207 120 /*FUNCTION Hook::copy {{{1*/ 208 121 Object* Hook::copy(void){ -
issm/trunk/src/c/objects/Hook.h
r9777 r12330 34 34 void Echo(void); 35 35 void DeepEcho(void); 36 #ifdef _SERIAL_37 void Marshall(char** pmarshalled_dataset);38 int MarshallSize();39 void Demarshall(char** pmarshalled_dataset);40 #endif41 36 Object* copy(void); 42 37 /*}}}*/ -
issm/trunk/src/c/objects/Inputs/BoolInput.cpp
r11995 r12330 59 59 } 60 60 /*}}}*/ 61 #ifdef _SERIAL_62 /*FUNCTION BoolInput::Marshall{{{1*/63 void BoolInput::Marshall(char** pmarshalled_dataset){64 65 char* marshalled_dataset=NULL;66 int enum_value=0;67 68 /*recover marshalled_dataset: */69 marshalled_dataset=*pmarshalled_dataset;70 71 /*get enum value of BoolInput: */72 enum_value=BoolInputEnum;73 74 /*marshall enum: */75 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);76 77 /*marshall BoolInput data: */78 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);79 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);80 81 *pmarshalled_dataset=marshalled_dataset;82 }83 /*}}}*/84 /*FUNCTION BoolInput::MarshallSize{{{1*/85 int BoolInput::MarshallSize(){86 87 return sizeof(value)+88 +sizeof(enum_type)+89 +sizeof(int); //sizeof(int) for enum value90 }91 /*}}}*/92 /*FUNCTION BoolInput::Demarshall{{{1*/93 void BoolInput::Demarshall(char** pmarshalled_dataset){94 95 char* marshalled_dataset=NULL;96 int i;97 98 /*recover marshalled_dataset: */99 marshalled_dataset=*pmarshalled_dataset;100 101 /*this time, no need to get enum type, the pointer directly points to the beginning of the102 *object data (thanks to DataSet::Demarshall):*/103 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);104 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);105 106 /*return: */107 *pmarshalled_dataset=marshalled_dataset;108 return;109 }110 /*}}}*/111 #endif112 61 /*FUNCTION BoolInput::ObjectEnum{{{1*/ 113 62 int BoolInput::ObjectEnum(void){ -
issm/trunk/src/c/objects/Inputs/BoolInput.h
r12299 r12330 31 31 int Id(); 32 32 int MyRank(); 33 #ifdef _SERIAL_34 void Marshall(char** pmarshalled_dataset);35 int MarshallSize();36 void Demarshall(char** pmarshalled_dataset);37 #endif38 33 int ObjectEnum(); 39 34 Object* copy(); -
issm/trunk/src/c/objects/Inputs/ControlInput.cpp
r11995 r12330 90 90 } 91 91 /*}}}*/ 92 #ifdef _SERIAL_93 /*FUNCTION ControlInput::Marshall{{{1*/94 void ControlInput::Marshall(char** pmarshalled_dataset){95 96 char* marshalled_dataset=NULL;97 int enum_value=0;98 int flag;99 100 /*recover marshalled_dataset: */101 marshalled_dataset=*pmarshalled_dataset;102 103 /*get enum value of ControlInput: */104 enum_value=ControlInputEnum;105 106 /*marshall enum: */107 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);108 109 /*marshall enum_type: */110 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);111 memcpy(marshalled_dataset,&control_id,sizeof(control_id));marshalled_dataset+=sizeof(control_id);112 113 /*marshal values*/114 if(!values){115 flag=0;116 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);117 }118 else{119 flag=1;120 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);121 this->values->Marshall(&marshalled_dataset);122 }123 124 /*marshal savedvalues*/125 if(!savedvalues){126 flag=0;127 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);128 }129 else{130 flag=1;131 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);132 this->savedvalues->Marshall(&marshalled_dataset);133 }134 135 /*marshal minvalues*/136 if(!minvalues){137 flag=0;138 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);139 }140 else{141 flag=1;142 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);143 this->minvalues->Marshall(&marshalled_dataset);144 }145 146 /*marshal maxvalues*/147 if(!maxvalues){148 flag=0;149 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);150 }151 else{152 flag=1;153 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);154 this->maxvalues->Marshall(&marshalled_dataset);155 }156 157 /*marshal gradient*/158 if(!gradient){159 flag=0;160 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);161 }162 else{163 flag=1;164 memcpy(marshalled_dataset,&flag,sizeof(flag));marshalled_dataset+=sizeof(flag);165 this->gradient->Marshall(&marshalled_dataset);166 }167 168 /*clean up and assign output pointer*/169 *pmarshalled_dataset=marshalled_dataset;170 }171 /*}}}*/172 /*FUNCTION ControlInput::MarshallSize{{{1*/173 int ControlInput::MarshallSize(){174 175 int size=0;176 177 size=sizeof(enum_type)+178 +sizeof(control_id)179 +5*sizeof(int) //5 flags180 +sizeof(int); //sizeof(int) for enum value181 182 if(values) size+=values->MarshallSize();183 if(savedvalues)size+=savedvalues->MarshallSize();184 if(minvalues)size+=minvalues->MarshallSize();185 if(maxvalues)size+=maxvalues->MarshallSize();186 if(gradient) size+=gradient->MarshallSize();187 return size;188 }189 /*}}}*/190 /*FUNCTION ControlInput::Demarshall{{{1*/191 void ControlInput::Demarshall(char** pmarshalled_dataset){192 193 char* marshalled_dataset=NULL;194 int flag,input_enum_type;195 196 /*recover marshalled_dataset: */197 marshalled_dataset=*pmarshalled_dataset;198 199 /*this time, no need to get enum type, the pointer directly points to the beginning of the200 *object data (thanks to DataSet::Demarshall):*/201 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);202 memcpy(&control_id,marshalled_dataset,sizeof(control_id));marshalled_dataset+=sizeof(control_id);203 204 /*Demarshal values*/205 memcpy(&flag,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);206 if(flag){207 memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);208 if(input_enum_type==PentaP1InputEnum){209 values=new PentaP1Input();210 values->Demarshall(&marshalled_dataset);211 }212 else if(input_enum_type==TriaP1InputEnum){213 values=new TriaP1Input();214 values->Demarshall(&marshalled_dataset);215 }216 else _error_("Not supported yet");217 }218 else{219 values=NULL;220 }221 222 /*Demarshal savedvalues*/223 memcpy(&flag,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);224 if(flag){225 memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);226 if(input_enum_type==PentaP1InputEnum){227 savedvalues=new PentaP1Input();228 savedvalues->Demarshall(&marshalled_dataset);229 }230 else if(input_enum_type==TriaP1InputEnum){231 savedvalues=new TriaP1Input();232 savedvalues->Demarshall(&marshalled_dataset);233 }234 else _error_("Not supported yet");235 }236 else{237 savedvalues=NULL;238 }239 240 /*Demarshal minvalues*/241 memcpy(&flag,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);242 if(flag){243 memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);244 if(input_enum_type==PentaP1InputEnum){245 minvalues=new PentaP1Input();246 minvalues->Demarshall(&marshalled_dataset);247 }248 else if(input_enum_type==TriaP1InputEnum){249 minvalues=new TriaP1Input();250 minvalues->Demarshall(&marshalled_dataset);251 }252 else _error_("Not supported yet");253 }254 else{255 minvalues=NULL;256 }257 258 /*Demarshal maxvalues*/259 memcpy(&flag,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);260 if(flag){261 memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);262 if(input_enum_type==PentaP1InputEnum){263 maxvalues=new PentaP1Input();264 maxvalues->Demarshall(&marshalled_dataset);265 }266 else if(input_enum_type==TriaP1InputEnum){267 maxvalues=new TriaP1Input();268 maxvalues->Demarshall(&marshalled_dataset);269 }270 else _error_("Not supported yet");271 }272 else{273 maxvalues=NULL;274 }275 276 /*Demarshal gradient*/277 memcpy(&flag,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);278 if(flag){279 memcpy(&input_enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);280 if(input_enum_type==PentaP1InputEnum){281 gradient=new PentaP1Input();282 gradient->Demarshall(&marshalled_dataset);283 }284 else if(input_enum_type==TriaP1InputEnum){285 gradient=new TriaP1Input();286 gradient->Demarshall(&marshalled_dataset);287 }288 else _error_("Not supported yet");289 }290 else{291 gradient=NULL;292 }293 294 /*return: */295 *pmarshalled_dataset=marshalled_dataset;296 return;297 }298 /*}}}*/299 #endif300 92 /*FUNCTION ControlInput::ObjectEnum{{{1*/ 301 93 int ControlInput::ObjectEnum(void){ -
issm/trunk/src/c/objects/Inputs/ControlInput.h
r12299 r12330 35 35 int Id(); 36 36 int MyRank(); 37 #ifdef _SERIAL_38 void Marshall(char** pmarshalled_dataset);39 int MarshallSize();40 void Demarshall(char** pmarshalled_dataset);41 #endif42 37 int ObjectEnum(); 43 38 Object* copy(); -
issm/trunk/src/c/objects/Inputs/DatasetInput.cpp
r10135 r12330 61 61 } 62 62 /*}}}*/ 63 #ifdef _SERIAL_64 /*FUNCTION DatasetInput::Marshall{{{1*/65 void DatasetInput::Marshall(char** pmarshalled_dataset){66 67 char* marshalled_dataset=NULL;68 char* marshalled_inputs=NULL;69 int marshalled_inputs_size;70 int enum_value=0;71 72 /*recover marshalled_dataset: */73 marshalled_dataset=*pmarshalled_dataset;74 75 /*get enum value of DatasetInput: */76 enum_value=DatasetInputEnum;77 78 /*marshall enum: */79 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);80 81 /*marshall enum_type: */82 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);83 84 /*marshal inputs*/85 marshalled_inputs_size=inputs->MarshallSize();86 marshalled_inputs=inputs->Marshall();87 memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));88 marshalled_dataset+=marshalled_inputs_size;89 90 /*clean up and assign output pointer*/91 xfree((void**)&marshalled_inputs);92 *pmarshalled_dataset=marshalled_dataset;93 }94 /*}}}*/95 /*FUNCTION DatasetInput::MarshallSize{{{1*/96 int DatasetInput::MarshallSize(){97 98 int size=0;99 100 size=sizeof(enum_type)+101 +inputs->MarshallSize()102 +sizeof(int); //sizeof(int) for enum value103 104 return size;105 }106 /*}}}*/107 /*FUNCTION DatasetInput::Demarshall{{{1*/108 void DatasetInput::Demarshall(char** pmarshalled_dataset){109 char* marshalled_dataset=NULL;110 111 /*recover marshalled_dataset: */112 marshalled_dataset=*pmarshalled_dataset;113 114 /*this time, no need to get enum type, the pointer directly points to the beginning of the115 *object data (thanks to DataSet::Demarshall):*/116 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);117 118 /*Demarshal values*/119 inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);120 121 /*return: */122 *pmarshalled_dataset=marshalled_dataset;123 return;124 }125 /*}}}*/126 #endif127 63 /*FUNCTION DatasetInput::ObjectEnum{{{1*/ 128 64 int DatasetInput::ObjectEnum(void){ -
issm/trunk/src/c/objects/Inputs/DatasetInput.h
r12299 r12330 31 31 int Id(); 32 32 int MyRank(); 33 #ifdef _SERIAL_34 void Marshall(char** pmarshalled_dataset);35 int MarshallSize();36 void Demarshall(char** pmarshalled_dataset);37 #endif38 33 int ObjectEnum(); 39 34 Object* copy(); -
issm/trunk/src/c/objects/Inputs/DoubleInput.cpp
r11995 r12330 59 59 } 60 60 /*}}}*/ 61 #ifdef _SERIAL_62 /*FUNCTION DoubleInput::Marshall{{{1*/63 void DoubleInput::Marshall(char** pmarshalled_dataset){64 65 char* marshalled_dataset=NULL;66 int enum_value=0;67 68 /*recover marshalled_dataset: */69 marshalled_dataset=*pmarshalled_dataset;70 71 /*get enum value of DoubleInput: */72 enum_value=DoubleInputEnum;73 74 /*marshall enum: */75 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);76 77 /*marshall DoubleInput data: */78 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);79 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);80 81 *pmarshalled_dataset=marshalled_dataset;82 }83 /*}}}*/84 /*FUNCTION DoubleInput::MarshallSize{{{1*/85 int DoubleInput::MarshallSize(){86 87 return sizeof(value)+88 +sizeof(enum_type)+89 +sizeof(int); //sizeof(int) for enum value90 }91 /*}}}*/92 /*FUNCTION DoubleInput::Demarshall{{{1*/93 void DoubleInput::Demarshall(char** pmarshalled_dataset){94 95 char* marshalled_dataset=NULL;96 int i;97 98 /*recover marshalled_dataset: */99 marshalled_dataset=*pmarshalled_dataset;100 101 /*this time, no need to get enum type, the pointer directly points to the beginning of the102 *object data (thanks to DataSet::Demarshall):*/103 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);104 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);105 106 /*return: */107 *pmarshalled_dataset=marshalled_dataset;108 return;109 }110 /*}}}*/111 #endif112 61 /*FUNCTION DoubleInput::ObjectEnum{{{1*/ 113 62 int DoubleInput::ObjectEnum(void){ … … 159 108 /*FUNCTION DoubleInput::GetInputValue(bool* pvalue) {{{1*/ 160 109 void DoubleInput::GetInputValue(bool* pvalue){ 161 #ifdef _SERIAL_162 *pvalue=(bool)value;163 #else164 110 _error_("Double input of enum %s cannot return a boolean",EnumToStringx(enum_type)); 165 #endif166 111 167 112 } … … 169 114 /*FUNCTION DoubleInput::GetInputValue(int* pvalue){{{1*/ 170 115 void DoubleInput::GetInputValue(int* pvalue){ 171 #ifdef _SERIAL_172 *pvalue=(int)value;173 #else174 116 _error_("Double input of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type)); 175 #endif176 117 177 118 } -
issm/trunk/src/c/objects/Inputs/DoubleInput.h
r12299 r12330 30 30 int Id(); 31 31 int MyRank(); 32 #ifdef _SERIAL_33 void Marshall(char** pmarshalled_dataset);34 int MarshallSize();35 void Demarshall(char** pmarshalled_dataset);36 #endif37 32 int ObjectEnum(); 38 33 Object* copy(); -
issm/trunk/src/c/objects/Inputs/IntInput.cpp
r11995 r12330 54 54 } 55 55 /*}}}*/ 56 #ifdef _SERIAL_57 /*FUNCTION IntInput::Marshall{{{1*/58 void IntInput::Marshall(char** pmarshalled_dataset){59 60 char* marshalled_dataset=NULL;61 int enum_value=0;62 63 /*recover marshalled_dataset: */64 marshalled_dataset=*pmarshalled_dataset;65 66 /*get enum value of IntInput: */67 enum_value=IntInputEnum;68 69 /*marshall enum: */70 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);71 72 /*marshall IntInput data: */73 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);74 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);75 76 *pmarshalled_dataset=marshalled_dataset;77 }78 /*}}}*/79 /*FUNCTION IntInput::MarshallSize{{{1*/80 int IntInput::MarshallSize(){81 82 return sizeof(value)+83 +sizeof(enum_type)+84 +sizeof(int); //sizeof(int) for enum value85 }86 /*}}}*/87 /*FUNCTION IntInput::Demarshall{{{1*/88 void IntInput::Demarshall(char** pmarshalled_dataset){89 90 char* marshalled_dataset=NULL;91 int i;92 93 /*recover marshalled_dataset: */94 marshalled_dataset=*pmarshalled_dataset;95 96 /*this time, no need to get enum type, the pointer directly points to the beginning of the97 *object data (thanks to DataSet::Demarshall):*/98 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);99 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);100 101 /*return: */102 *pmarshalled_dataset=marshalled_dataset;103 return;104 }105 /*}}}*/106 #endif107 56 /*FUNCTION IntInput::ObjectEnum{{{1*/ 108 57 int IntInput::ObjectEnum(void){ -
issm/trunk/src/c/objects/Inputs/IntInput.h
r12299 r12330 31 31 int Id(); 32 32 int MyRank(); 33 #ifdef _SERIAL_34 void Marshall(char** pmarshalled_dataset);35 int MarshallSize();36 void Demarshall(char** pmarshalled_dataset);37 #endif38 33 int ObjectEnum(); 39 34 Object* copy(); -
issm/trunk/src/c/objects/Inputs/PentaP1Input.cpp
r11995 r12330 70 70 } 71 71 /*}}}*/ 72 #ifdef _SERIAL_73 /*FUNCTION PentaP1Input::Marshall{{{1*/74 void PentaP1Input::Marshall(char** pmarshalled_dataset){75 76 char* marshalled_dataset=NULL;77 int enum_value=0;78 79 /*recover marshalled_dataset: */80 marshalled_dataset=*pmarshalled_dataset;81 82 /*get enum value of PentaP1Input: */83 enum_value=PentaP1InputEnum;84 85 /*marshall enum: */86 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);87 88 /*marshall PentaP1Input data: */89 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);90 memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);91 92 *pmarshalled_dataset=marshalled_dataset;93 }94 /*}}}*/95 /*FUNCTION PentaP1Input::MarshallSize{{{1*/96 int PentaP1Input::MarshallSize(){97 98 return sizeof(values)+99 +sizeof(enum_type)+100 +sizeof(int); //sizeof(int) for enum value101 }102 /*}}}*/103 /*FUNCTION PentaP1Input::Demarshall{{{1*/104 void PentaP1Input::Demarshall(char** pmarshalled_dataset){105 106 char* marshalled_dataset=NULL;107 int i;108 109 /*recover marshalled_dataset: */110 marshalled_dataset=*pmarshalled_dataset;111 112 /*this time, no need to get enum type, the pointer directly points to the beginning of the113 *object data (thanks to DataSet::Demarshall):*/114 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);115 memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);116 117 /*return: */118 *pmarshalled_dataset=marshalled_dataset;119 return;120 }121 /*}}}*/122 #endif123 72 /*FUNCTION PentaP1Input::ObjectEnum{{{1*/ 124 73 int PentaP1Input::ObjectEnum(void){ -
issm/trunk/src/c/objects/Inputs/PentaP1Input.h
r12299 r12330 31 31 int Id(); 32 32 int MyRank(); 33 #ifdef _SERIAL_34 void Marshall(char** pmarshalled_dataset);35 int MarshallSize();36 void Demarshall(char** pmarshalled_dataset);37 #endif38 33 int ObjectEnum(); 39 34 Object* copy(); -
issm/trunk/src/c/objects/Inputs/TransientInput.cpp
r12299 r12330 85 85 } 86 86 /*}}}*/ 87 #ifdef _SERIAL_88 /*FUNCTION TransientInput::Marshall{{{*/89 void TransientInput::Marshall(char** pmarshalled_dataset){90 91 char* marshalled_dataset=NULL;92 char* marshalled_inputs=NULL;93 int marshalled_inputs_size;94 int enum_value=0;95 96 /*recover marshalled_dataset: */97 marshalled_dataset=*pmarshalled_dataset;98 99 /*get enum value of TransientInput: */100 enum_value=TransientInputEnum;101 102 /*marshall enum: */103 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);104 105 /*marshall TransientInput data: */106 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);107 memcpy(marshalled_dataset,&numtimesteps,sizeof(numtimesteps));marshalled_dataset+=sizeof(numtimesteps);108 memcpy(marshalled_dataset,timesteps,numtimesteps*sizeof(double));marshalled_dataset+=numtimesteps*sizeof(double);109 110 /*marshal inputs*/111 marshalled_inputs_size=inputs->MarshallSize();112 marshalled_inputs=inputs->Marshall();113 memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));114 marshalled_dataset+=marshalled_inputs_size;115 116 /*clean up and assign output pointer*/117 xfree((void**)&marshalled_inputs);118 *pmarshalled_dataset=marshalled_dataset;119 120 }121 /*}}}*122 /*FUNCTION TransientInput::MarshallSize{{{*/123 int TransientInput::MarshallSize(){124 125 return126 +sizeof(enum_type)+127 +sizeof(numtimesteps)+128 +inputs->MarshallSize()129 +numtimesteps*sizeof(double)+130 +sizeof(int); //sizeof(int) for enum value131 }132 /*}}}*/133 /*FUNCTION TransientInput::Demarshall{{{*/134 void TransientInput::Demarshall(char** pmarshalled_dataset){135 136 char* marshalled_dataset=NULL;137 138 /*recover marshalled_dataset: */139 marshalled_dataset=*pmarshalled_dataset;140 141 /*this time, no need to get enum type, the pointer directly points to the beginning of the142 *object data (thanks to DataSet::Demarshall):*/143 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);144 memcpy(&numtimesteps,marshalled_dataset,sizeof(numtimesteps));marshalled_dataset+=sizeof(numtimesteps);145 146 /*allocate: */147 timesteps=(double*)xmalloc(numtimesteps*sizeof(double));148 memcpy(timesteps,marshalled_dataset,numtimesteps*sizeof(double));marshalled_dataset+=numtimesteps*sizeof(double);149 150 /*Demarshal values*/151 inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);152 153 /*return: */154 *pmarshalled_dataset=marshalled_dataset;155 return;156 157 }158 /*}}}*/159 #endif160 87 /*FUNCTION TransientInput::ObjectEnum{{{*/ 161 88 int TransientInput::ObjectEnum(void){ -
issm/trunk/src/c/objects/Inputs/TransientInput.h
r12299 r12330 34 34 int Id(); 35 35 int MyRank(); 36 #ifdef _SERIAL_37 void Marshall(char** pmarshalled_dataset);38 int MarshallSize();39 void Demarshall(char** pmarshalled_dataset);40 #endif41 36 int ObjectEnum(); 42 37 Object* copy(); -
issm/trunk/src/c/objects/Inputs/TriaP1Input.cpp
r11995 r12330 70 70 } 71 71 /*}}}*/ 72 #ifdef _SERIAL_73 /*FUNCTION TriaP1Input::Marshall{{{1*/74 void TriaP1Input::Marshall(char** pmarshalled_dataset){75 76 char* marshalled_dataset=NULL;77 int enum_value=0;78 79 /*recover marshalled_dataset: */80 marshalled_dataset=*pmarshalled_dataset;81 82 /*get enum value of TriaP1Input: */83 enum_value=TriaP1InputEnum;84 85 /*marshall enum: */86 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);87 88 /*marshall TriaP1Input data: */89 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);90 memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);91 92 *pmarshalled_dataset=marshalled_dataset;93 }94 /*}}}*/95 /*FUNCTION TriaP1Input::MarshallSize{{{1*/96 int TriaP1Input::MarshallSize(){97 98 return sizeof(values)+99 +sizeof(enum_type)+100 +sizeof(int); //sizeof(int) for enum value101 }102 /*}}}*/103 /*FUNCTION TriaP1Input::Demarshall{{{1*/104 void TriaP1Input::Demarshall(char** pmarshalled_dataset){105 106 char* marshalled_dataset=NULL;107 int i;108 109 /*recover marshalled_dataset: */110 marshalled_dataset=*pmarshalled_dataset;111 112 /*this time, no need to get enum type, the pointer directly points to the beginning of the113 *object data (thanks to DataSet::Demarshall):*/114 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);115 memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);116 117 /*return: */118 *pmarshalled_dataset=marshalled_dataset;119 return;120 }121 /*}}}*/122 #endif123 72 /*FUNCTION TriaP1Input::ObjectEnum{{{1*/ 124 73 int TriaP1Input::ObjectEnum(void){ -
issm/trunk/src/c/objects/Inputs/TriaP1Input.h
r12299 r12330 31 31 int Id(); 32 32 int MyRank(); 33 #ifdef _SERIAL_34 void Marshall(char** pmarshalled_dataset);35 int MarshallSize();36 void Demarshall(char** pmarshalled_dataset);37 #endif38 33 int ObjectEnum(); 39 34 Object* copy(); -
issm/trunk/src/c/objects/IoModel.cpp
r10390 r12330 45 45 this->fid=iomodel_handle; 46 46 47 /*Check that Enums are Synchronized*/ 48 this->CheckEnumSync(); 49 47 50 /*Initialize and read constants:*/ 48 51 this->constants=new Parameters(); … … 89 92 /*}}}*/ 90 93 94 /*FUNCTION IoModel::CheckEnumSync{{{1*/ 95 void IoModel::CheckEnumSync(void){ 96 97 extern int my_rank; 98 int record_enum = 0; 99 100 101 /*Check that some fields have been allocated*/ 102 _assert_(this->fid || my_rank); 103 104 105 /*Go find in the binary file, the position of the data we want to fetch: */ 106 if(my_rank==0){ //cpu 0 107 108 /*First set FILE* position to the beginning of the file: */ 109 fseek(this->fid,0,SEEK_SET); 110 111 /*Get first Enum*/ 112 if(fread(&record_enum,sizeof(int),1,this->fid)==0){ 113 _error_("Marshalled file is empty"); 114 } 115 else{ 116 if(record_enum!=MaximumNumberOfEnums){ 117 printf("\n"); 118 printf("=========================================================================\n"); 119 printf(" Enums in marshalled file are not compatible with compiled code \n"); 120 printf(" \n"); 121 printf(" * If you are running ISSM on a remote cluster: \n"); 122 printf(" make sure that you are using the same version of ISSM on your local \n"); 123 printf(" machine and remote cluster (you might need to run svn update) \n"); 124 printf(" * If you are running ISSM on your local machine: \n"); 125 printf(" make sure that all the code is compiled (modules and executables) \n"); 126 printf(" * If you are a developer and just added a new Enum: \n"); 127 printf(" you might need to run ./Synchronize.sh in src/c/EnumDefinitions \n"); 128 printf(" and recompile \n"); 129 printf("=========================================================================\n"); 130 printf("\n"); 131 _error_("Enums not consistent (See error message above)"); 132 } 133 } 134 } 135 } 136 /*}}}*/ 91 137 /*FUNCTION IoModel::Constant(bool* poutput,int constant_enum){{{1*/ 92 138 void IoModel::Constant(bool* poutput,int constant_enum){ … … 198 244 /*Ok, we have reached the end of the file. break: */ 199 245 record_code=0; //0 means bailout 246 #ifdef _HAVE_MPI_ 200 247 MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD); /*tell others cpus we are bailing: */ 248 #endif 201 249 break; 202 250 } … … 207 255 fread(&record_code,sizeof(int),1,this->fid); 208 256 257 #ifdef _HAVE_MPI_ 209 258 /*Tell other cpus what we are doing: */ 210 259 MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD); /*tell other cpus what we are going to do: */ … … 213 262 MPI_Bcast(&record_enum,1,MPI_INT,0,MPI_COMM_WORLD); 214 263 MPI_Bcast(&record_length,1,MPI_INT,0,MPI_COMM_WORLD); 264 #endif 215 265 216 217 266 switch(record_code){ 218 267 case 1: 219 268 /*Read the boolean and broadcast it to other cpus:*/ 220 269 if(fread(&booleanint,sizeof(int),1,this->fid)!=1) _error_(" could not read boolean "); 270 #ifdef _HAVE_MPI_ 221 271 MPI_Bcast(&booleanint,1,MPI_INT,0,MPI_COMM_WORLD); 272 #endif 222 273 223 274 /*create BoolParam: */ … … 228 279 /*Read the integer and broadcast it to other cpus:*/ 229 280 if(fread(&integer,sizeof(int),1,this->fid)!=1) _error_(" could not read integer "); 281 #ifdef _HAVE_MPI_ 230 282 MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD); 283 #endif 231 284 232 285 /*create IntParam: */ … … 237 290 /*Read the scalar and broadcast it to other cpus:*/ 238 291 if(fread(&scalar,sizeof(double),1,this->fid)!=1) _error_(" could not read scalar "); 292 #ifdef _HAVE_MPI_ 239 293 MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 294 #endif 240 295 241 296 /*create DoubleParam: */ … … 246 301 /*We have to read a string from disk. First read the dimensions of the string, then the string: */ 247 302 if(fread(&string_size,sizeof(int),1,this->fid)!=1) _error_(" could not read length of string "); 303 #ifdef _HAVE_MPI_ 248 304 MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 305 #endif 249 306 250 307 if(string_size){ … … 254 311 /*Read string, then broadcast: */ 255 312 if(fread(string,string_size*sizeof(char),1,this->fid)!=1)_error_(" could not read string "); 313 #ifdef _HAVE_MPI_ 256 314 MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 315 #endif 257 316 } 258 317 else{ … … 308 367 } 309 368 } //}}} 369 #ifdef _HAVE_MPI_ 310 370 else{ //cpu ~0 {{{2 311 371 for(;;){ //wait on cpu 0 … … 377 437 } 378 438 } //}}} 439 #endif 379 440 } 380 441 /*}}}*/ … … 399 460 if(fread(&booleanint,sizeof(int),1,fid)!=1) _error_(" could not read boolean "); 400 461 } 462 #ifdef _HAVE_MPI_ 401 463 MPI_Bcast(&booleanint,1,MPI_INT,0,MPI_COMM_WORLD); 464 #endif 402 465 403 466 /*cast to bool: */ … … 428 491 } 429 492 493 #ifdef _HAVE_MPI_ 430 494 MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD); 495 #endif 431 496 432 497 /*Assign output pointers: */ … … 456 521 if(fread(&scalar,sizeof(double),1,fid)!=1)_error_(" could not read scalar "); 457 522 } 523 #ifdef _HAVE_MPI_ 458 524 MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 525 #endif 459 526 460 527 /*Assign output pointers: */ … … 487 554 } 488 555 556 #ifdef _HAVE_MPI_ 489 557 MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 558 #endif 490 559 491 560 /*Now allocate string: */ … … 498 567 if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string "); 499 568 } 569 #ifdef _HAVE_MPI_ 500 570 MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 571 #endif 501 572 } 502 573 else{ … … 538 609 } 539 610 611 #ifdef _HAVE_MPI_ 540 612 MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 613 #endif 541 614 542 615 if(my_rank==0){ 543 616 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix "); 544 617 } 545 MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 618 #ifdef _HAVE_MPI_ 619 MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 620 #endif 546 621 547 622 /*Now allocate matrix: */ … … 554 629 } 555 630 631 #ifdef _HAVE_MPI_ 556 632 MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 633 #endif 557 634 } 558 635 … … 602 679 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix "); 603 680 } 681 #ifdef _HAVE_MPI_ 604 682 MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 683 #endif 605 684 606 685 if(my_rank==0){ 607 686 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix "); 608 687 } 688 #ifdef _HAVE_MPI_ 609 689 MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 690 #endif 610 691 611 692 /*Now allocate matrix: */ … … 617 698 if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix "); 618 699 } 700 #ifdef _HAVE_MPI_ 619 701 MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 702 #endif 620 703 } 621 704 … … 652 735 if(fread(&numstrings,sizeof(int),1,fid)!=1) _error_(" could not read length of string array"); 653 736 } 737 #ifdef _HAVE_MPI_ 654 738 MPI_Bcast(&numstrings,1,MPI_INT,0,MPI_COMM_WORLD); 739 #endif 655 740 656 741 /*Now allocate string array: */ … … 665 750 if(fread(&string_size,sizeof(int),1,fid)!=1) _error_(" could not read length of string "); 666 751 } 752 #ifdef _HAVE_MPI_ 667 753 MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 754 #endif 668 755 if(string_size){ 669 756 string=(char*)xmalloc((string_size+1)*sizeof(char)); … … 674 761 if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string "); 675 762 } 763 #ifdef _HAVE_MPI_ 676 764 MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 765 #endif 677 766 } 678 767 else{ … … 717 806 if(fread(&numrecords,sizeof(int),1,fid)!=1) _error_("could not read number of records in matrix array "); 718 807 } 808 #ifdef _HAVE_MPI_ 719 809 MPI_Bcast(&numrecords,1,MPI_INT,0,MPI_COMM_WORLD); 810 #endif 720 811 721 812 if(numrecords){ … … 738 829 if(fread(&M,sizeof(int),1,fid)!=1) _error_("%s%i%s","could not read number of rows in ",i,"th matrix of matrix array"); 739 830 } 831 #ifdef _HAVE_MPI_ 740 832 MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 833 #endif 741 834 742 835 if(my_rank==0){ 743 836 if(fread(&N,sizeof(int),1,fid)!=1) _error_("%s%i%s","could not read number of columns in ",i,"th matrix of matrix array"); 744 837 } 838 #ifdef _HAVE_MPI_ 745 839 MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 840 #endif 746 841 747 842 /*Now allocate matrix: */ … … 754 849 } 755 850 851 #ifdef _HAVE_MPI_ 756 852 MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 853 #endif 757 854 } 758 855 … … 1047 1144 } 1048 1145 } 1146 #ifdef _HAVE_MPI_ 1049 1147 MPI_Bcast(&found,1,MPI_INT,0,MPI_COMM_WORLD); 1050 1148 if(!found)_error_("%s %s ","could not find data with name",EnumToStringx(data_enum)); 1149 #endif 1051 1150 1052 1151 /*Broadcast code and vector type: */ 1152 #ifdef _HAVE_MPI_ 1053 1153 MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD); 1054 1154 MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD); 1055 1155 if(record_code==5) MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD); 1156 #endif 1056 1157 1057 1158 /*Assign output pointers:*/ -
issm/trunk/src/c/objects/IoModel.h
r9476 r12330 19 19 private: 20 20 FILE *fid; //pointer to input file 21 double **data; //this dataset holds temporary data, memory intensive.22 Parameters *constants; //this dataset holds all double, int, bool and char *parameters read in from the input file.*21 IssmDouble **data; //this dataset holds temporary data, memory intensive. 22 Parameters *constants; //this dataset holds all IssmDouble, int, bool and char *parameters read in from the input file.* 23 23 24 24 public: … … 41 41 42 42 /*Input/Output*/ 43 void Constant(bool *poutput,int constant_enum); 44 void Constant(int *poutput,int constant_enum); 45 void Constant(double *poutput,int constant_enum); 46 void Constant(char **poutput,int constant_enum); 47 Param *CopyConstantObject(int constant_enum); 48 double *Data(int dataenum); 49 void DeleteData(int num,...); 50 void FetchConstants(void); 51 void FetchData(bool* pboolean,int data_enum); 52 void FetchData(int* pinteger,int data_enum); 53 void FetchData(double* pscalar,int data_enum); 54 void FetchData(char** pstring,int data_enum); 55 void FetchData(int** pmatrix,int* pM,int* pN,int data_enum); 56 void FetchData(double** pscalarmatrix,int* pM,int* pN,int data_enum); 57 void FetchData(char*** pstringarray,int* pnumstrings,int data_enum); 58 void FetchData(double*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum); 59 void FetchData(int num,...); 60 void FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum=NoneEnum,double default_value=0); 61 FILE* SetFilePointerToData(int* pcode,int* pvector_type, int data_enum); 43 void CheckEnumSync(void); 44 void Constant(bool *poutput,int constant_enum); 45 void Constant(int *poutput,int constant_enum); 46 void Constant(IssmDouble *poutput,int constant_enum); 47 void Constant(char **poutput,int constant_enum); 48 Param *CopyConstantObject(int constant_enum); 49 IssmDouble *Data(int dataenum); 50 void DeleteData(int num,...); 51 void FetchConstants(void); 52 void FetchData(bool* pboolean,int data_enum); 53 void FetchData(int* pinteger,int data_enum); 54 void FetchData(IssmDouble* pscalar,int data_enum); 55 void FetchData(char** pstring,int data_enum); 56 void FetchData(int** pmatrix,int* pM,int* pN,int data_enum); 57 void FetchData(IssmDouble** pscalarmatrix,int* pM,int* pN,int data_enum); 58 void FetchData(char*** pstringarray,int* pnumstrings,int data_enum); 59 void FetchData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum); 60 void FetchData(int num,...); 61 void FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum=NoneEnum,IssmDouble default_value=0); 62 FILE* SetFilePointerToData(int* pcode,int* pvector_type, int data_enum); 62 63 }; 63 64 -
issm/trunk/src/c/objects/Loads/Icefront.cpp
r11995 r12330 163 163 } 164 164 /*}}}*/ 165 #ifdef _SERIAL_166 /*FUNCTION Icefront::Marshall {{{1*/167 void Icefront::Marshall(char** pmarshalled_dataset){168 169 char* marshalled_dataset=NULL;170 int enum_type=0;171 char* marshalled_inputs=NULL;172 int marshalled_inputs_size;173 174 /*recover marshalled_dataset: */175 marshalled_dataset=*pmarshalled_dataset;176 177 /*get enum type of Icefront: */178 enum_type=IcefrontEnum;179 180 /*marshall enum: */181 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);182 183 /*marshall Icefront data: */184 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);185 memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);186 187 /*Marshall hooks: */188 hnodes->Marshall(&marshalled_dataset);189 helement->Marshall(&marshalled_dataset);190 hmatpar->Marshall(&marshalled_dataset);191 192 /*Marshall inputs: */193 marshalled_inputs_size=inputs->MarshallSize();194 marshalled_inputs=inputs->Marshall();195 memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));196 marshalled_dataset+=marshalled_inputs_size;197 198 /*parameters: don't do anything about it. parameters are marshalled somewhere else!*/199 200 xfree((void**)&marshalled_inputs);201 202 *pmarshalled_dataset=marshalled_dataset;203 }204 /*}}}*/205 /*FUNCTION Icefront::MarshallSize {{{1*/206 int Icefront::MarshallSize(){207 208 return sizeof(id)209 +sizeof(analysis_type)210 +hnodes->MarshallSize()211 +helement->MarshallSize()212 +hmatpar->MarshallSize()213 +inputs->MarshallSize()214 +sizeof(int); //sizeof(int) for enum type215 }216 /*}}}*/217 /*FUNCTION Icefront::Demarshall {{{1*/218 void Icefront::Demarshall(char** pmarshalled_dataset){219 220 char* marshalled_dataset=NULL;221 int i;222 223 /*recover marshalled_dataset: */224 marshalled_dataset=*pmarshalled_dataset;225 226 /*this time, no need to get enum type, the pointer directly points to the beginning of the227 *object data (thanks to DataSet::Demarshall):*/228 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);229 memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);230 231 /*demarshall hooks: */232 hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);233 helement=new Hook(); helement->Demarshall(&marshalled_dataset);234 hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);235 236 /*pointers are garbabe, until configuration is carried out: */237 nodes=NULL;238 element=NULL;239 matpar=NULL;240 241 /*demarshall inputs: */242 inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);243 244 /*parameters: may not exist even yet, so let Configure handle it: */245 this->parameters=NULL;246 247 /*return: */248 *pmarshalled_dataset=marshalled_dataset;249 return;250 }251 /*}}}*/252 #endif253 165 /*FUNCTION Icefront::ObjectEnum{{{1*/ 254 166 int Icefront::ObjectEnum(void){ -
issm/trunk/src/c/objects/Loads/Icefront.h
r11995 r12330 49 49 int Id(); 50 50 int MyRank(); 51 #ifdef _SERIAL_52 void Marshall(char** pmarshalled_dataset);53 int MarshallSize();54 void Demarshall(char** pmarshalled_dataset);55 #endif56 51 int ObjectEnum(); 57 52 Object* copy(); -
issm/trunk/src/c/objects/Loads/Numericalflux.cpp
r11995 r12330 189 189 } 190 190 /*}}}*/ 191 #ifdef _SERIAL_192 /*FUNCTION Numericalflux::Marshall {{{1*/193 void Numericalflux::Marshall(char** pmarshalled_dataset){194 195 char* marshalled_dataset=NULL;196 int enum_type=0;197 char* marshalled_inputs=NULL;198 int marshalled_inputs_size;199 200 /*recover marshalled_dataset: */201 marshalled_dataset=*pmarshalled_dataset;202 203 /*get enum type of Numericalflux: */204 enum_type=NumericalfluxEnum;205 206 /*marshall enum: */207 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);208 209 /*marshall Numericalflux data: */210 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);211 memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);212 213 /*Marshall hooks: */214 hnodes->Marshall(&marshalled_dataset);215 helement->Marshall(&marshalled_dataset);216 217 /*Marshall inputs: */218 marshalled_inputs_size=inputs->MarshallSize();219 marshalled_inputs=inputs->Marshall();220 memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));221 marshalled_dataset+=marshalled_inputs_size;222 223 /*parameters: don't do anything about it. parameters are marshalled somewhere else!*/224 225 xfree((void**)&marshalled_inputs);226 227 *pmarshalled_dataset=marshalled_dataset;228 return;229 }230 /*}}}*/231 /*FUNCTION Numericalflux::MarshallSize{{{1*/232 int Numericalflux::MarshallSize(){233 234 return sizeof(id)235 +sizeof(analysis_type)236 +hnodes->MarshallSize()237 +helement->MarshallSize()238 +inputs->MarshallSize()239 +sizeof(int); //sizeof(int) for enum type240 }241 /*}}}*/242 /*FUNCTION Numericalflux::Demarshall {{{1*/243 void Numericalflux::Demarshall(char** pmarshalled_dataset){244 245 char* marshalled_dataset=NULL;246 int i;247 248 /*recover marshalled_dataset: */249 marshalled_dataset=*pmarshalled_dataset;250 251 /*this time, no need to get enum type, the pointer directly points to the beginning of the252 *object data (thanks to DataSet::Demarshall):*/253 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);254 memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);255 256 /*demarshall hooks: */257 hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);258 helement=new Hook(); helement->Demarshall(&marshalled_dataset);259 260 /*demarshall inputs: */261 inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);262 263 /*parameters: may not exist even yet, so let Configure handle it: */264 this->parameters=NULL;265 this->element=NULL;266 this->nodes=NULL;267 268 /*return: */269 *pmarshalled_dataset=marshalled_dataset;270 return;271 }272 /*}}}*/273 #endif274 191 /*FUNCTION Numericalflux::ObjectEnum{{{1*/ 275 192 int Numericalflux::ObjectEnum(void){ -
issm/trunk/src/c/objects/Loads/Numericalflux.h
r11995 r12330 45 45 int Id(); 46 46 int MyRank(); 47 #ifdef _SERIAL_48 void Marshall(char** pmarshalled_dataset);49 int MarshallSize();50 void Demarshall(char** pmarshalled_dataset);51 #endif52 47 int ObjectEnum(); 53 48 Object* copy(); -
issm/trunk/src/c/objects/Loads/Pengrid.cpp
r11995 r12330 132 132 } 133 133 /*}}}1*/ 134 #ifdef _SERIAL_135 /*FUNCTION Pengrid::Marshall {{{1*/136 void Pengrid::Marshall(char** pmarshalled_dataset){137 138 char* marshalled_dataset=NULL;139 int enum_type=0;140 char* marshalled_inputs=NULL;141 int marshalled_inputs_size;142 143 /*recover marshalled_dataset: */144 marshalled_dataset=*pmarshalled_dataset;145 146 /*get enum type of Tria: */147 enum_type=PengridEnum;148 149 /*marshall enum: */150 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);151 152 /*marshall Tria data: */153 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);154 memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);155 memcpy(marshalled_dataset,&active,sizeof(active));marshalled_dataset+=sizeof(active);156 memcpy(marshalled_dataset,&zigzag_counter,sizeof(zigzag_counter));marshalled_dataset+=sizeof(zigzag_counter);157 158 /*Marshall hooks: */159 hnode->Marshall(&marshalled_dataset);160 helement->Marshall(&marshalled_dataset);161 hmatpar->Marshall(&marshalled_dataset);162 163 /*Marshall inputs: */164 marshalled_inputs_size=inputs->MarshallSize();165 marshalled_inputs=inputs->Marshall();166 memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));167 marshalled_dataset+=marshalled_inputs_size;168 169 /*parameters: don't do anything about it. parameters are marshalled somewhere else!*/170 171 xfree((void**)&marshalled_inputs);172 173 *pmarshalled_dataset=marshalled_dataset;174 return;175 }176 /*}}}*/177 /*FUNCTION Pengrid::MarshallSize {{{1*/178 int Pengrid::MarshallSize(){179 180 return sizeof(id)181 +sizeof(analysis_type)182 +sizeof(active)183 +sizeof(zigzag_counter)184 +hnode->MarshallSize()185 +helement->MarshallSize()186 +hmatpar->MarshallSize()187 +inputs->MarshallSize()188 +sizeof(int); //sizeof(int) for enum type189 }190 /*}}}*/191 /*FUNCTION Pengrid::Demarshall {{{1*/192 void Pengrid::Demarshall(char** pmarshalled_dataset){193 194 char* marshalled_dataset=NULL;195 int i;196 197 /*recover marshalled_dataset: */198 marshalled_dataset=*pmarshalled_dataset;199 200 /*this time, no need to get enum type, the pointer directly points to the beginning of the201 *object data (thanks to DataSet::Demarshall):*/202 203 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);204 memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);205 memcpy(&active,marshalled_dataset,sizeof(active));marshalled_dataset+=sizeof(active);206 memcpy(&zigzag_counter,marshalled_dataset,sizeof(zigzag_counter));marshalled_dataset+=sizeof(zigzag_counter);207 208 /*demarshall hooks: */209 hnode=new Hook(); hnode->Demarshall(&marshalled_dataset);210 helement=new Hook(); helement->Demarshall(&marshalled_dataset);211 hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);212 213 /*demarshall inputs: */214 inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);215 216 /*parameters: may not exist even yet, so let Configure handle it: */217 this->parameters=NULL;218 this->node=NULL;219 this->element=NULL;220 this->matpar=NULL;221 222 /*return: */223 *pmarshalled_dataset=marshalled_dataset;224 return;225 }226 /*}}}*/227 #endif228 134 /*FUNCTION Pengrid::ObjectEnum{{{1*/ 229 135 int Pengrid::ObjectEnum(void){ -
issm/trunk/src/c/objects/Loads/Pengrid.h
r11995 r12330 50 50 int Id(); 51 51 int MyRank(); 52 #ifdef _SERIAL_53 void Marshall(char** pmarshalled_dataset);54 int MarshallSize();55 void Demarshall(char** pmarshalled_dataset);56 #endif57 52 int ObjectEnum(); 58 53 Object* copy(); -
issm/trunk/src/c/objects/Loads/Penpair.cpp
r11995 r12330 85 85 } 86 86 /*}}}1*/ 87 #ifdef _SERIAL_88 /*FUNCTION Penpair::Marshall {{{1*/89 void Penpair::Marshall(char** pmarshalled_dataset){90 91 char* marshalled_dataset=NULL;92 int enum_type=0;93 94 /*recover marshalled_dataset: */95 marshalled_dataset=*pmarshalled_dataset;96 97 /*get enum type of Penpair: */98 enum_type=PenpairEnum;99 100 /*marshall enum: */101 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);102 103 /*marshall Penpair data: */104 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);105 memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);106 107 /*Marshall hooks*/108 hnodes->Marshall(&marshalled_dataset);109 110 *pmarshalled_dataset=marshalled_dataset;111 return;112 }113 /*}}}1*/114 /*FUNCTION Penpair::MarshallSize {{{1*/115 int Penpair::MarshallSize(){116 117 return sizeof(id)+118 +sizeof(analysis_type)119 +hnodes->MarshallSize()120 +sizeof(int); //sizeof(int) for enum type121 }122 /*}}}1*/123 /*FUNCTION Penpair::Demarshall {{{1*/124 void Penpair::Demarshall(char** pmarshalled_dataset){125 126 int i;127 char* marshalled_dataset=NULL;128 129 /*recover marshalled_dataset: */130 marshalled_dataset=*pmarshalled_dataset;131 132 /*this time, no need to get enum type, the pointer directly points to the beginning of the133 *object data (thanks to DataSet::Demarshall):*/134 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);135 memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);136 137 /*demarshall hooks: */138 hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);139 140 /*pointers are garbabe, until configuration is carried out: */141 nodes=NULL;142 parameters=NULL;143 144 /*return: */145 *pmarshalled_dataset=marshalled_dataset;146 return;147 }148 /*}}}1*/149 #endif150 87 /*FUNCTION Penpair::ObjectEnum{{{1*/ 151 88 int Penpair::ObjectEnum(void){ -
issm/trunk/src/c/objects/Loads/Penpair.h
r11995 r12330 37 37 int Id(); 38 38 int MyRank(); 39 #ifdef _SERIAL_40 void Marshall(char** pmarshalled_dataset);41 int MarshallSize();42 void Demarshall(char** pmarshalled_dataset);43 #endif44 39 int ObjectEnum(); 45 40 Object* copy(); -
issm/trunk/src/c/objects/Loads/Riftfront.cpp
r11995 r12330 192 192 } 193 193 /*}}}1*/ 194 #ifdef _SERIAL_195 /*FUNCTION Riftfront::Marshall {{{1*/196 void Riftfront::Marshall(char** pmarshalled_dataset){197 198 char* marshalled_dataset=NULL;199 int enum_type=0;200 char* marshalled_inputs=NULL;201 int marshalled_inputs_size;202 203 /*recover marshalled_dataset: */204 marshalled_dataset=*pmarshalled_dataset;205 206 /*get enum type of Riftfront: */207 enum_type=RiftfrontEnum;208 209 /*marshall enum: */210 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);211 212 /*marshall Riftfront data: */213 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);214 memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);215 memcpy(marshalled_dataset,&active,sizeof(active));marshalled_dataset+=sizeof(active);216 memcpy(marshalled_dataset,&normal,sizeof(normal));marshalled_dataset+=sizeof(normal);217 memcpy(marshalled_dataset,&length,sizeof(length));marshalled_dataset+=sizeof(length);218 memcpy(marshalled_dataset,&fraction,sizeof(fraction));marshalled_dataset+=sizeof(fraction);219 memcpy(marshalled_dataset,&frozen,sizeof(frozen));marshalled_dataset+=sizeof(frozen);220 memcpy(marshalled_dataset,&state,sizeof(state));marshalled_dataset+=sizeof(state);221 memcpy(marshalled_dataset,&counter,sizeof(counter));marshalled_dataset+=sizeof(counter);222 memcpy(marshalled_dataset,&prestable,sizeof(prestable));marshalled_dataset+=sizeof(prestable);223 memcpy(marshalled_dataset,&penalty_lock,sizeof(penalty_lock));marshalled_dataset+=sizeof(penalty_lock);224 memcpy(marshalled_dataset,&material_converged,sizeof(material_converged));marshalled_dataset+=sizeof(material_converged);225 226 /*Marshall hooks: */227 hnodes->Marshall(&marshalled_dataset);228 helements->Marshall(&marshalled_dataset);229 hmatpar->Marshall(&marshalled_dataset);230 231 /*Marshall inputs: */232 marshalled_inputs_size=inputs->MarshallSize();233 marshalled_inputs=inputs->Marshall();234 memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));235 marshalled_dataset+=marshalled_inputs_size;236 237 /*parameters: don't do anything about it. parameters are marshalled somewhere else!*/238 239 xfree((void**)&marshalled_inputs);240 241 *pmarshalled_dataset=marshalled_dataset;242 return;243 }244 /*}}}*/245 /*FUNCTION Riftfront::MarshallSize {{{1*/246 int Riftfront::MarshallSize(){247 248 return sizeof(id)249 +sizeof(analysis_type)250 +sizeof(active)251 +sizeof(normal)252 +sizeof(length)253 +sizeof(fraction)254 +sizeof(frozen)255 +sizeof(state)256 +sizeof(counter)257 +sizeof(prestable)258 +sizeof(penalty_lock)259 +sizeof(material_converged)260 +hnodes->MarshallSize()261 +helements->MarshallSize()262 +hmatpar->MarshallSize()263 +inputs->MarshallSize()264 +sizeof(int); //sizeof(int) for enum type265 }266 /*}}}*/267 /*FUNCTION Riftfront::Demarshall {{{1*/268 void Riftfront::Demarshall(char** pmarshalled_dataset){269 270 char* marshalled_dataset=NULL;271 int i;272 273 /*recover marshalled_dataset: */274 marshalled_dataset=*pmarshalled_dataset;275 276 /*this time, no need to get enum type, the pointer directly points to the beginning of the277 *object data (thanks to DataSet::Demarshall):*/278 279 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);280 memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);281 memcpy(&active,marshalled_dataset,sizeof(active));marshalled_dataset+=sizeof(active);282 memcpy(&normal,marshalled_dataset,sizeof(normal));marshalled_dataset+=sizeof(normal);283 memcpy(&length,marshalled_dataset,sizeof(length));marshalled_dataset+=sizeof(length);284 memcpy(&fraction,marshalled_dataset,sizeof(fraction));marshalled_dataset+=sizeof(fraction);285 memcpy(&frozen,marshalled_dataset,sizeof(frozen));marshalled_dataset+=sizeof(frozen);286 memcpy(&state,marshalled_dataset,sizeof(state));marshalled_dataset+=sizeof(state);287 memcpy(&counter,marshalled_dataset,sizeof(counter));marshalled_dataset+=sizeof(counter);288 memcpy(&prestable,marshalled_dataset,sizeof(prestable));marshalled_dataset+=sizeof(prestable);289 memcpy(&penalty_lock,marshalled_dataset,sizeof(penalty_lock));marshalled_dataset+=sizeof(penalty_lock);290 memcpy(&material_converged,marshalled_dataset,sizeof(material_converged));marshalled_dataset+=sizeof(material_converged);291 292 /*demarshall hooks: */293 hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);294 helements=new Hook(); helements->Demarshall(&marshalled_dataset);295 hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);296 297 /*pointers are garbabe, until configuration is carried out: */298 nodes=NULL;299 elements=NULL;300 matpar=NULL;301 302 /*demarshall inputs: */303 inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);304 305 /*parameters: may not exist even yet, so let Configure handle it: */306 this->parameters=NULL;307 308 /*return: */309 *pmarshalled_dataset=marshalled_dataset;310 }311 /*}}}*/312 #endif313 194 /*FUNCTION Riftfront::ObjectEnum{{{1*/ 314 195 int Riftfront::ObjectEnum(void){ -
issm/trunk/src/c/objects/Loads/Riftfront.h
r11995 r12330 57 57 int Id(); 58 58 int MyRank(); 59 #ifdef _SERIAL_60 void Marshall(char** pmarshalled_dataset);61 int MarshallSize();62 void Demarshall(char** pmarshalled_dataset);63 #endif64 59 int ObjectEnum(); 65 60 Object* copy(); -
issm/trunk/src/c/objects/Materials/Matice.cpp
r11995 r12330 88 88 } 89 89 /*}}}*/ 90 #ifdef _SERIAL_91 /*FUNCTION Matice::Marshall {{{1*/92 void Matice::Marshall(char** pmarshalled_dataset){93 94 /*Intermediaries*/95 char* marshalled_dataset=NULL;96 int enum_type=0;97 char* marshalled_inputs=NULL;98 int marshalled_inputs_size;99 100 /*recover marshalled_dataset: */101 marshalled_dataset=*pmarshalled_dataset;102 103 /*get enum type of Matice: */104 enum_type=MaticeEnum;105 106 /*marshall enum: */107 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);108 109 /*marshall Matice data: */110 memcpy(marshalled_dataset,&mid,sizeof(mid));marshalled_dataset+=sizeof(mid);111 112 /*Marshall hooks: */113 helement->Marshall(&marshalled_dataset);114 115 /*Marshall inputs: */116 marshalled_inputs_size=inputs->MarshallSize();117 marshalled_inputs=inputs->Marshall();118 memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));119 marshalled_dataset+=marshalled_inputs_size;120 121 *pmarshalled_dataset=marshalled_dataset;122 123 /*clean up and return*/124 xfree((void**)&marshalled_inputs);125 }126 /*}}}*/127 /*FUNCTION Matice::MarshallSize{{{1*/128 int Matice::MarshallSize(){129 130 return sizeof(mid)131 +helement->MarshallSize()132 +inputs->MarshallSize()133 +sizeof(int); //sizeof(int) for enum type134 }135 /*}}}*/136 /*FUNCTION Matice::Demarshall {{{1*/137 void Matice::Demarshall(char** pmarshalled_dataset){138 139 char* marshalled_dataset=NULL;140 141 /*recover marshalled_dataset: */142 marshalled_dataset=*pmarshalled_dataset;143 144 /*this time, no need to get enum type, the pointer directly points to the beginning of the145 *object data (thanks to DataSet::Demarshall):*/146 memcpy(&mid,marshalled_dataset,sizeof(mid));marshalled_dataset+=sizeof(mid);147 148 /*demarshall hooks: */149 helement=new Hook(); helement->Demarshall(&marshalled_dataset);150 151 /*demarshall inputs: */152 inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);153 154 /*return: */155 *pmarshalled_dataset=marshalled_dataset;156 return;157 }158 /*}}}*/159 #endif160 90 /*FUNCTION Matice::ObjectEnum{{{1*/ 161 91 int Matice::ObjectEnum(void){ -
issm/trunk/src/c/objects/Materials/Matice.h
r11995 r12330 35 35 int Id(); 36 36 int MyRank(); 37 #ifdef _SERIAL_38 void Marshall(char** pmarshalled_dataset);39 int MarshallSize();40 void Demarshall(char** pmarshalled_dataset);41 #endif42 37 int ObjectEnum(); 43 38 Object* copy(); -
issm/trunk/src/c/objects/Materials/Matpar.cpp
r12301 r12330 90 90 } 91 91 /*}}}1*/ 92 #ifdef _SERIAL_93 /*FUNCTION Matpar::Marshall {{{1*/94 void Matpar::Marshall(char** pmarshalled_dataset){95 96 char* marshalled_dataset=NULL;97 int enum_type=0;98 99 /*recover marshalled_dataset: */100 marshalled_dataset=*pmarshalled_dataset;101 102 /*get enum type of Matpar: */103 enum_type=MatparEnum;104 105 /*marshall enum: */106 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);107 108 /*marshall Matpar data: */109 memcpy(marshalled_dataset,&mid,sizeof(mid));marshalled_dataset+=sizeof(mid);110 memcpy(marshalled_dataset,&rho_ice,sizeof(rho_ice));marshalled_dataset+=sizeof(rho_ice);111 memcpy(marshalled_dataset,&rho_water,sizeof(rho_water));marshalled_dataset+=sizeof(rho_water);112 memcpy(marshalled_dataset,&rho_freshwater,sizeof(rho_freshwater));marshalled_dataset+=sizeof(rho_freshwater);113 memcpy(marshalled_dataset,&mu_water,sizeof(mu_water));marshalled_dataset+=sizeof(mu_water);114 memcpy(marshalled_dataset,&heatcapacity,sizeof(heatcapacity));marshalled_dataset+=sizeof(heatcapacity);115 memcpy(marshalled_dataset,&thermalconductivity,sizeof(thermalconductivity));marshalled_dataset+=sizeof(thermalconductivity);116 memcpy(marshalled_dataset,&latentheat,sizeof(latentheat));marshalled_dataset+=sizeof(latentheat);117 memcpy(marshalled_dataset,&beta,sizeof(beta));marshalled_dataset+=sizeof(beta);118 memcpy(marshalled_dataset,&meltingpoint,sizeof(meltingpoint));marshalled_dataset+=sizeof(meltingpoint);119 memcpy(marshalled_dataset,&referencetemperature,sizeof(referencetemperature));marshalled_dataset+=sizeof(referencetemperature);120 memcpy(marshalled_dataset,&mixed_layer_capacity,sizeof(mixed_layer_capacity));marshalled_dataset+=sizeof(mixed_layer_capacity);121 memcpy(marshalled_dataset,&thermal_exchange_velocity,sizeof(thermal_exchange_velocity));marshalled_dataset+=sizeof(thermal_exchange_velocity);122 memcpy(marshalled_dataset,&g,sizeof(g));marshalled_dataset+=sizeof(g);123 124 *pmarshalled_dataset=marshalled_dataset;125 return;126 }127 /*}}}1*/128 /*FUNCTION Matpar::MarshallSize {{{1*/129 int Matpar::MarshallSize(){130 131 return sizeof(mid)+132 sizeof(rho_ice)+133 sizeof(rho_water)+134 sizeof(rho_freshwater)+135 sizeof(mu_water)+136 sizeof(heatcapacity)+137 sizeof(thermalconductivity)+138 sizeof(latentheat)+139 sizeof(beta)+140 sizeof(meltingpoint)+141 sizeof(referencetemperature)+142 sizeof(mixed_layer_capacity)+143 sizeof(thermal_exchange_velocity)+144 sizeof(g)+145 sizeof(int); //sizeof(int) for enum type146 }147 /*}}}1*/148 /*FUNCTION Matpar::Demarshall {{{1*/149 void Matpar::Demarshall(char** pmarshalled_dataset){150 151 char* marshalled_dataset=NULL;152 153 /*recover marshalled_dataset: */154 marshalled_dataset=*pmarshalled_dataset;155 156 /*this time, no need to get enum type, the pointer directly points to the beginning of the157 *object data (thanks to DataSet::Demarshall):*/158 159 memcpy(&mid,marshalled_dataset,sizeof(mid));marshalled_dataset+=sizeof(mid);160 memcpy(&rho_ice,marshalled_dataset,sizeof(rho_ice));marshalled_dataset+=sizeof(rho_ice);161 memcpy(&rho_water,marshalled_dataset,sizeof(rho_water));marshalled_dataset+=sizeof(rho_water);162 memcpy(&rho_freshwater,marshalled_dataset,sizeof(rho_freshwater));marshalled_dataset+=sizeof(rho_freshwater);163 memcpy(&mu_water,marshalled_dataset,sizeof(mu_water));marshalled_dataset+=sizeof(mu_water);164 memcpy(&heatcapacity,marshalled_dataset,sizeof(heatcapacity));marshalled_dataset+=sizeof(heatcapacity);165 memcpy(&thermalconductivity,marshalled_dataset,sizeof(thermalconductivity));marshalled_dataset+=sizeof(thermalconductivity);166 memcpy(&latentheat,marshalled_dataset,sizeof(latentheat));marshalled_dataset+=sizeof(latentheat);167 memcpy(&beta,marshalled_dataset,sizeof(beta));marshalled_dataset+=sizeof(beta);168 memcpy(&meltingpoint,marshalled_dataset,sizeof(meltingpoint));marshalled_dataset+=sizeof(meltingpoint);169 memcpy(&referencetemperature,marshalled_dataset,sizeof(referencetemperature));marshalled_dataset+=sizeof(referencetemperature);170 memcpy(&mixed_layer_capacity,marshalled_dataset,sizeof(mixed_layer_capacity));marshalled_dataset+=sizeof(mixed_layer_capacity);171 memcpy(&thermal_exchange_velocity,marshalled_dataset,sizeof(thermal_exchange_velocity));marshalled_dataset+=sizeof(thermal_exchange_velocity);172 memcpy(&g,marshalled_dataset,sizeof(g));marshalled_dataset+=sizeof(g);173 174 /*return: */175 *pmarshalled_dataset=marshalled_dataset;176 return;177 }178 /*}}}1*/179 #endif180 92 /*FUNCTION Matpar::ObjectEnum{{{1*/ 181 93 int Matpar::ObjectEnum(void){ -
issm/trunk/src/c/objects/Materials/Matpar.h
r12301 r12330 47 47 int Id(); 48 48 int MyRank(); 49 #ifdef _SERIAL_50 void Marshall(char** pmarshalled_dataset);51 int MarshallSize();52 void Demarshall(char** pmarshalled_dataset);53 #endif54 49 int ObjectEnum(); 55 50 Object* copy(); -
issm/trunk/src/c/objects/Node.cpp
r11995 r12330 193 193 } 194 194 /*}}}*/ 195 #ifdef _SERIAL_196 /*FUNCTION Node::Marshall{{{1*/197 void Node::Marshall(char** pmarshalled_dataset){198 199 char* marshalled_dataset=NULL;200 int enum_type=0;201 char* marshalled_inputs=NULL;202 int marshalled_inputssize;203 204 /*recover marshalled_dataset: */205 marshalled_dataset=*pmarshalled_dataset;206 207 /*get enum type of Node: */208 enum_type=NodeEnum;209 210 /*marshall enum: */211 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);212 213 /*marshall Node data: */214 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);215 memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);216 memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);217 memcpy(marshalled_dataset,&coord_system,9*sizeof(double));marshalled_dataset+=9*sizeof(double);218 219 /*marshall objects: */220 indexing.Marshall(&marshalled_dataset);221 hvertex->Marshall(&marshalled_dataset);222 223 /*Marshall inputs: */224 marshalled_inputssize=inputs->MarshallSize();225 marshalled_inputs=inputs->Marshall();226 memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputssize*sizeof(char));227 marshalled_dataset+=marshalled_inputssize;228 229 /*Free ressources:*/230 xfree((void**)&marshalled_inputs);231 232 *pmarshalled_dataset=marshalled_dataset;233 return;234 }235 /*}}}*/236 /*FUNCTION Node::MarshallSize{{{1*/237 int Node::MarshallSize(){238 239 return sizeof(id)+240 sizeof(sid)+241 indexing.MarshallSize()+242 hvertex->MarshallSize()+243 inputs->MarshallSize()+244 sizeof(analysis_type)+245 9*sizeof(double)+246 sizeof(int); //sizeof(int) for enum type247 }248 /*}}}*/249 /*FUNCTION Node::Demarshall{{{1*/250 void Node::Demarshall(char** pmarshalled_dataset){251 252 char* marshalled_dataset=NULL;253 254 /*recover marshalled_dataset: */255 marshalled_dataset=*pmarshalled_dataset;256 257 /*this time, no need to get enum type, the pointer directly points to the beginning of the258 *object data (thanks to DataSet::Demarshall):*/259 260 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);261 memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);262 memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);263 memcpy(&coord_system,marshalled_dataset,9*sizeof(double));marshalled_dataset+=9*sizeof(double);264 265 /*demarshall objects: */266 indexing.Demarshall(&marshalled_dataset);267 hvertex=new Hook(); hvertex->Demarshall(&marshalled_dataset);268 269 /*demarshall inputs: */270 inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);271 272 /*return: */273 *pmarshalled_dataset=marshalled_dataset;274 return;275 }276 /*}}}*/277 #endif278 195 /*FUNCTION Node::ObjectEnum{{{1*/ 279 196 int Node::ObjectEnum(void){ -
issm/trunk/src/c/objects/Node.h
r11995 r12330 32 32 Inputs* inputs; //properties of this node 33 33 int analysis_type; 34 double coord_system[3][3];34 IssmDouble coord_system[3][3]; 35 35 36 36 /*Node constructors, destructors {{{1*/ … … 44 44 int Id(); 45 45 int MyRank(); 46 #ifdef _SERIAL_47 void Marshall(char** pmarshalled_dataset);48 int MarshallSize();49 void Demarshall(char** pmarshalled_dataset);50 #endif51 46 int ObjectEnum(); 52 47 Object* copy(){_error_("Not implemented yet (similar to Elements)");}; … … 54 49 /*Update virtual functions definitions: {{{1*/ 55 50 56 void InputUpdateFromVector( double* vector, int name, int type);51 void InputUpdateFromVector(IssmDouble* vector, int name, int type); 57 52 void InputUpdateFromVector(int* vector, int name, int type); 58 53 void InputUpdateFromVector(bool* vector, int name, int type); 59 void InputUpdateFromMatrixDakota( double* matrix,int nrows, int ncols, int name, int type);60 void InputUpdateFromVectorDakota( double* vector, int name, int type);54 void InputUpdateFromMatrixDakota(IssmDouble* matrix,int nrows, int ncols, int name, int type); 55 void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type); 61 56 void InputUpdateFromVectorDakota(int* vector, int name, int type); 62 57 void InputUpdateFromVectorDakota(bool* vector, int name, int type); 63 void InputUpdateFromConstant( double constant, int name);58 void InputUpdateFromConstant(IssmDouble constant, int name); 64 59 void InputUpdateFromConstant(int constant, int name); 65 60 void InputUpdateFromConstant(bool constant, int name); 66 void InputUpdateFromSolution( double* solution){_error_("Not implemented yet!");}61 void InputUpdateFromSolution(IssmDouble* solution){_error_("Not implemented yet!");} 67 62 void InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("Not implemented yet!");} 68 63 /*}}}*/ … … 75 70 int GetVertexId(void); 76 71 #ifdef _HAVE_DIAGNOSTIC_ 77 void GetCoordinateSystem( double* coord_system_out);72 void GetCoordinateSystem(IssmDouble* coord_system_out); 78 73 #endif 79 74 void SetVertexDof(int in_dof); … … 82 77 int GetNumberOfDofs(int approximation_enum,int setenum); 83 78 int IsClone(); 84 void ApplyConstraint(int dof, double value);79 void ApplyConstraint(int dof,IssmDouble value); 85 80 void RelaxConstraint(int dof); 86 81 void DofInSSet(int dof); … … 93 88 int GetDofList1(void); 94 89 int GetSidList(void); 95 double GetX();96 double GetY();97 double GetZ();98 double GetSigma();90 IssmDouble GetX(); 91 IssmDouble GetY(); 92 IssmDouble GetZ(); 93 IssmDouble GetSigma(); 99 94 int IsOnBed(); 100 95 int IsOnSurface(); … … 102 97 int IsFloating(); 103 98 int IsGrounded(); 104 void UpdateSpcs( double* ys);105 void VecMerge(Vector* ug, double* vector_serial,int setenum);106 void VecReduce(Vector* vector, double* ug_serial,int setnum);99 void UpdateSpcs(IssmDouble* ys); 100 void VecMerge(Vector* ug, IssmDouble* vector_serial,int setenum); 101 void VecReduce(Vector* vector, IssmDouble* ug_serial,int setnum); 107 102 108 103 /*}}}*/ -
issm/trunk/src/c/objects/Numerics/ElementVector.cpp
r11995 r12330 166 166 double* localvalues=NULL; 167 167 168 /*In debugging mode, check consistency (no NaN, and values not too big)*/ 169 this->CheckConsistency(); 170 168 171 if(this->fsize){ 169 172 /*first, retrieve values that are in the f-set from the g-set values vector: */ … … 200 203 } 201 204 205 } 206 /*}}}*/ 207 /*FUNCTION ElementVector::CheckConsistency{{{1*/ 208 void ElementVector::CheckConsistency(void){ 209 /*Check element matrix values, only in debugging mode*/ 210 #ifdef _ISSM_DEBUG_ 211 for (int i=0;i<this->nrows;i++){ 212 if (isnan(this->values[i])) _error_("NaN found in Element Vector"); 213 if (fabs( this->values[i])>1.e+50) _error_("Element Vector values exceeds 1.e+50"); 214 } 215 #endif 202 216 } 203 217 /*}}}*/ -
issm/trunk/src/c/objects/Numerics/ElementVector.h
r11995 r12330 43 43 void InsertIntoGlobal(Vector* pf); 44 44 void Echo(void); 45 void CheckConsistency(void); 45 46 void Init(ElementVector* pe); 46 47 void SetValue(double scalar); -
issm/trunk/src/c/objects/Numerics/Matrix.cpp
r11995 r12330 140 140 } 141 141 /*}}}*/ 142 143 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)144 /*FUNCTION Matrix::ToMatlabMatrix{{{1*/145 mxArray* Matrix::ToMatlabMatrix(void){146 147 mxArray* dataref=NULL;148 #ifdef _HAVE_PETSC_149 PetscMatrixToMatlabMatrix(&dataref,this->matrix);150 #else151 dataref=this->matrix->ToMatlabMatrix();152 #endif153 return dataref;154 155 }156 /*}}}*/157 /*FUNCTION MatlabMatrixToMatrix{{{1*/158 Matrix* MatlabMatrixToMatrix(const mxArray* mxmatrix){159 160 int dummy;161 Matrix* matrix=NULL;162 163 /*allocate matrix object: */164 matrix=new Matrix();165 166 #ifdef _HAVE_PETSC_167 MatlabMatrixToPetscMatrix(&matrix->matrix,NULL,NULL,mxmatrix);168 #else169 matrix->matrix=MatlabMatrixToSeqMat(mxmatrix);170 #endif171 172 return matrix;173 }174 /*}}}*/175 #endif176 142 /*FUNCTION Matrix::Assemble{{{1*/ 177 143 void Matrix::Assemble(void){ -
issm/trunk/src/c/objects/Numerics/Matrix.h
r11995 r12330 21 21 #endif 22 22 23 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)24 #include "mex.h"25 #endif26 23 class Vector; 27 24 … … 51 48 /*Matrix specific routines {{{1*/ 52 49 void Echo(void); 53 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)54 mxArray* ToMatlabMatrix(void);55 #endif56 50 void Assemble(void); 57 51 double Norm(NormMode norm_type); … … 66 60 67 61 }; 68 /*API: */69 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)70 Matrix* MatlabMatrixToMatrix(const mxArray* mxmatrix);71 #endif72 62 73 63 #endif //#ifndef _MATRIX_H_ -
issm/trunk/src/c/objects/Numerics/Vector.cpp
r11995 r12330 85 85 /*}}}*/ 86 86 #endif 87 #if def _HAVE_GSL_87 #if defined(_HAVE_GSL_) && !defined(_HAVE_PETSC_) 88 88 /*FUNCTION Vector::Vector(SeqVec* seq_vec){{{1*/ 89 89 Vector::Vector(SeqVec* seq_vec){ … … 132 132 } 133 133 /*}}}*/ 134 135 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)136 /*FUNCTION Vector::ToMatlabVector{{{1*/137 mxArray* Vector::ToMatlabVector(void){138 139 mxArray* dataref=NULL;140 #ifdef _HAVE_PETSC_141 PetscVectorToMatlabVector(&dataref,this->vector);142 #else143 dataref=this->vector->ToMatlabVector();144 #endif145 return dataref;146 147 }148 /*}}}*/149 /*FUNCTION MatlabVectorToVector{{{1*/150 Vector* MatlabVectorToVector(const mxArray* mxvector){151 152 int dummy;153 Vector* vector=NULL;154 155 /*allocate vector object: */156 vector=new Vector();157 158 #ifdef _HAVE_PETSC_159 MatlabVectorToPetscVector(&vector->vector,&dummy,mxvector);160 #else161 vector->vector=MatlabVectorToSeqVec(mxvector);162 #endif163 164 return vector;165 }166 /*}}}*/167 #endif168 134 /*FUNCTION Vector::Assemble{{{1*/ 169 135 void Vector::Assemble(void){ -
issm/trunk/src/c/objects/Numerics/Vector.h
r11995 r12330 21 21 #endif 22 22 23 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)24 #include "mex.h"25 #endif26 27 23 /*}}}*/ 28 24 … … 47 43 Vector(Vec petsc_vec); 48 44 #endif 49 #if def _HAVE_GSL_45 #if defined(_HAVE_GSL_) && !defined(_HAVE_PETSC_) 50 46 Vector(SeqVec* seq_vec); 51 47 #endif … … 54 50 /*Vector specific routines {{{1*/ 55 51 void Echo(void); 56 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)57 mxArray* ToMatlabVector(void);58 #endif59 52 void AXPY(Vector *X, double a); 60 53 void AYPX(Vector *X, double a); … … 77 70 }; 78 71 79 /*API: */80 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)81 Vector* MatlabVectorToVector(const mxArray* mxvector);82 #endif83 72 84 73 #endif //#ifndef _VECTOR_H_ -
issm/trunk/src/c/objects/Object.h
r9883 r12330 21 21 virtual int Id()=0; 22 22 virtual int MyRank()=0; 23 #ifdef _SERIAL_24 virtual void Marshall(char** pmarshalled_dataset)=0;25 virtual int MarshallSize()=0;26 virtual void Demarshall(char** pmarshalled_dataset)=0;27 #endif28 23 virtual int ObjectEnum()=0; 29 24 virtual Object* copy()=0; -
issm/trunk/src/c/objects/OptArgs.h
r11995 r12330 6 6 #define _OPTARGS_H_ 7 7 8 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)9 10 #include "mex.h"11 struct OptArgs{12 char* function_name;13 mxArray* femmodel;14 };15 16 #else17 18 8 class Model; 19 9 struct OptArgs{ 20 10 FemModel* femmodel; 21 11 }; 22 #endif23 12 24 13 #endif -
issm/trunk/src/c/objects/OptPars.h
r9563 r12330 8 8 struct OptPars{ 9 9 10 double xmin;11 double xmax;12 double cm_jump;10 IssmDouble xmin; 11 IssmDouble xmax; 12 IssmDouble cm_jump; 13 13 int maxiter; 14 14 -
issm/trunk/src/c/objects/Options/Option.h
r9883 r12330 33 33 int Id(){_error_("Not implemented yet");}; 34 34 int MyRank(){_error_("Not implemented yet");}; 35 #ifdef _SERIAL_36 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");};37 int MarshallSize(){_error_("Not implemented yet");};38 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");};39 #endif40 35 int ObjectEnum(){return OptionEnum;}; 41 36 Object* copy(){_error_("Not implemented yet");}; … … 47 42 virtual int NDims()=0; 48 43 virtual int* Size()=0; 44 virtual void Get(int* pvalue)=0; 49 45 virtual void Get(double* pvalue)=0; 50 46 virtual void Get(bool* pvalue)=0; -
issm/trunk/src/c/objects/Options/OptionCell.h
r9883 r12330 30 30 int Id(){_error_("Not implemented yet");}; 31 31 int MyRank(){_error_("Not implemented yet");}; 32 #ifdef _SERIAL_33 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");};34 int MarshallSize(){_error_("Not implemented yet");};35 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");};36 #endif37 32 int ObjectEnum(){return OptionCellEnum;}; 38 33 Object* copy(){_error_("Not implemented yet");}; … … 44 39 int NDims(); 45 40 int* Size(); 41 void Get(int* pvalue){_error_("An OptionCell object cannot return a int");}; 46 42 void Get(double* pvalue){_error_("An OptionCell object cannot return a double");}; 47 43 void Get(bool* pvalue){ _error_("An OptionCell object cannot return a bool");}; -
issm/trunk/src/c/objects/Options/OptionChar.h
r9883 r12330 30 30 int Id(){_error_("Not implemented yet");}; 31 31 int MyRank(){_error_("Not implemented yet");}; 32 #ifdef _SERIAL_33 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");};34 int MarshallSize(){_error_("Not implemented yet");};35 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");};36 #endif37 32 int ObjectEnum(){return OptionCharEnum;}; 38 33 Object* copy(){_error_("Not implemented yet");}; … … 44 39 int NDims(); 45 40 int* Size(); 41 void Get(int* pvalue){_error_("An OptionChar object cannot return a int");}; 46 42 void Get(double* pvalue){_error_("An OptionChar object cannot return a double");}; 47 43 void Get(bool* pvalue){ _error_("An OptionChar object cannot return a bool");}; -
issm/trunk/src/c/objects/Options/OptionDouble.cpp
r9761 r12330 120 120 } 121 121 /*}}}*/ 122 /*FUNCTION OptionDouble::Get(int* pvalue) {{{1*/ 123 void OptionDouble::Get(int* pvalue){ 124 125 /*We should first check that the size is one*/ 126 if(this->NumEl()!=1){ 127 _error_("option \"%s\" has %i elements and cannot return a single int",this->name,this->NumEl()); 128 } 129 130 /*Assign output pointer*/ 131 *pvalue=(int)this->values[0]; 132 } 133 /*}}}*/ 122 134 /*FUNCTION OptionDouble::Get(double* pvalue) {{{1*/ 123 135 void OptionDouble::Get(double* pvalue){ -
issm/trunk/src/c/objects/Options/OptionDouble.h
r9883 r12330 30 30 int Id(){_error_("Not implemented yet");}; 31 31 int MyRank(){_error_("Not implemented yet");}; 32 #ifdef _SERIAL_33 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");};34 int MarshallSize(){_error_("Not implemented yet");};35 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");};36 #endif37 32 int ObjectEnum(){return OptionDoubleEnum;}; 38 33 Object* copy(){_error_("Not implemented yet");}; … … 44 39 int NDims(); 45 40 int* Size(); 41 void Get(int* pvalue); 46 42 void Get(double* pvalue); 47 43 void Get(bool* pvalue){ _error_("An OptionDouble object cannot return a bool");}; -
issm/trunk/src/c/objects/Options/OptionLogical.h
r9883 r12330 30 30 int Id(){_error_("Not implemented yet");}; 31 31 int MyRank(){_error_("Not implemented yet");}; 32 #ifdef _SERIAL_33 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");};34 int MarshallSize(){_error_("Not implemented yet");};35 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");};36 #endif37 32 int ObjectEnum(){return OptionLogicalEnum;}; 38 33 Object* copy(){_error_("Not implemented yet");}; … … 44 39 int NDims(); 45 40 int* Size(); 41 void Get(int* pvalue){_error_("An OptionLogical object cannot return a int");}; 46 42 void Get(double* pvalue){_error_("An OptionLogical object cannot return a double");}; 47 43 void Get(bool* pvalue); -
issm/trunk/src/c/objects/Options/OptionStruct.h
r9883 r12330 30 30 int Id(){_error_("Not implemented yet");}; 31 31 int MyRank(){_error_("Not implemented yet");}; 32 #ifdef _SERIAL_33 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");};34 int MarshallSize(){_error_("Not implemented yet");};35 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");};36 #endif37 32 int ObjectEnum(){return OptionStructEnum;}; 38 33 Object* copy(){_error_("Not implemented yet");}; … … 44 39 int NDims(); 45 40 int* Size(); 41 void Get(int* pvalue){_error_("An OptionStruct object cannot return a int");}; 46 42 void Get(double* pvalue){_error_("An OptionStruct object cannot return a double");}; 47 43 void Get(bool* pvalue){ _error_("An OptionStruct object cannot return a bool");}; -
issm/trunk/src/c/objects/Params/BoolParam.cpp
r11995 r12330 62 62 } 63 63 /*}}}*/ 64 #ifdef _SERIAL_65 /*FUNCTION BoolParam::Marshall{{{1*/66 void BoolParam::Marshall(char** pmarshalled_dataset){67 68 char* marshalled_dataset=NULL;69 int enum_value=0;70 71 /*recover marshalled_dataset: */72 marshalled_dataset=*pmarshalled_dataset;73 74 /*get enum value of BoolParam: */75 enum_value=BoolParamEnum;76 77 /*marshall enum: */78 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);79 80 /*marshall BoolParam data: */81 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);82 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);83 84 *pmarshalled_dataset=marshalled_dataset;85 }86 /*}}}*/87 /*FUNCTION BoolParam::MarshallSize{{{1*/88 int BoolParam::MarshallSize(){89 90 return sizeof(value)+91 +sizeof(enum_type)+92 +sizeof(int); //sizeof(int) for enum value93 }94 /*}}}*/95 /*FUNCTION BoolParam::Demarshall{{{1*/96 void BoolParam::Demarshall(char** pmarshalled_dataset){97 98 char* marshalled_dataset=NULL;99 int i;100 101 /*recover marshalled_dataset: */102 marshalled_dataset=*pmarshalled_dataset;103 104 /*this time, no need to get enum type, the pointer directly points to the beginning of the105 *object data (thanks to DataSet::Demarshall):*/106 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);107 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);108 109 /*return: */110 *pmarshalled_dataset=marshalled_dataset;111 return;112 }113 /*}}}*/114 #endif115 64 /*FUNCTION BoolParam::ObjectEnum{{{1*/ 116 65 int BoolParam::ObjectEnum(void){ … … 134 83 } 135 84 /*}}}*/ 136 /*FUNCTION BoolParam::SetMatlabField{{{1*/137 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)138 void BoolParam::SetMatlabField(mxArray* dataref){139 char* name=NULL;140 this->GetParameterName(&name);141 mxSetField( dataref, 0, name,mxCreateDoubleScalar((double)value));142 }143 #endif144 /*}}}*/145 85 /*FUNCTION BoolParam::UnitConversion{{{1*/ 146 86 void BoolParam::UnitConversion(int direction_enum){ -
issm/trunk/src/c/objects/Params/BoolParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 41 37 int Id(); 42 38 int MyRank(); 43 #ifdef _SERIAL_44 void Marshall(char** pmarshalled_dataset);45 int MarshallSize();46 void Demarshall(char** pmarshalled_dataset);47 #endif48 39 int ObjectEnum(); 49 40 Object* copy(); … … 81 72 82 73 void GetParameterName(char**pname); 83 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)84 void SetMatlabField(mxArray* dataref);85 #endif86 74 /*}}}*/ 87 75 }; -
issm/trunk/src/c/objects/Params/DoubleMatArrayParam.cpp
r11995 r12330 127 127 } 128 128 /*}}}*/ 129 #ifdef _SERIAL_130 /*FUNCTION DoubleMatArrayParam::Marshall{{{1*/131 void DoubleMatArrayParam::Marshall(char** pmarshalled_dataset){132 133 char* marshalled_dataset=NULL;134 int enum_value=0;135 int i;136 137 /*recover marshalled_dataset: */138 marshalled_dataset=*pmarshalled_dataset;139 140 /*get enum value of DoubleMatArrayParam: */141 enum_value=DoubleMatArrayParamEnum;142 143 /*marshall enum: */144 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);145 146 /*marshall DoubleMatArrayParam data: */147 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);148 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);149 if(M){150 memcpy(marshalled_dataset,mdim_array,M*sizeof(int));marshalled_dataset+=M*sizeof(int);151 memcpy(marshalled_dataset,ndim_array,M*sizeof(int));marshalled_dataset+=M*sizeof(int);152 for(i=0;i<M;i++){153 double* matrix=this->array[i];154 int m=this->mdim_array[i];155 int n=this->ndim_array[i];156 memcpy(marshalled_dataset,&m,sizeof(m));marshalled_dataset+=sizeof(m);157 memcpy(marshalled_dataset,&n,sizeof(n));marshalled_dataset+=sizeof(n);158 if(m*n)memcpy(marshalled_dataset,matrix,m*n*sizeof(double));marshalled_dataset+=m*n*sizeof(double);159 }160 }161 162 *pmarshalled_dataset=marshalled_dataset;163 }164 /*}}}*/165 /*FUNCTION DoubleMatArrayParam::MarshallSize{{{1*/166 int DoubleMatArrayParam::MarshallSize(){167 168 int size=0;169 int i;170 171 size+=sizeof(enum_type)+172 sizeof(M)+173 M*sizeof(int)+174 M*sizeof(int);175 176 for(i=0;i<M;i++){177 int m=this->mdim_array[i];178 int n=this->ndim_array[i];179 size+=sizeof(m)+sizeof(n)+m*n*sizeof(double);180 }181 size+=sizeof(int); //sizeof(int) for enum value182 183 return size;184 }185 /*}}}*/186 /*FUNCTION DoubleMatArrayParam::Demarshall{{{1*/187 void DoubleMatArrayParam::Demarshall(char** pmarshalled_dataset){188 189 char* marshalled_dataset=NULL;190 int i;191 double* matrix=NULL;192 int m,n;193 194 /*recover marshalled_dataset: */195 marshalled_dataset=*pmarshalled_dataset;196 197 /*this time, no need to get enum value, the pointer directly points to the beginning of the198 *object data (thanks to DataSet::Demarshall):*/199 200 /*data: */201 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);202 203 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);204 if(M){205 this->mdim_array=(int*)xmalloc(M*sizeof(int));206 this->ndim_array=(int*)xmalloc(M*sizeof(int));207 memcpy(this->mdim_array,marshalled_dataset,M*sizeof(int));marshalled_dataset+=M*sizeof(int);208 memcpy(this->ndim_array,marshalled_dataset,M*sizeof(int));marshalled_dataset+=M*sizeof(int);209 210 this->array=(double**)xmalloc(M*sizeof(double*));211 for(i=0;i<M;i++){212 memcpy(&m,marshalled_dataset,sizeof(m));marshalled_dataset+=sizeof(m);213 memcpy(&n,marshalled_dataset,sizeof(n));marshalled_dataset+=sizeof(n);214 if(m*n){215 matrix=(double*)xmalloc(m*n*sizeof(double));216 memcpy(matrix,marshalled_dataset,m*n*sizeof(double));marshalled_dataset+=m*n*sizeof(double);217 }218 else{219 matrix=NULL;220 }221 this->array[i]=matrix;222 }223 }224 else{225 this->array=NULL;226 this->mdim_array=NULL;227 this->ndim_array=NULL;228 }229 230 /*return: */231 *pmarshalled_dataset=marshalled_dataset;232 return;233 }234 /*}}}*/235 #endif236 129 /*FUNCTION DoubleMatArrayParam::ObjectEnum{{{1*/ 237 130 int DoubleMatArrayParam::ObjectEnum(void){ … … 307 200 EnumToStringx(pname,this->enum_type); 308 201 } 309 /*}}}*/310 /*FUNCTION StringArrayParam::SetMatlabField{{{1*/311 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)312 void DoubleMatArrayParam::SetMatlabField(mxArray* dataref){313 314 int i,m,n;315 double* matrix=NULL;316 double* outmatrix=NULL;317 char* name=NULL;318 mwSize dims[2]={0};319 mxArray* pfield=NULL;320 mxArray* pfield2=NULL;321 mxArray* pfield3=NULL;322 323 this->GetParameterName(&name);324 dims[0]=this->M;325 dims[1]=1;326 pfield=mxCreateCellArray(2,dims);327 328 for(i=0;i<this->M;i++){329 matrix=this->array[i];330 m=this->mdim_array[i];331 n=this->ndim_array[i];332 outmatrix=(double*)xmalloc(m*n*sizeof(double));333 memcpy(outmatrix,matrix,m*n*sizeof(double));334 335 pfield2=mxCreateDoubleMatrix(0,0,mxREAL);336 mxSetM(pfield2,n);337 mxSetN(pfield2,m);338 mxSetPr(pfield2,outmatrix);339 340 //transpose the outmatrix, written directly to matlab! from C to matlab.341 mexCallMATLAB(1,&pfield3, 1, &pfield2, "transpose");342 343 mxSetCell(pfield,i,pfield3);344 }345 346 mxSetField( dataref, 0, name,pfield);347 }348 #endif349 202 /*}}}*/ 350 203 /*FUNCTION DoubleMatArrayParam::SetValue(double** array, int M, int* mdim_array, int* ndim_array){{{1*/ -
issm/trunk/src/c/objects/Params/DoubleMatArrayParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 44 40 int Id(); 45 41 int MyRank(); 46 #ifdef _SERIAL_47 void Marshall(char** pmarshalled_dataset);48 int MarshallSize();49 void Demarshall(char** pmarshalled_dataset);50 #endif51 42 int ObjectEnum(); 52 43 Object* copy(); … … 84 75 85 76 void GetParameterName(char**pname); 86 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)87 void SetMatlabField(mxArray* dataref);88 #endif89 77 90 78 /*}}}*/ -
issm/trunk/src/c/objects/Params/DoubleMatParam.cpp
r11995 r12330 78 78 } 79 79 /*}}}*/ 80 #ifdef _SERIAL_81 /*FUNCTION DoubleMatParam::Marshall{{{1*/82 void DoubleMatParam::Marshall(char** pmarshalled_dataset){83 84 char* marshalled_dataset=NULL;85 int enum_value=0;86 87 /*recover marshalled_dataset: */88 marshalled_dataset=*pmarshalled_dataset;89 90 /*get enum value of DoubleMatParam: */91 enum_value=DoubleMatParamEnum;92 93 /*marshall enum: */94 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);95 96 /*marshall DoubleMatParam data: */97 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);98 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);99 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);100 memcpy(marshalled_dataset,value,M*N*sizeof(double));marshalled_dataset+=M*N*sizeof(double);101 102 *pmarshalled_dataset=marshalled_dataset;103 }104 /*}}}*/105 /*FUNCTION DoubleMatParam::MarshallSize{{{1*/106 int DoubleMatParam::MarshallSize(){107 108 return sizeof(M)109 +sizeof(N)110 +M*N*sizeof(double)111 +sizeof(enum_type)+112 +sizeof(int); //sizeof(int) for enum value113 }114 /*}}}*/115 /*FUNCTION DoubleMatParam::Demarshall{{{1*/116 void DoubleMatParam::Demarshall(char** pmarshalled_dataset){117 118 char* marshalled_dataset=NULL;119 int i;120 121 /*recover marshalled_dataset: */122 marshalled_dataset=*pmarshalled_dataset;123 124 /*this time, no need to get enum type, the pointer directly points to the beginning of the125 *object data (thanks to DataSet::Demarshall):*/126 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);127 128 /*data: */129 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);130 memcpy(&N,marshalled_dataset,sizeof(N));marshalled_dataset+=sizeof(N);131 value=(double*)xmalloc(M*N*sizeof(double));132 memcpy(value,marshalled_dataset,M*N*sizeof(double));marshalled_dataset+=M*N*sizeof(double);133 134 /*return: */135 *pmarshalled_dataset=marshalled_dataset;136 return;137 }138 /*}}}*/139 #endif140 80 /*FUNCTION DoubleMatParam::ObjectEnum{{{1*/ 141 81 int DoubleMatParam::ObjectEnum(void){ … … 169 109 /*FUNCTION DoubleMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){{{1*/ 170 110 void DoubleMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){ 171 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)172 int* output=NULL;173 int i;174 175 output=(int*)xmalloc((int)(M*N*sizeof(int)));176 for(i=0;i<M*N;i++) output[i]=(int)value[i];177 178 /*Assign output pointers:*/179 if(pM) *pM=M;180 if(pN) *pN=N;181 *pintarray=output;182 #else183 111 _error_("DoubleMat of enum %i (%s) cannot return an array of int",enum_type,EnumToStringx(enum_type)); 184 #endif185 112 } 186 113 /*}}}*/ … … 189 116 EnumToStringx(pname,this->enum_type); 190 117 } 191 /*}}}*/192 /*FUNCTION DoubleMatParam::SetMatlabField{{{1*/193 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)194 void DoubleMatParam::SetMatlabField(mxArray* dataref){195 196 mxArray* pfield=NULL;197 mxArray* pfield2=NULL;198 double* doublemat=NULL;199 char* name=NULL;200 201 this->GetParameterName(&name);202 this->GetParameterValue(&doublemat,NULL,NULL);203 204 pfield=mxCreateDoubleMatrix(0,0,mxREAL);205 mxSetM(pfield,N);206 mxSetN(pfield,M);207 mxSetPr(pfield,doublemat);208 209 //transpose the matrix, written directly to matlab! from C to matlab.210 mexCallMATLAB(1,&pfield2, 1, &pfield, "transpose");211 mxSetField( dataref, 0, name,pfield2);212 }213 #endif214 118 /*}}}*/ 215 119 /*FUNCTION DoubleMatParam::SetValue{{{1*/ -
issm/trunk/src/c/objects/Params/DoubleMatParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 43 39 int Id(); 44 40 int MyRank(); 45 #ifdef _SERIAL_46 void Marshall(char** pmarshalled_dataset);47 int MarshallSize();48 void Demarshall(char** pmarshalled_dataset);49 #endif50 41 int ObjectEnum(); 51 42 Object* copy(); … … 84 75 85 76 void GetParameterName(char**pname); 86 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)87 void SetMatlabField(mxArray* dataref);88 #endif89 77 90 78 /*}}}*/ -
issm/trunk/src/c/objects/Params/DoubleParam.cpp
r11995 r12330 59 59 } 60 60 /*}}}*/ 61 #ifdef _SERIAL_62 /*FUNCTION DoubleParam::Marshall{{{1*/63 void DoubleParam::Marshall(char** pmarshalled_dataset){64 65 char* marshalled_dataset=NULL;66 int enum_value=0;67 68 /*recover marshalled_dataset: */69 marshalled_dataset=*pmarshalled_dataset;70 71 /*get enum value of DoubleParam: */72 enum_value=DoubleParamEnum;73 74 /*marshall enum: */75 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);76 77 /*marshall DoubleParam data: */78 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);79 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);80 81 *pmarshalled_dataset=marshalled_dataset;82 }83 /*}}}*/84 /*FUNCTION DoubleParam::MarshallSize{{{1*/85 int DoubleParam::MarshallSize(){86 87 return sizeof(value)+88 +sizeof(enum_type)+89 +sizeof(int); //sizeof(int) for enum value90 }91 /*}}}*/92 /*FUNCTION DoubleParam::Demarshall{{{1*/93 void DoubleParam::Demarshall(char** pmarshalled_dataset){94 95 char* marshalled_dataset=NULL;96 int i;97 98 /*recover marshalled_dataset: */99 marshalled_dataset=*pmarshalled_dataset;100 101 /*this time, no need to get enum type, the pointer directly points to the beginning of the102 *object data (thanks to DataSet::Demarshall):*/103 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);104 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);105 106 /*return: */107 *pmarshalled_dataset=marshalled_dataset;108 return;109 }110 /*}}}*/111 #endif112 61 /*FUNCTION DoubleParam::ObjectEnum{{{1*/ 113 62 int DoubleParam::ObjectEnum(void){ … … 133 82 /*FUNCTION DoubleParam::GetParameterValue(int* pinteger){{{1*/ 134 83 void DoubleParam::GetParameterValue(int* pinteger){ 135 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)136 *pinteger=(int)value;137 #else138 84 _error_("Double param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type)); 139 #endif140 85 } 141 86 /*}}}*/ 142 87 /*FUNCTION DoubleParam::GetParameterValue(bool* pbool){{{1*/ 143 88 void DoubleParam::GetParameterValue(bool* pbool){ 144 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)145 146 /*If debugging mode, cheeck that the double is 0 or 1*/147 _assert_(value==0 || value==1);148 *pbool=(bool)value;149 150 #else151 89 _error_("Double param of enum %i (%s) cannot return an bool",enum_type,EnumToStringx(enum_type)); 152 #endif153 90 } 154 91 /*}}}*/ 155 92 /*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM){{{1*/ 156 93 void DoubleParam::GetParameterValue(int** pintarray,int* pM){ 157 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)158 int* output=NULL;159 160 output=(int*)xmalloc(1*sizeof(int));161 *output=(int)value;162 163 /*Assign output pointers:*/164 if(pM) *pM=1;165 *pintarray=output;166 #else167 94 _error_("Double param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type)); 168 #endif169 95 } 170 96 /*}}}*/ 171 97 /*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM,int* pN){{{1*/ 172 98 void DoubleParam::GetParameterValue(int** pintarray,int* pM,int* pN){ 173 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)174 int* output=NULL;175 176 output=(int*)xmalloc(1*sizeof(int));177 *output=(int)value;178 179 /*Assign output pointers:*/180 if(pM) *pM=1;181 if(pN) *pN=1;182 *pintarray=output;183 #else184 99 _error_("Double param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type)); 185 #endif186 100 } 187 101 /*}}}*/ 188 102 /*FUNCTION DoubleParam::GetParameterValue(double** pdoublearray,int* pM){{{1*/ 189 103 void DoubleParam::GetParameterValue(double** pdoublearray,int* pM){ 190 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)191 double* output=NULL;192 193 output=(double*)xmalloc(1*sizeof(double));194 *output=(double)value;195 196 /*Assign output podoubleers:*/197 if(pM) *pM=1;198 *pdoublearray=output;199 #else200 104 _error_("Double param of enum %i (%s) cannot return an array of double",enum_type,EnumToStringx(enum_type)); 201 #endif202 105 } 203 106 /*}}}*/ 204 107 /*FUNCTION DoubleParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){{{1*/ 205 108 void DoubleParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){ 206 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)207 double* output=NULL;208 209 output=(double*)xmalloc(1*sizeof(double));210 *output=(double)value;211 212 /*Assign output podoubleers:*/213 if(pM) *pM=1;214 if(pN) *pN=1;215 *pdoublearray=output;216 #else217 109 _error_("Double param of enum %i (%s) cannot return an array of double",enum_type,EnumToStringx(enum_type)); 218 #endif219 110 } 220 /*}}}*/221 /*FUNCTION DoubleParam::SetMatlabField{{{1*/222 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)223 void DoubleParam::SetMatlabField(mxArray* dataref){224 225 char* name=NULL;226 this->GetParameterName(&name);227 mxSetField( dataref, 0, name,mxCreateDoubleScalar(value));228 }229 #endif230 111 /*}}}*/ 231 112 /*FUNCTION DoubleParam::UnitConversion{{{1*/ -
issm/trunk/src/c/objects/Params/DoubleParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 42 38 int Id(); 43 39 int MyRank(); 44 #ifdef _SERIAL_45 void Marshall(char** pmarshalled_dataset);46 int MarshallSize();47 void Demarshall(char** pmarshalled_dataset);48 #endif49 40 int ObjectEnum(); 50 41 Object* copy(); … … 82 73 83 74 void GetParameterName(char**pname); 84 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)85 void SetMatlabField(mxArray* dataref);86 #endif87 75 88 76 /*}}}*/ -
issm/trunk/src/c/objects/Params/DoubleTransientMatParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 -
issm/trunk/src/c/objects/Params/DoubleVecParam.cpp
r11995 r12330 75 75 } 76 76 /*}}}*/ 77 #ifdef _SERIAL_78 /*FUNCTION DoubleVecParam::Marshall{{{1*/79 void DoubleVecParam::Marshall(char** pmarshalled_dataset){80 81 char* marshalled_dataset=NULL;82 int enum_value=0;83 84 /*recover marshalled_dataset: */85 marshalled_dataset=*pmarshalled_dataset;86 87 /*get enum value of DoubleVecParam: */88 enum_value=DoubleVecParamEnum;89 90 /*marshall enum: */91 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);92 93 /*marshall DoubleVecParam data: */94 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);95 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);96 memcpy(marshalled_dataset,values,M*sizeof(double));marshalled_dataset+=M*sizeof(double);97 98 *pmarshalled_dataset=marshalled_dataset;99 }100 /*}}}*/101 /*FUNCTION DoubleVecParam::MarshallSize{{{1*/102 int DoubleVecParam::MarshallSize(){103 104 return sizeof(M)105 +M*sizeof(double)106 +sizeof(enum_type)+107 +sizeof(int); //sizeof(int) for enum value108 }109 /*}}}*/110 /*FUNCTION DoubleVecParam::Demarshall{{{1*/111 void DoubleVecParam::Demarshall(char** pmarshalled_dataset){112 113 char* marshalled_dataset=NULL;114 int i;115 116 /*recover marshalled_dataset: */117 marshalled_dataset=*pmarshalled_dataset;118 119 /*this time, no need to get enum type, the pointer directly points to the beginning of the120 *object data (thanks to DataSet::Demarshall):*/121 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);122 123 /*data: */124 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);125 values=(double*)xmalloc(M*sizeof(double));126 memcpy(values,marshalled_dataset,M*sizeof(double));marshalled_dataset+=M*sizeof(double);127 128 /*return: */129 *pmarshalled_dataset=marshalled_dataset;130 return;131 }132 /*}}}*/133 #endif134 77 /*FUNCTION DoubleVecParam::ObjectEnum{{{1*/ 135 78 int DoubleVecParam::ObjectEnum(void){ … … 181 124 /*FUNCTION DoubleVecParam::GetParameterValue(int** pintarray,int* pM){{{1*/ 182 125 void DoubleVecParam::GetParameterValue(int** pintarray,int* pM){ 183 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)184 int* output=NULL;185 int i;186 187 /*Cast values into integers*/188 output=(int*)xmalloc(M*sizeof(int));189 for(i=0;i<M;i++) output[i]=(int)values[i];190 191 /*Assign output pointers:*/192 if(pM) *pM=M;193 *pintarray=output;194 #else195 126 _error_("DoubleVec param of enum %i (%s) cannot return an array of int",enum_type,EnumToStringx(enum_type)); 196 #endif197 127 } 198 128 /*}}}*/ … … 201 131 EnumToStringx(pname,this->enum_type); 202 132 } 203 /*}}}*/204 /*FUNCTION DoubleVecParam::SetMatlabField{{{1*/205 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)206 void DoubleVecParam::SetMatlabField(mxArray* dataref){207 208 char* name=NULL;209 double* doublevec=NULL;210 mxArray* pfield=NULL;211 212 this->GetParameterValue(&doublevec,NULL);213 this->GetParameterName(&name);214 215 pfield=mxCreateDoubleMatrix(0,0,mxREAL);216 mxSetM(pfield,M);217 mxSetN(pfield,1);218 mxSetPr(pfield,doublevec);219 220 mxSetField( dataref, 0, name, pfield);221 }222 #endif223 133 /*}}}*/ 224 134 /*FUNCTION DoubleVecParam::SetValue{{{1*/ -
issm/trunk/src/c/objects/Params/DoubleVecParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 42 38 int Id(); 43 39 int MyRank(); 44 #ifdef _SERIAL_45 void Marshall(char** pmarshalled_dataset);46 int MarshallSize();47 void Demarshall(char** pmarshalled_dataset);48 #endif49 40 int ObjectEnum(); 50 41 Object* copy(); … … 82 73 83 74 void GetParameterName(char**pname); 84 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)85 void SetMatlabField(mxArray* dataref);86 #endif87 75 /*}}}*/ 88 76 }; -
issm/trunk/src/c/objects/Params/FileParam.cpp
r11995 r12330 62 62 } 63 63 /*}}}*/ 64 #ifdef _SERIAL_65 /*FUNCTION FileParam::Marshall{{{1*/66 void FileParam::Marshall(char** pmarshalled_dataset){67 68 _error_("FileParam is a pointer and cannot be marshalled");69 }70 /*}}}*/71 /*FUNCTION FileParam::MarshallSize{{{1*/72 int FileParam::MarshallSize(){73 _error_("FileParam is a pointer and cannot be marshalled");74 }75 /*}}}*/76 /*FUNCTION FileParam::Demarshall{{{1*/77 void FileParam::Demarshall(char** pmarshalled_dataset){78 _error_("FileParam is a pointer and cannot be marshalled");79 }80 /*}}}*/81 #endif82 64 /*FUNCTION FileParam::ObjectEnum{{{1*/ 83 65 int FileParam::ObjectEnum(void){ … … 101 83 } 102 84 /*}}}*/ 103 /*FUNCTION FileParam::SetMatlabField{{{1*/104 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)105 void FileParam::SetMatlabField(mxArray* dataref){106 107 _error_("FileParam is a pointer and cannot be converted into a matlab object");108 }109 #endif110 /*}}}*/111 85 /*FUNCTION FileParam::UnitConversion{{{1*/ 112 86 void FileParam::UnitConversion(int direction_enum){ -
issm/trunk/src/c/objects/Params/FileParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 41 37 int Id(); 42 38 int MyRank(); 43 #ifdef _SERIAL_44 void Marshall(char** pmarshalled_dataset);45 int MarshallSize();46 void Demarshall(char** pmarshalled_dataset);47 #endif48 39 int ObjectEnum(); 49 40 Object* copy(); … … 81 72 82 73 void GetParameterName(char**pname); 83 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)84 void SetMatlabField(mxArray* dataref);85 #endif86 74 87 75 /*}}}*/ -
issm/trunk/src/c/objects/Params/IntMatParam.cpp
r11995 r12330 78 78 } 79 79 /*}}}*/ 80 #ifdef _SERIAL_81 /*FUNCTION IntMatParam::Marshall{{{1*/82 void IntMatParam::Marshall(char** pmarshalled_dataset){83 84 char* marshalled_dataset=NULL;85 int enum_value=0;86 87 /*recover marshalled_dataset: */88 marshalled_dataset=*pmarshalled_dataset;89 90 /*get enum value of IntMatParam: */91 enum_value=IntMatParamEnum;92 93 /*marshall enum: */94 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);95 96 /*marshall IntMatParam data: */97 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);98 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);99 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);100 memcpy(marshalled_dataset,value,M*N*sizeof(int));marshalled_dataset+=M*N*sizeof(int);101 102 *pmarshalled_dataset=marshalled_dataset;103 }104 /*}}}*/105 /*FUNCTION IntMatParam::MarshallSize{{{1*/106 int IntMatParam::MarshallSize(){107 108 return sizeof(M)109 +sizeof(N)110 +M*N*sizeof(int)111 +sizeof(enum_type)+112 +sizeof(int); //sizeof(int) for enum value113 }114 /*}}}*/115 /*FUNCTION IntMatParam::Demarshall{{{1*/116 void IntMatParam::Demarshall(char** pmarshalled_dataset){117 118 char* marshalled_dataset=NULL;119 int i;120 121 /*recover marshalled_dataset: */122 marshalled_dataset=*pmarshalled_dataset;123 124 /*this time, no need to get enum type, the pointer directly points to the beginning of the125 *object data (thanks to DataSet::Demarshall):*/126 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);127 128 /*data: */129 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);130 memcpy(&N,marshalled_dataset,sizeof(N));marshalled_dataset+=sizeof(N);131 value=(int*)xmalloc(M*N*sizeof(int));132 memcpy(value,marshalled_dataset,M*N*sizeof(int));marshalled_dataset+=M*N*sizeof(int);133 134 /*return: */135 *pmarshalled_dataset=marshalled_dataset;136 return;137 }138 /*}}}*/139 #endif140 80 /*FUNCTION IntMatParam::ObjectEnum{{{1*/ 141 81 int IntMatParam::ObjectEnum(void){ … … 172 112 } 173 113 /*}}}*/ 174 /*FUNCTION IntMatParam::SetMatlabField{{{1*/175 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)176 void IntMatParam::SetMatlabField(mxArray* dataref){177 178 char *name = NULL;179 double *doublearray = NULL;180 int *intarray = NULL;181 mxArray *pfield = NULL;182 mxArray *pfield2 = NULL;183 184 this->GetParameterValue(&intarray,NULL,NULL);185 this->GetParameterName(&name);186 187 /*cast intarray into doublearray for Matlab*/188 doublearray=(double*)xmalloc(M*N*sizeof(double));189 for(int i=0;i<M*N;i++)doublearray[i]=(double)intarray[i];190 xfree((void**)&intarray);191 192 pfield=mxCreateDoubleMatrix(0,0,mxREAL);193 mxSetM(pfield,M);194 mxSetN(pfield,N);195 mxSetPr(pfield,doublearray);196 197 //transpose the matrix, written directly to matlab! from C to matlab.198 mexCallMATLAB(1,&pfield2, 1, &pfield, "transpose");199 mxSetField( dataref, 0, name,pfield2);200 }201 #endif202 /*}}}*/203 114 /*FUNCTION IntMatParam::SetValue{{{1*/ 204 115 void IntMatParam::SetValue(int* intarray,int in_M,int in_N){ -
issm/trunk/src/c/objects/Params/IntMatParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 43 39 int Id(); 44 40 int MyRank(); 45 #ifdef _SERIAL_46 void Marshall(char** pmarshalled_dataset);47 int MarshallSize();48 void Demarshall(char** pmarshalled_dataset);49 #endif50 41 int ObjectEnum(); 51 42 Object* copy(); … … 83 74 84 75 void GetParameterName(char**pname); 85 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)86 void SetMatlabField(mxArray* dataref);87 #endif88 76 89 77 /*}}}*/ -
issm/trunk/src/c/objects/Params/IntParam.cpp
r11995 r12330 62 62 } 63 63 /*}}}*/ 64 #ifdef _SERIAL_65 /*FUNCTION IntParam::Marshall{{{1*/66 void IntParam::Marshall(char** pmarshalled_dataset){67 68 char* marshalled_dataset=NULL;69 int enum_value=0;70 71 /*recover marshalled_dataset: */72 marshalled_dataset=*pmarshalled_dataset;73 74 /*get enum value of IntParam: */75 enum_value=IntParamEnum;76 77 /*marshall enum: */78 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);79 80 /*marshall IntParam data: */81 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);82 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);83 84 *pmarshalled_dataset=marshalled_dataset;85 }86 /*}}}*/87 /*FUNCTION IntParam::MarshallSize{{{1*/88 int IntParam::MarshallSize(){89 90 return sizeof(value)+91 +sizeof(enum_type)+92 +sizeof(int); //sizeof(int) for enum value93 }94 /*}}}*/95 /*FUNCTION IntParam::Demarshall{{{1*/96 void IntParam::Demarshall(char** pmarshalled_dataset){97 98 char* marshalled_dataset=NULL;99 int i;100 101 /*recover marshalled_dataset: */102 marshalled_dataset=*pmarshalled_dataset;103 104 /*this time, no need to get enum type, the pointer directly points to the beginning of the105 *object data (thanks to DataSet::Demarshall):*/106 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);107 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);108 109 /*return: */110 *pmarshalled_dataset=marshalled_dataset;111 return;112 }113 /*}}}*/114 #endif115 64 /*FUNCTION IntParam::ObjectEnum{{{1*/ 116 65 int IntParam::ObjectEnum(void){ … … 134 83 } 135 84 /*}}}*/ 136 /*FUNCTION IntParam::SetMatlabField{{{1*/137 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)138 void IntParam::SetMatlabField(mxArray* dataref){139 140 char* name=NULL;141 this->GetParameterName(&name);142 mxSetField( dataref, 0, name,mxCreateDoubleScalar((double)value));143 }144 #endif145 /*}}}*/146 85 /*FUNCTION IntParam::UnitConversion{{{1*/ 147 86 void IntParam::UnitConversion(int direction_enum){ -
issm/trunk/src/c/objects/Params/IntParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 42 38 int Id(); 43 39 int MyRank(); 44 #ifdef _SERIAL_45 void Marshall(char** pmarshalled_dataset);46 int MarshallSize();47 void Demarshall(char** pmarshalled_dataset);48 #endif49 40 int ObjectEnum(); 50 41 Object* copy(); … … 82 73 83 74 void GetParameterName(char**pname); 84 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)85 void SetMatlabField(mxArray* dataref);86 #endif87 75 88 76 /*}}}*/ -
issm/trunk/src/c/objects/Params/IntVecParam.cpp
r11995 r12330 91 91 } 92 92 /*}}}*/ 93 #ifdef _SERIAL_94 /*FUNCTION IntVecParam::Marshall{{{1*/95 void IntVecParam::Marshall(char** pmarshalled_dataset){96 97 char* marshalled_dataset=NULL;98 int enum_value=0;99 100 /*recover marshalled_dataset: */101 marshalled_dataset=*pmarshalled_dataset;102 103 /*get enum value of IntVecParam: */104 enum_value=IntVecParamEnum;105 106 /*marshall enum: */107 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);108 109 /*marshall IntVecParam data: */110 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);111 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);112 if(M)memcpy(marshalled_dataset,values,M*sizeof(int));marshalled_dataset+=M*sizeof(int);113 114 *pmarshalled_dataset=marshalled_dataset;115 }116 /*}}}*/117 /*FUNCTION IntVecParam::MarshallSize{{{1*/118 int IntVecParam::MarshallSize(){119 120 return sizeof(M)+121 +M*sizeof(int)122 +sizeof(enum_type)+123 +sizeof(int); //sizeof(int) for enum value124 }125 /*}}}*/126 /*FUNCTION IntVecParam::Demarshall{{{1*/127 void IntVecParam::Demarshall(char** pmarshalled_dataset){128 129 char* marshalled_dataset=NULL;130 int i;131 132 /*recover marshalled_dataset: */133 marshalled_dataset=*pmarshalled_dataset;134 135 /*this time, no need to get enum type, the pointer directly points to the beginning of the136 *object data (thanks to DataSet::Demarshall):*/137 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);138 139 /*data: */140 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);141 if(M) {142 values=(int*)xmalloc(M*sizeof(int));143 memcpy(values,marshalled_dataset,M*sizeof(int));marshalled_dataset+=M*sizeof(int);144 }145 146 /*return: */147 *pmarshalled_dataset=marshalled_dataset;148 return;149 }150 /*}}}*/151 #endif152 93 /*FUNCTION IntVecParam::ObjectEnum{{{1*/ 153 94 int IntVecParam::ObjectEnum(void){ … … 185 126 } 186 127 /*}}}*/ 187 /*FUNCTION IntVecParam::SetMatlabField{{{1*/188 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)189 void IntVecParam::SetMatlabField(mxArray* dataref){190 191 char *name = NULL;192 double *doublevec = NULL;193 int *intvec = NULL;194 mxArray *pfield = NULL;195 196 this->GetParameterValue(&intvec,NULL);197 this->GetParameterName(&name);198 199 /*cast intvec into doublevec for Matlab*/200 if(M){201 doublevec=(double*)xmalloc(M*sizeof(double));202 for(int i=0;i<M;i++)doublevec[i]=(double)intvec[i];203 }204 else doublevec=NULL;205 xfree((void**)&intvec);206 207 pfield=mxCreateDoubleMatrix(0,0,mxREAL);208 mxSetM(pfield,M);209 mxSetN(pfield,1);210 mxSetPr(pfield,doublevec);211 212 mxSetField(dataref, 0, name, pfield);213 }214 #endif215 /*}}}*/216 128 /*FUNCTION IntVecParam::SetValue{{{1*/ 217 129 void IntVecParam::SetValue(int* intarray,int in_M){ -
issm/trunk/src/c/objects/Params/IntVecParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 43 39 int Id(); 44 40 int MyRank(); 45 #ifdef _SERIAL_46 void Marshall(char** pmarshalled_dataset);47 int MarshallSize();48 void Demarshall(char** pmarshalled_dataset);49 #endif50 41 int ObjectEnum(); 51 42 Object* copy(); … … 83 74 84 75 void GetParameterName(char**pname); 85 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)86 void SetMatlabField(mxArray* dataref);87 #endif88 76 /*}}}*/ 89 77 }; -
issm/trunk/src/c/objects/Params/MatrixParam.cpp
r11995 r12330 70 70 } 71 71 /*}}}*/ 72 #ifdef _SERIAL_73 /*FUNCTION MatrixParam::Marshall{{{1*/74 void MatrixParam::Marshall(char** pmarshalled_dataset){75 76 char* marshalled_dataset=NULL;77 int enum_value=0;78 int M,N;79 double* serial_mat=NULL;80 81 /*recover marshalled_dataset: */82 marshalled_dataset=*pmarshalled_dataset;83 84 /*get enum value of MatrixParam: */85 enum_value=MatrixParamEnum;86 87 /*marshall enum: */88 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);89 90 /*marshall MatrixParam data: */91 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);92 if(value){93 value->GetSize(&M,&N);94 serial_mat=value->ToSerial();95 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);96 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);97 memcpy(marshalled_dataset,serial_mat,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double));98 }99 else{100 M=0;101 N=0;102 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);103 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N);104 }105 106 /*Free ressources:*/107 xfree((void**)&serial_mat);108 109 /*return:*/110 *pmarshalled_dataset=marshalled_dataset;111 }112 /*}}}*/113 /*FUNCTION MatrixParam::MarshallSize{{{1*/114 int MatrixParam::MarshallSize(){115 116 int M=0;117 int N=0;118 if(value)value->GetSize(&M,&N);119 120 return sizeof(M)+121 sizeof(N)+122 M*N*sizeof(double)+123 +sizeof(enum_type)+124 +sizeof(int); //sizeof(int) for enum value125 }126 /*}}}*/127 /*FUNCTION MatrixParam::Demarshall{{{1*/128 void MatrixParam::Demarshall(char** pmarshalled_dataset){129 130 char* marshalled_dataset=NULL;131 int M,N;132 double* serial_mat=NULL;133 134 /*recover marshalled_dataset: */135 marshalled_dataset=*pmarshalled_dataset;136 137 /*this time, no need to get enum type, the pointer directly points to the beginning of the138 *object data (thanks to DataSet::Demarshall):*/139 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);140 141 /*data: */142 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);143 memcpy(&N,marshalled_dataset,sizeof(N));marshalled_dataset+=sizeof(N);144 if(M!=0 && N!=0){145 serial_mat=(double*)xmalloc(M*N*sizeof(double));146 memcpy(serial_mat,marshalled_dataset,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double));147 value=new Matrix(serial_mat,M,N,.001);148 }149 else{150 value=NULL;151 }152 153 /*Free ressources:*/154 xfree((void**)&serial_mat);155 156 /*return: */157 *pmarshalled_dataset=marshalled_dataset;158 }159 /*}}}*/160 #endif161 72 /*FUNCTION MatrixParam::ObjectEnum{{{1*/ 162 73 int MatrixParam::ObjectEnum(void){ … … 190 101 } 191 102 /*}}}*/ 192 /*FUNCTION MatrixParam::SetMatlabField{{{1*/193 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)194 void MatrixParam::SetMatlabField(mxArray* dataref){195 196 char* name=NULL;197 int M,N;198 double* doublemat=NULL;199 mxArray* pfield=NULL;200 201 doublemat=value->ToSerial();202 value->GetSize(&M,&N);203 this->GetParameterName(&name);204 205 pfield=mxCreateDoubleMatrix(0,0,mxREAL);206 mxSetM(pfield,M);207 mxSetN(pfield,N);208 mxSetPr(pfield,doublemat);209 mxSetField( dataref, 0, name, pfield);210 }211 #endif212 /*}}}*/213 103 /*FUNCTION MatrixParam::SetValue{{{1*/ 214 104 void MatrixParam::SetValue(Matrix* matrix){ -
issm/trunk/src/c/objects/Params/MatrixParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 42 38 int Id(); 43 39 int MyRank(); 44 #ifdef _SERIAL_45 void Marshall(char** pmarshalled_dataset);46 int MarshallSize();47 void Demarshall(char** pmarshalled_dataset);48 #endif49 40 int ObjectEnum(); 50 41 Object* copy(); … … 82 73 83 74 void GetParameterName(char**pname); 84 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)85 void SetMatlabField(mxArray* dataref);86 #endif87 75 88 76 /*}}}*/ -
issm/trunk/src/c/objects/Params/Param.h
r11995 r12330 14 14 #else 15 15 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 16 #endif17 18 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)19 #include <mex.h>20 16 #endif 21 17 … … 60 56 virtual void UnitConversion(int direction_enum)=0; 61 57 virtual void GetParameterName(char**pname)=0; 62 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)63 virtual void SetMatlabField(mxArray* dataref)=0;64 #endif65 58 }; 66 59 #endif -
issm/trunk/src/c/objects/Params/StringArrayParam.cpp
r11995 r12330 92 92 } 93 93 /*}}}*/ 94 #ifdef _SERIAL_95 /*FUNCTION StringArrayParam::Marshall{{{1*/96 void StringArrayParam::Marshall(char** pmarshalled_dataset){97 98 int i;99 char* marshalled_dataset=NULL;100 int enum_value=0;101 int stringsize;102 char* string=NULL;103 104 /*recover marshalled_dataset: */105 marshalled_dataset=*pmarshalled_dataset;106 107 /*get enum value of StringArrayParam: */108 enum_value=StringArrayParamEnum;109 110 /*marshall enum: */111 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);112 113 /*marshall data: */114 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);115 memcpy(marshalled_dataset,&numstrings,sizeof(numstrings));marshalled_dataset+=sizeof(numstrings);116 for(i=0;i<numstrings;i++){117 string=this->value[i];118 stringsize=strlen(string)+1;119 120 memcpy(marshalled_dataset,&stringsize,sizeof(stringsize));marshalled_dataset+=sizeof(stringsize);121 memcpy(marshalled_dataset,string,stringsize*sizeof(char));marshalled_dataset+=stringsize*sizeof(char);122 }123 124 *pmarshalled_dataset=marshalled_dataset;125 }126 /*}}}*/127 /*FUNCTION StringArrayParam::MarshallSize{{{1*/128 int StringArrayParam::MarshallSize(){129 130 int i;131 int marshallsize=0;132 int stringsize;133 char* string=NULL;134 135 marshallsize+=sizeof(numstrings);136 137 for(i=0;i<numstrings;i++){138 string=this->value[i];139 stringsize=strlen(string)+1;140 marshallsize+=sizeof(stringsize);141 marshallsize+=stringsize*sizeof(char);142 }143 144 marshallsize+=sizeof(enum_type);145 marshallsize+=sizeof(int); //sizeof(int) for enum value146 147 return marshallsize;148 }149 /*}}}*/150 /*FUNCTION StringArrayParam::Demarshall{{{1*/151 void StringArrayParam::Demarshall(char** pmarshalled_dataset){152 153 char* marshalled_dataset=NULL;154 int i;155 int stringsize;156 char* string=NULL;157 158 /*recover marshalled_dataset: */159 marshalled_dataset=*pmarshalled_dataset;160 161 /*this time, no need to get enum type, the pointer directly points to the beginning of the162 *object data (thanks to DataSet::Demarshall):*/163 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);164 165 memcpy(&numstrings,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);166 if(numstrings){167 this->value=(char**)xmalloc(numstrings*sizeof(char*));168 169 for(i=0;i<numstrings;i++){170 memcpy(&stringsize,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);171 172 string=(char*)xmalloc(stringsize*sizeof(char));173 memcpy(string,marshalled_dataset,stringsize*sizeof(char));marshalled_dataset+=stringsize*sizeof(char);174 175 this->value[i]=string;176 }177 }178 else this->value=NULL;179 180 /*return: */181 *pmarshalled_dataset=marshalled_dataset;182 return;183 }184 /*}}}*/185 #endif186 94 /*FUNCTION StringArrayParam::ObjectEnum{{{1*/ 187 95 int StringArrayParam::ObjectEnum(void){ … … 236 144 } 237 145 /*}}}*/ 238 /*FUNCTION StringArrayParam::SetMatlabField{{{1*/239 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)240 void StringArrayParam::SetMatlabField(mxArray* dataref){241 242 int i;243 char* name=NULL;244 mwSize dims[2]={0};245 mxArray* pfield=NULL;246 247 this->GetParameterName(&name);248 249 dims[0]=this->numstrings;250 dims[1]=1;251 pfield=mxCreateCellArray(2,dims);252 for(i=0;i<this->numstrings;i++){253 char* string=value[i];254 mxSetCell(pfield,i,mxCreateString(string));255 }256 mxSetField( dataref, 0, name,pfield);257 }258 #endif259 /*}}}*/260 146 /*FUNCTION StringArrayParam::SetValue{{{1*/ 261 147 void StringArrayParam::SetValue(char** stringarray,int M){ -
issm/trunk/src/c/objects/Params/StringArrayParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 44 40 int Id(); 45 41 int MyRank(); 46 #ifdef _SERIAL_47 void Marshall(char** pmarshalled_dataset);48 int MarshallSize();49 void Demarshall(char** pmarshalled_dataset);50 #endif51 42 int ObjectEnum(); 52 43 Object* copy(); … … 84 75 85 76 void GetParameterName(char**pname); 86 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)87 void SetMatlabField(mxArray* dataref);88 #endif89 77 /*}}}*/ 90 78 }; -
issm/trunk/src/c/objects/Params/StringParam.cpp
r11995 r12330 64 64 } 65 65 /*}}}*/ 66 #ifdef _SERIAL_67 /*FUNCTION StringParam::Marshall{{{1*/68 void StringParam::Marshall(char** pmarshalled_dataset){69 70 char* marshalled_dataset=NULL;71 int enum_value=0;72 int stringsize;73 74 /*recover marshalled_dataset: */75 marshalled_dataset=*pmarshalled_dataset;76 77 /*get enum value of StringParam: */78 enum_value=StringParamEnum;79 80 /*marshall enum: */81 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);82 83 /*marshall data: */84 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);85 stringsize=strlen(this->value)+1;86 87 memcpy(marshalled_dataset,&stringsize,sizeof(stringsize));marshalled_dataset+=sizeof(stringsize);88 memcpy(marshalled_dataset,this->value,stringsize*sizeof(char));marshalled_dataset+=stringsize*sizeof(char);89 90 *pmarshalled_dataset=marshalled_dataset;91 }92 /*}}}*/93 /*FUNCTION StringParam::MarshallSize{{{1*/94 int StringParam::MarshallSize(){95 96 int stringsize;97 stringsize=strlen(this->value)+1;98 99 return sizeof(int)+100 stringsize*sizeof(char)+101 sizeof(enum_type)+102 sizeof(int); //sizeof(int) for enum value103 }104 /*}}}*/105 /*FUNCTION StringParam::Demarshall{{{1*/106 void StringParam::Demarshall(char** pmarshalled_dataset){107 108 char* marshalled_dataset=NULL;109 int i;110 int stringsize;111 112 /*recover marshalled_dataset: */113 marshalled_dataset=*pmarshalled_dataset;114 115 /*this time, no need to get enum type, the pointer directly points to the beginning of the116 *object data (thanks to DataSet::Demarshall):*/117 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);118 119 memcpy(&stringsize,marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);120 121 this->value=(char*)xmalloc(stringsize*sizeof(char));122 memcpy(this->value,marshalled_dataset,stringsize*sizeof(char));marshalled_dataset+=stringsize*sizeof(char);123 124 /*return: */125 *pmarshalled_dataset=marshalled_dataset;126 return;127 }128 /*}}}*/129 #endif130 66 /*FUNCTION StringParam::ObjectEnum{{{1*/ 131 67 int StringParam::ObjectEnum(void){ … … 164 100 } 165 101 /*}}}*/ 166 /*FUNCTION StringParam::SetMatlabField{{{1*/167 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)168 void StringParam::SetMatlabField(mxArray* dataref){169 170 char* name=NULL;171 172 this->GetParameterName(&name);173 mxSetField( dataref, 0, name, mxCreateString(value));174 }175 #endif176 /*}}}*/177 102 /*FUNCTION StringParam::SetValue{{{1*/ 178 103 void StringParam::SetValue(char* string){ -
issm/trunk/src/c/objects/Params/StringParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 42 38 int Id(); 43 39 int MyRank(); 44 #ifdef _SERIAL_45 void Marshall(char** pmarshalled_dataset);46 int MarshallSize();47 void Demarshall(char** pmarshalled_dataset);48 #endif49 40 int ObjectEnum(); 50 41 Object* copy(); … … 82 73 83 74 void GetParameterName(char**pname); 84 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)85 void SetMatlabField(mxArray* dataref);86 #endif87 75 88 76 /*}}}*/ -
issm/trunk/src/c/objects/Params/VectorParam.cpp
r11995 r12330 72 72 } 73 73 /*}}}*/ 74 #ifdef _SERIAL_75 /*FUNCTION VectorParam::Marshall{{{1*/76 void VectorParam::Marshall(char** pmarshalled_dataset){77 78 char* marshalled_dataset=NULL;79 int enum_value=0;80 int M;81 double* serial_value=NULL;82 83 /*recover marshalled_dataset: */84 marshalled_dataset=*pmarshalled_dataset;85 86 /*get enum value of VectorParam: */87 enum_value=VectorParamEnum;88 89 /*marshall enum: */90 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);91 92 /*marshall VectorParam data: */93 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);94 if(value){95 value->GetSize(&M);96 serial_value=value->ToMPISerial();97 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);98 memcpy(marshalled_dataset,serial_value,M*sizeof(double));marshalled_dataset+=(M*sizeof(double));99 }100 else{101 M=0;102 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);103 }104 /*Free ressources:*/105 xfree((void**)&serial_value);106 107 /*return:*/108 *pmarshalled_dataset=marshalled_dataset;109 }110 /*}}}*/111 /*FUNCTION VectorParam::MarshallSize{{{1*/112 int VectorParam::MarshallSize(){113 114 int M=0;115 if(value)value->GetSize(&M);116 117 return sizeof(M)+M*sizeof(double)118 +sizeof(enum_type)+119 +sizeof(int); //sizeof(int) for enum value120 }121 /*}}}*/122 /*FUNCTION VectorParam::Demarshall{{{1*/123 void VectorParam::Demarshall(char** pmarshalled_dataset){124 125 char* marshalled_dataset=NULL;126 int i;127 double* serial_vec=NULL;128 int M;129 130 /*recover marshalled_dataset: */131 marshalled_dataset=*pmarshalled_dataset;132 133 /*this time, no need to get enum type, the pointer directly points to the beginning of the134 *object data (thanks to DataSet::Demarshall):*/135 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);136 137 /*data: */138 139 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);140 if(M){141 serial_vec=(double*)xmalloc(M*sizeof(double));142 memcpy(serial_vec,marshalled_dataset,M*sizeof(double));marshalled_dataset+=(M*sizeof(double));143 144 value=new Vector(serial_vec,M);145 }146 else{147 value=NULL;148 }149 150 /*Free ressources:*/151 xfree((void**)&serial_vec);152 153 /*return: */154 *pmarshalled_dataset=marshalled_dataset;155 }156 /*}}}*/157 #endif158 74 /*FUNCTION VectorParam::ObjectEnum{{{1*/ 159 75 int VectorParam::ObjectEnum(void){ … … 188 104 } 189 105 /*}}}*/ 190 /*FUNCTION VectorParam::SetMatlabField{{{1*/191 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)192 void VectorParam::SetMatlabField(mxArray* dataref){193 194 mxArray* pfield=NULL;195 char* name=NULL;196 double* doublevec=NULL;197 int M;198 199 doublevec=value->ToMPISerial();200 value->GetSize(&M);201 this->GetParameterName(&name);202 203 pfield=mxCreateDoubleMatrix(0,0,mxREAL);204 mxSetM(pfield,M);205 mxSetN(pfield,1);206 mxSetPr(pfield,doublevec);207 208 mxSetField( dataref, 0, name, pfield);209 }210 #endif211 /*}}}*/212 106 /*FUNCTION VectorParam::SetValue{{{1*/ 213 107 void VectorParam::SetValue(Vector* vector){ -
issm/trunk/src/c/objects/Params/VectorParam.h
r11995 r12330 13 13 #else 14 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif16 17 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)18 #include <mex.h>19 15 #endif 20 16 … … 42 38 int Id(); 43 39 int MyRank(); 44 #ifdef _SERIAL_45 void Marshall(char** pmarshalled_dataset);46 int MarshallSize();47 void Demarshall(char** pmarshalled_dataset);48 #endif49 40 int ObjectEnum(); 50 41 Object* copy(); … … 82 73 83 74 void GetParameterName(char**pname); 84 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)85 void SetMatlabField(mxArray* dataref);86 #endif87 75 88 76 /*}}}*/ -
issm/trunk/src/c/objects/Patch.cpp
r11527 r12330 120 120 int node_numrows; 121 121 double *total_values = NULL; 122 #ifdef _HAVE_MPI_ 122 123 MPI_Status status; 124 #endif 123 125 124 #ifdef _SERIAL_125 return; //nothing to be done126 #endif127 128 126 /*First, figure out total number of rows combining all the cpus: */ 127 #ifdef _HAVE_MPI_ 129 128 MPI_Reduce(&this->numrows,&total_numrows,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 130 129 MPI_Bcast(&total_numrows,1,MPI_INT,0,MPI_COMM_WORLD); 130 #else 131 total_numrows=this->numrows; 132 #endif 131 133 132 134 /*return if patch empty*/ … … 144 146 145 147 /*Now, ask other nodes to send their values: */ 148 #ifdef _HAVE_MPI_ 146 149 for (i=1;i<num_procs;i++){ 147 150 if (my_rank==i){ … … 155 158 } 156 159 } 160 #endif 157 161 158 162 /*Now, node 0 has total_values, of size total_numrows*this->numcols. Update the fields in the patch, to reflect this new … … 163 167 this->values=total_values; 164 168 } 169 #ifdef _HAVE_MPI_ 165 170 else{ 166 171 this->numrows=0; 167 172 xfree((void**)&this->values); 168 173 } 174 #endif 169 175 }/*}}}*/ -
issm/trunk/src/c/objects/Patch.h
r10400 r12330 34 34 int maxnodes; // maxnodes corresponds to the largest amout of nodes on a given element, determined by the interpolation type. 35 35 36 double* values; //result values36 IssmDouble* values; //result values 37 37 38 38 Patch(); … … 40 40 ~Patch(); 41 41 void fillelementinfo(int row, int element_id, int* vertices_ids, int num_vertices); 42 void fillresultinfo(int row,int enum_type,int step, double time, int interpolation, double* nodal_values, int num_nodes);42 void fillresultinfo(int row,int enum_type,int step, IssmDouble time, int interpolation, IssmDouble* nodal_values, int num_nodes); 43 43 void Gather(void); 44 44 -
issm/trunk/src/c/objects/Segment.cpp
r9883 r12330 71 71 } 72 72 /*}}}*/ 73 #ifdef _SERIAL_74 /*FUNCTION Segment::Marshall{{{1*/75 void Segment::Marshall(char** pmarshalled_dataset){76 77 _error_(" not supported yet!");78 }79 /*}}}*/80 /*FUNCTION Segment::MarshallSize{{{1*/81 int Segment::MarshallSize(){82 _error_(" not supported yet!");83 }84 /*}}}*/85 /*FUNCTION Segment::Demarshall{{{1*/86 void Segment::Demarshall(char** pmarshalled_dataset){87 _error_(" not supported yet!");88 }89 /*}}}*/90 #endif91 73 /*FUNCTION Segment::ObjectEnum{{{1*/ 92 74 int Segment::ObjectEnum(void){ -
issm/trunk/src/c/objects/Segment.h
r9883 r12330 15 15 public: 16 16 int eid; 17 double x1;18 double y1;19 double x2;20 double y2;17 IssmDouble x1; 18 IssmDouble y1; 19 IssmDouble x2; 20 IssmDouble y2; 21 21 22 22 /*Segment constructors, destructors {{{1*/ 23 23 Segment(); 24 Segment(int eid, double x1,double y1, double x2, double y2);24 Segment(int eid,IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2); 25 25 ~Segment(); 26 26 /*}}}*/ … … 30 30 int Id(); 31 31 int MyRank(); 32 #ifdef _SERIAL_33 void Marshall(char** pmarshalled_dataset);34 int MarshallSize();35 void Demarshall(char** pmarshalled_dataset);36 #endif37 32 int ObjectEnum(); 38 33 Object* copy(); -
issm/trunk/src/c/objects/Update.h
r10576 r12330 15 15 public: 16 16 17 virtual void InputUpdateFromVector( double* vector, int name, int type)=0;17 virtual void InputUpdateFromVector(IssmDouble* vector, int name, int type)=0; 18 18 virtual void InputUpdateFromVector(int* vector, int name, int type)=0; 19 19 virtual void InputUpdateFromVector(bool* vector, int name, int type)=0; 20 20 #ifdef _HAVE_DAKOTA_ 21 virtual void InputUpdateFromMatrixDakota( double* matrix, int rows, int ncols, int name, int type)=0;22 virtual void InputUpdateFromVectorDakota( double* vector, int name, int type)=0;21 virtual void InputUpdateFromMatrixDakota(IssmDouble* matrix, int rows, int ncols, int name, int type)=0; 22 virtual void InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type)=0; 23 23 virtual void InputUpdateFromVectorDakota(int* vector, int name, int type)=0; 24 24 virtual void InputUpdateFromVectorDakota(bool* vector, int name, int type)=0; 25 25 #endif 26 virtual void InputUpdateFromConstant( double constant, int name)=0;26 virtual void InputUpdateFromConstant(IssmDouble constant, int name)=0; 27 27 virtual void InputUpdateFromConstant(int constant, int name)=0; 28 28 virtual void InputUpdateFromConstant(bool constant, int name)=0; 29 virtual void InputUpdateFromSolution( double* solution)=0;29 virtual void InputUpdateFromSolution(IssmDouble* solution)=0; 30 30 virtual void InputUpdateFromIoModel(int index, IoModel* iomodel)=0; 31 31 -
issm/trunk/src/c/objects/Vertex.cpp
r11995 r12330 92 92 } 93 93 /*}}}*/ 94 #ifdef _SERIAL_95 /*FUNCTION Vertex::Marshall {{{1*/96 void Vertex::Marshall(char** pmarshalled_dataset){97 98 char* marshalled_dataset=NULL;99 int enum_type=0;100 101 /*recover marshalled_dataset: */102 marshalled_dataset=*pmarshalled_dataset;103 104 /*get enum type of Vertex: */105 enum_type=VertexEnum;106 107 /*marshall enum: */108 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);109 110 /*marshall Vertex data: */111 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);112 memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);113 memcpy(marshalled_dataset,&x,sizeof(x));marshalled_dataset+=sizeof(x);114 memcpy(marshalled_dataset,&y,sizeof(y));marshalled_dataset+=sizeof(y);115 memcpy(marshalled_dataset,&z,sizeof(z));marshalled_dataset+=sizeof(z);116 memcpy(marshalled_dataset,&sigma,sizeof(sigma));marshalled_dataset+=sizeof(sigma);117 memcpy(marshalled_dataset,&connectivity,sizeof(connectivity));marshalled_dataset+=sizeof(connectivity);118 memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof);119 memcpy(marshalled_dataset,&clone,sizeof(clone));marshalled_dataset+=sizeof(clone);120 121 *pmarshalled_dataset=marshalled_dataset;122 return;123 }124 /*}}}*/125 /*FUNCTION Vertex::MarshallSize {{{1*/126 int Vertex::MarshallSize(){127 128 return sizeof(id)+129 sizeof(sid)+130 sizeof(x)+131 sizeof(y)+132 sizeof(z)+133 sizeof(sigma)+134 sizeof(connectivity)+135 sizeof(dof)+136 sizeof(clone)+137 +sizeof(int); //sizeof(int) for enum type138 }139 /*}}}*/140 /*FUNCTION Vertex::Demarshall {{{1*/141 void Vertex::Demarshall(char** pmarshalled_dataset){142 143 char* marshalled_dataset=NULL;144 int i;145 146 /*recover marshalled_dataset: */147 marshalled_dataset=*pmarshalled_dataset;148 149 /*this time, no need to get enum type, the pointer directly points to the beginning of the150 *object data (thanks to DataSet::Demarshall):*/151 152 memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);153 memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);154 memcpy(&x,marshalled_dataset,sizeof(x));marshalled_dataset+=sizeof(x);155 memcpy(&y,marshalled_dataset,sizeof(y));marshalled_dataset+=sizeof(y);156 memcpy(&z,marshalled_dataset,sizeof(z));marshalled_dataset+=sizeof(z);157 memcpy(&sigma,marshalled_dataset,sizeof(sigma));marshalled_dataset+=sizeof(sigma);158 memcpy(&connectivity,marshalled_dataset,sizeof(connectivity));marshalled_dataset+=sizeof(connectivity);159 memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof);160 memcpy(&clone,marshalled_dataset,sizeof(clone));marshalled_dataset+=sizeof(clone);161 162 /*return: */163 *pmarshalled_dataset=marshalled_dataset;164 return;165 }166 /*}}}*/167 #endif168 94 /*FUNCTION Vertex::ObjectEnum{{{1*/ 169 95 int Vertex::ObjectEnum(void){ -
issm/trunk/src/c/objects/Vertex.h
r11995 r12330 25 25 int id; 26 26 int sid; //sid for "serial" id, ie the rank of this vertex in the vertices dataset, if the dataset was serial on 1 cpu. 27 double x;28 double y;29 double z;30 double sigma; //sigma coordinate: (z-bed)/thickness27 IssmDouble x; 28 IssmDouble y; 29 IssmDouble z; 30 IssmDouble sigma; //sigma coordinate: (z-bed)/thickness 31 31 int connectivity; //number of vertices connected to this vertex 32 32 … … 37 37 /*Vertex constructors, destructors {{{1*/ 38 38 Vertex(); 39 Vertex(int id, int sid, double x, double y, double z, double sigma, int connectivity);40 void Init(int id, int sid, double x, double y, double z, double sigma,int connectivity);39 Vertex(int id, int sid,IssmDouble x, IssmDouble y, IssmDouble z, IssmDouble sigma, int connectivity); 40 void Init(int id, int sid, IssmDouble x, IssmDouble y, IssmDouble z, IssmDouble sigma,int connectivity); 41 41 Vertex(int id, int sid, int i, IoModel* iomodel); 42 42 ~Vertex(); … … 47 47 int Id(); 48 48 int MyRank(); 49 #ifdef _SERIAL_50 void Marshall(char** pmarshalled_dataset);51 int MarshallSize();52 void Demarshall(char** pmarshalled_dataset);53 #endif54 49 int ObjectEnum(); 55 50 Object* copy(); … … 65 60 int Sid(void); 66 61 int Connectivity(void); 67 void UpdatePosition(Vector* vz,Parameters* parameters, double* thickness,double* bed);62 void UpdatePosition(Vector* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed); 68 63 /*}}}*/ 69 64 }; -
issm/trunk/src/c/objects/objects.h
r11995 r12330 170 170 #include "./Bamg/Mesh.h" 171 171 #include "./Bamg/Geometry.h" 172 #include "./Bamg/ QuadTree.h"172 #include "./Bamg/BamgQuadtree.h" 173 173 #include "./Bamg/SetOfE4.h" 174 174 175 /*Kriging*/ 176 #include "./Kriging/Variogram.h" 177 #include "./Kriging/GaussianVariogram.h" 178 #include "./Kriging/ExponentialVariogram.h" 179 #include "./Kriging/SphericalVariogram.h" 180 #include "./Kriging/PowerVariogram.h" 181 #include "./Kriging/Quadtree.h" 182 #include "./Kriging/Observation.h" 183 175 184 #endif -
issm/trunk/src/c/shared/Alloc/alloc.cpp
r11995 r12330 19 19 #endif 20 20 21 #if defined(_SERIAL_) && defined(_HAVE_MATLAB_)22 #include "mex.h"23 #endif24 25 21 #include <stdio.h> 26 22 #include <stdlib.h> … … 37 33 if(!size)_error_(" attempting to 0 size allocation!"); 38 34 39 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)40 /* Use the matlab api to do the allocation: */41 memptr=mxMalloc(size);42 #else43 35 /* Use the c library to do the allocation: */ 44 36 memptr=malloc(size); 45 #endif46 37 if(!memptr) _error_("memory allocation failed!"); 47 38 … … 55 46 if(!size)_error_("attempting to 0 size allocation!"); 56 47 57 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)58 /* Use the matlab api to do the allocation: */59 memptr=mxCalloc(n,size);60 #else61 48 /* Use the c library to do the allocation: */ 62 49 memptr=calloc(n,size); 63 #endif64 50 if(!memptr) _error_("memory allocation failed!"); 65 51 … … 70 56 71 57 if (pv && *pv){ 72 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_) 73 mxFree(*pv); 74 #else 75 free(*pv); 76 #endif 58 free(*pv); 77 59 78 60 *pv=NULL; … … 83 65 84 66 if (pv && *pv){ 85 #ifdef _PARALLEL_86 67 /*There is no mxDelete in the Matlab API -> using delete trips up Matlab. So we 87 68 * don't actually free memory in Matlab, we let the memory manager do that. We only 88 69 * free in parallel: */ 89 70 delete *pv; 90 #else91 /*Actually, still get rid of internal Petsc matrix. Quick fix until Matlab handles C++92 * correctly: */93 #ifdef _HAVE_PETSC_94 MatFree(&(*pv)->matrix);95 #endif96 #endif97 71 *pv=NULL; 98 72 } … … 102 76 103 77 if (pv && *pv){ 104 #ifdef _PARALLEL_105 78 /*There is no mxDelete in the Matlab API -> using delete trips up Matlab. So we 106 79 * don't actually free memory in Matlab, we let the memory manager do that. We only 107 80 * free in parallel: */ 108 81 delete *pv; 109 #else110 /*Actually, still get rid of internal Petsc vector. Quick fix until Matlab handles C++111 * correctly: */112 #ifdef _HAVE_PETSC_113 VecFree(&(*pv)->vector);114 #endif115 #endif116 82 *pv=NULL; 117 83 } … … 124 90 125 91 if(!size)_error_("attempting to realloc to zero"); 126 127 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)128 value = (void*)mxRealloc(pv,size);129 #else130 92 value = (void*)realloc(pv,size); 131 #endif132 93 133 94 if (value == NULL) { -
issm/trunk/src/c/shared/Elements/elements.h
r11995 r12330 47 47 printf("\n"); 48 48 } 49 inline void printbinary(int n) { 50 unsigned int i=1L<<(sizeof(n)*8-1); 51 52 while (i>0) { 53 if (n&i) 54 printf("1"); 55 else 56 printf("0"); 57 i>>=1; 58 } 59 } 49 60 50 61 #endif //ifndef _SHARED_ELEMENTS_H_ -
issm/trunk/src/c/shared/Exceptions/Exceptions.cpp
r11995 r12330 11 11 #include "../shared.h" 12 12 #include "../../include/include.h" 13 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)14 #include "mex.h"15 #endif16 13 17 14 ErrorException::ErrorException(const string &what_arg){ … … 32 29 33 30 ErrorException::~ErrorException() throw(){ 31 extern int num_procs; 32 /*We want the report only for matlab modules, otherwise we get twice the report 33 * We assume that if num_procs==1, it is a module (FIXME)*/ 34 if(num_procs==1) this->Report(); 34 35 } 35 36 … … 40 41 void ErrorException::Report(){ 41 42 extern int my_rank; 43 extern int num_procs; 42 44 43 45 if (function_name=="" || file_line==0){ //WINDOWS … … 45 47 } 46 48 else{ 47 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_) 48 mexErrMsgTxt(exprintf("\n??? Error using ==> %s at %i\n%s error message: %s\n", 49 file_name.c_str(),file_line,function_name.c_str(),what())); 50 #else 49 if(num_procs==1){ 50 printf("\n??? Error using ==> %s:%i\n",file_name.c_str(),file_line); 51 printf("%s error message: %s\n\n",function_name.c_str(),what()); 52 } 53 else{ 51 54 printf("\n[%i] ??? Error using ==> %s:%i\n",my_rank,file_name.c_str(),file_line); 52 55 printf("[%i] %s error message: %s\n\n",my_rank,function_name.c_str(),what()); 53 #endif56 } 54 57 } 55 58 return; -
issm/trunk/src/c/shared/Exceptions/exceptions.h
r11237 r12330 23 23 24 24 public: 25 26 25 ErrorException(const string &what_arg); //for windows 27 26 ErrorException(string what_file,string what_function,int what_line,string what_arg);//UNIX 28 27 ~ErrorException() throw(); 29 30 28 virtual const char *what() const throw(); 31 32 29 void Report(); 33 30 -
issm/trunk/src/c/shared/Exp/DomainOutlineRead.cpp
r11995 r12330 13 13 #include "../../Container/DataSet.h" 14 14 15 int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname,bool whole=true){ 16 15 int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname){ 17 16 18 17 /*indexing: */ … … 102 101 if((x[0]==x[n-1]) && (y[0]==y[n-1])){ 103 102 cl=true; 104 if (!whole) {105 n=n-1;106 }107 103 } 108 104 … … 126 122 } 127 123 128 DataSet* DomainOutlineRead(char* domainname,bool whole=true){ 129 130 /*indexing: */ 131 int i; 124 DataSet* DomainOutlineRead(char* domainname){ 132 125 133 126 /*intermediary: */ 134 int nprof; 135 int* profnvertices=NULL; 136 double** pprofx=NULL; 137 double** pprofy=NULL; 138 139 Contour* contour=NULL; 127 int nprof; 128 int *profnvertices = NULL; 129 double **pprofx = NULL; 130 double **pprofy = NULL; 131 Contour *contour = NULL; 140 132 141 133 /*output: */ 142 134 DataSet* domain=NULL; 143 135 144 /*get domain outline from intermediary function:*/ 145 DomainOutlineRead(&nprof,&profnvertices,&pprofx, &pprofy, NULL,domainname,whole); 136 /*If domainname is an empty string, return empty dataset*/ 137 if (strcmp(domainname,"")==0){ 138 nprof=0; 139 } 140 else{ 141 DomainOutlineRead(&nprof,&profnvertices,&pprofx, &pprofy, NULL,domainname); 142 } 146 143 147 144 /*now create dataset of contours: */ 148 145 domain=new DataSet(0); 149 146 150 for(i =0;i<nprof;i++){147 for(int i=0;i<nprof;i++){ 151 148 domain->AddObject(new Contour(i,profnvertices[i],pprofx[i],pprofy[i],1)); 152 149 } 153 154 150 return domain; 155 151 } -
issm/trunk/src/c/shared/Exp/DomainOutlineWrite.cpp
r9320 r12330 11 11 #include "../Exceptions/exceptions.h" 12 12 13 int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname ,bool whole=true){13 int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname){ 14 14 15 15 … … 20 20 /*I/O: */ 21 21 FILE* fid=NULL; 22 23 /*input: */24 // int nprof; //number of profiles in the domainname file25 // int* profnvertices=NULL; //array holding the number of vertices for the nprof profiles26 // double** pprofx=NULL; //array of profiles x coordinates27 // double** pprofy=NULL; //array of profiles y coordinates28 // bool* closed=NULL; //array holding closed flags for the nprof profiles29 22 30 23 /*open domain outline file for writing: */ … … 43 36 44 37 /*Write number of profile vertices: */ 45 if(closed[counter] && !whole) 46 fprintf(fid,"%u %s\n",profnvertices[counter]+1,"1."); 47 else 48 fprintf(fid,"%u %s\n",profnvertices[counter] ,"1."); 38 fprintf(fid,"%u %s\n",profnvertices[counter] ,"1."); 49 39 50 40 /*Write next line: */ … … 55 45 fprintf(fid,"%lf\t%lf\n",pprofx[counter][i],pprofy[counter][i]); 56 46 } 57 58 /*Now check that we are dealing with open contours: */59 if(closed[counter] && !whole)60 fprintf(fid,"%lf\t%lf\n",pprofx[counter][0],pprofy[counter][0]);61 47 62 48 /*Write blank line: */ -
issm/trunk/src/c/shared/Exp/exp.h
r11995 r12330 13 13 int IsOutsidePoly(Vector* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue); 14 14 int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue); 15 int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname ,bool whole);15 int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname); 16 16 int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue); 17 17 18 int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname ,bool whole);19 DataSet* DomainOutlineRead(char* domainname ,bool whole);18 int DomainOutlineRead(int* pnprof,int** pprofnvertices,double*** ppprofx,double*** ppprofy,bool** pclosed,char* domainname); 19 DataSet* DomainOutlineRead(char* domainname); 20 20 21 21 -
issm/trunk/src/c/shared/Numerics/OptionsFromAnalysis.cpp
r11995 r12330 8 8 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 9 9 #endif 10 11 #include <cstring> 10 12 11 13 #include "../../objects/objects.h" … … 30 32 parameters->FindParam(&strings,&numanalyses,PetscOptionsStringsEnum); 31 33 32 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_) //do not take this away, because ISSM loads analyses as a Double Param instead of a DoubleVec Param when running with only 1 analysis33 if(numanalyses==1){ analyses=(double*)xmalloc(1*sizeof(double)); parameters->FindParam(analyses,PetscOptionsAnalysesEnum);34 }35 else parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum);36 #else37 34 parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum); 38 #endif39 35 40 36 if(numanalyses==0)return NULL; //we did not find petsc options, don't bother. -
issm/trunk/src/c/shared/Numerics/Synchronize.sh
r11527 r12330 2 2 #Synchronize Verbosity 3 3 #first remove existing files 4 rm $ISSM_ TIER/src/m/shared/Verb*.m4 rm $ISSM_DIR/src/m/shared/Verb*.m 5 5 6 6 echo "Synchronizing Verbosity levels..." … … 29 29 #include "../../include/macros.h" 30 30 #include "../Exceptions/exceptions.h" 31 #ifdef _SERIAL_32 #include <mex.h>33 #endif34 31 /*}}}*/ 35 32 … … 54 51 55 52 #Add Verbosity Matlab file{{{ 56 cat <<END > $ISSM_ TIER"/src/m/shared/"$(echo $FILENAME".m")53 cat <<END > $ISSM_DIR"/src/m/shared/"$(echo $FILENAME".m") 57 54 function bool=$(echo $FILENAME)() 58 55 %$(echo $FILENAME | awk {'print toupper($1)'}) - Return true if $(echo $LEVELNAME | awk {'print tolower($1)'}) level is activated … … 140 137 if(level<0) _error_("vebosity level should be a positive integer (user provided %i)",level); 141 138 142 #ifdef _SERIAL_143 144 mxArray* output=NULL;145 mxArray* input=NULL;146 input=mxCreateDoubleScalar((double)level);147 148 mexCallMATLAB(0,&output,1,&input,"SetVerbosityLevel");149 #else150 151 139 verbositylevel = level; 152 140 153 #endif154 141 }/*}}}*/ 155 142 /*FUNCTION GetVerbosityLevel {{{*/ 156 143 int GetVerbosityLevel(void){ 157 #ifdef _SERIAL_158 159 mxArray* output=NULL;160 mxArray* input=NULL;161 double level;162 163 mexCallMATLAB(1,&output,0,&input,"GetVerbosityLevel");164 level=mxGetScalar(output);165 166 verbositylevel = (int)level;167 return verbositylevel;168 169 #else170 171 144 _assert_(verbositylevel>=0); 172 145 return verbositylevel; 173 174 #endif175 146 }/*}}}*/ 176 147 END 177 148 #}}} 178 149 #Complete verbose.m {{{1 179 VERBOSEPATH="$ISSM_ TIER/src/m/classes/verbose.m"150 VERBOSEPATH="$ISSM_DIR/src/m/classes/verbose.m" 180 151 cat $VERBOSEPATH | sed "/%BEGINFIELDS/,$ d" > temp_begin 181 152 cat $VERBOSEPATH | sed "1,/%ENDFIELDS/d" > temp_end -
issm/trunk/src/c/shared/Numerics/Verbosity.cpp
r11995 r12330 18 18 #include "../../include/macros.h" 19 19 #include "../Exceptions/exceptions.h" 20 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)21 #include <mex.h>22 #endif23 20 /*}}}*/ 24 21 … … 39 36 if(level<0) _error_("vebosity level should be a positive integer (user provided %i)",level); 40 37 41 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)42 43 mxArray* output=NULL;44 mxArray* input=NULL;45 input=mxCreateDoubleScalar((double)level);46 47 mexCallMATLAB(0,&output,1,&input,"SetVerbosityLevel");48 #else49 50 38 verbositylevel = level; 51 39 52 #endif53 40 }/*}}}*/ 54 41 /*FUNCTION GetVerbosityLevel {{{*/ 55 42 int GetVerbosityLevel(void){ 56 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)57 58 mxArray* output=NULL;59 mxArray* input=NULL;60 double level;61 62 mexCallMATLAB(1,&output,0,&input,"GetVerbosityLevel");63 level=mxGetScalar(output);64 65 verbositylevel = (int)level;66 return verbositylevel;67 68 #else69 43 70 44 _assert_(verbositylevel>=0); 71 45 return verbositylevel; 72 46 73 #endif74 47 }/*}}}*/ -
issm/trunk/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp
r11995 r12330 1 #include "../../io/Matlab/matlabio.h"2 1 #include "../Alloc/alloc.h" 3 2 #include "../../include/include.h" 4 3 #include "../Exceptions/exceptions.h" 4 #include "./isnan.h" 5 5 #include <math.h> 6 6 -
issm/trunk/src/c/shared/Sorting/binary_search.cpp
r9320 r12330 11 11 #include <stdio.h> 12 12 13 int binary_search(int* poffset,int target, 13 int binary_search(int* poffset,int target,int* sorted_integers,int num_integers){ 14 14 15 15 /*output: */ 16 16 int offset; //offset, if found 17 int found=0; 17 int found=0; //found=0 if target is not found, 1 otherwise. 18 18 19 19 /*intermediary: */ … … 64 64 return found; 65 65 } 66 -
issm/trunk/src/c/shared/Sorting/sorting.h
r1 r12330 6 6 #define _SORTING_H_ 7 7 8 int binary_search(int* poffset,int target, int* sorted_integers,int num_integers); 9 8 int binary_search(int* poffset,int target,int* sorted_integers,int num_integers); 10 9 11 10 #endif //ifndef _SORTING_H_ 12 -
issm/trunk/src/c/shared/Threads/LaunchThread.cpp
r9320 r12330 67 67 function((void*)&handle); 68 68 #endif 69 70 69 } -
issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp
r8301 r12330 47 47 segmentmarkerlist=*psegmentmarkerlist; 48 48 49 50 49 /*Establish list of segments that belong to a rift: */ 51 RiftSegmentsFromSegments(&nriftsegs,&riftsegments,nel,index,nsegs,segments); /*riftsegments of size nriftsegsx4 (4 for first element on segment,second element,52 first node and second snode)*/50 /*riftsegments of size nriftsegsx4 (4 for first element on segment,second element,first node and second snode)*/ 51 RiftSegmentsFromSegments(&nriftsegs,&riftsegments,nel,index,nsegs,segments); 53 52 54 53 /*Go through all nodes of the rift segments, and start splitting the mesh: */ … … 57 56 for (j=0;j<2;j++){ 58 57 59 node= *(riftsegments+4*i+j+2);58 node=riftsegments[4*i+j+2]; 60 59 if(flags[node-1]){ 61 60 /*This node was already split, skip:*/ … … 70 69 DetermineGridElementListOnOneSideOfRift(&NumGridElementListOnOneSideOfRift,&GridElementListOnOneSideOfRift,i,nriftsegs,riftsegments,node,index,nel); 71 70 72 /*Summary: we have for node, a list of elements (GridElementListOnOneSideOfRift, of size NumGridElementListOnOneSideOfRift) that all contain node 73 *and that are on the same side of the rift. For all these elements, we clone node into another node, and we swap all instances of node in the triangulation 74 *for those elements, to the new node.*/ 71 /*Summary: we have for node, a list of elements 72 * (GridElementListOnOneSideOfRift, of size 73 * NumGridElementListOnOneSideOfRift) that all contain node 74 *and that are on the same side of the rift. For all these 75 elements, we clone node into another node, and we swap all 76 instances of node in the triangulation *for those elements, to the 77 new node.*/ 75 78 76 79 //augment number of nodes … … 94 97 95 98 /*update segments: they got modified completely by adding new nodes.*/ 96 UpdateSegments(&segments,&segmentmarkerlist, &nsegs,index,x,y,riftsegments,nriftsegs );99 UpdateSegments(&segments,&segmentmarkerlist, &nsegs,index,x,y,riftsegments,nriftsegs,nods,nel); 97 100 98 101 /*Assign output pointers: */ -
issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp
r11527 r12330 11 11 12 12 #define RIFTPENALTYPAIRSWIDTH 8 13 /*FUNCTION IsGridOnRift{{{*/ 13 14 int IsGridOnRift(int* riftsegments, int nriftsegs, int node){ 14 15 … … 32 33 return 0; 33 34 } 34 } 35 36 35 }/*}}}*/ 36 /*FUNCTION GridElementsList{{{*/ 37 37 int GridElementsList(int** pGridElements, int* pNumGridElements,int node,double * index,int nel){ 38 38 … … 87 87 *pNumGridElements=NumGridElements; 88 88 return noerr; 89 } 90 91 89 }/*}}}*/ 90 /*FUNCTION IsNeighbor{{{*/ 92 91 int IsNeighbor(int el1,int el2,double* index){ 93 92 /*From a triangulation held in index, figure out if elements 1 and 2 have two nodes in common: */ … … 105 104 return 0; 106 105 } 107 } 108 109 106 }/*}}}*/ 107 /*FUNCTION IsOnRift{{{*/ 110 108 int IsOnRift(int el,int nriftsegs,int* riftsegments){ 111 109 /*From a list of elements segments, figure out if el belongs to it: */ … … 117 115 } 118 116 return 0; 119 } 120 121 122 /****************************************************************************************************************************** 123 RiftSegmentsFromSegments 124 ******************************************************************************************************************************/ 125 117 }/*}}}*/ 118 /*FUNCTION RiftSegmentsFromSegments{{{*/ 126 119 void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments){ 127 120 … … 189 182 *priftsegments=riftsegments; 190 183 *pnriftsegs=nriftsegs; 191 } 192 193 /****************************************************************************************************************************** 194 DetermineGridElementListOnOneSideOfRift 195 ******************************************************************************************************************************/ 196 184 }/*}}}*/ 185 /*FUNCTION DetermineGridElementListOnOneSideOfRift{{{*/ 197 186 int DetermineGridElementListOnOneSideOfRift(int* pNumGridElementListOnOneSideOfRift, int** pGridElementListOnOneSideOfRift, int segmentnumber, int nriftsegs, int* riftsegments, int node,double* index,int nel){ 198 187 … … 257 246 *pGridElementListOnOneSideOfRift=GridElementListOnOneSideOfRift; 258 247 return noerr; 259 } 260 261 /****************************************************************************************************************************** 262 UpdateSegments 263 ******************************************************************************************************************************/ 264 265 int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs){ 248 }/*}}}*/ 249 /*FUNCTION UpdateSegments{{{*/ 250 int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs,int nods,int nel){ 266 251 267 252 int noerr=1; … … 284 269 /*First, update the existing segments to the new nodes :*/ 285 270 for (i=0;i<nriftsegs;i++){ 286 el1= *(riftsegments+4*i+0);287 el2= *(riftsegments+4*i+1);271 el1=riftsegments[4*i+0]; 272 el2=riftsegments[4*i+1]; 288 273 for (j=0;j<nsegs;j++){ 289 if ( *(segments+3*j+2)==(el1+1)){274 if (segments[3*j+2]==(el1+1)){ 290 275 /*segment j is the same as rift segment i.Let's update segments[j][:] using element el1 and the corresponding rift segment. 291 276 *Because riftsegments does not represent a list of rift segments anymore (it got heavily modified in SplitElementsForRifts, … … 293 278 for (k=0;k<3;k++){ 294 279 if ((x[(int)*(index+el1*3+k)-1]==x[(int)*(segments+3*j+0)-1]) && (y[(int)*(index+el1*3+k)-1]==y[(int)*(segments+3*j+0)-1])){ 295 *(segments+3*j+0)=*(index+el1*3+k); 280 *(segments+3*j+0)=*(index+el1*3+k); _assert_(segments[3*j+0]<nods+1); 296 281 break; 297 282 } … … 299 284 for (k=0;k<3;k++){ 300 285 if ((x[(int)*(index+el1*3+k)-1]==x[(int)*(segments+3*j+1)-1]) && (y[(int)*(index+el1*3+k)-1]==y[(int)*(segments+3*j+1)-1])){ 301 *(segments+3*j+1)=*(index+el1*3+k); 286 *(segments+3*j+1)=*(index+el1*3+k); _assert_(segments[3*j+1]<nods+1); 302 287 break; 303 288 } … … 308 293 for (k=0;k<3;k++){ 309 294 if ((x[(int)*(index+el2*3+k)-1]==x[(int)*(segments+3*j+0)-1]) && (y[(int)*(index+el2*3+k)-1]==y[(int)*(segments+3*j+0)-1])){ 310 *(segments+3*(nsegs+i)+0)=*(index+el2*3+k); 295 *(segments+3*(nsegs+i)+0)=*(index+el2*3+k); _assert_(segments[3*(nsegs+i)+0]<nods+1); 311 296 break; 312 297 } … … 314 299 for (k=0;k<3;k++){ 315 300 if ((x[(int)*(index+el2*3+k)-1]==x[(int)*(segments+3*j+1)-1]) && (y[(int)*(index+el2*3+k)-1]==y[(int)*(segments+3*j+1)-1])){ 316 *(segments+3*(nsegs+i)+1)=*(index+el2*3+k); 301 *(segments+3*(nsegs+i)+1)=*(index+el2*3+k); _assert_(segments[3*(nsegs+i)+1]<nods+1); 317 302 break; 318 303 } … … 324 309 for (k=0;k<3;k++){ 325 310 if ((x[(int)*(index+el2*3+k)-1]==x[(int)*(segments+3*j+0)-1]) && (y[(int)*(index+el2*3+k)-1]==y[(int)*(segments+3*j+0)-1])){ 326 *(segments+3*j+0)=*(index+el2*3+k); 311 *(segments+3*j+0)=*(index+el2*3+k); _assert_(segments[3*j+0]<nods+1); 327 312 break; 328 313 } … … 330 315 for (k=0;k<3;k++){ 331 316 if ((x[(int)*(index+el2*3+k)-1]==x[(int)*(segments+3*j+1)-1]) && (y[(int)*(index+el2*3+k)-1]==y[(int)*(segments+3*j+1)-1])){ 332 *(segments+3*j+1)=*(index+el2*3+k); 317 *(segments+3*j+1)=*(index+el2*3+k);_assert_(segments[3*j+1]<nods+1); 333 318 break; 334 319 } … … 339 324 for (k=0;k<3;k++){ 340 325 if ((x[(int)*(index+el1*3+k)-1]==x[(int)*(segments+3*j+0)-1]) && (y[(int)*(index+el1*3+k)-1]==y[(int)*(segments+3*j+0)-1])){ 341 *(segments+3*(nsegs+i)+0)=*(index+el1*3+k); 326 *(segments+3*(nsegs+i)+0)=*(index+el1*3+k);_assert_(segments[3*(nsegs+i)+0]<nods+1); 342 327 break; 343 328 } … … 345 330 for (k=0;k<3;k++){ 346 331 if ((x[(int)*(index+el1*3+k)-1]==x[(int)*(segments+3*j+1)-1]) && (y[(int)*(index+el1*3+k)-1]==y[(int)*(segments+3*j+1)-1])){ 347 *(segments+3*(nsegs+i)+1)=*(index+el1*3+k); 332 *(segments+3*(nsegs+i)+1)=*(index+el1*3+k);_assert_(segments[3*(nsegs+i)+1]<nods+1); 348 333 break; 349 334 } … … 360 345 361 346 return noerr; 362 } 363 364 /****************************************************************************************************************************** 365 pnpoly 366 ******************************************************************************************************************************/ 347 }/*}}}*/ 348 /*FUNCTION pnpoly{{{*/ 367 349 int pnpoly(int npol, double *xp, double *yp, double x, double y) { 368 350 int i, j, c = 0; … … 374 356 } 375 357 return c; 376 } 377 378 /****************************************************************************************************************************** 379 IsInPoly 380 ******************************************************************************************************************************/ 381 //void IsInPoly(double* in,double* xc,double* yc,int numnodes,double* x,double* y,int nods){ 382 // 383 // int i; 384 // double x0,y0; 385 // 386 // /*Go through all nodes of the mesh:*/ 387 // for (i=0;i<nods;i++){ 388 // if (in[i]){ 389 // /*this node already is inside one of the contours, continue*/ 390 // continue; 391 // } 392 // /*pick up node: */ 393 // x0=x[i]; 394 // y0=y[i]; 395 // if (pnpoly(numnodes,xc,yc,x0,y0)){ 396 // in[i]=1; 397 // } 398 // } 399 //} 400 401 /****************************************************************************************************************************** 402 FindElement 403 ******************************************************************************************************************************/ 404 358 }/*}}}*/ 359 /*FUNCTION FindElement{{{*/ 405 360 int FindElement(double A,double B,double* index,int nel){ 406 361 … … 414 369 } 415 370 return el; 416 } 417 /****************************************************************************************************************************** 418 SplitRiftSegments 419 ******************************************************************************************************************************/ 420 421 int SplitRiftSegments(double** psegments,double** psegmentmarkerlist, int* pnumsegs, int* pnumrifts,int** priftsnumsegs,double*** priftssegments,int numrifts){ 371 }/*}}}*/ 372 /*FUNCTION SplitRiftSegments{{{*/ 373 int SplitRiftSegments(double** psegments,double** psegmentmarkerlist, int* pnumsegs, int* pnumrifts,int** priftsnumsegs,double*** priftssegments,int numrifts,int nods,int nel){ 422 374 423 375 /*Using segment markers, wring out the rift segments from the segments. Rift markers are … … 461 413 for (i=0;i<numsegs;i++){ 462 414 if (segmentmarkerlist[i]==1){ 463 *(new_segments+3*counter+0)=*(segments+3*i+0);464 *(new_segments+3*counter+1)=*(segments+3*i+1);465 *(new_segments+3*counter+2)=*(segments+3*i+2);415 new_segments[3*counter+0]=segments[3*i+0]; 416 new_segments[3*counter+1]=segments[3*i+1]; 417 new_segments[3*counter+2]=segments[3*i+2]; 466 418 new_segmentmarkers[counter]=segmentmarkerlist[i]; 467 419 counter++; … … 484 436 for (j=0;j<numsegs;j++){ 485 437 if (segmentmarkerlist[j]==(2+i)){ 486 *(riftsegment+3*counter+0)=*(segments+3*j+0);487 *(riftsegment+3*counter+1)=*(segments+3*j+1);488 *(riftsegment+3*counter+2)=*(segments+3*j+2);438 riftsegment[3*counter+0]=segments[3*j+0];_assert_(riftsegment[3*counter+0]<nods+1); 439 riftsegment[3*counter+1]=segments[3*j+1];_assert_(riftsegment[3*counter+1]<nods+1); 440 riftsegment[3*counter+2]=segments[3*j+2];_assert_(riftsegment[3*counter+2]<nel+1); 489 441 counter++; 490 442 } … … 504 456 *priftsnumsegs=riftsnumsegs; 505 457 return noerr; 506 } 507 508 /****************************************************************************************************************************** 509 PairRiftElements 510 ******************************************************************************************************************************/ 511 458 }/*}}}*/ 459 /*FUNCTION PairRiftElements{{{*/ 512 460 int PairRiftElements(int** priftsnumpairs, double*** priftspairs,int numrifts,int* riftsnumsegments, double** riftssegments,double* x,double* y){ 513 461 … … 558 506 559 507 return noerr; 560 } 561 562 563 /****************************************************************************************************************************** 564 RemoveRifts 565 ******************************************************************************************************************************/ 566 567 double dabs(double x){ 568 if (x<0)x=-x; 569 return x; 570 } 508 }/*}}}*/ 509 /*FUNCTION RemoveRifts{{{*/ 571 510 int RemoveRifts(double** pindex,double** px,double** py,int* pnods,double** psegments,int* pnumsegs,int numrifts1,int* rifts1numsegs,double** rifts1segments,double** rifts1pairs,int nel){ 572 511 … … 615 554 if (y[i]<ymin)ymin=y[i]; 616 555 } 617 xmin=xmin- dabs(xmin);618 ymin=ymin- dabs(ymin);556 xmin=xmin-fabs(xmin); 557 ymin=ymin-fabs(ymin); 619 558 620 559 /*Initialize two arrays, one for nodes that are going to be merged, the other with corresponding nodes being merge into: */ … … 751 690 752 691 return noerr; 753 } 754 755 /****************************************************************************************************************************** 756 IsRiftPresent 757 ******************************************************************************************************************************/ 758 692 }/*}}}*/ 693 /*FUNCTION IsRiftPresent{{{*/ 759 694 int IsRiftPresent(int* priftflag,int* pnumrifts, double* segmentmarkerlist,int nsegs){ 760 695 … … 783 718 784 719 return noerr; 785 } 786 787 /****************************************************************************************************************************** 788 OrderRifts 789 ******************************************************************************************************************************/ 790 791 int OrderRifts(double** priftstips, double** riftssegments,double** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y){ 720 }/*}}}*/ 721 /*FUNCTION OrderRifts{{{*/ 722 int OrderRifts(double** priftstips, double** riftssegments,double** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y,int nods,int nels){ 792 723 793 724 int noerr=1; … … 811 742 /*output: */ 812 743 double* riftstips=NULL; 813 814 744 815 745 /*Allocate byproduct of this routine, riftstips: */ … … 822 752 numsegs=riftsnumsegments[i]; 823 753 824 825 754 /*Allocate copy of riftsegments and riftpairs, 826 755 *as well as ordering vector: */ … … 847 776 } 848 777 /* Make sure node3 faces node1 and node4 faces node2: */ 849 if ((x[node1]==x[node4]) && (y[node1]==y[node4])){ 778 _assert_(node1<nods+1 && node4<nods+1); 779 _assert_(node1>0 && node4>0); 780 if ((x[node1-1]==x[node4-1]) && (y[node1-1]==y[node4-1])){ 850 781 /*Swap node3 and node4:*/ 851 782 temp_node=node3; … … 943 874 *priftstips=riftstips; 944 875 return noerr; 945 } 946 947 /****************************************************************************************************************************** 948 PenaltyPairs 949 ******************************************************************************************************************************/ 950 876 }/*}}}*/ 877 /*FUNCTION PenaltyPairs{{{*/ 951 878 int PenaltyPairs(double*** priftspenaltypairs,int** priftsnumpenaltypairs,int numrifts,double** riftssegments, 952 879 int* riftsnumsegs,double** riftspairs,double* riftstips,double* x,double* y){ -
issm/trunk/src/c/shared/TriMesh/trimesh.h
r11527 r12330 6 6 #define _SHARED_TRIMESH_H 7 7 8 9 8 #include <stdio.h> 10 9 #include <math.h> 11 10 12 13 14 11 //#define REAL double //took it out because it may conflict with stdlib.h defines. put back if necessary 15 16 12 int AssociateSegmentToElement(double** psegments,int nseg, double* index,int nel); 17 13 int OrderSegments(double** psegments,int nseg, double* index,int nel); 18 19 14 int GridInsideHole(double* px0,double* py0,int n,double* x,double* y); 20 15 int FindElement(double A,double B,double* index,int nel); 21 22 16 int SplitMeshForRifts(int* pnel,double** pindex,int* pnods,double** px,double** py,int* pnsegs,double** psegments,double** psegmentmarkerlist); 23 24 17 int IsGridOnRift(int* riftsegments, int nriftsegs, int node); 25 18 int GridElementsList(int** pGridElements, int* pNumGridElements,int node,double * index,int nel); … … 28 21 void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments); 29 22 int DetermineGridElementListOnOneSideOfRift(int* pNumGridElementListOnOneSideOfRift, int** pGridElementListOnOneSideOfRift, int segmentnumber, int nriftsegs, int* riftsegments, int node,double* index,int nel); 30 int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs );23 int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs,int nods,int nel); 31 24 int pnpoly(int npol, double *xp, double *yp, double x, double y); 32 25 int FindElement(double A,double B,double* index,int nel); 33 26 int RemoveRifts(double** pindex,double** px,double** py,int* pnods,double** psegments,int* pnumsegs,int numrifts1,int* rifts1numsegs,double** rifts1segments,double** rifts1pairs,int nel); 34 27 int IsRiftPresent(int* priftflag,int* pnumrifts, double* segmentmarkerlist,int nsegs); 35 int SplitRiftSegments(double** psegments,double** psegmentmarkerlist, int* pnumsegs, int* pnumrifts,int** priftsnumsegs,double*** priftssegments,int numrifts );36 int OrderRifts(double** priftstips, double** riftssegments,double** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y );28 int SplitRiftSegments(double** psegments,double** psegmentmarkerlist, int* pnumsegs, int* pnumrifts,int** priftsnumsegs,double*** priftssegments,int numrifts,int nods,int nels); 29 int OrderRifts(double** priftstips, double** riftssegments,double** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y,int nods,int nels); 37 30 int PenaltyPairs(double*** priftspenaltypairs,int** priftsnumpenaltypairs,int numrifts,double** riftssegments, 38 31 int* riftsnumsegments,double** riftspairs,double* riftstips,double* x,double* y); 39 40 32 int RemoveCornersFromRifts(double** pindex,int* pnel,double** px,double** py,int* pnods, double* segments,double* segmentmarkers,int num_seg); 41 33 int PairRiftElements(int** priftsnumpairs, double*** priftspairs,int numrifts,int* riftsnumsegments, double** riftssegments,double* x,double* y); 42 34 43 44 35 #endif /* _SHARED_TRIMESH_H */ -
issm/trunk/src/c/shared/Wrapper/wrappershared.h
r11995 r12330 8 8 #include "../../objects/objects.h" 9 9 10 #ifdef _SERIAL_11 10 int ModuleBoot(void); 12 11 int ModuleEnd(void); 13 #endif14 12 15 13 #endif -
issm/trunk/src/c/shared/shared.h
r11995 r12330 8 8 9 9 #include "Alloc/alloc.h" 10 #include "Alloc/alloc_module.h" 10 11 #include "Exceptions/exceptions.h" 11 12 #include "Exp/exp.h" -
issm/trunk/src/c/solutions/ProcessArguments.cpp
r10568 r12330 4 4 5 5 #include <stdio.h> 6 #include <cstring> 7 6 8 #include "../shared/shared.h" 7 9 #include "../include/include.h" -
issm/trunk/src/c/solutions/issm.cpp
r11995 r12330 35 35 int ierr; 36 36 37 MODULEBOOT(); 38 39 #ifndef _PARALLEL_ 40 _error_(" parallel executable was compiled without support of parallel libraries!"); 41 #endif 37 ISSMBOOT(); 42 38 43 39 /*Initialize environments: Petsc, MPI, etc...: */ … … 46 42 if(ierr) _error_("Could not initialize Petsc"); 47 43 #else 44 #ifdef _HAVE_MPI_ 48 45 MPI_Init(&argc,&argv); 49 46 #endif 47 #endif 50 48 49 #ifdef _HAVE_MPI_ 51 50 MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime(); 51 #else 52 start=(double)clock(); 53 #endif 52 54 53 55 /*Size and rank: */ 56 #ifdef _HAVE_MPI_ 54 57 MPI_Comm_rank(MPI_COMM_WORLD,&my_rank); 55 58 MPI_Comm_size(MPI_COMM_WORLD,&num_procs); 59 #endif 56 60 57 61 /*First process inputs*/ … … 66 70 67 71 /*Create femmodel, using input file: */ 72 #ifdef _HAVE_MPI_ 68 73 MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime(); 74 #else 75 start_init=(double)clock(); 76 #endif 69 77 femmodel=new FemModel(binfilename,outbinfilename,solution_type,analyses,numanalyses); 70 78 … … 86 94 femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum); 87 95 femmodel->parameters->FindParam(&tao_analysis,InversionTaoEnum); 96 #ifdef _HAVE_MPI_ 88 97 MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime(); 98 #else 99 finish_init=(double)clock(); 100 #endif 89 101 90 102 _printf_(true,"call computational core:\n"); 103 #ifdef _HAVE_MPI_ 91 104 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 105 #else 106 start_core=(double)clock(); 107 #endif 108 92 109 if(dakota_analysis){ 93 110 #ifdef _HAVE_DAKOTA_ … … 110 127 solutioncore(femmodel); 111 128 } 129 #ifdef _HAVE_MPI_ 112 130 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 113 131 #else 132 finish_core=(double)clock(); 133 #endif 134 114 135 _printf_(true,"write results to disk:\n"); 115 136 OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results); … … 131 152 132 153 /*Get finish time and close*/ 154 #ifdef _HAVE_MPI_ 133 155 MPI_Barrier(MPI_COMM_WORLD); finish = MPI_Wtime( ); 134 156 _printf_(true,"\n %-34s %f seconds \n","FemModel initialization elapsed time:",finish_init-start_init); 135 157 _printf_(true," %-34s %f seconds \n","Core solution elapsed time:",finish_core-start_core); 136 158 _printf_(true,"\n %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600),int(int(finish-start)%3600/60),int(finish-start)%60); 159 #else 160 finish=(double)clock(); 161 _printf_(true,"\n %-34s %f seconds \n","FemModel initialization elapsed time:",(finish_init-start_init)/CLOCKS_PER_SEC); 162 _printf_(true," %-34s %f seconds \n","Core solution elapsed time:",(finish_core-start_core)/CLOCKS_PER_SEC); 163 _printf_(true,"\n %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600/CLOCKS_PER_SEC),int(int((finish-start)/CLOCKS_PER_SEC)%3600/60),(int(finish-start)/CLOCKS_PER_SEC)%60); 164 #endif 137 165 166 138 167 168 #ifdef _HAVE_PETSC_ 139 169 _printf_(true,"closing MPI and Petsc\n"); 140 #ifdef _HAVE_PETSC_141 170 PetscFinalize(); 142 171 #else 172 #ifdef _HAVE_MPI_ 173 _printf_(true,"closing MPI and Petsc\n"); 143 174 MPI_Finalize(); 175 #endif 144 176 #endif 145 177 146 178 /*end module: */ 147 MODULEEND();179 ISSMEND(); 148 180 149 181 return 0; //unix success return; 150 182 } 151 -
issm/trunk/src/c/solvers/solver_newton.cpp
r11995 r12330 67 67 convergence(&converged,Kff,pf,uf,old_uf,femmodel->parameters); 68 68 xdelete(&Kff); xdelete(&pf); 69 if(converged==true) break; 69 if(converged==true){ 70 bool max_iteration_state=false; 71 int tempStep=1; 72 double tempTime=1.0; 73 femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime)); 74 break; 75 } 70 76 if(count>=max_nonlinear_iterations){ 71 _printf_(true," maximum number of iterations (%i) exceeded\n",max_nonlinear_iterations); 77 _printf_(true," maximum number of Newton iterations (%i) exceeded\n",max_nonlinear_iterations); 78 bool max_iteration_state=true; 79 int tempStep=1; 80 double tempTime=1.0; 81 femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime)); 72 82 break; 73 83 } -
issm/trunk/src/c/solvers/solver_nonlinear.cpp
r11995 r12330 85 85 /*Increase count: */ 86 86 count++; 87 if(converged==true)break; 87 if(converged==true){ 88 bool max_iteration_state=false; 89 int tempStep=1; 90 double tempTime=1.0; 91 femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime)); 92 break; 93 } 88 94 if(count>=max_nonlinear_iterations){ 89 _printf_(true," maximum number of iterations (%i) exceeded\n",max_nonlinear_iterations);95 _printf_(true," maximum number of nonlinear iterations (%i) exceeded\n",max_nonlinear_iterations); 90 96 converged=true; 91 InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum); 92 InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug); 97 InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum); 98 InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug); 99 bool max_iteration_state=true; 100 int tempStep=1; 101 double tempTime=1.0; 102 femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime)); 93 103 break; 94 104 } -
issm/trunk/src/c/toolkits/issm/SeqMat.cpp
r11995 r12330 92 92 } 93 93 /*}}}*/ 94 95 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)96 /*FUNCTION SeqMat::ToMatlabMatrix{{{1*/97 mxArray* SeqMat::ToMatlabMatrix(void){98 99 /*Intermediary: */100 double* buffer=NULL;101 mxArray* pfield=NULL;102 103 /*output: */104 mxArray* dataref=NULL;105 106 /*copy vector into a new buffer: */107 if(this->M*this->N){108 buffer=(double*)xmalloc(this->M*this->N*sizeof(double));109 memcpy(buffer,this->matrix,M*N*sizeof(double));110 111 pfield=mxCreateDoubleMatrix(0,0,mxREAL);112 mxSetM(pfield,this->N);113 mxSetN(pfield,this->M);114 mxSetPr(pfield,buffer);115 116 //transpose the matrix, written directly to matlab! from C to matlab.117 mexCallMATLAB(1,&dataref, 1, &pfield, "transpose");118 }119 else dataref=mxCreateDoubleMatrix(0,0,mxREAL);120 121 /*do not erase buffer!: */122 return dataref;123 124 }125 126 127 128 129 /*}}}*/130 /*FUNCTION MatlabMatrixToSeqMat{{{1*/131 SeqMat* MatlabMatrixToSeqMat(const mxArray* dataref){132 133 SeqMat* output=NULL;134 135 output=new SeqMat();136 MatlabMatrixToDoubleMatrix(&output->matrix,&output->M,&output->N,dataref);137 return output;138 139 }140 /*}}}*/141 #endif142 94 /*FUNCTION SeqMat::Assemble{{{1*/ 143 95 void SeqMat::Assemble(void){ -
issm/trunk/src/c/toolkits/issm/SeqMat.h
r11995 r12330 15 15 16 16 #include "../toolkitsenums.h" 17 18 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)19 #include "mex.h"20 #endif21 17 22 18 /*}}}*/ … … 40 36 /*SeqMat specific routines {{{1*/ 41 37 void Echo(void); 42 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)43 mxArray* ToMatlabMatrix(void);44 #endif45 38 void Assemble(void); 46 39 double Norm(NormMode norm_type); … … 56 49 }; 57 50 58 /*API :*/59 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)60 SeqMat* MatlabMatrixToSeqMat(const mxArray* dataref);61 #endif62 63 51 #endif //#ifndef _SEQMAT_H_ -
issm/trunk/src/c/toolkits/issm/SeqVec.cpp
r11995 r12330 66 66 /*}}}*/ 67 67 68 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)69 /*FUNCTION SeqVec::ToMatlabVector{{{1*/70 mxArray* SeqVec::ToMatlabVector(void){71 72 double* buffer=NULL;73 74 mxArray* dataref=NULL;75 76 /*copy vector into a new buffer: */77 if(this->M){78 buffer=(double*)xmalloc(this->M*sizeof(double));79 memcpy(buffer,vector,M*sizeof(double));80 81 dataref = mxCreateDoubleMatrix(0,0,mxREAL);82 mxSetM(dataref,this->M);83 mxSetN(dataref,1);84 mxSetPr(dataref,buffer);85 }86 else dataref = mxCreateDoubleMatrix(0,0,mxREAL);87 88 89 /*do not erase buffer!: */90 return dataref;91 92 }93 /*}}}*/94 /*FUNCTION MatlabVectorToSeqVec{{{1*/95 SeqVec* MatlabVectorToSeqVec(const mxArray* dataref){96 97 SeqVec* output=NULL;98 99 output=new SeqVec();100 MatlabVectorToDoubleVector(&output->vector,&output->M,dataref);101 return output;102 103 }104 /*}}}*/105 #endif106 68 /*FUNCTION SeqVec::Assemble{{{1*/ 107 69 void SeqVec::Assemble(void){ -
issm/trunk/src/c/toolkits/issm/SeqVec.h
r11995 r12330 15 15 16 16 #include "../toolkitsenums.h" 17 18 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)19 #include "mex.h"20 #endif21 17 22 18 /*}}}*/ … … 37 33 /*SeqVec specific routines {{{1*/ 38 34 void Echo(void); 39 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)40 mxArray* ToMatlabVector(void);41 #endif42 35 void Assemble(void); 43 36 void SetValues(int ssize, int* list, double* values, InsMode mode); … … 59 52 }; 60 53 61 62 /*API :*/63 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)64 SeqVec* MatlabVectorToSeqVec(const mxArray* dataref);65 #endif66 67 54 #endif //#ifndef _SEQVEC_H_ -
issm/trunk/src/c/toolkits/petsc/patches/MatInvert.cpp
r11995 r12330 55 55 MatAssemblyBegin(inv,MAT_FINAL_ASSEMBLY); 56 56 MatAssemblyEnd(inv,MAT_FINAL_ASSEMBLY); 57 58 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_) 59 MatConvert(inv, MATSEQAIJ,MAT_REUSE_MATRIX,&inv); 60 #else 61 MatConvert(inv, MATMPIAIJ,MAT_REUSE_MATRIX,&inv); 62 #endif 57 58 MatConvert(inv, MATMPIAIJ,MAT_REUSE_MATRIX,&inv); 63 59 64 60 /*Free ressources:*/ -
issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp
r11995 r12330 68 68 69 69 #ifdef _HAVE_PETSCDEV_ 70 MatCreateAIJ(MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 70 if(sparsity==1){ 71 MatCreateDense(MPI_COMM_WORLD,m,n,M,N,NULL,&outmatrix); 72 } 73 else{ 74 MatCreateAIJ(MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 75 } 71 76 #else 72 77 MatCreateMPIAIJ(MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); -
issm/trunk/src/c/toolkits/petsc/patches/petscpatches.h
r11995 r12330 15 15 16 16 class Parameters; 17 18 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)19 #include "mex.h"20 int MatlabMatrixToPetscMatrix(Mat* matrix,int* prows,int* pcols, const mxArray* mxmatrix);21 int MatlabVectorToPetscVector(Vec* pvector,int* pvector_rows,const mxArray* mxvector);22 int PetscMatrixToMatlabMatrix(mxArray** pdataref,Mat matrix);23 int PetscVectorToMatlabVector(mxArray** pdataref,Vec vector);24 #endif25 17 26 18 Vec NewVec(int size,bool fromlocalsize=false); … … 51 43 MatType ISSMToPetscMatrixType(MatrixType type); 52 44 45 void PetscMatrixToDoubleMatrix(double** pmatrix, int* prows, int* pcols,Mat matrix); 46 void PetscVectorToDoubleVector(double** pvector, int* prows, Vec vector); 47 53 48 #endif -
issm/trunk/src/c/toolkits/python/pythonincludes.h
r11995 r12330 7 7 8 8 9 #ifdef HAVE_CONFIG_H 10 #include <config.h> 11 #else 12 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 13 #endif 14 15 #if _PYTHON_MAJOR_ == 2 16 #undef NPY_NO_DEPRECATED_API 17 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION 18 #else 19 #define NPY_NO_DEPRECATED_API 20 #endif 21 9 22 #include "Python.h" 10 23 #include "arrayobject.h" 11 12 13 24 14 25 #ifdef _HAVE_BOOST_ -
issm/trunk/src/c/toolkits/toolkits.h
r11995 r12330 12 12 #endif 13 13 14 #if defined(_HAVE_PYTHON_) && defined(_SERIAL_)14 #ifdef _HAVE_PYTHON_ 15 15 #include "./python/pythonincludes.h" 16 16 #endif … … 20 20 #endif 21 21 22 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)23 #include "./m atlab/matlabincludes.h"22 #ifdef _HAVE_MPI_ 23 #include "./mpi/mpiincludes.h" 24 24 #endif 25 25 26 #ifdef _HAVE_METIS_ 27 #include "./metis/metisincludes.h" 28 #endif 26 29 27 #include "./mpi/mpiincludes.h"28 #include "./metis/metisincludes.h"29 30 #include "./triangle/triangleincludes.h" 30 #include "./double/double.h"31 31 #include "./toolkitsenums.h" 32 32 #include "./issm/issmtoolkit.h" -
issm/trunk/src/c/toolkits/triangle/triangleincludes.h
r2214 r12330 6 6 #define _TRIANGLE_INCLUDES_H_ 7 7 8 #ifdef _SERIAL_9 10 8 #ifdef _C_ //only valid for iso C, not C++ 11 9 /*Triangle includes: */ … … 13 11 #endif //#ifdef _C_ 14 12 15 #endif //ifdef _SERIAL_16 17 13 18 14 #endif
Note:
See TracChangeset
for help on using the changeset viewer.