Changeset 13975 for issm/trunk/src
- Timestamp:
- 11/16/12 08:10:16 (12 years ago)
- Location:
- issm/trunk
- Files:
-
- 57 deleted
- 855 edited
- 94 copied
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:mergeinfo changed
/issm/trunk-jpl merged: 13397-13398,13401,13407-13582,13584-13974
- Property svn:mergeinfo changed
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/Makefile.am
r13395 r13975 1 EXTRA_DIST = perl pro py 2 SUBDIRS = c modules m 1 EXTRA_DIST = perl pro 2 SUBDIRS = c m wrappers 3 if ANDROID 4 SUBDIRS += android 5 endif -
issm/trunk/src/ad/todo
r13395 r13975 57 57 - make gdb wrapper. 58 58 - think about ModelProcessor setup. need to keep track, before we partition, on cpu 0, of the independent declarations. 59 60 61 MPI: what's missing that equivalent of MPI.h -> no well defined api. 62 What's exposed is the internals of it. 63 64 Wanted to look at changing the way for the matrices and vertices would be implemented. 65 -
issm/trunk/src/android
-
Property svn:ignore
set to
Makefile.in
Makefile
-
Property svn:ignore
set to
-
issm/trunk/src/c/Container/Constraints.cpp
r12706 r13975 49 49 /*figure out total number of constraints combining all the cpus (no clones here)*/ 50 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);51 MPI_Reduce(&localconstraints,&numberofconstraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() ); 52 MPI_Bcast(&numberofconstraints,1,MPI_INT,0,IssmComm::GetComm()); 53 53 #else 54 54 numberofconstraints=localconstraints; 55 55 #endif 56 57 56 58 57 return numberofconstraints; -
issm/trunk/src/c/Container/Constraints.h
r12706 r13975 16 16 class Inputs; 17 17 18 19 18 class Constraints: public DataSet{ 20 19 21 20 public: 22 21 23 /*constructors, destructors : {{{*/22 /*constructors, destructors*/ 24 23 Constraints(); 25 24 ~Constraints(); 26 /*}}}*/ 27 /*numerics : {{{*/25 26 /*numerics*/ 28 27 int NumberOfConstraints(void); 29 /*}}}*/30 28 31 29 }; 32 30 33 34 31 #endif //ifndef _CONSTRAINTS_H_ 35 -
issm/trunk/src/c/Container/DataSet.cpp
r13395 r13975 30 30 /*FUNCTION DataSet::DataSet(){{{*/ 31 31 DataSet::DataSet(){ 32 32 33 33 sorted=0; 34 34 sorted_ids=NULL; … … 40 40 DataSet::DataSet(int dataset_enum){ 41 41 enum_type=dataset_enum; 42 42 43 43 sorted=0; 44 44 sorted_ids=NULL; … … 50 50 DataSet* DataSet::Copy(void){ 51 51 52 DataSet* copy=NULL;53 52 vector<Object*>::iterator object; 54 53 Object* object_copy=NULL; 55 54 56 copy=new DataSet(enum_type);55 DataSet* copy=new DataSet(enum_type); 57 56 58 57 copy->sorted=sorted; … … 130 129 void DataSet::DeepEcho(){ 131 130 132 133 131 vector<Object*>::iterator object; 134 132 … … 191 189 int id_offset; 192 190 int offset; 193 int i;194 191 195 192 _assert_(this); … … 216 213 /*vector of objects is already sorted, just allocate the sorted ids and their 217 214 * offsets:*/ 218 int i;219 220 215 if(objects.size()){ 221 216 … … 229 224 230 225 /*Build id_offsets and sorted_ids*/ 231 for(i =0;i<objects.size();i++){226 for(int i=0;i<objects.size();i++){ 232 227 id_offsets[i]=i; 233 228 sorted_ids[i]=objects[i]->Id(); -
issm/trunk/src/c/Container/DataSet.h
r13395 r13975 23 23 24 24 class DataSet{ 25 25 26 26 public: 27 27 28 28 /*internals: */ 29 29 std::vector<Object*> objects; 30 30 31 31 /*type of dataset: */ 32 32 int enum_type; 33 33 34 34 /*sorting: */ 35 35 int sorted; … … 38 38 int* id_offsets; 39 39 40 /*constructors, destructors : {{{*/40 /*constructors, destructors*/ 41 41 DataSet(); 42 42 DataSet(int enum_type); 43 43 ~DataSet(); 44 /*}}}*/ 45 /*management: {{{*/ 46 int GetEnum(); 47 int GetEnum(int offset); 48 void Echo(); 49 void DeepEcho(); 50 int AddObject(Object* object); 51 int DeleteObject(int id); 52 int Size(); 53 void clear(); 54 Object* GetObjectByOffset(int offset); 55 Object* GetObjectById(int* poffset,int eid); 56 void Presort(); 57 void SetSorting(int* in_sorted_ids,int* in_id_offsets); 58 void Sort(); 59 DataSet* Copy(void); 60 int DeleteObject(Object* object); 61 Results* SpawnTriaResults(int* indices); 62 /*}}}*/ 44 45 /*management*/ 46 int GetEnum(); 47 int GetEnum(int offset); 48 void Echo(); 49 void DeepEcho(); 50 int AddObject(Object *object); 51 int DeleteObject(int id); 52 int Size(); 53 void clear(); 54 Object *GetObjectByOffset(int offset); 55 Object *GetObjectById(int *poffset,int eid); 56 void Presort(); 57 void SetSorting(int *in_sorted_ids,int*in_id_offsets); 58 void Sort(); 59 DataSet *Copy(void); 60 int DeleteObject(Object *object); 61 Results *SpawnTriaResults(int *indices); 63 62 64 63 }; -
issm/trunk/src/c/Container/Elements.cpp
r13395 r13975 46 46 for ( object=objects.begin() ; object < objects.end(); object++ ){ 47 47 48 element= (Element*)(*object);48 element=dynamic_cast<Element*>((*object)); 49 49 element->Configure(elements,loads,nodes,materials,parameters); 50 50 … … 58 58 //Process results to be output in the correct units 59 59 for(int i=0;i<this->Size();i++){ 60 Element* element= (Element*)this->GetObjectByOffset(i);60 Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i)); 61 61 element->ProcessResultsUnits(); 62 62 } … … 65 65 /*FUNCTION Elements::DeleteResults{{{*/ 66 66 void Elements::DeleteResults(void){ 67 67 68 68 for (int i=0;i<this->Size();i++){ 69 Element* element= (Element*)this->GetObjectByOffset(i);69 Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i)); 70 70 element->DeleteResults(); 71 71 } … … 108 108 * We will use the Patch object, which will store all of the information needed, and will be able 109 109 * to output itself to disk on its own. See object/Patch.h for format of this object.*/ 110 110 111 111 /*First, determine maximum number of vertices, nodes, and number of results: */ 112 112 numrows=0; … … 116 116 for(i=0;i<this->Size();i++){ 117 117 118 Element* element= (Element*)this->GetObjectByOffset(i);118 Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i)); 119 119 element->PatchSize(&element_numrows,&element_numvertices,&element_numnodes); 120 120 … … 126 126 /*Synchronize across cluster, so as to not end up with different sizes for each patch on each cpu: */ 127 127 #ifdef _HAVE_MPI_ 128 MPI_Reduce (&numvertices,&max_numvertices,1,MPI_INT,MPI_MAX,0, MPI_COMM_WORLD);129 MPI_Bcast(&max_numvertices,1,MPI_INT,0, MPI_COMM_WORLD);128 MPI_Reduce (&numvertices,&max_numvertices,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() ); 129 MPI_Bcast(&max_numvertices,1,MPI_INT,0,IssmComm::GetComm()); 130 130 numvertices=max_numvertices; 131 131 132 MPI_Reduce (&numnodes,&max_numnodes,1,MPI_INT,MPI_MAX,0, MPI_COMM_WORLD);133 MPI_Bcast(&max_numnodes,1,MPI_INT,0, MPI_COMM_WORLD);132 MPI_Reduce (&numnodes,&max_numnodes,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() ); 133 MPI_Bcast(&max_numnodes,1,MPI_INT,0,IssmComm::GetComm()); 134 134 numnodes=max_numnodes; 135 135 #endif … … 141 141 count=0; 142 142 for(i=0;i<this->Size();i++){ 143 Element* element= (Element*)this->GetObjectByOffset(i);143 Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i)); 144 144 element->PatchFill(&count,patch); 145 145 } … … 156 156 for ( object=objects.begin() ; object < objects.end(); object++ ){ 157 157 158 element= (Element*)(*object);158 element=dynamic_cast<Element*>((*object)); 159 159 element->SetCurrentConfiguration(elements,loads,nodes,materials,parameters); 160 160 … … 166 166 void Elements::ToResults(Results* results,Parameters* parameters){ 167 167 168 int i; 169 170 extern int my_rank; 171 extern int num_procs; 172 173 Patch *patch = NULL; 174 int *resultsenums = NULL; 175 int *resultssizes = NULL; 176 int *resultssteps = NULL; 177 IssmDouble *resultstimes = NULL; 178 IssmDouble *vector_serial= NULL; 179 Vector<IssmDouble>* vector = NULL; 180 bool io_gather; 181 bool results_as_patches; 182 int numberofvertices,numberofelements; 183 int numberofresults,vectorsize; 184 int rank; 185 int minrank; 168 int my_rank; 169 int num_procs; 170 171 Patch *patch = NULL; 172 int *resultsenums = NULL; 173 int *resultssizes = NULL; 174 int *resultssteps = NULL; 175 IssmDouble *resultstimes = NULL; 176 IssmDouble *vector_serial = NULL; 177 Vector<IssmDouble> *vector = NULL; 178 bool io_gather; 179 bool results_as_patches; 180 int numberofvertices ,numberofelements; 181 int numberofresults ,vectorsize; 182 int rank; 183 int minrank; 184 185 /*recover my_rank:*/ 186 my_rank=IssmComm::GetRank(); 187 num_procs=IssmComm::GetSize(); 186 188 187 189 /*Recover parameters: */ … … 198 200 if(this->Size()) rank=my_rank; 199 201 else rank=num_procs; 200 MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN, MPI_COMM_WORLD);202 MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN,IssmComm::GetComm()); 201 203 #else 202 204 minrank=my_rank; … … 206 208 if(my_rank==minrank){ 207 209 if(this->Size()==0) _error_("Cannot write results because there is no element??"); 208 Element* element= (Element*)this->GetObjectByOffset(0);210 Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(0)); 209 211 element->ListResultsInfo(&resultsenums,&resultssizes,&resultstimes,&resultssteps,&numberofresults); 210 212 } 211 213 #ifdef _HAVE_MPI_ 212 MPI_Bcast(&numberofresults,1,MPI_DOUBLE,minrank, MPI_COMM_WORLD);214 MPI_Bcast(&numberofresults,1,MPI_DOUBLE,minrank,IssmComm::GetComm()); 213 215 #endif 214 216 … … 222 224 resultssteps=xNew<int>(numberofresults); 223 225 } 224 MPI_Bcast(resultsenums,numberofresults,MPI_INT,minrank, MPI_COMM_WORLD);225 MPI_Bcast(resultssizes,numberofresults,MPI_INT,minrank, MPI_COMM_WORLD);226 MPI_Bcast(resultstimes,numberofresults,MPI_DOUBLE,minrank, MPI_COMM_WORLD);227 MPI_Bcast(resultssteps,numberofresults,MPI_INT,minrank, MPI_COMM_WORLD);226 MPI_Bcast(resultsenums,numberofresults,MPI_INT,minrank,IssmComm::GetComm()); 227 MPI_Bcast(resultssizes,numberofresults,MPI_INT,minrank,IssmComm::GetComm()); 228 MPI_Bcast(resultstimes,numberofresults,MPI_DOUBLE,minrank,IssmComm::GetComm()); 229 MPI_Bcast(resultssteps,numberofresults,MPI_INT,minrank,IssmComm::GetComm()); 228 230 #endif 229 231 … … 238 240 239 241 for(int j=0;j<this->Size();j++){ 240 Element* element= (Element*)this->GetObjectByOffset(j);242 Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(j)); 241 243 element->GetVectorFromResults(vector,i,resultsenums[i],resultssizes[i]); 242 244 } … … 292 294 } 293 295 /*}}}*/ 296 /*FUNCTION Elements::MaxNumNodes{{{*/ 297 int Elements::MaxNumNodes(void){ 298 299 int max=0; 300 int allmax; 301 int numnodes=0; 302 303 /*Now go through all elements, and get how many nodes they own, unless they are clone nodes: */ 304 for(int i=0;i<this->Size();i++){ 305 306 Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i)); 307 numnodes=element->GetNumberOfNodes(); 308 if(numnodes>max)max=numnodes; 309 } 310 311 /*Grab max of all cpus: */ 312 #ifdef _HAVE_MPI_ 313 MPI_Allreduce((void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm()); 314 max=allmax; 315 #endif 316 317 return max; 318 } 319 /*}}}*/ 294 320 /*FUNCTION Elements::NumberOfElements{{{*/ 295 321 int Elements::NumberOfElements(void){ 296 322 297 int local_nelem =0;323 int local_nelem; 298 324 int numberofelements; 299 325 300 326 local_nelem=this->Size(); 301 327 #ifdef _HAVE_MPI_ 302 MPI_Allreduce ( (void*)&local_nelem,(void*)&numberofelements,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);328 MPI_Allreduce ( (void*)&local_nelem,(void*)&numberofelements,1,MPI_INT,MPI_SUM,IssmComm::GetComm()); 303 329 #else 304 330 numberofelements=local_nelem; … … 312 338 313 339 for(int i=0;i<this->Size();i++){ 314 Element* element= (Element*)this->GetObjectByOffset(i);340 Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i)); 315 341 element->InputDuplicate(input_enum,output_enum); 316 342 } -
issm/trunk/src/c/Container/Elements.h
r12706 r13975 20 20 public: 21 21 22 /*constructors, destructors : {{{*/22 /*constructors, destructors*/ 23 23 Elements(); 24 24 ~Elements(); 25 /*}}}*/ 26 /*numerics: {{{*/ 27 void Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 28 void DeleteResults(void); 29 void ProcessResultsUnits(void); 30 void SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 31 void ToResults(Results* results,Parameters* parameters); 25 26 /*numerics*/ 27 void Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 28 void DeleteResults(void); 29 int MaxNumNodes(void); 30 void ProcessResultsUnits(void); 31 void SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 32 void ToResults(Results* results,Parameters* parameters); 32 33 Patch* ResultsToPatch(void); 33 int NumberOfElements(void); 34 void InputDuplicate(int input_enum,int output_enum); 35 /*}}}*/ 34 int NumberOfElements(void); 35 void InputDuplicate(int input_enum,int output_enum); 36 36 37 37 }; -
issm/trunk/src/c/Container/Inputs.cpp
r13395 r13975 47 47 for ( object=objects.begin() ; object < objects.end(); object++ ){ 48 48 49 input= (Input*)(*object);49 input=dynamic_cast<Input*>(*object); 50 50 if (input->InstanceEnum()==enum_type){ 51 51 found=true; … … 75 75 for ( object=objects.begin() ; object < objects.end(); object++ ){ 76 76 77 input= (Input*)(*object);77 input=dynamic_cast<Input*>(*object); 78 78 if (input->InstanceEnum()==enum_type){ 79 79 found=true; … … 103 103 for ( object=objects.begin() ; object < objects.end(); object++ ){ 104 104 105 input= (Input*)(*object);105 input=dynamic_cast<Input*>(*object); 106 106 if (input->InstanceEnum()==enum_type){ 107 107 found=true; … … 131 131 for ( object=objects.begin() ; object < objects.end(); object++ ){ 132 132 133 input= (Input*)(*object);133 input=dynamic_cast<Input*>(*object); 134 134 if (input->InstanceEnum()==enum_type){ 135 135 found=true; … … 163 163 for ( object=objects.begin() ; object < objects.end(); object++ ){ 164 164 165 input= (Input*)(*object);165 input=dynamic_cast<Input*>(*object); 166 166 167 167 if (input->InstanceEnum()==in_input->InstanceEnum()){ … … 185 185 /*Delete existing input of newenumtype if it exists*/ 186 186 for ( object=objects.begin() ; object < objects.end(); object++ ){ 187 input= (Input*)(*object);187 input=dynamic_cast<Input*>(*object); 188 188 189 189 if (input->InstanceEnum()==newenumtype){ … … 196 196 for ( object=objects.begin() ; object < objects.end(); object++ ){ 197 197 198 input= (Input*)(*object);198 input=dynamic_cast<Input*>(*object); 199 199 200 200 if (input->InstanceEnum()==oldenumtype){ … … 207 207 /*FUNCTION Inputs::ConstrainMin{{{*/ 208 208 void Inputs::ConstrainMin(int constrain_enum, IssmDouble minimum){ 209 210 Input* constrain_input=NULL; 209 211 210 /*Find x and y inputs: */ 212 constrain_input=(Input*)this->GetInput(constrain_enum);211 Input* constrain_input=dynamic_cast<Input*>(this->GetInput(constrain_enum)); 213 212 214 213 /*some checks: */ … … 226 225 227 226 /*Get input*/ 228 Input* input= (Input*)this->GetInput(enumtype);227 Input* input=dynamic_cast<Input*>(this->GetInput(enumtype)); 229 228 230 229 /*Apply ContrainMin: */ … … 247 246 248 247 /*Get input*/ 249 Input* input= (Input*)this->GetInput(enumtype);248 Input* input=dynamic_cast<Input*>(this->GetInput(enumtype)); 250 249 251 250 /*Apply ContrainMin: */ … … 268 267 269 268 /*Get input*/ 270 Input* input= (Input*)this->GetInput(enumtype);269 Input* input=dynamic_cast<Input*>(this->GetInput(enumtype)); 271 270 272 271 /*Apply ContrainMin: */ … … 289 288 290 289 /*Get input*/ 291 Input* input= (Input*)this->GetInput(enumtype);290 Input* input=dynamic_cast<Input*>(this->GetInput(enumtype)); 292 291 293 292 /*Apply ContrainMin: */ … … 310 309 311 310 /*Get input*/ 312 Input* input= (Input*)this->GetInput(enumtype);311 Input* input=dynamic_cast<Input*>(this->GetInput(enumtype)); 313 312 314 313 /*Apply ContrainMin: */ … … 332 331 for ( object=objects.begin() ; object < objects.end(); object++ ){ 333 332 334 input= (Input*)(*object);333 input=dynamic_cast<Input*>(*object); 335 334 336 335 if (input->InstanceEnum()==enum_name){ … … 349 348 for ( object=objects.begin() ; object < objects.end(); object++ ){ 350 349 351 input= (Input*)(*object);350 input=dynamic_cast<Input*>(*object); 352 351 353 352 if (input->InstanceEnum()==enum_type){ … … 364 363 void Inputs::DuplicateInput(int original_enum,int new_enum){ 365 364 366 Input* original=NULL;367 Input* copy=NULL;368 369 365 /*Make a copy of the original input: */ 370 original=(Input*)this->GetInput(original_enum);366 Input* original=dynamic_cast<Input*>(this->GetInput(original_enum)); 371 367 if(!original)_error_("could not find input with enum: " << EnumToStringx(original_enum)); 372 copy=(Input*)original->copy();368 Input* copy=dynamic_cast<Input*>(original->copy()); 373 369 374 370 /*Change copy enum to reinitialized_enum: */ … … 376 372 377 373 /*Add copy into inputs, it will wipe off the one already there: */ 378 this->AddInput( (Input*)copy);374 this->AddInput(dynamic_cast<Input*>(copy)); 379 375 } 380 376 /*}}}*/ … … 394 390 395 391 /*Create new input*/ 396 inputin= (Input*)(*object);392 inputin=dynamic_cast<Input*>(*object); 397 393 inputout=inputin->SpawnTriaInput(indices); 398 394 … … 407 403 /*FUNCTION Inputs::AXPY{{{*/ 408 404 void Inputs::AXPY(int MeshYEnum, IssmDouble scalar, int MeshXEnum){ 409 410 Input* xinput=NULL;411 Input* yinput=NULL;412 405 413 406 /*Find x and y inputs: */ 414 xinput=(Input*)this->GetInput(MeshXEnum);415 yinput=(Input*)this->GetInput(MeshYEnum);407 Input* xinput=dynamic_cast<Input*>(this->GetInput(MeshXEnum)); 408 Input* yinput=dynamic_cast<Input*>(this->GetInput(MeshYEnum)); 416 409 417 410 /*some checks: */ … … 431 424 for ( object=objects.begin() ; object < objects.end(); object++ ){ 432 425 433 input= (Input*)(*object);426 input=dynamic_cast<Input*>(*object); 434 427 input->Configure(parameters); 435 428 -
issm/trunk/src/c/Container/Inputs.h
r12706 r13975 23 23 public: 24 24 25 /*constructors, destructors : {{{*/25 /*constructors, destructors*/ 26 26 Inputs(); 27 27 ~Inputs(); 28 28 29 /*}}}*/ 30 /*numerics: {{{*/ 31 int AddInput(Input* in_input); 32 void ChangeEnum(int enumtype,int new_enumtype); 33 void ConstrainMin(int constrain_enum, IssmDouble minimum); 34 int DeleteInput(int enum_type); 35 void DuplicateInput(int original_enum,int new_enum); 36 Input* GetInput(int enum_name); 37 Inputs* SpawnTriaInputs(int* indices); 38 void AXPY(int MeshYEnum, IssmDouble scalar, int MeshXEnum); 29 /*numerics*/ 30 int AddInput(Input* in_input); 31 void ChangeEnum(int enumtype,int new_enumtype); 32 void ConstrainMin(int constrain_enum, IssmDouble minimum); 33 int DeleteInput(int enum_type); 34 void DuplicateInput(int original_enum,int new_enum); 35 Input* GetInput(int enum_name); 36 Inputs* SpawnTriaInputs(int* indices); 37 void AXPY(int MeshYEnum, IssmDouble scalar, int MeshXEnum); 39 38 IssmDouble InfinityNorm(int enumtype); 40 39 IssmDouble Max(int enumtype); … … 42 41 IssmDouble Min(int enumtype); 43 42 IssmDouble MinAbs(int enumtype); 44 45 43 void GetInputAverage(IssmDouble* pvalue, int enum_type); 46 44 void GetInputValue(bool* pvalue,int enum_type); 47 45 void GetInputValue(int* pvalue,int enum_type); 48 46 void GetInputValue(IssmDouble* pvalue,int enum_type); 49 50 47 void Configure(Parameters* parameters); 51 /*}}}*/52 48 53 49 }; -
issm/trunk/src/c/Container/Loads.cpp
r12706 r13975 46 46 for ( object=objects.begin() ; object < objects.end(); object++ ){ 47 47 48 load= (Load*)(*object);48 load=dynamic_cast<Load*>(*object); 49 49 load->Configure(elements,loads,nodes,vertices,materials,parameters); 50 50 … … 53 53 } 54 54 /*}}}*/ 55 /*FUNCTION Loads::NumberOfLoads{{{*/ 55 /*FUNCTION Loads::IsPenalty{{{*/ 56 bool Loads::IsPenalty(int analysis_type){ 57 58 int ispenalty=0; 59 int allispenalty=0; 60 61 /*Now go through all loads, and get how many nodes they own, unless they are clone nodes: */ 62 for(int i=0;i<this->Size();i++){ 63 64 Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i)); 65 if (load->InAnalysis(analysis_type)){ 66 if(load->IsPenalty()) ispenalty++; 67 } 68 } 69 70 /*Grab sum of all cpus: */ 71 #ifdef _HAVE_MPI_ 72 MPI_Allreduce((void*)&ispenalty,(void*)&allispenalty,1,MPI_INT,MPI_SUM,IssmComm::GetComm()); 73 ispenalty=allispenalty; 74 #endif 75 76 if(ispenalty) 77 return true; 78 else 79 return false; 80 } 81 /*}}}*/ 82 /*FUNCTION Loads::MaxNumNodes{{{*/ 83 int Loads::MaxNumNodes(int analysis_type){ 84 85 int max=0; 86 int allmax; 87 int numnodes=0; 88 89 /*Now go through all loads, and get how many nodes they own, unless they are clone nodes: */ 90 for(int i=0;i<this->Size();i++){ 91 92 Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i)); 93 if (load->InAnalysis(analysis_type)){ 94 numnodes=load->GetNumberOfNodes(); 95 if(numnodes>max)max=numnodes; 96 } 97 } 98 99 /*Grab max of all cpus: */ 100 #ifdef _HAVE_MPI_ 101 MPI_Allreduce((void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm()); 102 max=allmax; 103 #endif 104 105 return max; 106 } 107 /*}}}*/ 108 /*FUNCTION Loads::NumberOfLoads(){{{*/ 56 109 int Loads::NumberOfLoads(void){ 57 110 58 int localloads =0;59 int numberofloads =0;111 int localloads; 112 int numberofloads; 60 113 61 114 /*Get number of local loads*/ … … 64 117 /*figure out total number of loads combining all the cpus (no clones here)*/ 65 118 #ifdef _HAVE_MPI_ 66 MPI_Reduce(&localloads,&numberofloads,1,MPI_INT,MPI_SUM,0, MPI_COMM_WORLD);67 MPI_Bcast(&numberofloads,1,MPI_INT,0, MPI_COMM_WORLD);119 MPI_Reduce(&localloads,&numberofloads,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() ); 120 MPI_Bcast(&numberofloads,1,MPI_INT,0,IssmComm::GetComm()); 68 121 #else 69 122 numberofloads=localloads; 70 123 #endif 71 124 125 return numberofloads; 126 } 127 /*}}}*/ 128 /*FUNCTION Loads::NumberOfLoads(int analysis){{{*/ 129 int Loads::NumberOfLoads(int analysis_type){ 130 131 int localloads = 0; 132 int numberofloads; 133 134 /*Get number of local loads*/ 135 for(int i=0;i<this->Size();i++){ 136 137 Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i)); 138 139 /*Check that this load corresponds to our analysis currently being carried out: */ 140 if (load->InAnalysis(analysis_type)) localloads++; 141 } 142 143 /*figure out total number of loads combining all the cpus (no clones here)*/ 144 #ifdef _HAVE_MPI_ 145 MPI_Reduce(&localloads,&numberofloads,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() ); 146 MPI_Bcast(&numberofloads,1,MPI_INT,0,IssmComm::GetComm()); 147 #else 148 numberofloads=localloads; 149 #endif 72 150 73 151 return numberofloads; 152 } 153 /*}}}*/ 154 /*FUNCTION Loads::Size(){{{*/ 155 int Loads::Size(void){ 156 157 return this->DataSet::Size(); 158 } 159 /*}}}*/ 160 /*FUNCTION Loads::Size(int analysis){{{*/ 161 int Loads::Size(int analysis_type){ 162 163 int localloads = 0; 164 165 /*Get number of local loads*/ 166 for(int i=0;i<this->Size();i++){ 167 168 Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i)); 169 170 /*Check that this load corresponds to our analysis currently being carried out: */ 171 if (load->InAnalysis(analysis_type)) localloads++; 172 } 173 174 return localloads; 74 175 } 75 176 /*}}}*/ … … 82 183 for ( object=objects.begin() ; object < objects.end(); object++ ){ 83 184 84 load= (Load*)(*object);185 load=dynamic_cast<Load*>(*object); 85 186 load->SetCurrentConfiguration(elements,loads,nodes,vertices,materials,parameters); 86 187 -
issm/trunk/src/c/Container/Loads.h
r12706 r13975 20 20 public: 21 21 22 /*constructors, destructors : {{{*/22 /*constructors, destructors*/ 23 23 Loads(); 24 24 ~Loads(); 25 /*}}}*/ 26 /*numerics : {{{*/25 26 /*numerics*/ 27 27 void Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 28 bool IsPenalty(int analysis); 29 int MaxNumNodes(int analysis); 28 30 int NumberOfLoads(void); 31 int NumberOfLoads(int analysis); 29 32 void SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 30 /*}}}*/ 33 int Size(int analysis); 34 int Size(void); 31 35 32 36 }; -
issm/trunk/src/c/Container/Materials.cpp
r12706 r13975 46 46 for ( object=objects.begin() ; object < objects.end(); object++ ){ 47 47 48 material= (Material*)(*object);48 material=dynamic_cast<Material*>(*object); 49 49 material->Configure(elements); 50 50 -
issm/trunk/src/c/Container/Materials.h
r12706 r13975 19 19 public: 20 20 21 /*constructors, destructors : {{{*/21 /*constructors, destructors*/ 22 22 Materials(); 23 23 ~Materials(); 24 /*}}}*/ 25 /*numerics : {{{*/24 25 /*numerics*/ 26 26 void Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 27 /*}}}*/28 27 29 28 }; -
issm/trunk/src/c/Container/Nodes.cpp
r12706 r13975 46 46 for ( object=objects.begin() ; object < objects.end(); object++ ){ 47 47 48 node= (Node*)(*object);48 node=dynamic_cast<Node*>(*object); 49 49 node->Configure(nodes,vertices); 50 50 … … 55 55 /*FUNCTION Nodes::DistributeDofs{{{*/ 56 56 void Nodes::DistributeDofs(int analysis_type,int setenum){ 57 58 extern int num_procs;59 extern int my_rank;60 57 61 58 int i; … … 67 64 int numnodes=0; 68 65 66 /*recover my_rank:*/ 67 int my_rank = IssmComm::GetRank(); 68 int num_procs = IssmComm::GetSize(); 69 69 70 /*some check: */ 70 71 _assert_(setenum==GsetEnum || setenum==FsetEnum || setenum==SsetEnum); … … 72 73 /*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/ 73 74 for (i=0;i<this->Size();i++){ 74 Node* node= (Node*)this->GetObjectByOffset(i);75 Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i)); 75 76 76 77 /*Check that this node corresponds to our analysis currently being carried out: */ … … 86 87 alldofcount=xNew<int>(num_procs); 87 88 #ifdef _HAVE_MPI_ 88 MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0, MPI_COMM_WORLD);89 MPI_Bcast(alldofcount,num_procs,MPI_INT,0, MPI_COMM_WORLD);89 MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,IssmComm::GetComm()); 90 MPI_Bcast(alldofcount,num_procs,MPI_INT,0,IssmComm::GetComm()); 90 91 #else 91 92 alldofcount[0]=dofcount; … … 94 95 /* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/ 95 96 dofcount=0; 96 if(my_rank!=0){ 97 for(i=0;i<my_rank;i++){ 98 dofcount+=alldofcount[i]; 99 } 97 for(i=0;i<my_rank;i++){ 98 dofcount+=alldofcount[i]; 100 99 } 101 100 for (i=0;i<this->Size();i++){ 102 101 /*Check that this node corresponds to our analysis currently being carried out: */ 103 Node* node= (Node*)this->GetObjectByOffset(i);102 Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i)); 104 103 if (node->InAnalysis(analysis_type)){ 105 104 node->OffsetDofs(dofcount,setenum); … … 118 117 119 118 for (i=0;i<this->Size();i++){ 120 Node* node= (Node*)this->GetObjectByOffset(i);119 Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i)); 121 120 if (node->InAnalysis(analysis_type)){ 122 121 node->ShowTrueDofs(truedofs,maxdofspernode,setenum);//give maxdofspernode, column size, so that nodes can index into truedofs … … 125 124 126 125 #ifdef _HAVE_MPI_ 127 MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX, MPI_COMM_WORLD);126 MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX,IssmComm::GetComm()); 128 127 #else 129 128 for(i=0;i<numnodes*maxdofspernode;i++)alltruedofs[i]=truedofs[i]; … … 132 131 /* Now every cpu knows the true dofs of everyone else that is not a clone*/ 133 132 for (i=0;i<this->Size();i++){ 134 Node* node= (Node*)this->GetObjectByOffset(i);133 Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i)); 135 134 if (node->InAnalysis(analysis_type)){ 136 135 node->UpdateCloneDofs(alltruedofs,maxdofspernode,setenum); … … 148 147 149 148 int i; 150 externint num_procs;151 152 int* ranks=NULL; 153 int* minranks=NULL;154 int numnodes;149 int num_procs; 150 int numnodes; 151 152 /*recover num_procs: */ 153 num_procs=IssmComm::GetSize(); 155 154 156 155 /*Figure out number of nodes for this analysis: */ … … 158 157 159 158 /*Allocate ranks: */ 160 ranks=xNew<int>(numnodes); 161 minranks=xNew<int>(numnodes); 162 159 int* ranks = xNew<int>(numnodes); 160 int* minranks = xNew<int>(numnodes); 163 161 for(i=0;i<numnodes;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit. 164 162 … … 171 169 * order of cpu rank. This is also why we initialized this array to num_procs.*/ 172 170 #ifdef _HAVE_MPI_ 173 MPI_Allreduce ( (void*)ranks,(void*)minranks,numnodes,MPI_INT,MPI_MIN,MPI_COMM_WORLD);171 MPI_Allreduce((void*)ranks,(void*)minranks,numnodes,MPI_INT,MPI_MIN,IssmComm::GetComm()); 174 172 #else 175 173 for(i=0;i<numnodes;i++)minranks[i]=ranks[i]; … … 179 177 for(i=0;i<this->Size();i++){ 180 178 181 Node* node= (Node*)this->GetObjectByOffset(i);179 Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i)); 182 180 183 181 /*Check that this node corresponds to our analysis currently being carried out: */ … … 199 197 200 198 int i; 201 int 202 int 203 int 199 int max=0; 200 int allmax; 201 int numdofs=0; 204 202 205 203 /*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */ 206 204 for(i=0;i<this->Size();i++){ 207 205 208 Node* node= (Node*)this->GetObjectByOffset(i);206 Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i)); 209 207 210 208 /*Check that this node corresponds to our analysis currently being carried out: */ … … 212 210 213 211 numdofs=node->GetNumberOfDofs(NoneApproximationEnum,setenum); 214 if 212 if(numdofs>max)max=numdofs; 215 213 } 216 214 } … … 218 216 /*Grab max of all cpus: */ 219 217 #ifdef _HAVE_MPI_ 220 MPI_Allreduce ( (void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);218 MPI_Allreduce((void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm()); 221 219 max=allmax; 222 220 #endif … … 228 226 int Nodes::NumberOfDofs(int analysis_type,int setenum){ 229 227 230 int i; 231 228 int allnumdofs; 229 230 /*Get number of dofs on current cpu (excluding clones)*/ 231 int numdofs=this->NumberOfDofsLocal(analysis_type,setenum); 232 233 /*Gather from all cpus: */ 234 #ifdef _HAVE_MPI_ 235 MPI_Allreduce ( (void*)&numdofs,(void*)&allnumdofs,1,MPI_INT,MPI_SUM,IssmComm::GetComm()); 236 #else 237 allnumdofs=numdofs; 238 #endif 239 return allnumdofs; 240 } 241 /*}}}*/ 242 /*FUNCTION Nodes::NumberOfDofsLocal{{{*/ 243 int Nodes::NumberOfDofsLocal(int analysis_type,int setenum){ 244 232 245 int numdofs=0; 233 int allnumdofs;234 246 235 247 /*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */ 236 for(i =0;i<this->Size();i++){237 238 Node* node= (Node*)this->GetObjectByOffset(i);248 for(int i=0;i<this->Size();i++){ 249 250 Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i)); 239 251 240 252 /*Check that this node corresponds to our analysis currently being carried out: */ … … 243 255 /*Ok, this object is a node, ask it to plug values into partition: */ 244 256 if (!node->IsClone()){ 245 246 257 numdofs+=node->GetNumberOfDofs(NoneApproximationEnum,setenum); 247 248 258 } 249 259 } 250 260 } 251 261 252 /*Gather from all cpus: */ 253 #ifdef _HAVE_MPI_ 254 MPI_Allreduce ( (void*)&numdofs,(void*)&allnumdofs,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); 255 #else 256 allnumdofs=numdofs; 257 #endif 258 return allnumdofs; 262 return numdofs; 259 263 } 260 264 /*}}}*/ … … 264 268 /*Careful! only use once all clones have been setup for all nodes!: */ 265 269 266 int i; 267 268 int numnodes=0; 269 int allnumnodes=0; 270 int numnodes=0; 271 int allnumnodes=0; 270 272 271 273 /*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */ 272 for(i =0;i<this->Size();i++){273 Node* node= (Node*)this->GetObjectByOffset(i);274 for(int i=0;i<this->Size();i++){ 275 Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i)); 274 276 275 277 /*Ok, this object is a node, ask it to plug values into partition: */ … … 279 281 /*Gather from all cpus: */ 280 282 #ifdef _HAVE_MPI_ 281 MPI_Allreduce ( (void*)&numnodes,(void*)&allnumnodes,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);283 MPI_Allreduce ( (void*)&numnodes,(void*)&allnumnodes,1,MPI_INT,MPI_SUM,IssmComm::GetComm()); 282 284 #else 283 285 allnumnodes=numnodes; … … 298 300 for(i=0;i<this->Size();i++){ 299 301 300 Node* node= (Node*)this->GetObjectByOffset(i);302 Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i)); 301 303 302 304 /*Check that this node corresponds to our analysis currently being carried out: */ … … 309 311 310 312 #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 MPI_Reduce (&max_sid,&node_max_sid,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() ); 314 MPI_Bcast(&node_max_sid,1,MPI_INT,0,IssmComm::GetComm()); 313 315 max_sid=node_max_sid; 314 316 #endif 315 317 316 if(max_sid==1){ 317 return 0; 318 } 319 else{ 320 /*sid starts at 0*/ 321 max_sid++; 322 323 /*return*/ 324 return max_sid; 325 } 318 /*sid starts at 0*/ 319 max_sid++; 320 321 /*return*/ 322 return max_sid; 326 323 } 327 324 /*}}}*/ … … 329 326 void Nodes::Ranks(int* ranks,int analysis_type){ 330 327 328 int my_rank; 329 int sid; 330 331 /*recover my_rank:*/ 332 my_rank=IssmComm::GetRank(); 333 331 334 /*Go through nodes, and for each object, report it cpu: */ 332 333 int i; 334 int rank; 335 int sid; 336 337 for(i=0;i<this->Size();i++){ 338 339 Node* node=(Node*)this->GetObjectByOffset(i); 340 341 /*Check that this node corresponds to our analysis currently being carried out: */ 342 if (node->InAnalysis(analysis_type)){ 343 344 rank=node->MyRank(); 335 for(int i=0;i<this->Size();i++){ 336 337 Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i)); 338 339 /*Check that this node corresponds to our analysis currently being carried out: */ 340 if (node->InAnalysis(analysis_type)){ 341 /*Plug rank into ranks, according to sid: */ 345 342 sid=node->Sid(); 346 347 /*Plug rank into ranks, according to id: */ 348 ranks[sid]=rank; 349 } 350 } 351 return; 343 ranks[sid]=my_rank; 344 } 345 } 352 346 } 353 347 /*}}}*/ … … 358 352 Node* node=NULL; 359 353 360 for ( 361 362 node= (Node*)(*object);354 for (object=objects.begin() ; object < objects.end(); object++ ){ 355 356 node=dynamic_cast<Node*>(*object); 363 357 node->SetCurrentConfiguration(nodes,vertices); 364 358 365 359 } 366 367 } 368 /*}}}*/ 360 } 361 /*}}}*/ -
issm/trunk/src/c/Container/Nodes.h
r12706 r13975 13 13 public: 14 14 15 /*constructors, destructors : {{{*/15 /*constructors, destructors*/ 16 16 Nodes(); 17 17 ~Nodes(); 18 /*}}}*/ 19 /*numerics : {{{*/18 19 /*numerics*/ 20 20 void Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 21 21 void DistributeDofs(int analysis_type,int SETENUM); … … 23 23 int MaxNumDofs(int analysis_type,int setenum); 24 24 int NumberOfDofs(int analysis_type,int setenum); 25 int NumberOfDofsLocal(int analysis_type,int setenum); 25 26 int NumberOfNodes(int analysis_type); 26 27 int NumberOfNodes(void); 27 28 void Ranks(int* ranks,int analysis_type); 28 29 void SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 29 /*}}}*/30 30 31 31 }; -
issm/trunk/src/c/Container/Observations.cpp
r13395 r13975 40 40 41 41 /*Intermediaries*/ 42 int i, j,maxdepth,level,counter,index;42 int i,maxdepth,level,counter,index; 43 43 int xi,yi; 44 44 IssmPDouble xmin,xmax,ymin,ymax; … … 88 88 this->quadtree->ClosestObs(&index,x[i],y[i]); 89 89 if(index>=0){ 90 observation= (Observation*)this->GetObjectByOffset(index);90 observation=dynamic_cast<Observation*>(this->GetObjectByOffset(index)); 91 91 if(pow(observation->x-x[i],2)+pow(observation->y-y[i],2) < minspacing) continue; 92 92 } … … 121 121 122 122 /*Output and Intermediaries*/ 123 bool stop;124 123 int nobs,i,index; 125 124 IssmPDouble h2,hmin2,radius2; … … 136 135 this->quadtree->RangeSearch(&indices,&nobs,x_interp,y_interp,radius); 137 136 for (i=0;i<nobs;i++){ 138 observation= (Observation*)this->GetObjectByOffset(indices[i]);137 observation=dynamic_cast<Observation*>(this->GetObjectByOffset(indices[i])); 139 138 h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp); 140 139 … … 158 157 } 159 158 else{ 160 observation= (Observation*)this->GetObjectByOffset(indices[index]);159 observation=dynamic_cast<Observation*>(this->GetObjectByOffset(indices[index])); 161 160 *px=observation->x; 162 161 *py=observation->y; … … 195 194 nobs = 0; 196 195 for (i=0;i<tempnobs;i++){ 197 observation= (Observation*)this->GetObjectByOffset(tempindices[i]);196 observation=dynamic_cast<Observation*>(this->GetObjectByOffset(tempindices[i])); 198 197 h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp); 199 198 … … 237 236 /*Loop over all observations and fill in x, y and obs*/ 238 237 for (i=0;i<nobs;i++){ 239 observation= (Observation*)this->GetObjectByOffset(indices[i]);238 observation=dynamic_cast<Observation*>(this->GetObjectByOffset(indices[i])); 240 239 observation->WriteXYObs(&x[i],&y[i],&obs[i]); 241 240 } … … 266 265 obs = xNew<IssmPDouble>(nobs); 267 266 for(int i=0;i<this->Size();i++){ 268 observation= (Observation*)this->GetObjectByOffset(i);267 observation=dynamic_cast<Observation*>(this->GetObjectByOffset(i)); 269 268 observation->WriteXYObs(&x[i],&y[i],&obs[i]); 270 269 } … … 451 450 452 451 for(i=0;i<this->Size();i++){ 453 observation1= (Observation*)this->GetObjectByOffset(i);452 observation1=dynamic_cast<Observation*>(this->GetObjectByOffset(i)); 454 453 455 454 for(j=i+1;j<this->Size();j++){ 456 observation2= (Observation*)this->GetObjectByOffset(j);455 observation2=dynamic_cast<Observation*>(this->GetObjectByOffset(j)); 457 456 458 457 distance=sqrt(pow(observation1->x - observation2->x,2.) + pow(observation1->y - observation2->y,2.)); -
issm/trunk/src/c/Container/Observations.h
r13395 r13975 37 37 }; 38 38 #endif //ifndef _OBSERVATIONS_H_ 39 -
issm/trunk/src/c/Container/Options.cpp
r13395 r13975 42 42 43 43 char* name=NULL; 44 44 45 45 vector<Object*>::iterator object; 46 46 Option* option=NULL; … … 60 60 for(object=objects.begin();object<objects.end();object++){ 61 61 62 option= (Option*)(*object);62 option=dynamic_cast<Option*>(*object); 63 63 if (!strcmp(option->Name(),name)){ 64 64 _error_("Options \"" << name << "\" found multiple times"); … … 82 82 for ( object=objects.begin() ; object < objects.end(); object++ ){ 83 83 84 option= (Option*)(*object);84 option=dynamic_cast<Option*>(*object); 85 85 if (!strncmp(name,option->Name(),strlen(option->Name()))){ 86 86 -
issm/trunk/src/c/Container/Options.h
r13395 r13975 22 22 int AddOption(Option* in_oobject); 23 23 Option* GetOption(const char* name); 24 25 24 26 25 template <class OptionType> void Get(OptionType* pvalue,const char* name){ /*{{{*/ 27 26 28 vector<Object*>::iterator object;29 GenericOption<OptionType>* genericoption=NULL;30 31 27 /*Get option*/ 32 genericoption=(GenericOption<OptionType>*)GetOption(name);28 GenericOption<OptionType>* genericoption=dynamic_cast<GenericOption<OptionType>*>(GetOption(name)); 33 29 34 30 /*If the pointer is not NULL, the option has been found*/ … … 44 40 template <class OptionType> void Get(OptionType* pvalue,int* pnumel, const char* name){ /*{{{*/ 45 41 46 vector<Object*>::iterator object;47 GenericOption<OptionType>* genericoption=NULL;48 49 42 /*Get option*/ 50 genericoption=(GenericOption<OptionType>*)GetOption(name);43 GenericOption<OptionType>* genericoption=dynamic_cast<GenericOption<OptionType>*>(GetOption(name)); 51 44 52 45 /*If the pointer is not NULL, the option has been found*/ … … 63 56 template <class OptionType> void Get(OptionType* pvalue,const char* name,OptionType default_value){ /*{{{*/ 64 57 65 vector<Object*>::iterator object;66 GenericOption<OptionType>* genericoption=NULL;67 68 58 /*Get option*/ 69 genericoption=(GenericOption<OptionType>*)GetOption(name);59 GenericOption<OptionType>* genericoption=dynamic_cast<GenericOption<OptionType>*>(GetOption(name)); 70 60 71 61 /*If the pointer is not NULL, the option has been found*/ … … 80 70 template <class OptionType> void Get(OptionType* pvalue,int* pnumel, const char* name,OptionType default_value){ /*{{{*/ 81 71 82 vector<Object*>::iterator object;83 GenericOption<OptionType>* genericoption=NULL;84 85 72 /*Get option*/ 86 genericoption=(GenericOption<OptionType>*)GetOption(name);73 GenericOption<OptionType>* genericoption=dynamic_cast<GenericOption<OptionType>*>(GetOption(name)); 87 74 88 75 /*If the pointer is not NULL, the option has been found*/ … … 103 90 template <> inline void Options::Get(char** pvalue,const char* name,char* default_value){ /*{{{*/ 104 91 105 vector<Object*>::iterator object;106 GenericOption<char*>* genericoption=NULL;107 108 92 /*Get option*/ 109 genericoption=(GenericOption<char*>*)GetOption(name);93 GenericOption<char*>* genericoption=dynamic_cast<GenericOption<char*>*>(GetOption(name)); 110 94 111 95 /*If the pointer is not NULL, the option has been found*/ … … 115 99 else{ 116 100 /*Make a copy*/ 117 char* outstring=NULL; 118 int stringsize; 119 120 stringsize=strlen(default_value)+1; 121 outstring=xNew<char>(stringsize); 101 int stringsize=strlen(default_value)+1; 102 char* outstring=xNew<char>(stringsize); 122 103 xMemCpy<char>(outstring,default_value,stringsize); 123 104 *pvalue=outstring; -
issm/trunk/src/c/Container/Parameters.cpp
r13395 r13975 45 45 46 46 for ( object=objects.begin() ; object < objects.end(); object++ ){ 47 param= (Param*)(*object);47 param=dynamic_cast<Param*>(*object); 48 48 if(param->InstanceEnum()==enum_type) return true; 49 49 } … … 53 53 /*FUNCTION Parameters::FindParam(bool* pbool,int enum_type){{{*/ 54 54 void Parameters::FindParam(bool* pbool,int enum_type){ _assert_(this); 55 56 vector<Object*>::iterator object; 57 Param* param=NULL; 58 59 for ( object=objects.begin() ; object < objects.end(); object++ ){ 60 61 param= (Param*)(*object);55 56 vector<Object*>::iterator object; 57 Param* param=NULL; 58 59 for ( object=objects.begin() ; object < objects.end(); object++ ){ 60 61 param=dynamic_cast<Param*>(*object); 62 62 if(param->InstanceEnum()==enum_type){ 63 63 param->GetParameterValue(pbool); … … 70 70 /*FUNCTION Parameters::FindParam(int* pinteger,int enum_type){{{*/ 71 71 void Parameters::FindParam(int* pinteger,int enum_type){ _assert_(this); 72 73 vector<Object*>::iterator object; 74 Param* param=NULL; 75 76 for ( object=objects.begin() ; object < objects.end(); object++ ){ 77 78 param= (Param*)(*object);72 73 vector<Object*>::iterator object; 74 Param* param=NULL; 75 76 for ( object=objects.begin() ; object < objects.end(); object++ ){ 77 78 param=dynamic_cast<Param*>(*object); 79 79 if(param->InstanceEnum()==enum_type){ 80 80 param->GetParameterValue(pinteger); … … 87 87 /*FUNCTION Parameters::FindParam(IssmDouble* pscalar, int enum_type){{{*/ 88 88 void Parameters::FindParam(IssmDouble* pscalar, int enum_type){ _assert_(this); 89 90 vector<Object*>::iterator object; 91 Param* param=NULL; 92 93 for ( object=objects.begin() ; object < objects.end(); object++ ){ 94 95 param= (Param*)(*object);89 90 vector<Object*>::iterator object; 91 Param* param=NULL; 92 93 for ( object=objects.begin() ; object < objects.end(); object++ ){ 94 95 param=dynamic_cast<Param*>(*object); 96 96 if(param->InstanceEnum()==enum_type){ 97 97 param->GetParameterValue(pscalar); … … 110 110 for ( object=objects.begin() ; object < objects.end(); object++ ){ 111 111 112 param= (Param*)(*object);112 param=dynamic_cast<Param*>(*object); 113 113 if(param->InstanceEnum()==enum_type){ 114 114 param->GetParameterValue(pscalar,time); … … 121 121 /*FUNCTION Parameters::FindParam(char** pstring,int enum_type){{{*/ 122 122 void Parameters::FindParam(char** pstring,int enum_type){ _assert_(this); 123 124 vector<Object*>::iterator object; 125 Param* param=NULL; 126 127 for ( object=objects.begin() ; object < objects.end(); object++ ){ 128 129 param= (Param*)(*object);123 124 vector<Object*>::iterator object; 125 Param* param=NULL; 126 127 for ( object=objects.begin() ; object < objects.end(); object++ ){ 128 129 param=dynamic_cast<Param*>(*object); 130 130 if(param->InstanceEnum()==enum_type){ 131 131 param->GetParameterValue(pstring); … … 139 139 /*FUNCTION Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){{{*/ 140 140 void Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){ _assert_(this); 141 142 vector<Object*>::iterator object; 143 Param* param=NULL; 144 145 for ( object=objects.begin() ; object < objects.end(); object++ ){ 146 147 param= (Param*)(*object);141 142 vector<Object*>::iterator object; 143 Param* param=NULL; 144 145 for ( object=objects.begin() ; object < objects.end(); object++ ){ 146 147 param=dynamic_cast<Param*>(*object); 148 148 if(param->InstanceEnum()==enum_type){ 149 149 param->GetParameterValue(pstringarray,pM); … … 163 163 for ( object=objects.begin() ; object < objects.end(); object++ ){ 164 164 165 param= (Param*)(*object);165 param=dynamic_cast<Param*>(*object); 166 166 if(param->InstanceEnum()==enum_type){ 167 167 param->GetParameterValue(pintarray,pM); … … 181 181 for ( object=objects.begin() ; object < objects.end(); object++ ){ 182 182 183 param= (Param*)(*object);183 param=dynamic_cast<Param*>(*object); 184 184 if(param->InstanceEnum()==enum_type){ 185 185 param->GetParameterValue(pintarray,pM,pN); … … 199 199 for ( object=objects.begin() ; object < objects.end(); object++ ){ 200 200 201 param= (Param*)(*object);201 param=dynamic_cast<Param*>(*object); 202 202 if(param->InstanceEnum()==enum_type){ 203 203 param->GetParameterValue(pIssmDoublearray,pM); … … 217 217 for ( object=objects.begin() ; object < objects.end(); object++ ){ 218 218 219 param= (Param*)(*object);219 param=dynamic_cast<Param*>(*object); 220 220 if(param->InstanceEnum()==enum_type){ 221 221 param->GetParameterValue(pIssmDoublearray,pM,pN); … … 229 229 /*FUNCTION Parameters::FindParam(IssmDouble*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){{{*/ 230 230 void Parameters::FindParam(IssmDouble*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){ _assert_(this); 231 232 vector<Object*>::iterator object; 233 Param* param=NULL; 234 235 for ( object=objects.begin() ; object < objects.end(); object++ ){ 236 237 param= (Param*)(*object);231 232 vector<Object*>::iterator object; 233 Param* param=NULL; 234 235 for ( object=objects.begin() ; object < objects.end(); object++ ){ 236 237 param=dynamic_cast<Param*>(*object); 238 238 if(param->InstanceEnum()==enum_type){ 239 239 param->GetParameterValue(parray,pM,pmdims_array,pndims_array); … … 246 246 /*FUNCTION Parameters::FindParam(Vector<IssmDouble>** pvec,int enum_type){{{*/ 247 247 void Parameters::FindParam(Vector<IssmDouble>** pvec,int enum_type){ _assert_(this); 248 249 vector<Object*>::iterator object; 250 Param* param=NULL; 251 252 for ( object=objects.begin() ; object < objects.end(); object++ ){ 253 254 param= (Param*)(*object);248 249 vector<Object*>::iterator object; 250 Param* param=NULL; 251 252 for ( object=objects.begin() ; object < objects.end(); object++ ){ 253 254 param=dynamic_cast<Param*>(*object); 255 255 if(param->InstanceEnum()==enum_type){ 256 256 param->GetParameterValue(pvec); … … 264 264 /*FUNCTION Parameters::FindParam(Matrix<IssmDouble>** pmat,int enum_type){{{*/ 265 265 void Parameters::FindParam(Matrix<IssmDouble>** pmat,int enum_type){ _assert_(this); 266 267 vector<Object*>::iterator object; 268 Param* param=NULL; 269 270 for ( object=objects.begin() ; object < objects.end(); object++ ){ 271 272 param= (Param*)(*object);266 267 vector<Object*>::iterator object; 268 Param* param=NULL; 269 270 for ( object=objects.begin() ; object < objects.end(); object++ ){ 271 272 param=dynamic_cast<Param*>(*object); 273 273 if(param->InstanceEnum()==enum_type){ 274 274 param->GetParameterValue(pmat); … … 288 288 for ( object=objects.begin() ; object < objects.end(); object++ ){ 289 289 290 param= (Param*)(*object);290 param=dynamic_cast<Param*>(*object); 291 291 if(param->InstanceEnum()==enum_type){ 292 292 param->GetParameterValue(pfid); 293 return; 294 } 295 } 296 _error_("could not find parameter " << EnumToStringx(enum_type)); 297 } 298 /*}}}*/ 299 /*FUNCTION Parameters::FindParam(DataSet** pdataset,int enum_type){{{*/ 300 void Parameters::FindParam(DataSet** pdataset,int enum_type){ 301 _assert_(this); 302 303 vector<Object*>::iterator object; 304 Param* param=NULL; 305 306 for ( object=objects.begin() ; object < objects.end(); object++ ){ 307 308 param=dynamic_cast<Param*>(*object); 309 if(param->InstanceEnum()==enum_type){ 310 param->GetParameterValue(pdataset); 293 311 return; 294 312 } … … 302 320 303 321 Param* param=NULL; 304 305 /*first, figure out if the param has already been created: */ 306 param= (Param*)this->FindParamObject(enum_type);322 323 /*first, figure out if the param has already been created: */ 324 param=dynamic_cast<Param*>(this->FindParamObject(enum_type)); 307 325 308 326 if(param) param->SetValue(boolean); //already exists, just set it. … … 314 332 315 333 Param* param=NULL; 316 317 /*first, figure out if the param has already been created: */ 318 param= (Param*)this->FindParamObject(enum_type);334 335 /*first, figure out if the param has already been created: */ 336 param=dynamic_cast<Param*>(this->FindParamObject(enum_type)); 319 337 320 338 if(param) param->SetValue(integer); //already exists, just set it. … … 326 344 327 345 Param* param=NULL; 328 329 /*first, figure out if the param has already been created: */ 330 param= (Param*)this->FindParamObject(enum_type);346 347 /*first, figure out if the param has already been created: */ 348 param=dynamic_cast<Param*>(this->FindParamObject(enum_type)); 331 349 332 350 if(param) param->SetValue(scalar); //already exists, just set it. … … 338 356 339 357 Param* param=NULL; 340 341 /*first, figure out if the param has already been created: */ 342 param= (Param*)this->FindParamObject(enum_type);358 359 /*first, figure out if the param has already been created: */ 360 param=dynamic_cast<Param*>(this->FindParamObject(enum_type)); 343 361 344 362 if(param) param->SetValue(string); //already exists, just set it. … … 350 368 351 369 Param* param=NULL; 352 353 /*first, figure out if the param has already been created: */ 354 param= (Param*)this->FindParamObject(enum_type);370 371 /*first, figure out if the param has already been created: */ 372 param=dynamic_cast<Param*>(this->FindParamObject(enum_type)); 355 373 356 374 if(param) param->SetValue(stringarray,M); //already exists, just set it. … … 362 380 363 381 Param* param=NULL; 364 365 /*first, figure out if the param has already been created: */ 366 param= (Param*)this->FindParamObject(enum_type);382 383 /*first, figure out if the param has already been created: */ 384 param=dynamic_cast<Param*>(this->FindParamObject(enum_type)); 367 385 368 386 if(param) param->SetValue(IssmDoublearray,M); //already exists, just set it. … … 374 392 375 393 Param* param=NULL; 376 377 /*first, figure out if the param has already been created: */ 378 param= (Param*)this->FindParamObject(enum_type);394 395 /*first, figure out if the param has already been created: */ 396 param=dynamic_cast<Param*>(this->FindParamObject(enum_type)); 379 397 380 398 if(param) param->SetValue(IssmDoublearray,M,N); //already exists, just set it. … … 388 406 389 407 /*first, figure out if the param has already been created: */ 390 param= (Param*)this->FindParamObject(enum_type);408 param=dynamic_cast<Param*>(this->FindParamObject(enum_type)); 391 409 392 410 if(param) param->SetValue(intarray,M); //already exists, just set it. … … 400 418 401 419 /*first, figure out if the param has already been created: */ 402 param= (Param*)this->FindParamObject(enum_type);420 param=dynamic_cast<Param*>(this->FindParamObject(enum_type)); 403 421 404 422 if(param) param->SetValue(intarray,M,N); //already exists, just set it. … … 410 428 411 429 Param* param=NULL; 412 413 /*first, figure out if the param has already been created: */ 414 param= (Param*)this->FindParamObject(enum_type);430 431 /*first, figure out if the param has already been created: */ 432 param=dynamic_cast<Param*>(this->FindParamObject(enum_type)); 415 433 416 434 if(param) param->SetValue(vector); //already exists, just set it. … … 422 440 423 441 Param* param=NULL; 424 425 /*first, figure out if the param has already been created: */ 426 param= (Param*)this->FindParamObject(enum_type);442 443 /*first, figure out if the param has already been created: */ 444 param=dynamic_cast<Param*>(this->FindParamObject(enum_type)); 427 445 428 446 if(param) param->SetValue(matrix); //already exists, just set it. … … 436 454 437 455 /*first, figure out if the param has already been created: */ 438 param= (Param*)this->FindParamObject(enum_type);456 param=dynamic_cast<Param*>(this->FindParamObject(enum_type)); 439 457 440 458 if(param) param->SetValue(fid); //already exists, just set it. … … 449 467 450 468 for ( object=objects.begin() ; object < objects.end(); object++ ){ 451 param= (Param*)(*object);469 param=dynamic_cast<Param*>(*object); 452 470 param->UnitConversion(direction_enum); 453 471 } … … 464 482 for ( object=objects.begin() ; object < objects.end(); object++ ){ 465 483 466 param= (Param*)(*object);484 param=dynamic_cast<Param*>(*object); 467 485 if(param->InstanceEnum()==enum_type){ 468 486 return (*object); -
issm/trunk/src/c/Container/Parameters.h
r13395 r13975 44 44 void FindParam(Matrix<IssmDouble>** pmat,int enum_type); 45 45 void FindParam(FILE** pfid,int enum_type); 46 46 void FindParam(DataSet** pdataset, int enum_type); 47 47 48 void SetParam(bool boolean,int enum_type); 48 49 void SetParam(int integer,int enum_type); -
issm/trunk/src/c/Container/Results.cpp
r12706 r13975 66 66 /*FUNCTION Results::Write{{{*/ 67 67 void Results::Write(Parameters* parameters){ 68 68 69 69 int i; 70 70 FILE *fid = NULL; … … 76 76 77 77 for(i=0;i<this->Size();i++){ 78 ExternalResult* result= (ExternalResult*)this->GetObjectByOffset(i);78 ExternalResult* result=dynamic_cast<ExternalResult*>(this->GetObjectByOffset(i)); 79 79 80 80 /*write result to disk: */ -
issm/trunk/src/c/Container/Results.h
r12706 r13975 20 20 public: 21 21 22 /*constructors, destructors : {{{*/22 /*constructors, destructors*/ 23 23 Results(); 24 24 ~Results(); 25 /*}}}*/ 26 /*numerics : {{{*/25 26 /*numerics*/ 27 27 Results* SpawnTriaResults(int* indices); 28 void Write(Parameters* parameters); 29 /*}}}*/ 28 void Write(Parameters* parameters); 30 29 }; 31 30 #endif //ifndef _RESULTS_H_ 32 -
issm/trunk/src/c/Container/Vertices.cpp
r12706 r13975 38 38 39 39 /*Numerics management*/ 40 /*FUNCTION Vertices::Distribute Dofs{{{*/41 void Vertices::Distribute Dofs(int numberofobjects,int numberofdofsperobject){42 43 externint num_procs;44 externint my_rank;40 /*FUNCTION Vertices::DistributePids{{{*/ 41 void Vertices::DistributePids(int numberofobjects){ 42 43 int num_procs; 44 int my_rank; 45 45 46 46 int i; 47 int dofcount=0; 48 int* alldofcount=NULL; 49 int* truedofs=NULL; 50 int* alltruedofs=NULL; 51 52 /*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/ 47 int pidcount = 0; 48 int *allpidcount = NULL; 49 int *truepids = NULL; 50 int *alltruepids = NULL; 51 52 /*recover my_rank:*/ 53 my_rank=IssmComm::GetRank(); 54 num_procs=IssmComm::GetSize(); 55 56 /*Go through objects, and distribute pids locally, from 0 to numberofpidsperobject*/ 53 57 for (i=0;i<this->Size();i++){ 54 Vertex* vertex= (Vertex*)this->GetObjectByOffset(i);55 vertex->Distribute Dofs(&dofcount);56 } 57 58 /* Now every object has distributed dofs, but locally, and with a dofcount starting from59 * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of eache60 * cpus by the total last dofs of the previus cpu, starting from 0.61 * First: bet number of dofs for each cpu*/62 all dofcount=xNew<int>(num_procs);63 #ifdef _HAVE_MPI_ 64 MPI_Gather(& dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);65 MPI_Bcast(all dofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);58 Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i)); 59 vertex->DistributePids(&pidcount); 60 } 61 62 /* Now every object has distributed pids, but locally, and with a pid count starting from 63 * 0. This means the pids between all the cpus are not unique. We now offset the pids of each 64 * cpus by the total last pids of the previus cpu, starting from 0. 65 * First: get number of pids for each cpu*/ 66 allpidcount=xNew<int>(num_procs); 67 #ifdef _HAVE_MPI_ 68 MPI_Gather(&pidcount,1,MPI_INT,allpidcount,1,MPI_INT,0,IssmComm::GetComm()); 69 MPI_Bcast(allpidcount,num_procs,MPI_INT,0,IssmComm::GetComm()); 66 70 #else 67 all dofcount[0]=dofcount;68 #endif 69 70 /* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/71 dofcount=0;71 allpidcount[0]=pidcount; 72 #endif 73 74 /* Every cpu should start its own pid count at the end of the pidcount from cpu-1*/ 75 pidcount=0; 72 76 if(my_rank!=0){ 73 77 for(i=0;i<my_rank;i++){ 74 dofcount+=alldofcount[i];78 pidcount+=allpidcount[i]; 75 79 } 76 80 } 77 81 for (i=0;i<this->Size();i++){ 78 Vertex* vertex= (Vertex*)this->GetObjectByOffset(i);79 vertex->Offset Dofs(dofcount);82 Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i)); 83 vertex->OffsetPids(pidcount); 80 84 } 81 85 82 86 /* Finally, remember that cpus may have skipped some objects, because they were clones. For every 83 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked87 * object that is not a clone, tell them to show their pids, so that later on, they can get picked 84 88 * up by their clones: */ 85 true dofs =xNewZeroInit<int>(numberofobjects*numberofdofsperobject);86 alltrue dofs=xNewZeroInit<int>(numberofobjects*numberofdofsperobject);89 truepids =xNewZeroInit<int>(numberofobjects); 90 alltruepids=xNewZeroInit<int>(numberofobjects); 87 91 for (i=0;i<this->Size();i++){ 88 Vertex* vertex= (Vertex*)this->GetObjectByOffset(i);89 vertex->ShowTrue Dofs(truedofs);90 } 91 #ifdef _HAVE_MPI_ 92 MPI_Allreduce((void*)true dofs,(void*)alltruedofs,numberofobjects*numberofdofsperobject,MPI_INT,MPI_MAX,MPI_COMM_WORLD);92 Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i)); 93 vertex->ShowTruePids(truepids); 94 } 95 #ifdef _HAVE_MPI_ 96 MPI_Allreduce((void*)truepids,(void*)alltruepids,numberofobjects,MPI_INT,MPI_MAX,IssmComm::GetComm()); 93 97 #else 94 for(i=0;i<numberofobjects *numberofdofsperobject;i++)alltruedofs[i]=truedofs[i];95 #endif 96 97 /* Now every cpu knows the true dofs of everyone else that is not a clone*/98 for 99 Vertex* vertex= (Vertex*)this->GetObjectByOffset(i);100 vertex->UpdateClone Dofs(alltruedofs);98 for(i=0;i<numberofobjects;i++)alltruepids[i]=truepids[i]; 99 #endif 100 101 /* Now every cpu knows the true pids of everyone else that is not a clone*/ 102 for(i=0;i<this->Size();i++){ 103 Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i)); 104 vertex->UpdateClonePids(alltruepids); 101 105 } 102 106 103 107 /* Free ressources: */ 104 xDelete<int>(all dofcount);105 xDelete<int>(true dofs);106 xDelete<int>(alltrue dofs);108 xDelete<int>(allpidcount); 109 xDelete<int>(truepids); 110 xDelete<int>(alltruepids); 107 111 } 108 112 /*}}}*/ … … 111 115 112 116 int i; 113 externint num_procs;117 int num_procs; 114 118 115 119 int* ranks=NULL; 116 120 int* minranks=NULL; 121 122 /*recover num_procs:*/ 123 num_procs=IssmComm::GetSize(); 117 124 118 125 /*Allocate ranks: */ … … 130 137 * order of cpu rank. This is also why we initialized this array to num_procs.*/ 131 138 #ifdef _HAVE_MPI_ 132 MPI_Allreduce ( (void*)ranks,(void*)minranks,numberofobjects,MPI_INT,MPI_MIN, MPI_COMM_WORLD);139 MPI_Allreduce ( (void*)ranks,(void*)minranks,numberofobjects,MPI_INT,MPI_MIN,IssmComm::GetComm()); 133 140 #else 134 141 for(i=0;i<numberofobjects;i++)minranks[i]=ranks[i]; … … 138 145 for(i=0;i<this->Size();i++){ 139 146 /*For this object, decide whether it is a clone: */ 140 Vertex* vertex= (Vertex*)this->GetObjectByOffset(i);147 Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i)); 141 148 vertex->SetClone(minranks); 142 149 } … … 156 163 157 164 for(i=0;i<this->Size();i++){ 158 Vertex* vertex= (Vertex*)this->GetObjectByOffset(i);165 Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i)); 159 166 sid=vertex->Sid(); 160 167 if (sid>max_sid)max_sid=sid; … … 162 169 163 170 #ifdef _HAVE_MPI_ 164 MPI_Reduce (&max_sid,&vertex_max_sid,1,MPI_INT,MPI_MAX,0, MPI_COMM_WORLD);165 MPI_Bcast(&vertex_max_sid,1,MPI_INT,0, MPI_COMM_WORLD);171 MPI_Reduce (&max_sid,&vertex_max_sid,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() ); 172 MPI_Bcast(&vertex_max_sid,1,MPI_INT,0,IssmComm::GetComm()); 166 173 max_sid=vertex_max_sid; 167 174 #endif … … 177 184 void Vertices::Ranks(int* ranks){ 178 185 186 int my_rank; 187 int sid; 188 189 /*recover my_rank:*/ 190 my_rank=IssmComm::GetRank(); 191 179 192 /*Go through a dataset, and for each object, report it cpu: */ 180 181 int i; 182 int rank; 183 int sid; 184 185 for(i=0;i<this->Size();i++){ 186 Vertex* vertex=(Vertex*)this->GetObjectByOffset(i); 187 rank=vertex->MyRank(); 193 for(int i=0;i<this->Size();i++){ 194 /*Plug rank into ranks, according to id: */ 195 Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i)); 188 196 sid=vertex->Sid(); 189 190 /*Plug rank into ranks, according to id: */ 191 ranks[sid]=rank; 192 } 193 return; 194 } 195 /*}}}*/ 197 ranks[sid]=my_rank; 198 } 199 } 200 /*}}}*/ -
issm/trunk/src/c/Container/Vertices.h
r12706 r13975 19 19 public: 20 20 21 /*constructors, destructors: {{{*/21 /*constructors, destructors:*/ 22 22 Vertices(); 23 23 ~Vertices(); 24 /*}}}*/ 25 /*numerics: {{{*/26 void Distribute Dofs(int numberofnodes,int numdofspernode);24 25 /*numerics:*/ 26 void DistributePids(int numberofnodes); 27 27 void FlagClones(int numberofnodes); 28 28 int NumberOfVertices(void); 29 29 void Ranks(int* ranks); 30 /*}}}*/31 32 30 }; 33 31 -
issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
r13395 r13975 13 13 /*Model fields {{{1*/ 14 14 AutodiffIsautodiffEnum, 15 AutodiffDependentsEnum,16 15 AutodiffNumDependentsEnum, 17 AutodiffIndependentsEnum, 16 AutodiffNumDependentObjectsEnum, 17 AutodiffDependentObjectNamesEnum, 18 AutodiffDependentObjectTypesEnum, 19 AutodiffDependentObjectIndicesEnum, 20 AutodiffDependentObjectsEnum, 18 21 AutodiffNumIndependentsEnum, 22 AutodiffNumIndependentObjectsEnum, 23 AutodiffIndependentObjectNamesEnum, 24 AutodiffIndependentObjectTypesEnum, 25 AutodiffIndependentObjectsEnum, 19 26 AutodiffJacobianEnum, 20 27 AutodiffXpEnum, 21 AutodiffFosForwardOutputEnum, 28 AutodiffDriverEnum, 29 AutodiffFosForwardIndexEnum, 30 AutodiffFovForwardIndicesEnum, 31 AutodiffFosReverseIndexEnum, 32 AutodiffMassFluxSegmentsPresentEnum, 33 AutodiffKeepEnum, 22 34 BalancethicknessSpcthicknessEnum, 23 35 BalancethicknessStabilizationEnum, … … 31 43 ConstantsReferencetemperatureEnum, 32 44 ConstantsYtsEnum, 45 DependentObjectEnum, 33 46 DiagnosticAbstolEnum, 34 47 DiagnosticIcefrontEnum, … … 70 83 HydrologySpcwatercolumnEnum, 71 84 HydrologyStabilizationEnum, 85 IndependentObjectEnum, 72 86 InversionControlParametersEnum, 73 87 InversionCostFunctionEnum, … … 143 157 PrognosticStabilizationEnum, 144 158 PrognosticVertexPairingEnum, 159 PrognosticNumRequestedOutputsEnum, 160 PrognosticRequestedOutputsEnum, 145 161 QmuIsdakotaEnum, 146 QmuMassFluxSegmentsEnum, 162 MassFluxSegmentsEnum, 163 MassFluxSegmentsPresentEnum, 164 QmuMassFluxSegmentsPresentEnum, 147 165 QmuNumberofpartitionsEnum, 148 166 QmuNumberofresponsesEnum, … … 179 197 SurfaceforcingsMonthlytemperaturesEnum, 180 198 SurfaceforcingsHcEnum, 199 SurfaceforcingsHrefEnum, 200 SurfaceforcingsSmbrefEnum, 181 201 SurfaceforcingsSmbPosMaxEnum, 182 202 SurfaceforcingsSmbPosMinEnum, … … 273 293 DofIndexingEnum, 274 294 DoubleInputEnum, 295 DataSetParamEnum, 275 296 DoubleMatArrayParamEnum, 276 297 DoubleMatParamEnum, … … 302 323 PentaEnum, 303 324 PentaP1InputEnum, 325 ProfilerEnum, 304 326 MatrixParamEnum, 305 327 VectorParamEnum, … … 490 512 OldGradientEnum, 491 513 OutputFilePointerEnum, 514 OutputFileNameEnum, 515 LockFileNameEnum, 492 516 PetscOptionsAnalysesEnum, 493 517 PetscOptionsStringsEnum, -
issm/trunk/src/c/Makefile.am
r13395 r13975 1 AM_CPPFLAGS = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @M ATLABINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@1 AM_CPPFLAGS = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@ 2 2 3 3 EXEEXT=$(ISSMEXT) … … 9 9 lib_LTLIBRARIES = libISSMCore.la libISSMOverload.la libISSM.la 10 10 endif 11 if PYTHON 12 lib_LIBRARIES += libISSMPython.a 13 endif 14 if MATLAB 15 if SHAREDLIBS 16 lib_LTLIBRARIES += libISSMMatlab.la 17 endif 18 lib_LIBRARIES += libISSMMatlab.a 19 endif 20 if MODULES 11 if WRAPPERS 21 12 if SHAREDLIBS 22 13 lib_LTLIBRARIES += libISSMModules.la … … 54 45 ./classes/objects/Constraints/SpcTransient.cpp\ 55 46 ./classes/objects/Constraints/SpcTransient.h\ 47 ./classes/objects/IndependentObject.h\ 48 ./classes/objects/IndependentObject.cpp\ 49 ./classes/objects/DependentObject.h\ 50 ./classes/objects/DependentObject.cpp\ 56 51 ./classes/DofIndexing.h\ 57 52 ./classes/DofIndexing.cpp\ … … 63 58 ./classes/objects/Vertex.h\ 64 59 ./classes/objects/Vertex.cpp\ 60 ./classes/objects/AdolcEdf.h\ 61 ./classes/IssmComm.h\ 62 ./classes/IssmComm.cpp\ 65 63 ./classes/Hook.h\ 66 64 ./classes/Hook.cpp\ … … 152 150 ./classes/objects/Params/TransientParam.h\ 153 151 ./classes/objects/Params/TransientParam.cpp\ 152 ./classes/objects/Params/DataSetParam.h\ 153 ./classes/objects/Params/DataSetParam.cpp\ 154 ./classes/objects/Profiler.h\ 155 ./classes/objects/Profiler.cpp\ 154 156 ./Container/Container.h\ 155 157 ./Container/Constraints.h\ … … 182 184 ./shared/Matrix/matrix.h\ 183 185 ./shared/Matrix/MatrixUtils.cpp\ 184 ./shared/Numerics/adolc_edf.h\185 186 ./shared/Numerics/numerics.h\ 186 187 ./shared/Numerics/Verbosity.h\ … … 213 214 ./shared/Elements/ComputeDelta18oTemperaturePrecipitation.cpp\ 214 215 ./shared/String/sharedstring.h\ 215 ./shared/Wrapper/wrappershared.h\ 216 ./shared/Wrapper/ModuleBoot.cpp\ 217 ./shared/Wrapper/ModuleEnd.cpp\ 218 ./shared/Sys/sys.h\ 219 ./shared/Sys/ProfilingStart.cpp\ 220 ./shared/Sys/ProfilingEnd.cpp\ 216 ./shared/String/DescriptorIndex.cpp\ 221 217 ./toolkits/metis/metisincludes.h\ 222 218 ./toolkits/issm/issmtoolkit.h\ … … 230 226 ./io/Disk/pfopen.cpp\ 231 227 ./io/Disk/pfclose.cpp\ 228 ./io/Disk/WriteLockFile.cpp\ 232 229 ./io/PrintfFunction.cpp\ 233 230 ./EnumDefinitions/EnumDefinitions.h\ … … 279 276 ./modules/InputArtificialNoisex/InputArtificialNoisex.h\ 280 277 ./modules/InputArtificialNoisex/InputArtificialNoisex.cpp\ 281 ./modules/TimeAdaptx/TimeAdaptx.h\282 ./modules/TimeAdaptx/TimeAdaptx.cpp\283 ./modules/UpdateVertexPositionsx/UpdateVertexPositionsx.h\284 ./modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp\285 278 ./modules/ConfigureObjectsx/ConfigureObjectsx.h\ 286 279 ./modules/ConfigureObjectsx/ConfigureObjectsx.cpp\ … … 297 290 ./modules/SmbGradientsx/SmbGradientsx.h\ 298 291 ./modules/SmbGradientsx/SmbGradientsx.cpp\ 299 ./modules/UpdateConstraintsx/UpdateConstraintsx.h\300 ./modules/UpdateConstraintsx/UpdateConstraintsx.cpp\301 292 ./modules/MeshPartitionx/MeshPartitionx.h\ 302 293 ./modules/Reducevectorgtofx/Reducevectorgtofx.cpp\ … … 308 299 ./modules/StringToEnumx/StringToEnumx.cpp\ 309 300 ./modules/StringToEnumx/StringToEnumx.h\ 310 ./modules/SystemMatricesx/SystemMatricesx.cpp\311 ./modules/SystemMatricesx/SystemMatricesx.h\312 ./modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp\313 ./modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h\314 301 ./modules/ConstraintsStatex/ConstraintsStatex.cpp\ 315 302 ./modules/ConstraintsStatex/ConstraintsStatex.h\ 316 303 ./modules/ConstraintsStatex/ConstraintsStateLocal.h\ 317 ./modules/Responsex/Responsex.h\318 ./modules/Responsex/Responsex.cpp\319 ./modules/RequestedOutputsx/RequestedOutputsx.h\320 ./modules/RequestedOutputsx/RequestedOutputsx.cpp\321 ./modules/RequestedDependentsx/RequestedDependentsx.h\322 ./modules/RequestedDependentsx/RequestedDependentsx.cpp\323 ./modules/AutodiffDriversx/AutodiffDriversx.h\324 ./modules/AutodiffDriversx/AutodiffDriversx.cpp\325 304 ./modules/ResetConstraintsx/ResetConstraintsx.h\ 326 305 ./modules/ResetConstraintsx/ResetConstraintsx.cpp\ … … 340 319 ./solutions/convergence.cpp\ 341 320 ./solutions/ProcessArguments.cpp\ 342 ./solutions/WriteLockFile.cpp\343 321 ./solutions/ResetBoundaryConditions.cpp\ 344 322 ./solutions/AnalysisConfiguration.cpp\ 323 ./solutions/WrapperCorePointerFromSolutionEnum.cpp\ 345 324 ./solutions/CorePointerFromSolutionEnum.cpp\ 325 ./solutions/EnvironmentInit.cpp\ 326 ./solutions/EnvironmentFinalize.cpp\ 327 ./solutions/ad_core.cpp\ 346 328 ./solvers/solver_linear.cpp\ 347 329 ./solvers/solver_nonlinear.cpp\ … … 350 332 ./classes/objects/Options/GenericOption.h\ 351 333 ./classes/objects/Options/OptionUtilities.cpp\ 352 ./classes/objects/Options/OptionUtilities.h 353 334 ./classes/objects/Options/OptionUtilities.h\ 335 ./classes/RiftStruct.cpp\ 336 ./classes/RiftStruct.h 354 337 #}}} 355 338 #DAKOTA sources {{{ … … 358 341 ./modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h\ 359 342 ./modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp\ 360 ./modules/DakotaResponsesx/DakotaResponsesx.h\361 ./modules/DakotaResponsesx/DakotaResponsesx.cpp\362 343 ./modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h\ 363 344 ./modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp\ … … 366 347 ./modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp\ 367 348 ./modules/AverageOntoPartitionx/AverageOntoPartitionx.h\ 368 ./modules/Dakotax/Dakotax.h\369 ./modules/Dakotax/Dakotax.cpp\370 ./modules/Dakotax/DakotaMPI_Bcast.cpp\371 ./modules/Dakotax/DakotaFree.cpp\372 ./modules/Dakotax/SpawnCore.cpp\373 ./modules/Dakotax/DescriptorIndex.cpp\374 349 ./modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp\ 375 ./modules/Dakotax/SpawnCoreParallel.cpp 350 ./solutions/dakota_core.cpp\ 351 ./solutions/DakotaSpawnCore.cpp 376 352 #}}} 377 353 #Transient sources {{{ … … 437 413 ./modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.h\ 438 414 ./modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp\ 439 ./modules/CostFunctionx/CostFunctionx.h\440 ./modules/CostFunctionx/CostFunctionx.cpp\441 415 ./modules/Orthx/Orthx.h\ 442 416 ./modules/Orthx/Orthx.cpp\ … … 445 419 ./modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp\ 446 420 ./modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.h\ 447 ./modules/ThicknessAbsGradientx/ThicknessAbsGradientx.cpp\448 ./modules/ThicknessAbsGradientx/ThicknessAbsGradientx.h\449 421 ./modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp\ 450 422 ./modules/ThicknessAlongGradientx/ThicknessAlongGradientx.h\ … … 505 477 ./solutions/balancethickness_core.cpp 506 478 #}}} 507 #Responses sources {{{508 responses_sources = ./modules/MinVelx/MinVelx.h\509 ./modules/MinVelx/MinVelx.cpp\510 ./modules/MaxVelx/MaxVelx.h\511 ./modules/MaxVelx/MaxVelx.cpp\512 ./modules/MaxAbsVxx/MaxAbsVxx.h\513 ./modules/MaxAbsVxx/MaxAbsVxx.cpp\514 ./modules/MaxAbsVyx/MaxAbsVyx.h\515 ./modules/MaxAbsVyx/MaxAbsVyx.cpp\516 ./modules/MaxAbsVzx/MaxAbsVzx.h\517 ./modules/MaxAbsVzx/MaxAbsVzx.cpp\518 ./modules/MaxVxx/MaxVxx.h\519 ./modules/MaxVxx/MaxVxx.cpp\520 ./modules/MaxVyx/MaxVyx.h\521 ./modules/MaxVyx/MaxVyx.cpp\522 ./modules/MaxVzx/MaxVzx.h\523 ./modules/MaxVzx/MaxVzx.cpp\524 ./modules/MinVxx/MinVxx.h\525 ./modules/MinVxx/MinVxx.cpp\526 ./modules/MinVyx/MinVyx.h\527 ./modules/MinVyx/MinVyx.cpp\528 ./modules/MinVzx/MinVzx.h\529 ./modules/MinVzx/MinVzx.cpp\530 ./modules/TotalSmbx/TotalSmbx.h\531 ./modules/TotalSmbx/TotalSmbx.cpp\532 ./modules/IceVolumex/IceVolumex.h\533 ./modules/IceVolumex/IceVolumex.cpp\534 ./modules/ElementResponsex/ElementResponsex.h\535 ./modules/ElementResponsex/ElementResponsex.cpp\536 ./modules/MassFluxx/MassFluxx.cpp\537 ./modules/MassFluxx/MassFluxx.h538 #}}}539 479 #Slope sources {{{ 540 480 slope_sources = ./modules/ModelProcessorx/BedSlope/UpdateElementsBedSlope.cpp\ … … 557 497 ./classes/objects/Loads/Riftfront.h\ 558 498 ./modules/ConstraintsStatex/RiftConstraintsState.cpp 499 #}}} 500 #Android sources {{{ 501 android_sources = ./android/fac.h\ 502 ./android/fac.cpp 559 503 #}}} 560 504 #3D sources {{{ … … 751 695 ./toolkits/petsc/patches/SolverEnum.h\ 752 696 ./toolkits/petsc/patches/petscpatches.h\ 753 ./toolkits/petsc/patches/VecTranspose.cpp\754 697 ./toolkits/petsc/patches/VecToMPISerial.cpp\ 755 698 ./toolkits/petsc/patches/MatToSerial.cpp\ … … 759 702 ./toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp\ 760 703 ./toolkits/petsc/patches/NewMat.cpp\ 761 ./toolkits/petsc/patches/SerialToVec.cpp\762 704 ./toolkits/petsc/patches/VecFree.cpp\ 763 705 ./toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp\ … … 765 707 ./toolkits/petsc/patches/VecDuplicatePatch.cpp\ 766 708 ./toolkits/petsc/patches/KSPFree.cpp\ 767 ./toolkits/petsc/patches/ISFree.cpp\768 709 ./toolkits/petsc/patches/MatFree.cpp\ 769 ./toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp\770 ./toolkits/petsc/patches/VecPartition.cpp\771 ./toolkits/petsc/patches/MatPartition.cpp\772 ./toolkits/petsc/patches/MatInvert.cpp\773 710 ./toolkits/petsc/patches/MatMultPatch.cpp\ 774 711 ./toolkits/petsc/patches/ISSMToPetscMatrixType.cpp\ … … 789 726 mpi_sources= ./toolkits/mpi/mpiincludes.h\ 790 727 ./toolkits/mpi/patches/mpipatches.h\ 791 ./toolkits/mpi/patches/DetermineLocalSize.cpp\ 792 ./toolkits/mpi/patches/MPI_Upperrow.cpp\ 793 ./toolkits/mpi/patches/MPI_Lowerrow.cpp\ 794 ./toolkits/mpi/patches/MPI_Boundariesfromrange.cpp 728 ./toolkits/mpi/patches/DetermineLocalSize.cpp 795 729 #}}} 796 730 #Metis sources {{{ … … 798 732 ./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp 799 733 #}}} 800 #Python sources {{{801 python_sources= ./python/io/pythonio.h\802 ./python/python-binding.h\803 ./python/io/WritePythonData.cpp\804 ./python/io/CheckNumPythonArguments.cpp\805 ./python/io/FetchPythonData.cpp806 807 #}}}808 #Matlab sources {{{809 matlab_sources= ./toolkits/matlab/matlabincludes.h\810 ./matlab/matlab-binding.h\811 ./matlab/io/matlabio.h\812 ./matlab/io/MatlabNArrayToNArray.cpp\813 ./matlab/io/CheckNumMatlabArguments.cpp\814 ./matlab/io/mxGetAssignedField.cpp\815 ./matlab/io/WriteMatlabData.cpp\816 ./matlab/io/FetchMatlabData.cpp\817 ./matlab/io/OptionParse.cpp\818 ./matlab/io/MatlabMatrixToMatrix.cpp\819 ./matlab/io/MatlabVectorToVector.cpp\820 ./matlab/io/MatlabVectorToDoubleVector.cpp\821 ./matlab/io/MatlabMatrixToDoubleMatrix.cpp\822 ./matlab/io/MatlabMatrixToSeqMat.cpp\823 ./matlab/io/MatlabVectorToSeqVec.cpp824 #}}}825 #Matlab and Petsc sources {{{826 matlabpetsc_sources= ./matlab/io/MatlabMatrixToPetscMat.cpp\827 ./matlab/io/MatlabVectorToPetscVec.cpp828 829 #}}}830 734 #Modules sources{{{ 831 module _sources= ./shared/Threads/issm_threads.h\735 modules_sources= ./shared/Threads/issm_threads.h\ 832 736 ./shared/Threads/LaunchThread.cpp\ 833 737 ./shared/Threads/PartitionRange.cpp\ … … 842 746 ./shared/TriMesh/SplitMeshForRifts.cpp\ 843 747 ./shared/TriMesh/TriMeshUtils.cpp\ 844 ./modules/AddExternalResultx/AddExternalResultx.h\845 ./modules/AddExternalResultx/AddExternalResultx.cpp\846 748 ./modules/Chacox/Chacox.h\ 847 749 ./modules/Chacox/Chacox.cpp\ … … 853 755 ./modules/TriMeshx/TriMeshx.h\ 854 756 ./modules/TriMeshx/TriMeshx.cpp\ 757 ./modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.h\ 758 ./modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.cpp\ 855 759 ./modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h\ 856 760 ./modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp\ … … 947 851 endif 948 852 949 if RESPONSES950 issm_sources += $(responses_sources)951 endif952 953 853 if SLOPE 954 854 issm_sources += $(slope_sources) … … 963 863 endif 964 864 865 if ANDROID 866 issm_sources += $(android_sources) 867 endif 868 965 869 if THREED 966 870 issm_sources += $(threed_sources) … … 973 877 if METIS 974 878 issm_sources += $(metis_sources) 975 endif976 977 if PETSC978 if MATLAB979 issm_sources += $(matlabpetsc_sources)980 endif981 879 endif 982 880 … … 1001 899 endif 1002 900 1003 if MODULES1004 libISSMModules_a_SOURCES = $(module _sources)901 if WRAPPERS 902 libISSMModules_a_SOURCES = $(modules_sources) 1005 903 libISSMModules_a_SOURCES += $(bamg_sources) 1006 904 if KRIGING … … 1017 915 endif 1018 916 1019 if PYTHON1020 libISSMPython_a_SOURCES = $(python_sources)1021 libISSMPython_a_CXXFLAGS= $(ALLCXXFLAGS)1022 endif1023 1024 if MATLAB1025 libISSMMatlab_a_SOURCES = $(matlab_sources)1026 libISSMMatlab_a_CXXFLAGS= $(ALLCXXFLAGS)1027 if SHAREDLIBS1028 libISSMMatlab_la_SOURCES = $(libISSMMatlab_a_SOURCES)1029 endif1030 endif1031 1032 917 if VERSION 1033 918 AM_LDFLAGS = … … 1042 927 1043 928 #Executable {{{ 929 if ANDROID 930 if ANDROIDEXE 1044 931 bin_PROGRAMS = issm 932 else 933 bin_PROGRAMS = 934 endif 935 else 936 bin_PROGRAMS = issm 937 endif 1045 938 1046 939 #Standard libraries -
issm/trunk/src/c/classes/DofIndexing.cpp
r13395 r13975 10 10 11 11 #include <stdio.h> 12 #include <string.h> 12 13 #include "./classes.h" 13 #include <string.h>14 14 #include "../EnumDefinitions/EnumDefinitions.h" 15 15 #include "../shared/shared.h" … … 21 21 DofIndexing::DofIndexing(){ 22 22 23 this->gsize =UNDEF;24 this->fsize =UNDEF;25 this->ssize =UNDEF;26 this->clone =0;27 this->f_set =NULL;28 this->s_set =NULL;29 this->svalues =NULL;30 this->doftype =NULL;31 this->gdoflist =NULL;32 this->fdoflist =NULL;33 this->sdoflist =NULL;23 this->gsize = UNDEF; 24 this->fsize = UNDEF; 25 this->ssize = UNDEF; 26 this->clone = false; 27 this->f_set = NULL; 28 this->s_set = NULL; 29 this->svalues = NULL; 30 this->doftype = NULL; 31 this->gdoflist = NULL; 32 this->fdoflist = NULL; 33 this->sdoflist = NULL; 34 34 35 35 } … … 43 43 DofIndexing::DofIndexing(DofIndexing* in){ //copy constructor 44 44 45 int i; 46 this->gsize=in->gsize; 47 this->fsize=in->fsize; 48 this->ssize=in->ssize; 49 50 this->clone=in->clone; 45 this->gsize = in->gsize; 46 this->fsize = in->fsize; 47 this->ssize = in->ssize; 48 this->clone = in->clone; 51 49 52 50 if(this->gsize>0){ … … 58 56 } 59 57 else{ 60 this->f_set =NULL;61 this->s_set =NULL;62 this->svalues =NULL;63 this->doftype =NULL;64 this->gdoflist =NULL;58 this->f_set = NULL; 59 this->s_set = NULL; 60 this->svalues = NULL; 61 this->doftype = NULL; 62 this->gdoflist = NULL; 65 63 } 66 64 if(this->fsize>0 && this->fsize!=UNDEF)this->fdoflist=xNew<int>(this->fsize); else this->fdoflist=NULL; … … 95 93 void DofIndexing::Init(int in_gsize,int* in_doftype){ 96 94 97 int i;98 95 this->gsize=in_gsize; 99 100 this->clone=0; 96 this->clone=false; 101 97 102 98 /*allocate: */ … … 109 105 } 110 106 111 for (i=0;i<this->gsize;i++){107 for(int i=0;i<this->gsize;i++){ 112 108 /*assume dof is free, no constraints, no rigid body constraint: */ 113 109 this->f_set[i]=true; … … 151 147 void DofIndexing::Echo(void){ 152 148 153 int i;154 155 149 _printLine_("DofIndexing:"); 156 150 _printLine_(" gsize: " << gsize); … … 168 162 _printLine_(" ssize: " << ssize); 169 163 _printLine_(" clone: " << clone); 170 164 171 165 _printLine_(" set membership: f,s sets "); 172 166 for(i=0;i<gsize;i++){ … … 208 202 } 209 203 /*}}}*/ 210 -
issm/trunk/src/c/classes/DofIndexing.h
r13395 r13975 9 9 10 10 class DofIndexing{ 11 11 12 12 public: 13 13 14 14 /*sizes: */ 15 int gsize; //number of dofs for a node16 int fsize; //number of dofs solver for17 int ssize; //number of constrained dofs15 int gsize; //number of dofs for a node 16 int fsize; //number of dofs solver for 17 int ssize; //number of constrained dofs 18 18 19 19 /*partitioning: */ 20 int clone; //this node is replicated from another one20 bool clone; //this node is replicated from another one 21 21 22 22 /*boundary conditions sets: */ 23 bool * f_set;//is dof on f-set (on which we solve)24 bool * s_set;//is dof on s-set (on which boundary conditions -dirichlet- are applied)25 IssmDouble * svalues;//list of constraint values. size g_size, for ease of use.23 bool *f_set; //is dof on f-set (on which we solve) 24 bool *s_set; //is dof on s-set (on which boundary conditions -dirichlet- are applied) 25 IssmDouble *svalues; //list of constraint values. size g_size, for ease of use. 26 26 27 27 /*types of dofs: */ 28 int * doftype;//approximation type of the dofs (used only for coupling), size g_size29 28 int *doftype; //approximation type of the dofs (used only for coupling), size g_size 29 30 30 /*list of degrees of freedom: */ 31 int* gdoflist; //dof list in g_set 32 int* fdoflist; //dof list in f_set 33 int* sdoflist; //dof list in s_set 34 31 int *gdoflist; //dof list in g_set 32 int *fdoflist; //dof list in f_set 33 int *sdoflist; //dof list in s_set 35 34 36 35 /*DofIndexing constructors, destructors {{{*/ -
issm/trunk/src/c/classes/FemModel.cpp
r13395 r13975 2 2 * \brief: implementation of the FemModel object 3 3 */ 4 5 4 6 5 #ifdef HAVE_CONFIG_H … … 13 12 #include "../Container/Container.h" 14 13 #include "../modules/ModelProcessorx/ModelProcessorx.h" 14 #include "../solutions/solutions.h" 15 15 #include "../io/io.h" 16 16 #include "./classes.h" … … 20 20 21 21 /*Object constructors and destructor*/ 22 /*FUNCTION FemModel::constructor {{{*/ 23 FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, const int in_solution_type,const int* analyses,const int nummodels){ 24 25 /*intermediary*/ 26 int i; 27 int analysis_type; 28 FILE *IOMODEL = NULL; 29 extern int my_rank; 30 31 /*Open input file on cpu 0: */ 32 if(my_rank==0) IOMODEL = pfopen(inputfilename ,"rb"); 33 34 /*Initialize internal data: */ 35 this->nummodels=nummodels; 36 this->solution_type=in_solution_type; 37 this->analysis_counter=nummodels-1; //point to last analysis_type carried out. 38 this->results=new Results(); //not initialized by CreateDataSets 22 /*FUNCTION FemModel::FemModel(int argc,char** argv){{{*/ 23 FemModel::FemModel(int argc,char** argv,COMM incomm){ 24 25 /*configuration: */ 26 int* analyses=NULL; 27 int numanalyses; 28 int solution_type; 29 int ierr; 30 31 /*File names*/ 32 char *lockfilename = NULL; 33 char *binfilename = NULL; 34 char *outbinfilename = NULL; 35 char *petscfilename = NULL; 36 char *rootpath = NULL; 37 38 /*First things first, store the communicator, and set it as a global variable: */ 39 this->comm=incomm; 40 this->SetStaticComm(); 39 41 40 /*Dynamically allocate whatever is a list of length nummodels: */ 41 analysis_type_list=xNew<int>(nummodels); 42 43 /*Initialize: */ 44 for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i]; 45 46 /*create datasets for all analyses*/ 47 ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,rootpath,this->solution_type,nummodels,analyses); 48 49 /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */ 50 for(i=0;i<nummodels;i++){ 51 52 if(VerboseMProcessor()) _pprintLine_(" Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":"); 53 analysis_type=analysis_type_list[i]; 54 this->SetCurrentConfiguration(analysis_type); 55 56 if(i==0){ 57 if(VerboseMProcessor()) _pprintLine_(" creating vertex degrees of freedom"); 58 VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices 59 } 60 61 if(VerboseMProcessor()) _pprintLine_(" resolving node constraints"); 62 SpcNodesx(nodes,constraints,parameters,analysis_type); 63 64 if(VerboseMProcessor()) _pprintLine_(" creating nodal degrees of freedom"); 65 NodesDofx(nodes,parameters,analysis_type); 66 67 if(VerboseMProcessor()) _pprintLine_(" configuring element and loads"); 68 ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters); 69 } 70 71 /*Close input file descriptors: */ 72 if(my_rank==0) pfclose(IOMODEL,inputfilename); 73 74 /*Add output file name to parameters: */ 75 this->parameters->AddObject(new StringParam(OutputfilenameEnum,outputfilename)); 76 77 } 78 79 /*}}}*/ 80 /*FUNCTION FemModel::destructor {{{*/ 42 /*Now, initialize PETSC: */ 43 #ifdef _HAVE_PETSC_ 44 PETSC_COMM_WORLD=this->comm; 45 ierr=PetscInitialize(&argc,&argv,(char*)0,""); if(ierr) _error_("Could not initialize Petsc"); 46 #endif 47 48 /*Start profiler: */ 49 this->profiler=new Profiler(); 50 profiler->Tag(Start); 51 52 /*From command line arguments, retrieve different filenames needed to create the FemModel: */ 53 ProcessArguments(&solution_type,&binfilename,&outbinfilename,&petscfilename,&lockfilename,&rootpath,argc,argv); 54 55 /*out of solution_type, figure out types of analyses needed in the femmodel: */ 56 AnalysisConfiguration(&analyses,&numanalyses,solution_type); 57 58 /*Create femmodel from input files: */ 59 profiler->Tag(StartInit); 60 this->InitFromFiles(rootpath,binfilename,outbinfilename,petscfilename,lockfilename,solution_type,analyses,numanalyses); 61 profiler->Tag(FinishInit); 62 63 /*Free resources */ 64 xDelete<int>(analyses); 65 xDelete<char>(lockfilename); 66 xDelete<char>(binfilename); 67 xDelete<char>(outbinfilename); 68 xDelete<char>(petscfilename); 69 xDelete<char>(rootpath); 70 71 } 72 /*}}}*/ 73 /*FUNCTION FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){{{*/ 74 FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){ 75 76 /*Call InitFromFiles. This constructor is just a wrapper: */ 77 this->InitFromFiles(rootpath, inputfilename, outputfilename, petscfilename, lockfilename, in_solution_type,analyses,nummodels); 78 79 } 80 /*}}}*/ 81 /*FUNCTION FemModel::~FemModel{{{*/ 81 82 FemModel::~FemModel(){ 82 83 83 84 /*Intermediary*/ 84 int i; 85 FILE *output_fid; 86 char *outbinfilename = NULL; 87 char *lockfilename = NULL; 88 bool waitonlock = false; 89 90 /*Close output file: */ 91 this->parameters->FindParam(&output_fid,OutputFilePointerEnum); 92 this->parameters->FindParam(&outbinfilename,OutputFileNameEnum); 93 pfclose(output_fid,outbinfilename); 94 95 /*Write lock file if requested: */ 96 this->parameters->FindParam(&waitonlock,SettingsWaitonlockEnum); 97 this->parameters->FindParam(&lockfilename,LockFileNameEnum); 98 if (waitonlock>0){ 99 _pprintLine_("write lock file:"); 100 WriteLockFile(lockfilename); 101 } 85 102 86 103 /*Delete all the datasets: */ 87 104 xDelete<int>(analysis_type_list); 105 xDelete<char>(outbinfilename); 106 xDelete<char>(lockfilename); 88 107 delete elements; 89 108 delete nodes; … … 95 114 delete results; 96 115 116 /*Before we delete the profiler, report statistics for this run: */ 117 profiler->Tag(Finish); //final tagging 118 _pprintLine_(""); 119 _pprintLine_(" "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<profiler->DeltaTime(StartInit,FinishInit)); 120 _pprintLine_(" "<<setw(40)<<left<<"Core solution elapsed time:"<<profiler->DeltaTime(StartCore,FinishCore)); 121 _pprintLine_(""); 122 _pprintLine_(" Total elapsed time:" 123 <<profiler->DeltaTimeModHour(Start,Finish)<<" hrs " 124 <<profiler->DeltaTimeModMin(Start,Finish)<<" min " 125 <<profiler->DeltaTimeModSec(Start,Finish)<<" sec" 126 ); 127 _pprintLine_(""); 128 129 /*Now delete: */ 130 delete profiler; 131 132 /*Finalize PETSC for this model: */ 133 #ifdef _HAVE_PETSC_ 134 _pprintLine_("closing Petsc"); 135 PetscFinalize(); 136 #endif 137 97 138 } 98 139 /*}}}*/ … … 111 152 } 112 153 /*}}}*/ 113 114 /*Numerics: */ 154 /*FUNCTION FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){{{*/ 155 void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){ 156 157 /*intermediary*/ 158 int i; 159 int analysis_type; 160 FILE *IOMODEL = NULL; 161 FILE *petscoptionsfid = NULL; 162 FILE *output_fid = NULL; 163 int my_rank; 164 165 /*recover my_rank:*/ 166 my_rank=IssmComm::GetRank(); 167 168 /*Open input file on cpu 0: */ 169 if(my_rank==0) IOMODEL = pfopen(inputfilename ,"rb"); 170 171 /*Initialize internal data: */ 172 this->nummodels = nummodels; 173 this->solution_type = in_solution_type; 174 this->analysis_counter = nummodels-1; //point to last analysis_type carried out. 175 this->results = new Results(); //not initialized by CreateDataSets 176 177 /*Dynamically allocate whatever is a list of length nummodels: */ 178 analysis_type_list=xNew<int>(nummodels); 179 180 /*Initialize: */ 181 for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i]; 182 183 /*create datasets for all analyses*/ 184 ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,rootpath,this->solution_type,nummodels,analyses); 185 186 /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */ 187 for(i=0;i<nummodels;i++){ 188 189 if(VerboseMProcessor()) _pprintLine_(" Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":"); 190 analysis_type=analysis_type_list[i]; 191 this->SetCurrentConfiguration(analysis_type); 192 193 if(i==0){ 194 if(VerboseMProcessor()) _pprintLine_(" creating vertex degrees of freedom"); 195 VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices 196 } 197 198 if(VerboseMProcessor()) _pprintLine_(" resolving node constraints"); 199 SpcNodesx(nodes,constraints,parameters,analysis_type); 200 201 if(VerboseMProcessor()) _pprintLine_(" creating nodal degrees of freedom"); 202 NodesDofx(nodes,parameters,analysis_type); 203 204 if(VerboseMProcessor()) _pprintLine_(" configuring element and loads"); 205 ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters); 206 } 207 208 /*Close input file descriptors: */ 209 if(my_rank==0) pfclose(IOMODEL,inputfilename); 210 211 /*Open output file once for all and add output file name and file descriptor to parameters*/ 212 output_fid=pfopen(outputfilename,"wb"); 213 this->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename)); 214 this->parameters->SetParam(output_fid,OutputFilePointerEnum); 215 216 /*Save lock file name for later: */ 217 this->parameters->AddObject(new StringParam(LockFileNameEnum,lockfilename)); 218 219 /*Now, deal with petsc options, which need to be put into the parameters dataset: */ 220 petscoptionsfid=pfopen(petscfilename,"r"); 221 ParsePetscOptionsx(this->parameters,petscoptionsfid); 222 pfclose(petscoptionsfid,petscfilename); 223 } 224 /*}}}*/ 225 /*FUNCTION FemModel::OutputResults {{{*/ 226 void FemModel::OutputResults(void){ 227 228 _pprintLine_("write results to disk:"); 229 230 /*Just call the OutputResultsx module: */ 231 OutputResultsx(this->elements, this->nodes, this->vertices, this->loads, this->materials, this->parameters,this->results); 232 233 } 234 /*}}}*/ 235 /*FUNCTION FemModel::SetStaticComm {{{*/ 236 void FemModel::SetStaticComm(void){ 237 238 /*This routine sets the global communicator variable hidden inside the IssmComm 239 *class: */ 240 IssmComm::SetComm(this->comm); 241 242 } 243 /*}}}*/ 115 244 /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){{{*/ 116 245 void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){ … … 153 282 /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{*/ 154 283 void FemModel::SetCurrentConfiguration(int configuration_type){ 155 156 /*overload: analysis_type = configuration_type: */157 284 this->SetCurrentConfiguration(configuration_type,configuration_type); 158 285 } 159 286 /*}}}*/ 287 /*FUNCTION FemModel::Solve {{{*/ 288 void FemModel::Solve(void){ 289 290 /*profiling: */ 291 bool profiling = false; 292 IssmDouble solution_time; 293 IssmDouble solution_flops; 294 IssmDouble solution_memory; 295 296 /*solution: */ 297 int solution_type; 298 void (*solutioncore)(FemModel*)=NULL; //core solution function pointer 299 300 _pprintLine_("call computational core:"); 301 302 /*Retrieve solution_type from parameters: */ 303 parameters->FindParam(&solution_type,SolutionTypeEnum); 304 305 /*Figure out which solution core we are going to run with the current solution type: */ 306 WrapperCorePointerFromSolutionEnum(&solutioncore,this->parameters,solution_type); 307 308 /*run solutoin core: */ 309 profiler->Tag(StartCore); 310 solutioncore(this); 311 profiler->Tag(FinishCore); 312 313 /*run AD core if needed: */ 314 profiler->Tag(StartAdCore); 315 ad_core(this); 316 profiler->Tag(FinishAdCore); 317 318 /*some profiling results for the core: */ 319 parameters->FindParam(&profiling,DebugProfilingEnum); 320 if(profiling){ 321 322 solution_time=profiler->DeltaTime(StartCore,FinishCore); 323 solution_flops=profiler->DeltaFlops(StartCore,FinishCore); 324 solution_memory=profiler->Memory(FinishCore); 325 326 _pprintLine_("Solution elapsed time : " << solution_time << " Seconds"); 327 _pprintLine_("Solution elapsed flops : " << solution_flops << " Flops"); 328 _pprintLine_("Solution memory used : " << solution_memory << " Bytes"); 329 330 /*Add to results: */ 331 results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingSolutionTimeEnum, solution_time, 1, 0)); 332 results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentMemEnum, solution_memory, 1, 0)); 333 results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentFlopsEnum, solution_flops, 1, 0)); 334 } 335 } 336 /*}}}*/ 337 338 /*Modules:*/ 339 void FemModel::AllocateSystemMatrices(Matrix<IssmDouble>** pKff,Matrix<IssmDouble>** pKfs,Vector<IssmDouble>** pdf,Vector<IssmDouble>** ppf){ /*{{{*/ 340 341 /*Intermediary*/ 342 int fsize,ssize,flocalsize,slocalsize; 343 int connectivity, numberofdofspernode; 344 int configuration_type; 345 int m,n,M,N; 346 int *d_nnz = NULL; 347 int *o_nnz = NULL; 348 349 /*output*/ 350 Matrix<IssmDouble> *Kff = NULL; 351 Matrix<IssmDouble> *Kfs = NULL; 352 Vector<IssmDouble> *pf = NULL; 353 Vector<IssmDouble> *df = NULL; 354 355 bool oldalloc=false; 356 357 /*retrieve parameters: */ 358 this->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 359 this->parameters->FindParam(&connectivity,MeshAverageVertexConnectivityEnum); 360 361 /*retrieve node info*/ 362 fsize = this->nodes->NumberOfDofs(configuration_type,FsetEnum); 363 ssize = this->nodes->NumberOfDofs(configuration_type,SsetEnum); 364 flocalsize = this->nodes->NumberOfDofsLocal(configuration_type,FsetEnum); 365 slocalsize = this->nodes->NumberOfDofsLocal(configuration_type,SsetEnum); 366 367 numberofdofspernode=this->nodes->MaxNumDofs(configuration_type,GsetEnum); 368 369 if(oldalloc){ 370 if(pKff) Kff=new Matrix<IssmDouble>(fsize,fsize,connectivity,numberofdofspernode); 371 if(pKfs) Kfs=new Matrix<IssmDouble>(fsize,ssize,connectivity,numberofdofspernode); 372 if(pdf) df =new Vector<IssmDouble>(fsize); 373 if(ppf) pf =new Vector<IssmDouble>(fsize); 374 } 375 else{ 376 if(pKff){ 377 m=flocalsize; n=flocalsize; /*local sizes*/ 378 M=fsize; N=fsize; /*global sizes*/ 379 this->MatrixNonzeros(&d_nnz,&o_nnz,FsetEnum,FsetEnum); 380 Kff=new Matrix<IssmDouble>(m,n,M,N,d_nnz,o_nnz); 381 xDelete<int>(d_nnz); 382 xDelete<int>(o_nnz); 383 } 384 if(pKfs){ 385 m=flocalsize; n=slocalsize; /*local sizes*/ 386 M=fsize; N=ssize; /*global sizes*/ 387 this->MatrixNonzeros(&d_nnz,&o_nnz,FsetEnum,SsetEnum); 388 Kfs=new Matrix<IssmDouble>(m,n,M,N,d_nnz,o_nnz); 389 xDelete<int>(d_nnz); 390 xDelete<int>(o_nnz); 391 } 392 if(pdf) df =new Vector<IssmDouble>(flocalsize,fsize); 393 if(ppf) pf =new Vector<IssmDouble>(flocalsize,fsize); 394 } 395 396 /*Allocate output pointers*/ 397 if(pKff) *pKff = Kff; 398 if(pKfs) *pKfs = Kfs; 399 if(pdf) *pdf = df; 400 if(ppf) *ppf = pf; 401 } 402 /*}}}*/ 403 void FemModel::MatrixNonzeros(int** pd_nnz,int** po_nnz,int set1enum,int set2enum){/*{{{*/ 404 405 /*Intermediary*/ 406 int i,j,k,index,offset,count; 407 int configuration_type; 408 int d_nz,o_nz; 409 Element *element = NULL; 410 Load *load = NULL; 411 int *head_e = NULL; 412 int *next_e = NULL; 413 int *count2offset_e = NULL; 414 int *head_l = NULL; 415 int *next_l = NULL; 416 int *count2offset_l = NULL; 417 int *sidlist = NULL; 418 419 /*output*/ 420 int *d_nnz = NULL; 421 int *o_nnz = NULL; 422 423 /*retrive parameters: */ 424 this->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 425 426 /*Get vector size and number of nodes*/ 427 int numnodes = nodes->NumberOfNodes(configuration_type); 428 int numberofdofspernode = nodes->MaxNumDofs(configuration_type,GsetEnum); 429 int M = nodes->NumberOfDofs(configuration_type,set1enum); 430 int N = nodes->NumberOfDofs(configuration_type,set2enum); 431 int m = nodes->NumberOfDofsLocal(configuration_type,set1enum); 432 int n = nodes->NumberOfDofsLocal(configuration_type,set2enum); 433 int numnodesperelement = elements->MaxNumNodes(); 434 int numnodesperload = loads->MaxNumNodes(configuration_type); 435 436 /*First, we are building chaining vectors so that we know what nodes are 437 * connected to what elements. These vectors are such that: 438 * for(int i=head[id];i!=-1;i=next[i]) 439 * will loop over all the elements that are connected to the node number 440 * id*/ 441 head_e = xNew<int>(numnodes); for(i=0;i<numnodes;i++) head_e[i]=-1; 442 next_e = xNew<int>(elements->Size()*numnodesperelement); 443 count2offset_e = xNew<int>(elements->Size()*numnodesperelement); 444 445 k=0; 446 for(i=0;i<elements->Size();i++){ 447 element = dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 448 sidlist = xNew<int>(element->GetNumberOfNodes()); 449 element->GetNodesSidList(sidlist); 450 451 for(j=0;j<element->GetNumberOfNodes();j++){ 452 index = sidlist[j]; 453 _assert_(index>=0 && index<numnodes); 454 455 count2offset_e[k]=i; 456 next_e[k]=head_e[index]; 457 head_e[index]=k++; 458 } 459 for(j=0;j<numnodesperelement-element->GetNumberOfNodes();j++) k++; 460 461 xDelete<int>(sidlist); 462 } 463 464 /*Chain for loads*/ 465 head_l = xNew<int>(numnodes); for(i=0;i<numnodes;i++) head_l[i]=-1; 466 next_l = xNew<int>(loads->Size(configuration_type)*numnodesperload); 467 count2offset_l = xNew<int>(loads->Size(configuration_type)*numnodesperload); 468 k=0; 469 for(i=0;i<loads->Size();i++){ 470 load = dynamic_cast<Load*>(loads->GetObjectByOffset(i)); 471 if(!load->InAnalysis(configuration_type)) continue; 472 sidlist = xNew<int>(load->GetNumberOfNodes()); 473 load->GetNodesSidList(sidlist); 474 475 for(j=0;j<load->GetNumberOfNodes();j++){ 476 index = sidlist[j]; 477 _assert_(index>=0 && index<numnodes); 478 479 count2offset_l[k]=i; 480 next_l[k]=head_l[index]; 481 head_l[index]=k++; 482 } 483 for(j=0;j<numnodesperload-load->GetNumberOfNodes();j++) k++; 484 485 xDelete<int>(sidlist); 486 } 487 488 /*OK now count number of dofs and flag each nodes for each node i*/ 489 bool *flags = xNew<bool>(numnodes); 490 int *d_connectivity = xNewZeroInit<int>(numnodes); 491 int *o_connectivity = xNewZeroInit<int>(numnodes); 492 int *connectivity_clone = xNewZeroInit<int>(numnodes); 493 int *all_connectivity_clone = xNewZeroInit<int>(numnodes); 494 495 /*Create connectivity vector*/ 496 for(i=0;i<nodes->Size();i++){ 497 Node* node=dynamic_cast<Node*>(nodes->GetObjectByOffset(i)); 498 if(node->InAnalysis(configuration_type)){ 499 500 /*Reinitialize flags to 0*/ 501 for(j=0;j<numnodes;j++) flags[j]=false; 502 503 /*Loop over elements that hold node number i*/ 504 _assert_(head_e[node->Sid()]!=-1 || head_l[node->Sid()]!=-1); 505 for(j=head_e[node->Sid()];j!=-1;j=next_e[j]){ 506 offset=count2offset_e[j]; 507 element=dynamic_cast<Element*>(elements->GetObjectByOffset(offset)); 508 element->SetwiseNodeConnectivity(&d_nz,&o_nz,node,flags,set1enum,set2enum); 509 if(node->IsClone()){ 510 connectivity_clone[node->Sid()]+=d_nz+o_nz; 511 } 512 else{ 513 d_connectivity[node->Sid()]+=d_nz; 514 o_connectivity[node->Sid()]+=o_nz; 515 } 516 } 517 for(j=head_l[node->Sid()];j!=-1;j=next_l[j]){ 518 offset=count2offset_l[j]; 519 load=dynamic_cast<Load*>(loads->GetObjectByOffset(offset)); 520 load->SetwiseNodeConnectivity(&d_nz,&o_nz,node,flags,set1enum,set2enum); 521 if(node->IsClone()){ 522 connectivity_clone[node->Sid()]+=d_nz+o_nz; 523 } 524 else{ 525 d_connectivity[node->Sid()]+=d_nz; 526 o_connectivity[node->Sid()]+=o_nz; 527 } 528 } 529 } 530 } 531 xDelete<bool>(flags); 532 xDelete<int>(count2offset_e); 533 xDelete<int>(head_e); 534 xDelete<int>(next_e); 535 xDelete<int>(count2offset_l); 536 xDelete<int>(head_l); 537 xDelete<int>(next_l); 538 539 /*sum over all cpus*/ 540 #ifdef _HAVE_MPI_ 541 MPI_Allreduce((void*)connectivity_clone,(void*)all_connectivity_clone,numnodes,MPI_INT,MPI_SUM,IssmComm::GetComm()); 542 #endif 543 xDelete<int>(connectivity_clone); 544 545 if(set1enum==FsetEnum){ 546 count=0; 547 d_nnz=xNew<int>(m); 548 o_nnz=xNew<int>(m); 549 for(i=0;i<nodes->Size();i++){ 550 Node* node=dynamic_cast<Node*>(nodes->GetObjectByOffset(i)); 551 if(node->InAnalysis(configuration_type) && !node->IsClone()){ 552 for(j=0;j<node->indexing.fsize;j++){ 553 _assert_(count<m); 554 d_nnz[count]=numberofdofspernode*(d_connectivity[node->Sid()] + all_connectivity_clone[node->Sid()]); 555 o_nnz[count]=numberofdofspernode*(o_connectivity[node->Sid()] + all_connectivity_clone[node->Sid()]); 556 if(d_nnz[count]>n) d_nnz[count]=n; 557 if(o_nnz[count]>N-n) o_nnz[count]=N-n; 558 count++; 559 } 560 } 561 } 562 _assert_(m==count); 563 } 564 else{ 565 _error_("STOP not implemented"); 566 } 567 xDelete<int>(d_connectivity); 568 xDelete<int>(o_connectivity); 569 xDelete<int>(all_connectivity_clone); 570 571 /*Allocate ouptput pointer*/ 572 *pd_nnz=d_nnz; 573 *po_nnz=o_nnz; 574 575 }/*}}}*/ 576 void FemModel::CreateJacobianMatrixx(Matrix<IssmDouble>** pJff,IssmDouble kmax){/*{{{*/ 577 578 int i,connectivity; 579 int numberofdofspernode; 580 int fsize,configuration_type; 581 Element *element = NULL; 582 Load *load = NULL; 583 Matrix<IssmDouble>* Jff = NULL; 584 585 /*Checks*/ 586 _assert_(nodes && elements); 587 588 /*Recover some parameters*/ 589 parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 590 parameters->FindParam(&connectivity,MeshAverageVertexConnectivityEnum); 591 fsize=nodes->NumberOfDofs(configuration_type,FsetEnum); 592 numberofdofspernode=nodes->MaxNumDofs(configuration_type,GsetEnum); 593 594 /*Initialize Jacobian Matrix*/ 595 this->AllocateSystemMatrices(&Jff,NULL,NULL,NULL); 596 597 /*Create and assemble matrix*/ 598 for(i=0;i<elements->Size();i++){ 599 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 600 element->CreateJacobianMatrix(Jff); 601 } 602 for (i=0;i<loads->Size();i++){ 603 load=(Load*)loads->GetObjectByOffset(i); 604 if(load->InAnalysis(configuration_type)) load->CreateJacobianMatrix(Jff); 605 if(load->InAnalysis(configuration_type)) load->PenaltyCreateJacobianMatrix(Jff,kmax); 606 } 607 Jff->Assemble(); 608 609 /*Assign output pointer*/ 610 *pJff=Jff; 611 612 }/*}}}*/ 613 int FemModel::UpdateVertexPositionsx(void){ /*{{{*/ 614 615 int i; 616 Vector<IssmDouble>* vz = NULL; 617 Vertex *vertex = NULL; 618 IssmDouble *thickness = NULL; 619 IssmDouble *bed = NULL; 620 621 /*get vertex vectors for bed and thickness: */ 622 GetVectorFromInputsx(&thickness,elements,nodes, vertices, loads, materials, parameters, ThicknessEnum,VertexEnum); 623 GetVectorFromInputsx(&bed ,elements,nodes, vertices, loads, materials, parameters, BedEnum, VertexEnum); 624 625 /*Allocate vector*/ 626 vz=new Vector<IssmDouble>(vertices->NumberOfVertices()); 627 628 /*Update verices new geometry: */ 629 for (i=0;i<vertices->Size();i++){ 630 vertex=(Vertex*)vertices->GetObjectByOffset(i); 631 vertex->UpdatePosition(vz,parameters,thickness,bed); 632 } 633 634 /*Assemble mesh velocity*/ 635 vz->Assemble(); 636 637 /*Update element inputs*/ 638 InputUpdateFromVectorx(elements,nodes,vertices,loads,materials,parameters,vz,VzMeshEnum,VertexEnum); 639 640 /*Free ressources:*/ 641 xDelete<IssmDouble>(thickness); 642 xDelete<IssmDouble>(bed); 643 xdelete(&vz); 644 return 1; 645 } 646 /*}}}*/ 647 void FemModel::UpdateConstraintsx(void){ /*{{{*/ 648 649 IssmDouble time; 650 int analysis_type; 651 652 /*retrieve parameters: */ 653 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 654 parameters->FindParam(&time,TimeEnum); 655 656 /*start module: */ 657 if(VerboseModule()) _pprintLine_(" Updating constraints for time: " << time); 658 659 /*First, update dof constraints in nodes, using constraints: */ 660 SpcNodesx(nodes,constraints,parameters,analysis_type); 661 662 /*Now, update degrees of freedoms: */ 663 NodesDofx(nodes,parameters,analysis_type); 664 665 } 666 /*}}}*/ 667 void FemModel::Responsex(IssmDouble* responses,const char* response_descriptor,bool process_units,int weight_index){/*{{{*/ 668 669 int response_descriptor_enum=StringToEnumx(response_descriptor); 670 this->Responsex(responses, response_descriptor_enum, process_units, weight_index); 671 672 } 673 /*}}}*/ 674 void FemModel::Responsex(IssmDouble* responses,int response_descriptor_enum,bool process_units,int weight_index){/*{{{*/ 675 676 677 switch (response_descriptor_enum){ 678 679 #ifdef _HAVE_RESPONSES_ 680 case IceVolumeEnum: this->IceVolumex(responses,process_units); break; 681 case MinVelEnum: this->MinVelx(responses,process_units); break; 682 case MaxVelEnum: this->MaxVelx( responses,process_units); break; 683 case MinVxEnum: this->MinVxx(responses,process_units); break; 684 case MaxVxEnum: this->MaxVxx( responses,process_units); break; 685 case MaxAbsVxEnum: this->MaxAbsVxx( responses,process_units); break; 686 case MinVyEnum: this->MinVyx(responses,process_units); break; 687 case MaxVyEnum: this->MaxVyx( responses,process_units); break; 688 case MaxAbsVyEnum: this->MaxAbsVyx( responses,process_units); break; 689 case MinVzEnum: this->MinVzx(responses,process_units); break; 690 case MaxVzEnum: this->MaxVzx( responses,process_units); break; 691 case MaxAbsVzEnum: this->MaxAbsVzx( responses,process_units); break; 692 case MassFluxEnum: this->MassFluxx( responses,process_units); break; 693 case SurfaceAbsVelMisfitEnum: SurfaceAbsVelMisfitx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break; 694 case SurfaceRelVelMisfitEnum: SurfaceRelVelMisfitx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break; 695 case SurfaceLogVelMisfitEnum: SurfaceLogVelMisfitx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break; 696 case SurfaceLogVxVyMisfitEnum: SurfaceLogVxVyMisfitx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break; 697 case SurfaceAverageVelMisfitEnum:SurfaceAverageVelMisfitx( responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break; 698 case ThicknessAbsMisfitEnum: ThicknessAbsMisfitx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break; 699 case ThicknessAbsGradientEnum: this->ThicknessAbsGradientx(responses, process_units,weight_index); break; 700 case ThicknessAlongGradientEnum: ThicknessAlongGradientx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break; 701 case ThicknessAcrossGradientEnum:ThicknessAcrossGradientx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break; 702 case TotalSmbEnum: this->TotalSmbx(responses,process_units); break; 703 case RheologyBbarAbsGradientEnum:RheologyBbarAbsGradientx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break; 704 case DragCoefficientAbsGradientEnum:DragCoefficientAbsGradientx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break; 705 case MaterialsRheologyBbarEnum: this->ElementResponsex(responses,MaterialsRheologyBbarEnum,process_units); break; 706 case VelEnum: this->ElementResponsex(responses,VelEnum,process_units); break; 707 case FrictionCoefficientEnum:NodalValuex(responses, FrictionCoefficientEnum,elements,nodes, vertices, loads, materials, parameters,process_units); break; 708 default: _error_("response descriptor \"" << EnumToStringx(response_descriptor_enum) << "\" not supported yet!"); break; 709 #else 710 default: _error_("ISSM was not compiled with responses capabilities, exiting!"); 711 #endif 712 } 713 714 } 715 /*}}}*/ 716 void FemModel::RequestedOutputsx(int* requested_outputs, int numoutputs){/*{{{*/ 717 718 719 int output_enum; 720 int step; 721 IssmDouble time; 722 IssmDouble output_value; 723 Element *element = NULL; 724 725 /*Get time and step*/ 726 parameters->FindParam(&step,StepEnum); 727 parameters->FindParam(&time,TimeEnum); 728 729 /*retrieve Inputs*/ 730 if(numoutputs){ 731 for(int i=0;i<numoutputs;i++){ 732 output_enum=requested_outputs[i]; 733 734 switch(output_enum){ 735 736 case IceVolumeEnum: 737 Responsex(&output_value,"IceVolume",false,0); 738 results->AddObject(new GenericExternalResult<double>(results->Size()+1,IceVolumeEnum,reCast<IssmPDouble>(output_value),step,time)); 739 break; 740 case TotalSmbEnum: 741 Responsex(&output_value,"TotalSmb",false,0); 742 results->AddObject(new GenericExternalResult<double>(results->Size()+1,TotalSmbEnum,reCast<IssmPDouble>(output_value),step,time)); 743 break; 744 case MaxVelEnum: 745 Responsex(&output_value,"MaxVel",false,0); 746 results->AddObject(new GenericExternalResult<double>(results->Size()+1,MaxVelEnum,reCast<IssmPDouble>(output_value),step,time)); 747 break; 748 default: 749 /*create this output in the element inputs, and then transfer to results:*/ 750 for(int j=0;j<elements->Size();j++){ 751 element=(Element*)elements->GetObjectByOffset(j); 752 element->RequestedOutput(output_enum,step,time); 753 } 754 break; 755 } 756 } 757 } 758 } 759 /*}}}*/ 760 void FemModel::RequestedDependentsx(void){/*{{{*/ 761 762 763 bool isautodiff = false; 764 IssmDouble output_value; 765 766 int num_dependents; 767 IssmPDouble *dependents; 768 DataSet* dependent_objects=NULL; 769 770 /*AD mode on?: */ 771 parameters->FindParam(&isautodiff,AutodiffIsautodiffEnum); 772 773 if(isautodiff){ 774 #ifdef _HAVE_ADOLC_ 775 parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 776 parameters->FindParam(&dependent_objects,AutodiffDependentObjectsEnum); 777 if(num_dependents){ 778 dependents=xNew<IssmPDouble>(num_dependents); 779 780 /*Go through our dependent variables, and compute the response:*/ 781 for(int i=0;i<dependent_objects->Size();i++){ 782 DependentObject* dep=(DependentObject*)dependent_objects->GetObjectByOffset(i); 783 dep->Responsex(&output_value,this); 784 output_value>>=dependents[i]; 785 } 786 } 787 delete dependent_objects; 788 #else 789 _error_("Should not be requesting dependents when an AD library is not available!"); 790 #endif 791 } 792 } 793 /*}}}*/ 794 void FemModel::SystemMatricesx(Matrix<IssmDouble>** pKff, Matrix<IssmDouble>** pKfs, Vector<IssmDouble>** ppf, Vector<IssmDouble>** pdf, IssmDouble* pkmax){/*{{{*/ 795 796 /*intermediary: */ 797 int i; 798 int configuration_type; 799 Element *element = NULL; 800 Load *load = NULL; 801 802 /*output: */ 803 Matrix<IssmDouble> *Kff = NULL; 804 Matrix<IssmDouble> *Kfs = NULL; 805 Vector<IssmDouble> *pf = NULL; 806 Vector<IssmDouble> *df = NULL; 807 IssmDouble kmax = 0; 808 809 /*Display message*/ 810 if(VerboseModule()) _pprintLine_(" Generating matrices"); 811 812 /*retrive parameters: */ 813 this->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 814 815 /*First, we might need to do a dry run to get kmax if penalties are employed*/ 816 if(loads->IsPenalty(configuration_type)){ 817 818 /*Allocate Kff_temp*/ 819 Matrix<IssmDouble> *Kff_temp = NULL; 820 this->AllocateSystemMatrices(&Kff_temp,NULL,NULL,NULL); 821 822 /*Get complete stiffness matrix without penalties*/ 823 for (i=0;i<this->elements->Size();i++){ 824 element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 825 element->CreateKMatrix(Kff_temp,NULL,NULL); 826 } 827 for (i=0;i<this->loads->Size();i++){ 828 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 829 if(load->InAnalysis(configuration_type)) load->CreateKMatrix(Kff_temp,NULL); 830 } 831 Kff_temp->Assemble(); 832 833 /*Now, figure out maximum value of stiffness matrix, so that we can penalize it correctly: */ 834 kmax=Kff_temp->Norm(NORM_INF); 835 delete Kff_temp; 836 } 837 838 /*Allocate stiffness matrices and load vector*/ 839 this->AllocateSystemMatrices(&Kff,&Kfs,&df,&pf); 840 841 /*Fill stiffness matrix from elements and loads */ 842 for (i=0;i<this->elements->Size();i++){ 843 element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 844 element->CreateKMatrix(Kff,Kfs,df); 845 } 846 for (i=0;i<this->loads->Size();i++){ 847 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 848 if(load->InAnalysis(configuration_type)) load->CreateKMatrix(Kff,Kfs); 849 } 850 851 /*Fill right hand side vector, from elements and loads */ 852 for (i=0;i<this->elements->Size();i++){ 853 element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 854 element->CreatePVector(pf); 855 } 856 for (i=0;i<this->loads->Size();i++){ 857 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 858 if(load->InAnalysis(configuration_type)) load->CreatePVector(pf); 859 } 860 861 /*Now deal with penalties (only in loads)*/ 862 if(loads->IsPenalty(configuration_type)){ 863 for (i=0;i<this->loads->Size();i++){ 864 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 865 if(load->InAnalysis(configuration_type)) load->PenaltyCreateKMatrix(Kff,Kfs,kmax); 866 } 867 for (i=0;i<this->loads->Size();i++){ 868 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 869 if(load->InAnalysis(configuration_type)) load->PenaltyCreatePVector(pf,kmax); 870 } 871 } 872 873 /*Assemble matrices and vector*/ 874 Kff->Assemble(); 875 Kfs->Assemble(); 876 pf->Assemble(); 877 df->Assemble(); 878 //Kff->AllocationInfo(); 879 //Kfs->AllocationInfo(); 880 881 /*Assign output pointers: */ 882 if(pKff) *pKff=Kff; 883 else xdelete(&Kff); 884 if(pKfs) *pKfs=Kfs; 885 else xdelete(&Kfs); 886 if(ppf) *ppf=pf; 887 else xdelete(&pf); 888 if(pdf) *pdf=df; 889 else xdelete(&df); 890 if(pkmax) *pkmax=kmax; 891 } 892 /*}}}*/ 893 void FemModel::TimeAdaptx(IssmDouble* pdt){/*{{{*/ 894 895 int i; 896 897 /*output: */ 898 IssmDouble dt; 899 900 /*intermediary: */ 901 Element *element = NULL; 902 IssmDouble min_dt = 0; 903 IssmDouble node_min_dt = 0; 904 905 /*Go through elements, and figure out the minimum of the time steps for each element (using CFL criterion): */ 906 element=(Element*)elements->GetObjectByOffset(0); min_dt=element->TimeAdapt(); 907 908 for (i=1;i<elements->Size();i++){ 909 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 910 dt=element->TimeAdapt(); 911 if(dt<min_dt)min_dt=dt; 912 } 913 914 /*Figure out minimum across the cluster: */ 915 #ifdef _HAVE_MPI_ 916 MPI_Reduce (&min_dt,&node_min_dt,1,MPI_DOUBLE,MPI_MIN,0,IssmComm::GetComm() ); 917 MPI_Bcast(&node_min_dt,1,MPI_DOUBLE,0,IssmComm::GetComm()); 918 min_dt=node_min_dt; 919 #endif 920 921 /*Assign output pointers:*/ 922 *pdt=min_dt; 923 } 924 /*}}}*/ 925 #ifdef _HAVE_RESPONSES_ 926 void FemModel::MassFluxx(IssmDouble* pmass_flux,bool process_units){/*{{{*/ 927 928 int i,j; 929 Element *element = NULL; 930 int element_id; 931 bool ispresent = false; 932 IssmDouble mass_flux = 0; 933 IssmDouble all_mass_flux = 0; 934 int counter; 935 IssmDouble **array = NULL; 936 int M; 937 int *mdims_array = NULL; 938 int *ndims_array = NULL; 939 IssmDouble *segments = NULL; 940 int num_segments; 941 942 /*First, figure out which segment to compute our mass flux on. Start with retrieving qmu_mass_flux_segments: */ 943 this->parameters->FindParam(&ispresent,MassFluxSegmentsPresentEnum); 944 if(!ispresent)_error_("no mass flux segments available!"); 945 this->parameters->FindParam(&array,&M,&mdims_array,&ndims_array,MassFluxSegmentsEnum); 946 947 /*Retrieve index of segments being used for MassFlux computation: */ 948 parameters->FindParam(&counter,IndexEnum); 949 950 /*retrieve segments from array: */ 951 segments = array[counter-1]; //matlab to "C" indexing 952 num_segments = mdims_array[counter-1]; 953 954 /*Go through segments, and then elements, and figure out which elements belong to a segment. 955 * When we find one, use the element to compute the mass flux on the segment: */ 956 for(i=0;i<num_segments;i++){ 957 element_id=reCast<int,IssmDouble>(*(segments+5*i+4)); 958 for(j=0;j<elements->Size();j++){ 959 element=(Element*)this->elements->GetObjectByOffset(j); 960 if (element->Id()==element_id){ 961 /*We found the element which owns this segment, use it to compute the mass flux: */ 962 mass_flux+=element->MassFlux(segments+5*i+0,process_units); 963 break; 964 } 965 } 966 } 967 968 #ifdef _HAVE_MPI_ 969 MPI_Allreduce ( (void*)&mass_flux,(void*)&all_mass_flux,1,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm()); 970 mass_flux=all_mass_flux; 971 #endif 972 973 /*Free ressources:*/ 974 for(i=0;i<M;i++){ 975 IssmDouble* matrix=array[i]; 976 xDelete<IssmDouble>(matrix); 977 } 978 xDelete<int>(mdims_array); 979 xDelete<int>(ndims_array); 980 xDelete<IssmDouble*>(array); 981 982 /*Assign output pointers: */ 983 *pmass_flux=mass_flux; 984 985 }/*}}}*/ 986 void FemModel::MaxAbsVxx(IssmDouble* pmaxabsvx,bool process_units){/*{{{*/ 987 988 int i; 989 IssmDouble maxabsvx; 990 IssmDouble node_maxabsvx; 991 IssmDouble element_maxabsvx; 992 993 /*Go through elements, and request velocity: */ 994 maxabsvx=-INFINITY; 995 for(i=0;i<this->elements->Size();i++){ 996 Element* element=(Element*)this->elements->GetObjectByOffset(i); 997 element->MaxAbsVx(&element_maxabsvx,process_units); 998 if(element_maxabsvx>maxabsvx) maxabsvx=element_maxabsvx; 999 } 1000 1001 /*Figure out maximum across the cluster: */ 1002 #ifdef _HAVE_MPI_ 1003 MPI_Reduce(&maxabsvx,&node_maxabsvx,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() ); 1004 MPI_Bcast(&node_maxabsvx,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1005 maxabsvx=node_maxabsvx; 1006 #endif 1007 1008 /*Assign output pointers:*/ 1009 *pmaxabsvx=maxabsvx; 1010 1011 }/*}}}*/ 1012 void FemModel::MaxAbsVyx(IssmDouble* pmaxabsvy,bool process_units){/*{{{*/ 1013 1014 int i; 1015 IssmDouble maxabsvy; 1016 IssmDouble node_maxabsvy; 1017 IssmDouble element_maxabsvy; 1018 1019 /*Go through elements, and request velocity: */ 1020 maxabsvy=-INFINITY; 1021 for(i=0;i<this->elements->Size();i++){ 1022 Element* element=(Element*)this->elements->GetObjectByOffset(i); 1023 element->MaxAbsVy(&element_maxabsvy,process_units); 1024 if(element_maxabsvy>maxabsvy) maxabsvy=element_maxabsvy; 1025 } 1026 1027 /*Figure out maximum across the cluster: */ 1028 #ifdef _HAVE_MPI_ 1029 MPI_Reduce(&maxabsvy,&node_maxabsvy,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() ); 1030 MPI_Bcast(&node_maxabsvy,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1031 maxabsvy=node_maxabsvy; 1032 #endif 1033 1034 /*Assign output pointers:*/ 1035 *pmaxabsvy=maxabsvy; 1036 1037 }/*}}}*/ 1038 void FemModel::MaxAbsVzx(IssmDouble* pmaxabsvz,bool process_units){/*{{{*/ 1039 1040 int i; 1041 IssmDouble maxabsvz; 1042 IssmDouble node_maxabsvz; 1043 IssmDouble element_maxabsvz; 1044 1045 /*Go through elements, and request velocity: */ 1046 maxabsvz=-INFINITY; 1047 for(i=0;i<this->elements->Size();i++){ 1048 Element* element=(Element*)this->elements->GetObjectByOffset(i); 1049 element->MaxAbsVz(&element_maxabsvz,process_units); 1050 if(element_maxabsvz>maxabsvz) maxabsvz=element_maxabsvz; 1051 } 1052 1053 /*Figure out maximum across the cluster: */ 1054 #ifdef _HAVE_MPI_ 1055 MPI_Reduce(&maxabsvz,&node_maxabsvz,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() ); 1056 MPI_Bcast(&node_maxabsvz,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1057 maxabsvz=node_maxabsvz; 1058 #endif 1059 1060 /*Assign output pointers:*/ 1061 *pmaxabsvz=maxabsvz; 1062 1063 }/*}}}*/ 1064 void FemModel::MaxVelx(IssmDouble* pmaxvel,bool process_units){/*{{{*/ 1065 1066 int i; 1067 IssmDouble maxvel; 1068 IssmDouble node_maxvel; 1069 IssmDouble element_maxvel; 1070 1071 /*Go through elements, and request velocity: */ 1072 maxvel=-INFINITY; 1073 for(i=0;i<this->elements->Size();i++){ 1074 Element* element=(Element*)this->elements->GetObjectByOffset(i); 1075 element->MaxVel(&element_maxvel,process_units); 1076 if(element_maxvel>maxvel) maxvel=element_maxvel; 1077 } 1078 1079 /*Figure out maximum across the cluster: */ 1080 #ifdef _HAVE_MPI_ 1081 MPI_Reduce(&maxvel,&node_maxvel,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() ); 1082 MPI_Bcast(&node_maxvel,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1083 maxvel=node_maxvel; 1084 #endif 1085 1086 /*Assign output pointers:*/ 1087 *pmaxvel=maxvel; 1088 1089 }/*}}}*/ 1090 void FemModel::MaxVxx(IssmDouble* pmaxvx,bool process_units){/*{{{*/ 1091 1092 int i; 1093 IssmDouble maxvx; 1094 IssmDouble node_maxvx; 1095 IssmDouble element_maxvx; 1096 1097 /*Go through elements, and request velocity: */ 1098 maxvx=-INFINITY; 1099 for(i=0;i<this->elements->Size();i++){ 1100 Element* element=(Element*)this->elements->GetObjectByOffset(i); 1101 element->MaxVx(&element_maxvx,process_units); 1102 if(element_maxvx>maxvx) maxvx=element_maxvx; 1103 } 1104 1105 /*Figure out maximum across the cluster: */ 1106 #ifdef _HAVE_MPI_ 1107 MPI_Reduce(&maxvx,&node_maxvx,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() ); 1108 MPI_Bcast(&node_maxvx,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1109 maxvx=node_maxvx; 1110 #endif 1111 1112 /*Assign output pointers:*/ 1113 *pmaxvx=maxvx; 1114 1115 }/*}}}*/ 1116 void FemModel::MaxVyx(IssmDouble* pmaxvy,bool process_units){/*{{{*/ 1117 1118 int i; 1119 IssmDouble maxvy; 1120 IssmDouble node_maxvy; 1121 IssmDouble element_maxvy; 1122 1123 /*Go through elements, and request velocity: */ 1124 maxvy=-INFINITY; 1125 for(i=0;i<this->elements->Size();i++){ 1126 Element* element=(Element*)this->elements->GetObjectByOffset(i); 1127 element->MaxVy(&element_maxvy,process_units); 1128 if(element_maxvy>maxvy) maxvy=element_maxvy; 1129 } 1130 1131 /*Figure out maximum across the cluster: */ 1132 #ifdef _HAVE_MPI_ 1133 MPI_Reduce(&maxvy,&node_maxvy,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() ); 1134 MPI_Bcast(&node_maxvy,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1135 maxvy=node_maxvy; 1136 #endif 1137 1138 /*Assign output pointers:*/ 1139 *pmaxvy=maxvy; 1140 1141 }/*}}}*/ 1142 void FemModel::MaxVzx(IssmDouble* pmaxvz,bool process_units){/*{{{*/ 1143 1144 int i; 1145 IssmDouble maxvz; 1146 IssmDouble node_maxvz; 1147 IssmDouble element_maxvz; 1148 1149 /*Go through elements, and request velocity: */ 1150 maxvz=-INFINITY; 1151 for(i=0;i<this->elements->Size();i++){ 1152 Element* element=(Element*)this->elements->GetObjectByOffset(i); 1153 element->MaxVz(&element_maxvz,process_units); 1154 if(element_maxvz>maxvz) maxvz=element_maxvz; 1155 } 1156 1157 /*Figure out maximum across the cluster: */ 1158 #ifdef _HAVE_MPI_ 1159 MPI_Reduce(&maxvz,&node_maxvz,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() ); 1160 MPI_Bcast(&node_maxvz,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1161 maxvz=node_maxvz; 1162 #endif 1163 1164 /*Assign output pointers:*/ 1165 *pmaxvz=maxvz; 1166 1167 }/*}}}*/ 1168 void FemModel::MinVelx(IssmDouble* pminvel,bool process_units){/*{{{*/ 1169 1170 int i; 1171 IssmDouble minvel; 1172 IssmDouble node_minvel; 1173 IssmDouble element_minvel; 1174 1175 /*Go through elements, and request velocity: */ 1176 minvel=INFINITY; 1177 for(i=0;i<this->elements->Size();i++){ 1178 Element* element=(Element*)this->elements->GetObjectByOffset(i); 1179 element->MinVel(&element_minvel,process_units); 1180 if(element_minvel<minvel) minvel=element_minvel; 1181 } 1182 1183 /*Figure out minimum across the cluster: */ 1184 #ifdef _HAVE_MPI_ 1185 MPI_Reduce(&minvel,&node_minvel,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() ); 1186 MPI_Bcast(&node_minvel,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1187 minvel=node_minvel; 1188 #endif 1189 1190 /*Assign output pointers:*/ 1191 *pminvel=minvel; 1192 1193 }/*}}}*/ 1194 void FemModel::MinVxx(IssmDouble* pminvx,bool process_units){/*{{{*/ 1195 1196 int i; 1197 IssmDouble minvx; 1198 IssmDouble node_minvx; 1199 IssmDouble element_minvx; 1200 1201 /*Go through elements, and request velocity: */ 1202 minvx=INFINITY; 1203 for(i=0;i<this->elements->Size();i++){ 1204 Element* element=(Element*)this->elements->GetObjectByOffset(i); 1205 element->MinVx(&element_minvx,process_units); 1206 if(element_minvx<minvx) minvx=element_minvx; 1207 } 1208 1209 /*Figure out minimum across the cluster: */ 1210 #ifdef _HAVE_MPI_ 1211 MPI_Reduce(&minvx,&node_minvx,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() ); 1212 MPI_Bcast(&node_minvx,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1213 minvx=node_minvx; 1214 #endif 1215 1216 /*Assign output pointers:*/ 1217 *pminvx=minvx; 1218 1219 }/*}}}*/ 1220 void FemModel::MinVyx(IssmDouble* pminvy,bool process_units){/*{{{*/ 1221 1222 int i; 1223 IssmDouble minvy; 1224 IssmDouble node_minvy; 1225 IssmDouble element_minvy; 1226 1227 /*Go through elements, and request velocity: */ 1228 minvy=INFINITY; 1229 for(i=0;i<this->elements->Size();i++){ 1230 Element* element=(Element*)this->elements->GetObjectByOffset(i); 1231 element->MinVy(&element_minvy,process_units); 1232 if(element_minvy<minvy) minvy=element_minvy; 1233 } 1234 1235 /*Figure out minimum across the cluster: */ 1236 #ifdef _HAVE_MPI_ 1237 MPI_Reduce(&minvy,&node_minvy,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() ); 1238 MPI_Bcast(&node_minvy,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1239 minvy=node_minvy; 1240 #endif 1241 1242 /*Assign output pointers:*/ 1243 *pminvy=minvy; 1244 1245 }/*}}}*/ 1246 void FemModel::MinVzx(IssmDouble* pminvz,bool process_units){/*{{{*/ 1247 1248 int i; 1249 IssmDouble minvz; 1250 IssmDouble node_minvz; 1251 IssmDouble element_minvz; 1252 1253 /*Go through elements, and request velocity: */ 1254 minvz=INFINITY; 1255 for(i=0;i<this->elements->Size();i++){ 1256 Element* element=(Element*)this->elements->GetObjectByOffset(i); 1257 element->MinVz(&element_minvz,process_units); 1258 if(element_minvz<minvz) minvz=element_minvz; 1259 } 1260 1261 /*Figure out minimum across the cluster: */ 1262 #ifdef _HAVE_MPI_ 1263 MPI_Reduce(&minvz,&node_minvz,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() ); 1264 MPI_Bcast(&node_minvz,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1265 minvz=node_minvz; 1266 #endif 1267 1268 /*Assign output pointers:*/ 1269 *pminvz=minvz; 1270 1271 }/*}}}*/ 1272 void FemModel::TotalSmbx(IssmDouble* pSmb,bool process_units){/*{{{*/ 1273 1274 IssmDouble local_smb = 0; 1275 IssmDouble total_smb; 1276 1277 for(int i=0;i<this->elements->Size();i++){ 1278 Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 1279 local_smb+=element->TotalSmb(); 1280 } 1281 #ifdef _HAVE_MPI_ 1282 MPI_Reduce(&local_smb,&total_smb,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 1283 MPI_Bcast(&total_smb,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1284 #else 1285 total_smb=local_smb; 1286 #endif 1287 1288 /*Assign output pointers: */ 1289 *pSmb=total_smb; 1290 1291 }/*}}}*/ 1292 void FemModel::IceVolumex(IssmDouble* pV,bool process_units){/*{{{*/ 1293 1294 IssmDouble local_ice_volume = 0; 1295 IssmDouble total_ice_volume; 1296 1297 for(int i=0;i<this->elements->Size();i++){ 1298 Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 1299 local_ice_volume+=element->IceVolume(); 1300 } 1301 #ifdef _HAVE_MPI_ 1302 MPI_Reduce(&local_ice_volume,&total_ice_volume,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 1303 MPI_Bcast(&total_ice_volume,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1304 #else 1305 total_ice_volume=local_ice_volume; 1306 #endif 1307 1308 /*Assign output pointers: */ 1309 *pV=total_ice_volume; 1310 1311 }/*}}}*/ 1312 void FemModel::ElementResponsex(IssmDouble* presponse,int response_enum,bool process_units){/*{{{*/ 1313 1314 int found=0; 1315 int sumfound=0; 1316 int cpu_found=-1; 1317 int index; 1318 IssmDouble response; 1319 Element* element=NULL; 1320 1321 /*retrieve element we are interested in: */ 1322 this->parameters->FindParam(&index,IndexEnum); 1323 int my_rank=IssmComm::GetRank(); 1324 1325 /*now, go through our elements, and retrieve the one with this id: index: */ 1326 for(int i=0;i<this->elements->Size();i++){ 1327 element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 1328 if (element->Id()==index){ 1329 found=1; 1330 cpu_found=my_rank; 1331 break; 1332 } 1333 } 1334 1335 /*Broadcast whether we found the element: */ 1336 #ifdef _HAVE_MPI_ 1337 MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,IssmComm::GetComm()); 1338 if(!sumfound)_error_("could not find material with id" << index << " to compute ElementResponse"); 1339 #endif 1340 1341 /*Ok, we found the element, compute responseocity: */ 1342 if(my_rank==cpu_found){ 1343 element->ElementResponse(&response,response_enum,IuToExtEnum); 1344 } 1345 1346 /*Broadcast and plug into response: */ 1347 #ifdef _HAVE_MPI_ 1348 MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,IssmComm::GetComm()); 1349 MPI_Bcast(&response,1,MPI_DOUBLE,cpu_found,IssmComm::GetComm()); 1350 #endif 1351 1352 /*Assign output pointers: */ 1353 *presponse=response; 1354 1355 }/*}}}*/ 1356 #endif 1357 #ifdef _HAVE_CONTROL_ 1358 void FemModel::ThicknessAbsGradientx( IssmDouble* pJ, bool process_units, int weight_index){/*{{{*/ 1359 1360 1361 /*Intermediary*/ 1362 int i; 1363 Element* element=NULL; 1364 1365 /*output: */ 1366 IssmDouble J=0; 1367 IssmDouble J_sum; 1368 1369 /*Compute Misfit: */ 1370 for (i=0;i<elements->Size();i++){ 1371 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 1372 J+=element->ThicknessAbsGradient(process_units,weight_index); 1373 } 1374 1375 /*Sum all J from all cpus of the cluster:*/ 1376 #ifdef _HAVE_MPI_ 1377 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 1378 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 1379 J=J_sum; 1380 #endif 1381 1382 /*Assign output pointers: */ 1383 *pJ=J; 1384 } 1385 /*}}}*/ 1386 void FemModel::CostFunctionx(IssmDouble* pJ){/*{{{*/ 1387 1388 1389 /*Intermediary*/ 1390 int num_responses; 1391 Element *element = NULL; 1392 int *responses = NULL; 1393 1394 /*output: */ 1395 IssmDouble J,Jplus; 1396 1397 /*Recover parameters*/ 1398 parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum); 1399 parameters->FindParam(&responses,NULL,NULL,StepResponsesEnum); 1400 1401 /*Get response*/ 1402 J=0; 1403 for(int i=0;i<num_responses;i++){ 1404 this->Responsex(&Jplus,EnumToStringx(responses[i]),false,i); //False means DO NOT process units 1405 J+=Jplus; 1406 } 1407 1408 /*Assign output pointers: */ 1409 xDelete<int>(responses); 1410 *pJ=J; 1411 } 1412 /*}}}*/ 1413 #endif 1414 #ifdef _HAVE_DAKOTA_ 1415 void FemModel::DakotaResponsesx(double* d_responses,char** responses_descriptors,int numresponsedescriptors,int d_numresponses){/*{{{*/ 1416 1417 1418 int i,j; 1419 int my_rank; 1420 bool process_units = true; 1421 1422 /*intermediary: */ 1423 char root[50]; 1424 int index; 1425 int npart; 1426 double femmodel_response; 1427 int flag; 1428 double *vertex_response = NULL; 1429 double *qmu_response = NULL; 1430 double *responses_pointer = NULL; 1431 1432 /*retrieve npart: */ 1433 parameters->FindParam(&npart,QmuNumberofpartitionsEnum); 1434 my_rank=IssmComm::GetRank(); 1435 1436 /*save the d_responses pointer: */ 1437 responses_pointer=d_responses; 1438 1439 //watch out, we have more d_numresponses than numresponsedescriptors, because the responses have been expanded if they were scaled. 1440 //because we don't know the d_responses descriptors (the scaled ones) we can't key off them, so we will key off the responses_descriptors: */ 1441 1442 for(i=0;i<numresponsedescriptors;i++){ 1443 1444 flag=DescriptorIndex(root,&index,responses_descriptors[i]); 1445 1446 if(flag==ScaledEnum){ 1447 1448 /*this response was scaled. pick up the response from the inputs: */ 1449 GetVectorFromInputsx(&vertex_response,elements,nodes, vertices, loads, materials, parameters, StringToEnumx(root),VertexEnum); 1450 1451 /*Now, average it onto the partition nodes: */ 1452 AverageOntoPartitionx(&qmu_response,elements,nodes,vertices,loads,materials,parameters,vertex_response); 1453 1454 /*Copy onto our dakota responses: */ 1455 if(my_rank==0){ 1456 /*plug response: */ 1457 for(j=0;j<npart;j++)responses_pointer[j]=qmu_response[j]; 1458 1459 /*increment response_pointer :*/ 1460 responses_pointer+=npart; 1461 } 1462 1463 /*Free ressources:*/ 1464 xDelete<double>(vertex_response); 1465 xDelete<double>(qmu_response); 1466 1467 } 1468 else if (flag==IndexedEnum){ 1469 1470 /*indexed response: plug index into parameters and call response module: */ 1471 parameters->SetParam(index,IndexEnum); 1472 1473 this->Responsex(&femmodel_response,root,process_units,0);//0 is the index for weights 1474 1475 if(my_rank==0){ 1476 /*plug response: */ 1477 responses_pointer[0]=femmodel_response; 1478 1479 /*increment response_pointer :*/ 1480 responses_pointer++; 1481 } 1482 } 1483 else if (flag==NodalEnum){ 1484 _error_("nodal response functions not supported yet!"); 1485 1486 /*increment response_pointer :*/ 1487 responses_pointer++; 1488 } 1489 else if (flag==RegularEnum){ 1490 1491 /*perfectly normal response function: */ 1492 this->Responsex(&femmodel_response,root,process_units,0);//0 is the weight index 1493 1494 if(my_rank==0){ 1495 /*plug response: */ 1496 responses_pointer[0]=femmodel_response; 1497 1498 /*increment response_pointer :*/ 1499 responses_pointer++; 1500 } 1501 } 1502 else _error_("flag type " << flag << " not supported yet for response analysis"); 1503 } 1504 1505 /*Synthesize echo: {{{*/ 1506 if(my_rank==0){ 1507 _printString_(" responses: " << d_numresponses << ": "); 1508 for(i=0;i<d_numresponses-1;i++)_printString_(d_responses[i] << "|"); 1509 _printString_(d_responses[d_numresponses-1]); 1510 _printLine_(""); 1511 } 1512 /*}}}*/ 1513 1514 } 1515 /*}}}*/ 1516 #endif -
issm/trunk/src/c/classes/FemModel.h
r13395 r13975 19 19 class Loads; 20 20 class Materials; 21 class Profiler; 22 class Elements; 21 23 /*}}}*/ 22 23 24 24 25 class FemModel { … … 28 29 public: 29 30 30 int nummodels; 31 int solution_type; 32 int* analysis_type_list; //list of analyses this femmodel is going to carry out 33 int analysis_counter; //counter into analysis_type_list 34 35 Elements* elements; //elements (one set for all analyses) 36 Nodes* nodes; //one set of nodes 37 Vertices* vertices; //one set of vertices 38 Constraints* constraints; //one set of constraints. each constraint knows which analysis_type it handles 39 Loads* loads; //one set of constraints. each constraint knows which analysis_type it handles 40 Materials* materials; //one set of materials, for each element 41 Parameters* parameters; //one set of parameters, independent of the analysis_type 42 Results* results; //results that cannot be fit into the elements (such as one time constants, arrays, strings, etc ...) 31 int nummodels; 32 int solution_type; 33 int *analysis_type_list; //list of analyses this femmodel is going to carry out 34 int analysis_counter; //counter into analysis_type_list 35 36 Profiler* profiler; //keep time, cpu and mem statistics while we are running. 37 38 Elements *elements; //elements (one set for all analyses) 39 Nodes *nodes; //one set of nodes 40 Vertices *vertices; //one set of vertices 41 Constraints *constraints; //one set of constraints. each constraint knows which analysis_type it handles 42 Loads *loads; //one set of constraints. each constraint knows which analysis_type it handles 43 Materials *materials; //one set of materials, for each element 44 Parameters *parameters; //one set of parameters, independent of the analysis_type 45 Results *results; //results that cannot be fit into the elements 46 COMM comm; //communicator for this particular model 43 47 44 48 /*constructors, destructors: */ 45 FemModel(char* rootpath, char* inputfilename, char* outputfilename, const int solution_type,const int* analyses,const int nummodels); 49 FemModel(int argc,char** argv,COMM comm_init); 50 FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels); 46 51 ~FemModel(); 47 52 48 /*Methods: */ 53 /*Methods:*/ 54 void AllocateSystemMatrices(Matrix<IssmDouble>** pKff,Matrix<IssmDouble>** pKfs,Vector<IssmDouble>** pdf,Vector<IssmDouble>** ppf); 55 void CreateJacobianMatrixx(Matrix<IssmDouble>** pJff,IssmDouble kmax); 49 56 void Echo(); 57 void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels); 58 void MatrixNonzeros(int** pd_nnz,int** po_nnz,int set1enum,int set2enum); 59 void Solve(void); 60 void OutputResults(void); 61 void SetStaticComm(); 62 void SetCurrentConfiguration(int configuration_type); 63 void SetCurrentConfiguration(int configuration_type,int analysis_type); 50 64 51 /*Fem: */ 52 void SetCurrentConfiguration(int configuration_type); 53 void SetCurrentConfiguration(int configuration_type,int analysis_type); 54 65 /*Modules*/ 66 #ifdef _HAVE_RESPONSES_ 67 void MassFluxx(IssmDouble* presponse,bool process_units); 68 void MaxAbsVxx(IssmDouble* presponse,bool process_units); 69 void MaxAbsVyx(IssmDouble* presponse,bool process_units); 70 void MaxAbsVzx(IssmDouble* presponse,bool process_units); 71 void MaxVelx(IssmDouble* presponse,bool process_units); 72 void MaxVxx(IssmDouble* presponse,bool process_units); 73 void MaxVyx(IssmDouble* presponse,bool process_units); 74 void MaxVzx(IssmDouble* presponse,bool process_units); 75 void MinVelx(IssmDouble* presponse,bool process_units); 76 void MinVxx(IssmDouble* presponse,bool process_units); 77 void MinVyx(IssmDouble* presponse,bool process_units); 78 void MinVzx(IssmDouble* presponse,bool process_units); 79 void TotalSmbx(IssmDouble* pSmb,bool process_units); 80 void IceVolumex(IssmDouble* pV,bool process_units); 81 void ElementResponsex(IssmDouble* presponse,int response_enum,bool process_units); 82 #endif 83 #ifdef _HAVE_DAKOTA_ 84 void DakotaResponsesx(double* d_responses,char** responses_descriptors,int numresponsedescriptors,int d_numresponses); 85 #endif 86 void RequestedOutputsx(int* requested_outputs, int numoutputs); 87 void RequestedDependentsx(void); 88 void Responsex(IssmDouble* presponse,int response_descriptor_enum,bool process_units,int weight_index); 89 void Responsex(IssmDouble* presponse,const char* response_descriptor,bool process_units,int weight_index); 90 #ifdef _HAVE_CONTROL_ 91 void CostFunctionx( IssmDouble* pJ); 92 void ThicknessAbsGradientx( IssmDouble* pJ, bool process_units,int weight_index); 93 #endif 94 void SystemMatricesx(Matrix<IssmDouble>** pKff, Matrix<IssmDouble>** pKfs, Vector<IssmDouble>** ppf, Vector<IssmDouble>** pdf, IssmDouble* pkmax); 95 void TimeAdaptx(IssmDouble* pdt); 96 void UpdateConstraintsx(void); 97 int UpdateVertexPositionsx(void); 55 98 }; 56 99 -
issm/trunk/src/c/classes/Hook.cpp
r13395 r13975 2 2 * \brief: implementation of the Hook object: see Hook.h for more explanations. 3 3 */ 4 5 4 6 5 #ifdef HAVE_CONFIG_H … … 18 17 #include "../include/include.h" 19 18 20 21 19 /*Constructor/Destructors*/ 22 20 /*FUNCTION Hook::Hook(){{{*/ 23 21 Hook::Hook(){ 24 this->num=0; 25 this->objects=NULL; 26 this->ids=NULL; 27 this->offsets=NULL; 28 return; 22 this->num = 0; 23 this->objects = NULL; 24 this->ids = NULL; 25 this->offsets = NULL; 29 26 } 30 27 /*}}}*/ 31 28 /*FUNCTION Hook::Hook(int* ids, int num){{{*/ 32 29 Hook::Hook(int* in_ids, int in_num){ 33 34 /*Intermediaries*/35 int i;36 30 37 31 /*Get number of objects to hook*/ … … 41 35 if (num==0){ 42 36 /*Empty hook*/ 43 this->ids =NULL;44 this->objects =NULL;45 this->offsets =NULL;37 this->ids = NULL; 38 this->objects = NULL; 39 this->offsets = NULL; 46 40 } 47 41 else{ … … 52 46 53 47 /*Copy ids: */ 54 for (i=0;i<this->num;i++){55 this->ids[i] =in_ids[i];56 this->objects[i] =NULL;57 this->offsets[i] =0;48 for(int i=0;i<this->num;i++){ 49 this->ids[i] = in_ids[i]; 50 this->objects[i] = NULL; 51 this->offsets[i] = 0; 58 52 } 59 53 } … … 62 56 /*FUNCTION Hook::~Hook(){{{*/ 63 57 Hook::~Hook(){ 64 /*deallocate: */65 58 xDelete<Object*>(this->objects); 66 59 xDelete<int>(this->ids); 67 60 xDelete<int>(this->offsets); 68 return;69 61 } 70 62 /*}}}*/ … … 121 113 Object* Hook::copy(void){ 122 114 123 int i;124 125 115 /*output: */ 126 116 Hook* output=NULL; … … 132 122 output->num=this->num; 133 123 if(output->num){ 134 output->objects =xNew<Object*>(output->num);135 output->ids =xNew<int>(output->num);136 output->offsets =xNew<int>(output->num);137 } 138 139 for(i =0;i<output->num;i++){140 output->objects[i] =this->objects[i];141 output->offsets[i] =this->offsets[i];142 output->ids[i] =this->ids[i];124 output->objects = xNew<Object*>(output->num); 125 output->ids = xNew<int>(output->num); 126 output->offsets = xNew<int>(output->num); 127 } 128 129 for(int i=0;i<output->num;i++){ 130 output->objects[i] = this->objects[i]; 131 output->offsets[i] = this->offsets[i]; 132 output->ids[i] = this->ids[i]; 143 133 } 144 134 … … 183 173 /*Now, for this->objects that did not get resolved, and for which we have no offset, chase them in the dataset, by id: */ 184 174 if(this->objects[i]==NULL){ 185 this->objects[i]= (Object*)dataset->GetObjectById(this->offsets+i,this->ids[i]); //remember the offset for later on.175 this->objects[i]=dynamic_cast<Object*>(dataset->GetObjectById(this->offsets+i,this->ids[i])); //remember the offset for later on. 186 176 /*check the id is correct!: */ 187 177 if (this->objects[i]->Id()!=this->ids[i]) _error_("wrong id: " << this->objects[i]->Id() << " vs " << this->ids[i] << " in resolved pointer!"); … … 192 182 /*FUNCTION Hook::delivers{{{*/ 193 183 Object* Hook::delivers(void){ 194 184 195 185 /*first, check that we only have one T object in our object list: */ 196 186 if (this->num!=1) _error_("trying to delivery a single hook object when hook holds " << this->num << " objects" << "\n"); … … 230 220 /*FUNCTION Hook::Spawn{{{*/ 231 221 Hook* Hook::Spawn(int* indices, int numindices){ 232 233 int i;234 222 235 223 /*output: */ … … 246 234 247 235 /*Else, check that we are requesting a half of num*/ 248 if 236 if(numindices>this->num) _error_("Cannot spawn hook with " << numindices << " objects from a Hook of " << this->num << " objects"); 249 237 250 238 /*go pickup the correct objects, ids and offsets :*/ … … 252 240 if(output->num<1) _error_("Trying to spawn an empty ElementProperties!"); 253 241 254 output->objects =xNew<Object*>(output->num);255 output->ids =xNew<int>(output->num);256 output->offsets =xNew<int>(output->num);257 258 for(i =0;i<output->num;i++){259 output->objects[i] =this->objects[indices[i]];260 output->ids[i] =this->ids[indices[i]];261 output->offsets[i] =this->offsets[indices[i]];242 output->objects = xNew<Object*>(output->num); 243 output->ids = xNew<int>(output->num); 244 output->offsets = xNew<int>(output->num); 245 246 for(int i=0;i<output->num;i++){ 247 output->objects[i] = this->objects[indices[i]]; 248 output->ids[i] = this->ids[indices[i]]; 249 output->offsets[i] = this->offsets[indices[i]]; 262 250 } 263 251 -
issm/trunk/src/c/classes/Hook.h
r13395 r13975 19 19 private: 20 20 21 int num;//number of objects being hooked onto22 Object ** objects; //list of object pointers. we do not allocate objects, just a list a pointers, that will get to point to the real objects from a dataset.23 int * ids;//list of object ids, to go look for them in datasets.24 int * offsets;//list of object offsets into datasets, to speed up lookup.21 int num; //number of objects being hooked onto 22 Object **objects; //list of object pointers 23 int *ids; //list of object ids, to go look for them in datasets. 24 int *offsets; //list of object offsets into datasets, to speed up lookup. 25 25 26 26 public: -
issm/trunk/src/c/classes/IoModel.cpp
r13395 r13975 17 17 #include "./classes.h" 18 18 #include "../io/io.h" 19 #include ". /Container/Parameters.h"19 #include "../Container/Parameters.h" 20 20 #include "../shared/shared.h" 21 #include "../io/io.h"22 21 #include "../include/include.h" 23 22 … … 28 27 this->independents=NULL; 29 28 this->constants=NULL; 30 29 31 30 this->my_elements=NULL; 32 31 this->my_nodes=NULL; … … 34 33 this->singlenodetoelementconnectivity=NULL; 35 34 this->numbernodetoelementconnectivity=NULL; 36 35 37 36 this->nodecounter=0; 38 37 this->loadcounter=0; … … 42 41 /*FUNCTION IoModel::IoModel(FILE* iomodel_handle){{{*/ 43 42 IoModel::IoModel(FILE* iomodel_handle){ 44 43 45 44 /*First, keep track of the file handle: */ 46 45 this->fid=iomodel_handle; … … 48 47 /*Check that Enums are Synchronized*/ 49 48 this->CheckEnumSync(); 49 50 /*Initialize data: */ 51 this->data=xNew<IssmDouble*>(MaximumNumberOfEnums); 52 for(int i=0;i<MaximumNumberOfEnums;i++) this->data[i]=NULL; 53 54 /*If we are running in AD mode, we need to start the trace and declare our independent variables now, 55 *and prevent them from being erased during successive calls to iomodel->FetchConstants, iomodel->FetchData and 56 iomodel->DeleteData:*/ 57 this->DeclareIndependents(); 50 58 51 59 /*Initialize and read constants:*/ … … 53 61 this->FetchConstants(); /*this routine goes through the input file, and fetches bools, ints, IssmDoubles and strings only, nothing memory intensive*/ 54 62 55 /*Initialize data: */56 this->data=xNew<IssmDouble*>(MaximumNumberOfEnums);57 for(int i=0;i<MaximumNumberOfEnums;i++) this->data[i]=NULL;58 59 /*Initialize array detecting whether data[i] is an independent AD mode variable: */60 this->independents=xNew<bool>(MaximumNumberOfEnums);61 for(int i=0;i<MaximumNumberOfEnums;i++) this->independents[i]=false;62 63 63 /*Initialize permanent data: */ 64 64 this->my_elements=NULL; … … 67 67 this->singlenodetoelementconnectivity=NULL; 68 68 this->numbernodetoelementconnectivity=NULL; 69 69 70 70 this->nodecounter=0; 71 71 this->loadcounter=0; … … 91 91 xDelete<IssmDouble*>(this->data); 92 92 xDelete<bool>(this->independents); 93 if(this->independent_objects)delete this->independent_objects; 93 94 xDelete<bool>(this->my_elements); 94 95 xDelete<bool>(this->my_nodes); … … 102 103 void IoModel::CheckEnumSync(void){ 103 104 104 externint my_rank;105 int my_rank; 105 106 int record_enum = 0; 107 108 /*recover my_rank:*/ 109 my_rank=IssmComm::GetRank(); 106 110 107 111 /*Check that some fields have been allocated*/ … … 182 186 183 187 /*Find constant*/ 184 Param* param= (Param*)this->constants->FindParamObject(constant_enum);188 Param* param=dynamic_cast<Param*>(this->constants->FindParamObject(constant_enum)); 185 189 if(!param) _error_("Constant " << EnumToStringx(constant_enum) << " not found in iomodel"); 186 190 187 return (Param*)param->copy();191 return dynamic_cast<Param*>(param->copy()); 188 192 } 189 193 /*}}}*/ … … 195 199 196 200 return this->data[data_enum]; 201 } 202 /*}}}*/ 203 /*FUNCTION IoModel::DeclareIndependents{{{*/ 204 void IoModel::DeclareIndependents(void){ 205 206 int i; 207 bool autodiff = false; 208 int num_independent_objects; 209 210 int *names = NULL; 211 int *types = NULL; 212 213 int numberofvertices; 214 int dummy; 215 bool keep=false; 216 217 /*Initialize array detecting whether data[i] is an independent AD mode variable: */ 218 this->independents=xNew<bool>(MaximumNumberOfEnums); 219 for(i=0;i<MaximumNumberOfEnums;i++) this->independents[i]=false; 220 221 this->FetchData(&autodiff,AutodiffIsautodiffEnum); 222 if(autodiff){ 223 224 this->FetchData(&numberofvertices,MeshNumberofverticesEnum); 225 226 #ifdef _HAVE_ADOLC_ 227 228 /*Start trace: {{{*/ 229 this->FetchData(&keep,AutodiffKeepEnum); 230 if(keep)trace_on(1,1); 231 else trace_on(1); 232 233 /*}}}*/ 234 /*build dataset made of independent objects: {{{*/ 235 this->independent_objects=new DataSet(); 236 this->FetchData(&num_independent_objects,AutodiffNumIndependentObjectsEnum); 237 if(num_independent_objects){ 238 this->FetchData(&names,&dummy,&dummy,AutodiffIndependentObjectNamesEnum); 239 this->FetchData(&types,&dummy,&dummy,AutodiffIndependentObjectTypesEnum); 240 241 /*create independent objects, and at the same time, fetch the corresponding independent variables, 242 *and declare them as such in ADOLC: */ 243 for(i=0;i<num_independent_objects;i++){ 244 245 IndependentObject* independent_object=NULL; 246 independent_object=new IndependentObject(names[i],types[i],numberofvertices); 247 248 /*add to independent_objects dataset:*/ 249 this->independent_objects->AddObject(independent_object); 250 251 /*now go fetch the independent variable: */ 252 independent_object->FetchIndependent(this); //supply the pointer to iomodel. 253 } 254 xDelete<int>(names); 255 xDelete<int>(types); 256 } /*}}}*/ 257 258 #else 259 /*if we asked for AD computations, we have a problem!: */ 260 _error_("Cannot carry out AD mode computations without support of ADOLC compiled in!"); 261 #endif 262 } 263 else this->independent_objects=NULL; 264 197 265 } 198 266 /*}}}*/ … … 211 279 dataenum=va_arg(ap, int); 212 280 _assert_(dataenum<MaximumNumberOfEnums); 213 281 214 282 /*do not erase independent variables for the AD mode computations!: */ 215 283 if (!this->independents[dataenum]) xDelete<IssmDouble>(this->data[dataenum]); … … 227 295 void IoModel::FetchConstants(void){ 228 296 229 extern int my_rank; 230 extern int num_procs; 231 297 int my_rank; 298 232 299 /*record descriptions; */ 233 300 int record_enum; … … 238 305 int booleanint=0; 239 306 int integer=0; 240 IssmPDouble scalar=0; 307 IssmPDouble pscalar=0; 308 IssmDouble scalar=0; 241 309 char* string=NULL; 242 310 int string_size; 311 312 /*recover my_rank:*/ 313 my_rank=IssmComm::GetRank(); 243 314 244 315 /*Check that some fields have been allocated*/ … … 248 319 /*Go find in the binary file, the position of the data we want to fetch: */ 249 320 if(my_rank==0){ //cpu 0{{{ 250 321 251 322 /*First set FILE* position to the beginning of the file: */ 252 323 fseek(this->fid,0,SEEK_SET); … … 259 330 record_code=0; //0 means bailout 260 331 #ifdef _HAVE_MPI_ 261 MPI_Bcast(&record_code,1,MPI_INT,0, MPI_COMM_WORLD); /*tell others cpus we are bailing: */332 MPI_Bcast(&record_code,1,MPI_INT,0,IssmComm::GetComm()); /*tell others cpus we are bailing: */ 262 333 #endif 263 334 break; 264 335 } 265 336 else{ 266 337 267 338 /* Read the record length and the data type code: */ 268 339 fread(&record_length,sizeof(int),1,this->fid); 269 340 fread(&record_code,sizeof(int),1,this->fid); 270 341 271 342 #ifdef _HAVE_MPI_ 272 343 /*Tell other cpus what we are doing: */ 273 MPI_Bcast(&record_code,1,MPI_INT,0, MPI_COMM_WORLD); /*tell other cpus what we are going to do: */344 MPI_Bcast(&record_code,1,MPI_INT,0,IssmComm::GetComm()); /*tell other cpus what we are going to do: */ 274 345 275 346 /*Tell other cpus the name of the data, then branch according to the data type: */ 276 MPI_Bcast(&record_enum,1,MPI_INT,0, MPI_COMM_WORLD);277 MPI_Bcast(&record_length,1,MPI_INT,0, MPI_COMM_WORLD);347 MPI_Bcast(&record_enum,1,MPI_INT,0,IssmComm::GetComm()); 348 MPI_Bcast(&record_length,1,MPI_INT,0,IssmComm::GetComm()); 278 349 #endif 279 350 280 351 switch(record_code){ 281 352 case 1: … … 283 354 if(fread(&booleanint,sizeof(int),1,this->fid)!=1) _error_("could not read boolean "); 284 355 #ifdef _HAVE_MPI_ 285 MPI_Bcast(&booleanint,1,MPI_INT,0, MPI_COMM_WORLD);356 MPI_Bcast(&booleanint,1,MPI_INT,0,IssmComm::GetComm()); 286 357 #endif 287 358 … … 294 365 if(fread(&integer,sizeof(int),1,this->fid)!=1) _error_("could not read integer "); 295 366 #ifdef _HAVE_MPI_ 296 MPI_Bcast(&integer,1,MPI_INT,0, MPI_COMM_WORLD);367 MPI_Bcast(&integer,1,MPI_INT,0,IssmComm::GetComm()); 297 368 #endif 298 369 … … 302 373 break; 303 374 case 3: 304 /*Read the scalar and broadcast it to other cpus:*/ 305 if(fread(&scalar,sizeof(IssmPDouble),1,this->fid)!=1) _error_("could not read scalar "); 306 #ifdef _HAVE_MPI_ 307 MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 308 #endif 375 /*Read the scalar and broadcast it to other cpus. However, if this record has already 376 * been read in DeclareIndependents, we should not re-read it, but grab it from the iomodel->data 377 * slots: */ 378 if(this->independents[record_enum]){ 379 scalar=*(this->data[record_enum]); 380 } 381 else{ 382 if(fread(&pscalar,sizeof(IssmPDouble),1,this->fid)!=1) _error_("could not read scalar "); 383 #ifdef _HAVE_MPI_ 384 MPI_Bcast(&pscalar,1,MPI_DOUBLE,0,IssmComm::GetComm()); 385 #endif 386 scalar=reCast<IssmDouble>(pscalar); 387 } 309 388 310 389 /*create DoubleParam: */ … … 316 395 if(fread(&string_size,sizeof(int),1,this->fid)!=1) _error_("could not read length of string "); 317 396 #ifdef _HAVE_MPI_ 318 MPI_Bcast(&string_size,1,MPI_INT,0, MPI_COMM_WORLD);397 MPI_Bcast(&string_size,1,MPI_INT,0,IssmComm::GetComm()); 319 398 #endif 320 399 … … 326 405 if(fread(string,string_size*sizeof(char),1,this->fid)!=1)_error_(" could not read string "); 327 406 #ifdef _HAVE_MPI_ 328 MPI_Bcast(string,string_size,MPI_CHAR,0, MPI_COMM_WORLD);407 MPI_Bcast(string,string_size,MPI_CHAR,0,IssmComm::GetComm()); 329 408 #endif 330 409 } … … 333 412 string[0]='\0'; 334 413 } 335 414 336 415 /*Add string to parameters: */ 337 416 this->constants->AddObject(new StringParam(record_enum,string)); … … 384 463 else{ //cpu ~0 {{{ 385 464 for(;;){ //wait on cpu 0 386 MPI_Bcast(&record_code,1,MPI_INT,0, MPI_COMM_WORLD); /*get from cpu 0 what we are going to do: */465 MPI_Bcast(&record_code,1,MPI_INT,0,IssmComm::GetComm()); /*get from cpu 0 what we are going to do: */ 387 466 if(record_code==0){ 388 467 break; //we are done, break from the loop 389 468 } 390 469 else{ 391 MPI_Bcast(&record_enum,1,MPI_INT,0, MPI_COMM_WORLD); //get from cpu 0 name of the data392 MPI_Bcast(&record_length,1,MPI_INT,0, MPI_COMM_WORLD);470 MPI_Bcast(&record_enum,1,MPI_INT,0,IssmComm::GetComm()); //get from cpu 0 name of the data 471 MPI_Bcast(&record_length,1,MPI_INT,0,IssmComm::GetComm()); 393 472 switch(record_code){ 394 473 case 1: 395 474 /*boolean. get it from cpu 0 */ 396 MPI_Bcast(&booleanint,1,MPI_INT,0, MPI_COMM_WORLD);397 475 MPI_Bcast(&booleanint,1,MPI_INT,0,IssmComm::GetComm()); 476 398 477 /*create BoolParam: */ 399 478 this->constants->AddObject(new BoolParam(record_enum,(bool)booleanint)); //cast to a boolean … … 402 481 case 2: 403 482 /*integer. get it from cpu 0 */ 404 MPI_Bcast(&integer,1,MPI_INT,0, MPI_COMM_WORLD);405 483 MPI_Bcast(&integer,1,MPI_INT,0,IssmComm::GetComm()); 484 406 485 /*create IntParam: */ 407 486 this->constants->AddObject(new IntParam(record_enum,integer)); … … 410 489 case 3: 411 490 /*scalar. get it from cpu 0 */ 412 MPI_Bcast(&scalar,1,MPI_DOUBLE,0, MPI_COMM_WORLD);413 491 MPI_Bcast(&scalar,1,MPI_DOUBLE,0,IssmComm::GetComm()); 492 414 493 /*create DoubleParam: */ 415 494 this->constants->AddObject(new DoubleParam(record_enum,scalar)); … … 417 496 break; 418 497 case 4: 419 MPI_Bcast(&string_size,1,MPI_INT,0, MPI_COMM_WORLD);498 MPI_Bcast(&string_size,1,MPI_INT,0,IssmComm::GetComm()); 420 499 if(string_size){ 421 500 string=xNew<char>((string_size+1)); … … 423 502 424 503 /*Read string from cpu 0: */ 425 MPI_Bcast(string,string_size,MPI_CHAR,0, MPI_COMM_WORLD);504 MPI_Bcast(string,string_size,MPI_CHAR,0,IssmComm::GetComm()); 426 505 } 427 506 else{ … … 447 526 } 448 527 449 450 528 } 451 529 } … … 457 535 void IoModel::FetchData(bool* pboolean,int data_enum){ 458 536 459 extern int my_rank; 460 extern int num_procs; 461 537 int my_rank; 462 538 463 539 /*output: */ 464 540 int booleanint; 465 541 int code; 466 542 543 /*recover my_rank:*/ 544 my_rank=IssmComm::GetRank(); 545 467 546 /*Set file pointer to beginning of the data: */ 468 547 fid=this->SetFilePointerToData(&code,NULL,data_enum); 469 548 470 549 if(code!=1)_error_("expecting a boolean for enum " << EnumToStringx(data_enum)); 471 550 472 551 /*We have to read a boolean from disk. */ 473 552 if(my_rank==0){ … … 475 554 } 476 555 #ifdef _HAVE_MPI_ 477 MPI_Bcast(&booleanint,1,MPI_INT,0, MPI_COMM_WORLD);556 MPI_Bcast(&booleanint,1,MPI_INT,0,IssmComm::GetComm()); 478 557 #endif 479 558 … … 487 566 void IoModel::FetchData(int* pinteger,int data_enum){ 488 567 489 extern int my_rank; 490 extern int num_procs; 568 int my_rank; 491 569 492 570 /*output: */ 493 571 int integer; 494 572 int code; 495 573 574 /*recover my_rank:*/ 575 my_rank=IssmComm::GetRank(); 576 496 577 /*Set file pointer to beginning of the data: */ 497 578 fid=this->SetFilePointerToData(&code,NULL,data_enum); 498 579 499 580 if(code!=2)_error_("expecting an integer for enum " << EnumToStringx(data_enum)); 500 581 501 582 /*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */ 502 583 if(my_rank==0){ … … 505 586 506 587 #ifdef _HAVE_MPI_ 507 MPI_Bcast(&integer,1,MPI_INT,0, MPI_COMM_WORLD);588 MPI_Bcast(&integer,1,MPI_INT,0,IssmComm::GetComm()); 508 589 #endif 509 590 … … 515 596 void IoModel::FetchData(IssmDouble* pscalar,int data_enum){ 516 597 517 518 extern int my_rank; 519 extern int num_procs; 520 598 int my_rank; 521 599 522 600 /*output: */ … … 524 602 int code; 525 603 604 /*recover my_rank:*/ 605 my_rank=IssmComm::GetRank(); 606 526 607 /*Set file pointer to beginning of the data: */ 527 608 fid=this->SetFilePointerToData(&code,NULL,data_enum); 528 609 529 610 if(code!=3)_error_("expecting a IssmDouble for enum " << EnumToStringx(data_enum)); 530 611 531 612 /*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */ 532 613 if(my_rank==0){ … … 534 615 } 535 616 #ifdef _HAVE_MPI_ 536 MPI_Bcast(&scalar,1,MPI_DOUBLE,0, MPI_COMM_WORLD);617 MPI_Bcast(&scalar,1,MPI_DOUBLE,0,IssmComm::GetComm()); 537 618 #endif 538 619 539 620 /*Assign output pointers: */ 540 621 *pscalar=scalar; 541 622 542 623 } 543 624 /*}}}*/ … … 545 626 void IoModel::FetchData(char** pstring,int data_enum){ 546 627 547 extern int my_rank; 548 extern int num_procs; 549 628 int my_rank; 550 629 551 630 /*output: */ … … 554 633 int code=0; 555 634 635 /*recover my_rank:*/ 636 my_rank=IssmComm::GetRank(); 637 556 638 /*Set file pointer to beginning of the data: */ 557 639 fid=this->SetFilePointerToData(&code,NULL,data_enum); 558 640 559 641 if(code!=4)_error_("expecting a string for enum " << EnumToStringx(data_enum)); 560 642 561 643 /*Now fetch: */ 562 644 563 645 /*We have to read a string from disk. First read the dimensions of the string, then the string: */ 564 646 if(my_rank==0){ … … 567 649 568 650 #ifdef _HAVE_MPI_ 569 MPI_Bcast(&string_size,1,MPI_INT,0, MPI_COMM_WORLD);651 MPI_Bcast(&string_size,1,MPI_INT,0,IssmComm::GetComm()); 570 652 #endif 571 653 … … 580 662 } 581 663 #ifdef _HAVE_MPI_ 582 MPI_Bcast(string,string_size,MPI_CHAR,0, MPI_COMM_WORLD);664 MPI_Bcast(string,string_size,MPI_CHAR,0,IssmComm::GetComm()); 583 665 #endif 584 666 } … … 588 670 } 589 671 590 591 672 /*Assign output pointers: */ 592 673 *pstring=string; … … 596 677 void IoModel::FetchData(int** pmatrix,int* pM,int* pN,int data_enum){ 597 678 598 extern int my_rank; 599 extern int num_procs; 679 int my_rank; 600 680 int i,j; 601 681 … … 607 687 int vector_type=0; 608 688 689 /*recover my_rank:*/ 690 my_rank=IssmComm::GetRank(); 609 691 610 692 /*Set file pointer to beginning of the data: */ … … 612 694 613 695 if((code!=5) && (code!=6) && (code!=7))_error_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(data_enum)); 614 696 615 697 /*Now fetch: */ 616 698 … … 622 704 623 705 #ifdef _HAVE_MPI_ 624 MPI_Bcast(&M,1,MPI_INT,0, MPI_COMM_WORLD);706 MPI_Bcast(&M,1,MPI_INT,0,IssmComm::GetComm()); 625 707 #endif 626 708 … … 629 711 } 630 712 #ifdef _HAVE_MPI_ 631 MPI_Bcast(&N,1,MPI_INT,0, MPI_COMM_WORLD);713 MPI_Bcast(&N,1,MPI_INT,0,IssmComm::GetComm()); 632 714 #endif 633 715 … … 640 722 if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 641 723 } 642 724 643 725 #ifdef _HAVE_MPI_ 644 MPI_Bcast(matrix,M*N,MPI_DOUBLE,0, MPI_COMM_WORLD);726 MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,IssmComm::GetComm()); 645 727 #endif 646 728 } … … 671 753 void IoModel::FetchData(IssmDouble** pmatrix,int* pM,int* pN,int data_enum){ 672 754 673 extern int my_rank; 674 extern int num_procs; 755 int my_rank; 675 756 676 757 /*output: */ … … 680 761 int vector_type=0; 681 762 763 /*recover my_rank:*/ 764 my_rank=IssmComm::GetRank(); 765 682 766 /*Set file pointer to beginning of the data: */ 683 767 fid=this->SetFilePointerToData(&code,&vector_type,data_enum); 684 768 if((code!=5) && (code!=6) && (code!=7))_error_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(data_enum)); 685 769 686 770 /*Now fetch: */ 687 771 … … 692 776 } 693 777 #ifdef _HAVE_MPI_ 694 MPI_Bcast(&M,1,MPI_INT,0, MPI_COMM_WORLD);778 MPI_Bcast(&M,1,MPI_INT,0,IssmComm::GetComm()); 695 779 #endif 696 780 … … 699 783 } 700 784 #ifdef _HAVE_MPI_ 701 MPI_Bcast(&N,1,MPI_INT,0, MPI_COMM_WORLD);785 MPI_Bcast(&N,1,MPI_INT,0,IssmComm::GetComm()); 702 786 #endif 703 787 … … 711 795 } 712 796 #ifdef _HAVE_MPI_ 713 MPI_Bcast(matrix,M*N,MPI_DOUBLE,0, MPI_COMM_WORLD);797 MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,IssmComm::GetComm()); 714 798 #endif 715 799 … … 736 820 void IoModel::FetchData(char*** pstrings,int* pnumstrings,int data_enum){ 737 821 738 extern int my_rank; 739 extern int num_procs; 740 822 int my_rank; 823 741 824 int i; 742 825 … … 744 827 int numstrings=0; 745 828 char** strings=NULL; 746 829 747 830 /*intermediary: */ 748 831 char* string=NULL; 749 832 int string_size; 750 833 int code; 751 834 835 /*recover my_rank:*/ 836 my_rank=IssmComm::GetRank(); 837 752 838 /*Set file pointer to beginning of the data: */ 753 839 fid=this->SetFilePointerToData(&code,NULL,data_enum); 754 840 755 841 if(code!=9)_error_("expecting a string array for enum " << EnumToStringx(data_enum)); 756 842 757 843 /*We have to read a bunch of strings from disk. First read the number of strings, and allocate: */ 758 844 if(my_rank==0){ … … 760 846 } 761 847 #ifdef _HAVE_MPI_ 762 MPI_Bcast(&numstrings,1,MPI_INT,0, MPI_COMM_WORLD);848 MPI_Bcast(&numstrings,1,MPI_INT,0,IssmComm::GetComm()); 763 849 #endif 764 850 … … 770 856 /*Go through strings, and read: */ 771 857 for(i=0;i<numstrings;i++){ 772 858 773 859 if(my_rank==0){ 774 860 if(fread(&string_size,sizeof(int),1,fid)!=1) _error_("could not read length of string "); 775 861 } 776 862 #ifdef _HAVE_MPI_ 777 MPI_Bcast(&string_size,1,MPI_INT,0, MPI_COMM_WORLD);863 MPI_Bcast(&string_size,1,MPI_INT,0,IssmComm::GetComm()); 778 864 #endif 779 865 if(string_size){ … … 786 872 } 787 873 #ifdef _HAVE_MPI_ 788 MPI_Bcast(string,string_size,MPI_CHAR,0, MPI_COMM_WORLD);874 MPI_Bcast(string,string_size,MPI_CHAR,0,IssmComm::GetComm()); 789 875 #endif 790 876 } … … 808 894 int i; 809 895 810 extern int my_rank; 811 extern int num_procs; 896 int my_rank; 812 897 813 898 /*output: */ … … 821 906 IssmPDouble *matrix = NULL; 822 907 int code; 823 908 909 /*recover my_rank:*/ 910 my_rank=IssmComm::GetRank(); 911 824 912 /*Set file pointer to beginning of the data: */ 825 913 fid=this->SetFilePointerToData(&code,NULL,data_enum); 826 914 if(code!=8)_error_("expecting a IssmDouble mat array for enum " << EnumToStringx(data_enum)); 827 915 828 916 /*Now fetch: */ 829 917 if(my_rank==0){ … … 831 919 } 832 920 #ifdef _HAVE_MPI_ 833 MPI_Bcast(&numrecords,1,MPI_INT,0, MPI_COMM_WORLD);921 MPI_Bcast(&numrecords,1,MPI_INT,0,IssmComm::GetComm()); 834 922 #endif 835 923 … … 854 942 } 855 943 #ifdef _HAVE_MPI_ 856 MPI_Bcast(&M,1,MPI_INT,0, MPI_COMM_WORLD);944 MPI_Bcast(&M,1,MPI_INT,0,IssmComm::GetComm()); 857 945 #endif 858 946 … … 861 949 } 862 950 #ifdef _HAVE_MPI_ 863 MPI_Bcast(&N,1,MPI_INT,0, MPI_COMM_WORLD);951 MPI_Bcast(&N,1,MPI_INT,0,IssmComm::GetComm()); 864 952 #endif 865 953 … … 874 962 875 963 #ifdef _HAVE_MPI_ 876 MPI_Bcast(matrix,M*N,MPI_DOUBLE,0, MPI_COMM_WORLD);964 MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,IssmComm::GetComm()); 877 965 #endif 878 966 matrices[i]=xNew<IssmDouble>(M*N); … … 897 985 /*FUNCTION IoModel::FetchData(Option** poption,int data_enum){{{*/ 898 986 void IoModel::FetchData(Option** poption,int index){ 899 900 extern int my_rank;901 extern int num_procs;902 987 903 988 /*output: */ … … 955 1040 /*Go through the entire list of enums and fetch the corresponding data. Add it to the iomodel->data dataset. Everything 956 1041 *we fetch is a IssmDouble* : */ 957 1042 958 1043 va_start(ap,num); 959 1044 for(i=0; i<num; i++){ 960 1045 961 1046 dataenum=va_arg(ap, int); 962 1047 963 1048 if (this->independents[dataenum]){ 964 1049 /*this data has already been checked out! Continue: */ … … 996 1081 int vector_layout = 0; 997 1082 int counter; 998 int nods;999 int nel;1000 1083 int numberofelements; 1001 1002 1084 1003 1085 /*variables being fetched: */ … … 1023 1105 for (i=0;i<numberofelements;i++){ 1024 1106 if(this->my_elements[i]){ 1025 Element* element= (Element*)elements->GetObjectByOffset(counter);1107 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(counter)); 1026 1108 element->InputCreate((IssmDouble)boolean,vector_enum,code); 1027 1109 counter++; … … 1036 1118 for (i=0;i<numberofelements;i++){ 1037 1119 if(this->my_elements[i]){ 1038 Element* element= (Element*)elements->GetObjectByOffset(counter);1120 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(counter)); 1039 1121 element->InputCreate((IssmDouble)integer,vector_enum,code); 1040 1122 counter++; … … 1049 1131 for (i=0;i<numberofelements;i++){ 1050 1132 if(this->my_elements[i]){ 1051 Element* element= (Element*)elements->GetObjectByOffset(counter);1133 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(counter)); 1052 1134 element->InputCreate(scalar,vector_enum,code); 1053 1135 counter++; … … 1086 1168 for (i=0;i<numberofelements;i++){ 1087 1169 if(this->my_elements[i]){ 1088 Element* element= (Element*)elements->GetObjectByOffset(counter);1170 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(counter)); 1089 1171 if(defaulting) element->InputCreate(default_value,vector_enum,code); 1090 1172 else element->InputCreate(IssmDoublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements. … … 1124 1206 for (i=0;i<numberofelements;i++){ 1125 1207 if(this->my_elements[i]){ 1126 Element* element= (Element*)elements->GetObjectByOffset(counter);1208 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(counter)); 1127 1209 if(defaulting) element->InputCreate(default_value,vector_enum,code); 1128 1210 else element->InputCreate(IssmDoublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements. … … 1162 1244 for (i=0;i<numberofelements;i++){ 1163 1245 if(this->my_elements[i]){ 1164 Element* element= (Element*)elements->GetObjectByOffset(counter);1246 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(counter)); 1165 1247 if(defaulting) element->InputCreate(default_value,vector_enum,code); 1166 1248 else element->InputCreate(IssmDoublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements. … … 1183 1265 void IoModel::LastIndex(int *pindex){ 1184 1266 1185 externint my_rank;1267 int my_rank; 1186 1268 int lastindex,index; 1187 1269 int record_length; 1270 1271 /*recover my_rank:*/ 1272 my_rank=IssmComm::GetRank(); 1188 1273 1189 1274 /*Go find in the binary file, the position of the data we want to fetch: */ … … 1209 1294 /*Broadcast code and vector type: */ 1210 1295 #ifdef _HAVE_MPI_ 1211 MPI_Bcast(&lastindex,1,MPI_INT,0, MPI_COMM_WORLD);1296 MPI_Bcast(&lastindex,1,MPI_INT,0,IssmComm::GetComm()); 1212 1297 #endif 1213 1298 … … 1219 1304 FILE* IoModel::SetFilePointerToData(int* pcode,int* pvector_type, int data_enum){ 1220 1305 1221 extern int my_rank; 1222 extern int num_procs; 1223 1224 int found=0; 1306 int my_rank; 1307 1308 int found = 0; 1225 1309 int record_enum; 1226 1310 int record_length; 1227 int record_code; //1 to 7 number 1228 int vector_type; //nodal or elementary 1311 int record_code; //1 to 7 number 1312 int vector_type = 0; //nodal or elementary 1313 1314 /*recover my_rank:*/ 1315 my_rank=IssmComm::GetRank(); 1229 1316 1230 1317 /*Go find in the binary file, the position of the data we want to fetch: */ … … 1262 1349 } 1263 1350 } 1264 #ifdef _HAVE_MPI_1265 MPI_Bcast(&found,1,MPI_INT,0, MPI_COMM_WORLD);1266 if(!found)_error_("could not find data with name " << " " << EnumToStringx(data_enum) << "");1267 #endif1351 #ifdef _HAVE_MPI_ 1352 MPI_Bcast(&found,1,MPI_INT,0,IssmComm::GetComm()); 1353 if(!found)_error_("could not find data with name " << EnumToStringx(data_enum) << " in binary file"); 1354 #endif 1268 1355 1269 1356 /*Broadcast code and vector type: */ 1270 #ifdef _HAVE_MPI_1271 MPI_Bcast(&record_code,1,MPI_INT,0, MPI_COMM_WORLD);1272 MPI_Bcast(&vector_type,1,MPI_INT,0, MPI_COMM_WORLD);1273 if(record_code==5) MPI_Bcast(&vector_type,1,MPI_INT,0, MPI_COMM_WORLD);1274 #endif1357 #ifdef _HAVE_MPI_ 1358 MPI_Bcast(&record_code,1,MPI_INT,0,IssmComm::GetComm()); 1359 MPI_Bcast(&vector_type,1,MPI_INT,0,IssmComm::GetComm()); 1360 if(record_code==5) MPI_Bcast(&vector_type,1,MPI_INT,0,IssmComm::GetComm()); 1361 #endif 1275 1362 1276 1363 /*Assign output pointers:*/ … … 1281 1368 } 1282 1369 /*}}}*/ 1283 /*FUNCTION IoModel::DeclareIndependents{{{*/1284 void IoModel::DeclareIndependents(void){1285 1286 bool autodiff=false;1287 int dummy;1288 int i;1289 int num_independents;1290 int* independents=NULL;1291 1292 #ifdef _HAVE_ADOLC_1293 /*recover independent enums: */1294 this->Constant(&num_independents,AutodiffNumIndependentsEnum);1295 if(num_independents){1296 this->FetchData(&independents,&dummy,&dummy,AutodiffIndependentsEnum);1297 1298 /*now go fetch the independent variables for each independent enum: */1299 for(i=0;i<num_independents;i++){1300 this->FetchIndependent(independents[i]);1301 }1302 xDelete<int>(independents);1303 }1304 #else1305 /*if we asked for AD computations, we have a problem!: */1306 this->Constant(&autodiff,AutodiffIsautodiffEnum);1307 if(autodiff)_error_("Cannot carry out AD mode computations without support of ADOLC compiled in!");1308 #endif1309 1310 }1311 /*}}}*/1312 /*FUNCTION IoModel::FetchIndependent{{{*/1313 void IoModel::FetchIndependent(int independent_enum){1314 1315 #ifdef _HAVE_ADOLC_ //cannot come here unless you are running AD mode, from DeclaredIndependents:1316 extern int my_rank;1317 extern int num_procs;1318 1319 /*output: */1320 int M,N;1321 IssmPDouble* buffer=NULL; //a buffer to read the data from disk1322 IssmDouble* matrix=NULL; //our independent variable1323 int code=0;1324 int vector_type=0;1325 1326 /*Set file pointer to beginning of the data: */1327 fid=this->SetFilePointerToData(&code,&vector_type,independent_enum);1328 if((code!=5) && (code!=6) && (code!=7))_error_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(independent_enum));1329 1330 /*Now fetch: */1331 1332 /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */1333 /*numberofelements: */1334 if(my_rank==0){1335 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");1336 }1337 #ifdef _HAVE_MPI_1338 MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD);1339 #endif1340 1341 if(my_rank==0){1342 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");1343 }1344 #ifdef _HAVE_MPI_1345 MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD);1346 #endif1347 1348 /*Now allocate matrix: */1349 if(M*N){1350 buffer=xNew<IssmPDouble>(M*N);1351 matrix=xNew<IssmDouble>(M*N);1352 1353 /*Read matrix on node 0, then broadcast: */1354 if(my_rank==0){1355 if(fread(buffer,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix ");1356 1357 /*Now, before we even broadcast this to other nodes, declare the whole matrix as a independent variable!: */1358 for (int i=0;i<M*N;++i) matrix[i]<<=buffer[i]; /*we use the <<= ADOLC overloaded operator to declare the independency*/1359 }1360 #ifdef _HAVE_MPI_1361 MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD);1362 #endif1363 1364 xDelete<IssmPDouble>(buffer);1365 }1366 else _error_("cannot declare the independent variable " << EnumToStringx(independent_enum) << "if it's empty!");1367 1368 /*Ok, we are almost done. Matrix is now a independent matrix. We don't want this matrix to be fetched again in the1369 *future, which would effectively write over the independency in the ADOLC tape! So we are going to keep track of this1370 independent matrix inthe iomodel->data[independent_enum] data slot: */1371 this->data[independent_enum]=matrix;1372 this->independents[independent_enum]=true;1373 #endif1374 }1375 /*}}}*/ -
issm/trunk/src/c/classes/IoModel.h
r13395 r13975 19 19 20 20 private: 21 Parameters *constants; //this dataset holds all IssmDouble, int, bool and char *parameters read in from the input file.*22 21 Parameters *constants; //this dataset holds all IssmDouble, int, bool and char from input 22 23 23 public: 24 IssmDouble **data; 25 24 IssmDouble **data; //this dataset holds temporary data, memory intensive. 25 26 26 /*This data needs to stay memory resident at all time, even if it's memory intensive: */ 27 FILE *fid; //pointer to input file27 FILE *fid; //pointer to input file 28 28 bool *my_elements; 29 29 bool *my_nodes; … … 36 36 int loadcounter; //keep track of how many loads are being created in each analysis type 37 37 int constraintcounter; //keep track of how many constraints are being created in each analysis type 38 38 39 39 /*for AD mode: to keep track of our independent variables we fetch:*/ 40 40 bool* independents; 41 DataSet* independent_objects; 41 42 42 43 /*Methods*/ -
issm/trunk/src/c/classes/Patch.cpp
r13395 r13975 3 3 */ 4 4 5 /*Include files : {{{*/5 /*Include files */ 6 6 #ifdef HAVE_CONFIG_H 7 7 #include <config.h> … … 19 19 #include "../shared/shared.h" 20 20 #include "../include/include.h" 21 /*}}}*/22 21 23 22 /*Object constructors and destructors:*/ 24 23 /*FUNCTION Patch::Patch() default constructor {{{*/ 25 24 Patch::Patch(){ 26 this->numrows =0;27 this->numcols =0;28 this->maxvertices =0;29 this->maxnodes =0;30 this->values =NULL;25 this->numrows = 0; 26 this->numcols = 0; 27 this->maxvertices = 0; 28 this->maxnodes = 0; 29 this->values = NULL; 31 30 } 32 31 /*}}}*/ … … 34 33 Patch::Patch(int in_numrows, int in_maxvertices, int in_maxnodes){ 35 34 36 int i,j;37 35 this->numrows=in_numrows; 38 36 this->maxvertices=in_maxvertices; 39 37 this->maxnodes=in_maxnodes; 40 41 38 this->numcols=1 //enum_type 42 39 +1 //step … … 52 49 } 53 50 else{ 54 55 for(i =0;i<this->numrows;i++){56 for( j=0;j<this->numcols;j++){51 this->values=xNew<IssmDouble>(this->numcols*this->numrows); 52 for(int i=0;i<this->numrows;i++){ 53 for(int j=0;j<this->numcols;j++){ 57 54 this->values[i*this->numcols+j]=NAN; 58 55 } … … 98 95 99 96 /*Let's remember what is on a row: 100 enum_type step time element_id interpolation vertices_ids nodal_values 101 */ 97 enum_type step time element_id interpolation vertices_ids nodal_values */ 102 98 row[0]=enum_type; 103 99 row[1]=(IssmDouble)step; … … 113 109 void Patch::Gather(void){ 114 110 115 int i;116 111 int count; 117 extern intmy_rank;118 extern intnum_procs;112 int my_rank; 113 int num_procs; 119 114 int total_numrows; 120 115 int node_numrows; … … 124 119 #endif 125 120 121 /*recover my_rank:*/ 122 my_rank=IssmComm::GetRank(); 123 num_procs=IssmComm::GetSize(); 124 126 125 /*First, figure out total number of rows combining all the cpus: */ 127 126 #ifdef _HAVE_MPI_ 128 MPI_Reduce(&this->numrows,&total_numrows,1,MPI_INT,MPI_SUM,0, MPI_COMM_WORLD);129 MPI_Bcast(&total_numrows,1,MPI_INT,0, MPI_COMM_WORLD);127 MPI_Reduce(&this->numrows,&total_numrows,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() ); 128 MPI_Bcast(&total_numrows,1,MPI_INT,0,IssmComm::GetComm()); 130 129 #else 131 130 total_numrows=this->numrows; … … 147 146 /*Now, ask other nodes to send their values: */ 148 147 #ifdef _HAVE_MPI_ 149 for (i=1;i<num_procs;i++){148 for(int i=1;i<num_procs;i++){ 150 149 if (my_rank==i){ 151 MPI_Send(&this->numrows,1,MPI_INT,0,1, MPI_COMM_WORLD);152 if (this->numrows)MPI_Send(this->values,this->numrows*this->numcols,MPI_DOUBLE,0,1, MPI_COMM_WORLD);150 MPI_Send(&this->numrows,1,MPI_INT,0,1,IssmComm::GetComm()); 151 if (this->numrows)MPI_Send(this->values,this->numrows*this->numcols,MPI_DOUBLE,0,1,IssmComm::GetComm()); 153 152 } 154 153 if (my_rank==0){ 155 MPI_Recv(&node_numrows,1,MPI_INT,i,1, MPI_COMM_WORLD,&status);156 if (node_numrows)MPI_Recv(total_values+count,node_numrows*this->numcols,MPI_DOUBLE,i,1, MPI_COMM_WORLD,&status);154 MPI_Recv(&node_numrows,1,MPI_INT,i,1,IssmComm::GetComm(),&status); 155 if (node_numrows)MPI_Recv(total_values+count,node_numrows*this->numcols,MPI_DOUBLE,i,1,IssmComm::GetComm(),&status); 157 156 count+=node_numrows*this->numcols; 158 157 } -
issm/trunk/src/c/classes/Patch.h
r13395 r13975 4 4 5 5 /*A Patch object is used to store all results held in elements, in a serial way, and to dump them to disk. 6 6 7 7 Each row of the Patch object is made of the following information: 8 8 - the result enum_type, … … 12 12 - the vertices ids, 13 13 - and the values at the nodes (could be different from the vertices). 14 14 15 15 For ex: 16 16 1. on a Beam element, Vx, at step 1, time .5, element id 1, interpolation type P0 (constant), vertices ids 1 and 2, one constant value 4.5 … … 19 19 VzEnum 2 .8 2 P1 1 3 4 4.5 3.2 2.5 20 20 */ 21 22 21 23 22 #ifndef _PATCH_H_ … … 29 28 public: 30 29 31 int numrows; //number of results held in Patch object 32 int numcols; //number of columns 33 int maxvertices; //maxvertices corresponds to largest amount of vertices on a given element, determined by the geometry. 34 int maxnodes; // maxnodes corresponds to the largest amout of nodes on a given element, determined by the interpolation type. 35 36 IssmDouble* values; //result values 30 int numrows; //number of results held in Patch object 31 int numcols; //number of columns 32 int maxvertices; //largest amount of vertices on a given element, determined by geometry 33 int maxnodes; //the largest amout of nodes on a given element, determined by interpolation 34 IssmDouble *values; //result values 37 35 38 36 Patch(); -
issm/trunk/src/c/classes/Update.h
r13395 r13975 7 7 8 8 /*Headers:*/ 9 /*{{{*/10 9 #include "../shared/shared.h" 11 /*}}}*/ 10 class IoModel; 12 11 13 12 class Update{ … … 33 32 34 33 #endif //ifndef _UPDATE_H_ 35 -
issm/trunk/src/c/classes/bamg/AdjacentTriangle.cpp
r13395 r13975 8 8 9 9 namespace bamg { 10 11 10 12 11 /*Constructors/Destructors*/ -
issm/trunk/src/c/classes/bamg/AdjacentTriangle.h
r13395 r13975 44 44 } 45 45 #endif 46 -
issm/trunk/src/c/classes/bamg/BamgGeom.cpp
r13395 r13975 1 1 #include <stdio.h> 2 #include "../objects .h"2 #include "../objects/objects.h" 3 3 #include "../../io/io.h" 4 4 #include "../../shared/shared.h" -
issm/trunk/src/c/classes/bamg/BamgMesh.cpp
r13395 r13975 1 1 #include <stdio.h> 2 #include "../objects .h"2 #include "../objects/objects.h" 3 3 #include "../../io/io.h" 4 4 #include "../../shared/shared.h" -
issm/trunk/src/c/classes/bamg/BamgOpts.cpp
r13395 r13975 2 2 #include "../../shared/shared.h" 3 3 #include "../../include/include.h" 4 #include "../objects .h"4 #include "../objects/objects.h" 5 5 #include "../../io/io.h" 6 6 -
issm/trunk/src/c/classes/bamg/BamgQuadtree.cpp
r13395 r13975 3 3 #include <stdlib.h> 4 4 5 #include "../objects .h"5 #include "../objects/objects.h" 6 6 7 7 namespace bamg { … … 428 428 } 429 429 430 431 430 if ( n0 > 0) 432 431 { -
issm/trunk/src/c/classes/bamg/BamgQuadtree.h
r13395 r13975 34 34 void DeepEcho() {_error_("not implemented yet"); }; 35 35 int Id() {_error_("not implemented yet"); }; 36 int MyRank() {_error_("not implemented yet"); };37 36 int ObjectEnum() {_error_("not implemented yet"); }; 38 37 Object *copy() {_error_("not implemented yet"); }; -
issm/trunk/src/c/classes/bamg/BamgVertex.cpp
r13395 r13975 4 4 #include <ctime> 5 5 6 #include "../objects .h"6 #include "../objects/objects.h" 7 7 8 8 namespace bamg { -
issm/trunk/src/c/classes/bamg/Direction.h
r13395 r13975 19 19 } 20 20 #endif 21 -
issm/trunk/src/c/classes/bamg/Edge.h
r13395 r13975 12 12 //classes 13 13 class Mesh; 14 14 15 15 class Edge { 16 16 … … 36 36 } 37 37 #endif 38 -
issm/trunk/src/c/classes/bamg/EigenMetric.cpp
r13395 r13975 29 29 b=-a11-a22; 30 30 delta=b*b - 4*(a11*a22-a21*a21); 31 32 31 33 32 /*Compute norm of M to avoid round off errors*/ -
issm/trunk/src/c/classes/bamg/Geometry.cpp
r13395 r13975 4 4 #include <ctime> 5 5 6 #include "../objects .h"6 #include "../objects/objects.h" 7 7 #include "../../include/include.h" 8 8 #include "../../shared/Exceptions/exceptions.h" … … 68 68 69 69 double Hmin = HUGE_VAL;// the infinie value 70 int i,j, k,n,i0,i1,i2,i3;70 int i,j,n,i0,i1,i2,i3; 71 71 72 72 /*initialize some variables*/ … … 173 173 } 174 174 delete [] verticeslength; 175 175 176 176 } 177 177 else{ … … 499 499 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/AfterRead)*/ 500 500 501 long i,j,k; 502 int jj; 503 long *head_v = new long[nbv]; 504 long *next_p = new long[2*nbe]; 505 float *eangle = new float[nbe]; 506 double eps = 1e-20; 507 BamgQuadtree quadtree; // build quadtree to find duplicates 508 BamgVertex *v0 = vertices; 509 GeomVertex *v0g = (GeomVertex*) (void*)v0; 501 long i ,j,k; 502 long *head_v = new long[nbv]; 503 long *next_p = new long[2 *nbe]; 504 float *eangle = new float[nbe]; 505 double eps = 1e-20; 506 BamgQuadtree quadtree; // build quadtree to find duplicates 507 BamgVertex *v0 = vertices; 510 508 511 509 k=0; … … 869 867 directionge[bge]=1; 870 868 871 while 869 while(eg0!=(GeomEdge*)vg0 && (*eg0)(direction0)!=(GeomVertex*)vg0){ 872 870 if (bge<=0) { 873 871 if(NbTry) { … … 904 902 _assert_(tge>=0 && tge<=mxe); 905 903 } 906 907 904 908 905 if ((*eg0)(direction0)==(GeomVertex*)vg0) -
issm/trunk/src/c/classes/bamg/Geometry.h
r13395 r13975 64 64 void WriteGeometry(BamgGeom *bamggeom, BamgOpts*bamgopts); 65 65 }; 66 66 67 67 } 68 68 #endif -
issm/trunk/src/c/classes/bamg/ListofIntersectionTriangles.cpp
r13395 r13975 4 4 #include <ctime> 5 5 6 #include "../objects .h"6 #include "../objects/objects.h" 7 7 8 8 namespace bamg { … … 319 319 ilast=NewItem(t,ba[0],ba[1],ba[2]); } 320 320 } // outside departure 321 322 323 321 324 322 // recherche the intersection of [a,b] with Bh Mesh. … … 392 390 Icoor2 detbij = bamg::det((*t)[i],(*t)[j],b); 393 391 394 395 392 if (detbij >= 0) { //we find the triangle contening b 396 393 dt[0]=bamg::det((*t)[1],(*t)[2],b); -
issm/trunk/src/c/classes/bamg/Mesh.cpp
r13395 r13975 4 4 #include <ctime> 5 5 6 #include "../objects .h"6 #include "../objects/objects.h" 7 7 8 8 namespace bamg { … … 201 201 } 202 202 203 204 203 if(nbe) 205 204 edges = new Edge[nbe]; … … 270 269 double Hmin = HUGE_VAL;// the infinie value 271 270 long i1,i2,i3; 272 long i ,j;271 long i; 273 272 Metric M1(1); 274 273 int verbose=0; … … 386 385 if(bamgmesh->Quadrilaterals){ 387 386 if(verbose>5) _printLine_(" processing Quadrilaterals"); 388 long i1,i2,i3,i4 ,iref;387 long i1,i2,i3,i4; 389 388 triangles =new Triangle[nbt]; 390 389 for (i=0;i<bamgmesh->QuadrilateralsSize[0];i++){ … … 1009 1008 1010 1009 /*Intermediary*/ 1011 int i,k,num; 1012 int verbose=0; 1010 int i,k; 1013 1011 1014 1012 /*output*/ 1015 1013 int* index=NULL; 1014 int num=0; 1016 1015 1017 1016 /*Get number of triangles*/ … … 1024 1023 if (k){ 1025 1024 index=xNew<int>(3*k); 1026 num=0;1027 1025 for (i=0;i<nbt;i++){ 1028 1026 Triangle &t=triangles[i]; … … 1245 1243 tt[2]->SetSingleVertexToTriangleConnectivity(); 1246 1244 1247 1248 1245 // swap if the point s is on a edge 1249 1246 if(izerodet>=0) { … … 1574 1571 //initialize subdomains[isd].head as 0 1575 1572 for (isd=0;isd<nbsubdomains;isd++) subdomains[isd].head =0; 1576 1573 1577 1574 k=0; 1578 1575 for (it=0;it<nbt;it++){ … … 2539 2536 delete [] HeapArete; 2540 2537 delete [] HeapTriangle; 2541 2542 2538 2543 2539 if (OutSide|| !Gh.subdomains || !Gh.nbsubdomains ) … … 2695 2691 nbsubdomains=inew;} 2696 2692 2697 2698 2693 for (it=0;it<nbt;it++) 2699 2694 if ( mark[it] ==-1 ) … … 3075 3070 if (verbose>5) _printLine_(" do nothing: costheta > 1"); 3076 3071 } 3077 3078 3072 3079 3073 long nbqq = (nbt*3)/2; … … 4273 4267 newedges[ie].adj[1]=newedges + ie +1; 4274 4268 R2 A = edges[i][0],B = edges[i][1]; 4275 4276 4269 4277 4270 kk += (i == edge4->SortAndAdd(GetId(edges[i][0]),GetId(edges[i][1]))); … … 4343 4336 nbv = k; 4344 4337 4345 4346 4338 kedge = new long[3*nbt+1]; 4347 4339 ksplitarray = new long[nbt+1]; … … 4412 4404 const Triangle & tt = ta; 4413 4405 4414 4415 4406 const BamgVertex & v0 = t[VerticesOfTriangularEdge[j][0]]; 4416 4407 const BamgVertex & v1 = t[VerticesOfTriangularEdge[j][1]]; … … 4648 4639 BTh.vertices[i].m = BTh.vertices[i].m*2.; 4649 4640 4650 4651 4641 ret = 2; 4652 4642 if (nbt>= maxnbt) goto Error; // bug … … 4963 4953 4964 4954 /*Intermediaries*/ 4965 int i, j,k;4955 int i,k; 4966 4956 int nbcurves = 0; 4967 4957 int NbNewPoints,NbEdgeCurve; … … 5001 4991 _assert_(nbv<maxnbv); 5002 4992 vertices[nbv]=Gh[i]; 5003 4993 5004 4994 //Add pointer from geometry (Gh) to vertex from mesh (Th) 5005 4995 Gh[i].MeshVertexHook=vertices+nbv; … … 5196 5186 va = vb; 5197 5187 } 5198 5188 5199 5189 /*We just added one edge to the curve: Go to the next one*/ 5200 5190 lcurve = lcurveb; … … 5371 5361 /*Get curve number*/ 5372 5362 int nc=ei.GeomEdgeHook->CurveNumber; 5373 5363 5374 5364 //_printLine_("Dealing with curve number " << nc); 5375 5365 //_printLine_("edge on geometry is same as GhCurve? " << (ei.GeomEdgeHook==Gh.curves[nc].FirstEdge || ei.GeomEdgeHook==Gh.curves[nc].LastEdge)?"yes":"no"); … … 5419 5409 /*Get edge of Bth with index iedge*/ 5420 5410 Edge &ei = BTh.edges[iedge]; 5421 5411 5422 5412 /*Initialize variables*/ 5423 5413 double Lstep=0,Lcurve=0; // step between two points (phase==1) … … 5536 5526 }// for(;;) end of the curve 5537 5527 } 5538 5539 5528 5540 5529 if (phase){ // construction of the last edge … … 5787 5776 BamgVertex & s2= (*t2)[OppositeVertex[a2]]; 5788 5777 5789 5790 5778 Icoor2 dets2 = det(*pva,*pvb,s2); 5791 5779 Icoor2 det1=t1->det , det2=t2->det ; -
issm/trunk/src/c/classes/bamg/Metric.cpp
r13395 r13975 16 16 /*FUNCTION Metric::Metric(double a){{{*/ 17 17 Metric::Metric(double a): a11(1/(a*a)),a21(0),a22(1/(a*a)){ 18 18 19 19 }/*}}}*/ 20 20 /*FUNCTION Metric::Metric(double a,double b,double c){{{*/ 21 21 Metric::Metric(double a,double b,double c) :a11(a),a21(b),a22(c){ 22 22 23 23 }/*}}}*/ 24 24 /*FUNCTION Metric::Metric(const double a[3],const Metric& m0, const Metric& m1,const Metric& m2 ){{{*/ -
issm/trunk/src/c/classes/bamg/R2.h
r13395 r13975 39 39 template <class R,class RR> class P2xP2{ 40 40 41 private:42 43 friend P2<R,RR> operator*(P2<R,RR> c,P2xP2<R,RR> cc){44 return P2<R,RR>(c.x*cc.x.x + c.y*cc.y.x, c.x*cc.x.y + c.y*cc.y.y);45 }46 41 public: 47 42 -
issm/trunk/src/c/classes/bamg/SetOfE4.cpp
r13395 r13975 1 #include "../objects .h"1 #include "../objects/objects.h" 2 2 3 3 using namespace std; -
issm/trunk/src/c/classes/bamg/Triangle.cpp
r13395 r13975 4 4 #include <ctime> 5 5 6 #include "../objects .h"6 #include "../objects/objects.h" 7 7 8 8 namespace bamg { … … 424 424 sinb12 = double(det2), 425 425 sinba2 = double(t2->det); 426 427 426 428 427 // angle b12 > angle ba2 => cotg(angle b12) < cotg(angle ba2) -
issm/trunk/src/c/classes/bamg/VertexOnVertex.cpp
r13395 r13975 17 17 /*FUNCTION VertexOnVertex::VertexOnVertex(BamgVertex * w,BamgVertex *bw){{{*/ 18 18 VertexOnVertex::VertexOnVertex(BamgVertex * w,BamgVertex *bw) :v(w),bv(bw){ 19 19 20 20 }/*}}}*/ 21 21 -
issm/trunk/src/c/classes/classes.h
r13395 r13975 30 30 #include "./OptArgs.h" 31 31 #include "./OptPars.h" 32 #include "./AdolcEdf.h" 33 #include "./IssmComm.h" 34 #include "./RiftStruct.h" 32 35 33 36 #endif -
issm/trunk/src/c/classes/dakota/DakotaPlugin.cpp
r13395 r13975 15 15 */ 16 16 17 18 17 #ifdef HAVE_CONFIG_H 19 18 #include <config.h> … … 25 24 #include "../../shared/shared.h" 26 25 #include "../../include/include.h" 26 #include "../../solutions/solutions.h" 27 27 #include "../classes.h" 28 #include "../../modules/Dakotax/Dakotax.h"29 28 30 29 /*Standard includes: */ … … 34 33 35 34 //Dakota headers 36 #include "DakotaResponse.H"37 #include "ParamResponsePair.H"38 #include "DakotaPlugin.h"39 #include "system_defs.h"40 #include "ProblemDescDB.H"41 #include " ParallelLibrary.H"35 #include <DakotaResponse.H> 36 #include <ParamResponsePair.H> 37 #include <system_defs.h> 38 #include <ProblemDescDB.H> 39 #include <ParallelLibrary.H> 40 #include "./DakotaPlugin.h" 42 41 43 42 namespace SIM { 44 43 45 //constructor 46 DakotaPlugin::DakotaPlugin(const Dakota::ProblemDescDB& problem_db,void* in_femmodel):Dakota::DirectApplicInterface(problem_db){ 47 44 DakotaPlugin::DakotaPlugin(const Dakota::ProblemDescDB& problem_db,void* in_femmodel):Dakota::DirectApplicInterface(problem_db){/*{{{*/ 48 45 49 46 femmodel=in_femmodel; 50 47 counter=0; 51 } 52 53 //destructor 54 DakotaPlugin::~DakotaPlugin(){ /* Virtual destructor handles referenceCount at Interface level. */ } 55 56 int DakotaPlugin::derived_map_ac(const Dakota::String& driver) { 48 }/*}}}*/ 49 DakotaPlugin::~DakotaPlugin(){/*{{{*/ 50 /* Virtual destructor handles referenceCount at Interface level. */ 51 }/*}}}*/ 52 int DakotaPlugin::derived_map_ac(const Dakota::String& driver){/*{{{*/ 57 53 58 54 int i; … … 80 76 memcpy(variable_descriptor,label.c_str(),(strlen(label.c_str())+1)*sizeof(char)); 81 77 82 83 78 variable_descriptors[i]=variable_descriptor; 84 79 } … … 88 83 89 84 /*run core solution: */ 90 SpawnCore(responses,numFns, variables,variable_descriptors,numACV,femmodel,counter);85 DakotaSpawnCore(responses,numFns, variables,variable_descriptors,numACV,femmodel,counter); 91 86 92 87 /*populate responses: */ … … 94 89 fnVals[i]=responses[i]; 95 90 } 96 97 91 98 92 /*Free ressources:*/ … … 106 100 107 101 return 0; 108 } 109 110 111 int DakotaPlugin::GetCounter(){ 102 }/*}}}*/ 103 int DakotaPlugin::GetCounter(){/*{{{*/ 112 104 return counter; 113 } 105 }/*}}}*/ 114 106 115 107 } // namespace SIM 116 108 117 118 109 #endif //only works if dakota library has been compiled in. -
issm/trunk/src/c/classes/dakota/DakotaPlugin.h
r13395 r13975 5 5 #define _DAKOTAPLUGIN_H 6 6 7 8 7 #ifdef _HAVE_DAKOTA_ //only works if dakota library has been compiled in. 9 8 10 9 /*Headers:*/ 11 /*{{{*/ 12 #include "DirectApplicInterface.H" 10 #include <DirectApplicInterface.H> 13 11 #include "../../toolkits/toolkits.h" 14 12 #include "../../classes/classes.h" 15 /*}}}*/16 13 17 14 namespace SIM { … … 49 46 #endif //only works if dakota library has been compiled in. 50 47 51 52 48 #endif -
issm/trunk/src/c/classes/gauss/GaussPenta.h
r13395 r13975 28 28 double coord3; 29 29 double coord4; 30 30 31 31 public: 32 32 -
issm/trunk/src/c/classes/gauss/GaussTria.h
r13395 r13975 25 25 IssmDouble coord2; 26 26 IssmDouble coord3; 27 27 28 28 public: 29 29 -
issm/trunk/src/c/classes/kriging/ExponentialVariogram.cpp
r13395 r13975 11 11 #include <stdio.h> 12 12 #include <string.h> 13 #include "../objects .h"13 #include "../objects/objects.h" 14 14 #include "../../EnumDefinitions/EnumDefinitions.h" 15 15 #include "../../shared/shared.h" -
issm/trunk/src/c/classes/kriging/ExponentialVariogram.h
r13395 r13975 25 25 void DeepEcho(){_error_("Not implemented yet");}; 26 26 int Id(){_error_("Not implemented yet");}; 27 int MyRank(){_error_("Not implemented yet");};28 27 int ObjectEnum(){_error_("Not implemented yet");}; 29 28 Object* copy(){_error_("Not implemented yet");}; -
issm/trunk/src/c/classes/kriging/GaussianVariogram.cpp
r13395 r13975 11 11 #include <stdio.h> 12 12 #include <string.h> 13 #include "../objects .h"13 #include "../objects/objects.h" 14 14 #include "../../EnumDefinitions/EnumDefinitions.h" 15 15 #include "../../shared/shared.h" -
issm/trunk/src/c/classes/kriging/GaussianVariogram.h
r13395 r13975 26 26 void DeepEcho(){_error_("Not implemented yet");}; 27 27 int Id(){_error_("Not implemented yet");}; 28 int MyRank(){_error_("Not implemented yet");};29 28 int ObjectEnum(){_error_("Not implemented yet");}; 30 29 Object* copy(){_error_("Not implemented yet");}; -
issm/trunk/src/c/classes/kriging/Observation.cpp
r13395 r13975 4 4 5 5 #include <stdlib.h> 6 #include "../objects .h"6 #include "../objects/objects.h" 7 7 8 8 /*Observation constructors and destructor*/ … … 35 35 void Observation::Echo(void){ 36 36 37 int bit;38 39 37 _printLine_("Observation"); 40 38 _printLine_(" index : " << this->index); -
issm/trunk/src/c/classes/kriging/Observation.h
r13395 r13975 26 26 void DeepEcho() {_error_("Not implemented yet"); }; 27 27 int Id() {_error_("Not implemented yet"); }; 28 int MyRank() {_error_("Not implemented yet"); };29 28 int ObjectEnum(){_error_("Not implemented yet"); }; 30 29 Object *copy() {_error_("Not implemented yet"); }; -
issm/trunk/src/c/classes/kriging/PowerVariogram.cpp
r13395 r13975 11 11 #include <stdio.h> 12 12 #include <string.h> 13 #include "../objects .h"13 #include "../objects/objects.h" 14 14 #include "../../EnumDefinitions/EnumDefinitions.h" 15 15 #include "../../shared/shared.h" -
issm/trunk/src/c/classes/kriging/PowerVariogram.h
r13395 r13975 25 25 void DeepEcho(){_error_("Not implemented yet");}; 26 26 int Id(){_error_("Not implemented yet");}; 27 int MyRank(){_error_("Not implemented yet");};28 27 int ObjectEnum(){_error_("Not implemented yet");}; 29 28 Object* copy(){_error_("Not implemented yet");}; -
issm/trunk/src/c/classes/kriging/Quadtree.cpp
r13395 r13975 1 #include "../objects .h"1 #include "../objects/objects.h" 2 2 3 3 /*DOCUMENTATION What is a Quadtree? {{{ -
issm/trunk/src/c/classes/kriging/Quadtree.h
r13395 r13975 29 29 void DeepEcho() {_error_("not implemented yet"); }; 30 30 int Id() {_error_("not implemented yet"); }; 31 int MyRank() {_error_("not implemented yet"); };32 31 int ObjectEnum(){_error_("not implemented yet"); }; 33 32 Object *copy() {_error_("not implemented yet"); }; -
issm/trunk/src/c/classes/kriging/SphericalVariogram.cpp
r13395 r13975 11 11 #include <stdio.h> 12 12 #include <string.h> 13 #include "../objects .h"13 #include "../objects/objects.h" 14 14 #include "../../EnumDefinitions/EnumDefinitions.h" 15 15 #include "../../shared/shared.h" -
issm/trunk/src/c/classes/kriging/SphericalVariogram.h
r13395 r13975 25 25 void DeepEcho(){_error_("Not implemented yet");}; 26 26 int Id(){_error_("Not implemented yet");}; 27 int MyRank(){_error_("Not implemented yet");};28 27 int ObjectEnum(){_error_("Not implemented yet");}; 29 28 Object* copy(){_error_("Not implemented yet");}; -
issm/trunk/src/c/classes/matrix/ElementMatrix.cpp
r13395 r13975 230 230 /*FUNCTION ElementMatrix::~ElementMatrix(){{{*/ 231 231 ElementMatrix::~ElementMatrix(){ 232 232 233 233 xDelete<IssmDouble>(this->values); 234 234 xDelete<int>(this->gglobaldoflist); … … 278 278 } 279 279 280 281 280 if((this->row_ssize!=0) && (this->row_fsize!=0)){ 282 281 /*first, retrieve values that are in the f and s-set from the g-set values matrix: */ -
issm/trunk/src/c/classes/matrix/ElementMatrix.h
r13395 r13975 22 22 23 23 public: 24 24 25 25 int nrows; 26 26 int ncols; -
issm/trunk/src/c/classes/matrix/ElementVector.cpp
r13395 r13975 36 36 /*intermediaries*/ 37 37 int i,j,counter; 38 int gsize,fsize ,ssize;38 int gsize,fsize; 39 39 int* P=NULL; 40 40 bool found; … … 139 139 /*fill values with 0: */ 140 140 this->values=xNewZeroInit<IssmDouble>(this->nrows); 141 141 142 142 /*g list*/ 143 143 this->gglobaldoflist=GetGlobalDofList(nodes,numnodes,GsetEnum,approximation); … … 151 151 /*FUNCTION ElementVector::~ElementVector(){{{*/ 152 152 ElementVector::~ElementVector(){ 153 153 154 154 xDelete<IssmDouble>(this->values); 155 155 xDelete<int>(this->gglobaldoflist); … … 181 181 xDelete<IssmDouble>(localvalues); 182 182 } 183 183 184 184 } 185 185 /*}}}*/ … … 219 219 void ElementVector::Echo(void){ 220 220 221 int i,j; 221 int i; 222 222 223 _printLine_("Element Vector echo:"); 223 224 _printLine_(" nrows: " << nrows); -
issm/trunk/src/c/classes/matrix/ElementVector.h
r13395 r13975 22 22 23 23 public: 24 24 25 25 int nrows; 26 26 IssmDouble* values; 27 27 28 28 //gset 29 29 int* gglobaldoflist; … … 33 33 int* flocaldoflist; 34 34 int* fglobaldoflist; 35 35 36 36 /*ElementVector constructors, destructors {{{*/ 37 37 ElementVector(); … … 51 51 }; 52 52 #endif //#ifndef _ELEMENT_VECTOR_H_ 53 -
issm/trunk/src/c/classes/matrix/Matrix.h
r13395 r13975 76 76 } 77 77 /*}}}*/ 78 /*FUNCTION Matrix(int m,int n,int M,int N,int* d_nnz,int* o_nnz,int type){{{*/ 79 #ifdef _HAVE_PETSC_ 80 Matrix(int m,int n,int M,int N,int* d_nnz,int* o_nnz,int in_type=PetscMatType){ 81 #else 82 Matrix(int m,int n,int M,int N,int* d_nnz,int* o_nnz,int in_type=SeqMatType){ 83 #endif 84 85 #ifdef _HAVE_PETSC_ 86 pmatrix=NULL; 87 #endif 88 smatrix=NULL; 89 type=in_type; 90 91 if(type==PetscMatType){ 92 #ifdef _HAVE_PETSC_ 93 this->pmatrix=new PetscMat(m,n,M,N,d_nnz,o_nnz); 94 #else 95 _error_("Petsc matrix format not usable, as Petsc has not been compiled!"); 96 #endif 97 } 98 else if(type==SeqMatType){ 99 this->smatrix=new SeqMat<doubletype>(m,n,M,N,d_nnz,o_nnz); 100 } 101 else _error_("Matrix type: " << type << " not supported yet!"); 102 103 } 104 /*}}}*/ 78 105 /*FUNCTION Matrix(int M,int N,IssmDouble sparsity,int in_type){{{*/ 79 106 #ifdef _HAVE_PETSC_ … … 163 190 #ifdef _HAVE_PETSC_ 164 191 delete this->pmatrix; 165 #else166 _error_("Petsc matrix format not usable, as Petsc has not been compiled!");167 192 #endif 168 193 } … … 170 195 delete this->smatrix; 171 196 } 172 else _error_("Matrix type: " << type << " not supported yet!");173 197 174 198 } … … 192 216 } 193 217 /*}}}*/ 218 /*FUNCTION AllocationInfo{{{*/ 219 void AllocationInfo(void){ 220 _assert_(this); 221 if(type==PetscMatType){ 222 #ifdef _HAVE_PETSC_ 223 this->pmatrix->AllocationInfo(); 224 #endif 225 } 226 else if(type==SeqMatType){ 227 //this->smatrix->AllocationInfo(); 228 } 229 else _error_("Matrix type: " << type << " not supported yet!"); 230 }/*}}}*/ 194 231 /*FUNCTION Assemble{{{*/ 195 232 void Assemble(void){ … … 274 311 Matrix* Duplicate(void){ 275 312 276 Matrix* output=NULL; 277 278 output=new Matrix(); 313 Matrix* output=new Matrix(); 279 314 280 315 if(type==PetscMatType){ … … 306 341 else _error_("Matrix type: " << type << " not supported yet!"); 307 342 308 309 343 return output; 310 344 } -
issm/trunk/src/c/classes/matrix/Vector.h
r13395 r13975 61 61 type=in_type; 62 62 63 64 63 if(type==PetscVecType){ 65 64 #ifdef _HAVE_PETSC_ … … 71 70 else if(type==SeqVecType){ 72 71 this->svector=new SeqVec<doubletype>(M,fromlocalsize); 72 } 73 else _error_("Vector type: " << type << " not supported yet!"); 74 75 } 76 /*}}}*/ 77 /*FUNCTION Vector(int m,int M,int in_type){{{*/ 78 #ifdef _HAVE_PETSC_ 79 Vector(int m,int M,int in_type=PetscVecType){ 80 #else 81 Vector(int m,int M,int in_type=SeqVecType){ 82 #endif 83 84 #ifdef _HAVE_PETSC_ 85 pvector=NULL; 86 #endif 87 svector=NULL; 88 type=in_type; 89 90 if(type==PetscVecType){ 91 #ifdef _HAVE_PETSC_ 92 this->pvector=new PetscVec(m,M); 93 #else 94 _error_("Petsc matrix format not usable, as Petsc has not been compiled!"); 95 #endif 96 } 97 else if(type==SeqVecType){ 98 this->svector=new SeqVec<doubletype>(m,M); 73 99 } 74 100 else _error_("Vector type: " << type << " not supported yet!"); … … 111 137 #ifdef _HAVE_PETSC_ 112 138 delete this->pvector; 113 #else114 _error_("Petsc matrix format not usable, as Petsc has not been compiled!");115 139 #endif 116 140 } … … 118 142 delete this->svector; 119 143 } 120 else _error_("Vector type: " << type << " not supported yet!");121 144 } 122 145 /*}}}*/ … … 171 194 void SetValues(int ssize, int* list, doubletype* values, InsMode mode){ 172 195 173 174 196 if(type==PetscVecType){ 175 197 #ifdef _HAVE_PETSC_ … … 183 205 } 184 206 else _error_("Vector type: " << type << " not supported yet!"); 185 186 187 207 188 208 } … … 207 227 /*FUNCTION GetValue{{{*/ 208 228 void GetValue(doubletype* pvalue,int dof){ 209 210 229 211 230 if(type==PetscVecType){ … … 256 275 void GetLocalSize(int* pM){ 257 276 258 259 277 if(type==PetscVecType){ 260 278 #ifdef _HAVE_PETSC_ … … 276 294 Vector* output=NULL; 277 295 278 279 296 if(type==PetscVecType){ 280 297 #ifdef _HAVE_PETSC_ … … 298 315 void Set(doubletype value){ 299 316 300 301 317 if(type==PetscVecType){ 302 318 #ifdef _HAVE_PETSC_ … … 316 332 void AXPY(Vector* X, doubletype a){ 317 333 318 319 334 if(type==PetscVecType){ 320 335 #ifdef _HAVE_PETSC_ … … 334 349 void AYPX(Vector* X, doubletype a){ 335 350 336 337 351 if(type==PetscVecType){ 338 352 #ifdef _HAVE_PETSC_ … … 346 360 } 347 361 else _error_("Vector type: " << type << " not supported yet!"); 348 349 362 350 363 } … … 374 387 void Copy(Vector* to){ 375 388 376 377 389 if(type==PetscVecType){ 378 390 #ifdef _HAVE_PETSC_ … … 386 398 } 387 399 else _error_("Vector type: " << type << " not supported yet!"); 388 389 400 390 401 } … … 413 424 void Scale(doubletype scale_factor){ 414 425 415 416 426 if(type==PetscVecType){ 417 427 #ifdef _HAVE_PETSC_ … … 451 461 void PointwiseDivide(Vector* x,Vector* y){ 452 462 453 454 463 if(type==PetscVecType){ 455 464 #ifdef _HAVE_PETSC_ -
issm/trunk/src/c/classes/matrix/matrixobjects.h
r13395 r13975 6 6 #define ALL_MATRIX_OBJECTS_H_ 7 7 8 9 8 /*Numerics:*/ 10 9 #include "./ElementMatrix.h" … … 13 12 #include "./Matrix.h" 14 13 15 16 14 #endif -
issm/trunk/src/c/classes/objects/Constraints/Constraint.h
r13395 r13975 4 4 * It is derived from Object, so DataSets can contain them. 5 5 */ 6 7 6 8 7 #ifndef _CONSTRAINT_H_ … … 19 18 20 19 public: 21 20 22 21 virtual ~Constraint(){}; 23 22 virtual void ConstrainNode(Nodes* nodes,Parameters* parameters)=0; 24 23 virtual bool InAnalysis(int analysis_type)=0; 25 24 26 27 25 }; 28 26 #endif -
issm/trunk/src/c/classes/objects/Constraints/SpcDynamic.cpp
r13395 r13975 41 41 } 42 42 /*}}}*/ 43 43 44 44 /*Object virtual functions definitions:*/ 45 45 /*FUNCTION SpcDynamic::Echo {{{*/ … … 65 65 /*FUNCTION SpcDynamic::Id {{{*/ 66 66 int SpcDynamic::Id(void){ return sid; } 67 /*}}}*/68 /*FUNCTION SpcDynamic::MyRank {{{*/69 int SpcDynamic::MyRank(void){70 extern int my_rank;71 return my_rank;72 }73 67 /*}}}*/ 74 68 /*FUNCTION SpcDynamic::ObjectEnum{{{*/ … … 117 111 /*FUNCTION SpcDynamic::GetNodeId {{{*/ 118 112 int SpcDynamic::GetNodeId(){ 119 113 120 114 return nodeid; 121 115 } -
issm/trunk/src/c/classes/objects/Constraints/SpcDynamic.h
r13395 r13975 33 33 void DeepEcho(); 34 34 int Id(); 35 int MyRank();36 35 int ObjectEnum(); 37 36 Object* copy(); -
issm/trunk/src/c/classes/objects/Constraints/SpcStatic.cpp
r13395 r13975 40 40 } 41 41 /*}}}*/ 42 42 43 43 /*Object virtual functions definitions:*/ 44 44 /*FUNCTION SpcStatic::Echo {{{*/ … … 68 68 /*FUNCTION SpcStatic::Id {{{*/ 69 69 int SpcStatic::Id(void){ return sid; } 70 /*}}}*/71 /*FUNCTION SpcStatic::MyRank {{{*/72 int SpcStatic::MyRank(void){73 extern int my_rank;74 return my_rank;75 }76 70 /*}}}*/ 77 71 /*FUNCTION SpcStatic::ObjectEnum{{{*/ … … 118 112 /*FUNCTION SpcStatic::GetNodeId {{{*/ 119 113 int SpcStatic::GetNodeId(){ 120 114 121 115 return nodeid; 122 116 } -
issm/trunk/src/c/classes/objects/Constraints/SpcStatic.h
r13395 r13975 32 32 void DeepEcho(); 33 33 int Id(); 34 int MyRank();35 34 int ObjectEnum(); 36 35 Object* copy(); -
issm/trunk/src/c/classes/objects/Constraints/SpcTransient.cpp
r13395 r13975 54 54 } 55 55 /*}}}*/ 56 56 57 57 /*Object virtual functions definitions:*/ 58 58 /*FUNCTION SpcTransient::Echo {{{*/ … … 81 81 int SpcTransient::Id(void){ return sid; } 82 82 /*}}}*/ 83 /*FUNCTION SpcTransient::MyRank {{{*/84 int SpcTransient::MyRank(void){85 extern int my_rank;86 return my_rank;87 }88 /*}}}*/89 83 /*FUNCTION SpcTransient::ObjectEnum{{{*/ 90 84 int SpcTransient::ObjectEnum(void){ … … 103 97 /*FUNCTION SpcTransient::InAnalysis{{{*/ 104 98 bool SpcTransient::InAnalysis(int in_analysis_type){ 105 99 106 100 if (in_analysis_type==this->analysis_type) return true; 107 101 else return false; … … 120 114 /*Chase through nodes and find the node to which this SpcTransient applys: */ 121 115 node=(Node*)nodes->GetObjectById(NULL,nodeid); 122 116 123 117 if(node){ //in case the spc is dealing with a node on another cpu 124 118 … … 165 159 /*FUNCTION SpcTransient::GetNodeId {{{*/ 166 160 int SpcTransient::GetNodeId(){ 167 161 168 162 return nodeid; 169 163 } … … 174 168 } 175 169 /*}}}*/ 176 -
issm/trunk/src/c/classes/objects/Constraints/SpcTransient.h
r13395 r13975 34 34 void DeepEcho(); 35 35 int Id(); 36 int MyRank();37 36 int ObjectEnum(); 38 37 Object* copy(); -
issm/trunk/src/c/classes/objects/Contour.h
r13395 r13975 22 22 public: 23 23 24 int id;25 int nods;//number of vertices in the contour26 doubletype *x;27 doubletype *y;28 bool closed;//is this contour closed?24 int id; 25 int nods; //number of vertices in the contour 26 doubletype *x; 27 doubletype *y; 28 bool closed; //is this contour closed? 29 29 30 30 /*Contour constructors, destructors :*/ 31 /*FUNCTION Contour() default constructor{{{*/31 /*FUNCTION Contour() {{{*/ 32 32 Contour(){ 33 this->id =0;34 this->nods =0;35 this->x =NULL;36 this->y =NULL;37 this->closed =false;33 this->id = 0; 34 this->nods = 0; 35 this->x = NULL; 36 this->y = NULL; 37 this->closed = false; 38 38 } 39 39 /*}}}*/ … … 41 41 Contour(int pid,int pnods, doubletype* px, doubletype* py,bool pclosed){ 42 42 43 this->id =pid;44 this->nods =pnods;45 this->closed =pclosed;43 this->id = pid; 44 this->nods = pnods; 45 this->closed = pclosed; 46 46 if(nods){ 47 47 this->x=xNew<doubletype>(nods); … … 52 52 } 53 53 /*}}}*/ 54 /*FUNCTION Contour() default constructor{{{*/54 /*FUNCTION ~Contour() {{{*/ 55 55 ~Contour(){ 56 56 xDelete<doubletype>(this->x); … … 59 59 /*}}}*/ 60 60 61 62 61 /*Object virtual function resolutoin: */ 63 62 /*FUNCTION Echo(){{{*/ 64 63 void Echo(void){ 65 66 int i; 67 68 _printLine_("Contour: " << id); 69 _printLine_(" nods: " << nods); 70 _printLine_(" closed: " << (closed?"true":"false")); 64 _printLine_(" Contour: " << id); 65 _printLine_(" nods: " << nods); 66 _printLine_(" closed: " << (closed?"true":"false")); 71 67 if(nods){ 72 _printLine_(" x ,y:");73 for(i =0;i<nods;i++){74 _printLine_(i << ": " << x[i] << " |" << y[i]);68 _printLine_(" x , y:"); 69 for(int i=0;i<nods;i++){ 70 _printLine_(i << ": " << x[i] << " | " << y[i]); 75 71 } 76 72 } … … 87 83 } 88 84 /*}}}*/ 89 /*FUNCTION MyRank{{{*/90 int MyRank(void){91 extern int my_rank;92 93 return my_rank;94 }95 /*}}}*/96 85 /*FUNCTION ObjectEnum{{{*/ 97 86 int ObjectEnum(void){ 98 99 87 return ContourEnum; 100 101 88 } 102 89 /*}}}*/ 103 90 /*FUNCTION copy {{{*/ 104 91 Object* copy() { 105 106 92 return new Contour(*this); 107 108 93 } 109 94 /*}}}*/ -
issm/trunk/src/c/classes/objects/ElementResults/BoolElementResult.cpp
r13395 r13975 58 58 int BoolElementResult::Id(void){ return -1; } 59 59 /*}}}*/ 60 /*FUNCTION BoolElementResult::MyRank{{{*/61 int BoolElementResult::MyRank(void){62 extern int my_rank;63 return my_rank;64 }65 /*}}}*/66 60 /*FUNCTION BoolElementResult::ObjectEnum{{{*/ 67 61 int BoolElementResult::ObjectEnum(void){ … … 116 110 /*FUNCTION BoolElementResult::PatchFill{{{*/ 117 111 void BoolElementResult::PatchFill(int row, Patch* patch){ 118 112 119 113 /*Here, we fill the result information into the patch object. First, let's remember what is in a row 120 114 * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values -
issm/trunk/src/c/classes/objects/ElementResults/BoolElementResult.h
r13395 r13975 3 3 * A boll result object is just derived from a BoolInput object, with additional time and step information. 4 4 */ 5 6 5 7 6 #ifndef _BOOLELEMENTRESULT_H_ … … 34 33 void DeepEcho(); 35 34 int Id(); 36 int MyRank();37 35 int ObjectEnum(); 38 36 Object* copy(); -
issm/trunk/src/c/classes/objects/ElementResults/DoubleElementResult.cpp
r13395 r13975 58 58 int DoubleElementResult::Id(void){ return -1; } 59 59 /*}}}*/ 60 /*FUNCTION DoubleElementResult::MyRank{{{*/61 int DoubleElementResult::MyRank(void){62 extern int my_rank;63 return my_rank;64 }65 /*}}}*/66 60 /*FUNCTION DoubleElementResult::ObjectEnum{{{*/ 67 61 int DoubleElementResult::ObjectEnum(void){ … … 106 100 /*FUNCTION DoubleElementResult::ProcessUnits{{{*/ 107 101 void DoubleElementResult::ProcessUnits(Parameters* parameters){ 108 102 109 103 this->value=UnitConversion(this->value,IuToExtEnum,this->enum_type); 110 104 … … 118 112 /*FUNCTION DoubleElementResult::PatchFill{{{*/ 119 113 void DoubleElementResult::PatchFill(int row, Patch* patch){ 120 114 121 115 /*Here, we fill the result information into the patch object. First, let's remember what is in a row 122 116 * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values -
issm/trunk/src/c/classes/objects/ElementResults/DoubleElementResult.h
r13395 r13975 3 3 * A IssmDouble result object is just derived from a DoubleInput object, with additional time and step information. 4 4 */ 5 6 5 7 6 #ifndef _DOUBLEELEMENTRESULT_H_ … … 34 33 void DeepEcho(); 35 34 int Id(); 36 int MyRank();37 35 int ObjectEnum(); 38 36 Object* copy(); -
issm/trunk/src/c/classes/objects/ElementResults/ElementResult.h
r13395 r13975 2 2 * \brief abstract class for ElementResult object 3 3 */ 4 5 4 6 5 #ifndef _ELEMENTRESULT_H_ … … 15 14 16 15 public: 17 16 18 17 virtual ~ElementResult(){}; 19 20 18 virtual ElementResult* SpawnTriaElementResult(int* indices)=0; 21 19 virtual IssmDouble GetTime(void)=0; -
issm/trunk/src/c/classes/objects/ElementResults/ElementResultLocal.h
r13395 r13975 9 9 10 10 #endif //ifndef _ELEMENTRESULTLOCAL_H_ 11 -
issm/trunk/src/c/classes/objects/ElementResults/PentaP1ElementResult.cpp
r13395 r13975 61 61 int PentaP1ElementResult::Id(void){ return -1; } 62 62 /*}}}*/ 63 /*FUNCTION PentaP1ElementResult::MyRank{{{*/64 int PentaP1ElementResult::MyRank(void){65 extern int my_rank;66 return my_rank;67 }68 /*}}}*/69 63 /*FUNCTION PentaP1ElementResult::ObjectEnum{{{*/ 70 64 int PentaP1ElementResult::ObjectEnum(void){ … … 76 70 /*FUNCTION PentaP1ElementResult::copy{{{*/ 77 71 Object* PentaP1ElementResult::copy() { 78 72 79 73 return new PentaP1ElementResult(this->enum_type,this->values,this->step,this->time); 80 74 … … 117 111 /*FUNCTION PentaP1ElementResult::ProcessUnits{{{*/ 118 112 void PentaP1ElementResult::ProcessUnits(Parameters* parameters){ 119 113 120 114 UnitConversion(this->values,6,IuToExtEnum,this->enum_type); 121 115 … … 129 123 /*FUNCTION PentaP1ElementResult::PatchFill{{{*/ 130 124 void PentaP1ElementResult::PatchFill(int row, Patch* patch){ 131 125 132 126 /*Here, we fill the result information into the patch object. First, let's remember what is in a row 133 127 * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values -
issm/trunk/src/c/classes/objects/ElementResults/PentaP1ElementResult.h
r13395 r13975 3 3 * this object is just a PentaP1Input with additional time and step info. 4 4 */ 5 6 5 7 6 #ifndef _PENTAP1ELEMENTRESULT_H_ … … 33 32 void DeepEcho(); 34 33 int Id(); 35 int MyRank();36 34 int ObjectEnum(); 37 35 Object* copy(); -
issm/trunk/src/c/classes/objects/ElementResults/TriaP1ElementResult.cpp
r13395 r13975 49 49 /*FUNCTION TriaP1ElementResult::DeepEcho{{{*/ 50 50 void TriaP1ElementResult::DeepEcho(void){ 51 51 52 52 _printLine_("TriaP1ElementResult:"); 53 53 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")"); … … 60 60 int TriaP1ElementResult::Id(void){ return -1; } 61 61 /*}}}*/ 62 /*FUNCTION TriaP1ElementResult::MyRank{{{*/63 int TriaP1ElementResult::MyRank(void){64 extern int my_rank;65 return my_rank;66 }67 /*}}}*/68 62 /*FUNCTION TriaP1ElementResult::ObjectEnum{{{*/ 69 63 int TriaP1ElementResult::ObjectEnum(void){ … … 75 69 /*FUNCTION TriaP1ElementResult::copy{{{*/ 76 70 Object* TriaP1ElementResult::copy() { 77 71 78 72 return new TriaP1ElementResult(this->enum_type,this->values,this->step,this->time); 79 73 … … 105 99 /*FUNCTION TriaP1ElementResult::ProcessUnits{{{*/ 106 100 void TriaP1ElementResult::ProcessUnits(Parameters* parameters){ 107 101 108 102 UnitConversion(this->values,3,IuToExtEnum,this->enum_type); 109 103 … … 117 111 /*FUNCTION TriaP1ElementResult::PatchFill{{{*/ 118 112 void TriaP1ElementResult::PatchFill(int row, Patch* patch){ 119 113 120 114 /*Here, we fill the result information into the patch object. First, let's remember what is in a row 121 115 * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values -
issm/trunk/src/c/classes/objects/ElementResults/TriaP1ElementResult.h
r13395 r13975 2 2 * \brief: header file for TriaP1ElementResult object 3 3 */ 4 5 4 6 5 #ifndef _TRIAP1ELEMENTRESULT_H_ … … 32 31 void DeepEcho(); 33 32 int Id(); 34 int MyRank();35 33 int ObjectEnum(); 36 34 Object* copy(); -
issm/trunk/src/c/classes/objects/Elements/Element.h
r13395 r13975 4 4 * It is derived from Element, so DataSets can contain them. 5 5 */ 6 7 6 8 7 #ifndef _ELEMENT_H_ … … 25 24 26 25 public: 27 26 28 27 virtual ~Element(){}; 29 28 30 29 virtual void Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters)=0; 31 30 virtual void SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters)=0; 31 virtual void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum)=0; 32 32 virtual void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,Vector<IssmDouble>* df)=0; 33 33 virtual void CreatePVector(Vector<IssmDouble>* pf)=0; … … 35 35 virtual void GetSolutionFromInputs(Vector<IssmDouble>* solution)=0; 36 36 virtual int GetNodeIndex(Node* node)=0; 37 virtual int GetNumberOfNodes(void)=0; 38 virtual void GetNodesSidList(int* sidlist)=0; 39 37 40 virtual int Sid()=0; 38 41 virtual bool IsFloating()=0; … … 43 46 virtual void GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue)=0; 44 47 virtual void GetInputValue(IssmDouble* pvalue,Node* node,int enumtype)=0; 45 48 46 49 virtual IssmDouble SurfaceArea(void)=0; 47 50 virtual void InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum)=0; … … 59 62 virtual void ProcessResultsUnits(void)=0; 60 63 virtual void RequestedOutput(int output_enum,int step,IssmDouble time)=0; 61 64 62 65 virtual int NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units)=0; 63 66 virtual void InputScale(int enum_type,IssmDouble scale_factor)=0; -
issm/trunk/src/c/classes/objects/Elements/Penta.cpp
r13395 r13975 82 82 this->inputs=new Inputs(); 83 83 this->results=new Results(); 84 84 85 85 /*initialize pointers:*/ 86 86 this->nodes=NULL; … … 180 180 181 181 /*Intermediaries */ 182 int count ,ig;182 int count; 183 183 IssmDouble basalfriction[NUMVERTICES]={0,0,0,0,0,0}; 184 184 IssmDouble alpha2,vx,vy; 185 185 Friction* friction=NULL; 186 186 GaussPenta* gauss=NULL; 187 188 187 189 188 /* Basal friction can only be found at the base of an ice sheet: */ … … 199 198 Input* vz_input=inputs->GetInput(VzEnum); _assert_(vz_input); 200 199 201 202 200 /*Build friction element, needed later: */ 203 201 friction=new Friction("3d",inputs,matpar,DiagnosticHorizAnalysisEnum); … … 206 204 gauss=new GaussPenta(0,1,2,2); 207 205 count=0; 208 for(i g=gauss->begin();ig<gauss->end();ig++){206 for(int ig=gauss->begin();ig<gauss->end();ig++){ 209 207 210 208 gauss->GaussPoint(ig); … … 216 214 count++; 217 215 } 218 216 219 217 /*Create PentaVertex input, which will hold the basal friction:*/ 220 218 this->inputs->AddInput(new PentaP1Input(BasalFrictionEnum,&basalfriction[0])); … … 228 226 void Penta::ComputeBasalStress(Vector<IssmDouble>* sigma_b){ 229 227 230 int i,j ,ig;228 int i,j; 231 229 int dofv[3]={0,1,2}; 232 230 int dofp[1]={3}; 233 231 int analysis_type,approximation; 234 int doflist[NUMVERTICES]; 235 IssmDouble xyz_list[NUMVERTICES][3]; 236 IssmDouble xyz_list_tria[3][3]; 237 IssmDouble rho_ice,gravity,stokesreconditioning; 238 IssmDouble pressure,viscosity,bed,Jdet2d; 239 IssmDouble bed_normal[3]; 240 IssmDouble basalforce[3]; 241 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 242 IssmDouble devstresstensor[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 243 IssmDouble stresstensor[6]={0.0}; 244 IssmDouble sigma_xx,sigma_yy,sigma_zz; 245 IssmDouble sigma_xy,sigma_xz,sigma_yz; 246 IssmDouble surface=0,value=0; 232 IssmDouble xyz_list[NUMVERTICES][3]; 233 IssmDouble xyz_list_tria[3][3]; 234 IssmDouble rho_ice,gravity,stokesreconditioning; 235 IssmDouble pressure,viscosity,Jdet2d; 236 IssmDouble bed_normal[3]; 237 IssmDouble basalforce[3]; 238 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 239 IssmDouble stresstensor[6]={0.0}; 240 IssmDouble sigma_xx,sigma_yy,sigma_zz; 241 IssmDouble sigma_xy,sigma_xz,sigma_yz; 242 IssmDouble surface=0,value=0; 247 243 GaussPenta* gauss; 248 244 … … 257 253 /*retrieve some parameters: */ 258 254 this->parameters->FindParam(&stokesreconditioning,DiagnosticStokesreconditioningEnum); 259 255 260 256 if(!IsOnBed()){ 261 257 //put zero … … 280 276 /* Start looping on the number of gaussian points: */ 281 277 gauss=new GaussPenta(0,1,2,2); 282 for (ig=gauss->begin();ig<gauss->end();ig++){278 for(int ig=gauss->begin();ig<gauss->end();ig++){ 283 279 284 280 gauss->GaussPoint(ig); … … 325 321 void Penta::ComputeStressTensor(){ 326 322 327 int iv;328 323 IssmDouble xyz_list[NUMVERTICES][3]; 329 324 IssmDouble pressure,viscosity; … … 364 359 sigma_yz[iv]=2*viscosity*epsilon[5]; 365 360 } 366 361 367 362 /*Add Stress tensor components into inputs*/ 368 363 this->inputs->AddInput(new PentaP1Input(StressTensorxxEnum,&sigma_xx[0])); … … 381 376 382 377 int analysis_counter; 383 378 384 379 /*go into parameters and get the analysis_counter: */ 385 380 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum); … … 421 416 _assert_(this->nodes && this->material && this->matpar && this->verticalneighbors && this->parameters && this->inputs); 422 417 /*}}}*/ 423 418 424 419 /*Skip if water element*/ 425 420 if(IsOnWater()) return; … … 651 646 void Penta::DeepEcho(void){ 652 647 653 int i;654 655 648 _printLine_("Penta:"); 656 649 _printLine_(" id: " << id); … … 672 665 _printLine_("neighboor sids: "); 673 666 _printLine_(" " << horizontalneighborsids[0] << " " << horizontalneighborsids[1] << " " << horizontalneighborsids[2]); 674 675 return;676 667 } 677 668 /*}}}*/ … … 794 785 void Penta::GetDofList(int** pdoflist,int approximation_enum,int setenum){ 795 786 796 int i, j,count=0;787 int i,count=0; 797 788 int numberofdofs=0; 798 789 int* doflist=NULL; … … 815 806 } 816 807 /*}}}*/ 817 /*FUNCTION Penta::Get DofList1{{{*/818 void Penta::Get DofList1(int* doflist){808 /*FUNCTION Penta::GetVertexPidList {{{*/ 809 void Penta::GetVertexPidList(int* doflist){ 819 810 820 811 int i; 821 for(i=0;i<6;i++) doflist[i]=nodes[i]->GetDofList1(); 812 for(i=0;i<6;i++) doflist[i]=nodes[i]->GetVertexPid(); 813 814 } 815 /*}}}*/ 816 /*FUNCTION Penta::GetVertexSidList{{{*/ 817 void Penta::GetVertexSidList(int* sidlist){ 818 819 int i; 820 for(i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetVertexSid(); 822 821 823 822 } … … 892 891 } 893 892 /*}}}*/ 893 /*FUNCTION Penta::GetNodesSidList{{{*/ 894 void Penta::GetNodesSidList(int* sidlist){ 895 896 _assert_(sidlist); 897 _assert_(nodes); 898 899 for(int i=0;i<NUMVERTICES;i++){ 900 sidlist[i]=nodes[i]->Sid(); 901 } 902 } 903 /*}}}*/ 904 /*FUNCTION Penta::GetNumberOfNodes{{{*/ 905 int Penta::GetNumberOfNodes(void){ 906 907 if(this->nodes==NULL) return 0; 908 909 switch(this->element_type){ 910 case P1Enum: 911 return 6; 912 case P1DGEnum: 913 return 6; 914 default: 915 _error_("Element type "<<EnumToStringx(this->element_type)<<" not supported yet"); 916 } 917 } 918 /*}}}*/ 894 919 /*FUNCTION Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype) {{{*/ 895 920 void Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype){ 896 897 /*Intermediaries*/898 IssmDouble value[NUMVERTICES];899 GaussPenta *gauss = NULL;900 921 901 922 /*Recover input*/ … … 907 928 908 929 /* Start looping on the number of vertices: */ 909 gauss=new GaussPenta();930 GaussPenta *gauss=new GaussPenta(); 910 931 for (int iv=0;iv<NUMVERTICES;iv++){ 911 932 gauss->GaussVertex(iv); … … 920 941 void Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){ 921 942 922 /*Intermediaries*/923 IssmDouble value[NUMVERTICES];924 GaussPenta *gauss = NULL;925 926 943 /*Recover input*/ 927 944 Input* input=inputs->GetInput(enumtype); … … 932 949 /* Start looping on the number of vertices: */ 933 950 if (input){ 934 gauss=new GaussPenta();951 GaussPenta *gauss=new GaussPenta(); 935 952 for (int iv=0;iv<NUMVERTICES;iv++){ 936 953 gauss->GaussVertex(iv); 937 954 input->GetInputValue(&pvalue[iv],gauss); 938 955 } 956 delete gauss; 939 957 } 940 958 else{ 941 959 for (int iv=0;iv<NUMVERTICES;iv++) pvalue[iv]=defaultvalue; 942 960 } 943 944 /*clean-up*/945 delete gauss;946 961 } 947 962 /*}}}*/ … … 995 1010 * = 4 * mu * eps_eff ^2*/ 996 1011 *phi=4*pow(epsilon_eff,2.0)*viscosity; 997 }998 /*}}}*/999 /*FUNCTION Penta::GetSidList{{{*/1000 void Penta::GetSidList(int* sidlist){1001 1002 int i;1003 for(i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetSidList();1004 1005 1012 } 1006 1013 /*}}}*/ … … 1135 1142 void Penta::GetVectorFromInputs(Vector<IssmDouble>* vector,int input_enum){ 1136 1143 1137 int doflist1[NUMVERTICES];1144 int vertexpidlist[NUMVERTICES]; 1138 1145 1139 1146 /*Get out if this is not an element input*/ … … 1141 1148 1142 1149 /*Prepare index list*/ 1143 this->Get DofList1(&doflist1[0]);1150 this->GetVertexPidList(&vertexpidlist[0]); 1144 1151 1145 1152 /*Get input (either in element or material)*/ … … 1148 1155 1149 1156 /*We found the enum. Use its values to fill into the vector, using the vertices ids: */ 1150 input->GetVectorFromInputs(vector,& doflist1[0]);1157 input->GetVectorFromInputs(vector,&vertexpidlist[0]); 1151 1158 } 1152 1159 /*}}}*/ … … 1160 1167 } 1161 1168 if(interp==P1Enum){ 1162 int doflist1[NUMVERTICES];1169 int vertexpidlist[NUMVERTICES]; 1163 1170 int connectivity[NUMVERTICES]; 1164 this->Get SidList(&doflist1[0]);1171 this->GetVertexSidList(&vertexpidlist[0]); 1165 1172 this->GetConnectivityList(&connectivity[0]); 1166 elementresult->GetVectorFromResults(vector,& doflist1[0],&connectivity[0],NUMVERTICES);1173 elementresult->GetVectorFromResults(vector,&vertexpidlist[0],&connectivity[0],NUMVERTICES); 1167 1174 } 1168 1175 else if(interp==P0Enum){ … … 1191 1198 /*FUNCTION Penta::Sid {{{*/ 1192 1199 int Penta::Sid(){ 1193 1200 1194 1201 return sid; 1195 1202 … … 1251 1258 /*Check that name is an element input*/ 1252 1259 if (!IsInput(name)) return; 1253 1260 1254 1261 if ((code==5) || (code==1)){ //boolean 1255 1262 this->inputs->AddInput(new BoolInput(name,reCast<bool,IssmDouble>(scalar))); … … 1269 1276 1270 1277 /*Intermediaries*/ 1271 int i, j,t;1278 int i,t; 1272 1279 int penta_vertex_ids[6]; 1273 1280 int row; … … 1873 1880 penta=penta->GetUpperElement(); _assert_(penta->Id()!=this->id); 1874 1881 } 1875 1882 1876 1883 /*Free ressources:*/ 1877 1884 xDelete<int>(doflist); … … 1897 1904 /*Add input to the element: */ 1898 1905 this->inputs->AddInput(new PentaP1Input(enum_type,values)); 1899 1906 1900 1907 /*Free ressources:*/ 1901 1908 xDelete<int>(doflist); … … 1937 1944 penta=penta->GetUpperElement(); _assert_(penta->Id()!=this->id); 1938 1945 } 1939 1946 1940 1947 /*Free ressources:*/ 1941 1948 xDelete<int>(doflist); … … 1960 1967 /*Get values on the 6 vertices*/ 1961 1968 for (int i=0;i<6;i++){ 1962 values[i]=vector[this->nodes[i]->GetVertex Dof()];1969 values[i]=vector[this->nodes[i]->GetVertexPid()]; 1963 1970 } 1964 1971 … … 2162 2169 /*Recover info at the vertices: */ 2163 2170 parameters->FindParam(&migration_style,GroundinglineMigrationEnum); 2171 parameters->FindParam(&gl_melting_rate,GroundinglineMeltingRateEnum); 2164 2172 parameters->FindParam(&yts,ConstantsYtsEnum); 2165 2173 GetInputListOnVertices(&h[0],ThicknessEnum); … … 2170 2178 rho_ice=matpar->GetRhoIce(); 2171 2179 density=rho_ice/rho_water; 2172 2180 2173 2181 /*go through vertices, and update inputs, considering them to be PentaVertex type: */ 2174 2182 for(i=0;i<NUMVERTICES;i++){ … … 2211 2219 } 2212 2220 } 2213 2221 2214 2222 /*Add basal melting rate if element just ungrounded*/ 2215 2223 if(!this->IsFloating() && elementonshelf==true){ … … 2251 2259 2252 2260 return minlength; 2253 }2254 /*}}}*/2255 /*FUNCTION Penta::MyRank {{{*/2256 int Penta::MyRank(void){2257 extern int my_rank;2258 return my_rank;2259 2261 } 2260 2262 /*}}}*/ … … 2299 2301 /*recover pointer: */ 2300 2302 count=*pcount; 2301 2303 2302 2304 /*will be needed later: */ 2303 2305 for(i=0;i<6;i++) vertices_ids[i]=nodes[i]->GetVertexId(); //vertices id start at column 3 of the patch. … … 2508 2510 /*FUNCTION Penta::RequestedOutput{{{*/ 2509 2511 void Penta::RequestedOutput(int output_enum,int step,IssmDouble time){ 2510 2512 2511 2513 if(IsInput(output_enum)){ 2512 2514 /*just transfer this input to results, and we are done: */ … … 2607 2609 } 2608 2610 /*}}}*/ 2611 /*FUNCTION Penta::SetwiseNodeConnectivity{{{*/ 2612 void Penta::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){ 2613 2614 /*Output */ 2615 int d_nz = 0; 2616 int o_nz = 0; 2617 2618 /*Loop over all nodes*/ 2619 for(int i=0;i<6;i++){ 2620 2621 if(!flags[this->nodes[i]->Sid()]){ 2622 2623 /*flag current node so that no other element processes it*/ 2624 flags[this->nodes[i]->Sid()]=true; 2625 2626 /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/ 2627 switch(set2_enum){ 2628 case FsetEnum: 2629 if(nodes[i]->indexing.fsize){ 2630 if(this->nodes[i]->IsClone()) 2631 o_nz += 1; 2632 else 2633 d_nz += 1; 2634 } 2635 break; 2636 case GsetEnum: 2637 if(nodes[i]->indexing.gsize){ 2638 if(this->nodes[i]->IsClone()) 2639 o_nz += 1; 2640 else 2641 d_nz += 1; 2642 } 2643 break; 2644 case SsetEnum: 2645 if(nodes[i]->indexing.ssize){ 2646 if(this->nodes[i]->IsClone()) 2647 o_nz += 1; 2648 else 2649 d_nz += 1; 2650 } 2651 break; 2652 default: _error_("not supported"); 2653 } 2654 } 2655 } 2656 2657 /*Assign output pointers: */ 2658 *pd_nz=d_nz; 2659 *po_nz=o_nz; 2660 } 2661 /*}}}*/ 2609 2662 /*FUNCTION Penta::SpawnTria {{{*/ 2610 2663 Tria* Penta::SpawnTria(int g0, int g1, int g2){ … … 2663 2716 IssmDouble b_neg[NUMVERTICES]; // Hs-SMB relation paremeter 2664 2717 IssmDouble Hc[NUMVERTICES]; // elevation of transition between accumulation regime and ablation regime 2718 IssmDouble Href[NUMVERTICES]; // reference elevation from which deviations are used to calculate the SMB adjustment 2719 IssmDouble Smbref[NUMVERTICES]; // reference SMB to which deviations are added 2665 2720 IssmDouble smb_pos_max[NUMVERTICES]; // maximum SMB value in the accumulation regime 2666 2721 IssmDouble smb_pos_min[NUMVERTICES]; // minimum SMB value in the accumulation regime … … 2673 2728 /*Recover SmbGradients*/ 2674 2729 GetInputListOnVertices(&Hc[0],SurfaceforcingsHcEnum); 2730 GetInputListOnVertices(&Href[0],SurfaceforcingsHrefEnum); 2731 GetInputListOnVertices(&Smbref[0],SurfaceforcingsSmbrefEnum); 2675 2732 GetInputListOnVertices(&smb_pos_max[0],SurfaceforcingsSmbPosMaxEnum); 2676 2733 GetInputListOnVertices(&smb_pos_min[0],SurfaceforcingsSmbPosMinEnum); … … 2679 2736 GetInputListOnVertices(&a_neg[0],SurfaceforcingsANegEnum); 2680 2737 GetInputListOnVertices(&b_neg[0],SurfaceforcingsBNegEnum); 2681 2738 2682 2739 /*Recover surface elevatio at vertices: */ 2683 2740 GetInputListOnVertices(&h[0],ThicknessEnum); … … 2687 2744 rho_ice=matpar->GetRhoIce(); 2688 2745 rho_water=matpar->GetRhoFreshwater(); 2689 2746 2690 2747 // loop over all vertices 2691 2748 for(i=0;i<NUMVERTICES;i++){ 2692 2749 if(s[i]>Hc[i]){ 2693 smb[i]=a_pos[i]+b_pos[i]*s[i]; 2694 if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];} 2695 if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];} 2750 if(Href[i]>Hc[i]){smb[i]=Smbref[i]+b_pos[i]*(s[i]-Href[i]);} 2751 if(Href[i]<=Hc[i]){smb[i]=a_pos[i]+b_pos[i]*s[i];} 2752 if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];} 2753 if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];} 2696 2754 } 2697 2755 else{ 2698 smb[i]=a_neg[i]+b_neg[i]*s[i]; 2756 if(Href[i]>Hc[i]){smb[i]=a_neg[i]+b_neg[i]*s[i];} 2757 if(Href[i]<=Hc[i]){smb[i]=Smbref[i]+b_neg[i]*(s[i]-Href[i]);} 2699 2758 } 2700 2759 smb[i]=smb[i]/rho_ice; // SMB in m/y ice 2701 2702 2760 } //end of the loop over the vertices 2703 2761 /*Update inputs*/ … … 2792 2850 minz=xyz_list[0][2]; 2793 2851 maxz=xyz_list[0][2]; 2794 2852 2795 2853 for(i=1;i<NUMVERTICES;i++){ 2796 2854 if (xyz_list[i][0]<minx)minx=xyz_list[i][0]; … … 2974 3032 if (reCast<bool,IssmDouble>(vertices_potentially_ungrounding[nodes[i]->Sid()])){ 2975 3033 vec_nodes_on_iceshelf->SetValue(nodes[i]->Sid(),1,INS_VAL); 2976 3034 2977 3035 /*If node was not on ice shelf, we flipped*/ 2978 3036 if(nodes_on_iceshelf[nodes[i]->Sid()]==0){ … … 2991 3049 2992 3050 /*Intermediaries*/ 2993 int iv;2994 3051 IssmDouble phi; 2995 3052 IssmDouble viscosity; 2996 3053 IssmDouble xyz_list[NUMVERTICES][3]; 2997 3054 IssmDouble epsilon[6]; 2998 IssmDouble 2999 IssmDouble 3055 IssmDouble viscousheating[NUMVERTICES]={0,0,0,0,0,0}; 3056 IssmDouble thickness; 3000 3057 GaussPenta *gauss=NULL; 3001 3058 … … 3014 3071 for (int iv=0;iv<NUMVERTICES;iv++){ 3015 3072 gauss->GaussVertex(iv); 3016 3073 3017 3074 thickness_input->GetInputValue(&thickness,gauss); 3018 3075 … … 3020 3077 material->GetViscosity3dStokes(&viscosity,&epsilon[0]); 3021 3078 GetPhi(&phi, &epsilon[0], viscosity); 3022 3023 3079 3024 3080 viscousheating[iv]=phi*thickness; … … 3275 3331 3276 3332 if(IsOnWater() || !IsOnSurface()) return 0.; 3277 3333 3278 3334 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3279 3335 … … 3287 3343 smb_input->GetInputAverage(&smb); 3288 3344 Total_Smb=rho_ice*base*smb;// smb on element in kg s-1 3289 3345 3290 3346 /*Process units: */ 3291 3347 Total_Smb=UnitConversion(Total_Smb,IuToExtEnum,TotalSmbEnum);// smb on element in GigaTon yr-1 3292 3348 3293 3349 /*Return: */ 3294 3350 return Total_Smb; … … 3300 3356 /*FUNCTION Penta::CreateKMatrixEnthalpy {{{*/ 3301 3357 ElementMatrix* Penta::CreateKMatrixEnthalpy(void){ 3302 3358 3303 3359 /*compute all stiffness matrices for this element*/ 3304 3360 ElementMatrix* Ke1=CreateKMatrixEnthalpyVolume(); 3305 3361 ElementMatrix* Ke2=CreateKMatrixEnthalpyShelf(); 3306 3362 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2); 3307 3363 3308 3364 /*clean-up and return*/ 3309 3365 delete Ke1; … … 3320 3376 /*Intermediaries */ 3321 3377 int stabilization; 3322 int i,j, ig,found=0;3323 IssmDouble 3324 IssmDouble 3325 IssmDouble 3326 IssmDouble 3327 IssmDouble 3328 IssmDouble 3329 IssmDouble 3330 IssmDouble 3331 IssmDouble 3332 IssmDouble 3333 IssmDouble 3334 IssmDouble 3335 IssmDouble 3336 IssmDouble 3337 IssmDouble 3338 IssmDouble 3339 IssmDouble 3340 IssmDouble 3378 int i,j,found=0; 3379 IssmDouble Jdet,u,v,w,um,vm,wm; 3380 IssmDouble h,hx,hy,hz,vx,vy,vz,vel; 3381 IssmDouble gravity,rho_ice,rho_water; 3382 IssmDouble epsvel=2.220446049250313e-16; 3383 IssmDouble heatcapacity,thermalconductivity,dt; 3384 IssmDouble pressure,enthalpy; 3385 IssmDouble latentheat,kappa; 3386 IssmDouble tau_parameter,diameter; 3387 IssmDouble xyz_list[NUMVERTICES][3]; 3388 IssmDouble B_conduct[3][numdof]; 3389 IssmDouble B_advec[3][numdof]; 3390 IssmDouble Bprime_advec[3][numdof]; 3391 IssmDouble L[numdof]; 3392 IssmDouble dbasis[3][6]; 3393 IssmDouble D_scalar_conduct,D_scalar_advec; 3394 IssmDouble D_scalar_trans,D_scalar_stab; 3395 IssmDouble D[3][3]; 3396 IssmDouble K[3][3]={0.0}; 3341 3397 Tria* tria=NULL; 3342 3398 GaussPenta *gauss=NULL; … … 3367 3423 /* Start looping on the number of gaussian points: */ 3368 3424 gauss=new GaussPenta(2,2); 3369 for (ig=gauss->begin();ig<gauss->end();ig++){3425 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3370 3426 3371 3427 gauss->GaussPoint(ig); … … 3476 3532 3477 3533 /*Intermediaries */ 3478 int i,j,ig;3479 IssmDouble 3480 IssmDouble 3481 IssmDouble 3482 IssmDouble 3483 IssmDouble 3484 IssmDouble 3485 IssmDouble 3534 int i,j; 3535 IssmDouble mixed_layer_capacity,thermal_exchange_velocity; 3536 IssmDouble rho_ice,rho_water,heatcapacity; 3537 IssmDouble Jdet2d,dt; 3538 IssmDouble xyz_list[NUMVERTICES][3]; 3539 IssmDouble xyz_list_tria[NUMVERTICES2D][3]; 3540 IssmDouble basis[NUMVERTICES]; 3541 IssmDouble D_scalar; 3486 3542 GaussPenta *gauss=NULL; 3487 3543 … … 3502 3558 /* Start looping on the number of gauss (nodes on the bedrock) */ 3503 3559 gauss=new GaussPenta(0,1,2,2); 3504 for (ig=gauss->begin();ig<gauss->end();ig++){3560 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3505 3561 3506 3562 gauss->GaussPoint(ig); 3507 3563 3508 3564 GetTriaJacobianDeterminant(&Jdet2d, &xyz_list_tria[0][0], gauss); 3509 3565 GetNodalFunctionsP1(&basis[0], gauss); 3510 3566 3511 3567 D_scalar=gauss->weight*Jdet2d*rho_water*mixed_layer_capacity*thermal_exchange_velocity/(rho_ice*heatcapacity); 3512 3568 if(reCast<bool,IssmDouble>(dt)) D_scalar=dt*D_scalar; … … 3517 3573 &Ke->values[0],1); 3518 3574 } 3519 3575 3520 3576 /*Clean up and return*/ 3521 3577 delete gauss; … … 3537 3593 /*FUNCTION Penta::CreateKMatrixThermal {{{*/ 3538 3594 ElementMatrix* Penta::CreateKMatrixThermal(void){ 3539 3595 3540 3596 /*compute all stiffness matrices for this element*/ 3541 3597 ElementMatrix* Ke1=CreateKMatrixThermalVolume(); 3542 3598 ElementMatrix* Ke2=CreateKMatrixThermalShelf(); 3543 3599 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2); 3544 3600 3545 3601 /*clean-up and return*/ 3546 3602 delete Ke1; … … 3557 3613 /*Intermediaries */ 3558 3614 int stabilization; 3559 int i,j, ig,found=0;3560 IssmDouble 3561 IssmDouble 3562 IssmDouble 3563 IssmDouble 3564 IssmDouble 3565 IssmDouble 3566 IssmDouble 3567 IssmDouble 3568 IssmDouble 3569 IssmDouble 3570 IssmDouble 3571 IssmDouble 3572 IssmDouble 3573 IssmDouble 3574 IssmDouble 3615 int i,j,found=0; 3616 IssmDouble Jdet,u,v,w,um,vm,wm,vel; 3617 IssmDouble h,hx,hy,hz,vx,vy,vz; 3618 IssmDouble gravity,rho_ice,rho_water,kappa; 3619 IssmDouble heatcapacity,thermalconductivity,dt; 3620 IssmDouble tau_parameter,diameter; 3621 IssmDouble xyz_list[NUMVERTICES][3]; 3622 IssmDouble B_conduct[3][numdof]; 3623 IssmDouble B_advec[3][numdof]; 3624 IssmDouble Bprime_advec[3][numdof]; 3625 IssmDouble L[numdof]; 3626 IssmDouble dbasis[3][6]; 3627 IssmDouble D_scalar_conduct,D_scalar_advec; 3628 IssmDouble D_scalar_trans,D_scalar_stab; 3629 IssmDouble D[3][3]; 3630 IssmDouble K[3][3]={0.0}; 3575 3631 Tria* tria=NULL; 3576 3632 GaussPenta *gauss=NULL; … … 3599 3655 /* Start looping on the number of gaussian points: */ 3600 3656 gauss=new GaussPenta(2,2); 3601 for (ig=gauss->begin();ig<gauss->end();ig++){3657 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3602 3658 3603 3659 gauss->GaussPoint(ig); … … 3704 3760 ElementMatrix* Penta::CreateKMatrixThermalShelf(void){ 3705 3761 3706 3707 3762 /*Constants*/ 3708 3763 const int numdof=NDOF1*NUMVERTICES; 3709 3764 3710 3765 /*Intermediaries */ 3711 int i,j ,ig;3712 IssmDouble 3713 IssmDouble 3714 IssmDouble 3715 IssmDouble 3716 IssmDouble 3717 IssmDouble 3718 IssmDouble 3766 int i,j; 3767 IssmDouble mixed_layer_capacity,thermal_exchange_velocity; 3768 IssmDouble rho_ice,rho_water,heatcapacity; 3769 IssmDouble Jdet2d,dt; 3770 IssmDouble xyz_list[NUMVERTICES][3]; 3771 IssmDouble xyz_list_tria[NUMVERTICES2D][3]; 3772 IssmDouble basis[NUMVERTICES]; 3773 IssmDouble D_scalar; 3719 3774 GaussPenta *gauss=NULL; 3720 3775 … … 3735 3790 /* Start looping on the number of gauss (nodes on the bedrock) */ 3736 3791 gauss=new GaussPenta(0,1,2,2); 3737 for (ig=gauss->begin();ig<gauss->end();ig++){3792 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3738 3793 3739 3794 gauss->GaussPoint(ig); 3740 3795 3741 3796 GetTriaJacobianDeterminant(&Jdet2d, &xyz_list_tria[0][0], gauss); 3742 3797 GetNodalFunctionsP1(&basis[0], gauss); 3743 3798 3744 3799 D_scalar=gauss->weight*Jdet2d*rho_water*mixed_layer_capacity*thermal_exchange_velocity/(heatcapacity*rho_ice); 3745 3800 if(reCast<bool,IssmDouble>(dt)) D_scalar=dt*D_scalar; … … 3750 3805 &Ke->values[0],1); 3751 3806 } 3752 3807 3753 3808 /*Clean up and return*/ 3754 3809 delete gauss; … … 3779 3834 3780 3835 /*Intermediaries*/ 3781 int i,j, ig,found=0;3836 int i,j,found=0; 3782 3837 int friction_type,stabilization; 3783 3838 IssmDouble Jdet,phi,dt; … … 3822 3877 /* Start looping on the number of gaussian points: */ 3823 3878 gauss=new GaussPenta(2,3); 3824 for (ig=gauss->begin();ig<gauss->end();ig++){3879 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3825 3880 3826 3881 gauss->GaussPoint(ig); … … 3875 3930 3876 3931 /*Intermediaries */ 3877 int i,j ,ig;3878 IssmDouble 3879 IssmDouble 3880 IssmDouble 3881 IssmDouble 3882 IssmDouble 3883 IssmDouble 3884 IssmDouble 3932 int i,j; 3933 IssmDouble Jdet2d; 3934 IssmDouble heatcapacity,h_pmp; 3935 IssmDouble mixed_layer_capacity,thermal_exchange_velocity; 3936 IssmDouble rho_ice,rho_water,pressure,dt,scalar_ocean; 3937 IssmDouble xyz_list[NUMVERTICES][3]; 3938 IssmDouble xyz_list_tria[NUMVERTICES2D][3]; 3939 IssmDouble basis[NUMVERTICES]; 3885 3940 GaussPenta* gauss=NULL; 3886 3941 … … 3904 3959 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ 3905 3960 gauss=new GaussPenta(0,1,2,2); 3906 for(i g=gauss->begin();ig<gauss->end();ig++){3961 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3907 3962 3908 3963 gauss->GaussPoint(ig); … … 3932 3987 3933 3988 /*Intermediaries */ 3934 int i,j ,ig;3989 int i,j; 3935 3990 int analysis_type; 3936 IssmDouble 3937 IssmDouble 3938 IssmDouble 3939 IssmDouble 3940 IssmDouble 3941 IssmDouble 3942 IssmDouble 3943 IssmDouble 3991 IssmDouble xyz_list[NUMVERTICES][3]; 3992 IssmDouble xyz_list_tria[NUMVERTICES2D][3]={0.0}; 3993 IssmDouble Jdet2d,dt; 3994 IssmDouble rho_ice,heatcapacity,geothermalflux_value; 3995 IssmDouble basalfriction,alpha2,vx,vy; 3996 IssmDouble scalar,enthalpy,enthalpyup; 3997 IssmDouble pressure,pressureup; 3998 IssmDouble basis[NUMVERTICES]; 3944 3999 Friction* friction=NULL; 3945 4000 GaussPenta* gauss=NULL; … … 3972 4027 gauss=new GaussPenta(0,1,2,2); 3973 4028 gaussup=new GaussPenta(3,4,5,2); 3974 for(i g=gauss->begin();ig<gauss->end();ig++){4029 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3975 4030 3976 4031 gauss->GaussPoint(ig); … … 4042 4097 4043 4098 /*Intermediaries*/ 4044 int i,j, ig,found=0;4099 int i,j,found=0; 4045 4100 int friction_type,stabilization; 4046 4101 IssmDouble Jdet,phi,dt; … … 4078 4133 /* Start looping on the number of gaussian points: */ 4079 4134 gauss=new GaussPenta(2,3); 4080 for (ig=gauss->begin();ig<gauss->end();ig++){4135 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4081 4136 4082 4137 gauss->GaussPoint(ig); … … 4129 4184 4130 4185 /*Intermediaries */ 4131 int i,j ,ig;4132 IssmDouble 4133 IssmDouble 4134 IssmDouble 4135 IssmDouble 4136 IssmDouble 4137 IssmDouble 4138 IssmDouble 4186 int i,j; 4187 IssmDouble Jdet2d; 4188 IssmDouble mixed_layer_capacity,thermal_exchange_velocity; 4189 IssmDouble rho_ice,rho_water,pressure,dt,scalar_ocean; 4190 IssmDouble heatcapacity,t_pmp; 4191 IssmDouble xyz_list[NUMVERTICES][3]; 4192 IssmDouble xyz_list_tria[NUMVERTICES2D][3]; 4193 IssmDouble basis[NUMVERTICES]; 4139 4194 GaussPenta* gauss=NULL; 4140 4195 … … 4158 4213 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ 4159 4214 gauss=new GaussPenta(0,1,2,2); 4160 for(i g=gauss->begin();ig<gauss->end();ig++){4215 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4161 4216 4162 4217 gauss->GaussPoint(ig); … … 4186 4241 4187 4242 /*Intermediaries */ 4188 int i,j ,ig;4243 int i,j; 4189 4244 int analysis_type; 4190 IssmDouble 4191 IssmDouble 4192 IssmDouble 4193 IssmDouble 4194 IssmDouble 4195 IssmDouble 4196 IssmDouble 4245 IssmDouble xyz_list[NUMVERTICES][3]; 4246 IssmDouble xyz_list_tria[NUMVERTICES2D][3]={0.0}; 4247 IssmDouble Jdet2d,dt; 4248 IssmDouble rho_ice,heatcapacity,geothermalflux_value; 4249 IssmDouble basalfriction,alpha2,vx,vy; 4250 IssmDouble basis[NUMVERTICES]; 4251 IssmDouble scalar; 4197 4252 Friction* friction=NULL; 4198 4253 GaussPenta* gauss=NULL; … … 4221 4276 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ 4222 4277 gauss=new GaussPenta(0,1,2,2); 4223 for(i g=gauss->begin();ig<gauss->end();ig++){4278 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4224 4279 4225 4280 gauss->GaussPoint(ig); … … 4410 4465 GetInputListOnVertices(&pressure[0],PressureEnum); 4411 4466 Input* surface_input=inputs->GetInput(SurfaceEnum); _assert_(surface_input); 4412 4467 4413 4468 this->inputs->GetInputValue(&converged,ConvergedEnum); 4414 4469 if(converged){ … … 4419 4474 //if(waterfraction[i]>1) _error_("Water fraction >1 found in solution vector"); 4420 4475 } 4421 4476 4422 4477 this->inputs->AddInput(new PentaP1Input(EnthalpyEnum,values)); 4423 4478 this->inputs->AddInput(new PentaP1Input(WaterfractionEnum,waterfraction)); … … 4463 4518 void Penta::ControlInputGetGradient(Vector<IssmDouble>* gradient,int enum_type,int control_index){ 4464 4519 4465 int doflist1[NUMVERTICES];4520 int vertexpidlist[NUMVERTICES]; 4466 4521 Input* input=NULL; 4467 4522 … … 4474 4529 input=(Input*)material->inputs->GetInput(MaterialsRheologyZEnum); 4475 4530 } 4476 4531 4477 4532 else{ 4478 4533 input=inputs->GetInput(enum_type); … … 4481 4536 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput"); 4482 4537 4483 GradientIndexing(& doflist1[0],control_index);4484 ((ControlInput*)input)->GetGradient(gradient,& doflist1[0]);4538 GradientIndexing(&vertexpidlist[0],control_index); 4539 ((ControlInput*)input)->GetGradient(gradient,&vertexpidlist[0]); 4485 4540 4486 4541 }/*}}}*/ … … 4507 4562 void Penta::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){ 4508 4563 4509 int doflist1[NUMVERTICES];4564 int vertexpidlist[NUMVERTICES]; 4510 4565 IssmDouble grad_list[NUMVERTICES]; 4511 4566 Input* grad_input=NULL; … … 4524 4579 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput"); 4525 4580 4526 GradientIndexing(& doflist1[0],control_index);4527 for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[ doflist1[i]];4581 GradientIndexing(&vertexpidlist[0],control_index); 4582 for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[vertexpidlist[i]]; 4528 4583 grad_input=new PentaP1Input(GradientEnum,grad_list); 4529 4584 ((ControlInput*)input)->SetGradient(grad_input); … … 4587 4642 ElementMatrix* Penta::CreateKMatrixAdjointPattyn(void){ 4588 4643 4589 /*Constants*/4590 const int numdof=NDOF2*NUMVERTICES;4591 4592 4644 /*Intermediaries */ 4593 int i,j ,ig;4645 int i,j; 4594 4646 bool incomplete_adjoint; 4595 IssmDouble 4596 IssmDouble 4597 IssmDouble 4598 IssmDouble 4599 IssmDouble 4600 IssmDouble 4601 IssmDouble 4602 IssmDouble 4603 IssmDouble 4647 IssmDouble xyz_list[NUMVERTICES][3]; 4648 IssmDouble Jdet; 4649 IssmDouble eps1dotdphii,eps1dotdphij; 4650 IssmDouble eps2dotdphii,eps2dotdphij; 4651 IssmDouble mu_prime; 4652 IssmDouble epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 4653 IssmDouble eps1[3],eps2[3]; 4654 IssmDouble phi[NUMVERTICES]; 4655 IssmDouble dphi[3][NUMVERTICES]; 4604 4656 GaussPenta *gauss=NULL; 4605 4657 … … 4616 4668 /* Start looping on the number of gaussian points: */ 4617 4669 gauss=new GaussPenta(5,5); 4618 for (ig=gauss->begin();ig<gauss->end();ig++){4670 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4619 4671 4620 4672 gauss->GaussPoint(ig); … … 4659 4711 4660 4712 /*Intermediaries */ 4661 int i,j ,ig;4713 int i,j; 4662 4714 bool incomplete_adjoint; 4663 IssmDouble xyz_list[NUMVERTICES][3]; 4664 IssmDouble Jdet; 4665 IssmDouble eps1dotdphii,eps1dotdphij; 4666 IssmDouble eps2dotdphii,eps2dotdphij; 4667 IssmDouble eps3dotdphii,eps3dotdphij; 4668 IssmDouble mu_prime; 4669 IssmDouble epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 4670 IssmDouble eps1[3],eps2[3],eps3[3]; 4671 IssmDouble phi[NUMVERTICES]; 4672 IssmDouble dphi[3][NUMVERTICES]; 4715 IssmDouble xyz_list[NUMVERTICES][3]; 4716 IssmDouble Jdet; 4717 IssmDouble eps1dotdphii,eps1dotdphij; 4718 IssmDouble eps2dotdphii,eps2dotdphij; 4719 IssmDouble eps3dotdphii,eps3dotdphij; 4720 IssmDouble mu_prime; 4721 IssmDouble epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 4722 IssmDouble eps1[3],eps2[3],eps3[3]; 4723 IssmDouble dphi[3][NUMVERTICES]; 4673 4724 GaussPenta *gauss=NULL; 4674 4725 … … 4686 4737 /* Start looping on the number of gaussian points: */ 4687 4738 gauss=new GaussPenta(5,5); 4688 for (ig=gauss->begin();ig<gauss->end();ig++){4739 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4689 4740 4690 4741 gauss->GaussPoint(ig); … … 4802 4853 /*get gradient indices*/ 4803 4854 for(int i=0;i<NUMVERTICES;i++){ 4804 indexing[i]=num_controls*this->nodes[i]->GetVertex Dof() + control_index;4855 indexing[i]=num_controls*this->nodes[i]->GetVertexPid() + control_index; 4805 4856 } 4806 4857 … … 4913 4964 void Penta::GradjDragPattyn(Vector<IssmDouble>* gradient,int control_index){ 4914 4965 4915 int i,j ,ig;4966 int i,j; 4916 4967 int analysis_type; 4917 int doflist1[NUMVERTICES];4918 IssmDouble 4919 IssmDouble 4920 IssmDouble 4921 IssmDouble 4922 IssmDouble 4923 IssmDouble 4924 IssmDouble 4925 IssmDouble 4968 int vertexpidlist[NUMVERTICES]; 4969 IssmDouble vx,vy,lambda,mu,alpha_complement,Jdet; 4970 IssmDouble bed,thickness,Neff,drag; 4971 IssmDouble xyz_list[NUMVERTICES][3]; 4972 IssmDouble xyz_list_tria[NUMVERTICES2D][3]={0.0}; 4973 IssmDouble dk[NDOF3]; 4974 IssmDouble grade_g[NUMVERTICES]={0.0}; 4975 IssmDouble grade_g_gaussian[NUMVERTICES]; 4976 IssmDouble basis[6]; 4926 4977 Friction* friction=NULL; 4927 GaussPenta 4978 GaussPenta *gauss=NULL; 4928 4979 4929 4980 /*Gradient is 0 if on shelf or not on bed*/ … … 4932 4983 /*Retrieve all inputs and parameters*/ 4933 4984 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 4934 GradientIndexing(& doflist1[0],control_index);4985 GradientIndexing(&vertexpidlist[0],control_index); 4935 4986 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 4936 4987 for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<2;j++) xyz_list_tria[i][j]=xyz_list[i][j]; … … 4946 4997 /* Start looping on the number of gaussian points: */ 4947 4998 gauss=new GaussPenta(0,1,2,4); 4948 for (ig=gauss->begin();ig<gauss->end();ig++){4999 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4949 5000 4950 5001 gauss->GaussPoint(ig); … … 4974 5025 } 4975 5026 } 4976 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);5027 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 4977 5028 4978 5029 /*Clean up and return*/ … … 4984 5035 void Penta::GradjDragStokes(Vector<IssmDouble>* gradient,int control_index){ 4985 5036 4986 int i,j ,ig;5037 int i,j; 4987 5038 int analysis_type; 4988 int doflist1[NUMVERTICES];4989 IssmDouble 4990 IssmDouble 4991 IssmDouble 4992 IssmDouble 4993 IssmDouble 4994 IssmDouble 4995 IssmDouble 4996 IssmDouble 4997 IssmDouble 4998 IssmDouble 5039 int vertexpidlist[NUMVERTICES]; 5040 IssmDouble bed,thickness,Neff; 5041 IssmDouble lambda,mu,xi,Jdet,vx,vy,vz; 5042 IssmDouble alpha_complement,drag; 5043 IssmDouble surface_normal[3],bed_normal[3]; 5044 IssmDouble xyz_list[NUMVERTICES][3]; 5045 IssmDouble xyz_list_tria[NUMVERTICES2D][3]={0.0}; 5046 IssmDouble dk[NDOF3]; 5047 IssmDouble basis[6]; 5048 IssmDouble grade_g[NUMVERTICES]={0.0}; 5049 IssmDouble grade_g_gaussian[NUMVERTICES]; 4999 5050 Friction* friction=NULL; 5000 5051 GaussPenta* gauss=NULL; … … 5007 5058 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 5008 5059 for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<2;j++) xyz_list_tria[i][j]=xyz_list[i][j]; 5009 GradientIndexing(& doflist1[0],control_index);5060 GradientIndexing(&vertexpidlist[0],control_index); 5010 5061 Input* drag_input =inputs->GetInput(FrictionCoefficientEnum); _assert_(drag_input); 5011 5062 Input* vx_input =inputs->GetInput(VxEnum); _assert_(vx_input); … … 5021 5072 /* Start looping on the number of gaussian points: */ 5022 5073 gauss=new GaussPenta(0,1,2,4); 5023 for(i g=gauss->begin();ig<gauss->end();ig++){5074 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5024 5075 5025 5076 gauss->GaussPoint(ig); … … 5067 5118 } 5068 5119 5069 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);5120 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 5070 5121 5071 5122 delete friction; … … 5494 5545 void Penta::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data){ 5495 5546 5496 int doflist1[NUMVERTICES];5547 int vertexpidlist[NUMVERTICES]; 5497 5548 5498 5549 /*Get out if this is not an element input*/ … … 5500 5551 5501 5552 /*Prepare index list*/ 5502 GradientIndexing(& doflist1[0],control_index);5553 GradientIndexing(&vertexpidlist[0],control_index); 5503 5554 5504 5555 /*Get input (either in element or material)*/ … … 5511 5562 } 5512 5563 5513 ((ControlInput*)input)->GetVectorFromInputs(vector,& doflist1[0],data);5564 ((ControlInput*)input)->GetVectorFromInputs(vector,&vertexpidlist[0],data); 5514 5565 } 5515 5566 /*}}}*/ … … 5518 5569 5519 5570 IssmDouble values[NUMVERTICES]; 5520 int doflist1[NUMVERTICES];5571 int vertexpidlist[NUMVERTICES]; 5521 5572 Input *input = NULL; 5522 5573 Input *new_input = NULL; … … 5526 5577 5527 5578 /*Prepare index list*/ 5528 GradientIndexing(& doflist1[0],control_index);5579 GradientIndexing(&vertexpidlist[0],control_index); 5529 5580 5530 5581 /*Get values on vertices*/ 5531 5582 for (int i=0;i<NUMVERTICES;i++){ 5532 values[i]=vector[ doflist1[i]];5583 values[i]=vector[vertexpidlist[i]]; 5533 5584 } 5534 5585 new_input = new PentaP1Input(control_enum,values); 5535 5536 5586 5537 5587 if(control_enum==MaterialsRheologyBbarEnum){ … … 5554 5604 /*FUNCTION Penta::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);{{{*/ 5555 5605 void Penta::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){ 5556 5606 5557 5607 int i,j; 5558 5608 … … 5569 5619 /*Get values on the 6 vertices*/ 5570 5620 for (i=0;i<6;i++){ 5571 values[i]=vector[this->nodes[i]->Get SidList()]; //careful, vector of values here is not parallel distributed, but serial distributed (from a serial Dakota core!)5621 values[i]=vector[this->nodes[i]->GetVertexSid()]; //careful, vector of values here is not parallel distributed, but serial distributed (from a serial Dakota core!) 5572 5622 } 5573 5623 … … 5581 5631 IssmDouble surface[6]; 5582 5632 IssmDouble bed[6]; 5583 5633 5584 5634 /*retrieve inputs: */ 5585 5635 GetInputListOnVertices(&thickness_init[0],ThicknessEnum); … … 5666 5716 /*FUNCTION Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type);{{{*/ 5667 5717 void Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){ 5668 5718 5669 5719 int i,j,t; 5670 5720 TransientInput* transientinput=NULL; … … 5680 5730 5681 5731 case VertexEnum: 5682 5732 5683 5733 /*Create transient input: */ 5684 5734 5685 5735 parameters->FindParam(&yts,ConstantsYtsEnum); 5686 5736 … … 5689 5739 /*create input values: */ 5690 5740 for(i=0;i<6;i++){ 5691 row=this->nodes[i]->Get SidList();5741 row=this->nodes[i]->GetVertexSid(); 5692 5742 values[i]=(IssmDouble)matrix[ncols*row+t]; 5693 5743 } … … 5753 5803 /*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattyn{{{*/ 5754 5804 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattyn(void){ 5755 5805 5756 5806 /*compute all stiffness matrices for this element*/ 5757 5807 ElementMatrix* Ke1=CreateKMatrixCouplingMacAyealPattynViscous(); 5758 5808 ElementMatrix* Ke2=CreateKMatrixCouplingMacAyealPattynFriction(); 5759 5809 ElementMatrix* Ke=new ElementMatrix(Ke1,Ke2); 5760 5810 5761 5811 /*clean-up and return*/ 5762 5812 delete Ke1; … … 5775 5825 5776 5826 /*Intermediaries */ 5777 int i,j ,ig;5778 IssmDouble 5779 IssmDouble 5780 IssmDouble 5781 IssmDouble 5782 IssmDouble 5783 IssmDouble 5784 IssmDouble 5785 IssmDouble 5786 IssmDouble 5787 IssmDouble 5827 int i,j; 5828 IssmDouble Jdet; 5829 IssmDouble viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity 5830 IssmDouble epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 5831 IssmDouble xyz_list[NUMVERTICES][3]; 5832 IssmDouble B[3][numdofp]; 5833 IssmDouble Bprime[3][numdofm]; 5834 IssmDouble D[3][3]={0.0}; // material matrix, simple scalar matrix. 5835 IssmDouble D_scalar; 5836 IssmDouble Ke_gg[numdofp][numdofm]={0.0}; //local element stiffness matrix 5837 IssmDouble Ke_gg_gaussian[numdofp][numdofm]; //stiffness matrix evaluated at the gaussian point. 5788 5838 GaussPenta *gauss=NULL; 5789 5839 GaussTria *gauss_tria=NULL; … … 5820 5870 gauss=new GaussPenta(5,5); 5821 5871 gauss_tria=new GaussTria(); 5822 for (ig=gauss->begin();ig<gauss->end();ig++){5872 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5823 5873 5824 5874 gauss->GaussPoint(ig); … … 5865 5915 const int numdof = NDOF2 *NUMVERTICES; 5866 5916 const int numdoftotal = NDOF4 *NUMVERTICES; 5867 5917 5868 5918 /*Intermediaries */ 5869 int i,j, ig,analysis_type;5870 IssmDouble 5871 IssmDouble 5872 IssmDouble 5873 IssmDouble 5874 IssmDouble 5875 IssmDouble 5876 IssmDouble 5877 IssmDouble 5878 IssmDouble 5879 IssmDouble 5880 IssmDouble 5919 int i,j,analysis_type; 5920 IssmDouble Jdet2d,slope_magnitude,alpha2; 5921 IssmDouble xyz_list[NUMVERTICES][3]; 5922 IssmDouble xyz_list_tria[NUMVERTICES2D][3]={0.0}; 5923 IssmDouble slope[3]={0.0,0.0,0.0}; 5924 IssmDouble MAXSLOPE=.06; // 6 % 5925 IssmDouble MOUNTAINKEXPONENT=10; 5926 IssmDouble L[2][numdof]; 5927 IssmDouble DL[2][2] ={{ 0,0 },{0,0}}; //for basal drag 5928 IssmDouble DL_scalar; 5929 IssmDouble Ke_gg[numdof][numdof] ={0.0}; 5930 IssmDouble Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag 5881 5931 Friction *friction = NULL; 5882 5932 GaussPenta *gauss=NULL; … … 5913 5963 /* Start looping on the number of gaussian points: */ 5914 5964 gauss=new GaussPenta(0,1,2,2); 5915 for (ig=gauss->begin();ig<gauss->end();ig++){5965 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5916 5966 5917 5967 gauss->GaussPoint(ig); … … 5934 5984 DL_scalar=alpha2*gauss->weight*Jdet2d; 5935 5985 for (i=0;i<2;i++) DL[i][i]=DL_scalar; 5936 5986 5937 5987 /* Do the triple producte tL*D*L: */ 5938 5988 TripleMultiply( &L[0][0],2,numdof,1, … … 5980 6030 5981 6031 /*Intermediaries */ 5982 int i,j ,ig;5983 IssmDouble 5984 IssmDouble 5985 IssmDouble 5986 IssmDouble 5987 IssmDouble 5988 IssmDouble 5989 IssmDouble 5990 IssmDouble 5991 IssmDouble 5992 IssmDouble 5993 IssmDouble 5994 IssmDouble 5995 IssmDouble 5996 IssmDouble 5997 IssmDouble 6032 int i,j; 6033 IssmDouble Jdet; 6034 IssmDouble viscosity,stokesreconditioning; //viscosity 6035 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 6036 IssmDouble xyz_list[NUMVERTICES][3]; 6037 IssmDouble B[4][numdofs+3]; 6038 IssmDouble Bprime[4][numdofm]; 6039 IssmDouble B2[3][numdofm]; 6040 IssmDouble Bprime2[3][numdofs+3]; 6041 IssmDouble D[4][4]={0.0}; // material matrix, simple scalar matrix. 6042 IssmDouble D2[3][3]={0.0}; // material matrix, simple scalar matrix. 6043 IssmDouble D_scalar; 6044 IssmDouble Ke_gg[numdofs][numdofm]={0.0}; //local element stiffness matrix 6045 IssmDouble Ke_gg2[numdofm][numdofs]={0.0}; //local element stiffness matrix 6046 IssmDouble Ke_gg_gaussian[numdofs+3][numdofm]; //stiffness matrix evaluated at the gaussian point. 6047 IssmDouble Ke_gg_gaussian2[numdofm][numdofs+3]; //stiffness matrix evaluated at the gaussian point. 5998 6048 GaussPenta *gauss=NULL; 5999 6049 GaussTria *gauss_tria=NULL; … … 6029 6079 gauss=new GaussPenta(5,5); 6030 6080 gauss_tria=new GaussTria(); 6031 for (ig=gauss->begin();ig<gauss->end();ig++){6081 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6032 6082 6033 6083 gauss->GaussPoint(ig); … … 6086 6136 6087 6137 /*Intermediaries */ 6088 int i,j ,ig;6138 int i,j; 6089 6139 int analysis_type,approximation; 6090 IssmDouble 6091 IssmDouble 6092 IssmDouble 6093 IssmDouble 6094 IssmDouble 6095 IssmDouble 6096 IssmDouble 6097 IssmDouble 6098 IssmDouble 6099 IssmDouble 6100 IssmDouble 6101 IssmDouble 6102 IssmDouble 6103 IssmDouble 6140 IssmDouble stokesreconditioning; 6141 IssmDouble viscosity,alpha2_gauss,Jdet2d; 6142 IssmDouble bed_normal[3]; 6143 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 6144 IssmDouble xyz_list[NUMVERTICES][3]; 6145 IssmDouble xyz_list_tria[NUMVERTICES2D][3]; 6146 IssmDouble LMacAyealStokes[8][numdof2dm]; 6147 IssmDouble LprimeMacAyealStokes[8][numdof2d]; 6148 IssmDouble DLMacAyealStokes[8][8]={0.0}; 6149 IssmDouble LStokesMacAyeal[4][numdof2d]; 6150 IssmDouble LprimeStokesMacAyeal[4][numdof2dm]; 6151 IssmDouble DLStokesMacAyeal[4][4]={0.0}; 6152 IssmDouble Ke_drag_gaussian[numdof2dm][numdof2d]; 6153 IssmDouble Ke_drag_gaussian2[numdof2d][numdof2dm]; 6104 6154 Friction* friction=NULL; 6105 6155 GaussPenta *gauss=NULL; … … 6137 6187 /* Start looping on the number of gaussian points: */ 6138 6188 gauss=new GaussPenta(0,1,2,2); 6139 for (ig=gauss->begin();ig<gauss->end();ig++){6189 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6140 6190 6141 6191 gauss->GaussPoint(ig); … … 6166 6216 DLStokesMacAyeal[2][2]=-alpha2_gauss*gauss->weight*Jdet2d*bed_normal[0]*bed_normal[2]; 6167 6217 DLStokesMacAyeal[3][3]=-alpha2_gauss*gauss->weight*Jdet2d*bed_normal[1]*bed_normal[2]; 6168 6218 6169 6219 TripleMultiply( &LMacAyealStokes[0][0],8,numdof2dm,1, 6170 6220 &DLMacAyealStokes[0][0],8,8,0, … … 6387 6437 6388 6438 /*Intermediaries */ 6389 int i,j, ig,approximation;6439 int i,j,approximation; 6390 6440 IssmDouble Jdet; 6391 6441 IssmDouble viscosity , oldviscosity, newviscosity, viscosity_overshoot; … … 6423 6473 gauss=new GaussPenta(5,5); 6424 6474 gauss_tria=new GaussTria(); 6425 for (ig=gauss->begin();ig<gauss->end();ig++){6475 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6426 6476 6427 6477 gauss->GaussPoint(ig); … … 6638 6688 6639 6689 /*Intermediaries */ 6640 int i,j ,ig;6690 int i,j; 6641 6691 int approximation; 6642 IssmDouble 6643 IssmDouble 6644 IssmDouble 6645 IssmDouble 6646 IssmDouble 6647 IssmDouble 6648 IssmDouble 6649 IssmDouble 6692 IssmDouble xyz_list[NUMVERTICES][3]; 6693 IssmDouble Jdet; 6694 IssmDouble viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity 6695 IssmDouble epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 6696 IssmDouble D_scalar; 6697 IssmDouble D[5][5]={0.0}; // material matrix, simple scalar matrix. 6698 IssmDouble B[5][numdof]; 6699 IssmDouble Bprime[5][numdof]; 6650 6700 Tria* tria=NULL; 6651 6701 GaussPenta *gauss=NULL; … … 6665 6715 /* Start looping on the number of gaussian points: */ 6666 6716 gauss=new GaussPenta(5,5); 6667 for (ig=gauss->begin();ig<gauss->end();ig++){6717 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6668 6718 6669 6719 gauss->GaussPoint(ig); … … 6701 6751 /*Constants*/ 6702 6752 const int numdof = NDOF2*NUMVERTICES; 6703 6753 6704 6754 /*Intermediaries */ 6705 int i,j ,ig;6755 int i,j; 6706 6756 int analysis_type; 6707 IssmDouble 6708 IssmDouble 6709 IssmDouble 6710 IssmDouble 6711 IssmDouble 6712 IssmDouble 6713 IssmDouble 6714 IssmDouble 6715 IssmDouble 6757 IssmDouble xyz_list[NUMVERTICES][3]; 6758 IssmDouble xyz_list_tria[NUMVERTICES2D][3]={0.0}; 6759 IssmDouble slope_magnitude,alpha2,Jdet; 6760 IssmDouble slope[3]={0.0,0.0,0.0}; 6761 IssmDouble MAXSLOPE=.06; // 6 % 6762 IssmDouble MOUNTAINKEXPONENT=10; 6763 IssmDouble L[2][numdof]; 6764 IssmDouble DL[2][2]={{ 0,0 },{0,0}}; //for basal drag 6765 IssmDouble DL_scalar; 6716 6766 Friction *friction = NULL; 6717 6767 GaussPenta *gauss=NULL; … … 6736 6786 /* Start looping on the number of gaussian points: */ 6737 6787 gauss=new GaussPenta(0,1,2,2); 6738 for (ig=gauss->begin();ig<gauss->end();ig++){6788 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6739 6789 6740 6790 gauss->GaussPoint(ig); … … 6752 6802 alpha2=pow((IssmDouble)10,MOUNTAINKEXPONENT); 6753 6803 } 6754 6804 6755 6805 DL_scalar=alpha2*gauss->weight*Jdet; 6756 6806 for (i=0;i<2;i++) DL[i][i]=DL_scalar; 6757 6807 6758 6808 TripleMultiply( &L[0][0],2,numdof,1, 6759 6809 &DL[0][0],2,2,0, … … 6805 6855 6806 6856 /*Intermediaries */ 6807 int i, j,ig,approximation;6808 IssmDouble 6809 IssmDouble 6810 IssmDouble 6811 IssmDouble 6812 IssmDouble 6813 IssmDouble 6814 IssmDouble 6815 IssmDouble 6857 int i,approximation; 6858 IssmDouble Jdet,viscosity,stokesreconditioning; 6859 IssmDouble xyz_list[NUMVERTICES][3]; 6860 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 6861 IssmDouble B[8][27]; 6862 IssmDouble B_prime[8][27]; 6863 IssmDouble D_scalar; 6864 IssmDouble D[8][8]={0.0}; 6865 IssmDouble Ke_temp[27][27]={0.0}; //for the six nodes and the bubble 6816 6866 GaussPenta *gauss=NULL; 6817 6867 … … 6830 6880 /* Start looping on the number of gaussian points: */ 6831 6881 gauss=new GaussPenta(5,5); 6832 for (ig=gauss->begin();ig<gauss->end();ig++){6882 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6833 6883 6834 6884 gauss->GaussPoint(ig); … … 6870 6920 6871 6921 /*Intermediaries */ 6872 int i,j ,ig;6922 int i,j; 6873 6923 int analysis_type,approximation; 6874 IssmDouble 6875 IssmDouble 6876 IssmDouble 6877 IssmDouble 6878 IssmDouble 6879 IssmDouble 6880 IssmDouble 6881 IssmDouble 6924 IssmDouble alpha2,Jdet2d; 6925 IssmDouble stokesreconditioning,viscosity; 6926 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 6927 IssmDouble xyz_list[NUMVERTICES][3]; 6928 IssmDouble xyz_list_tria[NUMVERTICES2D][3]; 6929 IssmDouble LStokes[2][numdof2d]; 6930 IssmDouble DLStokes[2][2]={0.0}; 6931 IssmDouble Ke_drag_gaussian[numdof2d][numdof2d]; 6882 6932 Friction* friction=NULL; 6883 6933 GaussPenta *gauss=NULL; … … 6902 6952 /* Start looping on the number of gaussian points: */ 6903 6953 gauss=new GaussPenta(0,1,2,2); 6904 for (ig=gauss->begin();ig<gauss->end();ig++){6954 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6905 6955 6906 6956 gauss->GaussPoint(ig); … … 6927 6977 /*DO NOT Transform Coordinate System: this stiffness matrix is already expressed in tangential coordinates*/ 6928 6978 //TransformStiffnessMatrixCoord(Ke,nodes,NUMVERTICES,XYZPEnum); 6929 6979 6930 6980 /*Clean up and return*/ 6931 6981 delete gauss; … … 6936 6986 /*FUNCTION Penta::CreateKMatrixDiagnosticVert {{{*/ 6937 6987 ElementMatrix* Penta::CreateKMatrixDiagnosticVert(void){ 6938 6988 6939 6989 /*compute all stiffness matrices for this element*/ 6940 6990 ElementMatrix* Ke1=CreateKMatrixDiagnosticVertVolume(); … … 6956 7006 6957 7007 /*Intermediaries */ 6958 int i,j,ig; 6959 IssmDouble Jdet; 6960 IssmDouble xyz_list[NUMVERTICES][3]; 6961 IssmDouble B[NDOF1][NUMVERTICES]; 6962 IssmDouble Bprime[NDOF1][NUMVERTICES]; 6963 IssmDouble DL_scalar; 7008 IssmDouble Jdet; 7009 IssmDouble xyz_list[NUMVERTICES][3]; 7010 IssmDouble B[NDOF1][NUMVERTICES]; 7011 IssmDouble Bprime[NDOF1][NUMVERTICES]; 7012 IssmDouble DL_scalar; 6964 7013 GaussPenta *gauss=NULL; 6965 7014 … … 6972 7021 /* Start looping on the number of gaussian points: */ 6973 7022 gauss=new GaussPenta(2,2); 6974 for (ig=gauss->begin();ig<gauss->end();ig++){7023 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6975 7024 6976 7025 gauss->GaussPoint(ig); … … 7002 7051 7003 7052 /*Intermediaries */ 7004 int i,j ,ig;7005 IssmDouble 7006 IssmDouble 7007 IssmDouble 7008 IssmDouble 7009 IssmDouble 7053 int i,j; 7054 IssmDouble xyz_list[NUMVERTICES][3]; 7055 IssmDouble xyz_list_tria[NUMVERTICES2D][3]; 7056 IssmDouble surface_normal[3]; 7057 IssmDouble Jdet2d,DL_scalar; 7058 IssmDouble basis[NUMVERTICES]; 7010 7059 GaussPenta *gauss=NULL; 7011 7060 … … 7020 7069 /* Start looping on the number of gaussian points: */ 7021 7070 gauss=new GaussPenta(3,4,5,2); 7022 for (ig=gauss->begin();ig<gauss->end();ig++){7071 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7023 7072 7024 7073 gauss->GaussPoint(ig); … … 7061 7110 7062 7111 /*Intermediaries */ 7063 int i,j ,ig;7112 int i,j; 7064 7113 int approximation; 7065 IssmDouble 7066 IssmDouble 7067 IssmDouble 7068 IssmDouble 7069 IssmDouble 7070 IssmDouble 7071 IssmDouble 7114 IssmDouble viscosity,Jdet; 7115 IssmDouble stokesreconditioning; 7116 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 7117 IssmDouble dw[3]; 7118 IssmDouble xyz_list[NUMVERTICES][3]; 7119 IssmDouble basis[6]; //for the six nodes of the penta 7120 IssmDouble dbasis[3][6]; //for the six nodes of the penta 7072 7121 GaussPenta *gauss=NULL; 7073 7122 … … 7087 7136 /* Start looping on the number of gaussian points: */ 7088 7137 gauss=new GaussPenta(5,5); 7089 for (ig=gauss->begin();ig<gauss->end();ig++){7138 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7090 7139 7091 7140 gauss->GaussPoint(ig); … … 7123 7172 7124 7173 /*Intermediaries*/ 7125 int i,j ,ig;7174 int i,j; 7126 7175 int approximation,analysis_type; 7127 IssmDouble 7128 IssmDouble 7129 IssmDouble 7130 IssmDouble 7131 IssmDouble 7132 IssmDouble 7133 IssmDouble 7134 IssmDouble 7135 IssmDouble 7176 IssmDouble Jdet,Jdet2d; 7177 IssmDouble stokesreconditioning; 7178 IssmDouble bed_normal[3]; 7179 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 7180 IssmDouble viscosity, w, alpha2_gauss; 7181 IssmDouble dw[3]; 7182 IssmDouble xyz_list_tria[NUMVERTICES2D][3]; 7183 IssmDouble xyz_list[NUMVERTICES][3]; 7184 IssmDouble basis[6]; //for the six nodes of the penta 7136 7185 Tria* tria=NULL; 7137 7186 Friction* friction=NULL; … … 7160 7209 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ 7161 7210 gauss=new GaussPenta(0,1,2,2); 7162 for(i g=gauss->begin();ig<gauss->end();ig++){7211 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7163 7212 7164 7213 gauss->GaussPoint(ig); … … 7212 7261 7213 7262 /*Intermediaries */ 7214 int i ,j,ig;7263 int i; 7215 7264 int approximation; 7216 IssmDouble 7217 IssmDouble 7218 IssmDouble 7219 IssmDouble 7220 IssmDouble 7221 IssmDouble 7222 IssmDouble 7265 IssmDouble viscosity,Jdet; 7266 IssmDouble stokesreconditioning; 7267 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 7268 IssmDouble dw[3]; 7269 IssmDouble xyz_list[NUMVERTICES][3]; 7270 IssmDouble basis[6]; //for the six nodes of the penta 7271 IssmDouble dbasis[3][6]; //for the six nodes of the penta 7223 7272 GaussPenta *gauss=NULL; 7224 7273 … … 7238 7287 /* Start looping on the number of gaussian points: */ 7239 7288 gauss=new GaussPenta(5,5); 7240 for (ig=gauss->begin();ig<gauss->end();ig++){7289 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7241 7290 7242 7291 gauss->GaussPoint(ig); … … 7274 7323 7275 7324 /*Intermediaries*/ 7276 int i,j ,ig;7325 int i,j; 7277 7326 int approximation,analysis_type; 7278 IssmDouble 7279 IssmDouble 7280 IssmDouble 7281 IssmDouble 7282 IssmDouble 7283 IssmDouble 7284 IssmDouble 7285 IssmDouble 7286 IssmDouble 7327 IssmDouble Jdet,Jdet2d; 7328 IssmDouble stokesreconditioning; 7329 IssmDouble bed_normal[3]; 7330 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 7331 IssmDouble viscosity, w, alpha2_gauss; 7332 IssmDouble dw[3]; 7333 IssmDouble xyz_list_tria[NUMVERTICES2D][3]; 7334 IssmDouble xyz_list[NUMVERTICES][3]; 7335 IssmDouble basis[6]; //for the six nodes of the penta 7287 7336 Tria* tria=NULL; 7288 7337 Friction* friction=NULL; … … 7311 7360 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ 7312 7361 gauss=new GaussPenta(0,1,2,2); 7313 for(i g=gauss->begin();ig<gauss->end();ig++){7362 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7314 7363 7315 7364 gauss->GaussPoint(ig); … … 7421 7470 ElementVector* Penta::CreatePVectorDiagnosticHutter(void){ 7422 7471 7423 /*Constants*/7424 const int numdofs=NDOF2*NUMVERTICES;7425 7426 7472 /*Intermediaries*/ 7427 int i,j ,k,ig;7473 int i,j; 7428 7474 int node0,node1; 7429 7475 int connectivity[2]; 7430 IssmDouble 7431 IssmDouble 7432 IssmDouble 7433 IssmDouble 7434 IssmDouble z_segment[2],slope[2];7435 IssmDouble 7436 IssmDouble 7437 IssmDouble 7476 IssmDouble Jdet; 7477 IssmDouble xyz_list[NUMVERTICES][3]; 7478 IssmDouble xyz_list_segment[2][3]; 7479 IssmDouble z_list[NUMVERTICES]; 7480 IssmDouble slope[2]; 7481 IssmDouble slope2,constant_part; 7482 IssmDouble rho_ice,gravity,n,B; 7483 IssmDouble ub,vb,z_g,surface,thickness; 7438 7484 GaussPenta* gauss=NULL; 7439 7485 … … 7468 7514 /*Loop on the Gauss points: */ 7469 7515 gauss=new GaussPenta(node0,node1,3); 7470 for(i g=gauss->begin();ig<gauss->end();ig++){7516 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7471 7517 gauss->GaussPoint(ig); 7472 7518 … … 7541 7587 7542 7588 /*Intermediaries*/ 7543 int i,j ,ig;7544 IssmDouble 7545 IssmDouble 7546 IssmDouble 7547 IssmDouble 7548 IssmDouble 7589 int i,j; 7590 IssmDouble Jdet; 7591 IssmDouble slope[3]; //do not put 2! this goes into GetInputDerivativeValue, which addresses slope[3] also! 7592 IssmDouble driving_stress_baseline,thickness; 7593 IssmDouble xyz_list[NUMVERTICES][3]; 7594 IssmDouble basis[6]; 7549 7595 GaussPenta *gauss=NULL; 7550 7596 … … 7559 7605 /* Start looping on the number of gaussian points: */ 7560 7606 gauss=new GaussPenta(2,3); 7561 for (ig=gauss->begin();ig<gauss->end();ig++){7607 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7562 7608 7563 7609 gauss->GaussPoint(ig); … … 7603 7649 7604 7650 /*Intermediaries*/ 7605 int i,j ,ig;7651 int i,j; 7606 7652 int approximation; 7607 IssmDouble Jdet,viscosity; 7608 IssmDouble gravity,rho_ice,stokesreconditioning; 7609 IssmDouble xyz_list[NUMVERTICES][3]; 7610 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 7611 IssmDouble l1l7[7]; //for the six nodes and the bubble 7612 IssmDouble B[8][numdofbubble]; 7613 IssmDouble B_prime[8][numdofbubble]; 7614 IssmDouble B_prime_bubble[8][3]; 7615 IssmDouble D[8][8]={0.0}; 7616 IssmDouble D_scalar; 7617 IssmDouble Pe_gaussian[numdofbubble]={0.0}; //for the six nodes and the bubble 7618 IssmDouble Ke_temp[numdofbubble][3]={0.0}; //for the six nodes and the bubble 7619 IssmDouble Ke_gaussian[numdofbubble][3]; 7653 IssmDouble Jdet,viscosity; 7654 IssmDouble gravity,rho_ice,stokesreconditioning; 7655 IssmDouble xyz_list[NUMVERTICES][3]; 7656 IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 7657 IssmDouble l1l7[7]; //for the six nodes and the bubble 7658 IssmDouble B[8][numdofbubble]; 7659 IssmDouble B_prime[8][numdofbubble]; 7660 IssmDouble B_prime_bubble[8][3]; 7661 IssmDouble D[8][8]={0.0}; 7662 IssmDouble D_scalar; 7663 IssmDouble Pe_gaussian[numdofbubble]={0.0}; //for the six nodes and the bubble 7664 IssmDouble Ke_temp[numdofbubble][3]={0.0}; //for the six nodes and the bubble 7620 7665 GaussPenta *gauss=NULL; 7621 7666 … … 7636 7681 /* Start looping on the number of gaussian points: */ 7637 7682 gauss=new GaussPenta(5,5); 7638 for (ig=gauss->begin();ig<gauss->end();ig++){7683 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7639 7684 7640 7685 gauss->GaussPoint(ig); … … 7680 7725 7681 7726 /*Intermediaries*/ 7682 int i,j ,ig;7727 int i,j; 7683 7728 int approximation,shelf_dampening; 7684 IssmDouble 7685 IssmDouble 7686 IssmDouble 7687 IssmDouble 7688 IssmDouble 7689 IssmDouble 7690 IssmDouble 7691 IssmDouble 7729 IssmDouble gravity,rho_water,bed,water_pressure; 7730 IssmDouble damper,normal_vel,vx,vy,vz,dt; 7731 IssmDouble xyz_list_tria[NUMVERTICES2D][3]; 7732 IssmDouble xyz_list[NUMVERTICES][3]; 7733 IssmDouble bed_normal[3]; 7734 IssmDouble dz[3]; 7735 IssmDouble basis[6]; //for the six nodes of the penta 7736 IssmDouble Jdet2d; 7692 7737 GaussPenta *gauss=NULL; 7693 7738 … … 7712 7757 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ 7713 7758 gauss=new GaussPenta(0,1,2,2); 7714 for(i g=gauss->begin();ig<gauss->end();ig++){7759 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7715 7760 7716 7761 gauss->GaussPoint(ig); … … 7765 7810 7766 7811 /*Intermediaries*/ 7767 int i,ig;7768 7812 int approximation; 7769 7813 IssmDouble Jdet; … … 7789 7833 /* Start looping on the number of gaussian points: */ 7790 7834 gauss=new GaussPenta(2,2); 7791 for (ig=gauss->begin();ig<gauss->end();ig++){7835 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7792 7836 7793 7837 gauss->GaussPoint(ig); … … 7806 7850 dvdy=dv[1]; 7807 7851 7808 for (i=0;i<numdof;i++) pe->values[i] += (dudx+dvdy+dwdz)*Jdet*gauss->weight*basis[i];7852 for(int i=0;i<numdof;i++) pe->values[i] += (dudx+dvdy+dwdz)*Jdet*gauss->weight*basis[i]; 7809 7853 } 7810 7854 … … 7817 7861 ElementVector* Penta::CreatePVectorDiagnosticVertBase(void){ 7818 7862 7819 7820 7863 /*Constants*/ 7821 7864 const int numdof=NDOF1*NUMVERTICES; 7822 7865 7823 7866 /*Intermediaries */ 7824 int i,j ,ig;7867 int i,j; 7825 7868 int approximation; 7826 IssmDouble 7827 IssmDouble 7828 IssmDouble 7829 IssmDouble 7830 IssmDouble 7831 IssmDouble 7869 IssmDouble xyz_list[NUMVERTICES][3]; 7870 IssmDouble xyz_list_tria[NUMVERTICES2D][3]; 7871 IssmDouble Jdet2d; 7872 IssmDouble vx,vy,vz,dbdx,dbdy,basalmeltingvalue; 7873 IssmDouble slope[3]; 7874 IssmDouble basis[NUMVERTICES]; 7832 7875 GaussPenta* gauss=NULL; 7833 7876 … … 7852 7895 /* Start looping on the number of gaussian points: */ 7853 7896 gauss=new GaussPenta(0,1,2,2); 7854 for(i g=gauss->begin();ig<gauss->end();ig++){7897 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7855 7898 7856 7899 gauss->GaussPoint(ig); … … 7940 7983 7941 7984 /*Intermediaries */ 7942 int i,j,ig; 7943 IssmDouble xyz_list[NUMVERTICES][3]; 7944 IssmDouble Jdet; 7945 IssmDouble eps1dotdphii,eps1dotdphij; 7946 IssmDouble eps2dotdphii,eps2dotdphij; 7947 IssmDouble mu_prime; 7948 IssmDouble epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 7949 IssmDouble eps1[3],eps2[3]; 7950 IssmDouble phi[NUMVERTICES]; 7951 IssmDouble dphi[3][NUMVERTICES]; 7985 int i,j; 7986 IssmDouble xyz_list[NUMVERTICES][3]; 7987 IssmDouble Jdet; 7988 IssmDouble eps1dotdphii,eps1dotdphij; 7989 IssmDouble eps2dotdphii,eps2dotdphij; 7990 IssmDouble mu_prime; 7991 IssmDouble epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 7992 IssmDouble eps1[3],eps2[3]; 7993 IssmDouble dphi[3][NUMVERTICES]; 7952 7994 GaussPenta *gauss=NULL; 7953 7995 … … 7962 8004 /* Start looping on the number of gaussian points: */ 7963 8005 gauss=new GaussPenta(5,5); 7964 for (ig=gauss->begin();ig<gauss->end();ig++){8006 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7965 8007 7966 8008 gauss->GaussPoint(ig); … … 8005 8047 8006 8048 /*Intermediaries */ 8007 int i,j,ig; 8008 IssmDouble xyz_list[NUMVERTICES][3]; 8009 IssmDouble Jdet; 8010 IssmDouble eps1dotdphii,eps1dotdphij; 8011 IssmDouble eps2dotdphii,eps2dotdphij; 8012 IssmDouble eps3dotdphii,eps3dotdphij; 8013 IssmDouble mu_prime; 8014 IssmDouble epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 8015 IssmDouble eps1[3],eps2[3],eps3[3]; 8016 IssmDouble phi[NUMVERTICES]; 8017 IssmDouble dphi[3][NUMVERTICES]; 8049 int i,j; 8050 IssmDouble xyz_list[NUMVERTICES][3]; 8051 IssmDouble Jdet; 8052 IssmDouble eps1dotdphii,eps1dotdphij; 8053 IssmDouble eps2dotdphii,eps2dotdphij; 8054 IssmDouble eps3dotdphii,eps3dotdphij; 8055 IssmDouble mu_prime; 8056 IssmDouble epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 8057 IssmDouble eps1[3],eps2[3],eps3[3]; 8058 IssmDouble dphi[3][NUMVERTICES]; 8018 8059 GaussPenta *gauss=NULL; 8019 8060 … … 8029 8070 /* Start looping on the number of gaussian points: */ 8030 8071 gauss=new GaussPenta(5,5); 8031 for (ig=gauss->begin();ig<gauss->end();ig++){8072 for(int ig=gauss->begin();ig<gauss->end();ig++){ 8032 8073 8033 8074 gauss->GaussPoint(ig); … … 8416 8457 penta=penta->GetUpperElement(); _assert_(penta->Id()!=this->id); 8417 8458 } 8418 8459 8419 8460 /*Free ressources:*/ 8420 8461 xDelete<int>(doflist); … … 8688 8729 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticPattyn {{{*/ 8689 8730 void Penta::InputUpdateFromSolutionDiagnosticPattyn(IssmDouble* solution){ 8690 8731 8691 8732 const int numdof=NDOF2*NUMVERTICES; 8692 8733 … … 8856 8897 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticHutter {{{*/ 8857 8898 void Penta::InputUpdateFromSolutionDiagnosticHutter(IssmDouble* solution){ 8858 8899 8859 8900 const int numdof=NDOF2*NUMVERTICES; 8860 8901 … … 8921 8962 8922 8963 const int numdof=NDOF1*NUMVERTICES; 8923 8964 8924 8965 int i; 8925 8966 int approximation; … … 8938 8979 int* doflist = NULL; 8939 8980 8940 8941 8981 /*Get the approximation and do nothing if the element in Stokes or None*/ 8942 8982 inputs->GetInputValue(&approximation,ApproximationEnum); … … 9023 9063 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticStokes {{{*/ 9024 9064 void Penta::InputUpdateFromSolutionDiagnosticStokes(IssmDouble* solution){ 9025 9065 9026 9066 const int numdof=NDOF4*NUMVERTICES; 9027 9067 … … 9063 9103 for(i=0;i<NUMVERTICES;i++) pressure[i]=pressure[i]*stokesreconditioning; 9064 9104 for(i=0;i<NUMVERTICES;i++) vel[i]=pow( pow(vx[i],2.0) + pow(vy[i],2.0) + pow(vz[i],2.0) , 0.5); 9065 9105 9066 9106 /*Now, we have to move the previous inputs to old 9067 9107 * status, otherwise, we'll wipe them off: */ … … 9133 9173 /*}}}*/ 9134 9174 #endif 9135 -
issm/trunk/src/c/classes/objects/Elements/Penta.h
r13395 r13975 34 34 int sid; 35 35 36 Node **nodes; // 6 nodes37 Material *material; // 1 material ice38 Matpar *matpar; // 1 material parameter39 Penta **verticalneighbors; // 2 neighbors: first one under, second one above36 Node **nodes; // 6 nodes 37 Material *material; // 1 material ice 38 Matpar *matpar; // 1 material parameter 39 Penta **verticalneighbors; // 2 neighbors: first one under, second one above 40 40 int horizontalneighborsids[3]; 41 41 42 Parameters *parameters; //pointer to solution parameters42 Parameters *parameters; //pointer to solution parameters 43 43 Inputs *inputs; 44 Results 44 Results *results; 45 45 46 46 /*Penta constructors and destructor: {{{*/ … … 50 50 /*}}}*/ 51 51 /*Object virtual functions definitions: {{{*/ 52 Object* copy(); 53 void DeepEcho(); 54 void Echo(); 55 int ObjectEnum(); 56 int Id(); 57 int MyRank(); 52 Object *copy(); 53 void DeepEcho(); 54 void Echo(); 55 int ObjectEnum(); 56 int Id(); 58 57 /*}}}*/ 59 58 /*Update virtual functions definitions: {{{*/ … … 81 80 void Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters); 82 81 void SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters); 82 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum); 83 83 void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,Vector<IssmDouble>* df); 84 84 void CreatePVector(Vector<IssmDouble>* pf); … … 87 87 void DeleteResults(void); 88 88 int GetNodeIndex(Node* node); 89 void GetNodesSidList(int* sidlist); 90 int GetNumberOfNodes(void); 89 91 void GetSolutionFromInputs(Vector<IssmDouble>* solution); 90 92 IssmDouble GetZcoord(GaussPenta* gauss); 91 93 void GetVectorFromInputs(Vector<IssmDouble>* vector,int name_enum); 92 94 void GetVectorFromResults(Vector<IssmDouble>* vector,int offset,int name_enum,int interp); 93 95 94 96 int Sid(); 95 97 void InputArtificialNoise(int enum_type,IssmDouble min, IssmDouble max); … … 100 102 void InputDuplicate(int original_enum,int new_enum); 101 103 void InputScale(int enum_type,IssmDouble scale_factor); 102 104 103 105 void InputToResult(int enum_type,int step,IssmDouble time); 104 106 void MigrateGroundingLine(IssmDouble* old_floating_ice,IssmDouble* sheet_ungrounding); … … 174 176 ElementVector* CreatePVectorSlope(void); 175 177 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 176 void Get DofList1(int* doflist);177 void Get SidList(int* sidlist);178 void GetVertexPidList(int* doflist); 179 void GetVertexSidList(int* sidlist); 178 180 void GetConnectivityList(int* connectivity); 179 181 int GetElementType(void); -
issm/trunk/src/c/classes/objects/Elements/PentaHook.cpp
r13395 r13975 49 49 /*intermediary: */ 50 50 int matpar_id; 51 51 52 52 /*retrieve parameters: */ 53 53 iomodel->Constant(&matpar_id,MeshNumberofelementsEnum); matpar_id++; … … 70 70 void PentaHook::SetHookNodes(int* node_ids,int analysis_counter){ 71 71 this->hnodes[analysis_counter]= new Hook(node_ids,6); 72 73 72 } 74 73 /*}}}*/ -
issm/trunk/src/c/classes/objects/Elements/PentaHook.h
r13395 r13975 13 13 14 14 public: 15 int numanalyses;//number of analysis types16 Hook ** hnodes;// 6 nodes for each analysis type17 Hook * hmaterial;// 1 ice material18 Hook * hmatpar;// 1 material parameter19 Hook * hneighbors;// 2 elements, first down, second up15 int numanalyses; //number of analysis types 16 Hook **hnodes; // 6 nodes for each analysis type 17 Hook *hmaterial; // 1 ice material 18 Hook *hmatpar; // 1 material parameter 19 Hook *hneighbors; // 2 elements, first down, second up 20 20 21 /* FUNCTION constructors, destructors {{{*/21 /*constructors, destructors*/ 22 22 PentaHook(); 23 23 PentaHook(int in_numanalyses,int material_id, IoModel* iomodel); 24 24 ~PentaHook(); 25 25 26 void SetHookNodes(int* node_ids,int analysis_counter); 26 27 void SpawnTriaHook(TriaHook* triahook,int* indices); 27 28 void InitHookNeighbors(int* element_ids); 28 /*}}}*/29 29 }; 30 30 31 32 31 #endif //ifndef _PENTAHOOK_H_ 33 -
issm/trunk/src/c/classes/objects/Elements/PentaRef.cpp
r13395 r13975 699 699 IssmDouble l1l2l3[NUMNODESP1_2d]; 700 700 701 702 701 /*Get l1l2l3 in actual coordinate system: */ 703 702 l1l2l3[0]=gauss->coord1*(1-gauss->coord4)/2.0; … … 812 811 IssmDouble l1l2l3[NUMNODESP1_2d]; 813 812 814 815 813 /*Get l1l2l3 in actual coordinate system: */ 816 814 l1l2l3[0]=gauss->coord1*(1-gauss->coord4)/2.0; … … 882 880 void PentaRef::GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussPenta* gauss){ 883 881 884 int i,j;885 886 882 /*The Jacobian is constant over the element, discard the gaussian points. 887 883 * J is assumed to have been allocated of size NDOF2xNDOF2.*/ … … 899 895 A3=gauss->coord3; 900 896 901 xi =A2-A1;902 eta =SQRT3*A3;903 zi =gauss->coord4;897 xi = A2-A1; 898 eta = SQRT3*A3; 899 zi = gauss->coord4; 904 900 905 901 x1=*(xyz_list+3*0+0); -
issm/trunk/src/c/classes/objects/Elements/PentaRef.h
r13395 r13975 4 4 */ 5 5 6 7 6 #ifndef _PENTAREF_H_ 8 7 #define _PENTAREF_H_ 9 8 10 9 class PentaRef{ 11 12 10 13 11 public: 14 12 int* element_type_list; //P1CG, P1DG, MINI, P2... 15 13 int element_type; 16 14 17 15 PentaRef(); 18 16 PentaRef(const int nummodels); -
issm/trunk/src/c/classes/objects/Elements/Tria.cpp
r13395 r13975 42 42 :TriaRef(nummodels) 43 43 ,TriaHook(nummodels,index+1,iomodel){ 44 45 int i; 44 46 45 /*id: */ 47 46 this->id=tria_id; … … 127 126 void Tria::AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){ 128 127 129 bool already=false; 130 int i,j; 131 int partition[NUMVERTICES]; 132 int offsetsid[NUMVERTICES]; 133 int offsetdof[NUMVERTICES]; 134 IssmDouble area; 135 IssmDouble mean; 136 IssmDouble values[3]; 128 bool already = false; 129 int i,j; 130 int partition[NUMVERTICES]; 131 int offsetsid[NUMVERTICES]; 132 int offsetdof[NUMVERTICES]; 133 IssmDouble area; 134 IssmDouble mean; 137 135 138 136 /*First, get the area: */ … … 140 138 141 139 /*Figure out the average for this element: */ 142 this->Get SidList(&offsetsid[0]);143 this->Get DofList1(&offsetdof[0]);140 this->GetVertexSidList(&offsetsid[0]); 141 this->GetVertexPidList(&offsetdof[0]); 144 142 mean=0; 145 143 for(i=0;i<NUMVERTICES;i++){ … … 164 162 } 165 163 /*}}}*/ 164 /*FUNCTION Tria::SetwiseNodeConnectivity{{{*/ 165 void Tria::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){ 166 167 /*Output */ 168 int d_nz = 0; 169 int o_nz = 0; 170 171 /*Loop over all nodes*/ 172 for(int i=0;i<3;i++){ 173 174 if(!flags[this->nodes[i]->Sid()]){ 175 176 /*flag current node so that no other element processes it*/ 177 flags[this->nodes[i]->Sid()]=true; 178 179 /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/ 180 switch(set2_enum){ 181 case FsetEnum: 182 if(nodes[i]->indexing.fsize){ 183 if(this->nodes[i]->IsClone()) 184 o_nz += 1; 185 else 186 d_nz += 1; 187 } 188 break; 189 case GsetEnum: 190 if(nodes[i]->indexing.gsize){ 191 if(this->nodes[i]->IsClone()) 192 o_nz += 1; 193 else 194 d_nz += 1; 195 } 196 break; 197 case SsetEnum: 198 if(nodes[i]->indexing.ssize){ 199 if(this->nodes[i]->IsClone()) 200 o_nz += 1; 201 else 202 d_nz += 1; 203 } 204 break; 205 default: _error_("not supported"); 206 } 207 } 208 } 209 210 /*Assign output pointers: */ 211 *pd_nz=d_nz; 212 *po_nz=o_nz; 213 } 214 /*}}}*/ 166 215 /*FUNCTION Tria::CreateKMatrix {{{*/ 167 216 void Tria::CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,Vector<IssmDouble>* df){ … … 175 224 _assert_(this->nodes && this->material && this->matpar && this->parameters && this->inputs); 176 225 /*}}}*/ 177 226 178 227 /*Skip if water element*/ 179 228 if(IsOnWater()) return; … … 231 280 232 281 /*Intermediaries */ 233 int i,j,ig;234 282 IssmDouble heatcapacity,latentheat; 235 283 IssmDouble Jdet,D_scalar; … … 248 296 /* Start looping on the number of gauss (nodes on the bedrock) */ 249 297 gauss=new GaussTria(2); 250 for (ig=gauss->begin();ig<gauss->end();ig++){298 for(int ig=gauss->begin();ig<gauss->end();ig++){ 251 299 252 300 gauss->GaussPoint(ig); … … 290 338 /*Intermediaries */ 291 339 int stabilization; 292 int i,j,ig,dim; 293 IssmDouble Jdettria,DL_scalar,dt,h; 294 IssmDouble vel,vx,vy,dvxdx,dvydy; 295 IssmDouble dvx[2],dvy[2]; 296 IssmDouble v_gauss[2]={0.0}; 297 IssmDouble xyz_list[NUMVERTICES][3]; 298 IssmDouble L[NUMVERTICES]; 299 IssmDouble B[2][NUMVERTICES]; 300 IssmDouble Bprime[2][NUMVERTICES]; 301 IssmDouble K[2][2] ={0.0}; 302 IssmDouble KDL[2][2] ={0.0}; 303 IssmDouble DL[2][2] ={0.0}; 304 IssmDouble DLprime[2][2] ={0.0}; 305 GaussTria *gauss=NULL; 340 int dim; 341 IssmDouble Jdettria,DL_scalar,dt,h; 342 IssmDouble vel,vx,vy,dvxdx,dvydy; 343 IssmDouble dvx[2],dvy[2]; 344 IssmDouble v_gauss[2]={0.0}; 345 IssmDouble xyz_list[NUMVERTICES][3]; 346 IssmDouble L[NUMVERTICES]; 347 IssmDouble B[2][NUMVERTICES]; 348 IssmDouble Bprime[2][NUMVERTICES]; 349 IssmDouble K[2][2] ={0.0}; 350 IssmDouble KDL[2][2] ={0.0}; 351 IssmDouble DL[2][2] ={0.0}; 352 IssmDouble DLprime[2][2] ={0.0}; 306 353 307 354 /*Initialize Element matrix*/ … … 326 373 327 374 /* Start looping on the number of gaussian points: */ 328 gauss=new GaussTria(2);329 for (ig=gauss->begin();ig<gauss->end();ig++){375 GaussTria *gauss=new GaussTria(2); 376 for(int ig=gauss->begin();ig<gauss->end();ig++){ 330 377 331 378 gauss->GaussPoint(ig); … … 409 456 410 457 /*Intermediaries */ 411 int i,j,ig,dim;412 IssmDouble 413 IssmDouble 414 IssmDouble 415 IssmDouble 416 IssmDouble 417 IssmDouble 418 IssmDouble 419 IssmDouble 458 int dim; 459 IssmDouble xyz_list[NUMVERTICES][3]; 460 IssmDouble Jdettria,dt,vx,vy; 461 IssmDouble L[NUMVERTICES]; 462 IssmDouble B[2][NUMVERTICES]; 463 IssmDouble Bprime[2][NUMVERTICES]; 464 IssmDouble DL[2][2]={0.0}; 465 IssmDouble DLprime[2][2]={0.0}; 466 IssmDouble DL_scalar; 420 467 GaussTria *gauss=NULL; 421 468 … … 440 487 /* Start looping on the number of gaussian points: */ 441 488 gauss=new GaussTria(2); 442 for (ig=gauss->begin();ig<gauss->end();ig++){489 for(int ig=gauss->begin();ig<gauss->end();ig++){ 443 490 444 491 gauss->GaussPoint(ig); … … 499 546 500 547 gauss->GaussPoint(ig); 501 548 502 549 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss); 503 550 D=gauss->weight*Jdet; … … 528 575 _assert_(this->nodes && this->material && this->matpar && this->parameters && this->inputs); 529 576 /*}}}*/ 530 577 531 578 /*Skip if water element*/ 532 579 if(IsOnWater()) return; … … 597 644 598 645 /*Intermediaries */ 599 int i,j,ig; 600 IssmDouble Jdettria,dt; 601 IssmDouble surface_mass_balance_g,basal_melting_g,basal_melting_correction_g,thickness_g; 602 IssmDouble xyz_list[NUMVERTICES][3]; 603 IssmDouble L[NUMVERTICES]; 646 IssmDouble Jdettria,dt; 647 IssmDouble surface_mass_balance_g,basal_melting_g,basal_melting_correction_g,thickness_g; 648 IssmDouble xyz_list[NUMVERTICES][3]; 649 IssmDouble L[NUMVERTICES]; 604 650 GaussTria* gauss=NULL; 605 651 … … 618 664 /* Start looping on the number of gaussian points: */ 619 665 gauss=new GaussTria(2); 620 for(i g=gauss->begin();ig<gauss->end();ig++){666 for(int ig=gauss->begin();ig<gauss->end();ig++){ 621 667 622 668 gauss->GaussPoint(ig); … … 633 679 basal_melting_correction_g=0.; 634 680 635 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];681 for(int 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]; 636 682 } 637 683 … … 648 694 649 695 /*Intermediaries */ 650 int i,j,ig; 651 IssmDouble Jdettria,dt; 652 IssmDouble surface_mass_balance_g,basal_melting_g,thickness_g; 653 IssmDouble xyz_list[NUMVERTICES][3]; 654 IssmDouble L[NUMVERTICES]; 696 IssmDouble Jdettria,dt; 697 IssmDouble surface_mass_balance_g,basal_melting_g,thickness_g; 698 IssmDouble xyz_list[NUMVERTICES][3]; 699 IssmDouble L[NUMVERTICES]; 655 700 GaussTria* gauss=NULL; 656 701 … … 667 712 /* Start looping on the number of gaussian points: */ 668 713 gauss=new GaussTria(2); 669 for(i g=gauss->begin();ig<gauss->end();ig++){714 for(int ig=gauss->begin();ig<gauss->end();ig++){ 670 715 671 716 gauss->GaussPoint(ig); … … 678 723 thickness_input->GetInputValue(&thickness_g,gauss); 679 724 680 for(i =0;i<numdof;i++) pe->values[i]+=Jdettria*gauss->weight*(thickness_g+dt*(surface_mass_balance_g-basal_melting_g))*L[i];725 for(int i=0;i<numdof;i++) pe->values[i]+=Jdettria*gauss->weight*(thickness_g+dt*(surface_mass_balance_g-basal_melting_g))*L[i]; 681 726 } 682 727 … … 691 736 /*Constants*/ 692 737 const int numdof=NDOF1*NUMVERTICES; 693 738 694 739 /*Intermediaries */ 695 int i ,j,ig;740 int i; 696 741 int analysis_type; 697 IssmDouble 698 IssmDouble 699 IssmDouble 700 IssmDouble 742 IssmDouble Jdet; 743 IssmDouble xyz_list[NUMVERTICES][3]; 744 IssmDouble slope[2]; 745 IssmDouble basis[3]; 701 746 GaussTria* gauss=NULL; 702 747 … … 714 759 slope_input=inputs->GetInput(BedEnum); _assert_(slope_input); 715 760 } 716 761 717 762 /* Start looping on the number of gaussian points: */ 718 763 gauss=new GaussTria(2); 719 for(i g=gauss->begin();ig<gauss->end();ig++){764 for(int ig=gauss->begin();ig<gauss->end();ig++){ 720 765 721 766 gauss->GaussPoint(ig); … … 785 830 void Tria::ComputeStressTensor(){ 786 831 787 int iv;788 832 IssmDouble xyz_list[NUMVERTICES][3]; 789 833 IssmDouble pressure,viscosity; … … 820 864 sigma_xy[iv]=2*viscosity*epsilon[2]; 821 865 } 822 866 823 867 /*Add Stress tensor components into inputs*/ 824 868 this->inputs->AddInput(new TriaP1Input(StressTensorxxEnum,&sigma_xx[0])); … … 835 879 /*FUNCTION Tria::Configure {{{*/ 836 880 void Tria::Configure(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){ 837 881 838 882 /*go into parameters and get the analysis_counter: */ 839 883 int analysis_counter; … … 894 938 _printLine_("neighboor sids: "); 895 939 _printLine_(" " << horizontalneighborsids[0] << " " << horizontalneighborsids[1] << " " << horizontalneighborsids[2]); 896 940 897 941 return; 898 942 } … … 946 990 this->parameters->FindParam(&Delta18oSurfaceLgm,SurfaceforcingsDelta18oSurfaceEnum,(finaltime-(21000*yts))); 947 991 this->parameters->FindParam(&Delta18oSurfaceTime,SurfaceforcingsDelta18oSurfaceEnum,time); 948 992 949 993 /*Compute the temperature and precipitation*/ 950 994 for(int iv=0;iv<NUMVERTICES;iv++){ … … 1027 1071 x2=xyz_list[1][0]; y2=xyz_list[1][1]; 1028 1072 x3=xyz_list[2][0]; y3=xyz_list[2][1]; 1029 1073 1030 1074 _assert_(x2*y3 - y2*x3 + x1*y2 - y1*x2 + x3*y1 - y3*x1>0); 1031 1075 return (x2*y3 - y2*x3 + x1*y2 - y1*x2 + x3*y1 - y3*x1)/2; … … 1055 1099 } 1056 1100 /*}}}*/ 1057 /*FUNCTION Tria::GetDofList1 {{{*/1058 void Tria::GetDofList1(int* doflist){1059 1060 int i;1061 for(i=0;i<3;i++) doflist[i]=nodes[i]->GetDofList1();1062 1063 }1064 /*}}}*/1065 1101 /*FUNCTION Tria::GetElementType {{{*/ 1066 1102 int Tria::GetElementType(){ … … 1090 1126 } 1091 1127 /*}}}*/ 1128 /*FUNCTION Tria::GetNodesSidList{{{*/ 1129 void Tria::GetNodesSidList(int* sidlist){ 1130 1131 _assert_(sidlist); 1132 _assert_(nodes); 1133 1134 for(int i=0;i<NUMVERTICES;i++){ 1135 sidlist[i]=nodes[i]->Sid(); 1136 } 1137 } 1138 /*}}}*/ 1139 /*FUNCTION Tria::GetNumberOfNodes{{{*/ 1140 int Tria::GetNumberOfNodes(void){ 1141 1142 if(this->nodes==NULL) return 0; 1143 1144 switch(this->element_type){ 1145 case P1Enum: 1146 return 3; 1147 case P1DGEnum: 1148 return 3; 1149 default: 1150 _error_("Element type "<<EnumToStringx(this->element_type)<<" not supported yet"); 1151 } 1152 } 1153 /*}}}*/ 1092 1154 /*FUNCTION Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype) {{{*/ 1093 1155 void Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype){ 1094 1095 /*Intermediaries*/1096 IssmDouble value[NUMVERTICES];1097 GaussTria *gauss = NULL;1098 1156 1099 1157 /*Recover input*/ … … 1105 1163 1106 1164 /* Start looping on the number of vertices: */ 1107 gauss=new GaussTria();1165 GaussTria* gauss=new GaussTria(); 1108 1166 for (int iv=0;iv<NUMVERTICES;iv++){ 1109 1167 gauss->GaussVertex(iv); … … 1118 1176 void Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){ 1119 1177 1120 IssmDouble value[NUMVERTICES];1121 GaussTria *gauss = NULL;1122 1178 Input *input = inputs->GetInput(enumtype); 1123 1179 … … 1127 1183 /* Start looping on the number of vertices: */ 1128 1184 if (input){ 1129 gauss=new GaussTria();1185 GaussTria* gauss=new GaussTria(); 1130 1186 for (int iv=0;iv<NUMVERTICES;iv++){ 1131 1187 gauss->GaussVertex(iv); 1132 1188 input->GetInputValue(&pvalue[iv],gauss); 1133 1189 } 1190 delete gauss; 1134 1191 } 1135 1192 else{ 1136 1193 for (int iv=0;iv<NUMVERTICES;iv++) pvalue[iv]=defaultvalue; 1137 1194 } 1138 1139 /*clean-up*/1140 delete gauss;1141 1195 } 1142 1196 /*}}}*/ … … 1144 1198 void Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue,int index){ 1145 1199 1146 IssmDouble value[NUMVERTICES];1147 GaussTria *gauss = NULL;1148 1200 Input *input = inputs->GetInput(enumtype); 1149 1201 … … 1153 1205 /* Start looping on the number of vertices: */ 1154 1206 if (input){ 1155 gauss=new GaussTria();1207 GaussTria* gauss=new GaussTria(); 1156 1208 for (int iv=0;iv<NUMVERTICES;iv++){ 1157 1209 gauss->GaussVertex(iv); 1158 1210 input->GetInputValue(&pvalue[iv],gauss,index); 1159 1211 } 1212 delete gauss; 1160 1213 } 1161 1214 else{ 1162 1215 for (int iv=0;iv<NUMVERTICES;iv++) pvalue[iv]=defaultvalue; 1163 1216 } 1164 1165 /*clean-up*/1166 delete gauss;1167 1217 } 1168 1218 /*}}}*/ … … 1180 1230 } 1181 1231 /*}}}*/ 1182 /*FUNCTION Tria::GetSidList {{{*/ 1183 void Tria::GetSidList(int* sidlist){ 1184 for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetSidList(); 1232 /*FUNCTION Tria::GetVertexPidList {{{*/ 1233 void Tria::GetVertexPidList(int* doflist){ 1234 1235 int i; 1236 for(i=0;i<3;i++) doflist[i]=nodes[i]->GetVertexPid(); 1237 1238 } 1239 /*}}}*/ 1240 /*FUNCTION Tria::GetVertexSidList {{{*/ 1241 void Tria::GetVertexSidList(int* sidlist){ 1242 for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetVertexSid(); 1185 1243 } 1186 1244 /*}}}*/ … … 1243 1301 void Tria::GetVectorFromInputs(Vector<IssmDouble>* vector,int input_enum){ 1244 1302 1245 int doflist1[NUMVERTICES];1303 int vertexpidlist[NUMVERTICES]; 1246 1304 1247 1305 /*Get out if this is not an element input*/ … … 1249 1307 1250 1308 /*Prepare index list*/ 1251 this->Get DofList1(&doflist1[0]);1309 this->GetVertexPidList(&vertexpidlist[0]); 1252 1310 1253 1311 /*Get input (either in element or material)*/ … … 1256 1314 1257 1315 /*We found the enum. Use its values to fill into the vector, using the vertices ids: */ 1258 input->GetVectorFromInputs(vector,& doflist1[0]);1316 input->GetVectorFromInputs(vector,&vertexpidlist[0]); 1259 1317 } 1260 1318 /*}}}*/ … … 1268 1326 } 1269 1327 if(interp==P1Enum){ 1270 int doflist1[NUMVERTICES];1328 int vertexpidlist[NUMVERTICES]; 1271 1329 int connectivity[NUMVERTICES]; 1272 this->Get SidList(&doflist1[0]);1330 this->GetVertexSidList(&vertexpidlist[0]); 1273 1331 this->GetConnectivityList(&connectivity[0]); 1274 elementresult->GetVectorFromResults(vector,& doflist1[0],&connectivity[0],NUMVERTICES);1332 elementresult->GetVectorFromResults(vector,&vertexpidlist[0],&connectivity[0],NUMVERTICES); 1275 1333 } 1276 1334 else if(interp==P0Enum){ … … 1284 1342 /*FUNCTION Tria::Id {{{*/ 1285 1343 int Tria::Id(){ 1286 1344 1287 1345 return id; 1288 1346 … … 1291 1349 /*FUNCTION Tria::Sid {{{*/ 1292 1350 int Tria::Sid(){ 1293 1351 1294 1352 return sid; 1295 1353 … … 1392 1450 void Tria::InputToResult(int enum_type,int step,IssmDouble time){ 1393 1451 1394 int i;1395 1452 Input *input = NULL; 1396 1453 1397 1454 /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */ 1398 if (enum_type==MaterialsRheologyBbarEnum || enum_type==MaterialsRheologyZbarEnum) input=this->material->inputs->GetInput(enum_type); 1399 else input=this->inputs->GetInput(enum_type); 1455 if (enum_type==MaterialsRheologyBbarEnum || enum_type==MaterialsRheologyZbarEnum) 1456 input=this->material->inputs->GetInput(enum_type); 1457 else 1458 input=this->inputs->GetInput(enum_type); 1400 1459 //if (!input) _error_("Input " << EnumToStringx(enum_type) << " not found in tria->inputs"); 1401 1460 if(!input)return; … … 1404 1463 * object out of the input, with the additional step and time information: */ 1405 1464 this->results->AddObject((Object*)input->SpawnResult(step,time)); 1406 1465 1407 1466 #ifdef _HAVE_CONTROL_ 1408 1467 if(input->ObjectEnum()==ControlInputEnum){ … … 1452 1511 IssmDouble yts; 1453 1512 int num_cm_responses; 1454 1513 1455 1514 /*Get parameters: */ 1456 1515 iomodel->Constant(&yts,ConstantsYtsEnum); … … 1687 1746 /*Get values on the 3 vertices*/ 1688 1747 for (int i=0;i<3;i++){ 1689 values[i]=vector[this->nodes[i]->GetVertex Dof()];1748 values[i]=vector[this->nodes[i]->GetVertexPid()]; 1690 1749 } 1691 1750 … … 1719 1778 /*Check that name is an element input*/ 1720 1779 if (!IsInput(name)) return; 1721 1780 1722 1781 if ((code==5) || (code==1)){ //boolean 1723 1782 this->inputs->AddInput(new BoolInput(name,reCast<bool>(scalar))); … … 1746 1805 int numberofelements; 1747 1806 IssmDouble yts; 1748 1749 1807 1750 1808 /*Fetch parameters: */ … … 1861 1919 /*FUNCTION Tria::IsOnBed {{{*/ 1862 1920 bool Tria::IsOnBed(){ 1863 1921 1864 1922 bool onbed; 1865 1923 inputs->GetInputValue(&onbed,MeshElementonbedEnum); … … 1967 2025 void Tria::MigrateGroundingLine(IssmDouble* old_floating_ice,IssmDouble* sheet_ungrounding){ 1968 2026 1969 int i,migration_style ,unground;2027 int i,migration_style; 1970 2028 bool elementonshelf = false; 1971 2029 IssmDouble bed_hydro,yts,gl_melting_rate; … … 1976 2034 /*Recover info at the vertices: */ 1977 2035 parameters->FindParam(&migration_style,GroundinglineMigrationEnum); 2036 parameters->FindParam(&gl_melting_rate,GroundinglineMeltingRateEnum); 1978 2037 parameters->FindParam(&yts,ConstantsYtsEnum); 1979 2038 GetInputListOnVertices(&h[0],ThicknessEnum); … … 1984 2043 rho_ice=matpar->GetRhoIce(); 1985 2044 density=rho_ice/rho_water; 1986 2045 1987 2046 /*go through vertices, and update inputs, considering them to be TriaVertex type: */ 1988 2047 for(i=0;i<NUMVERTICES;i++){ … … 2025 2084 } 2026 2085 } 2027 2086 2028 2087 /*Add basal melting rate if element just ungrounded*/ 2029 2088 if(!this->IsFloating() && elementonshelf==true){ … … 2038 2097 this->inputs->AddInput(new TriaP1Input(SurfaceEnum,&s[0])); 2039 2098 this->inputs->AddInput(new TriaP1Input(BedEnum,&b[0])); 2040 }2041 /*}}}*/2042 /*FUNCTION Tria::MyRank {{{*/2043 int Tria::MyRank(void){2044 extern int my_rank;2045 return my_rank;2046 2099 } 2047 2100 /*}}}*/ … … 2087 2140 /*recover pointer: */ 2088 2141 row=*prow; 2089 2142 2090 2143 for(i=0;i<3;i++) vertices_ids[i]=nodes[i]->GetVertexId(); //vertices id start at column 3 of the patch. 2091 2144 … … 2269 2322 IssmDouble b_neg[NUMVERTICES]; // Hs-SMB relation paremeter 2270 2323 IssmDouble Hc[NUMVERTICES]; // elevation of transition between accumulation regime and ablation regime 2324 IssmDouble Href[NUMVERTICES]; // reference elevation from which deviations are used to calculate the SMB adjustment 2325 IssmDouble Smbref[NUMVERTICES]; // reference SMB to which deviations are added 2271 2326 IssmDouble smb_pos_max[NUMVERTICES]; // maximum SMB value in the accumulation regime 2272 2327 IssmDouble smb_pos_min[NUMVERTICES]; // minimum SMB value in the accumulation regime … … 2279 2334 /*Recover SmbGradients*/ 2280 2335 GetInputListOnVertices(&Hc[0],SurfaceforcingsHcEnum); 2336 GetInputListOnVertices(&Href[0],SurfaceforcingsHrefEnum); 2337 GetInputListOnVertices(&Smbref[0],SurfaceforcingsSmbrefEnum); 2281 2338 GetInputListOnVertices(&smb_pos_max[0],SurfaceforcingsSmbPosMaxEnum); 2282 2339 GetInputListOnVertices(&smb_pos_min[0],SurfaceforcingsSmbPosMinEnum); … … 2285 2342 GetInputListOnVertices(&a_neg[0],SurfaceforcingsANegEnum); 2286 2343 GetInputListOnVertices(&b_neg[0],SurfaceforcingsBNegEnum); 2287 2344 2288 2345 /*Recover surface elevatio at vertices: */ 2289 2346 GetInputListOnVertices(&h[0],ThicknessEnum); … … 2293 2350 rho_ice=matpar->GetRhoIce(); 2294 2351 rho_water=matpar->GetRhoFreshwater(); 2295 2352 2296 2353 // loop over all vertices 2297 2354 for(i=0;i<NUMVERTICES;i++){ 2298 2355 if(s[i]>Hc[i]){ 2299 smb[i]=a_pos[i]+b_pos[i]*s[i]; 2300 if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];} 2301 if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];} 2356 if(Href[i]>Hc[i]){smb[i]=Smbref[i]+b_pos[i]*(s[i]-Href[i]);} 2357 if(Href[i]<=Hc[i]){smb[i]=a_pos[i]+b_pos[i]*s[i];} 2358 if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];} 2359 if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];} 2302 2360 } 2303 2361 else{ 2304 smb[i]=a_neg[i]+b_neg[i]*s[i]; 2362 if(Href[i]>Hc[i]){smb[i]=a_neg[i]+b_neg[i]*s[i];} 2363 if(Href[i]<=Hc[i]){smb[i]=Smbref[i]+b_neg[i]*(s[i]-Href[i]);} 2305 2364 } 2306 2365 smb[i]=smb[i]/rho_ice; // SMB in m/y ice 2307 } //end of the loop over the vertices 2366 /* printf("s %e \n",s[i]); 2367 printf("Hsref %e \n",Href[i]); 2368 printf("Hc %e \n",Hc[i]); 2369 printf("Smbref %e \n",Smbref[i]); 2370 printf("b_neg %e \n",b_neg[i]); 2371 printf("smb %e \n",smb[i]); 2372 _error_("stop-in-code"); */ 2373 } //end of the loop over the vertices 2308 2374 /*Update inputs*/ 2309 2375 this->inputs->AddInput(new TriaP1Input(SurfaceforcingsMassBalanceEnum,&smb[0])); … … 2312 2378 /*FUNCTION Tria::SetCurrentConfiguration {{{*/ 2313 2379 void Tria::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){ 2314 2380 2315 2381 /*go into parameters and get the analysis_counter: */ 2316 2382 int analysis_counter; … … 2533 2599 if (reCast<bool>(vertices_potentially_ungrounding[nodes[i]->Sid()])){ 2534 2600 vec_nodes_on_iceshelf->SetValue(nodes[i]->Sid(),1,INS_VAL); 2535 2601 2536 2602 /*If node was not on ice shelf, we flipped*/ 2537 2603 if(nodes_on_iceshelf[nodes[i]->Sid()]==0){ … … 2574 2640 IssmDouble Tria::MassFlux( IssmDouble* segment,bool process_units){ 2575 2641 2576 const int numdofs=2; 2577 2578 int i,dim; 2579 IssmDouble mass_flux=0; 2580 IssmDouble xyz_list[NUMVERTICES][3]; 2581 IssmDouble normal[2]; 2582 IssmDouble length,rho_ice; 2583 IssmDouble x1,y1,x2,y2,h1,h2; 2584 IssmDouble vx1,vx2,vy1,vy2; 2642 const int numdofs=2; 2643 int dim; 2644 IssmDouble mass_flux=0; 2645 IssmDouble xyz_list[NUMVERTICES][3]; 2646 IssmDouble normal[2]; 2647 IssmDouble length,rho_ice; 2648 IssmDouble x1,y1,x2,y2,h1,h2; 2649 IssmDouble vx1,vx2,vy1,vy2; 2585 2650 GaussTria* gauss_1=NULL; 2586 2651 GaussTria* gauss_2=NULL; … … 2842 2907 smb_input->GetInputAverage(&smb); // average smb on element in m ice s-1 2843 2908 Total_Smb=rho_ice*base*smb; // smb on element in kg s-1 2844 2909 2845 2910 /*Process units: */ 2846 2911 Total_Smb=UnitConversion(Total_Smb,IuToExtEnum,TotalSmbEnum); // smb on element in GigaTon yr-1 2847 2912 2848 2913 /*Return: */ 2849 2914 return Total_Smb; … … 2860 2925 ElementMatrix* Ke2=CreateKMatrixDiagnosticMacAyealFriction(); 2861 2926 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2); 2862 2927 2863 2928 /*clean-up and return*/ 2864 2929 delete Ke1; … … 2874 2939 2875 2940 /*Intermediaries*/ 2876 int i,j ,ig;2877 IssmDouble 2878 IssmDouble 2879 IssmDouble 2880 IssmDouble 2881 IssmDouble 2882 IssmDouble 2883 IssmDouble 2884 IssmDouble 2941 int i,j; 2942 IssmDouble xyz_list[NUMVERTICES][3]; 2943 IssmDouble viscosity,newviscosity,oldviscosity; 2944 IssmDouble viscosity_overshoot,thickness,Jdet; 2945 IssmDouble epsilon[3],oldepsilon[3]; /* epsilon=[exx,eyy,exy]; */ 2946 IssmDouble B[3][numdof]; 2947 IssmDouble Bprime[3][numdof]; 2948 IssmDouble D[3][3] = {0.0}; 2949 IssmDouble D_scalar; 2885 2950 GaussTria *gauss = NULL; 2886 2951 … … 2899 2964 /* Start looping on the number of gaussian points: */ 2900 2965 gauss=new GaussTria(2); 2901 for (ig=gauss->begin();ig<gauss->end();ig++){2966 for(int ig=gauss->begin();ig<gauss->end();ig++){ 2902 2967 2903 2968 gauss->GaussPoint(ig); … … 2938 3003 2939 3004 /*Intermediaries*/ 2940 int i,j ,ig;3005 int i,j; 2941 3006 int analysis_type; 2942 IssmDouble 2943 IssmDouble 2944 IssmDouble 2945 IssmDouble 2946 IssmDouble 2947 IssmDouble 2948 IssmDouble 2949 IssmDouble 2950 IssmDouble 3007 IssmDouble MAXSLOPE = .06; // 6 % 3008 IssmDouble MOUNTAINKEXPONENT = 10; 3009 IssmDouble slope_magnitude,alpha2; 3010 IssmDouble Jdet; 3011 IssmDouble L[2][numdof]; 3012 IssmDouble DL[2][2] = {{ 0,0 },{0,0}}; 3013 IssmDouble DL_scalar; 3014 IssmDouble slope[2] = {0.0,0.0}; 3015 IssmDouble xyz_list[NUMVERTICES][3]; 2951 3016 Friction *friction = NULL; 2952 3017 GaussTria *gauss = NULL; … … 2969 3034 /* Start looping on the number of gaussian points: */ 2970 3035 gauss=new GaussTria(2); 2971 for (ig=gauss->begin();ig<gauss->end();ig++){3036 for(int ig=gauss->begin();ig<gauss->end();ig++){ 2972 3037 2973 3038 gauss->GaussPoint(ig); … … 2984 3049 DL_scalar=alpha2*gauss->weight*Jdet; 2985 3050 for (i=0;i<2;i++) DL[i][i]=DL_scalar; 2986 3051 2987 3052 TripleMultiply( &L[0][0],2,numdof,1, 2988 3053 &DL[0][0],2,2,0, … … 3028 3093 3029 3094 /*Intermediaries */ 3030 int i,j ,ig;3031 IssmDouble 3032 IssmDouble 3033 IssmDouble 3034 IssmDouble 3035 IssmDouble 3036 IssmDouble 3095 int i,j; 3096 IssmDouble driving_stress_baseline,thickness; 3097 IssmDouble Jdet; 3098 IssmDouble xyz_list[NUMVERTICES][3]; 3099 IssmDouble slope[2]; 3100 IssmDouble basis[3]; 3101 IssmDouble pe_g_gaussian[numdof]; 3037 3102 GaussTria* gauss=NULL; 3038 3103 … … 3048 3113 /* Start looping on the number of gaussian points: */ 3049 3114 gauss=new GaussTria(2); 3050 for(i g=gauss->begin();ig<gauss->end();ig++){3115 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3051 3116 3052 3117 gauss->GaussPoint(ig); … … 3132 3197 3133 3198 /*Intermediaries */ 3134 int i,j ,ig;3135 IssmDouble 3136 IssmDouble 3137 IssmDouble 3138 IssmDouble 3139 IssmDouble 3140 IssmDouble 3141 IssmDouble 3142 IssmDouble 3143 IssmDouble 3199 int i,j; 3200 IssmDouble xyz_list[NUMVERTICES][3]; 3201 IssmDouble Jdet,thickness; 3202 IssmDouble eps1dotdphii,eps1dotdphij; 3203 IssmDouble eps2dotdphii,eps2dotdphij; 3204 IssmDouble mu_prime; 3205 IssmDouble epsilon[3];/* epsilon=[exx,eyy,exy];*/ 3206 IssmDouble eps1[2],eps2[2]; 3207 IssmDouble phi[NUMVERTICES]; 3208 IssmDouble dphi[2][NUMVERTICES]; 3144 3209 GaussTria *gauss=NULL; 3145 3210 … … 3155 3220 /* Start looping on the number of gaussian points: */ 3156 3221 gauss=new GaussTria(2); 3157 for (ig=gauss->begin();ig<gauss->end();ig++){3222 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3158 3223 3159 3224 gauss->GaussPoint(ig); … … 3271 3336 /*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHoriz {{{*/ 3272 3337 void Tria::InputUpdateFromSolutionDiagnosticHoriz(IssmDouble* solution){ 3273 3338 3274 3339 const int numdof=NDOF2*NUMVERTICES; 3275 3340 … … 3284 3349 IssmDouble pressure[NUMVERTICES]; 3285 3350 IssmDouble thickness[NUMVERTICES]; 3286 3351 3287 3352 /*Get dof list: */ 3288 3353 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); … … 3334 3399 /*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHutter {{{*/ 3335 3400 void Tria::InputUpdateFromSolutionDiagnosticHutter(IssmDouble* solution){ 3336 3401 3337 3402 const int numdof=NDOF2*NUMVERTICES; 3338 3403 3339 3404 int i; 3340 3405 int* doflist=NULL; … … 3347 3412 IssmDouble pressure[NUMVERTICES]; 3348 3413 IssmDouble thickness[NUMVERTICES]; 3349 3414 3350 3415 /*Get dof list: */ 3351 3416 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); … … 3432 3497 void Tria::ControlInputGetGradient(Vector<IssmDouble>* gradient,int enum_type,int control_index){ 3433 3498 3434 int doflist1[NUMVERTICES];3499 int vertexpidlist[NUMVERTICES]; 3435 3500 Input* input=NULL; 3436 3501 … … 3444 3509 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput"); 3445 3510 3446 GradientIndexing(& doflist1[0],control_index);3447 ((ControlInput*)input)->GetGradient(gradient,& doflist1[0]);3511 GradientIndexing(&vertexpidlist[0],control_index); 3512 ((ControlInput*)input)->GetGradient(gradient,&vertexpidlist[0]); 3448 3513 3449 3514 }/*}}}*/ … … 3467 3532 void Tria::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){ 3468 3533 3469 int doflist1[NUMVERTICES];3534 int vertexpidlist[NUMVERTICES]; 3470 3535 IssmDouble grad_list[NUMVERTICES]; 3471 3536 Input* grad_input=NULL; … … 3481 3546 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput"); 3482 3547 3483 GradientIndexing(& doflist1[0],control_index);3484 for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[ doflist1[i]];3548 GradientIndexing(&vertexpidlist[0],control_index); 3549 for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[vertexpidlist[i]]; 3485 3550 grad_input=new TriaP1Input(GradientEnum,grad_list); 3486 3551 … … 3555 3620 void Tria::GradjBGradient(Vector<IssmDouble>* gradient,int weight_index,int control_index){ 3556 3621 3557 int i ,ig;3558 int doflist1[NUMVERTICES];3559 IssmDouble 3560 IssmDouble 3561 IssmDouble 3562 IssmDouble 3563 IssmDouble 3622 int i; 3623 int vertexpidlist[NUMVERTICES]; 3624 IssmDouble Jdet,weight; 3625 IssmDouble xyz_list[NUMVERTICES][3]; 3626 IssmDouble dbasis[NDOF2][NUMVERTICES]; 3627 IssmDouble dk[NDOF2]; 3628 IssmDouble grade_g[NUMVERTICES]={0.0}; 3564 3629 GaussTria *gauss=NULL; 3565 3630 3566 3631 /*Retrieve all inputs we will be needing: */ 3567 3632 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3568 GradientIndexing(& doflist1[0],control_index);3633 GradientIndexing(&vertexpidlist[0],control_index); 3569 3634 Input* rheologyb_input=material->inputs->GetInput(MaterialsRheologyBbarEnum); _assert_(rheologyb_input); 3570 3635 Input* weights_input=inputs->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); … … 3572 3637 /* Start looping on the number of gaussian points: */ 3573 3638 gauss=new GaussTria(2); 3574 for (ig=gauss->begin();ig<gauss->end();ig++){3639 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3575 3640 3576 3641 gauss->GaussPoint(ig); … … 3586 3651 for (i=0;i<NUMVERTICES;i++) grade_g[i]+=-weight*Jdet*gauss->weight*(dbasis[0][i]*dk[0]+dbasis[1][i]*dk[1]); 3587 3652 } 3588 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);3653 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 3589 3654 3590 3655 /*Clean up and return*/ … … 3595 3660 void Tria::GradjZGradient(Vector<IssmDouble>* gradient,int weight_index,int control_index){ 3596 3661 3597 int i ,ig;3598 int doflist1[NUMVERTICES];3599 IssmDouble 3600 IssmDouble 3601 IssmDouble 3602 IssmDouble 3603 IssmDouble 3662 int i; 3663 int vertexpidlist[NUMVERTICES]; 3664 IssmDouble Jdet,weight; 3665 IssmDouble xyz_list[NUMVERTICES][3]; 3666 IssmDouble dbasis[NDOF2][NUMVERTICES]; 3667 IssmDouble dk[NDOF2]; 3668 IssmDouble grade_g[NUMVERTICES]={0.0}; 3604 3669 GaussTria *gauss=NULL; 3605 3670 3606 3671 /*Retrieve all inputs we will be needing: */ 3607 3672 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3608 GradientIndexing(& doflist1[0],control_index);3673 GradientIndexing(&vertexpidlist[0],control_index); 3609 3674 Input* rheologyz_input=material->inputs->GetInput(MaterialsRheologyZbarEnum); _assert_(rheologyz_input); 3610 3675 Input* weights_input=inputs->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); … … 3612 3677 /* Start looping on the number of gaussian points: */ 3613 3678 gauss=new GaussTria(2); 3614 for (ig=gauss->begin();ig<gauss->end();ig++){3679 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3615 3680 3616 3681 gauss->GaussPoint(ig); … … 3626 3691 for (i=0;i<NUMVERTICES;i++) grade_g[i]+=-weight*Jdet*gauss->weight*(dbasis[0][i]*dk[0]+dbasis[1][i]*dk[1]); 3627 3692 } 3628 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);3693 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 3629 3694 3630 3695 /*Clean up and return*/ … … 3636 3701 3637 3702 /*Intermediaries*/ 3638 int i ,ig;3703 int i; 3639 3704 int doflist[NUMVERTICES]; 3640 IssmDouble 3641 IssmDouble 3642 IssmDouble 3643 IssmDouble 3644 IssmDouble 3645 IssmDouble 3705 IssmDouble vx,vy,lambda,mu,thickness,Jdet; 3706 IssmDouble viscosity_complement; 3707 IssmDouble dvx[NDOF2],dvy[NDOF2],dadjx[NDOF2],dadjy[NDOF2],dB[NDOF2]; 3708 IssmDouble xyz_list[NUMVERTICES][3]; 3709 IssmDouble basis[3],epsilon[3]; 3710 IssmDouble grad[NUMVERTICES]={0.0}; 3646 3711 GaussTria *gauss = NULL; 3647 3712 … … 3660 3725 /* Start looping on the number of gaussian points: */ 3661 3726 gauss=new GaussTria(4); 3662 for (ig=gauss->begin();ig<gauss->end();ig++){3727 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3663 3728 3664 3729 gauss->GaussPoint(ig); … … 3693 3758 3694 3759 /*Intermediaries*/ 3695 int i ,ig;3760 int i; 3696 3761 int doflist[NUMVERTICES]; 3697 IssmDouble 3698 IssmDouble 3699 IssmDouble 3700 IssmDouble 3701 IssmDouble 3702 IssmDouble 3762 IssmDouble vx,vy,lambda,mu,thickness,Jdet; 3763 IssmDouble viscosity_complement; 3764 IssmDouble dvx[NDOF2],dvy[NDOF2],dadjx[NDOF2],dadjy[NDOF2],dZ[NDOF2]; 3765 IssmDouble xyz_list[NUMVERTICES][3]; 3766 IssmDouble basis[3],epsilon[3]; 3767 IssmDouble grad[NUMVERTICES]={0.0}; 3703 3768 GaussTria *gauss = NULL; 3704 3769 … … 3717 3782 /* Start looping on the number of gaussian points: */ 3718 3783 gauss=new GaussTria(4); 3719 for (ig=gauss->begin();ig<gauss->end();ig++){3784 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3720 3785 3721 3786 gauss->GaussPoint(ig); … … 3749 3814 void Tria::GradjDragMacAyeal(Vector<IssmDouble>* gradient,int control_index){ 3750 3815 3751 int i ,ig;3816 int i; 3752 3817 int analysis_type; 3753 int doflist1[NUMVERTICES];3818 int vertexpidlist[NUMVERTICES]; 3754 3819 int connectivity[NUMVERTICES]; 3755 IssmDouble 3756 IssmDouble 3757 IssmDouble 3758 IssmDouble 3759 IssmDouble 3760 IssmDouble 3761 IssmDouble 3762 IssmDouble 3820 IssmDouble vx,vy,lambda,mu,alpha_complement,Jdet; 3821 IssmDouble bed,thickness,Neff,drag; 3822 IssmDouble xyz_list[NUMVERTICES][3]; 3823 IssmDouble dk[NDOF2]; 3824 IssmDouble grade_g[NUMVERTICES]={0.0}; 3825 IssmDouble grade_g_gaussian[NUMVERTICES]; 3826 IssmDouble basis[3]; 3827 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/ 3763 3828 Friction* friction=NULL; 3764 3829 GaussTria *gauss=NULL; … … 3769 3834 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 3770 3835 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3771 GradientIndexing(& doflist1[0],control_index);3836 GradientIndexing(&vertexpidlist[0],control_index); 3772 3837 this->GetConnectivityList(&connectivity[0]); 3773 3838 … … 3784 3849 /* Start looping on the number of gaussian points: */ 3785 3850 gauss=new GaussTria(4); 3786 for (ig=gauss->begin();ig<gauss->end();ig++){3851 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3787 3852 3788 3853 gauss->GaussPoint(ig); … … 3793 3858 /*Build alpha_complement_list: */ 3794 3859 friction->GetAlphaComplement(&alpha_complement, gauss,VxEnum,VyEnum,VzEnum); 3795 3860 3796 3861 dragcoefficient_input->GetInputValue(&drag, gauss); 3797 3862 adjointx_input->GetInputValue(&lambda, gauss); … … 3805 3870 grade_g_gaussian[i]=-2*drag*alpha_complement*((lambda*vx+mu*vy))*Jdet*gauss->weight*basis[i]; 3806 3871 } 3807 3872 3808 3873 /*Add gradje_g_gaussian vector to gradje_g: */ 3809 3874 for(i=0;i<NUMVERTICES;i++){ … … 3827 3892 /*End Analytical gradient*/ 3828 3893 3829 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);3894 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 3830 3895 3831 3896 /*Clean up and return*/ … … 3837 3902 void Tria::GradjDragGradient(Vector<IssmDouble>* gradient, int weight_index,int control_index){ 3838 3903 3839 int i ,ig;3840 int doflist1[NUMVERTICES];3841 IssmDouble 3842 IssmDouble 3843 IssmDouble 3844 IssmDouble 3845 IssmDouble 3904 int i; 3905 int vertexpidlist[NUMVERTICES]; 3906 IssmDouble Jdet,weight; 3907 IssmDouble xyz_list[NUMVERTICES][3]; 3908 IssmDouble dbasis[NDOF2][NUMVERTICES]; 3909 IssmDouble dk[NDOF2]; 3910 IssmDouble grade_g[NUMVERTICES]={0.0}; 3846 3911 GaussTria *gauss=NULL; 3847 3912 … … 3849 3914 if(IsFloating())return; 3850 3915 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3851 GradientIndexing(& doflist1[0],control_index);3916 GradientIndexing(&vertexpidlist[0],control_index); 3852 3917 Input* dragcoefficient_input=inputs->GetInput(FrictionCoefficientEnum); _assert_(dragcoefficient_input); 3853 3918 Input* weights_input=inputs->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); … … 3855 3920 /* Start looping on the number of gaussian points: */ 3856 3921 gauss=new GaussTria(2); 3857 for (ig=gauss->begin();ig<gauss->end();ig++){3922 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3858 3923 3859 3924 gauss->GaussPoint(ig); … … 3872 3937 } 3873 3938 } 3874 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);3939 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 3875 3940 3876 3941 /*Clean up and return*/ … … 3882 3947 3883 3948 /*Intermediaries*/ 3884 int doflist1[NUMVERTICES];3949 int vertexpidlist[NUMVERTICES]; 3885 3950 IssmDouble lambda[NUMVERTICES]; 3886 3951 IssmDouble gradient_g[NUMVERTICES]; 3887 3952 3888 3953 /*Compute Gradient*/ 3889 GradientIndexing(& doflist1[0],control_index);3954 GradientIndexing(&vertexpidlist[0],control_index); 3890 3955 GetInputListOnVertices(&lambda[0],AdjointEnum); 3891 3956 for(int i=0;i<NUMVERTICES;i++) gradient_g[i]=-lambda[i]; 3892 3957 3893 gradient->SetValues(NUMVERTICES, doflist1,gradient_g,INS_VAL);3958 gradient->SetValues(NUMVERTICES,vertexpidlist,gradient_g,INS_VAL); 3894 3959 } 3895 3960 /*}}}*/ … … 3898 3963 3899 3964 /*Intermediaries*/ 3900 int i ,ig;3901 int doflist1[NUMVERTICES];3902 IssmDouble 3903 IssmDouble 3904 IssmDouble 3905 IssmDouble 3906 IssmDouble 3965 int i; 3966 int vertexpidlist[NUMVERTICES]; 3967 IssmDouble thickness,Jdet; 3968 IssmDouble basis[3]; 3969 IssmDouble Dlambda[2],dp[2]; 3970 IssmDouble xyz_list[NUMVERTICES][3]; 3971 IssmDouble grade_g[NUMVERTICES] = {0.0}; 3907 3972 GaussTria *gauss = NULL; 3908 3973 3909 3974 /* Get node coordinates and dof list: */ 3910 3975 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3911 GradientIndexing(& doflist1[0],control_index);3976 GradientIndexing(&vertexpidlist[0],control_index); 3912 3977 3913 3978 /*Retrieve all inputs we will be needing: */ … … 3917 3982 /* Start looping on the number of gaussian points: */ 3918 3983 gauss=new GaussTria(2); 3919 for (ig=gauss->begin();ig<gauss->end();ig++){3984 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3920 3985 3921 3986 gauss->GaussPoint(ig); … … 3923 3988 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss); 3924 3989 GetNodalFunctions(basis, gauss); 3925 3990 3926 3991 adjoint_input->GetInputDerivativeValue(&Dlambda[0],&xyz_list[0][0],gauss); 3927 3992 thickness_input->GetInputValue(&thickness, gauss); … … 3931 3996 } 3932 3997 3933 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);3998 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 3934 3999 3935 4000 /*Clean up and return*/ … … 3941 4006 3942 4007 /*Intermediaries*/ 3943 int i ,ig;3944 int doflist1[NUMVERTICES];3945 IssmDouble 3946 IssmDouble 3947 IssmDouble 3948 IssmDouble 3949 IssmDouble 4008 int i; 4009 int vertexpidlist[NUMVERTICES]; 4010 IssmDouble thickness,Jdet; 4011 IssmDouble basis[3]; 4012 IssmDouble Dlambda[2],dp[2]; 4013 IssmDouble xyz_list[NUMVERTICES][3]; 4014 IssmDouble grade_g[NUMVERTICES] = {0.0}; 3950 4015 GaussTria *gauss = NULL; 3951 4016 3952 4017 /* Get node coordinates and dof list: */ 3953 4018 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3954 GradientIndexing(& doflist1[0],control_index);4019 GradientIndexing(&vertexpidlist[0],control_index); 3955 4020 3956 4021 /*Retrieve all inputs we will be needing: */ … … 3960 4025 /* Start looping on the number of gaussian points: */ 3961 4026 gauss=new GaussTria(2); 3962 for (ig=gauss->begin();ig<gauss->end();ig++){4027 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3963 4028 3964 4029 gauss->GaussPoint(ig); … … 3973 4038 for(i=0;i<NUMVERTICES;i++) grade_g[i]+=thickness*Dlambda[1]*Jdet*gauss->weight*basis[i]; 3974 4039 } 3975 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);4040 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 3976 4041 3977 4042 /*Clean up and return*/ … … 3988 4053 /*get gradient indices*/ 3989 4054 for(int i=0;i<NUMVERTICES;i++){ 3990 indexing[i]=num_controls*this->nodes[i]->GetVertex Dof() + control_index;4055 indexing[i]=num_controls*this->nodes[i]->GetVertexPid() + control_index; 3991 4056 } 3992 4057 … … 3997 4062 3998 4063 /* Intermediaries */ 3999 int ig; 4000 IssmDouble Jelem = 0; 4001 IssmDouble weight; 4002 IssmDouble Jdet; 4003 IssmDouble xyz_list[NUMVERTICES][3]; 4004 IssmDouble dp[NDOF2]; 4064 IssmDouble Jelem = 0; 4065 IssmDouble weight; 4066 IssmDouble Jdet; 4067 IssmDouble xyz_list[NUMVERTICES][3]; 4068 IssmDouble dp[NDOF2]; 4005 4069 GaussTria *gauss = NULL; 4006 4070 … … 4017 4081 /* Start looping on the number of gaussian points: */ 4018 4082 gauss=new GaussTria(2); 4019 for (ig=gauss->begin();ig<gauss->end();ig++){4083 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4020 4084 4021 4085 gauss->GaussPoint(ig); … … 4040 4104 IssmDouble Tria::SurfaceAverageVelMisfit(bool process_units,int weight_index){ 4041 4105 4042 const int numdof=2*NUMVERTICES; 4043 4044 int i,ig; 4045 IssmDouble Jelem=0,S,Jdet; 4046 IssmDouble misfit; 4047 IssmDouble vx,vy,vxobs,vyobs,weight; 4048 IssmDouble xyz_list[NUMVERTICES][3]; 4106 IssmDouble Jelem=0,S,Jdet; 4107 IssmDouble misfit; 4108 IssmDouble vx,vy,vxobs,vyobs,weight; 4109 IssmDouble xyz_list[NUMVERTICES][3]; 4049 4110 GaussTria *gauss=NULL; 4050 4111 … … 4065 4126 /* Start looping on the number of gaussian points: */ 4066 4127 gauss=new GaussTria(3); 4067 for (ig=gauss->begin();ig<gauss->end();ig++){4128 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4068 4129 4069 4130 gauss->GaussPoint(ig); … … 4101 4162 IssmDouble Tria::SurfaceLogVelMisfit(bool process_units,int weight_index){ 4102 4163 4103 const int numdof=NDOF2*NUMVERTICES; 4104 4105 int i,ig; 4106 IssmDouble Jelem=0; 4107 IssmDouble misfit,Jdet; 4108 IssmDouble epsvel=2.220446049250313e-16; 4109 IssmDouble meanvel=3.170979198376458e-05; /*1000 m/yr*/ 4110 IssmDouble velocity_mag,obs_velocity_mag; 4111 IssmDouble xyz_list[NUMVERTICES][3]; 4112 IssmDouble vx,vy,vxobs,vyobs,weight; 4164 IssmDouble Jelem=0; 4165 IssmDouble misfit,Jdet; 4166 IssmDouble epsvel=2.220446049250313e-16; 4167 IssmDouble meanvel=3.170979198376458e-05; /*1000 m/yr*/ 4168 IssmDouble velocity_mag,obs_velocity_mag; 4169 IssmDouble xyz_list[NUMVERTICES][3]; 4170 IssmDouble vx,vy,vxobs,vyobs,weight; 4113 4171 GaussTria *gauss=NULL; 4114 4172 … … 4128 4186 /* Start looping on the number of gaussian points: */ 4129 4187 gauss=new GaussTria(4); 4130 for (ig=gauss->begin();ig<gauss->end();ig++){4188 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4131 4189 4132 4190 gauss->GaussPoint(ig); … … 4166 4224 IssmDouble Tria::SurfaceLogVxVyMisfit(bool process_units,int weight_index){ 4167 4225 4168 const int numdof=NDOF2*NUMVERTICES;4169 4170 int i,ig;4171 4226 int fit=-1; 4172 IssmDouble 4173 IssmDouble 4174 IssmDouble 4175 IssmDouble 4176 IssmDouble 4177 IssmDouble 4227 IssmDouble Jelem=0, S=0; 4228 IssmDouble epsvel=2.220446049250313e-16; 4229 IssmDouble meanvel=3.170979198376458e-05; /*1000 m/yr*/ 4230 IssmDouble misfit, Jdet; 4231 IssmDouble vx,vy,vxobs,vyobs,weight; 4232 IssmDouble xyz_list[NUMVERTICES][3]; 4178 4233 GaussTria *gauss=NULL; 4179 4234 … … 4190 4245 Input* vxobs_input =inputs->GetInput(InversionVxObsEnum); _assert_(vxobs_input); 4191 4246 Input* vyobs_input =inputs->GetInput(InversionVyObsEnum); _assert_(vyobs_input); 4192 4247 4193 4248 /* Start looping on the number of gaussian points: */ 4194 4249 gauss=new GaussTria(4); 4195 for (ig=gauss->begin();ig<gauss->end();ig++){4250 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4196 4251 4197 4252 gauss->GaussPoint(ig); … … 4232 4287 IssmDouble Tria::SurfaceAbsVelMisfit(bool process_units,int weight_index){ 4233 4288 4234 const int numdof=NDOF2*NUMVERTICES; 4235 4236 int i,ig; 4237 IssmDouble Jelem=0; 4238 IssmDouble misfit,Jdet; 4239 IssmDouble vx,vy,vxobs,vyobs,weight; 4240 IssmDouble xyz_list[NUMVERTICES][3]; 4289 IssmDouble Jelem=0; 4290 IssmDouble misfit,Jdet; 4291 IssmDouble vx,vy,vxobs,vyobs,weight; 4292 IssmDouble xyz_list[NUMVERTICES][3]; 4241 4293 GaussTria *gauss=NULL; 4242 4294 … … 4256 4308 /* Start looping on the number of gaussian points: */ 4257 4309 gauss=new GaussTria(2); 4258 for (ig=gauss->begin();ig<gauss->end();ig++){4310 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4259 4311 4260 4312 gauss->GaussPoint(ig); … … 4292 4344 /*FUNCTION Tria::SurfaceRelVelMisfit {{{*/ 4293 4345 IssmDouble Tria::SurfaceRelVelMisfit(bool process_units,int weight_index){ 4294 const int numdof=2*NUMVERTICES; 4295 4296 int i,ig; 4297 IssmDouble Jelem=0; 4298 IssmDouble scalex=1,scaley=1; 4299 IssmDouble misfit,Jdet; 4300 IssmDouble epsvel=2.220446049250313e-16; 4301 IssmDouble meanvel=3.170979198376458e-05; /*1000 m/yr*/ 4302 IssmDouble vx,vy,vxobs,vyobs,weight; 4303 IssmDouble xyz_list[NUMVERTICES][3]; 4346 4347 IssmDouble Jelem=0; 4348 IssmDouble scalex=1,scaley=1; 4349 IssmDouble misfit,Jdet; 4350 IssmDouble epsvel=2.220446049250313e-16; 4351 IssmDouble meanvel=3.170979198376458e-05; /*1000 m/yr*/ 4352 IssmDouble vx,vy,vxobs,vyobs,weight; 4353 IssmDouble xyz_list[NUMVERTICES][3]; 4304 4354 GaussTria *gauss=NULL; 4305 4355 … … 4319 4369 /* Start looping on the number of gaussian points: */ 4320 4370 gauss=new GaussTria(4); 4321 for (ig=gauss->begin();ig<gauss->end();ig++){4371 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4322 4372 4323 4373 gauss->GaussPoint(ig); … … 4358 4408 4359 4409 /* Intermediaries */ 4360 int ig; 4361 IssmDouble Jelem = 0; 4362 IssmDouble weight; 4363 IssmDouble Jdet; 4364 IssmDouble xyz_list[NUMVERTICES][3]; 4365 IssmDouble dp[NDOF2]; 4410 IssmDouble Jelem = 0; 4411 IssmDouble weight; 4412 IssmDouble Jdet; 4413 IssmDouble xyz_list[NUMVERTICES][3]; 4414 IssmDouble dp[NDOF2]; 4366 4415 GaussTria *gauss = NULL; 4367 4416 … … 4378 4427 /* Start looping on the number of gaussian points: */ 4379 4428 gauss=new GaussTria(2); 4380 for (ig=gauss->begin();ig<gauss->end();ig++){4429 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4381 4430 4382 4431 gauss->GaussPoint(ig); … … 4402 4451 4403 4452 /* Intermediaries */ 4404 int ig;4405 4453 IssmDouble Jelem = 0; 4406 4454 IssmDouble weight; … … 4425 4473 /* Start looping on the number of gaussian points: */ 4426 4474 gauss=new GaussTria(2); 4427 for (ig=gauss->begin();ig<gauss->end();ig++){4475 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4428 4476 4429 4477 gauss->GaussPoint(ig); … … 4454 4502 4455 4503 /* Intermediaries */ 4456 int ig;4457 4504 IssmDouble Jelem = 0; 4458 4505 IssmDouble weight; … … 4477 4524 /* Start looping on the number of gaussian points: */ 4478 4525 gauss=new GaussTria(2); 4479 for (ig=gauss->begin();ig<gauss->end();ig++){4526 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4480 4527 4481 4528 gauss->GaussPoint(ig); … … 4506 4553 4507 4554 /*Intermediaries*/ 4508 int i,ig; 4509 IssmDouble thickness,thicknessobs,weight; 4510 IssmDouble Jdet; 4511 IssmDouble Jelem = 0; 4512 IssmDouble xyz_list[NUMVERTICES][3]; 4555 IssmDouble thickness,thicknessobs,weight; 4556 IssmDouble Jdet; 4557 IssmDouble Jelem = 0; 4558 IssmDouble xyz_list[NUMVERTICES][3]; 4513 4559 GaussTria *gauss = NULL; 4514 IssmDouble 4560 IssmDouble dH[2]; 4515 4561 4516 4562 /*If on water, return 0: */ … … 4525 4571 /* Start looping on the number of gaussian points: */ 4526 4572 gauss=new GaussTria(2); 4527 for (ig=gauss->begin();ig<gauss->end();ig++){4573 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4528 4574 4529 4575 gauss->GaussPoint(ig); … … 4554 4600 4555 4601 /*Intermediaries */ 4556 int i, ig,resp;4602 int i,resp; 4557 4603 IssmDouble Jdet; 4558 4604 IssmDouble thickness,thicknessobs,weight; … … 4581 4627 /* Start looping on the number of gaussian points: */ 4582 4628 gauss=new GaussTria(2); 4583 for(i g=gauss->begin();ig<gauss->end();ig++){4629 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4584 4630 4585 4631 gauss->GaussPoint(ig); … … 4641 4687 4642 4688 /*Intermediaries */ 4643 int i,resp ,ig;4689 int i,resp; 4644 4690 int *responses=NULL; 4645 4691 int num_responses; … … 4677 4723 /* Start looping on the number of gaussian points: */ 4678 4724 gauss=new GaussTria(4); 4679 for (ig=gauss->begin();ig<gauss->end();ig++){4725 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4680 4726 4681 4727 gauss->GaussPoint(ig); … … 4823 4869 4824 4870 /*Intermediaries */ 4825 int i,resp ,ig;4871 int i,resp; 4826 4872 int *responses=NULL; 4827 4873 int num_responses; … … 4859 4905 /* Start looping on the number of gaussian points: */ 4860 4906 gauss=new GaussTria(4); 4861 for (ig=gauss->begin();ig<gauss->end();ig++){4907 for(int ig=gauss->begin();ig<gauss->end();ig++){ 4862 4908 4863 4909 gauss->GaussPoint(ig); … … 5006 5052 5007 5053 /* Intermediaries */ 5008 int ig; 5009 IssmDouble Jelem = 0; 5010 IssmDouble weight; 5011 IssmDouble Jdet; 5012 IssmDouble xyz_list[NUMVERTICES][3]; 5013 IssmDouble dp[NDOF2]; 5054 IssmDouble Jelem = 0; 5055 IssmDouble weight; 5056 IssmDouble Jdet; 5057 IssmDouble xyz_list[NUMVERTICES][3]; 5058 IssmDouble dp[NDOF2]; 5014 5059 GaussTria *gauss = NULL; 5015 5060 … … 5026 5071 /* Start looping on the number of gaussian points: */ 5027 5072 gauss=new GaussTria(2); 5028 for (ig=gauss->begin();ig<gauss->end();ig++){5073 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5029 5074 5030 5075 gauss->GaussPoint(ig); … … 5075 5120 5076 5121 /*Intermediaries */ 5077 int i,j ,ig;5122 int i,j; 5078 5123 bool incomplete_adjoint; 5079 IssmDouble xyz_list[NUMVERTICES][3]; 5080 IssmDouble Jdet,thickness; 5081 IssmDouble eps1dotdphii,eps1dotdphij; 5082 IssmDouble eps2dotdphii,eps2dotdphij; 5083 IssmDouble mu_prime; 5084 IssmDouble epsilon[3];/* epsilon=[exx,eyy,exy];*/ 5085 IssmDouble eps1[2],eps2[2]; 5086 IssmDouble phi[NUMVERTICES]; 5087 IssmDouble dphi[2][NUMVERTICES]; 5124 IssmDouble xyz_list[NUMVERTICES][3]; 5125 IssmDouble Jdet,thickness; 5126 IssmDouble eps1dotdphii,eps1dotdphij; 5127 IssmDouble eps2dotdphii,eps2dotdphij; 5128 IssmDouble mu_prime; 5129 IssmDouble epsilon[3];/* epsilon=[exx,eyy,exy];*/ 5130 IssmDouble eps1[2],eps2[2]; 5131 IssmDouble dphi[2][NUMVERTICES]; 5088 5132 GaussTria *gauss=NULL; 5089 5133 … … 5101 5145 /* Start looping on the number of gaussian points: */ 5102 5146 gauss=new GaussTria(2); 5103 for (ig=gauss->begin();ig<gauss->end();ig++){5147 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5104 5148 5105 5149 gauss->GaussPoint(ig); … … 5205 5249 void Tria::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data){ 5206 5250 5207 int doflist1[NUMVERTICES];5251 int vertexpidlist[NUMVERTICES]; 5208 5252 Input *input=NULL; 5209 5253 … … 5212 5256 5213 5257 /*Prepare index list*/ 5214 GradientIndexing(& doflist1[0],control_index);5258 GradientIndexing(&vertexpidlist[0],control_index); 5215 5259 5216 5260 /*Get input (either in element or material)*/ … … 5227 5271 } 5228 5272 5229 ((ControlInput*)input)->GetVectorFromInputs(vector,& doflist1[0],data);5273 ((ControlInput*)input)->GetVectorFromInputs(vector,&vertexpidlist[0],data); 5230 5274 } 5231 5275 /*}}}*/ … … 5234 5278 5235 5279 IssmDouble values[NUMVERTICES]; 5236 int doflist1[NUMVERTICES];5280 int vertexpidlist[NUMVERTICES]; 5237 5281 Input *input = NULL; 5238 5282 Input *new_input = NULL; … … 5242 5286 5243 5287 /*Prepare index list*/ 5244 GradientIndexing(& doflist1[0],control_index);5288 GradientIndexing(&vertexpidlist[0],control_index); 5245 5289 5246 5290 /*Get values on vertices*/ 5247 5291 for (int i=0;i<NUMVERTICES;i++){ 5248 values[i]=vector[ doflist1[i]];5292 values[i]=vector[vertexpidlist[i]]; 5249 5293 } 5250 5294 new_input = new TriaP1Input(control_enum,values); … … 5296 5340 /* compute VelocityFactor */ 5297 5341 VelocityFactor= n_man*CR*CR*rho_water*g/mu_water; 5298 5342 5299 5343 gauss=new GaussTria(); 5300 5344 for (int iv=0;iv<NUMVERTICES;iv++){ … … 5325 5369 5326 5370 /*Constants*/ 5327 const int 5371 const int numdof=NDOF1*NUMVERTICES; 5328 5372 5329 5373 /*Intermediaries */ 5330 IssmDouble diffusivity; 5331 int i,j,ig; 5332 IssmDouble Jdettria,DL_scalar,dt,h; 5333 IssmDouble vx,vy,vel,dvxdx,dvydy; 5334 IssmDouble dvx[2],dvy[2]; 5335 IssmDouble v_gauss[2]={0.0}; 5336 IssmDouble xyz_list[NUMVERTICES][3]; 5337 IssmDouble L[NUMVERTICES]; 5338 IssmDouble B[2][NUMVERTICES]; 5339 IssmDouble Bprime[2][NUMVERTICES]; 5340 IssmDouble K[2][2] ={0.0}; 5341 IssmDouble KDL[2][2] ={0.0}; 5342 IssmDouble DL[2][2] ={0.0}; 5343 IssmDouble DLprime[2][2] ={0.0}; 5374 IssmDouble diffusivity; 5375 IssmDouble Jdettria,DL_scalar,dt,h; 5376 IssmDouble vx,vy,vel,dvxdx,dvydy; 5377 IssmDouble dvx[2],dvy[2]; 5378 IssmDouble v_gauss[2]={0.0}; 5379 IssmDouble xyz_list[NUMVERTICES][3]; 5380 IssmDouble L[NUMVERTICES]; 5381 IssmDouble B[2][NUMVERTICES]; 5382 IssmDouble Bprime[2][NUMVERTICES]; 5383 IssmDouble K[2][2] ={0.0}; 5384 IssmDouble KDL[2][2] ={0.0}; 5385 IssmDouble DL[2][2] ={0.0}; 5386 IssmDouble DLprime[2][2] ={0.0}; 5344 5387 GaussTria *gauss=NULL; 5345 5388 … … 5363 5406 /* Start looping on the number of gaussian points: */ 5364 5407 gauss=new GaussTria(2); 5365 for (ig=gauss->begin();ig<gauss->end();ig++){5408 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5366 5409 5367 5410 gauss->GaussPoint(ig); … … 5433 5476 5434 5477 /*Intermediaries */ 5435 int i,j ,ig;5436 IssmDouble 5437 IssmDouble 5438 IssmDouble 5439 IssmDouble 5440 IssmDouble 5478 int i,j; 5479 IssmDouble Jdettria,dt; 5480 IssmDouble basal_melting_g; 5481 IssmDouble old_watercolumn_g; 5482 IssmDouble xyz_list[NUMVERTICES][3]; 5483 IssmDouble basis[numdof]; 5441 5484 GaussTria* gauss=NULL; 5442 5485 … … 5456 5499 /* Start looping on the number of gaussian points: */ 5457 5500 gauss=new GaussTria(2); 5458 for(i g=gauss->begin();ig<gauss->end();ig++){5501 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5459 5502 5460 5503 gauss->GaussPoint(ig); … … 5469 5512 else for(i=0;i<numdof;i++) pe->values[i]+=Jdettria*gauss->weight*basal_melting_g*basis[i]; 5470 5513 } 5471 5514 5472 5515 /*Clean up and return*/ 5473 5516 delete gauss; … … 5541 5584 /*FUNCTION Tria::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);{{{*/ 5542 5585 void Tria::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){ 5543 5586 5544 5587 int i,j; 5545 5588 … … 5556 5599 /*Get values on the 3 vertices*/ 5557 5600 for (i=0;i<3;i++){ 5558 values[i]=vector[this->nodes[i]->Get SidList()]; //careful, vector of values here is not parallel distributed, but serial distributed (from a serial Dakota core!)5601 values[i]=vector[this->nodes[i]->GetVertexSid()]; //careful, vector of values here is not parallel distributed, but serial distributed (from a serial Dakota core!) 5559 5602 } 5560 5603 … … 5567 5610 IssmDouble surface[3]; 5568 5611 IssmDouble bed[3]; 5569 5612 5570 5613 /*retrieve inputs: */ 5571 5614 GetInputListOnVertices(&thickness_init[0],ThicknessEnum); … … 5640 5683 /*FUNCTION Tria::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type);{{{*/ 5641 5684 void Tria::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){ 5642 5685 5643 5686 int i,j,t; 5644 5687 TransientInput* transientinput=NULL; … … 5654 5697 5655 5698 case VertexEnum: 5656 5699 5657 5700 /*Create transient input: */ 5658 5701 5659 5702 parameters->FindParam(&yts,ConstantsYtsEnum); 5660 5703 for(t=0;t<ncols;t++){ //ncols is the number of times … … 5662 5705 /*create input values: */ 5663 5706 for(i=0;i<3;i++){ 5664 row=this->nodes[i]->Get SidList();5707 row=this->nodes[i]->GetVertexSid(); 5665 5708 values[i]=(IssmDouble)matrix[ncols*row+t]; 5666 5709 } … … 5707 5750 /*Intermediaries */ 5708 5751 int stabilization; 5709 int i,j, ig,dim;5710 IssmDouble 5711 IssmDouble 5712 IssmDouble 5713 IssmDouble 5714 IssmDouble 5715 IssmDouble 5716 IssmDouble 5717 IssmDouble 5718 IssmDouble 5719 IssmDouble 5720 IssmDouble 5752 int i,j,dim; 5753 IssmDouble Jdettria,vx,vy,dvxdx,dvydy,vel,h; 5754 IssmDouble dvx[2],dvy[2]; 5755 IssmDouble xyz_list[NUMVERTICES][3]; 5756 IssmDouble L[NUMVERTICES]; 5757 IssmDouble B[2][NUMVERTICES]; 5758 IssmDouble Bprime[2][NUMVERTICES]; 5759 IssmDouble K[2][2] = {0.0}; 5760 IssmDouble KDL[2][2] = {0.0}; 5761 IssmDouble DL[2][2] = {0.0}; 5762 IssmDouble DLprime[2][2] = {0.0}; 5763 IssmDouble DL_scalar; 5721 5764 GaussTria *gauss = NULL; 5722 5765 … … 5742 5785 /*Start looping on the number of gaussian points:*/ 5743 5786 gauss=new GaussTria(2); 5744 for (ig=gauss->begin();ig<gauss->end();ig++){5787 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5745 5788 5746 5789 gauss->GaussPoint(ig); … … 5816 5859 5817 5860 /*Intermediaries*/ 5818 int i,j, ig,dim;5819 IssmDouble 5820 IssmDouble 5821 IssmDouble 5822 IssmDouble 5823 IssmDouble 5824 IssmDouble 5861 int i,j,dim; 5862 IssmDouble vx,vy,Jdettria; 5863 IssmDouble xyz_list[NUMVERTICES][3]; 5864 IssmDouble B[2][NUMVERTICES]; 5865 IssmDouble Bprime[2][NUMVERTICES]; 5866 IssmDouble DL[2][2]={0.0}; 5867 IssmDouble DL_scalar; 5825 5868 GaussTria *gauss=NULL; 5826 5869 … … 5836 5879 /*Start looping on the number of gaussian points:*/ 5837 5880 gauss=new GaussTria(2); 5838 for (ig=gauss->begin();ig<gauss->end();ig++){5881 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5839 5882 5840 5883 gauss->GaussPoint(ig); … … 5882 5925 /*Constants*/ 5883 5926 const int numdof=NDOF1*NUMVERTICES; 5884 5927 5885 5928 /*Intermediaries */ 5886 int i,j ,ig;5887 IssmDouble 5888 IssmDouble 5889 IssmDouble 5929 int i,j; 5930 IssmDouble xyz_list[NUMVERTICES][3]; 5931 IssmDouble dhdt_g,basal_melting_g,surface_mass_balance_g,Jdettria; 5932 IssmDouble L[NUMVERTICES]; 5890 5933 GaussTria* gauss=NULL; 5891 5934 … … 5898 5941 Input* basal_melting_input=inputs->GetInput(BasalforcingsMeltingRateEnum); _assert_(basal_melting_input); 5899 5942 Input* dhdt_input=inputs->GetInput(BalancethicknessThickeningRateEnum); _assert_(dhdt_input); 5900 5943 5901 5944 /* Start looping on the number of gaussian points: */ 5902 5945 gauss=new GaussTria(2); 5903 for(i g=gauss->begin();ig<gauss->end();ig++){5946 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5904 5947 5905 5948 gauss->GaussPoint(ig); … … 5927 5970 5928 5971 /*Intermediaries */ 5929 int i,j ,ig;5930 IssmDouble 5931 IssmDouble 5932 IssmDouble 5972 int i,j; 5973 IssmDouble xyz_list[NUMVERTICES][3]; 5974 IssmDouble basal_melting_g,surface_mass_balance_g,dhdt_g,Jdettria; 5975 IssmDouble L[NUMVERTICES]; 5933 5976 GaussTria* gauss=NULL; 5934 5977 … … 5944 5987 /* Start looping on the number of gaussian points: */ 5945 5988 gauss=new GaussTria(2); 5946 for(i g=gauss->begin();ig<gauss->end();ig++){5989 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5947 5990 5948 5991 gauss->GaussPoint(ig); -
issm/trunk/src/c/classes/objects/Elements/Tria.h
r13395 r13975 29 29 public: 30 30 31 int id;32 int sid;33 34 Node **nodes;// 3 nodes35 Material *material;// 1 material ice36 Matpar *matpar;// 1 material parameter37 int horizontalneighborsids[3];38 39 Parameters *parameters;//pointer to solution parameters40 Inputs *inputs;41 Results *results;31 int id; 32 int sid; 33 34 Node **nodes; // 3 nodes 35 Material *material; // 1 material ice 36 Matpar *matpar; // 1 material parameter 37 int horizontalneighborsids[3]; 38 39 Parameters *parameters; //pointer to solution parameters 40 Inputs *inputs; 41 Results *results; 42 42 43 43 /*Tria constructors, destructors {{{*/ … … 47 47 /*}}}*/ 48 48 /*Object virtual functions definitions:{{{ */ 49 void Echo(); 50 void DeepEcho(); 51 int Id(); 52 int MyRank(); 53 int ObjectEnum(); 54 Object* copy(); 49 void Echo(); 50 void DeepEcho(); 51 int Id(); 52 int ObjectEnum(); 53 Object *copy(); 55 54 /*}}}*/ 56 55 /*Update virtual functions resolution: {{{*/ … … 77 76 void Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters); 78 77 void SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters); 78 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum); 79 79 void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,Vector<IssmDouble>* df); 80 80 void CreatePVector(Vector<IssmDouble>* pf); … … 82 82 void Delta18oParameterization(void); 83 83 int GetNodeIndex(Node* node); 84 int GetNumberOfNodes(void); 85 void GetNodesSidList(int* sidlist); 84 86 int Sid(); 85 87 bool IsOnBed(); … … 137 139 #endif 138 140 139 140 141 #ifdef _HAVE_CONTROL_ 141 142 IssmDouble DragCoefficientAbsGradient(bool process_units,int weight_index); … … 190 191 int GetElementType(void); 191 192 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 192 void Get DofList1(int* doflist);193 void Get SidList(int* sidlist);193 void GetVertexPidList(int* doflist); 194 void GetVertexSidList(int* sidlist); 194 195 void GetConnectivityList(int* connectivity); 195 196 void GetInputListOnVertices(IssmDouble* pvalue,int enumtype); … … 203 204 void SetClone(int* minranks); 204 205 void SurfaceNormal(IssmDouble* surface_normal, IssmDouble xyz_list[3][3]); 205 206 206 207 #ifdef _HAVE_DIAGNOSTIC_ 207 208 ElementMatrix* CreateKMatrixDiagnosticMacAyeal(void); -
issm/trunk/src/c/classes/objects/Elements/TriaHook.cpp
r13395 r13975 50 50 /*retrieve parameters: */ 51 51 iomodel->Constant(&matpar_id,MeshNumberofelementsEnum); matpar_id++; 52 52 53 53 this->numanalyses=in_numanalyses; 54 54 this->hnodes= new Hook*[in_numanalyses]; -
issm/trunk/src/c/classes/objects/Elements/TriaHook.h
r13395 r13975 17 17 Hook* hmatpar; // 1 material parameter 18 18 19 20 19 /*FUNCTION constructors, destructors {{{*/ 21 20 TriaHook(); … … 27 26 }; 28 27 29 30 28 #endif //ifndef _TRIAHOOK_H_ 31 -
issm/trunk/src/c/classes/objects/Elements/TriaRef.cpp
r13395 r13975 319 319 y3=*(xyz_list+NUMNODES*2+1); 320 320 321 322 321 *(J+NDOF2*0+0)=0.5*(x2-x1); 323 322 *(J+NDOF2*1+0)=SQRT3/6.0*(2*x3-x1-x2); -
issm/trunk/src/c/classes/objects/Elements/TriaRef.h
r13395 r13975 3 3 * strain rate generation, etc ... 4 4 */ 5 6 5 7 6 #ifndef _TRIAREF_H_ … … 11 10 12 11 class TriaRef{ 13 14 12 15 13 public: 16 14 int* element_type_list; //P1CG, P1DG, MINI, P2... 17 15 int element_type; 18 16 19 17 TriaRef(); 20 18 TriaRef(const int nummodels); -
issm/trunk/src/c/classes/objects/ExternalResults/ExternalResult.h
r13395 r13975 2 2 * \brief abstract class for ExternalResult object 3 3 */ 4 5 4 6 5 #ifndef _EXTERNALRESULT_H_ … … 23 22 24 23 public: 25 24 26 25 virtual ~ExternalResult(){}; 27 26 /*Virtual functions:{{{*/ -
issm/trunk/src/c/classes/objects/ExternalResults/GenericExternalResult.h
r13395 r13975 20 20 #include "../../../io/io.h" 21 21 #include "../../../EnumDefinitions/EnumDefinitions.h" 22 #include "../../../classes/IssmComm.h" 22 23 #include "./ExternalResult.h" 23 24 /*}}}*/ … … 34 35 int step; 35 36 IssmDouble time; 36 37 37 38 public: 38 39 /*Diverse: must be in front, as it is used in what follows*/ … … 99 100 return -1; 100 101 } /*}}}*/ 101 int MyRank(void){ /*{{{*/102 extern int my_rank;103 return my_rank;104 } /*}}}*/105 102 int ObjectEnum(void){ /*{{{*/ 106 103 _error_("template ObjectEnum not implemented for this ResultType\n"); … … 112 109 /*GenericExternalResult management: */ 113 110 void WriteData(FILE* fid,bool io_gather){ /*{{{*/ 114 115 extern intmy_rank;111 112 int my_rank; 116 113 int type; 117 114 int size; 118 115 IssmPDouble passiveDouble; 119 116 117 /*recover my_rank:*/ 118 my_rank=IssmComm::GetRank(); 119 120 120 /*return if now on cpu 0: */ 121 121 if(my_rank)return; … … 205 205 template <> inline void GenericExternalResult<char*>::WriteData(FILE* fid,bool io_gather){ /*{{{*/ 206 206 207 extern intmy_rank;207 int my_rank; 208 208 int type; 209 209 int length; 210 211 /*recover my_rank:*/ 212 my_rank=IssmComm::GetRank(); 210 213 211 214 /*return if now on cpu 0: */ … … 235 238 M=in_M; 236 239 N=in_N; 237 240 238 241 step=in_step; 239 242 time=in_time; … … 254 257 } /*}}}*/ 255 258 template <> inline void GenericExternalResult<IssmPDouble*>::Echo(void){ /*{{{*/ 256 259 260 _printLine_("GenericExternalResult<IssmPDouble*>:"); 261 this->GenericEcho(); 262 _printLine_(" matrix size: " << this->M << "-" << this->N); 263 264 } /*}}}*/ 265 template <> inline void GenericExternalResult<IssmPDouble*>::DeepEcho(void){ /*{{{*/ 266 257 267 int i,j; 258 268 259 269 _printLine_("GenericExternalResult<IssmPDouble*>:"); 260 270 this->GenericEcho(); 261 _printLine_(" matrix size: " << this->M << "-" << this->N); 262 263 } /*}}}*/ 264 template <> inline void GenericExternalResult<IssmPDouble*>::DeepEcho(void){ /*{{{*/ 265 266 int i,j; 267 268 _printLine_("GenericExternalResult<IssmPDouble*>:"); 269 this->GenericEcho(); 270 271 271 272 _printLine_(" matrix size: " << this->M << "-" << this->N); 272 273 for (i=0;i<this->M;i++){ … … 283 284 } /*}}}*/ 284 285 template <> inline void GenericExternalResult<IssmPDouble*>::WriteData(FILE* fid,bool io_gather){ /*{{{*/ 285 286 extern intmy_rank;286 287 int my_rank; 287 288 int length; 288 289 int type; 289 290 int rows,cols; 290 291 char *name = NULL; 291 extern int my_rank;292 292 IssmPDouble passiveDouble; 293 294 /*recover my_rank:*/ 295 my_rank=IssmComm::GetRank(); 293 296 294 297 if(io_gather){ -
issm/trunk/src/c/classes/objects/Inputs/BoolInput.cpp
r13395 r13975 23 23 } 24 24 /*}}}*/ 25 /*FUNCTION BoolInput::BoolInput( IssmDouble* values){{{*/26 BoolInput::BoolInput(int in_enum_type, IssmBool in_value){25 /*FUNCTION BoolInput::BoolInput(int in_enum_type,bool in_value){{{*/ 26 BoolInput::BoolInput(int in_enum_type,bool in_value){ 27 27 28 28 enum_type=in_enum_type; … … 53 53 int BoolInput::Id(void){ return -1; } 54 54 /*}}}*/ 55 /*FUNCTION BoolInput::MyRank{{{*/56 int BoolInput::MyRank(void){57 extern int my_rank;58 return my_rank;59 }60 /*}}}*/61 55 /*FUNCTION BoolInput::ObjectEnum{{{*/ 62 56 int BoolInput::ObjectEnum(void){ … … 68 62 /*FUNCTION BoolInput::copy{{{*/ 69 63 Object* BoolInput::copy() { 70 64 71 65 return new BoolInput(this->enum_type,this->value); 72 66 73 67 } 74 68 /*}}}*/ 75 69 76 70 /*BoolInput management*/ 77 71 /*FUNCTION BoolInput::InstanceEnum{{{*/ … … 99 93 /*FUNCTION BoolInput::SpawnResult{{{*/ 100 94 ElementResult* BoolInput::SpawnResult(int step, IssmDouble time){ 101 95 102 96 return new BoolElementResult(this->enum_type,this->value,step,time); 103 97 -
issm/trunk/src/c/classes/objects/Inputs/BoolInput.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _BOOLINPUT_H_ … … 18 17 public: 19 18 /*just hold 3 values for 3 vertices: */ 20 int 21 IssmBool value;19 int enum_type; 20 bool value; 22 21 23 22 /*BoolInput constructors, destructors: {{{*/ 24 23 BoolInput(); 25 BoolInput(int enum_type, IssmBool value);24 BoolInput(int enum_type,bool value); 26 25 ~BoolInput(); 27 26 /*}}}*/ 28 27 /*Object virtual functions definitions:{{{ */ 29 void Echo(); 30 void DeepEcho(); 31 int Id(); 32 int MyRank(); 33 int ObjectEnum(); 34 Object* copy(); 28 void Echo(); 29 void DeepEcho(); 30 int Id(); 31 int ObjectEnum(); 32 Object *copy(); 35 33 /*}}}*/ 36 34 /*BoolInput management: {{{*/ -
issm/trunk/src/c/classes/objects/Inputs/ControlInput.cpp
r13395 r13975 84 84 int ControlInput::Id(void){ return -1; } 85 85 /*}}}*/ 86 /*FUNCTION ControlInput::MyRank{{{*/87 int ControlInput::MyRank(void){88 extern int my_rank;89 return my_rank;90 }91 /*}}}*/92 86 /*FUNCTION ControlInput::ObjectEnum{{{*/ 93 87 int ControlInput::ObjectEnum(void){ … … 99 93 /*FUNCTION ControlInput::copy{{{*/ 100 94 Object* ControlInput::copy() { 101 95 102 96 ControlInput* output=NULL; 103 97 … … 106 100 output->control_id=this->control_id; 107 101 108 if(values) output->values =(Input*)this->values->copy();109 if(savedvalues) output->savedvalues =(Input*)this->savedvalues->copy();110 if(minvalues) output->minvalues =(Input*)this->minvalues->copy();111 if(maxvalues) output->maxvalues =(Input*)this->maxvalues->copy();112 if(gradient) output->gradient =(Input*)this->gradient->copy();102 if(values) output->values = dynamic_cast<Input*>(this->values->copy()); 103 if(savedvalues) output->savedvalues = dynamic_cast<Input*>(this->savedvalues->copy()); 104 if(minvalues) output->minvalues = dynamic_cast<Input*>(this->minvalues->copy()); 105 if(maxvalues) output->maxvalues = dynamic_cast<Input*>(this->maxvalues->copy()); 106 if(gradient) output->gradient = dynamic_cast<Input*>(this->gradient->copy()); 113 107 114 108 return output; 115 109 } 116 110 /*}}}*/ 117 111 118 112 /*ControlInput management*/ 119 113 /*FUNCTION ControlInput::InstanceEnum{{{*/ … … 261 255 262 256 if(savedvalues) delete this->savedvalues; 263 this->savedvalues= (Input*)this->values->copy();257 this->savedvalues=dynamic_cast<Input*>(this->values->copy()); 264 258 }/*}}}*/ 265 259 /*FUNCTION ControlInput::UpdateValue{{{*/ … … 269 263 270 264 if(values) delete this->values; 271 this->values= (Input*)this->savedvalues->copy();265 this->values=dynamic_cast<Input*>(this->savedvalues->copy()); 272 266 this->values->AXPY(gradient,scalar); 273 267 }/*}}}*/ -
issm/trunk/src/c/classes/objects/Inputs/ControlInput.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _CONTROLINPUT_H_ … … 34 33 void DeepEcho(); 35 34 int Id(); 36 int MyRank();37 35 int ObjectEnum(); 38 36 Object* copy(); -
issm/trunk/src/c/classes/objects/Inputs/DatasetInput.cpp
r13395 r13975 55 55 int DatasetInput::Id(void){ return -1; } 56 56 /*}}}*/ 57 /*FUNCTION DatasetInput::MyRank{{{*/58 int DatasetInput::MyRank(void){59 extern int my_rank;60 return my_rank;61 }62 /*}}}*/63 57 /*FUNCTION DatasetInput::ObjectEnum{{{*/ 64 58 int DatasetInput::ObjectEnum(void){ … … 70 64 /*FUNCTION DatasetInput::copy{{{*/ 71 65 Object* DatasetInput::copy() { 72 66 73 67 DatasetInput* output=NULL; 74 68 … … 89 83 outinput=new DatasetInput(); 90 84 outinput->enum_type=this->enum_type; 91 outinput->inputs= (Inputs*)this->inputs->SpawnTriaInputs(indices);85 outinput->inputs=dynamic_cast<Inputs*>(this->inputs->SpawnTriaInputs(indices)); 92 86 93 87 /*Assign output*/ … … 95 89 } 96 90 /*}}}*/ 97 91 98 92 /*DatasetInput management*/ 99 93 /*FUNCTION DatasetInput::InstanceEnum{{{*/ … … 116 110 /*Get requested input within dataset*/ 117 111 if(index<0 || index > inputs->Size()-1) _error_("index requested (" << index << ") exceeds dataset size (" << inputs->Size() << ")"); 118 Input* input= (Input*)this->inputs->GetObjectByOffset(index);119 112 Input* input=dynamic_cast<Input*>(this->inputs->GetObjectByOffset(index)); 113 120 114 input->GetInputValue(pvalue,gauss); 121 115 } -
issm/trunk/src/c/classes/objects/Inputs/DatasetInput.h
r13395 r13975 2 2 * \brief: header file for datasetinput object 3 3 */ 4 5 4 6 5 #ifndef _DATASETINPUT_H_ … … 17 16 18 17 public: 19 int enum_type; 20 21 Inputs* inputs; 18 int enum_type; 19 Inputs *inputs; 22 20 23 21 /*DatasetInput constructors, destructors: {{{*/ … … 30 28 void DeepEcho(); 31 29 int Id(); 32 int MyRank();33 30 int ObjectEnum(); 34 31 Object* copy(); -
issm/trunk/src/c/classes/objects/Inputs/DoubleInput.cpp
r13395 r13975 53 53 int DoubleInput::Id(void){ return -1; } 54 54 /*}}}*/ 55 /*FUNCTION DoubleInput::MyRank{{{*/56 int DoubleInput::MyRank(void){57 extern int my_rank;58 return my_rank;59 }60 /*}}}*/61 55 /*FUNCTION DoubleInput::ObjectEnum{{{*/ 62 56 int DoubleInput::ObjectEnum(void){ … … 68 62 /*FUNCTION DoubleInput::copy{{{*/ 69 63 Object* DoubleInput::copy() { 70 64 71 65 return new DoubleInput(this->enum_type,this->value); 72 66 73 67 } 74 68 /*}}}*/ 75 69 76 70 /*DoubleInput management*/ 77 71 /*FUNCTION DoubleInput::InstanceEnum{{{*/ -
issm/trunk/src/c/classes/objects/Inputs/DoubleInput.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _DOUBLEINPUT_H_ … … 29 28 void DeepEcho(); 30 29 int Id(); 31 int MyRank();32 30 int ObjectEnum(); 33 31 Object* copy(); -
issm/trunk/src/c/classes/objects/Inputs/Input.h
r13395 r13975 2 2 * \brief abstract class for Input object 3 3 */ 4 5 4 6 5 #ifndef _INPUT_H_ … … 19 18 20 19 public: 21 20 22 21 virtual ~Input(){}; 23 22 … … 60 59 virtual void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist)=0; 61 60 virtual void GetValuesPtr(IssmDouble** pvalues,int* pnum_values)=0; 62 61 63 62 virtual Input* SpawnTriaInput(int* indices)=0; 64 63 virtual Input* PointwiseDivide(Input* inputB)=0; -
issm/trunk/src/c/classes/objects/Inputs/IntInput.cpp
r13395 r13975 48 48 int IntInput::Id(void){ return -1; } 49 49 /*}}}*/ 50 /*FUNCTION IntInput::MyRank{{{*/51 int IntInput::MyRank(void){52 extern int my_rank;53 return my_rank;54 }55 /*}}}*/56 50 /*FUNCTION IntInput::ObjectEnum{{{*/ 57 51 int IntInput::ObjectEnum(void){ … … 63 57 /*FUNCTION IntInput::copy{{{*/ 64 58 Object* IntInput::copy() { 65 59 66 60 return new IntInput(this->enum_type,this->value); 67 61 … … 98 92 /*FUNCTION IntInput::SpawnResult{{{*/ 99 93 ElementResult* IntInput::SpawnResult(int step, IssmDouble time){ 100 94 101 95 _error_("not supported yet!"); 102 96 -
issm/trunk/src/c/classes/objects/Inputs/IntInput.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _INTINPUT_H_ … … 30 29 void DeepEcho(); 31 30 int Id(); 32 int MyRank();33 31 int ObjectEnum(); 34 32 Object* copy(); -
issm/trunk/src/c/classes/objects/Inputs/PentaP1Input.cpp
r13395 r13975 64 64 int PentaP1Input::Id(void){ return -1; } 65 65 /*}}}*/ 66 /*FUNCTION PentaP1Input::MyRank{{{*/67 int PentaP1Input::MyRank(void){68 extern int my_rank;69 return my_rank;70 }71 /*}}}*/72 66 /*FUNCTION PentaP1Input::ObjectEnum{{{*/ 73 67 int PentaP1Input::ObjectEnum(void){ … … 77 71 } 78 72 /*}}}*/ 79 73 80 74 /*PentaP1Input management*/ 81 75 /*FUNCTION PentaP1Input::copy{{{*/ 82 76 Object* PentaP1Input::copy() { 83 77 84 78 return new PentaP1Input(this->enum_type,this->values); 85 79 … … 363 357 /*FUNCTION PentaP1Input::ConstrainMin{{{*/ 364 358 void PentaP1Input::ConstrainMin(IssmDouble minimum){ 365 359 366 360 int i; 367 361 const int numnodes=6; … … 431 425 /*FUNCTION PentaP1Input::Scale{{{*/ 432 426 void PentaP1Input::Scale(IssmDouble scale_factor){ 433 427 434 428 int i; 435 429 const int numnodes=6; … … 470 464 int i; 471 465 const int numnodes=6; 472 466 473 467 if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min; 474 468 if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max; … … 522 516 523 517 /*Intermediaries*/ 524 int i; 525 PentaP1Input *xinputB = NULL; 526 int B_numvalues; 527 const int numnodes = 6; 528 IssmDouble AdotBvalues[numnodes]; 518 PentaP1Input *xinputB = NULL; 519 const int numnodes = 6; 520 IssmDouble AdotBvalues[numnodes]; 529 521 530 522 /*Check that inputB is of the same type*/ … … 533 525 534 526 /*Create point wise sum*/ 535 for(i =0;i<numnodes;i++){527 for(int i=0;i<numnodes;i++){ 536 528 _assert_(xinputB->values[i]!=0); 537 529 AdotBvalues[i]=this->values[i]/xinputB->values[i]; … … 555 547 int i; 556 548 PentaP1Input *xinputB = NULL; 557 int B_numvalues;558 549 const int numnodes = 6; 559 550 IssmDouble minvalues[numnodes]; … … 586 577 int i; 587 578 PentaP1Input *xinputB = NULL; 588 int B_numvalues;589 579 const int numnodes = 6; 590 580 IssmDouble maxvalues[numnodes]; -
issm/trunk/src/c/classes/objects/Inputs/PentaP1Input.h
r13395 r13975 2 2 * \brief: header file for PentaP1Input object 3 3 */ 4 5 4 6 5 #ifndef _PENTAP1INPUT_H_ … … 18 17 public: 19 18 /*just hold 6 values for 6 vertices: */ 20 int enum_type;19 int enum_type; 21 20 IssmDouble values[6]; 22 21 … … 27 26 /*}}}*/ 28 27 /*Object virtual functions definitions:{{{ */ 29 void Echo(); 30 void DeepEcho(); 31 int Id(); 32 int MyRank(); 33 int ObjectEnum(); 34 Object* copy(); 28 void Echo(); 29 void DeepEcho(); 30 int Id(); 31 int ObjectEnum(); 32 Object *copy(); 35 33 /*}}}*/ 36 34 /*PentaP1Input management: {{{*/ -
issm/trunk/src/c/classes/objects/Inputs/TransientInput.cpp
r13395 r13975 79 79 int TransientInput::Id(void){ return -1; } 80 80 /*}}}*/ 81 /*FUNCTION TransientInput::MyRank{{{*/82 int TransientInput::MyRank(void){83 extern int my_rank;84 return my_rank;85 }86 /*}}}*/87 81 /*FUNCTION TransientInput::ObjectEnum{{{*/ 88 82 int TransientInput::ObjectEnum(void){ … … 109 103 } 110 104 /*}}}*/ 111 105 112 106 /*TransientInput management*/ 113 107 /*FUNCTION TransientInput::InstanceEnum{{{*/ … … 222 216 /*Retrieve interpolated values for this time step: */ 223 217 Input* input=GetTimeInput(time); 224 218 225 219 /*Call input function*/ 226 220 input->GetInputDerivativeValue(p,xyz_list,gauss); … … 237 231 /*FUNCTION TransientInput::GetInputAverage{{{*/ 238 232 void TransientInput::GetInputAverage(IssmDouble* pvalue){ 239 233 240 234 IssmDouble time; 241 235 … … 248 242 /*Call input function*/ 249 243 input->GetInputAverage(pvalue); 250 244 251 245 delete input; 252 246 … … 302 296 /*Retrieve interpolated values for this time step: */ 303 297 Input* input=GetTimeInput(time); 304 298 305 299 /*Call input function*/ 306 300 input->SquareMin(psquaremin,process_units,parameters); 307 301 308 302 delete input; 309 303 … … 324 318 /*Call input function*/ 325 319 infnorm=input->InfinityNorm(); 326 320 327 321 /*Clean-up and return*/ 328 322 delete input; … … 341 335 /*Retrieve interpolated values for this time step: */ 342 336 Input* input=GetTimeInput(time); 343 337 344 338 /*Call input function*/ 345 339 max=input->Max(); 346 340 347 341 delete input; 348 342 … … 406 400 /*Call input function*/ 407 401 minabs=input->MinAbs(); 408 402 409 403 /*Clean-up and return*/ 410 404 delete input; … … 422 416 /*Retrieve interpolated values for this time step: */ 423 417 Input* input=GetTimeInput(time); 424 418 425 419 /*Call input function*/ 426 420 input->GetVectorFromInputs(vector,doflist); 427 421 428 422 delete input; 429 423 … … 432 426 Input* TransientInput::GetTimeInput(IssmDouble intime){ 433 427 434 int i,j; 435 IssmDouble deltat; 436 IssmDouble alpha1,alpha2; 437 bool found=false; 438 Input* input=NULL; 439 Input* input1=NULL; 440 Input* input2=NULL; 441 442 /*Ok, we have the time, go through the timesteps, and figure out which interval we 428 IssmDouble deltat; 429 IssmDouble alpha1,alpha2; 430 int found; 431 int offset; 432 433 Input *input = NULL; 434 Input *input1 = NULL; 435 Input *input2 = NULL; 436 437 /*go through the timesteps, and figure out which interval we 443 438 *fall within. Then interpolate the values on this interval: */ 444 if(intime<this->timesteps[0]){ 439 found=binary_search(&offset,intime,this->timesteps,this->numtimesteps); 440 if(!found) _error_("Input not found (is TransientInput sorted ?)"); 441 442 if (offset==-1){ 445 443 /*get values for the first time: */ 444 _assert_(intime<this->timesteps[0]); 446 445 input=(Input*)((Input*)this->inputs->GetObjectByOffset(0))->copy(); 447 found=true; 448 } 449 else if(intime>this->timesteps[this->numtimesteps-1]){ 446 } 447 else if(offset==(this->numtimesteps-1)){ 450 448 /*get values for the last time: */ 451 input=(Input*)((Input*)this->inputs->GetObjectByOffset(numtimesteps-1))->copy();452 found=true;449 _assert_(intime>=this->timesteps[offset]); 450 input=(Input*)((Input*)this->inputs->GetObjectByOffset(offset))->copy(); 453 451 } 454 452 else{ 455 /*Find which interval we fall within: */ 456 for(i=0;i<this->numtimesteps;i++){ 457 if(intime==this->timesteps[i]){ 458 /*We are right on one step time: */ 459 input=(Input*)((Input*)this->inputs->GetObjectByOffset(i))->copy(); 460 found=true; 461 break; //we are done with the time interpolation. 462 } 463 else{ 464 if(this->timesteps[i]<intime && intime<this->timesteps[i+1]){ 465 /*ok, we have the interval ]i:i+1[. Interpolate linearly for now: */ 466 deltat=this->timesteps[i+1]-this->timesteps[i]; 467 alpha2=(intime-this->timesteps[i])/deltat; 468 alpha1=(1.0-alpha2); 469 470 input1=(Input*)this->inputs->GetObjectByOffset(i); 471 input2=(Input*)this->inputs->GetObjectByOffset(i+1); 472 473 input=(Input*)input1->copy(); 474 input->Scale(alpha1); 475 input->AXPY(input2,alpha2); 476 477 found=true; 478 break; 479 } 480 else continue; //keep looking on the next interval 481 } 482 } 483 } 484 if(!found)_error_("did not find time interval on which to interpolate forcing values!"); 453 /*get values between two times [offset:offset+1[, Interpolate linearly*/ 454 _assert_(intime>=this->timesteps[offset] && intime<this->timesteps[offset+1]); 455 deltat=this->timesteps[offset+1]-this->timesteps[offset]; 456 alpha2=(intime-this->timesteps[offset])/deltat; 457 alpha1=(1.0-alpha2); 458 459 input1=(Input*)this->inputs->GetObjectByOffset(offset); 460 input2=(Input*)this->inputs->GetObjectByOffset(offset+1); 461 462 input=(Input*)input1->copy(); 463 input->Scale(alpha1); 464 input->AXPY(input2,alpha2); 465 } 485 466 486 467 /*Assign output pointer*/ -
issm/trunk/src/c/classes/objects/Inputs/TransientInput.h
r13395 r13975 2 2 * \brief: header file for transientinput object 3 3 */ 4 5 4 6 5 #ifndef _TRANSIENTINPUT_H_ … … 17 16 18 17 public: 19 int enum_type;20 int numtimesteps;21 Inputs *inputs;22 IssmDouble *timesteps;23 Parameters * parameters;//to find current time.18 int enum_type; 19 int numtimesteps; 20 Inputs *inputs; 21 IssmDouble *timesteps; 22 Parameters *parameters; //to find current time. 24 23 25 24 /*TransientInput constructors, destructors: {{{*/ … … 33 32 void DeepEcho(); 34 33 int Id(); 35 int MyRank();36 34 int ObjectEnum(); 37 35 Object* copy(); -
issm/trunk/src/c/classes/objects/Inputs/TriaP1Input.cpp
r13395 r13975 64 64 int TriaP1Input::Id(void){ return -1; } 65 65 /*}}}*/ 66 /*FUNCTION TriaP1Input::MyRank{{{*/67 int TriaP1Input::MyRank(void){68 extern int my_rank;69 return my_rank;70 }71 /*}}}*/72 66 /*FUNCTION TriaP1Input::ObjectEnum{{{*/ 73 67 int TriaP1Input::ObjectEnum(void){ … … 79 73 /*FUNCTION TriaP1Input::copy{{{*/ 80 74 Object* TriaP1Input::copy() { 81 75 82 76 return new TriaP1Input(this->enum_type,this->values); 83 77 84 78 } 85 79 /*}}}*/ 86 80 87 81 /*TriaP1Input management*/ 88 82 /*FUNCTION TriaP1Input::InstanceEnum{{{*/ … … 214 208 /*FUNCTION TriaP1Input::ContrainMin{{{*/ 215 209 void TriaP1Input::ConstrainMin(IssmDouble minimum){ 216 210 217 211 int i; 218 212 const int numnodes=3; … … 282 276 /*FUNCTION TriaP1Input::Scale{{{*/ 283 277 void TriaP1Input::Scale(IssmDouble scale_factor){ 284 278 285 279 int i; 286 280 const int numnodes=3; … … 333 327 int i; 334 328 const int numnodes=3; 335 329 336 330 if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min; 337 331 if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max; … … 361 355 362 356 /*Intermediaries*/ 363 int i; 364 TriaP1Input *xinputB = NULL; 365 int B_numvalues; 366 const int numnodes = 3; 367 IssmDouble minvalues[numnodes]; 357 int i; 358 TriaP1Input *xinputB = NULL; 359 const int numnodes = 3; 360 IssmDouble minvalues[numnodes]; 368 361 369 362 /*Check that inputB is of the same type*/ … … 394 387 int i; 395 388 TriaP1Input *xinputB = NULL; 396 int B_numvalues;397 389 const int numnodes = 3; 398 390 IssmDouble maxvalues[numnodes]; -
issm/trunk/src/c/classes/objects/Inputs/TriaP1Input.h
r13395 r13975 2 2 * \brief: header file for TriaP1Input object 3 3 */ 4 5 4 6 5 #ifndef _TRIAP1INPUT_H_ … … 18 17 public: 19 18 /*just hold 3 values for 3 vertices: */ 20 int enum_type;19 int enum_type; 21 20 IssmDouble values[3]; 22 21 … … 27 26 /*}}}*/ 28 27 /*Object virtual functions definitions:{{{ */ 29 void Echo(); 30 void DeepEcho(); 31 int Id(); 32 int MyRank(); 33 int ObjectEnum(); 34 Object* copy(); 28 void Echo(); 29 void DeepEcho(); 30 int Id(); 31 int ObjectEnum(); 32 Object *copy(); 35 33 /*}}}*/ 36 34 /*TriaP1Input management: {{{*/ -
issm/trunk/src/c/classes/objects/KML/KMLFileReadUtils.cpp
r13395 r13975 545 545 FILE* fid){ 546 546 547 int i=-1 ,j;547 int i=-1; 548 548 char* kstr; 549 549 char* ktok; -
issm/trunk/src/c/classes/objects/KML/KMLFileReadUtils.h
r13395 r13975 55 55 56 56 #endif /* _KMLFILEREADUTILS_H */ 57 -
issm/trunk/src/c/classes/objects/KML/KML_Attribute.h
r13395 r13975 31 31 virtual void DeepEcho(const char* indent); 32 32 int Id(){_error_("Not implemented yet.");}; 33 int MyRank(){_error_("Not implemented yet.");};34 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};35 int MarshallSize(){_error_("Not implemented yet.");};36 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};37 33 int ObjectEnum(){_error_("Not implemented yet.");}; 38 34 Object* copy(){_error_("Not implemented yet.");}; … … 48 44 }; 49 45 #endif /* _KML_ATTRIBUTE_H */ 50 -
issm/trunk/src/c/classes/objects/KML/KML_ColorStyle.h
r13395 r13975 36 36 void Read(FILE* fid,char* kstr); 37 37 int Id(){_error_("Not implemented yet.");}; 38 int MyRank(){_error_("Not implemented yet.");};39 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};40 int MarshallSize(){_error_("Not implemented yet.");};41 38 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");}; 42 39 int ObjectEnum(){_error_("Not implemented yet.");}; … … 46 43 }; 47 44 #endif /* _KML_COLORSTYLE_H */ 48 -
issm/trunk/src/c/classes/objects/KML/KML_Comment.h
r13395 r13975 31 31 virtual void DeepEcho(const char* indent); 32 32 int Id(){_error_("Not implemented yet.");}; 33 int MyRank(){_error_("Not implemented yet.");};34 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};35 int MarshallSize(){_error_("Not implemented yet.");};36 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};37 33 int ObjectEnum(){_error_("Not implemented yet.");}; 38 34 Object* copy(){_error_("Not implemented yet.");}; … … 48 44 }; 49 45 #endif /* _KML_COMMENT_H */ 50 -
issm/trunk/src/c/classes/objects/KML/KML_Container.h
r13395 r13975 34 34 void WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp); 35 35 int Id(){_error_("Not implemented yet.");}; 36 int MyRank(){_error_("Not implemented yet.");};37 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};38 int MarshallSize(){_error_("Not implemented yet.");};39 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};40 36 int ObjectEnum(){_error_("Not implemented yet.");}; 41 37 Object* copy(){_error_("Not implemented yet.");}; … … 44 40 }; 45 41 #endif /* _KML_CONTAINER_H */ 46 -
issm/trunk/src/c/classes/objects/KML/KML_Document.cpp
r13395 r13975 125 125 } 126 126 /*}}}*/ 127 -
issm/trunk/src/c/classes/objects/KML/KML_Document.h
r13395 r13975 31 31 void Read(FILE* fid,char* kstr); 32 32 int Id(){_error_("Not implemented yet.");}; 33 int MyRank(){_error_("Not implemented yet.");};34 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};35 int MarshallSize(){_error_("Not implemented yet.");};36 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};37 33 int ObjectEnum(){_error_("Not implemented yet.");}; 38 34 Object* copy(){_error_("Not implemented yet.");}; … … 41 37 }; 42 38 #endif /* _KML_DOCUMENT_H */ 43 -
issm/trunk/src/c/classes/objects/KML/KML_Feature.h
r13395 r13975 45 45 void Read(FILE* fid,char* kstr); 46 46 int Id(){_error_("Not implemented yet.");}; 47 int MyRank(){_error_("Not implemented yet.");};48 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};49 int MarshallSize(){_error_("Not implemented yet.");};50 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};51 47 int ObjectEnum(){_error_("Not implemented yet.");}; 52 48 Object* copy(){_error_("Not implemented yet.");}; … … 55 51 }; 56 52 #endif /* _KML_FEATURE_H */ 57 -
issm/trunk/src/c/classes/objects/KML/KML_File.cpp
r13395 r13975 90 90 int ncom=0; 91 91 char** pcom=NULL; 92 KML_Object* kobj;93 92 94 93 /* get object attributes and check for solo tag */ -
issm/trunk/src/c/classes/objects/KML/KML_File.h
r13395 r13975 32 32 void WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp); 33 33 int Id(){_error_("Not implemented yet.");}; 34 int MyRank(){_error_("Not implemented yet.");};35 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};36 int MarshallSize(){_error_("Not implemented yet.");};37 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};38 34 int ObjectEnum(){_error_("Not implemented yet.");}; 39 35 Object* copy(){_error_("Not implemented yet.");}; … … 42 38 }; 43 39 #endif /* _KML_FILE_H */ 44 -
issm/trunk/src/c/classes/objects/KML/KML_Folder.h
r13395 r13975 31 31 void Read(FILE* fid,char* kstr); 32 32 int Id(){_error_("Not implemented yet.");}; 33 int MyRank(){_error_("Not implemented yet.");};34 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};35 int MarshallSize(){_error_("Not implemented yet.");};36 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};37 33 int ObjectEnum(){_error_("Not implemented yet.");}; 38 34 Object* copy(){_error_("Not implemented yet.");}; … … 41 37 }; 42 38 #endif /* _KML_FOLDER_H */ 43 -
issm/trunk/src/c/classes/objects/KML/KML_Geometry.h
r13395 r13975 30 30 void Read(FILE* fid,char* kstr); 31 31 int Id(){_error_("Not implemented yet.");}; 32 int MyRank(){_error_("Not implemented yet.");};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 32 int ObjectEnum(){_error_("Not implemented yet.");}; 37 33 Object* copy(){_error_("Not implemented yet.");}; … … 40 36 }; 41 37 #endif /* _KML_GEOMETRY_H */ 42 -
issm/trunk/src/c/classes/objects/KML/KML_GroundOverlay.h
r13395 r13975 37 37 void Read(FILE* fid,char* kstr); 38 38 int Id(){_error_("Not implemented yet.");}; 39 int MyRank(){_error_("Not implemented yet.");};40 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};41 int MarshallSize(){_error_("Not implemented yet.");};42 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};43 39 int ObjectEnum(){_error_("Not implemented yet.");}; 44 40 Object* copy(){_error_("Not implemented yet.");}; … … 47 43 }; 48 44 #endif /* _KML_GROUNDOVERLAY_H */ 49 -
issm/trunk/src/c/classes/objects/KML/KML_Icon.h
r13395 r13975 45 45 void Read(FILE* fid,char* kstr); 46 46 int Id(){_error_("Not implemented yet.");}; 47 int MyRank(){_error_("Not implemented yet.");};48 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};49 int MarshallSize(){_error_("Not implemented yet.");};50 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};51 47 int ObjectEnum(){_error_("Not implemented yet.");}; 52 48 Object* copy(){_error_("Not implemented yet.");}; … … 55 51 }; 56 52 #endif /* _KML_ICON_H */ 57 -
issm/trunk/src/c/classes/objects/KML/KML_LatLonBox.cpp
r13395 r13975 43 43 /*FUNCTION KML_LatLonBox::Echo {{{*/ 44 44 void KML_LatLonBox::Echo(){ 45 46 45 47 46 _printLine_("KML_LatLonBox:"); -
issm/trunk/src/c/classes/objects/KML/KML_LatLonBox.h
r13395 r13975 36 36 void Read(FILE* fid,char* kstr); 37 37 int Id(){_error_("Not implemented yet.");}; 38 int MyRank(){_error_("Not implemented yet.");};39 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};40 int MarshallSize(){_error_("Not implemented yet.");};41 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};42 38 int ObjectEnum(){_error_("Not implemented yet.");}; 43 39 Object* copy(){_error_("Not implemented yet.");}; … … 46 42 }; 47 43 #endif /* _KML_LATLONBOX_H */ 48 -
issm/trunk/src/c/classes/objects/KML/KML_LineString.h
r13395 r13975 39 39 void WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp); 40 40 int Id(){_error_("Not implemented yet.");}; 41 int MyRank(){_error_("Not implemented yet.");};42 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};43 int MarshallSize(){_error_("Not implemented yet.");};44 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};45 41 int ObjectEnum(){_error_("Not implemented yet.");}; 46 42 Object* copy(){_error_("Not implemented yet.");}; … … 49 45 }; 50 46 #endif /* _KML_LINESTRING_H */ 51 -
issm/trunk/src/c/classes/objects/KML/KML_LineStyle.cpp
r13395 r13975 63 63 void KML_LineStyle::DeepEcho(const char* indent){ 64 64 65 int i;66 65 bool flag=true; 67 66 -
issm/trunk/src/c/classes/objects/KML/KML_LineStyle.h
r13395 r13975 32 32 void Read(FILE* fid,char* kstr); 33 33 int Id(){_error_("Not implemented yet.");}; 34 int MyRank(){_error_("Not implemented yet.");};35 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};36 int MarshallSize(){_error_("Not implemented yet.");};37 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};38 34 int ObjectEnum(){_error_("Not implemented yet.");}; 39 35 Object* copy(){_error_("Not implemented yet.");}; … … 42 38 }; 43 39 #endif /* _KML_LINESTYLE_H */ 44 -
issm/trunk/src/c/classes/objects/KML/KML_LinearRing.h
r13395 r13975 39 39 void WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp); 40 40 int Id(){_error_("Not implemented yet.");}; 41 int MyRank(){_error_("Not implemented yet.");};42 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};43 int MarshallSize(){_error_("Not implemented yet.");};44 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};45 41 int ObjectEnum(){_error_("Not implemented yet.");}; 46 42 Object* copy(){_error_("Not implemented yet.");}; … … 49 45 }; 50 46 #endif /* _KML_LINEARRING_H */ 51 -
issm/trunk/src/c/classes/objects/KML/KML_MultiGeometry.h
r13395 r13975 35 35 void WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp); 36 36 int Id(){_error_("Not implemented yet.");}; 37 int MyRank(){_error_("Not implemented yet.");};38 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};39 int MarshallSize(){_error_("Not implemented yet.");};40 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};41 37 int ObjectEnum(){_error_("Not implemented yet.");}; 42 38 Object* copy(){_error_("Not implemented yet.");}; … … 45 41 }; 46 42 #endif /* _KML_MULTIGEOMETRY_H */ 47 -
issm/trunk/src/c/classes/objects/KML/KML_Object.h
r13395 r13975 32 32 virtual void DeepEcho(const char* indent); 33 33 int Id(){_error_("Not implemented yet.");}; 34 int MyRank(){_error_("Not implemented yet.");};35 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};36 int MarshallSize(){_error_("Not implemented yet.");};37 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};38 34 int ObjectEnum(){_error_("Not implemented yet.");}; 39 35 Object* copy(){_error_("Not implemented yet.");}; … … 54 50 }; 55 51 #endif /* _KML_OBJECT_H */ 56 -
issm/trunk/src/c/classes/objects/KML/KML_Overlay.h
r13395 r13975 37 37 void Read(FILE* fid,char* kstr); 38 38 int Id(){_error_("Not implemented yet.");}; 39 int MyRank(){_error_("Not implemented yet.");};40 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};41 int MarshallSize(){_error_("Not implemented yet.");};42 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};43 39 int ObjectEnum(){_error_("Not implemented yet.");}; 44 40 Object* copy(){_error_("Not implemented yet.");}; … … 47 43 }; 48 44 #endif /* _KML_OVERLAY_H */ 49 -
issm/trunk/src/c/classes/objects/KML/KML_Placemark.h
r13395 r13975 35 35 void WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp); 36 36 int Id(){_error_("Not implemented yet.");}; 37 int MyRank(){_error_("Not implemented yet.");};38 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};39 int MarshallSize(){_error_("Not implemented yet.");};40 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};41 37 int ObjectEnum(){_error_("Not implemented yet.");}; 42 38 Object* copy(){_error_("Not implemented yet.");}; … … 45 41 }; 46 42 #endif /* _KML_PLACEMARK_H */ 47 -
issm/trunk/src/c/classes/objects/KML/KML_Point.h
r13395 r13975 37 37 void WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp); 38 38 int Id(){_error_("Not implemented yet.");}; 39 int MyRank(){_error_("Not implemented yet.");};40 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};41 int MarshallSize(){_error_("Not implemented yet.");};42 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};43 39 int ObjectEnum(){_error_("Not implemented yet.");}; 44 40 Object* copy(){_error_("Not implemented yet.");}; … … 47 43 }; 48 44 #endif /* _KML_POINT_H */ 49 -
issm/trunk/src/c/classes/objects/KML/KML_PolyStyle.cpp
r13395 r13975 65 65 void KML_PolyStyle::DeepEcho(const char* indent){ 66 66 67 int i;68 67 bool flag=true; 69 68 -
issm/trunk/src/c/classes/objects/KML/KML_PolyStyle.h
r13395 r13975 33 33 void Read(FILE* fid,char* kstr); 34 34 int Id(){_error_("Not implemented yet.");}; 35 int MyRank(){_error_("Not implemented yet.");};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 35 int ObjectEnum(){_error_("Not implemented yet.");}; 40 36 Object* copy(){_error_("Not implemented yet.");}; … … 43 39 }; 44 40 #endif /* _KML_POLYSTYLE_H */ 45 -
issm/trunk/src/c/classes/objects/KML/KML_Polygon.cpp
r13395 r13975 250 250 } 251 251 252 253 252 else if (!strncmp(kstri,"<",1)) 254 253 KML_Geometry::Read(fid,kstri); -
issm/trunk/src/c/classes/objects/KML/KML_Polygon.h
r13395 r13975 41 41 void WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp); 42 42 int Id(){_error_("Not implemented yet.");}; 43 int MyRank(){_error_("Not implemented yet.");};44 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};45 int MarshallSize(){_error_("Not implemented yet.");};46 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};47 43 int ObjectEnum(){_error_("Not implemented yet.");}; 48 44 Object* copy(){_error_("Not implemented yet.");}; … … 51 47 }; 52 48 #endif /* _KML_POLYGON_H */ 53 -
issm/trunk/src/c/classes/objects/KML/KML_Style.h
r13395 r13975 39 39 void Read(FILE* fid,char* kstr); 40 40 int Id(){_error_("Not implemented yet.");}; 41 int MyRank(){_error_("Not implemented yet.");};42 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};43 int MarshallSize(){_error_("Not implemented yet.");};44 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};45 41 int ObjectEnum(){_error_("Not implemented yet.");}; 46 42 Object* copy(){_error_("Not implemented yet.");}; … … 49 45 }; 50 46 #endif /* _KML_STYLE_H */ 51 -
issm/trunk/src/c/classes/objects/KML/KML_StyleSelector.cpp
r13395 r13975 93 93 } 94 94 /*}}}*/ 95 -
issm/trunk/src/c/classes/objects/KML/KML_StyleSelector.h
r13395 r13975 30 30 void Read(FILE* fid,char* kstr); 31 31 int Id(){_error_("Not implemented yet.");}; 32 int MyRank(){_error_("Not implemented yet.");};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 32 int ObjectEnum(){_error_("Not implemented yet.");}; 37 33 Object* copy(){_error_("Not implemented yet.");}; … … 40 36 }; 41 37 #endif /* _KML_STYLESELECTOR_H */ 42 -
issm/trunk/src/c/classes/objects/KML/KML_SubStyle.cpp
r13395 r13975 93 93 } 94 94 /*}}}*/ 95 -
issm/trunk/src/c/classes/objects/KML/KML_SubStyle.h
r13395 r13975 30 30 void Read(FILE* fid,char* kstr); 31 31 int Id(){_error_("Not implemented yet.");}; 32 int MyRank(){_error_("Not implemented yet.");};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 32 int ObjectEnum(){_error_("Not implemented yet.");}; 37 33 Object* copy(){_error_("Not implemented yet.");}; … … 40 36 }; 41 37 #endif /* _KML_SUBSTYLE_H */ 42 -
issm/trunk/src/c/classes/objects/KML/KML_Unknown.cpp
r13395 r13975 79 79 valuei=xNew<char>(strlen(value)+1); 80 80 memcpy(valuei,value,(strlen(value)+1)*sizeof(char)); 81 81 82 82 vtoken=strtok(valuei,nl); 83 83 if(flag) _pprintString_(indent << " value: \"" << vtoken); 84 84 85 85 while (vtoken=strtok(NULL,nl)) 86 86 if(flag) _pprintString_("\n" << indent << " " << vtoken); … … 110 110 valuei=xNew<char>(strlen(value)+1); 111 111 memcpy(valuei,value,(strlen(value)+1)*sizeof(char)); 112 112 113 113 vtoken=strtok(valuei,nl); 114 114 fprintf(filout,"%s %s\n",indent,vtoken); 115 115 116 116 while (vtoken=strtok(NULL,nl)) 117 117 fprintf(filout,"%s %s\n",indent,vtoken); -
issm/trunk/src/c/classes/objects/KML/KML_Unknown.h
r13395 r13975 33 33 void Read(FILE* fid,char* kstr); 34 34 int Id(){_error_("Not implemented yet.");}; 35 int MyRank(){_error_("Not implemented yet.");};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 35 int ObjectEnum(){_error_("Not implemented yet.");}; 40 36 Object* copy(){_error_("Not implemented yet.");}; … … 43 39 }; 44 40 #endif /* _KML_UNKNOWN_H */ 45 -
issm/trunk/src/c/classes/objects/Loads/Friction.cpp
r13395 r13975 191 191 192 192 /*diverse: */ 193 int i;194 193 IssmDouble r,s; 195 194 IssmDouble vx,vy,vz,vmag; … … 257 256 258 257 /*diverse: */ 259 int i;260 258 IssmDouble r,s; 261 259 IssmDouble vx,vy,vz,vmag; -
issm/trunk/src/c/classes/objects/Loads/Friction.h
r13395 r13975 25 25 Friction(const char* element_type, Inputs* inputs,Matpar* matpar, int analysis_type); 26 26 ~Friction(); 27 27 28 28 void Echo(void); 29 29 void GetAlpha2(IssmDouble* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum); -
issm/trunk/src/c/classes/objects/Loads/Icefront.cpp
r13395 r13975 52 52 int icefront_node_ids[NUMVERTICESQUA]; //initialize with largest size 53 53 int icefront_fill; 54 54 55 55 /*find parameters: */ 56 56 iomodel->Constant(&dim,MeshDimensionEnum); … … 90 90 /*Fill*/ 91 91 icefront_fill=reCast<int>(iomodel->Data(DiagnosticIcefrontEnum)[segment_width*i+segment_width-1]); 92 92 93 93 /*Ok, we have everything to build the object: */ 94 94 this->id=icefront_id; … … 104 104 this->inputs->AddInput(new IntInput(FillEnum,icefront_fill)); 105 105 this->inputs->AddInput(new IntInput(TypeEnum,in_icefront_type)); 106 106 107 107 //parameters and hooked fields: we still can't point to them, they may not even exist. Configure will handle this. 108 108 this->parameters=NULL; … … 111 111 this->matpar= NULL; 112 112 } 113 114 113 115 114 /*}}}*/ … … 157 156 int Icefront::Id(void){ return id; } 158 157 /*}}}*/ 159 /*FUNCTION Icefront::MyRank {{{*/160 int Icefront::MyRank(void){161 extern int my_rank;162 return my_rank;163 }164 /*}}}*/165 158 /*FUNCTION Icefront::ObjectEnum{{{*/ 166 159 int Icefront::ObjectEnum(void){ … … 172 165 /*FUNCTION Icefront::copy {{{*/ 173 166 Object* Icefront::copy() { 174 167 175 168 Icefront* icefront=NULL; 176 169 … … 278 271 } 279 272 /*}}}*/ 273 /*FUNCTION Icefront::GetNodesSidList{{{*/ 274 void Icefront::GetNodesSidList(int* sidlist){ 275 276 int type; 277 inputs->GetInputValue(&type,TypeEnum); 278 _assert_(sidlist); 279 _assert_(nodes); 280 281 switch(type){ 282 case MacAyeal2dIceFrontEnum: 283 case MacAyeal3dIceFrontEnum: 284 for(int i=0;i<NUMVERTICESSEG;i++) sidlist[i]=nodes[i]->Sid(); 285 return; 286 #ifdef _HAVE_3D_ 287 case PattynIceFrontEnum: 288 case StokesIceFrontEnum: 289 for(int i=0;i<NUMVERTICESQUA;i++) sidlist[i]=nodes[i]->Sid(); 290 return; 291 #endif 292 default: 293 _error_("Icefront type " << EnumToStringx(type) << " not supported yet"); 294 } 295 } 296 /*}}}*/ 297 /*FUNCTION Icefront::GetNumberOfNodes{{{*/ 298 int Icefront::GetNumberOfNodes(void){ 299 300 int type; 301 inputs->GetInputValue(&type,TypeEnum); 302 303 switch(type){ 304 case MacAyeal2dIceFrontEnum: 305 return NUMVERTICESSEG; 306 #ifdef _HAVE_3D_ 307 case MacAyeal3dIceFrontEnum: 308 return NUMVERTICESSEG; 309 case PattynIceFrontEnum: 310 return NUMVERTICESQUA; 311 case StokesIceFrontEnum: 312 return NUMVERTICESQUA; 313 #endif 314 default: 315 _error_("Icefront type " << EnumToStringx(type) << " not supported yet"); 316 } 317 318 } 319 /*}}}*/ 320 /*FUNCTION Icefront::IsPenalty{{{*/ 321 bool Icefront::IsPenalty(void){ 322 return false; 323 } 324 /*}}}*/ 280 325 /*FUNCTION Icefront::PenaltyCreateKMatrix {{{*/ 281 326 void Icefront::PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs, IssmDouble kmax){ … … 293 338 void Icefront::PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){ 294 339 this->PenaltyCreateKMatrix(Jff,NULL,kmax); 340 } 341 /*}}}*/ 342 /*FUNCTION Icefront::SetwiseNodeConnectivity{{{*/ 343 void Icefront::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){ 344 345 /*Output */ 346 int d_nz = 0; 347 int o_nz = 0; 348 349 /*Loop over all nodes*/ 350 for(int i=0;i<this->GetNumberOfNodes();i++){ 351 352 if(!flags[this->nodes[i]->Sid()]){ 353 354 /*flag current node so that no other element processes it*/ 355 flags[this->nodes[i]->Sid()]=true; 356 357 /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/ 358 switch(set2_enum){ 359 case FsetEnum: 360 if(nodes[i]->indexing.fsize){ 361 if(this->nodes[i]->IsClone()) 362 o_nz += 1; 363 else 364 d_nz += 1; 365 } 366 break; 367 case GsetEnum: 368 if(nodes[i]->indexing.gsize){ 369 if(this->nodes[i]->IsClone()) 370 o_nz += 1; 371 else 372 d_nz += 1; 373 } 374 break; 375 case SsetEnum: 376 if(nodes[i]->indexing.ssize){ 377 if(this->nodes[i]->IsClone()) 378 o_nz += 1; 379 else 380 d_nz += 1; 381 } 382 break; 383 default: _error_("not supported"); 384 } 385 } 386 } 387 388 /*Assign output pointers: */ 389 *pd_nz=d_nz; 390 *po_nz=o_nz; 295 391 } 296 392 /*}}}*/ … … 479 575 ElementVector* Icefront::CreatePVectorDiagnosticMacAyeal3d(void){ 480 576 481 Icefront* icefront=NULL; 482 Penta* penta=NULL; 483 Tria* tria=NULL; 484 bool onbed; 577 Icefront *icefront = NULL; 578 Penta *penta = NULL; 579 Tria *tria = NULL; 485 580 486 581 /*Cast element onto Penta*/ … … 663 758 void Icefront::GetDofList(int** pdoflist,int approximation_enum,int setenum){ 664 759 665 int i,j;666 760 int numberofdofs=0; 667 761 int count=0; … … 672 766 int* doflist=NULL; 673 767 674 675 768 /*recover type: */ 676 769 inputs->GetInputValue(&type,TypeEnum); … … 678 771 /*Some checks for debugging*/ 679 772 _assert_(nodes); 680 773 681 774 /*How many nodes? :*/ 682 775 if(type==MacAyeal2dIceFrontEnum || type==MacAyeal3dIceFrontEnum) … … 684 777 else 685 778 numberofnodes=4; 686 779 687 780 /*Figure out size of doflist: */ 688 for(i =0;i<numberofnodes;i++){781 for(int i=0;i<numberofnodes;i++){ 689 782 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 690 783 } … … 695 788 /*Populate: */ 696 789 count=0; 697 for(i =0;i<numberofnodes;i++){790 for(int i=0;i<numberofnodes;i++){ 698 791 nodes[i]->GetDofList(doflist+count,approximation_enum,setenum); 699 792 count+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); -
issm/trunk/src/c/classes/objects/Loads/Icefront.h
r13395 r13975 48 48 void DeepEcho(); 49 49 int Id(); 50 int MyRank();51 50 int ObjectEnum(); 52 51 Object* copy(); … … 72 71 void CreatePVector(Vector<IssmDouble>* pf); 73 72 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff); 73 int GetNumberOfNodes(void); 74 void GetNodesSidList(int* sidlist); 75 bool IsPenalty(void); 74 76 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax); 75 77 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); 76 78 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax); 79 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum); 77 80 bool InAnalysis(int analysis_type); 78 81 /*}}}*/ -
issm/trunk/src/c/classes/objects/Loads/Load.h
r13395 r13975 4 4 * It is derived from Load, so DataSets can contain them. 5 5 */ 6 7 6 8 7 #ifndef _LOAD_H_ … … 25 24 26 25 virtual ~Load(){}; 27 28 /*Virtual functions: {{{*/29 26 virtual void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0; 27 virtual bool IsPenalty(void)=0; 28 virtual int GetNumberOfNodes(void)=0; 29 virtual void GetNodesSidList(int* sidlist)=0; 30 30 virtual void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0; 31 31 virtual void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs)=0; … … 36 36 virtual void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax)=0; 37 37 virtual bool InAnalysis(int analysis_type)=0; 38 /*}}}*/38 virtual void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum)=0; 39 39 }; 40 40 #endif -
issm/trunk/src/c/classes/objects/Loads/Numericalflux.cpp
r13395 r13975 34 34 } 35 35 /*}}}*/ 36 /* }}}*//*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel, int analysis_type) {{{*/36 /*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel, int analysis_type) {{{*/ 37 37 Numericalflux::Numericalflux(int numericalflux_id,int i, IoModel* iomodel, int in_analysis_type){ 38 38 … … 175 175 _printLine_(" inputs"); 176 176 inputs->DeepEcho(); 177 177 178 178 } 179 179 /*}}}*/ … … 183 183 } 184 184 /*}}}*/ 185 /*FUNCTION Numericalflux::MyRank {{{*/186 int Numericalflux::MyRank(void){187 extern int my_rank;188 return my_rank;189 }190 /*}}}*/191 185 /*FUNCTION Numericalflux::ObjectEnum{{{*/ 192 186 int Numericalflux::ObjectEnum(void){ … … 198 192 /*FUNCTION Numericalflux::copy {{{*/ 199 193 Object* Numericalflux::copy() { 200 194 201 195 Numericalflux* numericalflux=NULL; 202 196 … … 311 305 } 312 306 /*}}}*/ 307 /*FUNCTION Numericalflux::GetNodesSidList{{{*/ 308 void Numericalflux::GetNodesSidList(int* sidlist){ 309 310 int type; 311 inputs->GetInputValue(&type,TypeEnum); 312 _assert_(sidlist); 313 _assert_(nodes); 314 315 switch(type){ 316 case InternalEnum: 317 for(int i=0;i<NUMVERTICES_INTERNAL;i++) sidlist[i]=nodes[i]->Sid(); 318 return; 319 case BoundaryEnum: 320 for(int i=0;i<NUMVERTICES_BOUNDARY;i++) sidlist[i]=nodes[i]->Sid(); 321 return; 322 default: 323 _error_("Numericalflux type " << EnumToStringx(type) << " not supported yet"); 324 } 325 } 326 /*}}}*/ 327 /*FUNCTION Numericalflux::GetNumberOfNodes{{{*/ 328 int Numericalflux::GetNumberOfNodes(void){ 329 330 int type; 331 inputs->GetInputValue(&type,TypeEnum); 332 333 switch(type){ 334 case InternalEnum: 335 return NUMVERTICES_INTERNAL; 336 case BoundaryEnum: 337 return NUMVERTICES_BOUNDARY; 338 default: 339 _error_("Numericalflux type " << EnumToStringx(type) << " not supported yet"); 340 } 341 342 } 343 /*}}}*/ 344 /*FUNCTION Numericalflux::IsPenalty{{{*/ 345 bool Numericalflux::IsPenalty(void){ 346 return false; 347 } 348 /*}}}*/ 313 349 /*FUNCTION Numericalflux::PenaltyCreateKMatrix {{{*/ 314 350 void Numericalflux::PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,IssmDouble kmax){ … … 331 367 if (in_analysis_type==this->analysis_type) return true; 332 368 else return false; 369 } 370 /*}}}*/ 371 /*FUNCTION Numericalflux::SetwiseNodeConnectivity{{{*/ 372 void Numericalflux::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){ 373 374 /*Output */ 375 int d_nz = 0; 376 int o_nz = 0; 377 378 /*Loop over all nodes*/ 379 for(int i=0;i<this->GetNumberOfNodes();i++){ 380 381 if(!flags[this->nodes[i]->Sid()]){ 382 383 /*flag current node so that no other element processes it*/ 384 flags[this->nodes[i]->Sid()]=true; 385 386 /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/ 387 switch(set2_enum){ 388 case FsetEnum: 389 if(nodes[i]->indexing.fsize){ 390 if(this->nodes[i]->IsClone()) 391 o_nz += 1; 392 else 393 d_nz += 1; 394 } 395 break; 396 case GsetEnum: 397 if(nodes[i]->indexing.gsize){ 398 if(this->nodes[i]->IsClone()) 399 o_nz += 1; 400 else 401 d_nz += 1; 402 } 403 break; 404 case SsetEnum: 405 if(nodes[i]->indexing.ssize){ 406 if(this->nodes[i]->IsClone()) 407 o_nz += 1; 408 else 409 d_nz += 1; 410 } 411 break; 412 default: _error_("not supported"); 413 } 414 } 415 } 416 417 /*Assign output pointers: */ 418 *pd_nz=d_nz; 419 *po_nz=o_nz; 333 420 } 334 421 /*}}}*/ … … 410 497 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g2[i][j]; 411 498 } 412 499 413 500 /*Clean up and return*/ 414 501 delete gauss; … … 702 789 703 790 /* Intermediaries*/ 704 int i, j,ig,index1,index2;791 int i,ig,index1,index2; 705 792 IssmDouble DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN,thickness; 706 793 IssmDouble xyz_list[NUMVERTICES_BOUNDARY][3]; … … 796 883 797 884 /* Intermediaries*/ 798 int i, j,ig,index1,index2;799 IssmDouble 800 IssmDouble 801 IssmDouble 802 IssmDouble 885 int i,ig,index1,index2; 886 IssmDouble DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN,thickness; 887 IssmDouble xyz_list[NUMVERTICES_BOUNDARY][3]; 888 IssmDouble normal[2]; 889 IssmDouble L[numdof]; 803 890 GaussTria *gauss; 804 891 -
issm/trunk/src/c/classes/objects/Loads/Numericalflux.h
r13395 r13975 20 20 21 21 public: 22 int 22 int id; 23 23 int analysis_type; 24 24 25 25 /*Hooks*/ 26 Hook *helement;27 Hook *hnodes;26 Hook *helement; 27 Hook *hnodes; 28 28 29 29 /*Corresponding fields*/ 30 Element* element; 31 Node** nodes; 32 33 Parameters *parameters; 34 Inputs *inputs; 35 30 Element *element; 31 Node **nodes; 32 Parameters *parameters; 33 Inputs *inputs; 36 34 37 35 /*Numericalflux constructors,destructors {{{*/ … … 44 42 void DeepEcho(); 45 43 int Id(); 46 int MyRank();47 44 int ObjectEnum(); 48 45 Object* copy(); … … 67 64 void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs); 68 65 void CreatePVector(Vector<IssmDouble>* pf); 66 void GetNodesSidList(int* sidlist); 67 int GetNumberOfNodes(void); 69 68 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");}; 69 bool IsPenalty(void); 70 70 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");}; 71 71 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax); 72 72 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); 73 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum); 73 74 bool InAnalysis(int analysis_type); 74 75 /*}}}*/ -
issm/trunk/src/c/classes/objects/Loads/Pengrid.cpp
r13395 r13975 19 19 #include "../../../Container/Container.h" 20 20 /*}}}*/ 21 21 22 22 /*Element macros*/ 23 23 #define NUMVERTICES 1 … … 34 34 this->hmatpar=NULL; 35 35 this->matpar=NULL; 36 36 37 37 /*not active, not zigzagging: */ 38 38 active=0; … … 44 44 Pengrid::Pengrid(int id, int index, IoModel* iomodel, int in_analysis_type){ //i is the element index 45 45 46 int i,j;47 46 int pengrid_node_id; 48 47 int pengrid_matpar_id; … … 64 63 this->id=id; 65 64 this->analysis_type=in_analysis_type; 66 65 67 66 /*hooks: */ 68 67 pengrid_node_id=iomodel->nodecounter+index+1; … … 99 98 } 100 99 /*}}}*/ 101 100 102 101 /*Object virtual functions definitions:*/ 103 102 /*FUNCTION Pengrid::Echo {{{*/ … … 126 125 int Pengrid::Id(void){ return id; } 127 126 /*}}}*/ 128 /*FUNCTION Pengrid::MyRank {{{*/129 int Pengrid::MyRank(void){130 extern int my_rank;131 return my_rank;132 }133 /*}}}*/134 127 /*FUNCTION Pengrid::ObjectEnum{{{*/ 135 128 int Pengrid::ObjectEnum(void){ … … 140 133 /*FUNCTION Icefront::copy {{{*/ 141 134 Object* Pengrid::copy() { 142 135 143 136 Pengrid* pengrid=NULL; 144 137 … … 214 207 return; 215 208 209 } 210 /*}}}*/ 211 /*FUNCTION Pengrid::GetNodesSidList{{{*/ 212 void Pengrid::GetNodesSidList(int* sidlist){ 213 214 _assert_(sidlist); 215 _assert_(node); 216 217 sidlist[0]=node->Sid(); 218 } 219 /*}}}*/ 220 /*FUNCTION Pengrid::GetNumberOfNodes{{{*/ 221 int Pengrid::GetNumberOfNodes(void){ 222 223 return NUMVERTICES; 216 224 } 217 225 /*}}}*/ … … 287 295 } 288 296 /*}}}*/ 297 /*FUNCTION Pengrid::IsPenalty{{{*/ 298 bool Pengrid::IsPenalty(void){ 299 return true; 300 } 301 /*}}}*/ 302 /*FUNCTION Pengrid::SetwiseNodeConnectivity{{{*/ 303 void Pengrid::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){ 304 305 /*Output */ 306 int d_nz = 0; 307 int o_nz = 0; 308 309 if(!flags[this->node->Sid()]){ 310 311 /*flag current node so that no other element processes it*/ 312 flags[this->node->Sid()]=true; 313 314 /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/ 315 switch(set2_enum){ 316 case FsetEnum: 317 if(node->indexing.fsize){ 318 if(this->node->IsClone()) 319 o_nz += 1; 320 else 321 d_nz += 1; 322 } 323 break; 324 case GsetEnum: 325 if(node->indexing.gsize){ 326 if(this->node->IsClone()) 327 o_nz += 1; 328 else 329 d_nz += 1; 330 } 331 break; 332 case SsetEnum: 333 if(node->indexing.ssize){ 334 if(this->node->IsClone()) 335 o_nz += 1; 336 else 337 d_nz += 1; 338 } 339 break; 340 default: _error_("not supported"); 341 } 342 } 343 344 /*Assign output pointers: */ 345 *pd_nz=d_nz; 346 *po_nz=o_nz; 347 } 348 /*}}}*/ 289 349 290 350 /*Update virtual functions definitions:*/ … … 401 461 /*recover pointers: */ 402 462 Penta* penta=(Penta*)element; 403 463 404 464 /*check that pengrid is not a clone (penalty to be added only once)*/ 405 465 if (node->IsClone()){ … … 415 475 //Recover our data: 416 476 parameters->FindParam(&penalty_lock,ThermalPenaltyLockEnum); 417 477 418 478 //Compute pressure melting point 419 479 t_pmp=matpar->TMeltingPoint(pressure); … … 427 487 new_active=0; 428 488 } 429 430 489 431 490 //Figure out stability of this penalty … … 456 515 /*FUNCTION Pengrid::PenaltyCreateKMatrixDiagnosticStokes {{{*/ 457 516 ElementMatrix* Pengrid::PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax){ 458 517 459 518 const int numdof = NUMVERTICES *NDOF4; 460 519 IssmDouble slope[2]; … … 505 564 penta->GetInputValue(&temperature,node,TemperatureEnum); 506 565 parameters->FindParam(&penalty_factor,ThermalPenaltyFactorEnum); 507 566 508 567 /*Compute pressure melting point*/ 509 568 t_pmp=matpar->GetMeltingPoint()-matpar->GetBeta()*pressure; … … 539 598 /*FUNCTION Pengrid::PenaltyCreatePVectorMelting {{{*/ 540 599 ElementVector* Pengrid::PenaltyCreatePVectorMelting(IssmDouble kmax){ 541 600 542 601 const int numdof=NUMVERTICES*NDOF1; 543 602 IssmDouble pressure; -
issm/trunk/src/c/classes/objects/Loads/Pengrid.h
r13395 r13975 20 20 int id; 21 21 int analysis_type; 22 22 23 23 /*Hooks*/ 24 24 Hook* hnode; //hook to 1 node … … 33 33 Parameters* parameters; //pointer to solution parameters 34 34 Inputs* inputs; 35 35 36 36 /*internals: */ 37 37 int active; … … 49 49 void DeepEcho(); 50 50 int Id(); 51 int MyRank();52 51 int ObjectEnum(); 53 52 Object* copy(); … … 73 72 void CreatePVector(Vector<IssmDouble>* pf); 74 73 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");}; 74 void GetNodesSidList(int* sidlist); 75 int GetNumberOfNodes(void); 76 bool IsPenalty(void); 75 77 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");}; 76 78 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax); 77 79 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); 80 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum); 78 81 bool InAnalysis(int analysis_type); 79 82 /*}}}*/ … … 97 100 98 101 #endif /* _PENGRID_H_ */ 99 100 -
issm/trunk/src/c/classes/objects/Loads/Penpair.cpp
r13395 r13975 34 34 /*FUNCTION Penpair::creation {{{*/ 35 35 Penpair::Penpair(int penpair_id, int* penpair_node_ids,int in_analysis_type){ 36 36 37 37 this->id=penpair_id; 38 38 this->analysis_type=in_analysis_type; … … 40 40 this->parameters=NULL; 41 41 this->nodes=NULL; 42 42 43 43 return; 44 44 } … … 54 54 /*FUNCTION Penpair::Echo {{{*/ 55 55 void Penpair::Echo(void){ 56 57 int i;58 56 59 57 _printLine_("Penpair:"); … … 61 59 _printLine_(" analysis_type: " << EnumToStringx(analysis_type)); 62 60 hnodes->Echo(); 63 61 64 62 return; 65 63 } … … 79 77 int Penpair::Id(void){ return id; } 80 78 /*}}}*/ 81 /*FUNCTION Penpair::MyRank {{{*/82 int Penpair::MyRank(void){83 extern int my_rank;84 return my_rank;85 }86 /*}}}*/87 79 /*FUNCTION Penpair::ObjectEnum{{{*/ 88 80 int Penpair::ObjectEnum(void){ … … 93 85 /*FUNCTION Penpair::copy {{{*/ 94 86 Object* Penpair::copy() { 95 87 96 88 Penpair* penpair=NULL; 97 89 … … 113 105 } 114 106 /*}}}*/ 115 107 116 108 /*Load virtual functions definitions:*/ 117 109 /*FUNCTION Penpair::Configure {{{*/ … … 154 146 void Penpair::CreateJacobianMatrix(Matrix<IssmDouble>* Jff){ 155 147 this->CreateKMatrix(Jff,NULL); 148 } 149 /*}}}*/ 150 /*FUNCTION Penpair::GetNodesSidList{{{*/ 151 void Penpair::GetNodesSidList(int* sidlist){ 152 153 _assert_(sidlist); 154 _assert_(nodes); 155 156 for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->Sid(); 157 } 158 /*}}}*/ 159 /*FUNCTION Penpair::GetNumberOfNodes{{{*/ 160 int Penpair::GetNumberOfNodes(void){ 161 162 return NUMVERTICES; 163 } 164 /*}}}*/ 165 /*FUNCTION Penpair::IsPenalty{{{*/ 166 bool Penpair::IsPenalty(void){ 167 return true; 156 168 } 157 169 /*}}}*/ … … 197 209 if (in_analysis_type==this->analysis_type)return true; 198 210 else return false; 211 } 212 /*}}}*/ 213 /*FUNCTION Penpair::SetwiseNodeConnectivity{{{*/ 214 void Penpair::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){ 215 216 /*Output */ 217 int d_nz = 0; 218 int o_nz = 0; 219 220 /*Loop over all nodes*/ 221 for(int i=0;i<NUMVERTICES;i++){ 222 223 if(!flags[this->nodes[i]->Sid()]){ 224 225 /*flag current node so that no other element processes it*/ 226 flags[this->nodes[i]->Sid()]=true; 227 228 /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/ 229 switch(set2_enum){ 230 case FsetEnum: 231 if(nodes[i]->indexing.fsize){ 232 if(this->nodes[i]->IsClone()) 233 o_nz += 1; 234 else 235 d_nz += 1; 236 } 237 break; 238 case GsetEnum: 239 if(nodes[i]->indexing.gsize){ 240 if(this->nodes[i]->IsClone()) 241 o_nz += 1; 242 else 243 d_nz += 1; 244 } 245 break; 246 case SsetEnum: 247 if(nodes[i]->indexing.ssize){ 248 if(this->nodes[i]->IsClone()) 249 o_nz += 1; 250 else 251 d_nz += 1; 252 } 253 break; 254 default: _error_("not supported"); 255 } 256 } 257 } 258 259 /*Assign output pointers: */ 260 *pd_nz=d_nz; 261 *po_nz=o_nz; 199 262 } 200 263 /*}}}*/ … … 270 333 /*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn {{{*/ 271 334 ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn(IssmDouble kmax){ 272 335 273 336 const int numdof=NUMVERTICES*NDOF2; 274 337 IssmDouble penalty_offset; … … 297 360 /*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticStokes {{{*/ 298 361 ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax){ 299 362 300 363 const int numdof=NUMVERTICES*NDOF4; 301 364 IssmDouble penalty_offset; … … 317 380 Ke->values[5*numdof+1]=-kmax*pow((IssmDouble)10.0,penalty_offset); 318 381 Ke->values[5*numdof+5]=+kmax*pow((IssmDouble)10.0,penalty_offset); 319 382 320 383 Ke->values[2*numdof+2]=+kmax*pow((IssmDouble)10.0,penalty_offset); 321 384 Ke->values[2*numdof+6]=-kmax*pow((IssmDouble)10.0,penalty_offset); -
issm/trunk/src/c/classes/objects/Loads/Penpair.h
r13395 r13975 17 17 18 18 private: 19 int id; 20 int analysis_type; 21 22 Hook* hnodes; //hook to 2 nodes 23 Node** nodes; 24 25 Parameters* parameters; //pointer to solution parameters 19 int id; 20 int analysis_type; 21 Hook *hnodes; //hook to 2 nodes 22 Node **nodes; 23 Parameters *parameters; //pointer to solution parameters 26 24 27 25 public: … … 36 34 void DeepEcho(); 37 35 int Id(); 38 int MyRank();39 36 int ObjectEnum(); 40 37 Object* copy(); … … 60 57 void CreatePVector(Vector<IssmDouble>* pf); 61 58 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff); 59 void GetNodesSidList(int* sidlist); 60 int GetNumberOfNodes(void); 61 bool IsPenalty(void); 62 62 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff,Matrix<IssmDouble>* Kfs,IssmDouble kmax); 63 63 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); 64 64 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax); 65 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum); 65 66 bool InAnalysis(int analysis_type); 66 67 /*}}}*/ … … 74 75 75 76 #endif /* _PENPAIR_H_ */ 76 77 -
issm/trunk/src/c/classes/objects/Loads/Riftfront.cpp
r13395 r13975 97 97 //intialize inputs, and add as many inputs per element as requested: 98 98 this->inputs=new Inputs(); 99 99 100 100 riftfront_type=SegmentRiftfrontEnum; 101 101 riftfront_fill = reCast<int,IssmDouble>(*(iomodel->Data(RiftsRiftstructEnum)+RIFTINFOSIZE*i+7)); … … 109 109 this->inputs->AddInput(new DoubleInput(FractionIncrementEnum,riftfront_fractionincrement)); 110 110 this->inputs->AddInput(new BoolInput(SegmentOnIceShelfEnum,riftfront_shelf)); 111 111 112 112 //parameters and hooked fields: we still can't point to them, they may not even exist. Configure will handle this. 113 113 this->parameters=NULL; … … 115 115 this->elements= NULL; 116 116 this->matpar= NULL; 117 117 118 118 } 119 119 /*}}}*/ … … 137 137 IssmDouble friction,fractionincrement; 138 138 139 140 139 /*recover some inputs first: */ 141 140 input=(Input*)this->inputs->GetInput(FillEnum); input->GetInputValue(&fill); … … 165 164 _printLine_(" state: " << state); 166 165 _printLine_(" frozen: " << (frozen ? "true":"false")); 167 166 168 167 } 169 168 /*}}}*/ … … 186 185 int Riftfront::Id(void){ return id; } 187 186 /*}}}*/ 188 /*FUNCTION Riftfront::MyRank {{{*/189 int Riftfront::MyRank(void){190 extern int my_rank;191 return my_rank;192 }193 /*}}}*/194 187 /*FUNCTION Riftfront::ObjectEnum{{{*/ 195 188 int Riftfront::ObjectEnum(void){ … … 201 194 /*FUNCTION Riftfront::copy {{{*/ 202 195 Object* Riftfront::copy() { 203 196 204 197 Riftfront* riftfront=NULL; 205 198 … … 240 233 riftfront->length=this->length; 241 234 riftfront->fraction=this->fraction; 242 235 243 236 return riftfront; 244 237 245 238 } 246 239 /*}}}*/ 247 240 248 241 /*Update virtual functions definitions:*/ 249 242 /*FUNCTION Riftfront::InputUpdateFromConstant(bool constant,int name) {{{*/ … … 281 274 } 282 275 /*}}}*/ 283 284 276 285 277 /*Load virtual functions definitions:*/ … … 301 293 this->parameters=parametersin; 302 294 295 } 296 /*}}}*/ 297 /*FUNCTION Riftfront::IsPenalty{{{*/ 298 bool Riftfront::IsPenalty(void){ 299 return true; 303 300 } 304 301 /*}}}*/ … … 372 369 } 373 370 /*}}}*/ 371 /*FUNCTION Riftfront::GetNodesSidList{{{*/ 372 void Riftfront::GetNodesSidList(int* sidlist){ 373 374 _assert_(sidlist); 375 _assert_(nodes); 376 377 for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->Sid(); 378 } 379 /*}}}*/ 380 /*FUNCTION Riftfront::GetNumberOfNodes{{{*/ 381 int Riftfront::GetNumberOfNodes(void){ 382 383 return NUMVERTICES; 384 } 385 /*}}}*/ 374 386 /*FUNCTION Riftfront::InAnalysis{{{*/ 375 387 bool Riftfront::InAnalysis(int in_analysis_type){ … … 378 390 } 379 391 /*}}}*/ 392 /*FUNCTION Riftfront::SetwiseNodeConnectivity{{{*/ 393 void Riftfront::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){ 394 395 /*Output */ 396 int d_nz = 0; 397 int o_nz = 0; 398 399 /*Loop over all nodes*/ 400 for(int i=0;i<NUMVERTICES;i++){ 401 402 if(!flags[this->nodes[i]->Sid()]){ 403 404 /*flag current node so that no other element processes it*/ 405 flags[this->nodes[i]->Sid()]=true; 406 407 /*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/ 408 switch(set2_enum){ 409 case FsetEnum: 410 if(nodes[i]->indexing.fsize){ 411 if(this->nodes[i]->IsClone()) 412 o_nz += 1; 413 else 414 d_nz += 1; 415 } 416 break; 417 case GsetEnum: 418 if(nodes[i]->indexing.gsize){ 419 if(this->nodes[i]->IsClone()) 420 o_nz += 1; 421 else 422 d_nz += 1; 423 } 424 break; 425 case SsetEnum: 426 if(nodes[i]->indexing.ssize){ 427 if(this->nodes[i]->IsClone()) 428 o_nz += 1; 429 else 430 d_nz += 1; 431 } 432 break; 433 default: _error_("not supported"); 434 } 435 } 436 } 437 438 /*Assign output pointers: */ 439 *pd_nz=d_nz; 440 *po_nz=o_nz; 441 } 442 /*}}}*/ 380 443 381 444 /*Riftfront numerics*/ … … 384 447 385 448 const int numdof = NDOF2*NUMVERTICES; 386 int i,j;387 449 int dofs[1] = {0}; 388 IssmDouble Ke_gg[4][4]; 389 IssmDouble thickness; 390 IssmDouble h[2]; 391 IssmDouble penalty_offset; 392 IssmDouble friction; 450 IssmDouble thickness; 451 IssmDouble h[2]; 452 IssmDouble penalty_offset; 453 IssmDouble friction; 393 454 394 455 /*Objects: */ … … 466 527 ElementVector* Riftfront::PenaltyCreatePVectorDiagnosticHoriz(IssmDouble kmax){ 467 528 468 const int 469 int i,j;470 IssmDouble 471 IssmDouble 472 IssmDouble 473 IssmDouble 474 IssmDouble 475 IssmDouble 476 IssmDouble 477 IssmDouble 478 IssmDouble 479 IssmDouble 480 IssmDouble 481 IssmDouble 482 int 483 bool 529 const int numdof = NDOF2*NUMVERTICES; 530 int j; 531 IssmDouble rho_ice; 532 IssmDouble rho_water; 533 IssmDouble gravity; 534 IssmDouble thickness; 535 IssmDouble h[2]; 536 IssmDouble bed; 537 IssmDouble b[2]; 538 IssmDouble pressure; 539 IssmDouble pressure_litho; 540 IssmDouble pressure_air; 541 IssmDouble pressure_melange; 542 IssmDouble pressure_water; 543 int fill; 544 bool shelf; 484 545 485 546 /*Objects: */ 486 Tria *tria1= NULL;487 Tria *tria2= NULL;547 Tria *tria1 = NULL; 548 Tria *tria2 = NULL; 488 549 489 550 /*enum of element? */ … … 569 630 570 631 const int numnodes = 2; 571 IssmDouble max_penetration;572 632 IssmDouble penetration; 573 633 int activate; 574 int found;575 634 int unstable; 576 635 IssmDouble vx1; … … 602 661 if(this->state==OpenEnum)this->active=0; 603 662 if(this->state==ClosedEnum)this->active=1; 604 663 605 664 /*this segment is like frozen, no instability here: */ 606 665 *punstable=0; 607 666 return 1; 608 667 } 609 610 668 611 669 /*recover parameters: */ … … 674 732 int Riftfront::IsMaterialStable(void){ 675 733 676 int found=0;677 734 IssmDouble converged=0; 678 735 … … 693 750 694 751 const int numnodes=2; 695 IssmDouble max_penetration;696 752 IssmDouble penetration=0; 697 int found;698 753 IssmDouble vx1; 699 754 IssmDouble vy1; … … 729 784 /*If we are zigzag locked, same thing: */ 730 785 if(this->counter>this->penalty_lock)penetration=-1; 731 786 732 787 /*assign output pointer: */ 733 788 *ppenetration=penetration; … … 744 799 745 800 IssmDouble penetration; 746 int found;747 801 748 802 /*Objects: */ … … 768 822 /*Now, we return penetration only if we are active!: */ 769 823 if(this->active==0)penetration=0; 770 824 771 825 /*assign output pointer: */ 772 826 *ppenetration=penetration; … … 777 831 int Riftfront::PotentialUnstableConstraint(int* punstable){ 778 832 779 780 833 const int numnodes = 2; 781 IssmDouble max_penetration; 782 IssmDouble penetration; 783 int activate; 834 IssmDouble penetration; 784 835 int unstable; 785 int found; 786 IssmDouble vx1; 787 IssmDouble vy1; 788 IssmDouble vx2; 789 IssmDouble vy2; 836 IssmDouble vx1; 837 IssmDouble vy1; 838 IssmDouble vx2; 839 IssmDouble vy2; 790 840 791 841 /*Objects: */ 792 Tria *tria1 793 Tria *tria2 842 Tria *tria1 = NULL; 843 Tria *tria2 = NULL; 794 844 795 845 /*enum of element? */ … … 833 883 IssmDouble penetration; 834 884 int unstable; 835 int found;836 885 IssmDouble vx1; 837 886 IssmDouble vy1; -
issm/trunk/src/c/classes/objects/Loads/Riftfront.h
r13395 r13975 25 25 Hook* helements; 26 26 Hook* hmatpar; 27 27 28 28 /*Corresponding fields*/ 29 29 Matpar *matpar; … … 32 32 33 33 /*computational: */ 34 int penalty_lock; 35 bool active; 36 bool frozen; 37 int counter; 38 bool prestable; 39 bool material_converged; 40 IssmDouble normal[2]; 41 IssmDouble length; 42 IssmDouble fraction; 43 int state; 44 45 Parameters* parameters; //pointer to solution parameters 46 Inputs* inputs; 34 int penalty_lock; 35 bool active; 36 bool frozen; 37 int counter; 38 bool prestable; 39 bool material_converged; 40 IssmDouble normal[2]; 41 IssmDouble length; 42 IssmDouble fraction; 43 int state; 47 44 45 Parameters *parameters; //pointer to solution parameters 46 Inputs *inputs; 48 47 49 48 /*Riftfrontconstructors,destructors: {{{*/ … … 56 55 void DeepEcho(); 57 56 int Id(); 58 int MyRank();59 57 int ObjectEnum(); 60 58 Object* copy(); … … 80 78 void CreatePVector(Vector<IssmDouble>* pf); 81 79 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");}; 80 void GetNodesSidList(int* sidlist); 81 int GetNumberOfNodes(void); 82 bool IsPenalty(void); 82 83 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");}; 83 84 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax); 84 85 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); 86 void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum); 85 87 bool InAnalysis(int analysis_type); 86 88 /*}}}*/ -
issm/trunk/src/c/classes/objects/Materials/Matdamageice.cpp
r13395 r13975 15 15 #include "../../../shared/shared.h" 16 16 #include "../../../include/include.h" 17 17 18 18 /*Matdamageice constructors and destructor*/ 19 19 /*FUNCTION Matdamageice::Matdamageice(){{{*/ … … 28 28 29 29 /*Intermediaries:*/ 30 int i;31 30 int matice_eid; 32 31 … … 82 81 int Matdamageice::Id(void){ return mid; } 83 82 /*}}}*/ 84 /*FUNCTION Matdamageice::MyRank {{{*/85 int Matdamageice::MyRank(void){86 extern int my_rank;87 return my_rank;88 }89 /*}}}*/90 83 /*FUNCTION Matdamageice::ObjectEnum{{{*/ 91 84 int Matdamageice::ObjectEnum(void){ … … 210 203 /*Prepare index list*/ 211 204 int doflist1[3]; 212 for(int i=0;i<3;i++) doflist1[i]=((Tria*)element)->nodes[i]->GetVertex Dof();205 for(int i=0;i<3;i++) doflist1[i]=((Tria*)element)->nodes[i]->GetVertexPid(); 213 206 214 207 /*Get input (either in element or material)*/ … … 305 298 * return g, initial viscosity. 306 299 */ 307 300 308 301 /*output: */ 309 302 IssmDouble viscosity3d; … … 347 340 else{ 348 341 e=(n-1)/2/n; 349 342 350 343 viscosity3d=B/(2*pow(A,e)); 351 344 } … … 376 369 * return g, initial viscosity. 377 370 */ 378 371 379 372 /*output: */ 380 373 IssmDouble viscosity3d; … … 393 386 Z=GetZ(); 394 387 B=Z*GetB(); 395 388 396 389 if (n==1){ 397 390 /*Viscous behaviour! viscosity3d=B: */ … … 446 439 * return mu20, initial viscosity. 447 440 */ 448 441 449 442 /*output: */ 450 443 IssmDouble viscosity_complement; … … 474 467 else{ 475 468 e=(n-1)/(2*n); 476 469 477 470 viscosity_complement=1/(2*pow(A,e)); 478 471 } … … 486 479 _assert_(n>0); 487 480 _assert_(viscosity_complement>0); 488 481 489 482 /*Return: */ 490 483 *pviscosity_complement=viscosity_complement; … … 502 495 * return mu20, initial viscosity. 503 496 */ 504 497 505 498 /*output: */ 506 499 IssmDouble viscosity_complement; … … 530 523 else{ 531 524 e=(n-1)/(2*n); 532 525 533 526 viscosity_complement=B/(2*pow(A,e)); 534 527 } … … 542 535 _assert_(n>0); 543 536 _assert_(viscosity_complement>0); 544 537 545 538 /*Return: */ 546 539 *pviscosity_complement=viscosity_complement; … … 589 582 590 583 /*input strain rate: */ 591 IssmDouble exx,eyy,exy ,exz;584 IssmDouble exx,eyy,exy; 592 585 593 586 /*Get visocisty and n*/ … … 640 633 case TriaEnum: { 641 634 IssmDouble values[3]; 642 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertex Dof()];635 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexPid()]; 643 636 this->inputs->AddInput(new TriaP1Input(name,values)); 644 637 return; … … 682 675 case TriaEnum: { 683 676 IssmDouble values[3]; 684 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->Get SidList()]; //use sid list, to index into serial oriented vector677 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexSid()]; //use sid list, to index into serial oriented vector 685 678 this->inputs->AddInput(new TriaP1Input(name,values)); 686 679 /*Special case for rheology B in 2D: Pourave land for this solution{{{*/ … … 706 699 default: _error_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet"); 707 700 } 708 709 710 701 711 702 } -
issm/trunk/src/c/classes/objects/Materials/Matdamageice.h
r13395 r13975 28 28 void DeepEcho(); 29 29 int Id(); 30 int MyRank();31 30 int ObjectEnum(); 32 31 Object* copy(); -
issm/trunk/src/c/classes/objects/Materials/Material.h
r13395 r13975 2 2 * \brief abstract class for Material object 3 3 */ 4 5 4 6 5 #ifndef _MATERIAL_H_ -
issm/trunk/src/c/classes/objects/Materials/Matice.cpp
r13395 r13975 15 15 #include "../../../shared/shared.h" 16 16 #include "../../../include/include.h" 17 17 18 18 /*Matice constructors and destructor*/ 19 19 /*FUNCTION Matice::Matice(){{{*/ … … 28 28 29 29 /*Intermediaries:*/ 30 int i;31 30 int matice_eid; 32 31 … … 82 81 int Matice::Id(void){ return mid; } 83 82 /*}}}*/ 84 /*FUNCTION Matice::MyRank {{{*/85 int Matice::MyRank(void){86 extern int my_rank;87 return my_rank;88 }89 /*}}}*/90 83 /*FUNCTION Matice::ObjectEnum{{{*/ 91 84 int Matice::ObjectEnum(void){ … … 190 183 /*Prepare index list*/ 191 184 int doflist1[3]; 192 for(int i=0;i<3;i++) doflist1[i]=((Tria*)element)->nodes[i]->GetVertex Dof();185 for(int i=0;i<3;i++) doflist1[i]=((Tria*)element)->nodes[i]->GetVertexPid(); 193 186 194 187 /*Get input (either in element or material)*/ … … 283 276 * return g, initial viscosity. 284 277 */ 285 278 286 279 /*output: */ 287 280 IssmDouble viscosity3d; … … 324 317 else{ 325 318 e=(n-1)/2/n; 326 319 327 320 viscosity3d=B/(2*pow(A,e)); 328 321 } … … 353 346 * return g, initial viscosity. 354 347 */ 355 348 356 349 /*output: */ 357 350 IssmDouble viscosity3d; … … 369 362 B=GetB(); 370 363 n=GetN(); 371 364 372 365 if (n==1){ 373 366 /*Viscous behaviour! viscosity3d=B: */ … … 422 415 * return mu20, initial viscosity. 423 416 */ 424 417 425 418 /*output: */ 426 419 IssmDouble viscosity_complement; … … 450 443 else{ 451 444 e=(n-1)/(2*n); 452 445 453 446 viscosity_complement=1/(2*pow(A,e)); 454 447 } … … 462 455 _assert_(n>0); 463 456 _assert_(viscosity_complement>0); 464 457 465 458 /*Return: */ 466 459 *pviscosity_complement=viscosity_complement; … … 509 502 510 503 /*input strain rate: */ 511 IssmDouble exx,eyy,exy ,exz;504 IssmDouble exx,eyy,exy; 512 505 513 506 /*Get visocisty and n*/ … … 560 553 case TriaEnum: { 561 554 IssmDouble values[3]; 562 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertex Dof()];555 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexPid()]; 563 556 this->inputs->AddInput(new TriaP1Input(name,values)); 564 557 return; … … 602 595 case TriaEnum: { 603 596 IssmDouble values[3]; 604 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->Get SidList()]; //use sid list, toindex into serial oriented vector597 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexSid()]; //index into serial oriented vector 605 598 this->inputs->AddInput(new TriaP1Input(name,values)); 606 599 /*Special case for rheology B in 2D: Pourave land for this solution{{{*/ … … 627 620 } 628 621 629 630 631 622 } 632 623 /*}}}*/ -
issm/trunk/src/c/classes/objects/Materials/Matice.h
r13395 r13975 15 15 16 16 private: 17 int 18 Hook *helement;17 int mid; 18 Hook *helement; 19 19 20 20 public: … … 28 28 void DeepEcho(); 29 29 int Id(); 30 int MyRank();31 30 int ObjectEnum(); 32 31 Object* copy(); -
issm/trunk/src/c/classes/objects/Materials/Matpar.cpp
r13395 r13975 15 15 #include "../../../include/include.h" 16 16 #include "../../../EnumDefinitions/EnumDefinitions.h" 17 17 18 18 /*Matpar constructors and destructor*/ 19 19 /*FUNCTION Matpar::Matpar() {{{*/ … … 39 39 iomodel->Constant(&this->thermal_exchange_velocity,MaterialsThermalExchangeVelocityEnum); 40 40 iomodel->Constant(&this->g,ConstantsGEnum); 41 41 42 42 iomodel->Constant(&this->hydro_CR,HydrologyCREnum); 43 43 iomodel->Constant(&this->kn,HydrologyKnEnum); … … 85 85 int Matpar::Id(void){ return mid; } 86 86 /*}}}*/ 87 /*FUNCTION Matpar::MyRank {{{*/88 int Matpar::MyRank(void){89 extern int my_rank;90 return my_rank;91 }92 /*}}}*/93 87 /*FUNCTION Matpar::ObjectEnum{{{*/ 94 88 int Matpar::ObjectEnum(void){ … … 250 244 /*FUNCTION Matpar::GetRhoIce {{{*/ 251 245 IssmDouble Matpar::GetRhoIce(){ 252 246 253 247 return rho_ice; 254 248 } … … 329 323 /*Ouput*/ 330 324 IssmDouble temperature,waterfraction; 331 325 332 326 if(enthalpy<PureIceEnthalpy(pressure)){ 333 327 temperature=referencetemperature+enthalpy/heatcapacity; … … 349 343 /*Ouput*/ 350 344 IssmDouble enthalpy; 351 345 352 346 if(temperature<TMeltingPoint(pressure)){ 353 347 enthalpy=heatcapacity*(temperature-referencetemperature); -
issm/trunk/src/c/classes/objects/Materials/Matpar.h
r13395 r13975 43 43 44 44 /*Object virtual functions definitions:{{{ */ 45 void Echo(); 46 void DeepEcho(); 47 int Id(); 48 int MyRank(); 49 int ObjectEnum(); 50 Object* copy(); 45 void Echo(); 46 void DeepEcho(); 47 int Id(); 48 int ObjectEnum(); 49 Object *copy(); 51 50 /*}}}*/ 52 51 /*Update virtual functions resolution: {{{*/ -
issm/trunk/src/c/classes/objects/Node.cpp
r13395 r13975 58 58 this->inputs=new Inputs(); 59 59 if (iomodel->Data(MeshVertexonbedEnum)) 60 this->inputs->AddInput(new BoolInput(MeshVertexonbedEnum,reCast< IssmBool>(iomodel->Data(MeshVertexonbedEnum)[io_index])));60 this->inputs->AddInput(new BoolInput(MeshVertexonbedEnum,reCast<bool>(iomodel->Data(MeshVertexonbedEnum)[io_index]))); 61 61 if (iomodel->Data(MeshVertexonsurfaceEnum)) 62 this->inputs->AddInput(new BoolInput(MeshVertexonsurfaceEnum,reCast< IssmBool>(iomodel->Data(MeshVertexonsurfaceEnum)[io_index])));62 this->inputs->AddInput(new BoolInput(MeshVertexonsurfaceEnum,reCast<bool>(iomodel->Data(MeshVertexonsurfaceEnum)[io_index]))); 63 63 if (iomodel->Data(MaskVertexonfloatingiceEnum)) 64 this->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,reCast< IssmBool>(iomodel->Data(MaskVertexonfloatingiceEnum)[io_index])));64 this->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,reCast<bool>(iomodel->Data(MaskVertexonfloatingiceEnum)[io_index]))); 65 65 if (iomodel->Data(MaskVertexongroundediceEnum)) 66 this->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,reCast< IssmBool>(iomodel->Data(MaskVertexongroundediceEnum)[io_index])));66 this->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,reCast<bool>(iomodel->Data(MaskVertexongroundediceEnum)[io_index]))); 67 67 if (analysis_type==DiagnosticHorizAnalysisEnum) 68 68 this->inputs->AddInput(new IntInput(ApproximationEnum,reCast<IssmInt>(iomodel->Data(FlowequationVertexEquationEnum)[io_index]))); … … 71 71 /*spc all nodes on water*/ 72 72 if (!iomodel->Data(MaskVertexonwaterEnum)) _error_("iomodel->nodeonwater is NULL"); 73 if (reCast< IssmBool>(iomodel->Data(MaskVertexonwaterEnum)[io_index])){73 if (reCast<bool>(iomodel->Data(MaskVertexonwaterEnum)[io_index])){ 74 74 for(k=1;k<=gsize;k++){ 75 75 this->FreezeDof(k); … … 137 137 /*On a 3d mesh, we may have collapsed elements, hence dead nodes. Freeze them out: */ 138 138 _assert_(iomodel->Data(MeshVertexonbedEnum)); 139 if (!(reCast< IssmBool>(iomodel->Data(MeshVertexonbedEnum)[io_index]))){139 if (!(reCast<bool>(iomodel->Data(MeshVertexonbedEnum)[io_index]))){ 140 140 for(k=1;k<=gsize;k++){ 141 141 this->FreezeDof(k); … … 166 166 _printLine_(" hvertex: not displayed"); 167 167 _printLine_(" inputs: " << inputs); 168 169 168 170 169 } … … 182 181 _printLine_(" inputs"); 183 182 184 185 183 } 186 184 /*}}}*/ 187 185 /*FUNCTION Node::Id{{{*/ 188 186 int Node::Id(void){ return id; } 189 /*}}}*/190 /*FUNCTION Node::MyRank{{{*/191 int Node::MyRank(void){192 extern int my_rank;193 194 return my_rank;195 }196 187 /*}}}*/ 197 188 /*FUNCTION Node::ObjectEnum{{{*/ … … 234 225 235 226 } /*}}}*/ 236 /*FUNCTION Node::GetDofList1{{{*/237 int Node::GetDofList1(void){238 239 Vertex* vertex=NULL;240 241 vertex=(Vertex*)this->hvertex->delivers();242 243 return vertex->dof;244 }245 /*}}}*/246 227 /*FUNCTION Node::GetDofList{{{*/ 247 228 void Node::GetDofList(int* outdoflist,int approximation_enum,int setenum){ … … 249 230 int count=0; 250 231 int count2=0; 251 232 252 233 if(approximation_enum==NoneApproximationEnum){ 253 234 if(setenum==GsetEnum)for(i=0;i<this->indexing.gsize;i++) outdoflist[i]=indexing.gdoflist[i]; … … 306 287 } 307 288 /*}}}*/ 308 /*FUNCTION Node::GetSidList{{{*/309 int Node::GetSidList(void){310 311 Vertex* vertex=NULL;312 313 vertex=(Vertex*)this->hvertex->delivers();314 315 return vertex->sid;316 }317 /*}}}*/318 289 /*FUNCTION Node::GetLocalDofList{{{*/ 319 290 void Node::GetLocalDofList(int* outdoflist,int approximation_enum,int setenum){ … … 321 292 int count=0; 322 293 int count2=0; 323 294 324 295 if(approximation_enum==NoneApproximationEnum){ 325 296 if(setenum==GsetEnum)for(i=0;i<this->indexing.gsize;i++) outdoflist[i]=i; … … 427 398 } 428 399 /*}}}*/ 429 /*FUNCTION Node::GetVertex Dof{{{*/430 int Node::GetVertex Dof(void){400 /*FUNCTION Node::GetVertexPid{{{*/ 401 int Node::GetVertexPid(void){ 431 402 432 403 Vertex* vertex=NULL; 433 404 434 405 vertex=(Vertex*)hvertex->delivers(); 435 return vertex->dof; 406 return vertex->pid; 407 } 408 /*}}}*/ 409 /*FUNCTION Node::GetVertexSid{{{*/ 410 int Node::GetVertexSid(void){ 411 412 Vertex* vertex=NULL; 413 414 vertex=(Vertex*)this->hvertex->delivers(); 415 416 return vertex->sid; 436 417 } 437 418 /*}}}*/ … … 446 427 /*}}}*/ 447 428 #endif 448 /*FUNCTION Node::SetVertexDof {{{*/449 void Node::SetVertexDof(int in_dof){450 451 Vertex* vertex=NULL;452 453 vertex=(Vertex*)hvertex->delivers();454 vertex->dof=in_dof;455 456 }457 /*}}}*/458 429 /*FUNCTION Node::InAnalysis{{{*/ 459 430 bool Node::InAnalysis(int in_analysis_type){ … … 467 438 void Node::ApplyConstraint(int dof,IssmDouble value){ 468 439 469 int index;470 471 440 /*Dof should be added in the s set, describing which 472 441 * dofs are constrained to a certain value (dirichlet boundary condition*/ … … 495 464 /*g set: */ 496 465 pv_g->SetValue(indexing.gdoflist[i],gvalue,INS_VAL); 497 466 498 467 /*f set: */ 499 468 value=(IssmDouble)this->indexing.f_set[i]; … … 505 474 506 475 } 507 508 476 509 477 } … … 527 495 } 528 496 } 529 497 530 498 /*Add values into constraint vector: */ 531 499 ys->SetValues(this->indexing.ssize,this->indexing.sdoflist,values,INS_VAL); … … 535 503 xDelete<IssmDouble>(values); 536 504 537 538 505 } 539 506 /*}}}*/ … … 560 527 /*FUNCTION Node::FreezeDof{{{*/ 561 528 void Node::FreezeDof(int dof){ 562 529 563 530 DofInSSet(dof-1); //with 0 displacement for this dof. 564 531 … … 589 556 /*Get number of degrees of freedom in a node, for a certain set (g,f or s-set) 590 557 *and for a certain approximation type: */ 591 558 592 559 int i; 593 560 int numdofs=0; … … 666 633 /*FUNCTION Node::IsClone {{{*/ 667 634 int Node::IsClone(){ 668 635 669 636 return indexing.clone; 670 637 … … 695 662 /*FUNCTION Node::IsFloating {{{*/ 696 663 int Node::IsFloating(){ 697 664 698 665 bool onshelf; 699 666 … … 887 854 /*}}}*/ 888 855 889 /* DofObjectroutines:*/856 /* indexing routines:*/ 890 857 /*FUNCTION Node::DistributeDofs{{{*/ 891 858 void Node::DistributeDofs(int* pdofcount,int setenum){ 892 859 893 860 int i; 894 extern int my_rank;895 861 int dofcount; 896 862 … … 900 866 if(setenum==FsetEnum) this->indexing.InitSet(setenum); 901 867 if(setenum==SsetEnum) this->indexing.InitSet(setenum); 902 903 868 904 869 /*For clone nodfs, don't distribute dofs, we will get them from another cpu in UpdateCloneDofs!*/ 905 870 if(indexing.clone){ … … 908 873 909 874 /*This node should distribute dofs for setenum set (eg, f_set or s_set), go ahead: */ 910 911 875 if(setenum==GsetEnum){ 912 876 for(i=0;i<this->indexing.gsize;i++){ … … 929 893 else _error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!"); 930 894 931 932 895 /*Assign output pointers: */ 933 896 *pdofcount=dofcount; 934 935 } 936 /*}}}*/ 937 /*FUNCTION Node::Off_setDofs{{{*/ 897 } 898 /*}}}*/ 899 /*FUNCTION Node::OffsetDofs{{{*/ 938 900 void Node::OffsetDofs(int dofcount,int setenum){ 939 901 940 902 int i; 941 extern int my_rank; 942 903 943 904 if(indexing.clone){ 944 905 /*This node is a clone, don't off_set the dofs!: */ … … 963 924 964 925 int j; 965 extern int my_rank; 966 926 967 927 /*Are we a clone? : */ 968 if(indexing.clone) return;928 if(indexing.clone) return; 969 929 970 930 /*Ok, we are not a clone, just plug our dofs into truedofs: */ 971 if(setenum==GsetEnum)for(j=0;j<this->indexing.gsize;j++) *(truedofs+ncols*sid+j)=indexing.gdoflist[j]; 972 else if(setenum==FsetEnum)for(j=0;j<this->indexing.fsize;j++) *(truedofs+ncols*sid+j)=indexing.fdoflist[j]; 973 else if(setenum==SsetEnum)for(j=0;j<this->indexing.ssize;j++) *(truedofs+ncols*sid+j)=indexing.sdoflist[j]; 974 else _error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!"); 931 switch(setenum){ 932 case GsetEnum: 933 for(j=0;j<this->indexing.gsize;j++) truedofs[ncols*sid+j]=indexing.gdoflist[j]; 934 break; 935 case FsetEnum: 936 for(j=0;j<this->indexing.fsize;j++) truedofs[ncols*sid+j]=indexing.fdoflist[j]; 937 break; 938 case SsetEnum: 939 for(j=0;j<this->indexing.ssize;j++) truedofs[ncols*sid+j]=indexing.sdoflist[j]; 940 break; 941 default: 942 _error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!"); 943 } 975 944 976 945 } … … 980 949 981 950 int j; 982 extern int my_rank; 983 951 984 952 /*If we are not a clone, don't update, we already have dofs!: */ 985 if(indexing.clone==0)return; 986 953 if(!indexing.clone)return; 987 954 988 955 /*Ok, we are a clone node, but we did not create the dofs for this node. 989 * * Therefore, our doflist is garbage right now. Go pick it up in the alltruedofs: */ 990 if(setenum==GsetEnum)for(j=0;j<this->indexing.gsize;j++) indexing.gdoflist[j]=*(alltruedofs+ncols*sid+j); 991 else if(setenum==FsetEnum)for(j=0;j<this->indexing.fsize;j++) indexing.fdoflist[j]=*(alltruedofs+ncols*sid+j); 992 else if(setenum==SsetEnum)for(j=0;j<this->indexing.ssize;j++) indexing.sdoflist[j]=*(alltruedofs+ncols*sid+j); 993 else _error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!"); 994 956 *Therefore, our doflist is garbage right now. Go pick it up in the alltruedofs: */ 957 switch(setenum){ 958 case GsetEnum: 959 for(j=0;j<this->indexing.gsize;j++) indexing.gdoflist[j]=alltruedofs[ncols*sid+j]; 960 break; 961 case FsetEnum: 962 for(j=0;j<this->indexing.fsize;j++) indexing.fdoflist[j]=alltruedofs[ncols*sid+j]; 963 break; 964 case SsetEnum: 965 for(j=0;j<this->indexing.ssize;j++) indexing.sdoflist[j]=alltruedofs[ncols*sid+j]; 966 break; 967 default: 968 _error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!"); 969 } 995 970 } 996 971 /*}}}*/ … … 998 973 void Node::SetClone(int* minranks){ 999 974 1000 extern int my_rank; 975 int my_rank; 976 977 /*recover my_rank:*/ 978 my_rank=IssmComm::GetRank(); 1001 979 1002 980 if (minranks[sid]==my_rank){ 1003 indexing.clone= 0;981 indexing.clone=false; 1004 982 } 1005 983 else{ 1006 984 /*!there is a cpu with lower rank that has the same node, 1007 985 therefore, I am a clone*/ 1008 indexing.clone=1; 1009 } 1010 1011 } 1012 /*}}}*/ 986 indexing.clone=true; 987 } 988 } 989 /*}}}*/ -
issm/trunk/src/c/classes/objects/Node.h
r13395 r13975 25 25 public: 26 26 27 int id;//unique arbitrary id.28 int sid; //sid for "serial" id, ie the rank of this node in the nodes dataset, if the dataset was serial on 1 cpu.29 30 DofIndexing 31 Hook *hvertex;32 Inputs * inputs;//properties of this node33 int 34 IssmDouble 27 int id; //unique arbitrary id. 28 int sid; //"serial" id (rank of this node if the dataset was serial on 1 cpu) 29 30 DofIndexing indexing; 31 Hook *hvertex; 32 Inputs *inputs; //properties of this node 33 int analysis_type; 34 IssmDouble coord_system[3][3]; 35 35 36 36 /*Node constructors, destructors {{{*/ … … 40 40 /*}}}*/ 41 41 /*Object virtual functions definitions:{{{ */ 42 void Echo(); 43 void DeepEcho(); 44 int Id(); 45 int MyRank(); 46 int ObjectEnum(); 47 Object* copy(){_error_("Not implemented yet (similar to Elements)");}; 42 void Echo(); 43 void DeepEcho(); 44 int Id(); 45 int ObjectEnum(); 46 Object *copy() {_error_("Not implemented yet (similar to Elements)"); }; 48 47 /*}}}*/ 49 48 /*Update virtual functions definitions: {{{*/ 50 51 49 void InputUpdateFromVector(IssmDouble* vector, int name, int type); 52 50 void InputUpdateFromVector(int* vector, int name, int type); … … 67 65 void SetCurrentConfiguration(DataSet* nodes,Vertices* vertices); 68 66 int Sid(void); 69 int GetVertexDof(void);70 int GetVertexId(void);71 67 #ifdef _HAVE_DIAGNOSTIC_ 72 68 void GetCoordinateSystem(IssmDouble* coord_system_out); 73 69 #endif 74 void SetVertexDof(int in_dof);75 70 bool InAnalysis(int analysis_type); 76 71 int GetApproximation(); … … 86 81 void GetDofList(int* poutdoflist,int approximation_enum,int setenum); 87 82 void GetLocalDofList(int* poutdoflist,int approximation_enum,int setenum); 88 int GetDofList1(void); 89 int GetSidList(void); 83 int GetVertexId(void); 84 int GetVertexPid(void); 85 int GetVertexSid(void); 90 86 IssmDouble GetX(); 91 87 IssmDouble GetY(); … … 100 96 void VecMerge(Vector<IssmDouble>* ug, IssmDouble* vector_serial,int setenum); 101 97 void VecReduce(Vector<IssmDouble>* vector, IssmDouble* ug_serial,int setnum); 102 103 /*}}}*/104 /*Dof Object routines {{{*/105 98 void DistributeDofs(int* pdofcount,int setenum); 106 99 void OffsetDofs(int dofcount,int setenum); -
issm/trunk/src/c/classes/objects/Object.h
r13395 r13975 7 7 * DataSet. 8 8 */ 9 10 9 11 10 #ifndef _OBJECT_H_ … … 20 19 virtual void DeepEcho()=0; 21 20 virtual int Id()=0; 22 virtual int MyRank()=0;23 21 virtual int ObjectEnum()=0; 24 22 virtual Object* copy()=0; -
issm/trunk/src/c/classes/objects/Options/GenericOption.h
r13395 r13975 29 29 public: 30 30 31 char *name;32 OptionType value;31 char *name; 32 OptionType value; 33 33 34 int numel;//in case OptionType is an array35 int ndims;//in case OptionType is a multi-dimensional array: */36 int *size;34 int numel; //in case OptionType is an array 35 int ndims; //in case OptionType is a multi-dimensional array: */ 36 int *size; 37 37 38 38 /*GenericOption constructors, destructors*/ … … 43 43 ndims =0; 44 44 size =NULL; 45 46 45 47 46 } /*}}}*/ … … 81 80 } /*}}}*/ 82 81 int Id(){_error_("Not implemented yet");}; 83 int MyRank(){_error_("Not implemented yet");};84 82 int ObjectEnum(){return GenericOptionEnum;}; 85 83 Object* copy(){_error_("Not implemented yet");}; 86 84 87 85 /*GenericOption functions: */ 88 86 char* Name(){return name;}; … … 93 91 }; 94 92 95 #if def _HAVE_ADOLC_//We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization.93 #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_) //We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization. 96 94 template <> inline void GenericOption<IssmPDouble*>::Get(IssmPDouble** pvalue){ /*{{{*/ 97 95 … … 115 113 template <> inline void GenericOption<char*>::Get(char** pvalue){ /*{{{*/ 116 114 117 char* outstring=NULL; 118 int stringsize; 119 120 stringsize=strlen(this->value)+1; 121 outstring=xNew<char>(stringsize); 115 int stringsize=strlen(this->value)+1; 116 char* outstring=xNew<char>(stringsize); 122 117 xMemCpy<char>(outstring,this->value,stringsize); 123 118 -
issm/trunk/src/c/classes/objects/Options/Option.h
r13395 r13975 18 18 public: 19 19 20 21 /*Option constructors, destructors {{{*/ 20 /*Option constructors, destructors*/ 22 21 Option(){}; 23 22 ~Option(){}; 24 /*}}}*/ 25 /*Object virtual functions definitions :{{{*/23 24 /*Object virtual functions definitions*/ 26 25 virtual void Echo()= 0; 27 26 virtual void DeepEcho()= 0; 28 27 virtual void DeepEcho(char *indent)=0; 29 28 int Id(){_error_("Not implemented yet"); }; 30 int MyRank(){_error_("Not implemented yet"); };31 29 int ObjectEnum(){return OptionEnum; }; 32 30 Object *copy(){_error_("Not implemented yet"); }; 33 /*}}}*/34 31 35 32 /*virtual functions: */ … … 41 38 }; 42 39 #endif /* _OPTIONOBJECT_H */ 43 -
issm/trunk/src/c/classes/objects/Options/OptionUtilities.h
r13395 r13975 22 22 23 23 #endif /* _OPTIONUTILITIES_H */ 24 -
issm/trunk/src/c/classes/objects/Params/BoolParam.cpp
r13395 r13975 26 26 } 27 27 /*}}}*/ 28 /*FUNCTION BoolParam::BoolParam(int enum_type, IssmBool value){{{*/29 BoolParam::BoolParam(int in_enum_type, IssmBool in_value){28 /*FUNCTION BoolParam::BoolParam(int enum_type,bool value){{{*/ 29 BoolParam::BoolParam(int in_enum_type,bool in_value){ 30 30 31 31 enum_type=in_enum_type; … … 56 56 int BoolParam::Id(void){ return -1; } 57 57 /*}}}*/ 58 /*FUNCTION BoolParam::MyRank{{{*/59 int BoolParam::MyRank(void){60 extern int my_rank;61 return my_rank;62 }63 /*}}}*/64 58 /*FUNCTION BoolParam::ObjectEnum{{{*/ 65 59 int BoolParam::ObjectEnum(void){ … … 71 65 /*FUNCTION BoolParam::copy{{{*/ 72 66 Object* BoolParam::copy() { 73 67 74 68 return new BoolParam(this->enum_type,this->value); 75 69 -
issm/trunk/src/c/classes/objects/Params/BoolParam.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _BOOLPARAM_H_ … … 25 24 /*just hold 3 values for 3 vertices: */ 26 25 int enum_type; 27 IssmBool value;26 bool value; 28 27 29 28 /*BoolParam constructors, destructors: {{{*/ 30 29 BoolParam(); 31 BoolParam(int enum_type, IssmBool value);30 BoolParam(int enum_type,bool value); 32 31 ~BoolParam(); 33 32 /*}}}*/ … … 36 35 void DeepEcho(); 37 36 int Id(); 38 int MyRank();39 37 int ObjectEnum(); 40 38 Object* copy(); … … 56 54 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");} 57 55 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 56 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 58 57 59 58 void SetValue(bool boolean){this->value=boolean;} … … 71 70 void SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");} 72 71 void UnitConversion(int direction_enum); 73 72 74 73 void GetParameterName(char**pname); 75 74 /*}}}*/ -
issm/trunk/src/c/classes/objects/Params/DoubleMatArrayParam.cpp
r13395 r13975 77 77 xDelete<IssmDouble>(matrix); 78 78 } 79 79 80 80 xDelete<IssmDouble*>(array); 81 81 return; … … 100 100 int m,n; 101 101 IssmDouble* matrix=NULL; 102 102 103 103 _printLine_("DoubleMatArrayParam:"); 104 104 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")"); … … 121 121 int DoubleMatArrayParam::Id(void){ return -1; } 122 122 /*}}}*/ 123 /*FUNCTION DoubleMatArrayParam::MyRank{{{*/124 int DoubleMatArrayParam::MyRank(void){125 extern int my_rank;126 return my_rank;127 }128 /*}}}*/129 123 /*FUNCTION DoubleMatArrayParam::ObjectEnum{{{*/ 130 124 int DoubleMatArrayParam::ObjectEnum(void){ … … 136 130 /*FUNCTION DoubleMatArrayParam::copy{{{*/ 137 131 Object* DoubleMatArrayParam::copy() { 138 132 139 133 return new DoubleMatArrayParam(this->enum_type,this->array, this->M, this->mdim_array,this->ndim_array); 140 134 … … 156 150 int* out_ndim_array=NULL; 157 151 158 159 152 out_M=this->M; 160 153 if(out_M){ … … 187 180 } 188 181 189 190 182 /*Assign output pointers:*/ 191 183 if(pout_M) *pout_M=out_M; … … 222 214 this->mdim_array=xNew<int>(M); 223 215 this->ndim_array=xNew<int>(M); 224 216 225 217 xMemCpy<int>(this->mdim_array,in_mdim_array,M); 226 218 xMemCpy<int>(this->ndim_array,in_ndim_array,M); -
issm/trunk/src/c/classes/objects/Params/DoubleMatArrayParam.h
r13395 r13975 2 2 * \brief: header file for object holding an array of serial matrices 3 3 */ 4 5 4 6 5 #ifndef _DOUBLEMATARRAYPARAM_H_ … … 23 22 24 23 private: 25 int enum_type;26 IssmDouble ** array;//array of matrices27 int M;//size of array28 int * mdim_array;//m-dimensions of matrices in the array29 int * ndim_array;//n-dimensions -f matrices in the array24 int enum_type; 25 IssmDouble **array; //array of matrices 26 int M; //size of array 27 int *mdim_array; //m-dimensions of matrices in the array 28 int *ndim_array; //n-dimensions -f matrices in the array 30 29 31 30 public: … … 39 38 void DeepEcho(); 40 39 int Id(); 41 int MyRank();42 40 int ObjectEnum(); 43 41 Object* copy(); … … 59 57 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a Mat");} 60 58 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a FILE");} 59 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 61 60 62 61 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a boolean");} -
issm/trunk/src/c/classes/objects/Params/DoubleMatParam.cpp
r13395 r13975 58 58 59 59 int i,j; 60 60 61 61 _printLine_("DoubleMatParam:"); 62 62 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")"); … … 72 72 int DoubleMatParam::Id(void){ return -1; } 73 73 /*}}}*/ 74 /*FUNCTION DoubleMatParam::MyRank{{{*/75 int DoubleMatParam::MyRank(void){76 extern int my_rank;77 return my_rank;78 }79 /*}}}*/80 74 /*FUNCTION DoubleMatParam::ObjectEnum{{{*/ 81 75 int DoubleMatParam::ObjectEnum(void){ … … 87 81 /*FUNCTION DoubleMatParam::copy{{{*/ 88 82 Object* DoubleMatParam::copy() { 89 83 90 84 return new DoubleMatParam(this->enum_type,this->value,this->M,this->N); 91 85 -
issm/trunk/src/c/classes/objects/Params/DoubleMatParam.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _DOUBLEMATPARAM_H_ … … 23 22 24 23 protected: 25 int enum_type;26 IssmDouble *value;27 int M;28 int N;24 int enum_type; 25 IssmDouble *value; 26 int M; 27 int N; 29 28 30 29 public: … … 38 37 void DeepEcho(); 39 38 int Id(); 40 int MyRank();41 39 int ObjectEnum(); 42 40 Object* copy(); … … 58 56 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");} 59 57 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 58 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 60 59 61 60 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} -
issm/trunk/src/c/classes/objects/Params/DoubleParam.cpp
r13395 r13975 53 53 int DoubleParam::Id(void){ return -1; } 54 54 /*}}}*/ 55 /*FUNCTION DoubleParam::MyRank{{{*/56 int DoubleParam::MyRank(void){57 extern int my_rank;58 return my_rank;59 }60 /*}}}*/61 55 /*FUNCTION DoubleParam::ObjectEnum{{{*/ 62 56 int DoubleParam::ObjectEnum(void){ … … 68 62 /*FUNCTION DoubleParam::copy{{{*/ 69 63 Object* DoubleParam::copy() { 70 64 71 65 return new DoubleParam(this->enum_type,this->value); 72 66 -
issm/trunk/src/c/classes/objects/Params/DoubleParam.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _DOUBLEPARAM_H_ … … 24 23 private: 25 24 /*just hold 3 values for 3 vertices: */ 26 int enum_type;25 int enum_type; 27 26 IssmDouble value; 28 27 … … 37 36 void DeepEcho(); 38 37 int Id(); 39 int MyRank();40 38 int ObjectEnum(); 41 39 Object* copy(); … … 57 55 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");} 58 56 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 57 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 59 58 60 59 void SetValue(bool boolean){this->value=(IssmDouble)boolean;} -
issm/trunk/src/c/classes/objects/Params/DoubleTransientMatParam.h
r13395 r13975 2 2 * \brief: header file for DoubleTransientMatParam object 3 3 */ 4 5 4 6 5 #ifndef _DOUBLETRANSIENTMATPARAM_H_ -
issm/trunk/src/c/classes/objects/Params/DoubleVecParam.cpp
r13395 r13975 57 57 58 58 int i; 59 59 60 60 _printLine_("DoubleVecParam:"); 61 61 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")"); … … 69 69 int DoubleVecParam::Id(void){ return -1; } 70 70 /*}}}*/ 71 /*FUNCTION DoubleVecParam::MyRank{{{*/72 int DoubleVecParam::MyRank(void){73 extern int my_rank;74 return my_rank;75 }76 /*}}}*/77 71 /*FUNCTION DoubleVecParam::ObjectEnum{{{*/ 78 72 int DoubleVecParam::ObjectEnum(void){ … … 84 78 /*FUNCTION DoubleVecParam::copy{{{*/ 85 79 Object* DoubleVecParam::copy() { 86 80 87 81 return new DoubleVecParam(this->enum_type,this->values,this->M); 88 82 -
issm/trunk/src/c/classes/objects/Params/DoubleVecParam.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _DOUBLEVECPARAM_H_ … … 23 22 24 23 private: 25 int enum_type;26 IssmDouble *values;27 int M;24 int enum_type; 25 IssmDouble *values; 26 int M; 28 27 29 28 public: … … 37 36 void DeepEcho(); 38 37 int Id(); 39 int MyRank();40 38 int ObjectEnum(); 41 39 Object* copy(); … … 57 55 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");} 58 56 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 57 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 59 58 60 59 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} … … 72 71 void SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");} 73 72 void UnitConversion(int direction_enum); 74 73 75 74 void GetParameterName(char**pname); 76 75 /*}}}*/ -
issm/trunk/src/c/classes/objects/Params/FileParam.cpp
r13395 r13975 56 56 int FileParam::Id(void){ return -1; } 57 57 /*}}}*/ 58 /*FUNCTION FileParam::MyRank{{{*/59 int FileParam::MyRank(void){60 extern int my_rank;61 return my_rank;62 }63 /*}}}*/64 58 /*FUNCTION FileParam::ObjectEnum{{{*/ 65 59 int FileParam::ObjectEnum(void){ … … 71 65 /*FUNCTION FileParam::copy{{{*/ 72 66 Object* FileParam::copy() { 73 67 74 68 return new FileParam(this->enum_type,this->value); 75 69 -
issm/trunk/src/c/classes/objects/Params/FileParam.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _FILEPARAM_H_ … … 36 35 void DeepEcho(); 37 36 int Id(); 38 int MyRank();39 37 int ObjectEnum(); 40 38 Object* copy(); … … 56 54 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");} 57 55 void GetParameterValue(FILE** pfid){*pfid=value;}; 56 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 58 57 59 58 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");} -
issm/trunk/src/c/classes/objects/Params/GenericParam.h
r13395 r13975 49 49 void Echo() {DeepEcho();}; 50 50 int Id(){ return -1; }; 51 int MyRank() { extern int my_rank; return my_rank;} ;52 51 int ObjectEnum() {return AdolcParamEnum;}; 53 52 … … 80 79 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a Mat");} 81 80 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a FILE");} 81 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a DataSet");} 82 82 83 83 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a bool");} … … 99 99 }; 100 100 101 102 101 #endif /* GENERICPARAM_H_ */ -
issm/trunk/src/c/classes/objects/Params/IntMatParam.cpp
r13395 r13975 58 58 59 59 int i,j; 60 60 61 61 _printLine_("IntMatParam:"); 62 62 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")"); … … 72 72 int IntMatParam::Id(void){ return -1; } 73 73 /*}}}*/ 74 /*FUNCTION IntMatParam::MyRank{{{*/75 int IntMatParam::MyRank(void){76 extern int my_rank;77 return my_rank;78 }79 /*}}}*/80 74 /*FUNCTION IntMatParam::ObjectEnum{{{*/ 81 75 int IntMatParam::ObjectEnum(void){ … … 87 81 /*FUNCTION IntMatParam::copy{{{*/ 88 82 Object* IntMatParam::copy() { 89 83 90 84 return new IntMatParam(this->enum_type,this->value,this->M,this->N); 91 85 -
issm/trunk/src/c/classes/objects/Params/IntMatParam.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _INTMATPARAM_H_ … … 38 37 void DeepEcho(); 39 38 int Id(); 40 int MyRank();41 39 int ObjectEnum(); 42 40 Object* copy(); … … 58 56 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");} 59 57 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 58 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 60 59 61 60 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} -
issm/trunk/src/c/classes/objects/Params/IntParam.cpp
r13395 r13975 56 56 int IntParam::Id(void){ return -1; } 57 57 /*}}}*/ 58 /*FUNCTION IntParam::MyRank{{{*/59 int IntParam::MyRank(void){60 extern int my_rank;61 return my_rank;62 }63 /*}}}*/64 58 /*FUNCTION IntParam::ObjectEnum{{{*/ 65 59 int IntParam::ObjectEnum(void){ … … 71 65 /*FUNCTION IntParam::copy{{{*/ 72 66 Object* IntParam::copy() { 73 67 74 68 return new IntParam(this->enum_type,this->value); 75 69 -
issm/trunk/src/c/classes/objects/Params/IntParam.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _INTPARAM_H_ … … 37 36 void DeepEcho(); 38 37 int Id(); 39 int MyRank();40 38 int ObjectEnum(); 41 39 Object* copy(); … … 57 55 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");} 58 56 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 57 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 59 58 60 59 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a bool");} -
issm/trunk/src/c/classes/objects/Params/IntVecParam.cpp
r13395 r13975 73 73 74 74 int i; 75 75 76 76 _printLine_("IntVecParam:"); 77 77 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")"); … … 85 85 int IntVecParam::Id(void){ return -1; } 86 86 /*}}}*/ 87 /*FUNCTION IntVecParam::MyRank{{{*/88 int IntVecParam::MyRank(void){89 extern int my_rank;90 return my_rank;91 }92 /*}}}*/93 87 /*FUNCTION IntVecParam::ObjectEnum{{{*/ 94 88 int IntVecParam::ObjectEnum(void){ … … 100 94 /*FUNCTION IntVecParam::copy{{{*/ 101 95 Object* IntVecParam::copy() { 102 96 103 97 return new IntVecParam(this->enum_type,this->values,this->M); 104 98 -
issm/trunk/src/c/classes/objects/Params/IntVecParam.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _INTVECPARAM_H_ … … 38 37 void DeepEcho(); 39 38 int Id(); 40 int MyRank();41 39 int ObjectEnum(); 42 40 Object* copy(); … … 58 56 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");} 59 57 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 58 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 60 59 61 60 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} … … 73 72 void SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");} 74 73 void UnitConversion(int direction_enum); 75 74 76 75 void GetParameterName(char**pname); 77 76 /*}}}*/ -
issm/trunk/src/c/classes/objects/Params/MatrixParam.cpp
r13395 r13975 55 55 void MatrixParam::DeepEcho(void){ 56 56 57 int i;58 57 _printLine_("MatrixParam:"); 59 58 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")"); … … 63 62 /*FUNCTION MatrixParam::Id{{{*/ 64 63 int MatrixParam::Id(void){ return -1; } 65 /*}}}*/66 /*FUNCTION MatrixParam::MyRank{{{*/67 int MatrixParam::MyRank(void){68 extern int my_rank;69 return my_rank;70 }71 64 /*}}}*/ 72 65 /*FUNCTION MatrixParam::ObjectEnum{{{*/ … … 79 72 /*FUNCTION MatrixParam::copy{{{*/ 80 73 Object* MatrixParam::copy() { 81 74 82 75 return new MatrixParam(this->enum_type,this->value); 83 76 … … 103 96 /*FUNCTION MatrixParam::SetValue{{{*/ 104 97 void MatrixParam::SetValue(Matrix<IssmDouble>* matrix){ 105 98 106 99 /*avoid leak: */ 107 100 xdelete(&value); 108 101 109 102 /*copy: */ 110 103 value=matrix->Duplicate(); -
issm/trunk/src/c/classes/objects/Params/MatrixParam.h
r13395 r13975 2 2 * \brief: header file for MatrixParam object 3 3 */ 4 5 4 6 5 #ifndef _MATRIXPARAM_H_ … … 37 36 void DeepEcho(); 38 37 int Id(); 39 int MyRank();40 38 int ObjectEnum(); 41 39 Object* copy(); … … 57 55 void GetParameterValue(Matrix<IssmDouble>** poutput); 58 56 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 57 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 59 58 60 59 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} -
issm/trunk/src/c/classes/objects/Params/Param.h
r13395 r13975 2 2 * \brief abstract class for Param object 3 3 */ 4 5 4 6 5 #ifndef _PARAM_H_ … … 41 40 virtual void GetParameterValue(Matrix<IssmDouble>** pmat)=0; 42 41 virtual void GetParameterValue(FILE** pfid)=0; 43 42 virtual void GetParameterValue(DataSet** pdataset)=0; 43 44 44 virtual void SetValue(bool boolean)=0; 45 45 virtual void SetValue(int integer)=0; -
issm/trunk/src/c/classes/objects/Params/StringArrayParam.cpp
r13395 r13975 46 46 } 47 47 else value=NULL; 48 48 49 49 } 50 50 /*}}}*/ 51 51 /*FUNCTION StringArrayParam::~StringArrayParam(){{{*/ 52 52 StringArrayParam::~StringArrayParam(){ 53 53 54 54 int i; 55 55 56 56 char* string=NULL; 57 57 for(i=0;i<this->numstrings;i++){ … … 86 86 int StringArrayParam::Id(void){ return -1; } 87 87 /*}}}*/ 88 /*FUNCTION StringArrayParam::MyRank{{{*/89 int StringArrayParam::MyRank(void){90 extern int my_rank;91 return my_rank;92 }93 /*}}}*/94 88 /*FUNCTION StringArrayParam::ObjectEnum{{{*/ 95 89 int StringArrayParam::ObjectEnum(void){ … … 101 95 /*FUNCTION StringArrayParam::copy{{{*/ 102 96 Object* StringArrayParam::copy() { 103 97 104 98 return new StringArrayParam(this->enum_type,this->value,this->numstrings); 105 99 … … 110 104 /*FUNCTION StringArrayParam::GetParameterValue{{{*/ 111 105 void StringArrayParam::GetParameterValue(char*** pstringarray,int* pM){ 112 106 113 107 int i; 114 108 char** outstrings=NULL; … … 146 140 /*FUNCTION StringArrayParam::SetValue{{{*/ 147 141 void StringArrayParam::SetValue(char** stringarray,int M){ 148 142 149 143 int i; 150 144 char *string = NULL; -
issm/trunk/src/c/classes/objects/Params/StringArrayParam.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _STRINGARRAYPARAM_H_ … … 28 27 int numstrings; 29 28 30 31 29 public: 32 30 /*StringArrayParam constructors, destructors: {{{*/ … … 39 37 void DeepEcho(); 40 38 int Id(); 41 int MyRank();42 39 int ObjectEnum(); 43 40 Object* copy(); … … 59 56 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");} 60 57 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 58 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 61 59 62 60 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} -
issm/trunk/src/c/classes/objects/Params/StringParam.cpp
r13395 r13975 33 33 xMemCpy<char>(value,in_value,(strlen(in_value)+1)); 34 34 35 36 35 } 37 36 /*}}}*/ … … 58 57 int StringParam::Id(void){ return -1; } 59 58 /*}}}*/ 60 /*FUNCTION StringParam::MyRank{{{*/61 int StringParam::MyRank(void){62 extern int my_rank;63 return my_rank;64 }65 /*}}}*/66 59 /*FUNCTION StringParam::ObjectEnum{{{*/ 67 60 int StringParam::ObjectEnum(void){ … … 73 66 /*FUNCTION StringParam::copy{{{*/ 74 67 Object* StringParam::copy() { 75 68 76 69 return new StringParam(this->enum_type,this->value); 77 70 … … 82 75 /*FUNCTION StringParam::GetParameterValue{{{*/ 83 76 void StringParam::GetParameterValue(char** pstring){ 84 77 85 78 char* outstring=NULL; 86 79 int stringsize; … … 102 95 /*FUNCTION StringParam::SetValue{{{*/ 103 96 void StringParam::SetValue(char* string){ 104 97 105 98 int stringsize; 106 99 107 100 /*avoid leak: */ 108 101 xDelete<char>(this->value); -
issm/trunk/src/c/classes/objects/Params/StringParam.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _STRINGPARAM_H_ … … 24 23 private: 25 24 /*just hold 3 values for 3 vertices: */ 26 int enum_type;27 char *value;25 int enum_type; 26 char *value; 28 27 29 28 public: … … 37 36 void DeepEcho(); 38 37 int Id(); 39 int MyRank();40 38 int ObjectEnum(); 41 39 Object* copy(); … … 57 55 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");} 58 56 void GetParameterValue(FILE** pfid){_error_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");} 57 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 59 58 60 59 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} -
issm/trunk/src/c/classes/objects/Params/TransientParam.cpp
r13395 r13975 61 61 void TransientParam::DeepEcho(void){ 62 62 63 int i,j;64 65 63 _printLine_("TransientParam:"); 66 64 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")"); 67 65 _printLine_(" size: " << this->N); 68 for(i =0;i<this->N;i++){66 for(int i=0;i<this->N;i++){ 69 67 _printLine_( "time: " << this->timesteps[i] << " value: " << this->values[i]); 70 68 } … … 73 71 /*FUNCTION TransientParam::Id{{{*/ 74 72 int TransientParam::Id(void){ return -1; } 75 /*}}}*/76 /*FUNCTION TransientParam::MyRank{{{*/77 int TransientParam::MyRank(void){78 extern int my_rank;79 return my_rank;80 }81 73 /*}}}*/ 82 74 /*FUNCTION TransientParam::ObjectEnum{{{*/ … … 89 81 /*FUNCTION TransientParam::copy{{{*/ 90 82 Object* TransientParam::copy() { 91 83 92 84 return new TransientParam(this->enum_type,this->values,this->timesteps,this->N); 93 85 -
issm/trunk/src/c/classes/objects/Params/TransientParam.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _TRANSIENTPARAM_H_ … … 23 22 24 23 protected: 25 int enum_type;26 int N;27 IssmDouble *values;28 IssmDouble *timesteps;24 int enum_type; 25 int N; 26 IssmDouble *values; 27 IssmDouble *timesteps; 29 28 30 29 public: … … 38 37 void DeepEcho(); 39 38 int Id(); 40 int MyRank();41 39 int ObjectEnum(); 42 40 Object* copy(); … … 58 56 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a Mat");} 59 57 void GetParameterValue(FILE** pfid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a FILE");} 58 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 60 59 61 60 void SetValue(bool boolean){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a boolean");} -
issm/trunk/src/c/classes/objects/Params/VectorParam.cpp
r13395 r13975 57 57 void VectorParam::DeepEcho(void){ 58 58 59 int i;60 59 _printLine_("VectorParam:"); 61 60 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")"); … … 65 64 /*FUNCTION VectorParam::Id{{{*/ 66 65 int VectorParam::Id(void){ return -1; } 67 /*}}}*/68 /*FUNCTION VectorParam::MyRank{{{*/69 int VectorParam::MyRank(void){70 extern int my_rank;71 return my_rank;72 }73 66 /*}}}*/ 74 67 /*FUNCTION VectorParam::ObjectEnum{{{*/ … … 81 74 /*FUNCTION VectorParam::copy{{{*/ 82 75 Object* VectorParam::copy() { 83 76 84 77 return new VectorParam(this->enum_type,this->value); 85 78 … … 109 102 /*avoid leak: */ 110 103 xdelete(&value); 111 104 112 105 /*copy: */ 113 106 value=vector->Duplicate(); -
issm/trunk/src/c/classes/objects/Params/VectorParam.h
r13395 r13975 2 2 * \brief: header file for triavertexinput object 3 3 */ 4 5 4 6 5 #ifndef _VECTORPARAM_H_ … … 37 36 void DeepEcho(); 38 37 int Id(); 39 int MyRank();40 38 int ObjectEnum(); 41 39 Object* copy(); … … 57 55 void GetParameterValue(Vector<IssmDouble>** poutput); 58 56 void GetParameterValue(FILE** pfid){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");} 57 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 59 58 60 59 void SetValue(bool boolean){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");} -
issm/trunk/src/c/classes/objects/Segment.h
r13395 r13975 15 15 16 16 public: 17 int eid;17 int eid; 18 18 doubletype x1; 19 19 doubletype y1; … … 21 21 doubletype y2; 22 22 23 24 23 /*Segment constructors, destructors :*/ 25 24 /*FUNCTION Segment() default constructor {{{*/ 26 25 Segment(){ 27 this->eid =UNDEF;28 this->x1 =UNDEF;29 this->y1 =UNDEF;30 this->x2 =UNDEF;31 this->y2 =UNDEF;26 this->eid = UNDEF; 27 this->x1 = UNDEF; 28 this->y1 = UNDEF; 29 this->x2 = UNDEF; 30 this->y2 = UNDEF; 32 31 } 33 32 /*}}}*/ … … 35 34 Segment(int segment_eid, doubletype segment_x1,doubletype segment_y1,doubletype segment_x2, doubletype segment_y2){ 36 35 37 this->eid =segment_eid;38 this->x1 =segment_x1;39 this->y1 =segment_y1;40 this->x2 =segment_x2;41 this->y2 =segment_y2;36 this->eid = segment_eid; 37 this->x1 = segment_x1; 38 this->y1 = segment_y1; 39 this->x2 = segment_x2; 40 this->y2 = segment_y2; 42 41 43 42 } … … 67 66 int Id(void){ return eid; } 68 67 /*}}}*/ 69 /*FUNCTION MyRank{{{*/70 int MyRank(void){71 extern int my_rank;72 73 return my_rank;74 }75 /*}}}*/76 68 /*FUNCTION ObjectEnum{{{*/ 77 69 int ObjectEnum(void){ … … 84 76 Object* copy() { 85 77 return new Segment(this->eid,this->x1,this->y1,this->x2,this->y2); 86 87 78 } 88 89 79 /*}}}*/ 90 80 -
issm/trunk/src/c/classes/objects/Vertex.cpp
r13395 r13975 49 49 this->id=vertex_id; 50 50 this->sid=vertex_sid; 51 this->pid=UNDEF; 51 52 this->x=vertex_x; 52 53 this->y=vertex_y; … … 54 55 this->sigma=vertex_sigma; 55 56 this->connectivity=vertex_connectivity; 56 this->dof=UNDEF;57 57 58 58 return; … … 67 67 _printLine_(" id: " << id); 68 68 _printLine_(" sid: " << sid); 69 _printLine_(" pid: " << pid); 69 70 _printLine_(" x: " << x); 70 71 _printLine_(" y: " << y); … … 72 73 _printLine_(" sigma: " << sigma); 73 74 _printLine_(" connectivity: " << connectivity); 74 _printLine_(" dof: " << dof);75 75 _printLine_(" clone: " << clone); 76 76 … … 86 86 int Vertex::Id(void){ return id; } 87 87 /*}}}*/ 88 /*FUNCTION Vertex::MyRank {{{*/89 int Vertex::MyRank(void){90 extern int my_rank;91 return my_rank;92 }93 /*}}}*/94 88 /*FUNCTION Vertex::ObjectEnum{{{*/ 95 89 int Vertex::ObjectEnum(void){ … … 103 97 104 98 return new Vertex(*this); 105 106 }107 /*}}}*/108 109 /* DofObject routines: */110 /*FUNCTION Vertex::DistributeDofs{{{*/111 void Vertex::DistributeDofs(int* pdofcount){112 113 int i;114 extern int my_rank;115 int dofcount;116 117 dofcount=*pdofcount;118 119 if(this->clone){120 /*This vertex is a clone! Don't distribute dofs, it will get them from another cpu!*/121 return;122 }123 124 /*This vertex should distribute his dof, go ahead: */125 this->dof=dofcount;126 dofcount++;127 128 /*Assign output pointers: */129 *pdofcount=dofcount;130 131 }132 /*}}}*/133 /*FUNCTION Vertex::OffsetDofs{{{*/134 void Vertex::OffsetDofs(int dofcount){135 136 int i;137 extern int my_rank;138 139 if(this->clone){140 /*This vertex is a clone, don't offset the dofs!: */141 return;142 }143 144 /*This vertex should offset his dof, go ahead: */145 this->dof+=dofcount;146 }147 /*}}}*/148 /*FUNCTION Vertex::ShowTrueDofs{{{*/149 void Vertex::ShowTrueDofs(int* truedofs){150 151 int j;152 extern int my_rank;153 154 /*Are we a clone? : */155 if(this->clone)return;156 157 /*Ok, we are not a clone, just plug our dof into truedofs: */158 truedofs[this->id-1]=this->dof;159 160 }161 /*}}}*/162 /*FUNCTION Vertex::UpdateCloneDofs{{{*/163 void Vertex::UpdateCloneDofs(int* alltruedofs){164 165 int j;166 extern int my_rank;167 168 /*If we are not a clone, don't update, we already have dofs!: */169 if(this->clone==0)return;170 171 /*Ok, we are a clone node, but we did not create the dof for this vertex172 * Therefore, our dof is garbage right now. Go pick it up in the alltruedofs: */173 this->dof=alltruedofs[id-1];174 }175 /*}}}*/176 /*FUNCTION Vertex::SetClone {{{*/177 void Vertex::SetClone(int* minranks){178 179 extern int my_rank;180 181 if (minranks[id-1]==my_rank){182 this->clone=0;183 }184 else{185 /*!there is a cpu with lower rank that has the same vertex,186 therefore, I am a clone*/187 this->clone=1;188 }189 99 190 100 } … … 209 119 /*sigma remains constant. z=bed+sigma*thickness*/ 210 120 oldz = this->z; 211 newz = bed[this-> dof]+sigma*thickness[this->dof];121 newz = bed[this->pid]+sigma*thickness[this->pid]; 212 122 velz = (newz-oldz)/dt; 213 123 this->z = newz; 214 124 215 125 /*put vz in vector*/ 216 vz->SetValue(this-> dof,velz,INS_VAL);126 vz->SetValue(this->pid,velz,INS_VAL); 217 127 } 218 128 /*}}}*/ 129 /*FUNCTION Vertex::DistributePids{{{*/ 130 void Vertex::DistributePids(int* ppidcount){ 131 132 /*retrieve current pid*/ 133 int pidcount=*ppidcount; 134 135 /*This vertex is a clone! Don't distribute pids, it will get them from another cpu!*/ 136 if(this->clone) return; 137 138 /*This vertex should distribute its pid*/ 139 this->pid=pidcount; 140 pidcount++; 141 142 /*Assign output pointers: */ 143 *ppidcount=pidcount; 144 } 145 /*}}}*/ 146 /*FUNCTION Vertex::OffsetPids{{{*/ 147 void Vertex::OffsetPids(int pidcount){ 148 149 /*This vertex is a clone, don't offset the pids*/ 150 if(this->clone) return; 151 152 /*This vertex should offset his pid, go ahead: */ 153 this->pid+=pidcount; 154 } 155 /*}}}*/ 156 /*FUNCTION Vertex::ShowTruePids{{{*/ 157 void Vertex::ShowTruePids(int* truepids){ 158 159 /*Are we a clone? : */ 160 if(this->clone)return; 161 162 /*Ok, we are not a clone, just plug our pid into truepids: */ 163 truepids[this->sid]=this->pid; 164 } 165 /*}}}*/ 166 /*FUNCTION Vertex::UpdateClonePids{{{*/ 167 void Vertex::UpdateClonePids(int* alltruepids){ 168 169 /*If we are not a clone, don't update, we already have pids: */ 170 if(!this->clone)return; 171 172 /*Ok, we are a clone node, but we did not create the pid for this vertex 173 * Therefore, our pid is garbage right now. Go pick it up in the alltruepids: */ 174 this->pid=alltruepids[this->sid]; 175 } 176 /*}}}*/ 177 /*FUNCTION Vertex::SetClone {{{*/ 178 void Vertex::SetClone(int* minranks){ 179 180 int my_rank; 181 182 /*recover my_rank:*/ 183 my_rank=IssmComm::GetRank(); 184 185 if (minranks[this->sid]==my_rank){ 186 this->clone=false; 187 } 188 else{ 189 /*!there is a cpu with lower rank that has the same vertex, 190 therefore, I am a clone*/ 191 this->clone=true; 192 } 193 194 } 195 /*}}}*/ -
issm/trunk/src/c/classes/objects/Vertex.h
r13395 r13975 9 9 /*{{{*/ 10 10 #include "../classes.h" 11 class IoModel;12 template <class doubletype> class Vector;13 class Parameters;14 11 #include "../../shared/Exceptions/exceptions.h" 15 12 #include "../../toolkits/toolkits.h" 16 13 #include "../../include/include.h" 17 14 template <class doubletype> class Vector; 15 class Parameters; 16 class IoModel; 18 17 /*}}}*/ 19 20 18 21 19 class Vertex: public Object{ 22 20 23 21 public: 24 25 int id; 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. 22 bool clone; 23 int id; // random index 24 int sid; // "serial" id (rank of this vertex if the dataset was on 1 cpu) 25 int pid; // "parallel" id 27 26 IssmDouble x; 28 27 IssmDouble y; 29 28 IssmDouble z; 30 IssmDouble sigma; //sigma coordinate: (z-bed)/thickness 31 int connectivity; //number of vertices connected to this vertex 32 33 /*dof management: */ 34 int clone; 35 int dof; //dof to recover values in a vertex indexed vector 29 IssmDouble sigma; //sigma coordinate: (z-bed)/thickness 30 int connectivity; //number of vertices connected to this vertex 36 31 37 32 /*Vertex constructors, destructors {{{*/ … … 46 41 void DeepEcho(); 47 42 int Id(); 48 int MyRank();49 43 int ObjectEnum(); 50 44 Object* copy(); 51 45 /*}}}*/ 52 /*DofObject routines {{{*/ 53 void DistributeDofs(int* pdofcount); 54 void OffsetDofs(int dofcount); 55 void ShowTrueDofs(int* borderdofs); 56 void UpdateCloneDofs(int* allborderdofs); 57 void SetClone(int* minranks); 58 /*}}}*/ 59 /*Vertex management: {{{*/ 46 /*Vertex management:*/ 60 47 int Sid(void); 61 48 int Connectivity(void); 62 49 void UpdatePosition(Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed); 63 /*}}}*/ 50 void DistributePids(int* ppidcount); 51 void OffsetPids(int pidcount); 52 void ShowTruePids(int* borderpids); 53 void UpdateClonePids(int* allborderpids); 54 void SetClone(int* minranks); 64 55 }; 65 56 #endif /* _VERTEX_H */ -
issm/trunk/src/c/classes/objects/objects.h
r13395 r13975 13 13 #include "./Vertex.h" 14 14 #include "./Node.h" 15 #include "./Profiler.h" 16 #include "./DependentObject.h" 17 #include "./IndependentObject.h" 15 18 #include "./Segment.h" 16 19 … … 119 122 #include "./Params/StringParam.h" 120 123 #include "./Params/TransientParam.h" 124 #include "./Params/DataSetParam.h" 121 125 122 126 #endif -
issm/trunk/src/c/include/globals.h
r11995 r13975 6 6 #define GLOBALS_H_ 7 7 8 int my_rank=0; 9 int num_procs=1; 8 #include "./types.h" 9 #include "../classes/IssmComm.h" 10 11 COMM IssmComm::comm; 10 12 11 13 #endif -
issm/trunk/src/c/include/macros.h
r13395 r13975 23 23 #define _printf_(flag,...) do{if(flag) PrintfFunction(__VA_ARGS__);}while(0) 24 24 /*}}}*/ 25 /* _error 2_ {{{*/25 /* _error_ {{{*/ 26 26 /*new Error exception macro*/ 27 27 #ifdef _INTEL_WIN_ … … 71 71 #endif 72 72 /*}}}*/ 73 /* ISSMBOOT/ISSMEND{{{*/73 /* ExceptionTrapBegin/ExceptionTrapEnd {{{*/ 74 74 75 75 /*The following macros hide the error exception handling in a matlab module. Just put 76 * ISSMBOOT(); and ISSMEND(); at the beginning and end of a module, and c++ exceptions76 * ExceptionTrapBegin(); and ExceptionTrapEnd(); at the beginning and end of a module, and c++ exceptions 77 77 * will be trapped. Really nifty!*/ 78 78 79 #define ISSMBOOT(); \79 #define ExceptionTrapBegin(); \ 80 80 try{ 81 81 82 #define ISSMEND(); }\82 #define ExceptionTrapEnd(); }\ 83 83 catch(ErrorException &exception){\ 84 exception.Report(); 85 return 1;\84 exception.Report();\ 85 return 0;\ 86 86 }\ 87 87 catch (exception& e) {\ 88 88 _printf_(true,"Standard exception: %s\n",e.what());\ 89 return 1;\89 return 0;\ 90 90 }\ 91 91 catch(...){\ 92 92 _printf_(true,"An unexpected error occurred");\ 93 return 0;\ 93 94 } 94 95 /*}}}*/ -
issm/trunk/src/c/include/typedefs.h
r12706 r13975 36 36 #define INFINITY (DBL_MAX+DBL_MAX) 37 37 #define NAN (INFINITY-INFINITY) 38 38 39 39 #endif 40 40 -
issm/trunk/src/c/include/types.h
r12706 r13975 5 5 #ifndef _TYPES_H_ 6 6 #define _TYPES_H_ 7 8 7 9 8 #ifdef HAVE_CONFIG_H … … 27 26 #endif 28 27 29 #if def _HAVE_ADOLC_28 #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_) 30 29 #include "adolc/adolc.h" 31 30 // for active variables … … 40 39 #endif 41 40 42 typedef bool IssmBool; 41 /*Define communicator: */ 42 #ifdef _HAVE_MPI_ 43 #include <mpi.h> 44 typedef MPI_Comm COMM; 45 #else 46 typedef int COMM; 47 #endif 43 48 44 49 #endif //ifndef _TYPES_H_ -
issm/trunk/src/c/io/Disk/diskio.h
r13395 r13975 10 10 FILE* pfopen(char* filename,const char* format); 11 11 void pfclose(FILE* fid,char* filename); 12 void WriteLockFile(char* filename); 12 13 13 14 #endif /* _IO_H_ */ -
issm/trunk/src/c/io/Disk/pfclose.cpp
r13395 r13975 16 16 17 17 /*Close file handle: */ 18 extern int my_rank;19 18 _assert_(fid); 20 19 if(fclose(fid)!=0)_error_("could not close file " << filename); -
issm/trunk/src/c/io/Disk/pfopen.cpp
r13395 r13975 16 16 17 17 FILE* fid=NULL; 18 extern int my_rank; 19 18 20 19 /*Open handle to data on disk: */ 21 20 fid=fopen(filename,format); … … 24 23 return fid; 25 24 } 26 -
issm/trunk/src/c/io/PrintfFunction.cpp
r12706 r13975 15 15 char *buffer = NULL; 16 16 int n,size = 100; 17 int string_size; 18 extern int my_rank; 19 extern int num_procs; 20 17 int my_rank; 21 18 //variable list of arguments 22 19 va_list args; 20 21 /*recover my_rank:*/ 22 my_rank=IssmComm::GetRank(); 23 23 24 24 while(true){ … … 52 52 } 53 53 int PrintfFunction(const string & message){ 54 extern int my_rank; 54 int my_rank; 55 56 /*recover my_rank:*/ 57 my_rank=IssmComm::GetRank(); 58 55 59 if(my_rank==0){ 56 60 printf("%s\n",message.c_str()); … … 59 63 } 60 64 int PrintfFunction2(const string & message){ 61 extern int my_rank; 65 int my_rank; 66 67 /*recover my_rank:*/ 68 my_rank=IssmComm::GetRank(); 69 62 70 if(my_rank==0){ 63 71 printf("%s",message.c_str()); -
issm/trunk/src/c/issm.h
r13395 r13975 12 12 #endif 13 13 14 #include "./include/globals.h" //only include this header file once! 14 15 #include "./include/include.h" 15 16 #include "./shared/shared.h" -
issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.cpp
r12706 r13975 11 11 12 12 int AverageFilterx(double** pimageout,double* image, int lines,int samps,int smooth){ 13 13 14 14 double temp; 15 15 int numvalues; -
issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.h
r3109 r13975 11 11 /* local prototypes: */ 12 12 int AverageFilterx(double** pimageout,double* imagein, int lines,int samp,int smooth); 13 13 14 14 #endif /* AVERAGEFILTERX_H */ 15 -
issm/trunk/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp
r13395 r13975 18 18 #include "../modules.h" 19 19 20 21 20 void AverageOntoPartitionx(double** paverage, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* vertex_response){ 22 21 23 int i,j,k;24 22 int dummy; 25 26 23 int npart; 27 24 double *qmu_part = NULL; … … 49 46 50 47 /*loop on each element, and add contribution of the element to the partition (surface weighted average): */ 51 for(i =0;i<elements->Size();i++){52 Element* element= (Element*)elements->GetObjectByOffset(i);48 for(int i=0;i<elements->Size();i++){ 49 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 53 50 element->AverageOntoPartition(partition_contributions,partition_areas,vertex_response,qmu_part); 54 51 } -
issm/trunk/src/c/modules/Bamgx/Bamgx.cpp
r13395 r13975 20 20 21 21 /*intermediary*/ 22 int i; 22 23 int noerr=1; 23 int i,j,num;24 24 double costheta=2; 25 25 double hminaniso=1e-100; -
issm/trunk/src/c/modules/Chacox/Chacox.cpp
r12706 r13975 21 21 { 22 22 #ifdef _HAVE_CHACO_ //only works if Chaco library has been compiled in. 23 24 23 25 24 extern int Using_Main; /* is main routine being called? */ 26 25 extern char *PARAMS_FILENAME; /* name of file with parameter updates */ … … 62 61 int i,tvwgt; 63 62 double tgoal; 64 65 66 63 67 64 if (DEBUG_TRACE > 0) { … … 187 184 _printLine_("<Leaving main>"); 188 185 } 189 186 190 187 return(0); 191 192 188 193 189 #else //ifdef _HAVE_CHACO_ -
issm/trunk/src/c/modules/Chacox/Chacox.h
r13395 r13975 44 44 #define __FUNCT__ "Chacox" 45 45 46 47 46 #endif /* _CHACOX_H */ -
issm/trunk/src/c/modules/Chacox/chaco_seconds.cpp
r11237 r13975 8 8 #endif 9 9 10 double chaco_seconds(void){ 10 11 11 12 double chaco_seconds(void){13 14 12 double curtime; 15 13 … … 22 20 *is defined in the <sys/time.h> and <sys/resource.h> header files. Leaving it 23 21 *for reference in case we have a problem here in the future*/ 24 22 25 23 getrusage(RUSAGE_SELF, &rusage); 26 24 curtime = ((rusage.ru_utime.tv_sec + rusage.ru_stime.tv_sec) + -
issm/trunk/src/c/modules/Chacox/input_parse.cpp
r12706 r13975 4 4 5 5 #include "./Chacox.h" 6 7 6 8 7 #undef __FUNCT__ -
issm/trunk/src/c/modules/Chacox/user_params.cpp
r9320 r13975 14 14 #endif 15 15 16 17 16 #ifdef _HAVE_CHACO_ //only works if dakota library has been compiled in. 18 17 … … 21 20 #define TRUE 1 22 21 #define FALSE 0 23 24 22 25 23 /* Input and ouput control parameters */ … … 34 32 int PROMPT = FALSE; /* Prompt for input? (TRUE/FALSE) */ 35 33 int PRINT_HEADERS = FALSE; /* Print pretty output headers (TRUE/FALSE) */ 36 37 34 38 35 /* Eigenvector calculation parameters */ … … 57 54 int TIME_KERNELS = FALSE; /* Time numerical kernels? (TRUE/FALSE) */ 58 55 59 60 56 /* Other parameters for spectral methods */ 61 57 … … 69 65 int OPT3D_NTRIES = 5; /* # local opts to look for global min in opt3d */ 70 66 71 72 67 /* Kernighan--Lin/Fiduccia--Mattheyses parameters */ 73 68 … … 78 73 int KL_UNDO_LIST = TRUE; /* Only resort changed vtxs? (TRUE/FALSE) */ 79 74 double KL_IMBALANCE = 0.0; /* Fractional imbalance allowed by KL */ 80 81 75 82 76 /* Coarsening parameters */ … … 91 85 int KL_ONLY_BNDY = TRUE; /* Start moving vtxs on boundary? (TRUE/FALSE) */ 92 86 93 94 87 /* Parameters for post-processing options */ 95 88 … … 97 90 int INTERNAL_VERTICES = FALSE; /* ... to up internal vtxs? (TRUE/FALSE) */ 98 91 int REFINE_MAP = FALSE; /* ... to reduce hops? (TRUE/FALSE) */ 99 100 92 101 93 /* Architecture and simulator parameters */ … … 129 121 char *PARAMS_FILENAME = "User_Params"; /* File of parameter changes */ 130 122 131 132 123 /* Parameters that control debugging output */ 133 124 … … 151 142 int DEBUG_MACH_PARAMS = 0;/* Print computed machine params? (0..1) */ 152 143 153 154 144 #endif //ifdef _HAVE_CHACO_ -
issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp
r13395 r13975 29 29 /*Compute basal stress for each element: */ 30 30 for (i=0;i<elements->Size();i++){ 31 element= (Element*)elements->GetObjectByOffset(i);31 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 32 32 element->ComputeBasalStress(sigma); 33 33 } … … 38 38 /*Assign output pointers: */ 39 39 *psigma=sigma; 40 40 41 41 } -
issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.h
r13395 r13975 13 13 14 14 #endif /* _COMPUTEBASALSTRESSX_H */ 15 -
issm/trunk/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.cpp
r13395 r13975 29 29 /*Compute basal stress for each element: */ 30 30 for (i=0;i<elements->Size();i++){ 31 element= (Element*)elements->GetObjectByOffset(i);31 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 32 32 element->ComputeStrainRate(eps); 33 33 } … … 38 38 /*Assign output pointers: */ 39 39 *peps=eps; 40 40 41 41 } -
issm/trunk/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.h
r13395 r13975 13 13 14 14 #endif /* _COMPUTESTRAINRATEX_H */ 15 -
issm/trunk/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp
r12706 r13975 24 24 /*Get analysis type: */ 25 25 parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 26 26 27 27 if(VerboseMProcessor()) _pprintLine_(" Configuring elements..."); 28 28 for (i=0;i<elements->Size();i++){ 29 element= (Element*)elements->GetObjectByOffset(i);29 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 30 30 element->Configure(elements,loads,nodes,materials,parameters); 31 31 } … … 44 44 } 45 45 } 46 46 47 47 if(VerboseMProcessor()) _pprintLine_(" Configuring materials..."); 48 48 for (i=0;i<materials->Size();i++){ -
issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStateLocal.h
r13395 r13975 27 27 28 28 #endif /* _CONSTRAINTSSTATEX_H */ 29 -
issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.cpp
r12706 r13975 13 13 void ConstraintsStatex(int* pconverged, int* pnum_unstable_constraints, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads,Materials* materials, Parameters* parameters){ 14 14 15 int i;16 17 extern int num_procs;18 extern int my_rank;19 20 15 /*output: */ 21 16 int converged=0; … … 46 41 converged=1; 47 42 } 48 43 49 44 /*Assign output pointers: */ 50 45 *pconverged=converged; -
issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.h
r13395 r13975 15 15 16 16 #endif /* _CONSTRAINTSSTATEX_H */ 17 -
issm/trunk/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp
r12706 r13975 15 15 int RiftIsPresent(Loads* loads,int configuration_type){ 16 16 17 18 17 int i; 19 18 20 19 int found=0; 21 20 int mpi_found=0; … … 33 32 34 33 #ifdef _HAVE_MPI_ 35 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0, MPI_COMM_WORLD);36 MPI_Bcast(&mpi_found,1,MPI_INT,0, MPI_COMM_WORLD);34 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() ); 35 MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm()); 37 36 found=mpi_found; 38 37 #endif … … 46 45 int num_unstable_constraints=0; 47 46 int converged=0; 48 int potential;49 47 50 48 RiftConstrain(&num_unstable_constraints,loads,configuration_type); 51 49 if(num_unstable_constraints==0)converged=1; 52 50 53 51 if(RiftIsFrozen(loads,configuration_type)){ 54 52 converged=1; … … 69 67 70 68 int i; 71 69 72 70 /* generic object pointer: */ 73 71 Riftfront* riftfront=NULL; … … 77 75 int sum_num_unstable_constraints; 78 76 int num_unstable_constraints=0; 79 77 80 78 /*Enforce constraints: */ 81 79 for (i=0;i<loads->Size();i++){ … … 96 94 97 95 #ifdef _HAVE_MPI_ 98 MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0, MPI_COMM_WORLD);99 MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0, MPI_COMM_WORLD);96 MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() ); 97 MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,IssmComm::GetComm()); 100 98 num_unstable_constraints=sum_num_unstable_constraints; 101 99 #endif 102 100 103 101 /*Assign output pointers: */ 104 102 *pnum_unstable_constraints=num_unstable_constraints; … … 110 108 111 109 int i; 112 110 113 111 /* generic object pointer: */ 114 112 Load* load=NULL; … … 121 119 122 120 if (RiftfrontEnum==loads->GetEnum(i)){ 123 121 124 122 load=(Load*)loads->GetObjectByOffset(i); 125 123 if(load->InAnalysis(configuration_type)){ … … 133 131 } 134 132 } 135 133 136 134 /*Is there just one found? that would mean we have frozen! : */ 137 135 #ifdef _HAVE_MPI_ 138 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_MAX,0, MPI_COMM_WORLD);139 MPI_Bcast(&mpi_found,1,MPI_INT,0, MPI_COMM_WORLD);136 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() ); 137 MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm()); 140 138 found=mpi_found; 141 139 #endif … … 148 146 149 147 int i; 150 148 151 149 /* generic object pointer: */ 152 150 Load* load=NULL; … … 160 158 load=(Load*)loads->GetObjectByOffset(i); 161 159 if(load->InAnalysis(configuration_type)){ 162 160 163 161 riftfront=(Riftfront*)load; 164 162 riftfront->FreezeConstraints(); … … 176 174 177 175 int i; 178 176 179 177 Riftfront* riftfront=NULL; 180 178 int found=0; … … 196 194 197 195 #ifdef _HAVE_MPI_ 198 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0, MPI_COMM_WORLD);199 MPI_Bcast(&mpi_found,1,MPI_INT,0, MPI_COMM_WORLD);196 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() ); 197 MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm()); 200 198 found=mpi_found; 201 199 #endif … … 207 205 int RiftIsPreStable(Loads* loads){ 208 206 209 210 207 int i; 211 208 212 209 Riftfront* riftfront=NULL; 213 210 int found=0; … … 229 226 230 227 #ifdef _HAVE_MPI_ 231 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0, MPI_COMM_WORLD);232 MPI_Bcast(&mpi_found,1,MPI_INT,0, MPI_COMM_WORLD);228 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() ); 229 MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm()); 233 230 found=mpi_found; 234 231 #endif … … 246 243 void RiftSetPreStable(Loads* loads){ 247 244 248 249 245 int i; 250 246 251 247 Riftfront* riftfront=NULL; 252 248 int found=0; … … 268 264 269 265 int i; 270 266 271 267 /* generic object pointer: */ 272 268 Riftfront* riftfront=NULL; … … 275 271 int sum_num_unstable_constraints; 276 272 int num_unstable_constraints=0; 277 273 278 274 /*Enforce constraints: */ 279 275 for (i=0;i<loads->Size();i++){ … … 290 286 291 287 #ifdef _HAVE_MPI_ 292 MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0, MPI_COMM_WORLD);293 MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0, MPI_COMM_WORLD);288 MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() ); 289 MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,IssmComm::GetComm()); 294 290 num_unstable_constraints=sum_num_unstable_constraints; 295 291 #endif 296 292 297 293 /*Assign output pointers: */ 298 294 *pnum_unstable_constraints=num_unstable_constraints; … … 304 300 305 301 int i; 306 302 307 303 /* generic object pointer: */ 308 304 Riftfront* riftfront=NULL; … … 330 326 331 327 #ifdef _HAVE_MPI_ 332 MPI_Reduce (&max_penetration,&mpi_max_penetration,1,MPI_DOUBLE,MPI_MAX,0, MPI_COMM_WORLD);333 MPI_Bcast(&mpi_max_penetration,1,MPI_DOUBLE,0, MPI_COMM_WORLD);328 MPI_Reduce (&max_penetration,&mpi_max_penetration,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() ); 329 MPI_Bcast(&mpi_max_penetration,1,MPI_DOUBLE,0,IssmComm::GetComm()); 334 330 max_penetration=mpi_max_penetration; 335 331 #endif … … 346 342 347 343 int i; 348 344 349 345 /* generic object pointer: */ 350 346 Riftfront* riftfront=NULL; … … 369 365 370 366 #ifdef _HAVE_MPI_ 371 MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0, MPI_COMM_WORLD);372 MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0, MPI_COMM_WORLD);367 MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() ); 368 MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,IssmComm::GetComm()); 373 369 num_unstable_constraints=sum_num_unstable_constraints; 374 370 #endif -
issm/trunk/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp
r12330 r13975 37 37 38 38 #ifdef _HAVE_MPI_ 39 MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0, MPI_COMM_WORLD);40 MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0, MPI_COMM_WORLD);39 MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() ); 40 MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,IssmComm::GetComm()); 41 41 num_unstable_constraints=sum_num_unstable_constraints; 42 42 #endif -
issm/trunk/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp
r12330 r13975 27 27 } 28 28 } 29 29 30 30 #ifdef _HAVE_MPI_ 31 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0, MPI_COMM_WORLD);32 MPI_Bcast(&mpi_found,1,MPI_INT,0, MPI_COMM_WORLD);31 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() ); 32 MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm()); 33 33 found=mpi_found; 34 34 #endif -
issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.cpp
r13395 r13975 8 8 #endif 9 9 10 11 10 #include "./ContourToMeshx.h" 12 11 13 12 int ContourToMeshx(SeqVec<double>** pin_nod,SeqVec<double>** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue) { 14 15 int noerr=1;16 int i;17 int m,n;18 13 19 14 /*Contour:*/ … … 27 22 num=_NUMTHREADS_; 28 23 #endif 29 30 24 31 25 /*output: */ … … 54 48 /*Take care of the case where an element interpolation has been requested: */ 55 49 if ((strcmp(interptype,"element")==0) || (strcmp(interptype,"element and node")==0)){ 56 for (n=0;n<nel;n++){50 for(int n=0;n<nel;n++){ 57 51 if ( (in_nod_serial[ (int)*(index+3*n+0) -1] == 1) && (in_nod_serial[ (int)*(index+3*n+1) -1] == 1) && (in_nod_serial[ (int)*(index+3*n+2) -1] == 1) ){ 58 52 value=1; in_elem->SetValue(n,value,INS_VAL); … … 71 65 xDelete<double>(in_nod_serial); 72 66 73 return noerr;67 return 1; 74 68 } -
issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.h
r13395 r13975 2 2 ContourToMeshx.h 3 3 */ 4 5 4 6 5 #ifndef _CONTOURTOMESHX_H … … 22 21 } ContourToMeshxThreadStruct; 23 22 24 25 23 /* local prototypes: */ 26 24 int ContourToMeshx(SeqVec<double>** pin_nods,SeqVec<double>** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue); -
issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp
r13395 r13975 12 12 13 13 void* ContourToMeshxt(void* vpthread_handle){ 14 14 15 15 int noerr=1; 16 16 -
issm/trunk/src/c/modules/ContourToNodesx/ContourToNodesx.cpp
r13395 r13975 7 7 8 8 int i; 9 int m,n;10 9 11 10 /*Contour:*/ … … 14 13 double* xc=NULL; 15 14 double* yc=NULL; 16 double value;17 15 18 16 /*output: */ … … 34 32 /*Assign output pointers: */ 35 33 *pflags=flags; 36 37 34 return 1; 38 35 } … … 40 37 int ContourToNodesx(SeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue){ 41 38 42 int i;43 int m,n;44 45 39 /*Contour:*/ 46 40 Contour<IssmPDouble>* contouri=NULL; 47 int numnodes;48 41 double* xc=NULL; 49 42 double* yc=NULL; 50 double value;51 43 52 44 /*output: */ … … 56 48 /*Loop through all contours: */ 57 49 if(contours){ 58 for (i=0;i<contours->Size();i++){50 for(int i=0;i<contours->Size();i++){ 59 51 Contour<IssmPDouble>* contour=(Contour<IssmPDouble>*)contours->GetObjectByOffset(i); 60 52 IsInPoly(flags,contour->x,contour->y,contour->nods,x,y,0,nods,edgevalue); -
issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp
r13395 r13975 16 16 IssmDouble *scalar_list = NULL; 17 17 IssmDouble scalar; 18 19 18 20 19 /*Retrieve some parameters*/ -
issm/trunk/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp
r13395 r13975 12 12 void CreateNodalConstraintsx( Vector<IssmDouble>** pys, Nodes* nodes,int configuration_type){ 13 13 14 int i; 15 16 /*intermediary: */ 17 int numberofdofs; 14 bool oldalloc = false; 18 15 19 16 /*output: */ … … 21 18 22 19 /*figure out how many dofs we have: */ 23 numberofdofs=nodes->NumberOfDofs(configuration_type,SsetEnum); 20 int ssize=nodes->NumberOfDofs(configuration_type,SsetEnum); 21 int slocalsize = nodes->NumberOfDofsLocal(configuration_type,SsetEnum); 24 22 25 23 /*allocate:*/ 26 ys=new Vector<IssmDouble>(numberofdofs); 24 if(oldalloc) 25 ys=new Vector<IssmDouble>(ssize); 26 else 27 ys=new Vector<IssmDouble>(slocalsize,ssize); 27 28 28 29 /*go through all nodes, and for the ones corresponding to this configuration_type, fill the 29 30 * constraints vector with the constraint values: */ 30 for (i=0;i<nodes->Size();i++){31 for(int i=0;i<nodes->Size();i++){ 31 32 Node* node=(Node*)nodes->GetObjectByOffset(i); 32 33 if (node->InAnalysis(configuration_type)){ -
issm/trunk/src/c/modules/Delta18oParameterizationx/Delta18oParameterizationx.cpp
r13395 r13975 15 15 int i; 16 16 Element* element = NULL; 17 17 18 18 /*Compute temperature and precipitation fields: */ 19 19 for(i=0;i<elements->Size();i++){ 20 element= (Element*)elements->GetObjectByOffset(i);20 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 21 21 element->Delta18oParameterization(); 22 22 } -
issm/trunk/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp
r13395 r13975 22 22 /*Compute Misfit: */ 23 23 for (i=0;i<elements->Size();i++){ 24 element= (Element*)elements->GetObjectByOffset(i);24 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 25 25 J+=element->DragCoefficientAbsGradient(process_units,weight_index); 26 26 } … … 28 28 /*Sum all J from all cpus of the cluster:*/ 29 29 #ifdef _HAVE_MPI_ 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0, MPI_COMM_WORLD);31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0, MPI_COMM_WORLD);30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 32 32 J=J_sum; 33 33 #endif -
issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.cpp
r12706 r13975 41 41 * Once we get the neighbouring elements, figure out if they share a segment with the current element. If so, 42 42 * plug them in the connectivity, unless they are already there.: */ 43 43 44 44 for(n=0;n<nel;n++){ 45 45 … … 47 47 48 48 for(i=0;i<3;i++){ 49 49 50 50 node=(int)*(elements+n*3+i); //already matlab indexed, elements comes directly from the workspace. 51 51 index=node-1; … … 58 58 connectedelement=*(nodeconnectivity+width*index+j); 59 59 connectedelementindex=(int)(connectedelement-1); //go from matlab indexing to c indexing. 60 60 61 61 if(hascommondedge(elements+n*3+0,elements+connectedelementindex*3+0)){ 62 62 /*Ok, this connected element has a commond edge with element, plug it into elementconnectivity, unless … … 80 80 *pelementconnectivity=elementconnectivity; 81 81 } 82 83 82 84 83 int hascommondedge(double* element1,double* element2){ -
issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.h
r1105 r13975 10 10 11 11 #endif /* _ELEMENTCONNECTIVITYX_H */ 12 -
issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp
r13395 r13975 18 18 19 19 case AutodiffIsautodiffEnum : return "AutodiffIsautodiff"; 20 case AutodiffDependentsEnum : return "AutodiffDependents";21 20 case AutodiffNumDependentsEnum : return "AutodiffNumDependents"; 22 case AutodiffIndependentsEnum : return "AutodiffIndependents"; 21 case AutodiffNumDependentObjectsEnum : return "AutodiffNumDependentObjects"; 22 case AutodiffDependentObjectNamesEnum : return "AutodiffDependentObjectNames"; 23 case AutodiffDependentObjectTypesEnum : return "AutodiffDependentObjectTypes"; 24 case AutodiffDependentObjectIndicesEnum : return "AutodiffDependentObjectIndices"; 25 case AutodiffDependentObjectsEnum : return "AutodiffDependentObjects"; 23 26 case AutodiffNumIndependentsEnum : return "AutodiffNumIndependents"; 27 case AutodiffNumIndependentObjectsEnum : return "AutodiffNumIndependentObjects"; 28 case AutodiffIndependentObjectNamesEnum : return "AutodiffIndependentObjectNames"; 29 case AutodiffIndependentObjectTypesEnum : return "AutodiffIndependentObjectTypes"; 30 case AutodiffIndependentObjectsEnum : return "AutodiffIndependentObjects"; 24 31 case AutodiffJacobianEnum : return "AutodiffJacobian"; 25 32 case AutodiffXpEnum : return "AutodiffXp"; 26 case AutodiffFosForwardOutputEnum : return "AutodiffFosForwardOutput"; 33 case AutodiffDriverEnum : return "AutodiffDriver"; 34 case AutodiffFosForwardIndexEnum : return "AutodiffFosForwardIndex"; 35 case AutodiffFovForwardIndicesEnum : return "AutodiffFovForwardIndices"; 36 case AutodiffFosReverseIndexEnum : return "AutodiffFosReverseIndex"; 37 case AutodiffMassFluxSegmentsPresentEnum : return "AutodiffMassFluxSegmentsPresent"; 38 case AutodiffKeepEnum : return "AutodiffKeep"; 27 39 case BalancethicknessSpcthicknessEnum : return "BalancethicknessSpcthickness"; 28 40 case BalancethicknessStabilizationEnum : return "BalancethicknessStabilization"; … … 36 48 case ConstantsReferencetemperatureEnum : return "ConstantsReferencetemperature"; 37 49 case ConstantsYtsEnum : return "ConstantsYts"; 50 case DependentObjectEnum : return "DependentObject"; 38 51 case DiagnosticAbstolEnum : return "DiagnosticAbstol"; 39 52 case DiagnosticIcefrontEnum : return "DiagnosticIcefront"; … … 75 88 case HydrologySpcwatercolumnEnum : return "HydrologySpcwatercolumn"; 76 89 case HydrologyStabilizationEnum : return "HydrologyStabilization"; 90 case IndependentObjectEnum : return "IndependentObject"; 77 91 case InversionControlParametersEnum : return "InversionControlParameters"; 78 92 case InversionCostFunctionEnum : return "InversionCostFunction"; … … 148 162 case PrognosticStabilizationEnum : return "PrognosticStabilization"; 149 163 case PrognosticVertexPairingEnum : return "PrognosticVertexPairing"; 164 case PrognosticNumRequestedOutputsEnum : return "PrognosticNumRequestedOutputs"; 165 case PrognosticRequestedOutputsEnum : return "PrognosticRequestedOutputs"; 150 166 case QmuIsdakotaEnum : return "QmuIsdakota"; 151 case QmuMassFluxSegmentsEnum : return "QmuMassFluxSegments"; 167 case MassFluxSegmentsEnum : return "MassFluxSegments"; 168 case MassFluxSegmentsPresentEnum : return "MassFluxSegmentsPresent"; 169 case QmuMassFluxSegmentsPresentEnum : return "QmuMassFluxSegmentsPresent"; 152 170 case QmuNumberofpartitionsEnum : return "QmuNumberofpartitions"; 153 171 case QmuNumberofresponsesEnum : return "QmuNumberofresponses"; … … 184 202 case SurfaceforcingsMonthlytemperaturesEnum : return "SurfaceforcingsMonthlytemperatures"; 185 203 case SurfaceforcingsHcEnum : return "SurfaceforcingsHc"; 204 case SurfaceforcingsHrefEnum : return "SurfaceforcingsHref"; 205 case SurfaceforcingsSmbrefEnum : return "SurfaceforcingsSmbref"; 186 206 case SurfaceforcingsSmbPosMaxEnum : return "SurfaceforcingsSmbPosMax"; 187 207 case SurfaceforcingsSmbPosMinEnum : return "SurfaceforcingsSmbPosMin"; … … 270 290 case DofIndexingEnum : return "DofIndexing"; 271 291 case DoubleInputEnum : return "DoubleInput"; 292 case DataSetParamEnum : return "DataSetParam"; 272 293 case DoubleMatArrayParamEnum : return "DoubleMatArrayParam"; 273 294 case DoubleMatParamEnum : return "DoubleMatParam"; … … 299 320 case PentaEnum : return "Penta"; 300 321 case PentaP1InputEnum : return "PentaP1Input"; 322 case ProfilerEnum : return "Profiler"; 301 323 case MatrixParamEnum : return "MatrixParam"; 302 324 case VectorParamEnum : return "VectorParam"; … … 467 489 case OldGradientEnum : return "OldGradient"; 468 490 case OutputFilePointerEnum : return "OutputFilePointer"; 491 case OutputFileNameEnum : return "OutputFileName"; 492 case LockFileNameEnum : return "LockFileName"; 469 493 case PetscOptionsAnalysesEnum : return "PetscOptionsAnalyses"; 470 494 case PetscOptionsStringsEnum : return "PetscOptionsStrings"; -
issm/trunk/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp
r13395 r13975 295 295 return(iret); 296 296 } 297 -
issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp
r13395 r13975 27 27 gsize=nodes->NumberOfDofs(configuration_type,GsetEnum); 28 28 if (gsize==0) _error_("Allocating a Vec of size 0 as gsize=0 for configuration: " << EnumToStringx(configuration_type)); 29 29 30 30 /*Initialize solution: */ 31 31 solution=new Vector<IssmDouble>(gsize); 32 32 33 33 /*Go through elements and plug solution: */ 34 34 for (i=0;i<elements->Size();i++){ 35 element= (Element*)elements->GetObjectByOffset(i);35 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 36 36 element->GetSolutionFromInputs(solution); 37 37 } -
issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.h
r13395 r13975 13 13 14 14 #endif /* _GETSOLUTIONFROMINPUTSXX_H */ 15 -
issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp
r13395 r13975 37 37 38 38 void GetVectorFromControlInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, const char* data){ 39 39 40 40 /*output: */ 41 41 IssmDouble* vector=NULL; 42 42 43 43 /*intermediary: */ 44 44 Vector<IssmDouble>* vec_vector=NULL; -
issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h
r13395 r13975 13 13 14 14 #endif /* _GETVECTORFROMCONTROLINPUTSXX_H */ 15 -
issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp
r13395 r13975 21 21 /*Look up in elements*/ 22 22 for(i=0;i<elements->Size();i++){ 23 Element* element= (Element*)elements->GetObjectByOffset(i);23 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 24 24 element->GetVectorFromInputs(vector,name); 25 25 } … … 42 42 43 43 void GetVectorFromInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name, int type){ 44 44 45 45 /*output: */ 46 46 IssmDouble* vector=NULL; 47 47 48 48 /*intermediary: */ 49 49 Vector<IssmDouble>* vec_vector=NULL; -
issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h
r13395 r13975 13 13 14 14 #endif /* _GETVECTORFROMINPUTSXX_H */ 15 -
issm/trunk/src/c/modules/Gradjx/Gradjx.cpp
r13395 r13975 19 19 Vector<IssmDouble> *gradient = NULL; 20 20 Vector<IssmDouble> **gradient_list = NULL; 21 21 22 22 /*retrieve some parameters: */ 23 23 parameters->FindParam(&num_controls,InversionNumControlParametersEnum); _assert_(num_controls); -
issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
r13395 r13975 19 19 Vector<IssmDouble>* vec_old_floatingice = NULL; 20 20 Element* element = NULL; 21 21 22 22 if(VerboseModule()) _pprintLine_(" Migrating grounding line"); 23 23 24 24 /*retrieve parameters: */ 25 25 parameters->FindParam(&migration_style,GroundinglineMigrationEnum); … … 43 43 /*Migrate grounding line : */ 44 44 for(i=0;i<elements->Size();i++){ 45 element= (Element*)elements->GetObjectByOffset(i);45 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 46 46 element->MigrateGroundingLine(old_floatingice,vertices_ungrounding); 47 47 } … … 95 95 /*Fill vector vertices_potentially_floating: */ 96 96 for(i=0;i<elements->Size();i++){ 97 element= (Element*)elements->GetObjectByOffset(i);97 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 98 98 element->PotentialSheetUngrounding(vec_vertices_potentially_ungrounding); 99 99 } … … 121 121 Element* element = NULL; 122 122 123 124 123 /*recover parameters: */ 125 124 parameters->FindParam(&analysis_type,AnalysisTypeEnum); … … 132 131 nflipped=1; //bootstrap 133 132 while(nflipped){ 134 133 135 134 /*Vector of size number of elements*/ 136 135 vec_elements_neighboring_floatingice=new Vector<IssmDouble>(elements->NumberOfElements(),true); … … 138 137 /*Figure out if any of the nodes of the element will be floating -> elements neighbouting the floating ice*/ 139 138 for(i=0;i<elements->Size();i++){ 140 element= (Element*)elements->GetObjectByOffset(i);139 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 141 140 vec_elements_neighboring_floatingice->SetValue(element->Sid(),element->IsNodeOnShelfFromFlags(nodes_on_floatingice)?1.0:0.0,INS_VAL); 142 141 } … … 149 148 local_nflipped=0; 150 149 for(i=0;i<elements->Size();i++){ 151 element= (Element*)elements->GetObjectByOffset(i);150 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 152 151 if(reCast<int,IssmDouble>(elements_neighboring_floatingce[element->Sid()])){ 153 152 local_nflipped+=element->UpdatePotentialSheetUngrounding(vertices_potentially_ungrounding,vec_nodes_on_floatingice,nodes_on_floatingice); … … 155 154 } 156 155 vec_nodes_on_floatingice->Assemble(); 157 156 158 157 #ifdef _HAVE_MPI_ 159 MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);158 MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,IssmComm::GetComm()); 160 159 if(VerboseConvergence()) _pprintLine_(" Additional number of vertices allowed to unground: " << nflipped); 161 160 #else -
issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.cpp
r12706 r13975 10 10 11 11 int HoleFillerx(double** pimageout,double* image, int lines,int samps,int smooth){ 12 13 FILE *fp1; 14 unsigned long filesize; 12 15 13 long infinit; 16 14 double temp; 17 long i, j, k, l, ii, jj , bytes;15 long i, j, k, l, ii, jj; 18 16 long iii, jjj; 19 long test, prevlines, prevpix, test1, test2, thresh,counter; 20 long bell, cycles, leftovers; 21 float howlong; 17 long test; 22 18 float nsteps, ssteps, wsteps, esteps; 23 19 float nwsteps, nesteps, swsteps, sesteps; … … 29 25 float ssw, wsw, wnw, nnw; 30 26 float sum; 31 27 32 28 time_t t1, t2; 33 29 … … 39 35 double* image4=NULL; 40 36 41 /*Added to original routine: */42 int imageoutsize;43 44 37 /*^^^^^^^^^^^^^ Remove pixels close to the holes ^^^^^^^^^^^^^*/ 45 38 image2 = xNew<double>(lines*samps); 46 39 memcpy(image2,image,lines*samps*sizeof(double)); 47 40 48 41 for ( i = 0; i < lines; i++ ){ 49 42 for ( j = 0; j < samps; j++ ){ … … 84 77 85 78 again2: 86 79 87 80 #ifdef _DEBUG2_ 88 81 counter=0; … … 99 92 fflush( stdout ); 100 93 #endif 101 94 102 95 afterfirst2: 103 96 … … 128 121 129 122 /* For void edge pixels: */ 130 123 131 124 nsteps = 0.0; ssteps = 0.0; esteps = 0.0; wsteps = 0.0; 132 125 nwsteps = 0.0; nesteps = 0.0; swsteps = 0.0; sesteps = 0.0; … … 139 132 ssw = 0.0; wsw = 0.0; wnw = 0.0; nnw = 0.0; 140 133 141 142 134 /** NSEW **/ 143 135 for ( ii = i - 1; ii >= 0; ii-- ){ /* North */ … … 150 142 if ( *(image2+ii*samps+j) != 0 ){ south = *(image2+ii*samps+j); ssteps = ii - i; break;} 151 143 } 152 144 153 145 for ( jj = j - 1; jj >= 0; jj-- ){ /* West */ 154 146 if ( jj <= 0 ) { west = 0; wsteps = 0; break;} 155 147 if ( *(image2+i*samps+jj) != 0 ){ west = *(image2+i*samps+jj); wsteps = j - jj; break;} 156 148 } 157 149 158 150 for ( jj = j + 1; jj < samps; jj++ ){ /* East */ 159 151 if ( jj >= samps-1 ){ east = 0; esteps = 0; break;} … … 161 153 } 162 154 163 164 155 /** Diagonals **/ 165 156 /* Southeast */ … … 169 160 if ( *(image2+ii*samps+jj) != 0 ){ se = *(image2+ii*samps+jj); sesteps = 1.4142 * k; break;} 170 161 } 171 162 172 163 /* Northeast */ 173 164 for ( k = 1; k < infinit; k++ ){ … … 176 167 if ( *(image2+ii*samps+jj) != 0 ){ ne = *(image2+ii*samps+jj); nesteps = 1.4142 * k; break;} 177 168 } 178 169 179 170 /* Northwest */ 180 171 for ( k = 1; k < infinit; k++ ){ … … 183 174 if ( *(image2+ii*samps+jj) != 0 ){ nw = *(image2+ii*samps+jj); nwsteps = 1.4142 * k; break;} 184 175 } 185 176 186 177 /* Southwest */ 187 178 for ( k = 1; k < infinit; k++ ){ … … 198 189 if ( *(image2+ii*samps+jj) != 0 ){ nne = *(image2+ii*samps+jj); nnesteps = 2.2361 * k; break;} 199 190 } 200 191 201 192 /* ENE */ 202 193 for ( k = 1; k < infinit; k++ ){ … … 205 196 if ( *(image2+ii*samps+jj) != 0 ){ ene = *(image2+ii*samps+jj); enesteps = 2.2361 * k; break;} 206 197 } 207 198 208 199 /* ESE */ 209 200 for ( k = 1; k < infinit; k++ ){ … … 212 203 if ( *(image2+ii*samps+jj) != 0 ){ ese = *(image2+ii*samps+jj); esesteps = 2.2361 * k; break;} 213 204 } 214 205 215 206 /* SSE */ 216 207 for ( k = 1; k < infinit; k++ ){ … … 226 217 if ( *(image2+ii*samps+jj) != 0 ){ ssw = *(image2+ii*samps+jj); sswsteps = 2.2361 * k; break;} 227 218 } 228 219 229 220 /* WSW */ 230 221 for ( k = 1; k < infinit; k++ ){ … … 233 224 if ( *(image2+ii*samps+jj) != 0 ){ wsw = *(image2+ii*samps+jj); wswsteps = 2.2361 * k; break;} 234 225 } 235 226 236 227 /* WNW */ 237 228 for ( k = 1; k < infinit; k++ ){ … … 240 231 if ( *(image2+ii*samps+jj) != 0 ){ wnw = *(image2+ii*samps+jj); wnwsteps = 2.2361 * k; break;} 241 232 } 242 233 243 234 /* NNW */ 244 235 for ( k = 1; k < infinit; k++ ){ … … 247 238 if ( *(image2+ii*samps+jj) != 0 ){ nnw = *(image2+ii*samps+jj); nnwsteps = 2.2361 * k; break;} 248 239 } 249 240 250 241 elev = 0; range = 0; 251 242 /*NSEW*/ … … 259 250 if ( swsteps > 0.5 ){ elev += sw / swsteps; range += 1.00 / swsteps;} 260 251 if ( sesteps > 0.5 ){ elev += se / sesteps; range += 1.00 / sesteps;} 261 252 262 253 /*Other 8*/ 263 254 if ( nnesteps > 0.5 ){ elev += nne / nnesteps; range += 1.00 / nnesteps;} … … 269 260 if ( wnwsteps > 0.5 ){ elev += wnw / wnwsteps; range += 1.00 / wnwsteps;} 270 261 if ( nnwsteps > 0.5 ){ elev += nnw / nnwsteps; range += 1.00 / nnwsteps;} 271 262 272 263 //temp = ( elev / range ) + 0.5 ; 273 264 temp = ( elev / range ); … … 275 266 //if ( temp > 10000 ) temp = 10000; 276 267 //if ( temp < 0 ) temp = 0; 277 268 278 269 #ifdef _DEBUG2_ 279 270 //_printLine_(temp << " " << elev << " " << range << " "); … … 284 275 } 285 276 286 287 288 277 for ( i = 0; i < lines; i++ ){ 289 278 for ( j = 0; j < samps; j++ ){ … … 292 281 } 293 282 294 295 283 for ( i = 0; i < lines; i++ ){ 296 284 for ( j = 0; j < samps; j++ ){ … … 298 286 } 299 287 } 300 288 301 289 if ( smooth == 0 ) goto there2; 302 303 290 304 291 /************************ SMOOTH THE RESULT ***********************/ 305 292 306 293 image4 = xNew<double>(lines*samps); 307 294 memcpy(image4,image3,lines*samps*sizeof(double)); 308 309 295 310 296 for ( i = 0; i < lines; i++ ) { 311 297 for ( j = 0; j < samps; j++ ) { 312 298 if ( *(image4+i*samps+j) != 0 ) { *(image3+i*samps+j) = *(image2+i*samps+j) ; continue; } 313 314 299 315 300 for ( k = 1; k < infinit; k++ ) { /* Find the smallest box size with data */ … … 324 309 } 325 310 } 326 311 327 312 k_nowset: 328 313 k = k / 4; if ( k < 1 ) k = 1; /* Errrrr. Make it fourth size */ … … 343 328 } 344 329 345 346 330 there2: 347 348 331 349 332 /*Allocate output image: */ … … 352 335 353 336 time(&t2); 354 337 355 338 #ifdef _DEBUG2_ 356 339 _printString_( "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" ); … … 358 341 printf ( "\n"); 359 342 #endif 360 343 361 344 end: 362 345 -
issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.h
r3110 r13975 2 2 HoleFillerx.h 3 3 */ 4 5 4 6 5 #ifndef HOLEFILLERX_H … … 12 11 /* local prototypes: */ 13 12 int HoleFillerx(double** pimageout,double* imagein, int lines,int samp,int smooth); 14 13 15 14 #endif /* HOLEFILLERX_H */ 16 -
issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.cpp
r12706 r13975 15 15 /*Update elements, nodes, loads and materials from inputs: */ 16 16 for(i=0;i<elements->Size();i++){ 17 Element* element= (Element*)elements->GetObjectByOffset(i);17 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 18 18 element->InputArtificialNoise(enum_name,min,max); 19 19 } -
issm/trunk/src/c/modules/InputControlUpdatex/InputControlUpdatex.cpp
r13395 r13975 13 13 /*Go through elemnets, and ask to carry out the operation on inputs: */ 14 14 for(int i=0;i<elements->Size();i++){ 15 Element* element= (Element*)elements->GetObjectByOffset(i);15 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 16 16 element->InputControlUpdate(scalar,save_parameter); 17 17 } -
issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.cpp
r12706 r13975 24 24 /*Go through elements, and ask them to do the job: */ 25 25 for(i=0;i<elements->Size();i++){ 26 element= (Element*)elements->GetObjectByOffset(i);26 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 27 27 converged=element->InputConvergence(eps,enums,num_enums,criterionenums,criterionvalues,num_criterionenums); 28 28 if(!converged) num_notconverged++; … … 31 31 /*In parallel, we need to gather the converged status: */ 32 32 #ifdef _HAVE_MPI_ 33 MPI_Allreduce ( (void*)&num_notconverged,(void*)&total_notconverged,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);33 MPI_Allreduce ( (void*)&num_notconverged,(void*)&total_notconverged,1,MPI_INT,MPI_SUM,IssmComm::GetComm()); 34 34 num_notconverged=total_notconverged; 35 35 #endif -
issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.h
r12706 r13975 11 11 12 12 #endif /* _INPUTCONVERGENCEX_H */ 13 -
issm/trunk/src/c/modules/InputDuplicatex/InputDuplicatex.cpp
r4967 r13975 10 10 11 11 void InputDuplicatex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int original_enum, int new_enum){ 12 12 13 13 /*Go through elemnets, and ask to reinitialie the input: */ 14 14 int i; 15 15 for(i=0;i<elements->Size();i++){ 16 Element* element= (Element*)elements->GetObjectByOffset(i);16 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 17 17 element->InputDuplicate(original_enum,new_enum); 18 18 } -
issm/trunk/src/c/modules/InputDuplicatex/InputDuplicatex.h
r4236 r13975 12 12 13 13 #endif /* _INPUTDUPLICATEX_H */ 14 -
issm/trunk/src/c/modules/InputScalex/InputScalex.cpp
r12706 r13975 16 16 /*Go through elemnets, and ask to reinitialie the input: */ 17 17 for(i=0;i<elements->Size();i++){ 18 Element* element= (Element*)elements->GetObjectByOffset(i);18 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 19 19 element->InputScale(enum_type,scale_factor); 20 20 } -
issm/trunk/src/c/modules/InputScalex/InputScalex.h
r12706 r13975 12 12 13 13 #endif /* _SCALEINPUTX_H */ 14 -
issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp
r12706 r13975 23 23 for(int i=0;i<elements->Size();i++){ 24 24 25 element= (Element*)elements->GetObjectByOffset(i);25 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 26 26 element->InputToResult(enum_type,step,time); 27 27 } -
issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp
r12706 r13975 15 15 /*Elements and loads drive the update: */ 16 16 for(i=0;i<elements->Size();i++){ 17 Element* element= (Element*)elements->GetObjectByOffset(i);17 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 18 18 element->InputUpdateFromConstant(constant,name); 19 19 } … … 23 23 load->InputUpdateFromConstant(constant,name); 24 24 } 25 25 26 26 for(i=0;i<materials->Size();i++){ 27 27 Material* material=(Material*)materials->GetObjectByOffset(i); … … 30 30 } 31 31 void InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,int constant, int name){ 32 32 33 33 int i; 34 34 35 35 /*Elements and loads drive the update: */ 36 36 for(i=0;i<elements->Size();i++){ 37 Element* element= (Element*)elements->GetObjectByOffset(i);37 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 38 38 element->InputUpdateFromConstant(constant,name); 39 39 } … … 43 43 load->InputUpdateFromConstant(constant,name); 44 44 } 45 45 46 46 for(i=0;i<materials->Size();i++){ 47 47 Material* material=(Material*)materials->GetObjectByOffset(i); … … 55 55 /*Elements and loads drive the update: */ 56 56 for(i=0;i<elements->Size();i++){ 57 Element* element= (Element*)elements->GetObjectByOffset(i);57 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 58 58 element->InputUpdateFromConstant(constant,name); 59 59 } … … 63 63 load->InputUpdateFromConstant(constant,name); 64 64 } 65 65 66 66 for(i=0;i<materials->Size();i++){ 67 67 Material* material=(Material*)materials->GetObjectByOffset(i); -
issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.h
r13395 r13975 15 15 16 16 #endif /* _UPDATEINPUTSFROMCONSTANTXX_H */ 17 -
issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp
r13395 r13975 14 14 int i,j,k,l; 15 15 int dummy; 16 16 17 17 int numberofvertices; 18 18 int nrows; … … 35 35 36 36 for(i=0;i<numvariables;i++){ 37 37 38 38 descriptor=variables_descriptors[i]; 39 39 40 40 /*From descriptor, figure out if the variable is scaled, indexed, nodal, or just a simple variable: */ 41 41 if (strncmp(descriptor,"scaled_",7)==0){ 42 42 43 43 /*Variable is scaled. Determine root name of variable (ex: scaled_DragCoefficient_1 -> DragCoefficient). Allocate distributed_values and fill the 44 44 * distributed_values with the next npart variables: */ 45 45 46 46 //strcpy(root,strstr(descriptor,"_")+1); *strstr(root,"_")='\0'; 47 47 memcpy(root,strstr(descriptor,"_")+1,(strlen(strstr(descriptor,"_")+1)+1)*sizeof(char)); 48 48 *strstr(root,"_")='\0'; 49 50 49 51 50 distributed_values=xNew<double>(npart); … … 68 67 69 68 #ifdef _DEBUG_ 70 PetscSynchronizedPrintf( MPI_COMM_WORLD,"Parameter matrix:");71 PetscSynchronizedFlush( MPI_COMM_WORLD);69 PetscSynchronizedPrintf(IssmComm::GetComm(),"Parameter matrix:"); 70 PetscSynchronizedFlush(IssmComm::GetComm()); 72 71 for(l=0;l<ncols;l++){ 73 PetscSynchronizedPrintf( MPI_COMM_WORLD," time %i\n",l);74 PetscSynchronizedFlush( MPI_COMM_WORLD);72 PetscSynchronizedPrintf(IssmComm::GetComm()," time %i\n",l); 73 PetscSynchronizedFlush(IssmComm::GetComm()); 75 74 76 75 for(k=0;k<numberofvertices;k++){ 77 PetscSynchronizedPrintf( MPI_COMM_WORLD," node %i value %g\n",k+1,*(parameter+k*ncols+l));78 PetscSynchronizedFlush( MPI_COMM_WORLD);76 PetscSynchronizedPrintf(IssmComm::GetComm()," node %i value %g\n",k+1,*(parameter+k*ncols+l)); 77 PetscSynchronizedFlush(IssmComm::GetComm()); 79 78 } 80 79 } 81 PetscSynchronizedPrintf( MPI_COMM_WORLD," descriptor: %s root %s enum: %i\n",descriptor,root,StringToEnumx(root));82 PetscSynchronizedFlush( MPI_COMM_WORLD);80 PetscSynchronizedPrintf(IssmComm::GetComm()," descriptor: %s root %s enum: %i\n",descriptor,root,StringToEnumx(root)); 81 PetscSynchronizedFlush(IssmComm::GetComm()); 83 82 #endif 84 85 83 86 84 /*Update inputs using the parameter matrix: */ -
issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h
r13395 r13975 12 12 13 13 #endif /* _INPUTUPDATEFROMDAKOTAXX_H */ 14 -
issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.cpp
r10576 r13975 22 22 /*Update elements, nodes, loads and materials from inputs: */ 23 23 for(i=0;i<elements->Size();i++){ 24 Element* element= (Element*)elements->GetObjectByOffset(i);24 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 25 25 element->InputUpdateFromMatrixDakota(matrix,nrows,ncols,name,type); 26 26 } -
issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.h
r13395 r13975 13 13 14 14 #endif /* _UPDATEINPUTSFROMMATRIXDAKOTAXX_H */ 15 -
issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp
r13395 r13975 23 23 } 24 24 25 26 25 void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* solution){ 27 26 … … 32 31 /*Elements drive the update: */ 33 32 for (i=0;i<elements->Size();i++){ 34 element= (Element*)elements->GetObjectByOffset(i);33 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 35 34 element->InputUpdateFromSolution(solution); 36 35 } -
issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h
r13395 r13975 18 18 19 19 #endif /* _UPDATEINPUTSFROMSOLUTIONXX_H */ 20 -
issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp
r13395 r13975 21 21 } 22 22 23 24 23 void InputUpdateFromVectorDakotax( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* vector, int name, int type){ 25 24 … … 28 27 /*Update elements, nodes, loads and materials from inputs: */ 29 28 for(i=0;i<elements->Size();i++){ 30 Element* element= (Element*)elements->GetObjectByOffset(i);29 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 31 30 element->InputUpdateFromVectorDakota(vector,name,type); 32 31 } … … 46 45 47 46 void InputUpdateFromVectorDakotax( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,int* vector, int name, int type){ 48 47 49 48 int i; 50 49 51 50 /*Update elements, nodes, loads and materials from inputs: */ 52 51 for(i=0;i<elements->Size();i++){ 53 Element* element= (Element*)elements->GetObjectByOffset(i);52 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 54 53 element->InputUpdateFromVectorDakota(vector,name,type); 55 54 } … … 74 73 /*Update elements, nodes, loads and materials from inputs: */ 75 74 for(i=0;i<elements->Size();i++){ 76 Element* element= (Element*)elements->GetObjectByOffset(i);75 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 77 76 element->InputUpdateFromVectorDakota(vector,name,type); 78 77 } -
issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h
r13395 r13975 16 16 17 17 #endif /* _UPDATEINPUTSFROMVECTORDAKOTAXX_H */ 18 -
issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp
r13395 r13975 21 21 } 22 22 23 24 23 void InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* vector, int name, int type){ 25 24 … … 28 27 /*Update elements, nodes, loads and materials from inputs: */ 29 28 for(i=0;i<elements->Size();i++){ 30 Element* element= (Element*)elements->GetObjectByOffset(i);29 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 31 30 element->InputUpdateFromVector(vector,name,type); 32 31 } … … 46 45 47 46 void InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,int* vector, int name, int type){ 48 47 49 48 int i; 50 49 51 50 /*Update elements, nodes, loads and materials from inputs: */ 52 51 for(i=0;i<elements->Size();i++){ 53 Element* element= (Element*)elements->GetObjectByOffset(i);52 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 54 53 element->InputUpdateFromVector(vector,name,type); 55 54 } … … 74 73 /*Update elements, nodes, loads and materials from inputs: */ 75 74 for(i=0;i<elements->Size();i++){ 76 Element* element= (Element*)elements->GetObjectByOffset(i);75 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 77 76 element->InputUpdateFromVector(vector,name,type); 78 77 } -
issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h
r13395 r13975 16 16 17 17 #endif /* _UPDATEINPUTSFROMVECTORXX_H */ 18 -
issm/trunk/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp
r13395 r13975 21 21 /*output: */ 22 22 SeqVec<IssmPDouble>* data_mesh=NULL; 23 23 24 24 /*Intermediary*/ 25 25 double* x=NULL; 26 26 double* y=NULL; 27 double x_grid,y_grid;28 27 int i; 29 28 … … 312 311 _assert_(x2>x1 && y2>y1); 313 312 _assert_(x<=x2 && x>=x1 && y<=y2 && y>=y1); 314 313 315 314 double xm=(x2-x1)/2; 316 315 double ym=(y2-y1)/2; -
issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp
r13395 r13975 14 14 double* x_prime, double* y_prime, int nods_prime, 15 15 double* default_values,int num_default_values,Contour<IssmPDouble>** contours,int numcontours){ 16 16 17 17 /*Output*/ 18 18 SeqVec<IssmPDouble>* data_prime=NULL; 19 19 20 20 /*Intermediary*/ 21 int i ,j;21 int i; 22 22 int interpolation_type; 23 23 bool debug; 24 double area;25 double area_1,area_2,area_3;26 double data_value;27 24 double xmin,xmax; 28 25 double ymin,ymax; -
issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.h
r13395 r13975 29 29 double *incontour; 30 30 31 32 31 } InterpFromMesh2dxThreadStruct; 33 32 -
issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp
r13395 r13975 18 18 int my_thread = handle->id; 19 19 int num_threads = handle->num; 20 20 21 21 /*recover parameters :*/ 22 22 int interpolation_type = gate->interpolation_type; -
issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp
r13395 r13975 69 69 } 70 70 } 71 71 72 72 /*Get extreme coordinates of the grid*/ 73 73 if (xflip){ -
issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
r13395 r13975 15 15 int InterpFromMeshToMesh2dx(double** pdata_interp,int* index_data,double* x_data,double* y_data,int nods_data,int nels_data, 16 16 double* data,int M_data,int N_data,double* x_interp,double* y_interp,int N_interp,Options* options){ 17 17 18 18 /*Output*/ 19 19 double* data_interp=NULL; … … 25 25 R2 r; 26 26 I2 I; 27 int i,j ,k;27 int i,j; 28 28 int it; 29 29 int i0,i1,i2; 30 30 double areacoord[3]; 31 31 double aa,bb; 32 double data_value;33 32 Icoor2 dete[3]; 34 33 -
issm/trunk/src/c/modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp
r13395 r13975 11 11 12 12 void IoModelToConstraintsx(Constraints* constraints,IoModel* iomodel,int vector_enum,int analysis_type){ 13 14 13 15 14 /*intermediary: */ 16 15 int i,j; 17 bool transient = false; 18 19 FILE *fid = NULL; 20 int code = 0; 21 int vector_layout = 0; 22 int counter; 23 int nods; 24 IssmDouble* times=NULL; 25 IssmDouble* values=NULL; 26 bool spcpresent=false; 27 int count=0; 28 int numberofvertices; 16 bool transient = false; 17 FILE *fid = NULL; 18 int code = 0; 19 int vector_layout = 0; 20 IssmDouble *times = NULL; 21 IssmDouble *values = NULL; 22 bool spcpresent = false; 23 int count = 0; 24 int numberofvertices; 29 25 30 26 /*variables being fetched: */ … … 48 44 /*static: just create Constraints objects*/ 49 45 count=0; 50 46 51 47 /*Create Constraints from x,y,z: */ 52 48 for (i=0;i<numberofvertices;i++){ 53 49 54 50 /*keep only this partition's nodes:*/ 55 51 if((iomodel->my_vertices[i])){ … … 78 74 /*Create constraints from x,y,z: */ 79 75 for (i=0;i<numberofvertices;i++){ 80 76 81 77 /*keep only this partition's nodes:*/ 82 78 if((iomodel->my_vertices[i])){ -
issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.cpp
r12706 r13975 65 65 return(kfil); 66 66 } 67 -
issm/trunk/src/c/modules/KMLOverlayx/KMLOverlayx.cpp
r12706 r13975 79 79 kdoc=NULL; 80 80 81 82 81 /* write kml file */ 83 82 … … 95 94 return; 96 95 } 97 -
issm/trunk/src/c/modules/Kml2Expx/Kml2Expx.cpp
r13395 r13975 25 25 int sgn,double cm,double sp){ 26 26 27 int i ,iret=0;27 int iret=0; 28 28 double *lat=NULL,*lon=NULL; 29 29 … … 69 69 return(iret); 70 70 } 71 -
issm/trunk/src/c/modules/Krigingx/pKrigingx.cpp
r13395 r13975 14 14 int pKrigingx(double** ppredictions,double **perror,double* obs_x, double* obs_y, double* obs_list, int obs_length,double* x_interp,double* y_interp,int n_interp,Options* options){ 15 15 16 externint num_procs;17 externint my_rank;16 int num_procs; 17 int my_rank; 18 18 19 19 /*output*/ … … 27 27 Variogram *variogram = NULL; 28 28 Observations *observations = NULL; 29 30 /*Get my_rank: */ 31 my_rank=IssmComm::GetRank(); 32 num_procs=IssmComm::GetSize(); 29 33 30 34 /*Get some Options*/ … … 64 68 double *sumpredictions =xNew<double>(n_interp); 65 69 double *sumerror =xNew<double>(n_interp); 66 MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);67 MPI_Allreduce(error,sumerror,n_interp,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);70 MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm()); 71 MPI_Allreduce(error,sumerror,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm()); 68 72 xDelete<double>(error); error=sumerror; 69 73 xDelete<double>(predictions); predictions=sumpredictions; … … 81 85 #ifdef _HAVE_MPI_ 82 86 double *sumpredictions =xNew<double>(n_interp); 83 MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);87 MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm()); 84 88 xDelete<double>(predictions); predictions=sumpredictions; 85 89 #endif … … 98 102 #ifdef _HAVE_MPI_ 99 103 double *sumpredictions =xNew<double>(n_interp); 100 MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);104 MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm()); 101 105 xDelete<double>(predictions); predictions=sumpredictions; 102 106 #endif -
issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp
r13395 r13975 40 40 VecMergex(ug,uf,nodes,parameters,FsetEnum); 41 41 } 42 42 43 43 /*Merge s set back into g set: */ 44 44 if(ssize){ -
issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h
r13395 r13975 12 12 13 13 #endif /* _MERGESOLUTIONFROMFTOGX_H */ 14 -
issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.h
r13395 r13975 8 8 #include "../../include/include.h" 9 9 #include "../../EnumDefinitions/EnumDefinitions.h" 10 11 10 12 11 /* local prototypes: */ … … 89 88 /*Extrude epart2d to epart, using numlayers: */ 90 89 epart=xNew<int>(numberofelements); 91 90 92 91 count=0; 93 92 for(i=0;i<(numlayers-1);i++){ … … 100 99 /*Extrude npart2d to npart, using numlayers: */ 101 100 npart=xNew<int>(numberofnodes); 102 101 103 102 count=0; 104 103 for(i=0;i<(numlayers);i++){ … … 109 108 } 110 109 } 111 110 112 111 /*Assign output pointer:*/ 113 112 *pepart=epart; -
issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp
r13395 r13975 3 3 4 4 #include "./MeshProfileIntersectionx.h" 5 5 6 6 void ElementSegment(DataSet* segments_dataset,int el,double* xnodes,double* ynodes,double* xsegment,double* ysegment){ 7 7 … … 9 9 * If they do, create a Segment object with the intersection, and add to segments_dataset dataset: */ 10 10 11 int i;12 double alpha;13 11 double alpha1,alpha2; 14 12 double beta1,beta2; 15 13 double gamma1,gamma2; 16 14 17 15 int edge1,edge2,edge3; 18 16 … … 21 19 double xfinal[2],yfinal[2]; 22 20 23 24 21 /*edge 1: */ 25 22 xel[0]=xnodes[0]; yel[0]=ynodes[0]; xel[1]=xnodes[1]; yel[1]=ynodes[1]; … … 41 38 } 42 39 else if( ((edge1==IntersectEnum) && (edge2==IntersectEnum)) || ((edge2==IntersectEnum) && (edge3==IntersectEnum)) || ((edge3==IntersectEnum) && (edge1==IntersectEnum)) ){ 43 40 44 41 /*segment interscts 2 opposite edges of our triangle, at 2 segment coordinates, pick up the lowest (coord1) and highest (coord2): */ 45 42 if((edge1==IntersectEnum) && (edge2==IntersectEnum)) {coord1=min(alpha1,beta1); coord2=max(alpha1,beta1);} … … 77 74 coord2=1.0; 78 75 } 79 76 80 77 xfinal[0]=xsegment[0]+coord1*(xsegment[1]-xsegment[0]); 81 78 xfinal[1]=xsegment[0]+coord2*(xsegment[1]-xsegment[0]); -
issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegmentsIntersection.cpp
r8303 r13975 3 3 4 4 #include "./MeshProfileIntersectionx.h" 5 5 6 6 void ElementSegmentsIntersection(DataSet* segments_dataset,int el, double* xnodes,double* ynodes,double* xc,double* yc,int numnodes){ 7 7 -
issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp
r13395 r13975 7 7 8 8 int i,j,k; 9 int m,n;10 9 11 10 /*Contour:*/ … … 32 31 /*Loop through all contours: */ 33 32 for (i=0;i<numcontours;i++){ 34 33 35 34 /*retrieve contour info: */ 36 35 contouri=*(contours+i); … … 41 40 /*determine segmentsi and numsegsi for this contour and the mesh intersection: */ 42 41 MeshSegmentsIntersection(&segmentsi,&numsegsi,index,x,y,nel,nods,xc,yc,numnodes); 43 42 44 43 /*save segmentsi: */ 45 44 allsegments[i]=segmentsi; -
issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.h
r13395 r13975 2 2 MeshProfileIntersectionx.h 3 3 */ 4 5 4 6 5 #ifndef _MESHPROFILEINTERSECTIONX_H … … 19 18 20 19 #endif /* _MESHPROFILEINTERSECTIONX_H */ 21 -
issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp
r13395 r13975 12 12 Segment<double>* segment=NULL; 13 13 int numsegs; 14 14 15 15 /*intermediary: */ 16 16 DataSet* segments_dataset=NULL; … … 35 35 for(i=0;i<numsegs;i++){ 36 36 Segment<double>* segment=(Segment<double>*)segments_dataset->GetObjectByOffset(i); 37 37 38 38 /*x1,y1,x2,y2 then element_id: */ 39 39 *(segments+5*i+0)=segment->x1; -
issm/trunk/src/c/modules/MeshProfileIntersectionx/NodeInElement.cpp
r8303 r13975 19 19 y3=ynodes[2]; 20 20 21 22 21 /*compute determinant: */ 23 22 det=x1*y2-x1*y3-x3*y2-x2*y1+x2*y3+x3*y1; 24 23 25 24 /*area coordinates: */ 26 25 lambda1=((y2-y3)*(x-x3)+(x3-x2)*(y-y3))/det; -
issm/trunk/src/c/modules/MeshProfileIntersectionx/SegmentIntersect.cpp
r12330 r13975 11 11 double alpha=-1; 12 12 double beta=-1; 13 13 14 14 double xA,xB,xC,xD,yA,yB,yC,yD; 15 15 double O2A[2],O2B[2],O1C[2],O1D[2]; … … 29 29 O1C[0]=xC -(xA/2+xB/2); O1C[1]=yC -(yA/2+yB/2); 30 30 O1D[0]=xD -(xA/2+xB/2); O1D[1]=yD -(yA/2+yB/2); 31 32 31 33 32 n1[0]=yA-yB; n1[1]=xB-xA; //normal vector to segA -
issm/trunk/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp
r13395 r13975 7 7 #include "../../../io/io.h" 8 8 #include "../../../EnumDefinitions/EnumDefinitions.h" 9 #include "../../../classes/ objects/objects.h"9 #include "../../../classes/classes.h" 10 10 #include "../../../shared/shared.h" 11 11 #include "../../../include/include.h" 12 #include "../../Solverx/Solverx.h" 12 13 #include "../ModelProcessorx.h" 13 14 14 15 void CreateParametersAutodiff(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type){ 15 16 int i ,j;16 17 int i; 17 18 Parameters *parameters = NULL; 18 19 bool autodiff_analysis; 19 int* dependents = NULL; 20 int num_dependents; 21 int* independents = NULL; 22 int num_independents; 23 int numberofvertices; 20 int num_dependent_objects; 21 int num_dep=0; 22 int* names=NULL; 23 int* types=NULL; 24 int dummy; 25 char* autodiff_driver=NULL; 26 int* indices=NULL; 27 int num_indices; 28 24 29 IssmDouble* xp=NULL; 25 30 IssmDouble* xp_backup=NULL; 31 int num_ind,local_num_ind; 32 DataSet* dependent_objects=NULL; 33 26 34 /*Get parameters: */ 27 35 parameters=*pparameters; … … 29 37 /*retrieve some parameters: */ 30 38 iomodel->Constant(&autodiff_analysis,AutodiffIsautodiffEnum); 31 39 32 40 if(autodiff_analysis){ 33 41 34 iomodel->Constant(&num_independents,AutodiffNumIndependentsEnum); 35 iomodel->Constant(&num_dependents,AutodiffNumDependentsEnum); 36 iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum); 42 #ifdef _HAVE_ADOLC_ 37 43 38 /*recover dependents: */ 39 parameters->AddObject(iomodel->CopyConstantObject(AutodiffNumDependentsEnum)); 40 if(num_dependents){ 41 iomodel->FetchData(&dependents,NULL,&num_dependents,AutodiffDependentsEnum); 42 parameters->AddObject(new IntVecParam(AutodiffDependentsEnum,dependents,num_dependents)); 44 /*Copy some parameters from IoModel to parameters dataset: */ 45 parameters->AddObject(iomodel->CopyConstantObject(AutodiffKeepEnum)); 46 47 /*retrieve driver: {{{*/ 48 iomodel->Constant(&autodiff_driver,AutodiffDriverEnum); 49 parameters->AddObject(iomodel->CopyConstantObject(AutodiffDriverEnum)); 50 51 if(strcmp(autodiff_driver,"fos_forward")==0){ 52 parameters->AddObject(iomodel->CopyConstantObject(AutodiffFosForwardIndexEnum)); 43 53 } 54 else if(strcmp(autodiff_driver,"fos_reverse")==0){ 55 parameters->AddObject(iomodel->CopyConstantObject(AutodiffFosReverseIndexEnum)); 56 } 57 else if(strcmp(autodiff_driver,"fov_forward")==0){ 58 /*Retrieve list of indices: */ 59 iomodel->FetchData(&indices,&num_indices,&dummy,AutodiffFovForwardIndicesEnum); 60 parameters->AddObject(new IntMatParam(AutodiffFovForwardIndicesEnum,indices,num_indices,1)); 61 xDelete<int>(indices); 62 } 63 /*}}}*/ 64 /*Deal with dependents first: {{{*/ 65 iomodel->Constant(&num_dependent_objects,AutodiffNumDependentObjectsEnum); 66 dependent_objects=new DataSet(); 67 num_dep=0; 44 68 45 /*recover independents: */ 46 parameters->AddObject(iomodel->CopyConstantObject(AutodiffNumIndependentsEnum)); 47 if(num_independents){ 48 iomodel->FetchData(&independents,NULL,&num_independents,AutodiffIndependentsEnum); 49 parameters->AddObject(new IntVecParam(AutodiffIndependentsEnum,independents,num_independents)); 69 if(num_dependent_objects){ 70 iomodel->FetchData(&names,&dummy,&dummy,AutodiffDependentObjectNamesEnum); 71 iomodel->FetchData(&types,&dummy,&dummy,AutodiffDependentObjectTypesEnum); 72 iomodel->FetchData(&indices,&dummy,&dummy,AutodiffDependentObjectIndicesEnum); 50 73 51 /*Build state vector, value at which we compute our gradients of dependent variables in adolc: the xp vector */ 52 xp=xNew<IssmDouble>(num_independents*numberofvertices); 53 for(i=0;i<num_independents;i++){ 54 IssmDouble* values=iomodel->data[independents[i]]; 55 for(j=0;j<numberofvertices;j++){ 56 xp[i*numberofvertices+j]=values[j]; 57 } 74 for(i=0;i<num_dependent_objects;i++){ 75 DependentObject* dep=new DependentObject(names[i],types[i],indices[i]); 76 dependent_objects->AddObject(dep); 77 num_dep+=dep->NumDependents(); 58 78 } 59 parameters->AddObject(new DoubleVecParam(AutodiffXpEnum,xp,num_independents*numberofvertices)); 79 80 /*Free ressources:*/ 81 xDelete<int>(names); 82 xDelete<int>(types); 60 83 } 84 parameters->AddObject(new DataSetParam(AutodiffDependentObjectsEnum,dependent_objects)); 85 parameters->AddObject(new IntParam(AutodiffNumDependentsEnum,num_dep)); 61 86 62 /*Assign output pointer: */ 63 *pparameters=parameters; 87 delete dependent_objects; 88 /*}}}*/ 89 /*Deal with independents: {{{*/ 90 91 /*Independents have already been recovered in iomodel->DeclareIndependents. Just do some more processing. 92 *In particular, figure out num_independents, and create the state vector xp, or size num_independents x 1 :*/ 93 num_ind=0; 94 for(i=0;i<iomodel->independent_objects->Size();i++){ 95 IndependentObject* ind=(IndependentObject*)iomodel->independent_objects->GetObjectByOffset(i); 96 num_ind+=ind->NumIndependents(); 97 } 98 if(num_ind){ 99 xp=xNew<IssmDouble>(num_ind); 100 xp_backup=xp; 101 for(i=0;i<iomodel->independent_objects->Size();i++){ 102 IndependentObject* ind=(IndependentObject*)iomodel->independent_objects->GetObjectByOffset(i); 103 ind->FillIndependents(iomodel->data,xp); 104 local_num_ind=ind->NumIndependents(); xp=xp+local_num_ind; 105 } 106 xp=xp_backup; parameters->AddObject(new DoubleVecParam(AutodiffXpEnum,xp,num_ind)); 107 } 108 parameters->AddObject(new IntParam(AutodiffNumIndependentsEnum,num_ind)); 109 110 /*Don't forget to copy iomodel->independent_objects to parameters: */ 111 parameters->AddObject(new DataSetParam(AutodiffIndependentObjectsEnum,iomodel->independent_objects)); 112 /*}}}*/ 113 114 #endif 64 115 } 116 117 #ifdef _HAVE_ADOLC_ 118 /*initialize a placeholder to store solver pointers: {{{*/ 119 GenericParam<Adolc_edf> *theAdolcEDF_p=new GenericParam<Adolc_edf>(AdolcParamEnum); 120 theAdolcEDF_p->GetParameterValue().myEDF_for_solverx_p=reg_ext_fct(EDF_for_solverx); 121 // to save some space: 122 // we know we won't use adolc inside of the solver: 123 theAdolcEDF_p->GetParameterValue().myEDF_for_solverx_p->nestedAdolc=false; 124 // the solution vector is just allocated and doesn't have a meaningfull prior value 125 theAdolcEDF_p->GetParameterValue().myEDF_for_solverx_p->dp_y_priorRequired=false; 126 // the solver wrapper makes sure the matrix and the right hand side don't change 127 theAdolcEDF_p->GetParameterValue().myEDF_for_solverx_p->dp_x_changes=false; 128 parameters->AddObject(theAdolcEDF_p); 129 /*}}}*/ 130 #endif 131 132 /*Assign output pointer: */ 133 *pparameters=parameters; 134 65 135 } -
issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateConstraintsBalancethickness.cpp
r13395 r13975 10 10 void CreateConstraintsBalancethickness(Constraints** pconstraints, IoModel* iomodel){ 11 11 12 /*Fetch parameters: */ 12 13 int stabilization; 13 14 /*Fetch parameters: */15 14 iomodel->Constant(&stabilization,BalancethicknessStabilizationEnum); 16 15 17 /*Output*/18 Constraints* constraints = NULL;19 20 16 /*Recover pointer: */ 21 constraints=*pconstraints;17 Constraints* constraints=*pconstraints; 22 18 23 19 /*Create constraints if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp
r13395 r13975 14 14 15 15 /*Intermediary*/ 16 int i;17 16 int element; 18 17 int stabilization; … … 23 22 iomodel->Constant(&numberofedges,MeshNumberofedgesEnum); 24 23 25 /*Output*/26 Loads* loads = NULL;27 28 24 /*Recover pointer: */ 29 loads=*ploads;25 Loads* loads=*ploads; 30 26 31 27 /*Create loads if they do not exist yet*/ 32 28 if(!loads) loads = new Loads(); 33 29 34 30 /*Loads only in DG*/ 35 31 if (stabilization==3){ … … 39 35 40 36 /*First load data:*/ 41 for (i =0;i<numberofedges;i++){37 for (int i=0;i<numberofedges;i++){ 42 38 43 39 /*Get left and right elements*/ -
issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp
r13395 r13975 26 26 int stabilization; 27 27 28 /*DataSets: */29 Nodes* nodes = NULL;30 31 28 /*Fetch parameters: */ 32 29 iomodel->Constant(&dim,MeshDimensionEnum); … … 36 33 37 34 /*Recover pointer: */ 38 nodes=*pnodes;35 Nodes* nodes=*pnodes; 39 36 40 37 /*Create nodes if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateConstraintsBedSlope.cpp
r13395 r13975 13 13 void CreateConstraintsBedSlope(Constraints** pconstraints, IoModel* iomodel){ 14 14 15 /*Output*/16 Constraints* constraints = NULL;17 18 15 /*Recover pointer: */ 19 constraints=*pconstraints;16 Constraints* constraints=*pconstraints; 20 17 21 18 /*Create constraints if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateLoadsBedSlope.cpp
r13395 r13975 13 13 void CreateLoadsBedSlope(Loads** ploads, IoModel* iomodel){ 14 14 15 /*DataSet*/16 Loads* loads = NULL;17 18 15 /*Recover pointer: */ 19 loads=*ploads;16 Loads* loads=*ploads; 20 17 21 18 /*Create loads if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateNodesBedSlope.cpp
r13395 r13975 18 18 int i; 19 19 bool continuous_galerkin=true; 20 int numberofvertices;21 22 /*DataSets: */23 Nodes* nodes = NULL;24 20 25 21 /*Fetch parameters: */ 22 int numberofvertices; 26 23 iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum); 27 24 28 25 /*Recover pointer: */ 29 nodes=*pnodes;26 Nodes* nodes=*pnodes; 30 27 31 28 /*Create nodes if they do not exist yet*/ 32 29 if(!nodes) nodes = new Nodes(); 33 30 34 31 /*Continuous Galerkin partition of nodes: */ 35 32 NodesPartitioning(&iomodel->my_nodes,iomodel->my_elements,iomodel->my_vertices,iomodel,continuous_galerkin); 36 33 37 34 /*First fetch data: */ 38 35 iomodel->FetchData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum); … … 40 37 for (i=0;i<numberofvertices;i++){ 41 38 if(iomodel->my_vertices[i]){ 42 39 43 40 /*Add node to nodes dataset: */ 44 41 nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,i+1,i,iomodel,BedSlopeAnalysisEnum)); … … 49 46 /*Clean fetched data: */ 50 47 iomodel->DeleteData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum); 51 48 52 49 /*Assign output pointer: */ 53 50 *pnodes=nodes; -
issm/trunk/src/c/modules/ModelProcessorx/BedSlope/UpdateElementsBedSlope.cpp
r13395 r13975 42 42 iomodel->FetchDataToInput(elements,MeshElementonsurfaceEnum); 43 43 } 44 44 45 45 /*Free data: */ 46 46 iomodel->DeleteData(1,MeshElementsEnum); -
issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
r13395 r13975 13 13 14 14 void CreateParametersControl(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type){ 15 16 int i; 15 17 16 Parameters *parameters = NULL; 18 17 bool control_analysis; … … 21 20 int num_cm_responses; 22 21 int *control_type = NULL; 23 IssmDouble 24 IssmDouble 25 IssmDouble 26 IssmDouble 22 IssmDouble *cm_responses = NULL; 23 IssmDouble *cm_jump = NULL; 24 IssmDouble *optscal = NULL; 25 IssmDouble *maxiter = NULL; 27 26 28 27 /*Get parameters: */ -
issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp
r13395 r13975 25 25 bool control_analysis; 26 26 27 28 27 /*Fetch parameters: */ 29 28 iomodel->Constant(&numberofelements,MeshNumberofelementsEnum); … … 65 64 } 66 65 } 67 66 68 67 /*Free data: */ 69 68 iomodel->DeleteData(1+4+6,MeshElementsEnum,InversionControlParametersEnum,InversionCostFunctionsCoefficientsEnum,InversionMinParametersEnum,InversionMaxParametersEnum,BalancethicknessThickeningRateEnum,VxEnum,VyEnum,FrictionCoefficientEnum,MaterialsRheologyBEnum,MaterialsRheologyZEnum); -
issm/trunk/src/c/modules/ModelProcessorx/CreateDataSets.cpp
r13395 r13975 15 15 #include "./ModelProcessorx.h" 16 16 17 18 17 void CreateDataSets(Elements** pelements,Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads,Parameters** pparameters,IoModel* iomodel,char* rootpath,const int solution_type,const int analysis_type,const int nummodels,int analysis_counter){ 19 18 … … 22 21 Materials *materials = NULL; 23 22 Parameters *parameters = NULL; 24 23 25 24 /*Create elements, vertices and materials, independent of analysis_type: */ 26 25 CreateElementsVerticesAndMaterials(pelements, pvertices, pmaterials, iomodel,nummodels); … … 40 39 UpdateElementsDiagnosticHoriz(elements,iomodel,analysis_counter,analysis_type); 41 40 break; 42 41 43 42 case DiagnosticVertAnalysisEnum: 44 43 CreateNodesDiagnosticVert(pnodes, iomodel); … … 47 46 UpdateElementsDiagnosticVert(elements,iomodel,analysis_counter,analysis_type); 48 47 break; 49 48 50 49 case DiagnosticHutterAnalysisEnum: 51 50 CreateNodesDiagnosticHutter(pnodes, iomodel); … … 55 54 break; 56 55 #endif 57 56 58 57 #ifdef _HAVE_HYDROLOGY_ 59 58 case HydrologyAnalysisEnum: … … 72 71 UpdateElementsThermal(elements,iomodel,analysis_counter,analysis_type); 73 72 break; 74 73 75 74 case EnthalpyAnalysisEnum: 76 75 CreateNodesEnthalpy(pnodes, iomodel); … … 79 78 UpdateElementsEnthalpy(elements,iomodel,analysis_counter,analysis_type); 80 79 break; 81 80 82 81 case MeltingAnalysisEnum: 83 82 CreateNodesMelting(pnodes, iomodel); … … 122 121 #endif 123 122 124 125 123 default: 126 124 _error_("analysis_type: " << EnumToStringx(analysis_type) << " not supported yet!"); -
issm/trunk/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp
r13395 r13975 16 16 17 17 /*Intermediary*/ 18 int i ,j,k,n;18 int i; 19 19 int dim,materials_type; 20 20 int numberofelements; … … 41 41 vertices = new Vertices(); 42 42 materials = new Materials(); 43 43 44 44 /*First, partition elements and vertices. Nodes will partitioned on a per analysis_type basis. If partitining already done, ignore: */ 45 45 ElementsAndVerticesPartitioning(&iomodel->my_elements,&iomodel->my_vertices,iomodel); 46 46 47 47 iomodel->FetchData(2,MeshElementsEnum,MeshElementconnectivityEnum); 48 48 #ifdef _HAVE_3D_ … … 50 50 #endif 51 51 if(control_analysis)iomodel->FetchData(3,InversionControlParametersEnum,InversionMinParametersEnum,InversionMaxParametersEnum); 52 52 53 53 /*Create elements*/ 54 54 for (i=0;i<numberofelements;i++){ … … 62 62 } 63 63 } 64 64 65 65 /*Create materials*/ 66 66 switch(materials_type){ … … 84 84 /*Add new constant material property to materials, at the end: */ 85 85 materials->AddObject(new Matpar(numberofelements+1,iomodel));//put it at the end of the materials 86 86 87 87 /*Create vertices: */ 88 88 … … 90 90 iomodel->FetchData(6,MeshElementsEnum,MeshXEnum,MeshYEnum,MeshZEnum,BedEnum,ThicknessEnum); 91 91 CreateNumberNodeToElementConnectivity(iomodel); 92 92 93 93 for (i=0;i<numberofvertices;i++){ 94 94 95 95 /*vertices and nodes (same number, as we are running continuous galerkin formulation): */ 96 96 if(iomodel->my_vertices[i]){ 97 97 98 98 /*Add vertex to vertices dataset: */ 99 99 vertices->AddObject(new Vertex(i+1,i,i,iomodel)); -
issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp
r13395 r13975 8 8 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 9 9 #endif 10 11 10 12 11 #include "../../Container/Container.h" … … 20 19 21 20 void CreateParameters(Parameters** pparameters,IoModel* iomodel,char* rootpath,const int solution_type,int analysis_type,int analysis_counter){ 22 23 int i ;21 22 int i,j,m,k; 24 23 int numoutputs; 25 24 Parameters *parameters = NULL; … … 27 26 bool isdelta18o; 28 27 28 /*parameters for mass flux: {{{*/ 29 int mass_flux_num_profiles=0; 30 bool qmu_mass_flux_present=false; 31 bool autodiff_mass_flux_present=false; 32 bool mass_flux_present=false; 33 IssmDouble** array=NULL; 34 int* mdims_array=NULL; 35 int* ndims_array=NULL; 36 IssmDouble* temp_matrix=NULL; 37 int temp_m,temp_n; 38 IssmDouble* matrix=NULL; 39 int count; 40 /*}}}*/ 41 29 42 if(*pparameters)return; //do not create parameters twice! 30 43 31 44 /*Initialize dataset: */ 32 45 parameters = new Parameters(); 33 46 34 47 /*Copy some constants from iomodel */ 35 48 parameters->AddObject(iomodel->CopyConstantObject(MeshDimensionEnum)); … … 127 140 if(numoutputs)parameters->AddObject(new IntVecParam(DiagnosticRequestedOutputsEnum,requestedoutputs,numoutputs)); 128 141 iomodel->DeleteData(requestedoutputs,DiagnosticRequestedOutputsEnum); 142 129 143 iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,TransientRequestedOutputsEnum); 130 144 parameters->AddObject(new IntParam(TransientNumRequestedOutputsEnum,numoutputs)); 131 145 if(numoutputs)parameters->AddObject(new IntVecParam(TransientRequestedOutputsEnum,requestedoutputs,numoutputs)); 132 146 iomodel->DeleteData(requestedoutputs,TransientRequestedOutputsEnum); 147 133 148 iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,SteadystateRequestedOutputsEnum); 134 149 parameters->AddObject(new IntParam(SteadystateNumRequestedOutputsEnum,numoutputs)); 135 150 if(numoutputs)parameters->AddObject(new IntVecParam(SteadystateRequestedOutputsEnum,requestedoutputs,numoutputs)); 136 151 iomodel->DeleteData(requestedoutputs,SteadystateRequestedOutputsEnum); 137 152 153 iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,PrognosticRequestedOutputsEnum); 154 parameters->AddObject(new IntParam(PrognosticNumRequestedOutputsEnum,numoutputs)); 155 if(numoutputs)parameters->AddObject(new IntVecParam(PrognosticRequestedOutputsEnum,requestedoutputs,numoutputs)); 156 iomodel->DeleteData(requestedoutputs,PrognosticRequestedOutputsEnum); 157 158 /*Deal with mass flux segments: {{{*/ 159 iomodel->FetchData(&qmu_mass_flux_present,QmuMassFluxSegmentsPresentEnum); 160 iomodel->FetchData(&autodiff_mass_flux_present,AutodiffMassFluxSegmentsPresentEnum); 161 162 if(qmu_mass_flux_present || autodiff_mass_flux_present)mass_flux_present=true; 163 else mass_flux_present=false; 164 parameters->AddObject(new BoolParam(MassFluxSegmentsPresentEnum,mass_flux_present)); 165 166 if(mass_flux_present){ 167 168 /*Fetch the mass flux segments necessary to compute the mass fluxes. Build a DoubleMatArrayParam object out of them: */ 169 iomodel->FetchData(&array,&mdims_array,&ndims_array,&mass_flux_num_profiles,MassFluxSegmentsEnum); 170 if(mass_flux_num_profiles==0)_error_("mass_flux_num_profiles is 0, when MassFlux computations were requested!"); 171 172 /*Go through segments, and extract those that belong to this cpu: */ 173 for(i=0;i<mass_flux_num_profiles;i++){ 174 temp_matrix=array[i]; 175 temp_m=mdims_array[i]; 176 temp_n=ndims_array[i]; 177 178 m=0; 179 for(j=0;j<temp_m;j++){ 180 if ( iomodel->my_elements[reCast<int>(*(temp_matrix+5*j+4))-1] )m++; 181 } 182 if(m){ 183 matrix=xNewZeroInit<IssmDouble>(5*m); 184 count=0; 185 for(j=0;j<temp_m;j++){ 186 if (iomodel->my_elements[reCast<int>(*(temp_matrix+5*j+4))-1]){ 187 for(k=0;k<5;k++)*(matrix+5*count+k)=*(temp_matrix+5*j+k); 188 count++; 189 } 190 } 191 } 192 else{ 193 matrix=NULL; 194 } 195 196 /*Assign: */ 197 array[i]=matrix; 198 mdims_array[i]=m; 199 ndims_array[i]=5; 200 201 /*Free temporary matrix: */ 202 xDelete<IssmDouble>(temp_matrix); 203 } 204 205 /*Ok, we have an array of segments, different on every cpu. Create a DoubleMatArrayParam object with it: */ 206 parameters->AddObject(new DoubleMatArrayParam(MassFluxSegmentsEnum,array,mass_flux_num_profiles,mdims_array,ndims_array)); 207 208 /*Free data: */ 209 for(i=0;i<mass_flux_num_profiles;i++){ 210 IssmDouble* matrix=array[i]; 211 xDelete<IssmDouble>(matrix); 212 } 213 xDelete<int>(mdims_array); 214 xDelete<int>(ndims_array); 215 xDelete<IssmDouble*>(array); 216 } 217 /*}}}*/ 218 138 219 /*Before returning, create parameters in case we are running Qmu or control types runs: */ 139 220 #ifdef _HAVE_CONTROL_ -
issm/trunk/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp
r13395 r13975 16 16 17 17 /*variable declarations: {{{*/ 18 int i,j,k; 19 18 int i; 20 19 Parameters* parameters = NULL; 21 int second_count; 22 20 23 21 int* part=NULL; 24 22 double* dpart=NULL; … … 35 33 char* qmuerrname=NULL; 36 34 char* qmuoutname=NULL; 37 35 38 36 //descriptors: 39 37 char tag[50]; 40 41 /*parameters for mass flux: */ 42 bool qmu_mass_flux_present=false; 43 int qmu_mass_flux_num_profiles=0; 44 double** array=NULL; 45 int* mdims_array=NULL; 46 int* ndims_array=NULL; 47 48 double* matrix=NULL; 49 double* temp_matrix=NULL; 50 int M; 51 int temp_m,temp_n; 52 int m,n; 53 int count; 38 54 39 bool dakota_analysis=false; 55 40 char* name=NULL; … … 60 45 61 46 /*}}}*/ 62 47 63 48 /*recover parameters : */ 64 49 parameters=*pparameters; … … 102 87 /*Deal with partitioning: {{{*/ 103 88 /*partition vertices in iomodel->qmu_npart parts, unless a partition is already present: */ 104 89 105 90 parameters->AddObject(iomodel->CopyConstantObject(QmuNumberofpartitionsEnum)); 106 91 iomodel->FetchData(&dpart,NULL,NULL,QmuPartitionEnum); … … 117 102 /*}}}*/ 118 103 /*Deal with data needed because of qmu variables: {{{*/ 119 104 120 105 for(i=0;i<numvariabledescriptors;i++){ 121 106 … … 123 108 /*Ok, we are dealing with a variable that is distributed over nodes. Recover the name of the variable (ex: scaled_Thickness): */ 124 109 sscanf(variabledescriptors[i],"scaled_%s",tag); 125 110 126 111 /*Recover data: */ 127 112 iomodel->FetchData(&dakota_parameter,&nrows,&ncols,StringToEnumx(tag)); … … 134 119 parameters->AddObject(new DoubleTransientMatParam(StringToEnumx(tag),dakota_parameter,nrows,ncols)); 135 120 } 136 121 137 122 /*Free ressources:*/ 138 123 xDelete<double>(dakota_parameter); 139 124 } 140 }141 /*}}}*/142 /*Deal with data needed to compute qmu responses: {{{*/143 for(i=0;i<numresponsedescriptors;i++){144 145 if(strncmp(responsedescriptors[i],"indexed_MassFlux",16)==0){146 qmu_mass_flux_present=true;147 }148 }149 150 151 if(qmu_mass_flux_present){152 153 /*Fetch the mass flux segments necessary to compute the mass fluxes. Build a DoubleMatArrayParam object out of them: */154 iomodel->FetchData(&array,&mdims_array,&ndims_array,&qmu_mass_flux_num_profiles,QmuMassFluxSegmentsEnum);155 if(qmu_mass_flux_num_profiles==0)_error_("qmu_mass_flux_num_profiles is 0, when MassFlux computations were requested!");156 157 /*Go through segments, and extract those that belong to this cpu: */158 for(i=0;i<qmu_mass_flux_num_profiles;i++){159 temp_matrix=array[i];160 temp_m=mdims_array[i];161 temp_n=ndims_array[i];162 163 m=0;164 for(j=0;j<temp_m;j++){165 if ( iomodel->my_elements[(int)(*(temp_matrix+5*j+4))-1])m++;166 }167 if(m){168 matrix=xNewZeroInit<double>(5*m);169 count=0;170 for(j=0;j<temp_m;j++){171 if (iomodel->my_elements[(int)*(temp_matrix+5*j+4)-1]){172 for(k=0;k<5;k++)*(matrix+5*count+k)=*(temp_matrix+5*j+k);173 count++;174 }175 }176 }177 else{178 matrix=NULL;179 }180 181 /*Assign: */182 array[i]=matrix;183 mdims_array[i]=m;184 ndims_array[i]=5;185 186 /*Free temporary matrix: */187 xDelete<double>(temp_matrix);188 }189 190 /*Ok, we have an array of segments, different on every cpu. Create a DoubleMatArrayParam object with it: */191 parameters->AddObject(new DoubleMatArrayParam(QmuMassFluxSegmentsEnum,array,qmu_mass_flux_num_profiles,mdims_array,ndims_array));192 193 /*Free data: */194 for(i=0;i<qmu_mass_flux_num_profiles;i++){195 double* matrix=array[i];196 xDelete<double>(matrix);197 }198 xDelete<int>(mdims_array);199 xDelete<int>(ndims_array);200 xDelete<double*>(array);201 125 } 202 126 /*}}}*/ -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp
r13395 r13975 44 44 Constraints *constraints = NULL; 45 45 SpcStatic *spcstatic = NULL; 46 int node1,node2;47 46 int dim; 48 47 int numberofvertices; … … 64 63 /*Create constraints if they do not exist yet*/ 65 64 if(!constraints) constraints = new Constraints(); 66 65 67 66 /*Now, is the flag macayaealpattyn on? otherwise, do nothing: */ 68 67 if(!ismacayealpattyn & !isstokes & !isl1l2){ … … 70 69 return; 71 70 } 72 71 73 72 /*Constraints: fetch data: */ 74 73 iomodel->FetchData(&spcvx,&Mx,&Nx,DiagnosticSpcvxEnum); … … 324 323 } 325 324 } 326 325 327 326 /*Free data: */ 328 327 iomodel->DeleteData(spcvx,DiagnosticSpcvxEnum); -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp
r13395 r13975 14 14 15 15 /*DataSets*/ 16 Loads *loads = NULL;17 16 Icefront *icefront = NULL; 18 Riftfront *riftfront = NULL;19 17 Pengrid *pengrid = NULL; 20 18 … … 48 46 49 47 /*Recover pointer: */ 50 loads=*ploads;48 Loads* loads=*ploads; 51 49 52 50 /*Create loads if they do not exist yet*/ … … 58 56 return; 59 57 } 60 58 61 59 /*Create pressure loads as boundary conditions. Pay attention to the partitioning if we are running in parallel (the nodes 62 60 * referenced by a certain load must belong to the cluster node): */ … … 70 68 /*First load data:*/ 71 69 for (i=0;i<numberofpressureloads;i++){ 72 70 73 71 /*Retrieve element to which this icefront belongs: */ 74 72 if (dim==2) segment_width=4; … … 78 76 /*Now, if this element is not in the partition, pass: */ 79 77 if(!iomodel->my_elements[element]) continue; 80 78 81 79 /*Do not create ice front if Hutter or Stokes elements*/ 82 80 if (reCast<int,IssmDouble>(*(elements_type+element))==HutterApproximationEnum) continue; … … 132 130 iomodel->DeleteData(pressureload,DiagnosticIcefrontEnum); 133 131 134 135 132 /*Create Penpair for penalties: */ 136 133 iomodel->FetchData(&penalties,&numpenalties,NULL,DiagnosticVertexPairingEnum); 137 134 138 135 for(i=0;i<numpenalties;i++){ 139 136 … … 167 164 } 168 165 iomodel->DeleteData(5,RiftsRiftstructEnum,ThicknessEnum,BedEnum,SurfaceEnum,MaskVertexonfloatingiceEnum); 169 xDelete< Riftfront>(riftfront);166 xDelete<IssmDouble>(riftinfo); 170 167 } 171 168 -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp
r13395 r13975 21 21 bool isstokes,isl1l2,ismacayealpattyn; 22 22 23 /*DataSets: */24 Nodes* nodes = NULL;25 26 23 /*Fetch parameters: */ 27 24 iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum); … … 31 28 32 29 /*Recover pointer: */ 33 nodes=*pnodes;30 Nodes* nodes=*pnodes; 34 31 35 32 /*First create nodes*/ 36 33 if(!nodes) nodes = new Nodes(); 37 34 38 35 /*Now, is the flag macayaealpattyn on? otherwise, do nothing: */ 39 36 if(!ismacayealpattyn & !isstokes & !isl1l2){ … … 48 45 iomodel->FetchData(9,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,FlowequationBordermacayealEnum,FlowequationBorderstokesEnum, 49 46 MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,MaskVertexonwaterEnum,FlowequationVertexEquationEnum,DiagnosticReferentialEnum); 50 47 51 48 for (i=0;i<numberofvertices;i++){ 52 49 53 50 if(iomodel->my_vertices[i]){ 54 51 55 52 /*Add node to nodes dataset: */ 56 53 nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,i+1,i,iomodel,DiagnosticHorizAnalysisEnum)); -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp
r13395 r13975 85 85 elements->InputDuplicate(VxEnum,InversionVxObsEnum); 86 86 if(dakota_analysis)elements->InputDuplicate(VxEnum,QmuVxEnum); 87 87 88 88 elements->InputDuplicate(VyEnum,VyPicardEnum); 89 89 elements->InputDuplicate(VyEnum,InversionVyObsEnum); 90 90 if(dakota_analysis)elements->InputDuplicate(VyEnum,QmuVyEnum); 91 91 92 92 if(dim==3){ 93 93 elements->InputDuplicate(VzEnum,VzPicardEnum); … … 95 95 if(dakota_analysis)elements->InputDuplicate(VzEnum,QmuVzEnum); 96 96 } 97 97 98 98 /*Free data: */ 99 99 iomodel->DeleteData(2,MeshElementsEnum,FlowequationElementEquationEnum); -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp
r13395 r13975 75 75 /*Free data: */ 76 76 iomodel->DeleteData(3,DiagnosticSpcvxEnum,DiagnosticSpcvyEnum,FlowequationVertexEquationEnum); 77 77 78 78 /*Assign output pointer: */ 79 79 *pconstraints=constraints; -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateLoadsDiagnosticHutter.cpp
r13395 r13975 13 13 void CreateLoadsDiagnosticHutter(Loads** ploads, IoModel* iomodel){ 14 14 15 /*DataSet*/16 Loads* loads=NULL;17 18 15 /*Recover pointer: */ 19 loads=*ploads;16 Loads* loads=*ploads; 20 17 21 18 /*Create loads if they do not exist yet*/ 22 19 if(!loads) loads = new Loads(); 23 20 24 21 /*Assign output pointer: */ 25 22 *ploads=loads; -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateNodesDiagnosticHutter.cpp
r13395 r13975 21 21 bool ishutter; 22 22 23 /*DataSets: */24 Nodes* nodes = NULL;25 26 23 /*Fetch parameters: */ 27 24 iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum); … … 29 26 30 27 /*Recover pointer: */ 31 nodes=*pnodes;28 Nodes* nodes=*pnodes; 32 29 33 30 /*Create nodes if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/UpdateElementsDiagnosticHutter.cpp
r13395 r13975 19 19 bool ishutter; 20 20 21 22 21 /*Fetch data needed: */ 23 22 iomodel->Constant(&numberofelements,MeshNumberofelementsEnum); … … 38 37 } 39 38 } 40 39 41 40 iomodel->FetchDataToInput(elements,ThicknessEnum); 42 41 iomodel->FetchDataToInput(elements,GeometryHydrostaticRatioEnum); 43 42 44 43 /*Free data: */ 45 44 iomodel->DeleteData(2,MeshElementsEnum,FlowequationElementEquationEnum); -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateConstraintsDiagnosticVert.cpp
r13395 r13975 20 20 int numberofvertices; 21 21 22 /*Output*/23 Constraints* constraints = NULL;24 25 22 /*Fetch parameters: */ 26 23 iomodel->Constant(&dim,MeshDimensionEnum); … … 29 26 30 27 /*Recover pointer: */ 31 constraints=*pconstraints;28 Constraints* constraints=*pconstraints; 32 29 33 30 /*Create constraints if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateLoadsDiagnosticVert.cpp
r13395 r13975 13 13 void CreateLoadsDiagnosticVert(Loads** ploads, IoModel* iomodel){ 14 14 15 /*DataSet*/16 Loads* loads=NULL;17 18 15 /*Recover pointer: */ 19 loads=*ploads;16 Loads* loads=*ploads; 20 17 21 18 /*Create loads if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateNodesDiagnosticVert.cpp
r13395 r13975 21 21 int numberofvertices; 22 22 23 /*DataSets: */24 Nodes* nodes = NULL;25 26 23 /*Fetch parameters: */ 27 24 iomodel->Constant(&dim,MeshDimensionEnum); … … 29 26 30 27 /*Recover pointer: */ 31 nodes=*pnodes;28 Nodes* nodes=*pnodes; 32 29 33 30 /*Create nodes if they do not exist yet*/ … … 42 39 /*Continuous Galerkin partition of nodes: */ 43 40 NodesPartitioning(&iomodel->my_nodes,iomodel->my_elements,iomodel->my_vertices,iomodel,continuous_galerkin); 44 41 45 42 /*First fetch data: */ 46 43 iomodel->FetchData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum); … … 57 54 /*Clean fetched data: */ 58 55 iomodel->DeleteData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum); 59 56 60 57 /*Assign output pointer: */ 61 58 *pnodes=nodes; -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/UpdateElementsDiagnosticVert.cpp
r13395 r13975 54 54 /*Free data: */ 55 55 iomodel->DeleteData(1,MeshElementsEnum); 56 56 57 57 } -
issm/trunk/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp
r13395 r13975 6 6 #include "../../include/include.h" 7 7 #include "../../EnumDefinitions/EnumDefinitions.h" 8 8 9 9 void DistributeNumDofs(DofIndexing* index,int analysis_type,IssmDouble* vertices_type){ 10 10 … … 13 13 14 14 int numdofs=2; //default numdofs 15 int i;16 15 int* doftype=NULL; 17 16 -
issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
r13395 r13975 22 22 int i; 23 23 24 externint my_rank;25 externint num_procs;24 int my_rank; 25 int num_procs; 26 26 int numberofelements; 27 27 int numberofvertices; … … 46 46 IssmDouble* riftinfo=NULL; 47 47 IssmDouble* vertex_pairing=NULL; 48 49 /*Get my_rank:*/ 50 my_rank=IssmComm::GetRank(); 51 num_procs=IssmComm::GetSize(); 48 52 49 53 /*Fetch parameters: */ … … 102 106 103 107 my_elements[i]=true; 104 108 105 109 /*Now that we are here, we can also start building the list of vertices belonging to this cpu partition: we use 106 110 *the element index to do this. For each element n, we know index[n][0:2] holds the indices (matlab indexing) … … 110 114 my_vertices[reCast<int>(*(elements+elements_width*i+1))-1]=1; 111 115 my_vertices[reCast<int>(*(elements+elements_width*i+2))-1]=1; 112 116 113 117 if(elements_width==6){ 114 118 my_vertices[reCast<int>(*(elements+elements_width*i+3))-1]=1; -
issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp
r13395 r13975 23 23 IssmDouble heatcapacity; 24 24 IssmDouble referencetemperature; 25 25 26 26 /*Output*/ 27 27 IssmDouble *spcvector = NULL; 28 28 IssmDouble* times=NULL; 29 29 IssmDouble* values=NULL; 30 Constraints* constraints = NULL;31 30 32 31 /*Fetch parameters: */ … … 37 36 38 37 /*Recover pointer: */ 39 constraints=*pconstraints;38 Constraints* constraints=*pconstraints; 40 39 41 40 /*Create constraints if they do not exist yet*/ … … 85 84 /*Create constraints from x,y,z: */ 86 85 for (i=0;i<numberofvertices;i++){ 87 86 88 87 /*keep only this partition's nodes:*/ 89 88 if((iomodel->my_vertices[i])){ -
issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateLoadsEnthalpy.cpp
r13395 r13975 13 13 void CreateLoadsEnthalpy(Loads** ploads, IoModel* iomodel){ 14 14 15 /*DataSet*/16 Loads* loads=NULL;17 18 15 /*Recover pointer: */ 19 loads=*ploads;16 Loads* loads=*ploads; 20 17 21 18 /*Create loads if they do not exist yet*/ 22 19 if(!loads) loads = new Loads(); 23 20 24 25 21 /*Assign output pointer: */ 26 22 *ploads=loads; -
issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateNodesEnthalpy.cpp
r13395 r13975 20 20 int numberofvertices; 21 21 22 /*DataSets: */23 Nodes* nodes = NULL;24 25 22 /*Fetch parameters: */ 26 23 iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum); 27 24 28 25 /*Recover pointer: */ 29 nodes=*pnodes;26 Nodes* nodes=*pnodes; 30 27 31 28 /*Create nodes if they do not exist yet*/ … … 40 37 for (i=0;i<numberofvertices;i++){ 41 38 if(iomodel->my_vertices[i]){ 42 39 43 40 /*Add node to nodes dataset: */ 44 41 nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,i+1,i,iomodel,EnthalpyAnalysisEnum)); … … 49 46 /*Clean fetched data: */ 50 47 iomodel->DeleteData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum); 51 48 52 49 /*Assign output pointer: */ 53 50 *pnodes=nodes; -
issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/UpdateElementsEnthalpy.cpp
r13395 r13975 59 59 iomodel->FetchDataToInput(elements,VyEnum); 60 60 iomodel->FetchDataToInput(elements,VzEnum); 61 61 62 62 /*Free data: */ 63 63 iomodel->DeleteData(4,MeshElementsEnum,TemperatureEnum,WaterfractionEnum,PressureEnum); -
issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateConstraintsHydrology.cpp
r13395 r13975 14 14 void CreateConstraintsHydrology(Constraints** pconstraints, IoModel* iomodel){ 15 15 16 /*Output*/17 Constraints *constraints = NULL;18 19 16 /*Recover pointer: */ 20 constraints=*pconstraints;17 Constraints* constraints=*pconstraints; 21 18 22 19 /*Create constraints if they do not exist yet*/ 23 20 if(!constraints) constraints = new Constraints(); 24 21 IoModelToConstraintsx(constraints,iomodel,HydrologySpcwatercolumnEnum,HydrologyAnalysisEnum); 25 22 26 23 /*Assign output pointer: */ 27 24 *pconstraints=constraints; -
issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateLoadsHydrology.cpp
r13395 r13975 13 13 void CreateLoadsHydrology(Loads** ploads, IoModel* iomodel){ 14 14 15 /*Intermediary*/16 int i;17 18 /*DataSet*/19 Loads* loads = NULL;20 21 15 /*Recover pointer: */ 22 loads=*ploads;16 Loads* loads=*ploads; 23 17 24 18 /*Create loads if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateNodesHydrology.cpp
r13395 r13975 20 20 int numberofvertices; 21 21 22 /*DataSets: */23 Nodes* nodes = NULL;24 25 22 /*Fetch parameters: */ 26 23 iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum); 27 24 28 25 /*Recover pointer: */ 29 nodes=*pnodes;26 Nodes* nodes=*pnodes; 30 27 31 28 /*Create nodes if they do not exist yet*/ … … 46 43 } 47 44 iomodel->DeleteData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum); 48 45 49 46 /*Assign output pointer: */ 50 47 *pnodes=nodes; -
issm/trunk/src/c/modules/ModelProcessorx/Hydrology/UpdateElementsHydrology.cpp
r13395 r13975 17 17 18 18 int numberofelements; 19 19 20 20 /*Fetch data needed: */ 21 21 iomodel->Constant(&numberofelements,MeshNumberofelementsEnum); -
issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateConstraintsMelting.cpp
r13395 r13975 13 13 void CreateConstraintsMelting(Constraints** pconstraints, IoModel* iomodel){ 14 14 15 /*Intermediary*/16 int i;17 int count;18 19 /*Intermediary*/20 Constraints* constraints = NULL;21 22 15 /*Recover pointer: */ 23 constraints=*pconstraints;16 Constraints* constraints=*pconstraints; 24 17 25 18 /*Create constraints if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateLoadsMelting.cpp
r13395 r13975 14 14 15 15 /*Intermediary*/ 16 int i; 17 int dim; 18 int numberofvertices; 19 20 /*DataSet*/ 21 Loads* loads = NULL; 22 23 /*Fetch parameters: */ 16 int dim; 17 int numberofvertices; 24 18 iomodel->Constant(&dim,MeshDimensionEnum); 25 19 iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum); … … 29 23 30 24 /*Recover pointer: */ 31 loads=*ploads;25 Loads* loads=*ploads; 32 26 33 27 /*Create loads if they do not exist yet*/ … … 38 32 CreateSingleNodeToElementConnectivity(iomodel); 39 33 40 for (i=0;i<numberofvertices;i++){34 for(int i=0;i<numberofvertices;i++){ 41 35 if((iomodel->my_vertices[i]==1)){ 42 36 if (reCast<int>(iomodel->Data(MeshVertexonbedEnum)[i])){ -
issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateNodesMelting.cpp
r13395 r13975 20 20 int numberofvertices; 21 21 22 /*DataSets: */23 Nodes* nodes = NULL;24 25 22 /*Fetch parameters: */ 26 23 iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum); 27 24 28 25 /*Recover pointer: */ 29 nodes=*pnodes;26 Nodes* nodes=*pnodes; 30 27 31 28 /*Create nodes if they do not exist yet*/ … … 40 37 41 38 if(iomodel->my_vertices[i]){ 42 39 43 40 /*Add node to nodes dataset: */ 44 41 nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,i+1,i,iomodel,MeltingAnalysisEnum)); -
issm/trunk/src/c/modules/ModelProcessorx/Melting/UpdateElementsMelting.cpp
r13395 r13975 55 55 iomodel->FetchDataToInput(elements,BasalforcingsMeltingRateEnum); 56 56 iomodel->FetchDataToInput(elements,PressureEnum); 57 57 58 58 /*Free data: */ 59 59 iomodel->DeleteData(1,MeshElementsEnum); -
issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
r13395 r13975 20 20 21 21 int i,analysis_type,dim,verbose; 22 bool isthermal,isprognostic,isdiagnostic,isgroundingline,isenthalpy ,autodiff;23 22 bool isthermal,isprognostic,isdiagnostic,isgroundingline,isenthalpy; 23 24 24 /*output: */ 25 25 Elements *elements = NULL; … … 31 31 Parameters *parameters = NULL; 32 32 33 34 33 /*Initialize IoModel from input file*/ 35 34 IoModel* iomodel = new IoModel(IOMODEL); … … 43 42 iomodel->Constant(&isdiagnostic,TransientIsdiagnosticEnum); 44 43 iomodel->Constant(&isgroundingline,TransientIsgroundinglineEnum); 45 iomodel->Constant(&autodiff,AutodiffIsautodiffEnum);46 47 /*If we are running in AD mode, we need to declare our independent variables now, before48 *and prevent them from being erased during successive calls to iomodel->FetchData and49 iomodel->DeleteData:*/50 if(autodiff)iomodel->DeclareIndependents();51 44 52 45 SetVerbosityLevel(verbose); … … 73 66 if(solution_type==SteadystateSolutionEnum && analysis_type==MeltingAnalysisEnum && isenthalpy==true) continue; 74 67 if(solution_type==SteadystateSolutionEnum && analysis_type==EnthalpyAnalysisEnum && isenthalpy==false) continue; 75 68 76 69 if(VerboseMProcessor()) _pprintLine_(" creating datasets for analysis " << EnumToStringx(analysis_type)); 77 70 CreateDataSets(&elements,&nodes,&vertices,&materials,&constraints,&loads,¶meters,iomodel,rootpath,solution_type,analysis_type,nummodels,i); -
issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h
r13395 r13975 109 109 void UpdateCounters(IoModel* iomodel,Nodes** pnodes,Loads** ploads, Constraints** pconstraints); 110 110 111 112 111 /*Distribution of dofs: */ 113 112 void DistributeNumDofs(DofIndexing* index,int analysis_type,IssmDouble* vertices_type); -
issm/trunk/src/c/modules/ModelProcessorx/NodesPartitioning.cpp
r13395 r13975 22 22 23 23 void NodesPartitioning(bool** pmy_nodes,bool* my_elements, int* my_vertices, IoModel* iomodel, bool continuous){ 24 24 25 25 /*First thing, this is a new partition for a new analysis_type, therefore, to avoid a leak, erase the nodes partition that might come through pmy_nodes: */ 26 26 xDelete<bool>(*pmy_nodes); … … 51 51 } 52 52 53 54 53 void DiscontinuousGalerkinNodesPartitioning(bool** pmy_nodes,bool* my_elements, int* my_vertices, IoModel* iomodel){ 55 54 … … 62 61 * the nodes and the vertices. The vertices are similar to continuous galerkin, but the nodes partitioning involves edges, which mess up sorting of 63 62 * ids. */ 64 63 65 64 int i,j; 66 65 int dim; -
issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateConstraintsPrognostic.cpp
r13395 r13975 10 10 void CreateConstraintsPrognostic(Constraints** pconstraints, IoModel* iomodel){ 11 11 12 /*Fetch parameters: */ 12 13 int stabilization; 13 14 /*Fetch parameters: */15 14 iomodel->Constant(&stabilization,PrognosticStabilizationEnum); 16 15 17 /*Output*/18 Constraints *constraints = NULL;19 20 16 /*Recover pointer: */ 21 constraints=*pconstraints;17 Constraints* constraints=*pconstraints; 22 18 23 19 /*Create constraints if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp
r13395 r13975 23 23 int numberofelements; 24 24 25 /*DataSet*/26 Loads* loads = NULL;27 28 25 /*Fetch parameters: */ 29 26 iomodel->Constant(&stabilization,PrognosticStabilizationEnum); … … 32 29 33 30 /*Recover pointer: */ 34 loads=*ploads;31 Loads* loads=*ploads; 35 32 36 33 /*Create loads if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp
r13395 r13975 26 26 int stabilization; 27 27 28 /*DataSets: */29 Nodes* nodes = NULL;30 31 28 /*Fetch parameters: */ 32 29 iomodel->Constant(&dim,MeshDimensionEnum); … … 36 33 37 34 /*Recover pointer: */ 38 nodes=*pnodes;35 Nodes* nodes=*pnodes; 39 36 40 37 /*Create nodes if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp
r13395 r13975 73 73 if(issmbgradients){ 74 74 iomodel->FetchDataToInput(elements,SurfaceforcingsHcEnum); 75 iomodel->FetchDataToInput(elements,SurfaceforcingsHrefEnum); 76 iomodel->FetchDataToInput(elements,SurfaceforcingsSmbrefEnum); 75 77 iomodel->FetchDataToInput(elements,SurfaceforcingsSmbPosMaxEnum); 76 78 iomodel->FetchDataToInput(elements,SurfaceforcingsSmbPosMinEnum); -
issm/trunk/src/c/modules/ModelProcessorx/SortDataSets.cpp
r13395 r13975 14 14 #include "../../EnumDefinitions/EnumDefinitions.h" 15 15 #include "./ModelProcessorx.h" 16 17 16 18 17 void SortDataSets(Elements** pelements,Nodes** pnodes,Vertices** pvertices, Loads** ploads, Materials** pmaterials, Constraints** pconstraints, Parameters** pparameters){ -
issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateConstraintsSurfaceSlope.cpp
r13395 r13975 13 13 void CreateConstraintsSurfaceSlope(Constraints** pconstraints, IoModel* iomodel){ 14 14 15 /*Output*/16 Constraints* constraints = NULL;17 18 15 /*Recover pointer: */ 19 constraints=*pconstraints;16 Constraints* constraints=*pconstraints; 20 17 21 18 /*Create constraints if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp
r13395 r13975 13 13 void CreateLoadsSurfaceSlope(Loads** ploads, IoModel* iomodel){ 14 14 15 /*DataSet*/16 Loads* loads = NULL;17 18 15 /*Recover pointer: */ 19 loads=*ploads;16 Loads* loads=*ploads; 20 17 21 18 /*Create loads if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateNodesSurfaceSlope.cpp
r13395 r13975 16 16 17 17 /*Intermediary*/ 18 int i;19 18 bool continuous_galerkin=true; 20 19 int numberofvertices; 21 22 /*DataSets: */23 Nodes* nodes = NULL;24 20 25 21 /*Fetch parameters: */ … … 27 23 28 24 /*Recover pointer: */ 29 nodes=*pnodes;25 Nodes* nodes=*pnodes; 30 26 31 27 /*Create nodes if they do not exist yet*/ 32 28 if(!nodes) nodes = new Nodes(); 33 29 34 30 /*Continuous Galerkin partition of nodes: */ 35 31 NodesPartitioning(&iomodel->my_nodes,iomodel->my_elements,iomodel->my_vertices,iomodel,continuous_galerkin); 36 32 37 33 /*First fetch data: */ 38 34 iomodel->FetchData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum); 39 35 40 for (i=0;i<numberofvertices;i++){ 36 for(int i=0;i<numberofvertices;i++){ 37 if(iomodel->my_vertices[i]){ 41 38 42 if(iomodel->my_vertices[i]){43 44 39 /*Add node to nodes dataset: */ 45 40 nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,i+1,i,iomodel,SurfaceSlopeAnalysisEnum)); … … 50 45 /*Clean fetched data: */ 51 46 iomodel->DeleteData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum); 52 47 53 48 /*Assign output pointer: */ 54 49 *pnodes=nodes; -
issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/UpdateElementsSurfaceSlope.cpp
r13395 r13975 37 37 iomodel->FetchDataToInput(elements,BedEnum); 38 38 iomodel->FetchDataToInput(elements,MaskElementonwaterEnum); 39 39 40 40 if (dim==3){ 41 41 iomodel->FetchDataToInput(elements,MeshElementonbedEnum); 42 42 iomodel->FetchDataToInput(elements,MeshElementonsurfaceEnum); 43 43 } 44 44 45 45 /*Free data: */ 46 46 iomodel->DeleteData(1,MeshElementsEnum); -
issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateConstraintsThermal.cpp
r13395 r13975 14 14 void CreateConstraintsThermal(Constraints** pconstraints, IoModel* iomodel){ 15 15 16 /*Intermediary*/ 17 int i; 18 int count; 16 /*Fetch parameters: */ 19 17 int dim; 20 21 /*Output*/22 Constraints* constraints = NULL;23 24 /*Fetch parameters: */25 18 iomodel->Constant(&dim,MeshDimensionEnum); 26 19 27 20 /*Recover pointer: */ 28 constraints=*pconstraints;21 Constraints* constraints=*pconstraints; 29 22 30 23 /*Create constraints if they do not exist yet*/ -
issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateLoadsThermal.cpp
r13395 r13975 17 17 int dim; 18 18 int numberofvertices; 19 20 /*DataSet*/21 Loads* loads = NULL;22 19 Pengrid* pengrid = NULL; 23 20 24 21 /*Recover pointer: */ 25 loads=*ploads;22 Loads* loads=*ploads; 26 23 27 24 /*Fetch parameters: */ … … 40 37 41 38 for (i=0;i<numberofvertices;i++){ 42 39 43 40 /*keep only this partition's nodes:*/ 44 41 if((iomodel->my_vertices[i]==1)){ -
issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateNodesThermal.cpp
r13395 r13975 16 16 17 17 /*Intermediary*/ 18 int i;19 18 bool continuous_galerkin=true; 20 int numberofvertices;21 22 /*DataSets: */23 Nodes* nodes = NULL;24 19 25 20 /*Fetch parameters: */ 21 int numberofvertices; 26 22 iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum); 27 23 28 24 /*Recover pointer: */ 29 nodes=*pnodes;25 Nodes* nodes=*pnodes; 30 26 31 27 /*Create nodes if they do not exist yet*/ … … 38 34 iomodel->FetchData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum); 39 35 40 for (i=0;i<numberofvertices;i++){ 41 36 for(int i=0;i<numberofvertices;i++){ 42 37 if(iomodel->my_vertices[i]){ 43 38 /*Add node to nodes dataset: */ … … 49 44 /*Clean fetched data: */ 50 45 iomodel->DeleteData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum); 51 46 52 47 /*Assign output pointer: */ 53 48 *pnodes=nodes; -
issm/trunk/src/c/modules/ModelProcessorx/Thermal/UpdateElementsThermal.cpp
r13395 r13975 60 60 iomodel->FetchDataToInput(elements,VyEnum); 61 61 iomodel->FetchDataToInput(elements,VzEnum); 62 62 63 63 if(dakota_analysis){ 64 64 elements->InputDuplicate(TemperatureEnum,QmuTemperatureEnum); -
issm/trunk/src/c/modules/ModelProcessorx/UpdateCounters.cpp
r13395 r13975 26 26 constraints=*pconstraints; 27 27 28 29 28 if(nodes) iomodel->nodecounter=nodes->NumberOfNodes(); 30 29 else iomodel->nodecounter=0; … … 32 31 if(loads)iomodel->loadcounter=loads->NumberOfLoads(); 33 32 else iomodel->loadcounter=0; 34 33 35 34 if(constraints)iomodel->constraintcounter=constraints->NumberOfConstraints(); 36 35 else iomodel->constraintcounter=0; -
issm/trunk/src/c/modules/NodalValuex/NodalValuex.cpp
r13395 r13975 12 12 void NodalValuex( IssmDouble* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,bool process_units){ 13 13 14 externint my_rank;14 int my_rank; 15 15 int i; 16 16 int index; … … 21 21 int cpu_found; 22 22 23 /*Get my_rank:*/ 24 my_rank=IssmComm::GetRank(); 25 23 26 /*retrieve element we are interested in: */ 24 27 parameters->FindParam(&index,IndexEnum); … … 27 30 *element, figure out if they hold the vertex, and the data. If so, return it: */ 28 31 for(i=0;i<elements->Size();i++){ 29 Element* element= (Element*)elements->GetObjectByOffset(i);32 Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 30 33 found=element->NodalValue(&value,index,natureofdataenum,process_units); 31 34 if (found){ … … 37 40 /*Broadcast whether we found the element: */ 38 41 #ifdef _HAVE_MPI_ 39 MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);42 MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,IssmComm::GetComm()); 40 43 if(!sumfound)_error_("could not find element with vertex with id" << index << " to compute nodal value " << EnumToStringx(natureofdataenum)); 41 44 #endif … … 43 46 /*Broadcast and plug into response: */ 44 47 #ifdef _HAVE_MPI_ 45 MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX, MPI_COMM_WORLD);46 MPI_Bcast(&value,1,MPI_DOUBLE,cpu_found, MPI_COMM_WORLD);48 MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,IssmComm::GetComm()); 49 MPI_Bcast(&value,1,MPI_DOUBLE,cpu_found,IssmComm::GetComm()); 47 50 #else 48 51 value=cpu_found; -
issm/trunk/src/c/modules/NodalValuex/NodalValuex.h
r13395 r13975 13 13 14 14 #endif /* _NODALVALUEX_H */ 15 -
issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp
r13395 r13975 34 34 double* connectivity=NULL; 35 35 36 37 38 36 /*Allocate connectivity: */ 39 37 connectivity=xNewZeroInit<double>(nods*width); … … 46 44 47 45 for(i=0;i<3;i++){ 48 46 49 47 node=(int)*(elements+n*3+i); //already matlab indexed, elements comes directly from the workspace. 50 48 index=node-1; 51 49 52 50 num_elements=(int)*(connectivity+width*index+maxels); //retrieve number of elements already plugged into the connectivity of this node. 53 51 54 52 already_plugged=0; 55 53 for(j=0;j<num_elements;j++){ … … 64 62 *(connectivity+width*index+num_elements)=element; 65 63 *(connectivity+width*index+maxels)=(double)(num_elements+1); 66 64 67 65 } 68 66 } -
issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.h
r1105 r13975 10 10 11 11 #endif /* _NODECONNECTIVITYX_H */ 12 -
issm/trunk/src/c/modules/NodesDofx/NodesDofx.cpp
r8816 r13975 14 14 int noerr=1; 15 15 int found=0; 16 int i; 17 16 18 17 /*Do we have any nodes for this analysis type? :*/ 19 18 if(nodes->NumberOfNodes(configuration_type)){ -
issm/trunk/src/c/modules/Orthx/Orthx.cpp
r13395 r13975 6 6 7 7 void Orthx( Vector<IssmDouble>** pnewgradj, Vector<IssmDouble>* gradj, Vector<IssmDouble>* oldgradj){ 8 8 9 9 /*output: */ 10 10 Vector<IssmDouble>* newgradj=NULL; 11 11 12 12 /*intermediary:*/ 13 IssmDouble norm_ new,norm_old,dot_product;;13 IssmDouble norm_old,dot_product;; 14 14 15 15 /*Initialize output*/ -
issm/trunk/src/c/modules/Orthx/Orthx.h
r13395 r13975 14 14 15 15 #endif /* _ORTHX_H */ 16 -
issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp
r13395 r13975 15 15 #include "../../io/io.h" 16 16 #include "../../classes/objects/objects.h" 17 17 18 18 void OutputResultsx(Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Results* results){ 19 19 20 extern intmy_rank;20 int my_rank; 21 21 FILE *fid = NULL; 22 22 char *outputfilename = NULL; … … 26 26 char* solutiontypestring = NULL; 27 27 bool dakota_analysis = false; 28 28 29 29 /*retrieve parameters: */ 30 30 parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum); 31 32 /*recover my_rank:*/ 33 my_rank=IssmComm::GetRank(); 31 34 32 35 if(dakota_analysis){ … … 51 54 /*Now, open file for writing, if not already done: */ 52 55 if(!parameters->Exist(OutputFilePointerEnum)){ 53 56 54 57 /*We don't have a file pointer. Retrieve the output file name and open it for writing:*/ 55 58 parameters->FindParam(&outputfilename,OutputfilenameEnum); … … 69 72 } 70 73 xDelete<char>(outputfilename); 71 74 72 75 /*Add file pointer in parameters for further calls to OutputResultsx: */ 73 76 parameters->SetParam(fid,OutputFilePointerEnum); -
issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.h
r12330 r13975 17 17 18 18 #endif /* _OUTPUTRESULTS_H */ 19 -
issm/trunk/src/c/modules/OutputRiftsx/OutputRiftsx.cpp
r4214 r13975 17 17 18 18 /*Allocate grad_g: */ 19 riftproperties=NewVec(numrifts );19 riftproperties=NewVec(numrifts,IssmComm::GetComm()); 20 20 21 21 /*Compute rift properties : */ -
issm/trunk/src/c/modules/OutputRiftsx/OutputRiftsx.h
r4236 r13975 12 12 13 13 #endif /* _OUTPUTRIFTSX_H */ 14 -
issm/trunk/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp
r13395 r13975 23 23 24 24 char line [1000]; 25 externint my_rank;25 int my_rank; 26 26 int i; 27 27 … … 34 34 char* catstring=NULL; 35 35 int stringlength; 36 37 /*Get my_rank:*/ 38 my_rank=IssmComm::GetRank(); 36 39 37 40 if(my_rank==0){ … … 56 59 numanalyses=0; 57 60 while ( fgets(line, sizeof line, fid) ){ 58 61 59 62 /*skip comments and empty lines: */ 60 63 if ((line[0]=='%') || (line[0]=='\n') || (line[0]==' ') || (line[0]=='\t') || (line[0]=='\r'))continue; 61 64 62 65 /*Get rid of end of line: */ 63 66 line[strlen(line)-1]='\0'; 64 67 65 68 if (line[0]=='+'){ /*this is the analysis line: */ 66 69 analyses[numanalyses]=StringToEnumx(&line[1]); //skip the '+' … … 96 99 /*Ok, broadcast to other cpus: */ 97 100 #ifdef _HAVE_MPI_ 98 MPI_Bcast(&numanalyses,1,MPI_INT,0, MPI_COMM_WORLD);101 MPI_Bcast(&numanalyses,1,MPI_INT,0,IssmComm::GetComm()); 99 102 if(my_rank!=0){ 100 103 analyses=xNew<IssmPDouble>(numanalyses); 101 104 strings=xNew<char*>(numanalyses); 102 105 } 103 MPI_Bcast(analyses,numanalyses,MPI_DOUBLE,0, MPI_COMM_WORLD);106 MPI_Bcast(analyses,numanalyses,MPI_DOUBLE,0,IssmComm::GetComm()); 104 107 #endif 105 108 for(i=0;i<numanalyses;i++){ … … 110 113 if(my_rank==0)stringlength=(strlen(string)+1)*sizeof(char); 111 114 #ifdef _HAVE_MPI_ 112 MPI_Bcast(&stringlength,1,MPI_INT,0, MPI_COMM_WORLD);115 MPI_Bcast(&stringlength,1,MPI_INT,0,IssmComm::GetComm()); 113 116 if(my_rank!=0)string=xNew<char>(stringlength); 114 MPI_Bcast(string,stringlength,MPI_CHAR,0, MPI_COMM_WORLD);117 MPI_Bcast(string,stringlength,MPI_CHAR,0,IssmComm::GetComm()); 115 118 if(my_rank!=0)strings[i]=string; 116 119 #endif -
issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h
r13395 r13975 2 2 PointCloudFindNeighborsx.h 3 3 */ 4 5 4 6 5 #ifndef _POINTCLOUDFLAGNEIGHBORSX_H … … 26 25 void* PointCloudFindNeighborsxt(void* vPointCloudFindNeighborsThreadStruct); 27 26 28 29 27 #endif /* _POINTCLOUDFLAGNEIGHBORSX_H */ 30 -
issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp
r13395 r13975 24 24 my_thread=handle->id; 25 25 num_threads=handle->num; 26 26 27 27 /*recover parameters :*/ 28 28 x=gate->x; … … 57 57 if (j==i)continue; 58 58 distance=sqrt(pow(x[i]-x[j],2)+ pow(y[i]-y[j],2)); 59 59 60 60 if(distance<=mindistance){ 61 61 … … 74 74 /*Free ressources:*/ 75 75 xDelete<bool>(already); 76 76 77 77 return NULL; 78 78 } -
issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp
r12706 r13975 35 35 IssmDouble PDup, PDCUT = 2.0; // PDcut: rain/snow cutoff temperature (C) 36 36 IssmDouble tstar; // monthly mean surface temp 37 37 38 38 IssmDouble* pdds=NULL; 39 39 IssmDouble* pds=NULL; 40 40 Element* element = NULL; 41 41 42 42 pdds=xNew<IssmDouble>(NPDMAX+1); 43 43 pds=xNew<IssmDouble>(NPDCMAX+1); 44 44 45 45 // initialize PDD (creation of a lookup table) 46 46 tstep = 0.1; … … 55 55 56 56 itm = reCast<int,IssmDouble>((2*siglim/DT + 1.5)); 57 57 58 58 if (itm >= NPDMAX){ 59 59 _printLine_("increase NPDMAX in massBalance.cpp"); … … 73 73 } 74 74 pdds[itm+1] = siglim + DT; 75 75 76 76 //*********compute PD(T) : snow/precip fraction. precipitation falling as snow 77 77 tstepc = 0.1; … … 100 100 pds[itm+1] = 0.; 101 101 // *******END initialize PDD 102 102 103 103 for(i=0;i<elements->Size();i++){ 104 element= (Element*)elements->GetObjectByOffset(i);104 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 105 105 element->PositiveDegreeDay(pdds,pds,signorm); 106 106 } … … 108 108 xDelete<IssmDouble>(pdds); 109 109 xDelete<IssmDouble>(pds); 110 110 111 111 } -
issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.cpp
r3913 r13975 15 15 RecursivePropagation(pool, connectivity,index, flags); 16 16 } 17 18 17 19 18 void RecursivePropagation(double* pool, double* connectivity, int index, double* flags){ -
issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h
r4236 r13975 11 11 12 12 #endif /* _PROPAGATEFLAGSFROMCONNECTIVITYX_H */ 13 -
issm/trunk/src/c/modules/Reduceloadx/Reduceloadx.cpp
r13395 r13975 20 20 int global_m,global_n; 21 21 bool fromlocalsize = true; 22 int verbose;22 bool oldalloc = false; 23 23 24 24 if(VerboseModule()) _pprintLine_(" Dirichlet lifting applied to load vector"); … … 32 32 /*pf = pf - Kfs * y_s;*/ 33 33 Kfs->GetLocalSize(&Kfsm,&Kfsn); 34 Kfsy_s=new Vector<IssmDouble>(Kfsm,fromlocalsize); 34 if(oldalloc) 35 Kfsy_s=new Vector<IssmDouble>(Kfsm,fromlocalsize); 36 else 37 Kfsy_s=new Vector<IssmDouble>(Kfsm,global_m); 38 35 39 if (flag_ys0){ 36 40 … … 49 53 } 50 54 51 52 55 /*Free ressources and return*/ 53 56 xdelete(&y_s0); -
issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp
r13395 r13975 5 5 6 6 #include "./Reducevectorgtofx.h" 7 7 8 8 void Reducevectorgtofx(Vector<IssmDouble>** puf, Vector<IssmDouble>* ug, Nodes* nodes,Parameters* parameters){ 9 9 … … 12 12 13 13 /*variables: */ 14 int i;15 int configuration_type;16 int fsize;17 IssmDouble* ug_serial=NULL;14 int configuration_type; 15 int fsize; 16 IssmDouble *ug_serial = NULL; 17 bool oldalloc = false; 18 18 19 19 /*first figure out fsize: */ 20 20 parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 21 21 fsize=nodes->NumberOfDofs(configuration_type,FsetEnum); 22 23 int analysis_type; 24 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 25 int flocalsize = nodes->NumberOfDofsLocal(analysis_type,FsetEnum); 22 26 23 27 if(fsize==0){ … … 26 30 else{ 27 31 /*allocate: */ 28 uf=new Vector<IssmDouble>(fsize); 32 if(oldalloc) 33 uf=new Vector<IssmDouble>(fsize); 34 else 35 uf=new Vector<IssmDouble>(flocalsize,fsize); 29 36 30 37 if(nodes->NumberOfNodes(configuration_type)){ … … 34 41 35 42 /*Go through all nodes, and ask them to retrieve values from ug, and plug them into uf: */ 36 for(i =0;i<nodes->Size();i++){43 for(int i=0;i<nodes->Size();i++){ 37 44 38 45 Node* node=(Node*)nodes->GetObjectByOffset(i); -
issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.h
r13395 r13975 13 13 14 14 #endif /* _REDUCEVECTORGTOFX_H */ 15 -
issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp
r13395 r13975 21 21 ssize=nodes->NumberOfDofs(configuration_type,SsetEnum); 22 22 23 int analysis_type; 24 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 25 int slocalsize = nodes->NumberOfDofsLocal(analysis_type,SsetEnum); 26 27 bool oldalloc = false; 28 23 29 if(ssize==0){ 24 30 ys=NULL; … … 26 32 else{ 27 33 /*allocate: */ 28 ys=new Vector<IssmDouble>(ssize); 34 if(oldalloc) 35 ys=new Vector<IssmDouble>(ssize); 36 else 37 ys=new Vector<IssmDouble>(slocalsize,ssize); 29 38 30 39 if(nodes->NumberOfNodes(configuration_type)){ -
issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.h
r13395 r13975 13 13 14 14 #endif /* _REDUCEVECTORGTOSX_H */ 15 -
issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.cpp
r13395 r13975 12 12 13 13 void ResetConstraintsx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads,Materials* materials, Parameters* parameters){ 14 15 int i;16 17 extern int num_procs;18 extern int my_rank;19 14 20 15 /*output: */ -
issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.h
r13395 r13975 14 14 15 15 #endif /* _RESETCONSTRAINTSX_H */ 16 -
issm/trunk/src/c/modules/ResetCoordinateSystemx/ResetCoordinateSystemx.cpp
r10440 r13975 13 13 14 14 for (int i=0;i<elements->Size();i++){ 15 element= (Element*)elements->GetObjectByOffset(i);15 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 16 16 element->ResetCoordinateSystem(); 17 17 } -
issm/trunk/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp
r13395 r13975 22 22 /*Compute Misfit: */ 23 23 for (i=0;i<elements->Size();i++){ 24 element= (Element*)elements->GetObjectByOffset(i);24 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 25 25 J+=element->RheologyBbarAbsGradient(process_units,weight_index); 26 26 } … … 28 28 /*Sum all J from all cpus of the cluster:*/ 29 29 #ifdef _HAVE_MPI_ 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0, MPI_COMM_WORLD);31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0, MPI_COMM_WORLD);30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 32 32 J=J_sum; 33 33 #endif -
issm/trunk/src/c/modules/Scotchx/Scotchx.h
r13395 r13975 5 5 #ifndef _SCOTCHX_H 6 6 #define _SCOTCHX_H 7 8 7 9 8 #undef __FUNCT__ -
issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp
r13395 r13975 29 29 30 30 void SetControlInputsFromVectorx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vector<IssmDouble>* vector){ 31 31 32 32 IssmDouble* serial_vector=NULL; 33 33 -
issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp
r13395 r13975 15 15 16 16 #ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in. 17 17 18 18 double cm,sp; 19 19 … … 33 33 34 34 #ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in. 35 35 36 36 int i,j,k,iret=0; 37 37 int lwidth=1; … … 611 611 #endif 612 612 } 613 -
issm/trunk/src/c/modules/SmbGradientsx/SmbGradientsx.cpp
r12706 r13975 18 18 19 19 int i; 20 20 21 21 Element* element = NULL; 22 22 23 23 for(i=0;i<elements->Size();i++){ 24 element= (Element*)elements->GetObjectByOffset(i);24 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 25 25 element->SmbGradients(); 26 26 } -
issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp
r12706 r13975 12 12 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 13 13 #endif 14 14 15 15 void DofTypesToIndexSet(IS* pisv, IS* pisp, Vec df,int typeenum){ 16 16 … … 62 62 } 63 63 VecRestoreArray(df,&df_local); 64 64 65 65 /*Create indices sets: */ 66 66 #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2) 67 ISCreateGeneral( PETSC_COMM_WORLD,pressure_num,pressure_indices,&isp);68 ISCreateGeneral( PETSC_COMM_WORLD,velocity_num,velocity_indices,&isv);67 ISCreateGeneral(IssmComm::GetComm(),pressure_num,pressure_indices,&isp); 68 ISCreateGeneral(IssmComm::GetComm(),velocity_num,velocity_indices,&isv); 69 69 #else 70 ISCreateGeneral( PETSC_COMM_WORLD,pressure_num,pressure_indices,PETSC_COPY_VALUES,&isp);71 ISCreateGeneral( PETSC_COMM_WORLD,velocity_num,velocity_indices,PETSC_COPY_VALUES,&isv);70 ISCreateGeneral(IssmComm::GetComm(),pressure_num,pressure_indices,PETSC_COPY_VALUES,&isp); 71 ISCreateGeneral(IssmComm::GetComm(),velocity_num,velocity_indices,PETSC_COPY_VALUES,&isv); 72 72 #endif 73 73 } -
issm/trunk/src/c/modules/Solverx/Solverx.cpp
r13395 r13975 15 15 16 16 void Solverx(Vector<IssmDouble>** puf, Matrix<IssmDouble>* Kff, Vector<IssmDouble>* pf, Vector<IssmDouble>* uf0,Vector<IssmDouble>* df, Parameters* parameters){ 17 18 /*Intermediary: */19 int analysis_type;20 17 21 18 /*output: */ -
issm/trunk/src/c/modules/Solverx/Solverx.h
r13395 r13975 27 27 void SolverxSeq(IssmPDouble *X, IssmPDouble *A, IssmPDouble *B,int n); 28 28 29 #if def _HAVE_ADOLC_29 #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_) 30 30 void SolverxSeq(IssmDouble *X,IssmDouble *A,IssmDouble *B,int n, Parameters* parameters); 31 31 // call back functions: … … 38 38 39 39 #endif /* _SOLVERX_H */ 40 -
issm/trunk/src/c/modules/Solverx/SolverxPetsc.cpp
r13395 r13975 20 20 Vec uf0_vector = NULL; 21 21 Vec df_vector = NULL; 22 22 23 23 if(uf0) uf0_vector = uf0->vector; 24 24 if(df) df_vector = df->vector; … … 36 36 /*Intermediary: */ 37 37 int local_m,local_n,global_m,global_n; 38 int analysis_type;39 38 40 39 /*Solver */ … … 70 69 MatGetSize(Kff,&global_m,&global_n); _assert_(global_m==global_m); 71 70 if(!global_n){ 72 *puf=NewVec(0 ); return;71 *puf=NewVec(0,IssmComm::GetComm()); return; 73 72 } 74 73 … … 86 85 } 87 86 else{ 88 MatGetLocalSize(Kff,&local_m,&local_n);uf=NewVec(local_n, fromlocalsize);87 MatGetLocalSize(Kff,&local_m,&local_n);uf=NewVec(local_n,IssmComm::GetComm(),fromlocalsize); 89 88 } 90 89 … … 102 101 103 102 /*Prepare solver*/ 104 KSPCreate( MPI_COMM_WORLD,&ksp);103 KSPCreate(IssmComm::GetComm(),&ksp); 105 104 KSPSetOperators(ksp,Kff,Kff,DIFFERENT_NONZERO_PATTERN); 106 105 KSPSetFromOptions(ksp); … … 148 147 if(VerboseSolver())KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD); 149 148 KSPSolve(ksp,pf,uf); 150 149 151 150 /*Check convergence*/ 152 151 KSPGetIterationNumber(ksp,&iteration_number); … … 155 154 /*Free resources:*/ 156 155 KSPFree(&ksp); 157 156 158 157 /*Assign output pointers:*/ 159 158 *puf=uf; -
issm/trunk/src/c/modules/Solverx/SolverxSeq.cpp
r13395 r13975 12 12 #include "./Solverx.h" 13 13 #include "../../shared/shared.h" 14 #include "../../classes/classes.h" 14 15 #include "../../include/include.h" 15 16 #include "../../io/io.h" … … 19 20 #endif 20 21 21 #ifdef _HAVE_ADOLC_22 #include "../../shared/Numerics/adolc_edf.h"23 #endif24 25 22 void SolverxSeq(SeqVec<IssmDouble>** puf,SeqMat<IssmDouble>* Kff, SeqVec<IssmDouble>* pf, Parameters* parameters){/*{{{*/ 26 23 27 24 #ifdef _HAVE_GSL_ 28 25 /*Intermediary: */ 29 int M,N,N2 ,s;26 int M,N,N2; 30 27 SeqVec<IssmDouble> *uf = NULL; 31 28 … … 35 32 if(N!=N2)_error_("Right hand side vector of size " << N2 << ", when matrix is of size " << M << "-" << N << " !"); 36 33 if(M!=N)_error_("Stiffness matrix should be square!"); 34 #ifdef _HAVE_ADOLC_ 35 ensureContiguousLocations(N); 36 #endif 37 37 IssmDouble *x = xNew<IssmDouble>(N); 38 39 38 #ifdef _HAVE_ADOLC_ 40 39 SolverxSeq(x,Kff->matrix,pf->vector,N,parameters); … … 69 68 #ifdef _HAVE_ADOLC_ 70 69 int EDF_for_solverx(int n, IssmPDouble *x, int m, IssmPDouble *y){ /*{{{*/ 71 72 70 SolverxSeq(y,x, x+m*m, m); // x is where the matrix starts, x+m*m is where the right-hand side starts 71 return 0; 73 72 } /*}}}*/ 74 73 int EDF_fos_forward_for_solverx(int n, IssmPDouble *inVal, IssmPDouble *inDeriv, int m, IssmPDouble *outVal, IssmPDouble *outDeriv) { /*{{{*/ 75 74 #ifdef _HAVE_GSL_ 76 // the matrix will be modified by LU decomposition. Use gsl_A copy 77 double* Acopy = xNew<double>(m*m); 78 xMemCpy(Acopy,inVal,m*m); 79 /*Initialize gsl matrices and vectors: */ 80 gsl_matrix_view gsl_A = gsl_matrix_view_array (Acopy,m,m); 81 gsl_vector_view gsl_b = gsl_vector_view_array (inVal+m*m,m); // the right hand side starts at address inVal+m*m 82 gsl_permutation *perm_p = gsl_permutation_alloc (m); 83 int signPerm; 84 // factorize 85 gsl_linalg_LU_decomp (&gsl_A.matrix, perm_p, &signPerm); 86 gsl_vector *gsl_x_p = gsl_vector_alloc (m); 87 // solve for the value 88 gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_b.vector, gsl_x_p); 89 /*Copy result*/ 90 xMemCpy(outVal,gsl_vector_ptr(gsl_x_p,0),m); 91 gsl_vector_free(gsl_x_p); 92 // solve for the derivatives acc. to A * dx = r with r=db - dA * x 93 // compute the RHS 94 double* r=xNew<double>(m); 95 for (int i=0; i<m; i++) { 96 r[i]=inDeriv[m*m+i]; // this is db[i] 97 for (int j=0;j<m; j++) { 98 r[i]-=inDeriv[i*m+j]*outVal[j]; // this is dA[i][j]*x[j] 99 } 100 } 101 gsl_vector_view gsl_r=gsl_vector_view_array(r,m); 102 gsl_vector *gsl_dx_p = gsl_vector_alloc(m); 103 gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_r.vector, gsl_dx_p); 104 xMemCpy(outDeriv,gsl_vector_ptr(gsl_dx_p,0),m); 105 gsl_vector_free(gsl_dx_p); 106 xDelete(r); 107 gsl_permutation_free(perm_p); 108 xDelete(Acopy); 109 #endif 110 return 0; 75 // for (int i=0; i<m*m; ++i) std::cout << "EDF_fos_forward_for_solverx A["<< i << "]=" << inVal[i] << std::endl; 76 // for (int i=0; i<m; ++i) std::cout << "EDF_fos_forward_for_solverx b["<< i << "]=" << inVal[i+m*m] << std::endl; 77 // the matrix will be modified by LU decomposition. Use gsl_A copy 78 double* Acopy = xNew<double>(m*m); 79 xMemCpy(Acopy,inVal,m*m); 80 /*Initialize gsl matrices and vectors: */ 81 gsl_matrix_view gsl_A = gsl_matrix_view_array (Acopy,m,m); 82 gsl_vector_view gsl_b = gsl_vector_view_array (inVal+m*m,m); // the right hand side starts at address inVal+m*m 83 gsl_permutation *perm_p = gsl_permutation_alloc (m); 84 int signPerm; 85 // factorize 86 gsl_linalg_LU_decomp (&gsl_A.matrix, perm_p, &signPerm); 87 gsl_vector *gsl_x_p = gsl_vector_alloc (m); 88 // solve for the value 89 gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_b.vector, gsl_x_p); 90 /*Copy result*/ 91 xMemCpy(outVal,gsl_vector_ptr(gsl_x_p,0),m); 92 gsl_vector_free(gsl_x_p); 93 // for (int i=0; i<m; ++i) std::cout << "EDF_fos_forward_for_solverx x["<< i << "]=" << outVal[i] << std::endl; 94 // solve for the derivatives acc. to A * dx = r with r=db - dA * x 95 // compute the RHS 96 double* r=xNew<double>(m); 97 for (int i=0; i<m; i++) { 98 r[i]=inDeriv[m*m+i]; // this is db[i] 99 for (int j=0;j<m; j++) { 100 r[i]-=inDeriv[i*m+j]*outVal[j]; // this is dA[i][j]*x[j] 101 } 102 } 103 gsl_vector_view gsl_r=gsl_vector_view_array(r,m); 104 gsl_vector *gsl_dx_p = gsl_vector_alloc(m); 105 gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_r.vector, gsl_dx_p); 106 xMemCpy(outDeriv,gsl_vector_ptr(gsl_dx_p,0),m); 107 gsl_vector_free(gsl_dx_p); 108 xDelete(r); 109 gsl_permutation_free(perm_p); 110 xDelete(Acopy); 111 #endif 112 return 0; 111 113 } /*}}}*/ 112 114 int EDF_fov_forward_for_solverx(int n, IssmPDouble *inVal, int directionCount, IssmPDouble **inDeriv, int m, IssmPDouble *outVal, IssmPDouble **outDeriv) { /*{{{*/ 113 115 #ifdef _HAVE_GSL_ 114 // the matrix will be modified by LU decomposition. Use gsl_A copy 115 double* Acopy = xNew<double>(m*m); 116 xMemCpy(Acopy,inVal,m*m); 117 /*Initialize gsl matrices and vectors: */ 118 gsl_matrix_view gsl_A = gsl_matrix_view_array (Acopy,m,m); 119 gsl_vector_view gsl_b = gsl_vector_view_array (inVal+m*m,m); // the right hand side starts at address inVal+m*m 120 gsl_permutation *perm_p = gsl_permutation_alloc (m); 121 int signPerm; 122 // factorize 123 gsl_linalg_LU_decomp (&gsl_A.matrix, perm_p, &signPerm); 124 gsl_vector *gsl_x_p = gsl_vector_alloc (m); 125 // solve for the value 126 gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_b.vector, gsl_x_p); 127 /*Copy result*/ 128 xMemCpy(outVal,gsl_vector_ptr(gsl_x_p,0),m); 129 gsl_vector_free(gsl_x_p); 130 // solve for the derivatives acc. to A * dx = r with r=db - dA * x 131 double* r=xNew<double>(m); 132 gsl_vector *gsl_dx_p = gsl_vector_alloc(m); 133 for (int dir=0;dir<directionCount;++dir) { 134 // compute the RHS 135 for (int i=0; i<m; i++) { 136 r[i]=inDeriv[m*m+i][dir]; // this is db[i] 137 for (int j=0;j<m; j++) { 138 r[i]-=inDeriv[i*m+j][dir]*outVal[j]; // this is dA[i][j]*x[j] 139 } 140 } 141 gsl_vector_view gsl_r=gsl_vector_view_array(r,m); 142 gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_r.vector, gsl_dx_p); 143 // reuse r 144 xMemCpy(r,gsl_vector_ptr(gsl_dx_p,0),m); 145 for (int i=0; i<m; i++) { 146 outDeriv[i][dir]=r[i]; 147 } 148 } 149 gsl_vector_free(gsl_dx_p); 150 xDelete(r); 151 gsl_permutation_free(perm_p); 152 xDelete(Acopy); 153 #endif 154 return 0; 155 } 156 /*}}}*/ 157 int EDF_fos_reverse_for_solverx(int m, double *dp_U, int n, double *dp_Z) { /*{{{*/ 158 return 0; 116 // the matrix will be modified by LU decomposition. Use gsl_A copy 117 double* Acopy = xNew<double>(m*m); 118 xMemCpy(Acopy,inVal,m*m); 119 /*Initialize gsl matrices and vectors: */ 120 gsl_matrix_view gsl_A = gsl_matrix_view_array (Acopy,m,m); 121 gsl_vector_view gsl_b = gsl_vector_view_array (inVal+m*m,m); // the right hand side starts at address inVal+m*m 122 gsl_permutation *perm_p = gsl_permutation_alloc (m); 123 int signPerm; 124 // factorize 125 gsl_linalg_LU_decomp (&gsl_A.matrix, perm_p, &signPerm); 126 gsl_vector *gsl_x_p = gsl_vector_alloc (m); 127 // solve for the value 128 gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_b.vector, gsl_x_p); 129 /*Copy result*/ 130 xMemCpy(outVal,gsl_vector_ptr(gsl_x_p,0),m); 131 gsl_vector_free(gsl_x_p); 132 // solve for the derivatives acc. to A * dx = r with r=db - dA * x 133 double* r=xNew<double>(m); 134 gsl_vector *gsl_dx_p = gsl_vector_alloc(m); 135 for (int dir=0;dir<directionCount;++dir) { 136 // compute the RHS 137 for (int i=0; i<m; i++) { 138 r[i]=inDeriv[m*m+i][dir]; // this is db[i] 139 for (int j=0;j<m; j++) { 140 r[i]-=inDeriv[i*m+j][dir]*outVal[j]; // this is dA[i][j]*x[j] 141 } 142 } 143 gsl_vector_view gsl_r=gsl_vector_view_array(r,m); 144 gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_r.vector, gsl_dx_p); 145 // reuse r 146 xMemCpy(r,gsl_vector_ptr(gsl_dx_p,0),m); 147 for (int i=0; i<m; i++) { 148 outDeriv[i][dir]=r[i]; 149 } 150 } 151 gsl_vector_free(gsl_dx_p); 152 xDelete(r); 153 gsl_permutation_free(perm_p); 154 xDelete(Acopy); 155 #endif 156 return 0; 157 } 158 /*}}}*/ 159 int EDF_fos_reverse_for_solverx(int m, double *dp_U, int n, double *dp_Z, double* dp_x, double* dp_y) { /*{{{*/ 160 // copy to transpose the matrix 161 double* transposed=xNew<double>(m*m); 162 for (int i=0; i<m; ++i) for (int j=0; j<m; ++j) transposed[j*m+i]=dp_x[i*m+j]; 163 gsl_matrix_view aTransposed = gsl_matrix_view_array (transposed,m,m); 164 // the adjoint of the solution is our right-hand side 165 gsl_vector_view x_bar=gsl_vector_view_array(dp_U,m); 166 // the last m elements of dp_Z representing the adjoint of the right-hand side we want to compute: 167 gsl_vector_view b_bar=gsl_vector_view_array(dp_Z+m*m,m); 168 gsl_permutation *perm_p = gsl_permutation_alloc (m); 169 int permSign; 170 gsl_linalg_LU_decomp (&aTransposed.matrix, perm_p, &permSign); 171 gsl_linalg_LU_solve (&aTransposed.matrix, perm_p, &x_bar.vector, &b_bar.vector); 172 // now do the adjoint of the matrix 173 for (int i=0; i<m; ++i) for (int j=0; j<m; ++j) dp_Z[i*m+j]-=dp_Z[m*m+i]*dp_y[j]; 174 gsl_permutation_free(perm_p); 175 xDelete(transposed); 176 return 0; 177 } 178 /*}}}*/ 179 int EDF_fov_reverse_for_solverx(int m, int p, double **dpp_U, int n, double **dpp_Z, double* dp_x, double* dp_y) { /*{{{*/ 180 // copy to transpose the matrix 181 double* transposed=xNew<double>(m*m); 182 for (int i=0; i<m; ++i) for (int j=0; j<m; ++j) transposed[j*m+i]=dp_x[i*m+j]; 183 gsl_matrix_view aTransposed = gsl_matrix_view_array (transposed,m,m); 184 gsl_permutation *perm_p = gsl_permutation_alloc (m); 185 int permSign; 186 gsl_linalg_LU_decomp (&aTransposed.matrix, perm_p, &permSign); 187 for (int weightsRowIndex=0;weightsRowIndex<p;++weightsRowIndex) { 188 // the adjoint of the solution is our right-hand side 189 gsl_vector_view x_bar=gsl_vector_view_array(dpp_U[weightsRowIndex],m); 190 // the last m elements of dp_Z representing the adjoint of the right-hand side we want to compute: 191 gsl_vector_view b_bar=gsl_vector_view_array(dpp_Z[weightsRowIndex]+m*m,m); 192 gsl_linalg_LU_solve (&aTransposed.matrix, perm_p, &x_bar.vector, &b_bar.vector); 193 // now do the adjoint of the matrix 194 for (int i=0; i<m; ++i) for (int j=0; j<m; ++j) dpp_Z[weightsRowIndex][i*m+j]-=dpp_Z[weightsRowIndex][m*m+i]*dp_y[j]; 195 } 196 gsl_permutation_free(perm_p); 197 xDelete(transposed); 198 return 0; 159 199 } 160 200 /*}}}*/ 161 201 void SolverxSeq(IssmDouble *X,IssmDouble *A,IssmDouble *B,int n, Parameters* parameters){/*{{{*/ 162 202 // pack inputs to conform to the EDF-prescribed interface 203 // ensure a contiguous block of locations: 204 ensureContiguousLocations(n*(n+1)); 163 205 IssmDouble* adoubleEDFin=xNew<IssmDouble>(n*(n+1)); // packed inputs, i.e. matrix and right hand side 164 206 for(int i=0; i<n*n;i++)adoubleEDFin[i] =A[i]; // pack matrix … … 170 212 n*(n+1), pdoubleEDFin, adoubleEDFin, 171 213 n, pdoubleEDFout,X); 214 // for(int i=0; i<n; i++) {ADOLC_DUMP_MACRO(X[i]);} 172 215 xDelete(adoubleEDFin); 173 216 xDelete(pdoubleEDFin); … … 181 224 int s; 182 225 gsl_matrix_view a; 183 gsl_vector_view b; 184 gsl_vector *x = NULL; 226 gsl_vector_view b,x; 185 227 gsl_permutation *p = NULL; 228 // for (int i=0; i<n*n; ++i) std::cout << "SolverxSeq A["<< i << "]=" << A[i] << std::endl; 229 // for (int i=0; i<n; ++i) std::cout << "SolverxSeq b["<< i << "]=" << B[i] << std::endl; 186 230 /*A will be modified by LU decomposition. Use copy*/ 187 231 double* Acopy = xNew<double>(n*n); … … 191 235 a = gsl_matrix_view_array (Acopy,n,n); 192 236 b = gsl_vector_view_array (B,n); 193 x = gsl_vector_ alloc (n);237 x = gsl_vector_view_array (X,n); 194 238 195 239 /*Run LU and solve: */ 196 240 p = gsl_permutation_alloc (n); 197 241 gsl_linalg_LU_decomp (&a.matrix, p, &s); 198 gsl_linalg_LU_solve (&a.matrix, p, &b.vector, x); 199 200 //printf ("x = \n"); 201 //gsl_vector_fprintf (stdout, x, "%g"); 202 203 /*Copy result*/ 204 xMemCpy(X,gsl_vector_ptr(x,0),n); 242 gsl_linalg_LU_solve (&a.matrix, p, &b.vector, &x.vector); 205 243 206 244 /*Clean up and assign output pointer*/ 207 245 xDelete(Acopy); 208 246 gsl_permutation_free(p); 209 gsl_vector_free(x); 210 #endif 211 } 212 /*}}}*/ 247 #endif 248 } 249 /*}}}*/ -
issm/trunk/src/c/modules/SpcNodesx/SpcNodesx.cpp
r9298 r13975 13 13 14 14 for(int i=0;i<constraints->Size();i++){ 15 15 16 16 Constraint* constraint=(Constraint*)constraints->GetObjectByOffset(i); 17 17 -
issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp
r13395 r13975 19 19 if(stage==1){ 20 20 if (strcmp(name,"AutodiffIsautodiff")==0) return AutodiffIsautodiffEnum; 21 else if (strcmp(name,"AutodiffDependents")==0) return AutodiffDependentsEnum;22 21 else if (strcmp(name,"AutodiffNumDependents")==0) return AutodiffNumDependentsEnum; 23 else if (strcmp(name,"AutodiffIndependents")==0) return AutodiffIndependentsEnum; 22 else if (strcmp(name,"AutodiffNumDependentObjects")==0) return AutodiffNumDependentObjectsEnum; 23 else if (strcmp(name,"AutodiffDependentObjectNames")==0) return AutodiffDependentObjectNamesEnum; 24 else if (strcmp(name,"AutodiffDependentObjectTypes")==0) return AutodiffDependentObjectTypesEnum; 25 else if (strcmp(name,"AutodiffDependentObjectIndices")==0) return AutodiffDependentObjectIndicesEnum; 26 else if (strcmp(name,"AutodiffDependentObjects")==0) return AutodiffDependentObjectsEnum; 24 27 else if (strcmp(name,"AutodiffNumIndependents")==0) return AutodiffNumIndependentsEnum; 28 else if (strcmp(name,"AutodiffNumIndependentObjects")==0) return AutodiffNumIndependentObjectsEnum; 29 else if (strcmp(name,"AutodiffIndependentObjectNames")==0) return AutodiffIndependentObjectNamesEnum; 30 else if (strcmp(name,"AutodiffIndependentObjectTypes")==0) return AutodiffIndependentObjectTypesEnum; 31 else if (strcmp(name,"AutodiffIndependentObjects")==0) return AutodiffIndependentObjectsEnum; 25 32 else if (strcmp(name,"AutodiffJacobian")==0) return AutodiffJacobianEnum; 26 33 else if (strcmp(name,"AutodiffXp")==0) return AutodiffXpEnum; 27 else if (strcmp(name,"AutodiffFosForwardOutput")==0) return AutodiffFosForwardOutputEnum; 34 else if (strcmp(name,"AutodiffDriver")==0) return AutodiffDriverEnum; 35 else if (strcmp(name,"AutodiffFosForwardIndex")==0) return AutodiffFosForwardIndexEnum; 36 else if (strcmp(name,"AutodiffFovForwardIndices")==0) return AutodiffFovForwardIndicesEnum; 37 else if (strcmp(name,"AutodiffFosReverseIndex")==0) return AutodiffFosReverseIndexEnum; 38 else if (strcmp(name,"AutodiffMassFluxSegmentsPresent")==0) return AutodiffMassFluxSegmentsPresentEnum; 39 else if (strcmp(name,"AutodiffKeep")==0) return AutodiffKeepEnum; 28 40 else if (strcmp(name,"BalancethicknessSpcthickness")==0) return BalancethicknessSpcthicknessEnum; 29 41 else if (strcmp(name,"BalancethicknessStabilization")==0) return BalancethicknessStabilizationEnum; … … 37 49 else if (strcmp(name,"ConstantsReferencetemperature")==0) return ConstantsReferencetemperatureEnum; 38 50 else if (strcmp(name,"ConstantsYts")==0) return ConstantsYtsEnum; 51 else if (strcmp(name,"DependentObject")==0) return DependentObjectEnum; 39 52 else if (strcmp(name,"DiagnosticAbstol")==0) return DiagnosticAbstolEnum; 40 53 else if (strcmp(name,"DiagnosticIcefront")==0) return DiagnosticIcefrontEnum; … … 76 89 else if (strcmp(name,"HydrologySpcwatercolumn")==0) return HydrologySpcwatercolumnEnum; 77 90 else if (strcmp(name,"HydrologyStabilization")==0) return HydrologyStabilizationEnum; 91 else if (strcmp(name,"IndependentObject")==0) return IndependentObjectEnum; 78 92 else if (strcmp(name,"InversionControlParameters")==0) return InversionControlParametersEnum; 79 93 else if (strcmp(name,"InversionCostFunction")==0) return InversionCostFunctionEnum; … … 124 138 else if (strcmp(name,"MeshDimension")==0) return MeshDimensionEnum; 125 139 else if (strcmp(name,"MeshEdges")==0) return MeshEdgesEnum; 126 else if (strcmp(name,"MeshElementconnectivity")==0) return MeshElementconnectivityEnum; 140 else stage=2; 141 } 142 if(stage==2){ 143 if (strcmp(name,"MeshElementconnectivity")==0) return MeshElementconnectivityEnum; 127 144 else if (strcmp(name,"MeshElementonbed")==0) return MeshElementonbedEnum; 128 145 else if (strcmp(name,"MeshElementonsurface")==0) return MeshElementonsurfaceEnum; … … 138 155 else if (strcmp(name,"MeshUpperelements")==0) return MeshUpperelementsEnum; 139 156 else if (strcmp(name,"MeshVertexonbed")==0) return MeshVertexonbedEnum; 140 else stage=2; 141 } 142 if(stage==2){ 143 if (strcmp(name,"MeshVertexonsurface")==0) return MeshVertexonsurfaceEnum; 157 else if (strcmp(name,"MeshVertexonsurface")==0) return MeshVertexonsurfaceEnum; 144 158 else if (strcmp(name,"MeshX")==0) return MeshXEnum; 145 159 else if (strcmp(name,"MeshY")==0) return MeshYEnum; … … 152 166 else if (strcmp(name,"PrognosticStabilization")==0) return PrognosticStabilizationEnum; 153 167 else if (strcmp(name,"PrognosticVertexPairing")==0) return PrognosticVertexPairingEnum; 168 else if (strcmp(name,"PrognosticNumRequestedOutputs")==0) return PrognosticNumRequestedOutputsEnum; 169 else if (strcmp(name,"PrognosticRequestedOutputs")==0) return PrognosticRequestedOutputsEnum; 154 170 else if (strcmp(name,"QmuIsdakota")==0) return QmuIsdakotaEnum; 155 else if (strcmp(name,"QmuMassFluxSegments")==0) return QmuMassFluxSegmentsEnum; 171 else if (strcmp(name,"MassFluxSegments")==0) return MassFluxSegmentsEnum; 172 else if (strcmp(name,"MassFluxSegmentsPresent")==0) return MassFluxSegmentsPresentEnum; 173 else if (strcmp(name,"QmuMassFluxSegmentsPresent")==0) return QmuMassFluxSegmentsPresentEnum; 156 174 else if (strcmp(name,"QmuNumberofpartitions")==0) return QmuNumberofpartitionsEnum; 157 175 else if (strcmp(name,"QmuNumberofresponses")==0) return QmuNumberofresponsesEnum; … … 188 206 else if (strcmp(name,"SurfaceforcingsMonthlytemperatures")==0) return SurfaceforcingsMonthlytemperaturesEnum; 189 207 else if (strcmp(name,"SurfaceforcingsHc")==0) return SurfaceforcingsHcEnum; 208 else if (strcmp(name,"SurfaceforcingsHref")==0) return SurfaceforcingsHrefEnum; 209 else if (strcmp(name,"SurfaceforcingsSmbref")==0) return SurfaceforcingsSmbrefEnum; 190 210 else if (strcmp(name,"SurfaceforcingsSmbPosMax")==0) return SurfaceforcingsSmbPosMaxEnum; 191 211 else if (strcmp(name,"SurfaceforcingsSmbPosMin")==0) return SurfaceforcingsSmbPosMinEnum; … … 241 261 else if (strcmp(name,"PrognosticSolution")==0) return PrognosticSolutionEnum; 242 262 else if (strcmp(name,"SteadystateSolution")==0) return SteadystateSolutionEnum; 243 else if (strcmp(name,"SurfaceSlopeAnalysis")==0) return SurfaceSlopeAnalysisEnum; 263 else stage=3; 264 } 265 if(stage==3){ 266 if (strcmp(name,"SurfaceSlopeAnalysis")==0) return SurfaceSlopeAnalysisEnum; 244 267 else if (strcmp(name,"SurfaceSlopeSolution")==0) return SurfaceSlopeSolutionEnum; 245 268 else if (strcmp(name,"SurfaceSlopeXAnalysis")==0) return SurfaceSlopeXAnalysisEnum; … … 261 284 else if (strcmp(name,"Loads")==0) return LoadsEnum; 262 285 else if (strcmp(name,"Materials")==0) return MaterialsEnum; 263 else stage=3; 264 } 265 if(stage==3){ 266 if (strcmp(name,"Nodes")==0) return NodesEnum; 286 else if (strcmp(name,"Nodes")==0) return NodesEnum; 267 287 else if (strcmp(name,"Parameters")==0) return ParametersEnum; 268 288 else if (strcmp(name,"Vertices")==0) return VerticesEnum; … … 277 297 else if (strcmp(name,"DofIndexing")==0) return DofIndexingEnum; 278 298 else if (strcmp(name,"DoubleInput")==0) return DoubleInputEnum; 299 else if (strcmp(name,"DataSetParam")==0) return DataSetParamEnum; 279 300 else if (strcmp(name,"DoubleMatArrayParam")==0) return DoubleMatArrayParamEnum; 280 301 else if (strcmp(name,"DoubleMatParam")==0) return DoubleMatParamEnum; … … 306 327 else if (strcmp(name,"Penta")==0) return PentaEnum; 307 328 else if (strcmp(name,"PentaP1Input")==0) return PentaP1InputEnum; 329 else if (strcmp(name,"Profiler")==0) return ProfilerEnum; 308 330 else if (strcmp(name,"MatrixParam")==0) return MatrixParamEnum; 309 331 else if (strcmp(name,"VectorParam")==0) return VectorParamEnum; … … 362 384 else if (strcmp(name,"SurfaceAbsVelMisfit")==0) return SurfaceAbsVelMisfitEnum; 363 385 else if (strcmp(name,"SurfaceArea")==0) return SurfaceAreaEnum; 364 else if (strcmp(name,"SurfaceAverageVelMisfit")==0) return SurfaceAverageVelMisfitEnum; 386 else stage=4; 387 } 388 if(stage==4){ 389 if (strcmp(name,"SurfaceAverageVelMisfit")==0) return SurfaceAverageVelMisfitEnum; 365 390 else if (strcmp(name,"SurfaceLogVelMisfit")==0) return SurfaceLogVelMisfitEnum; 366 391 else if (strcmp(name,"SurfaceLogVxVyMisfit")==0) return SurfaceLogVxVyMisfitEnum; … … 384 409 else if (strcmp(name,"VyPicard")==0) return VyPicardEnum; 385 410 else if (strcmp(name,"Vz")==0) return VzEnum; 386 else stage=4; 387 } 388 if(stage==4){ 389 if (strcmp(name,"VzMacAyeal")==0) return VzMacAyealEnum; 411 else if (strcmp(name,"VzMacAyeal")==0) return VzMacAyealEnum; 390 412 else if (strcmp(name,"VzPattyn")==0) return VzPattynEnum; 391 413 else if (strcmp(name,"VzPicard")==0) return VzPicardEnum; … … 477 499 else if (strcmp(name,"OldGradient")==0) return OldGradientEnum; 478 500 else if (strcmp(name,"OutputFilePointer")==0) return OutputFilePointerEnum; 501 else if (strcmp(name,"OutputFileName")==0) return OutputFileNameEnum; 502 else if (strcmp(name,"LockFileName")==0) return LockFileNameEnum; 479 503 else if (strcmp(name,"PetscOptionsAnalyses")==0) return PetscOptionsAnalysesEnum; 480 504 else if (strcmp(name,"PetscOptionsStrings")==0) return PetscOptionsStringsEnum; … … 483 507 else if (strcmp(name,"QmuOutName")==0) return QmuOutNameEnum; 484 508 else if (strcmp(name,"Regular")==0) return RegularEnum; 485 else if (strcmp(name,"Scaled")==0) return ScaledEnum; 509 else stage=5; 510 } 511 if(stage==5){ 512 if (strcmp(name,"Scaled")==0) return ScaledEnum; 486 513 else if (strcmp(name,"Separate")==0) return SeparateEnum; 487 514 else if (strcmp(name,"Sset")==0) return SsetEnum; … … 501 528 else if (strcmp(name,"Paterson")==0) return PatersonEnum; 502 529 else if (strcmp(name,"Arrhenius")==0) return ArrheniusEnum; 503 else stage= 5;530 else stage=6; 504 531 } 505 532 /*If we reach this point, the string provided has not been found*/ -
issm/trunk/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp
r13395 r13975 22 22 /*Compute Misfit: */ 23 23 for (i=0;i<elements->Size();i++){ 24 element= (Element*)elements->GetObjectByOffset(i);24 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 25 25 J+=element->SurfaceAbsVelMisfit(process_units,weight_index); 26 26 } … … 28 28 /*Sum all J from all cpus of the cluster:*/ 29 29 #ifdef _HAVE_MPI_ 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0, MPI_COMM_WORLD);31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0, MPI_COMM_WORLD);30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 32 32 J=J_sum; 33 33 #endif -
issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.cpp
r12706 r13975 12 12 13 13 void SurfaceAreax( IssmDouble* pS, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters){ 14 14 15 15 /*Intermediary*/ 16 16 Element* element=NULL; … … 20 20 IssmDouble S=0; 21 21 IssmDouble S_sum; 22 22 23 23 /*Compute gradients: */ 24 24 for (i=0;i<elements->Size();i++){ 25 element= (Element*)elements->GetObjectByOffset(i);25 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 26 26 S+=element->SurfaceArea(); 27 27 } … … 29 29 /*Sum all J from all cpus of the cluster:*/ 30 30 #ifdef _HAVE_MPI_ 31 MPI_Reduce (&S,&S_sum,1,MPI_DOUBLE,MPI_SUM,0, MPI_COMM_WORLD);32 MPI_Bcast(&S_sum,1,MPI_DOUBLE,0, MPI_COMM_WORLD);31 MPI_Reduce (&S,&S_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 32 MPI_Bcast(&S_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 33 33 S=S_sum; 34 34 #endif -
issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.h
r13395 r13975 13 13 14 14 #endif /* _SURFACEAREAX_H */ 15 -
issm/trunk/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp
r13395 r13975 26 26 /*Compute Misfit: */ 27 27 for (i=0;i<elements->Size();i++){ 28 element= (Element*)elements->GetObjectByOffset(i);28 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 29 29 J+=element->SurfaceAverageVelMisfit(process_units,weight_index); 30 30 } … … 32 32 /*Sum all J from all cpus of the cluster:*/ 33 33 #ifdef _HAVE_MPI_ 34 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0, MPI_COMM_WORLD);35 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0, MPI_COMM_WORLD);34 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 35 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 36 36 J=J_sum; 37 37 #endif -
issm/trunk/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp
r13395 r13975 22 22 /*Compute Misfit: */ 23 23 for (i=0;i<elements->Size();i++){ 24 element= (Element*)elements->GetObjectByOffset(i);24 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 25 25 J+=element->SurfaceLogVelMisfit(process_units,weight_index); 26 26 } … … 28 28 /*Sum all J from all cpus of the cluster:*/ 29 29 #ifdef _HAVE_MPI_ 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0, MPI_COMM_WORLD);31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0, MPI_COMM_WORLD);30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 32 32 J=J_sum; 33 33 #endif -
issm/trunk/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp
r13395 r13975 22 22 /*Compute Misfit: */ 23 23 for (i=0;i<elements->Size();i++){ 24 element= (Element*)elements->GetObjectByOffset(i);24 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 25 25 J+=element->SurfaceLogVxVyMisfit(process_units,weight_index); 26 26 } … … 28 28 /*Sum all J from all cpus of the cluster:*/ 29 29 #ifdef _HAVE_MPI_ 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0, MPI_COMM_WORLD);31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0, MPI_COMM_WORLD);30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 32 32 J=J_sum; 33 33 #endif -
issm/trunk/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp
r13395 r13975 22 22 /*Compute Misfit: */ 23 23 for (i=0;i<elements->Size();i++){ 24 element= (Element*)elements->GetObjectByOffset(i);24 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 25 25 J+=element->SurfaceRelVelMisfit(process_units,weight_index); 26 26 } … … 28 28 /*Sum all J from all cpus of the cluster:*/ 29 29 #ifdef _HAVE_MPI_ 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0, MPI_COMM_WORLD);31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0, MPI_COMM_WORLD);30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 32 32 J=J_sum; 33 33 #endif -
issm/trunk/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp
r13395 r13975 22 22 /*Compute Misfit: */ 23 23 for (i=0;i<elements->Size();i++){ 24 element= (Element*)elements->GetObjectByOffset(i);24 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 25 25 J+=element->ThicknessAbsMisfit(process_units,weight_index); 26 26 } … … 28 28 /*Sum all J from all cpus of the cluster:*/ 29 29 #ifdef _HAVE_MPI_ 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0, MPI_COMM_WORLD);31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0, MPI_COMM_WORLD);30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 32 32 J=J_sum; 33 33 #endif -
issm/trunk/src/c/modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp
r13395 r13975 22 22 /*Compute Misfit: */ 23 23 for (i=0;i<elements->Size();i++){ 24 element= (Element*)elements->GetObjectByOffset(i);24 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 25 25 J+=element->ThicknessAcrossGradient(process_units,weight_index); 26 26 } … … 28 28 /*Sum all J from all cpus of the cluster:*/ 29 29 #ifdef _HAVE_MPI_ 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0, MPI_COMM_WORLD);31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0, MPI_COMM_WORLD);30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 32 32 J=J_sum; 33 33 #endif -
issm/trunk/src/c/modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp
r13395 r13975 22 22 /*Compute Misfit: */ 23 23 for (i=0;i<elements->Size();i++){ 24 element= (Element*)elements->GetObjectByOffset(i);24 element=dynamic_cast<Element*>(elements->GetObjectByOffset(i)); 25 25 J+=element->ThicknessAlongGradient(process_units,weight_index); 26 26 } … … 28 28 /*Sum all J from all cpus of the cluster:*/ 29 29 #ifdef _HAVE_MPI_ 30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0, MPI_COMM_WORLD);31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0, MPI_COMM_WORLD);30 MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() ); 31 MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 32 32 J=J_sum; 33 33 #endif -
issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp
r13395 r13975 11 11 #include "../../EnumDefinitions/EnumDefinitions.h" 12 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" 13 #if defined(_HAVE_TRIANGLE_) 14 #ifndef ANSI_DECLARATORS 15 #define ANSI_DECLARATORS 16 #include "triangle.h" 17 #undef ANSI_DECLARATORS 18 #else 19 #include "triangle.h" 20 #endif 19 21 #endif 20 22 /*}}}*/ … … 22 24 void TriMeshx(SeqMat<IssmPDouble>** pindex,SeqVec<IssmPDouble>** px,SeqVec<IssmPDouble>** py,SeqMat<IssmPDouble>** psegments,SeqVec<IssmPDouble>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area){ 23 25 26 #if !defined(_HAVE_TRIANGLE_) 27 _error_("triangle has not been installed"); 28 #else 24 29 /*indexing: */ 25 30 int i,j; … … 76 81 } 77 82 } 78 83 79 84 /*fill in the point attribute list: */ 80 85 in.pointattributelist = xNew<REAL>(in.numberofpoints*in.numberofpointattributes); 81 86 for (i=0;i<in.numberofpoints;i++) in.pointattributelist[i] = 0.0; 82 87 83 88 /*fill in the point marker list: */ 84 89 in.pointmarkerlist = xNew<int>(in.numberofpoints); … … 96 101 in.numberofsegments+=contour->nods-1; 97 102 } 98 103 99 104 in.segmentlist = xNew<int>(in.numberofsegments*2); 100 105 in.segmentmarkerlist = xNewZeroInit<int>(in.numberofsegments); … … 128 133 counter++; 129 134 } 130 135 131 136 /*Build regions: */ 132 137 in.numberofregions = 0; … … 194 199 index_matrix=new SeqMat<IssmPDouble>(index,out.numberoftriangles,3,1.0); 195 200 *pindex=index_matrix; 196 201 197 202 segments_matrix=new SeqMat<IssmPDouble>(segments,out.numberofsegments,3,1.0); 198 203 *psegments=segments_matrix; … … 201 206 *py=new SeqVec<IssmPDouble>(y,out.numberofpoints); 202 207 *psegmentmarkerlist=new SeqVec<IssmPDouble>(segmentmarkerlist,out.numberofsegments); 208 #endif 203 209 } -
issm/trunk/src/c/modules/TriMeshx/TriMeshx.h
r13395 r13975 6 6 #define _TRIMESHX_H_ 7 7 8 #include "string.h"8 #include <string.h> 9 9 #include "../../Container/Container.h" 10 10 #include "../../classes/objects/objects.h" -
issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.cpp
r13395 r13975 24 24 R2 r; 25 25 I2 I; 26 int i,j,k; 27 int i0,i1,i2; 28 double areacoord[3]; 29 double aa,bb; 30 double data_value; 26 int i; 31 27 Icoor2 dete[3]; 32 int verbose=0;33 28 34 / / read background mesh29 /* read background mesh */ 35 30 Mesh Th(index,x,y,nods,nel); 36 31 Th.CreateSingleVertexToTriangleConnectivity(); … … 40 35 //Get current point coordinates 41 36 r.x=x0[i]; r.y=y0[i]; 42 37 43 38 I=Th.R2ToI2(r); 44 39 -
issm/trunk/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp
r13395 r13975 11 11 12 12 void UpdateDynamicConstraintsx(Constraints* constraints,Nodes* nodes,Parameters* parameters,Vector<IssmDouble>* yg){ 13 13 14 14 int configuration_type; 15 15 IssmDouble* yg_serial=NULL; -
issm/trunk/src/c/modules/VecMergex/VecMergex.cpp
r13395 r13975 18 18 /*retrieve parameters: */ 19 19 parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 20 20 21 21 /*serialize uf: */ 22 22 uf_serial=uf->ToMPISerial(); 23 24 23 25 24 /*Do we have any nodes for this configuration? :*/ -
issm/trunk/src/c/modules/VerticesDofx/VerticesDofx.cpp
r6232 r13975 11 11 void VerticesDofx( Vertices* vertices, Parameters* parameters) { 12 12 13 int i;14 15 int found=0;16 extern int num_procs;17 extern int my_rank;18 19 13 /*intermediary: */ 20 14 int numberofvertices; … … 23 17 numberofvertices=vertices->NumberOfVertices(); 24 18 25 /*Ensure that only for each cpu, the partition border vertices only will be taken into account once 26 * across the cluster. To do so, we flag all the clone vertices: */ 19 /*Ensure that only for each cpu, the partition border vertices only will be 20 * taken into account once across the cluster. To do so, we flag all the 21 * clone vertices: */ 27 22 vertices->FlagClones(numberofvertices); 28 23 29 /*Go through all vertices and distribute 1 dof at a time. When a vertex has already been distributed his dof on a cpu, 30 * all other cpus with the same vertex cannot distribute it anymore. Use clone field to be sure of that: */ 31 vertices->DistributeDofs(numberofvertices,1); //only 1 dof per vertex. 24 /*Go through all vertices and distribute pids*/ 25 vertices->DistributePids(numberofvertices); 32 26 33 27 } -
issm/trunk/src/c/modules/VerticesDofx/VerticesDofx.h
r13395 r13975 13 13 14 14 #endif /* _VERTICESDOFX_H */ 15 -
issm/trunk/src/c/modules/modules.h
r13395 r13975 7 7 8 8 /*Modules: */ 9 #include "./AddExternalResultx/AddExternalResultx.h"10 #include "./AutodiffDriversx/AutodiffDriversx.h"11 9 #include "./AverageFilterx/AverageFilterx.h" 12 10 #include "./AverageOntoPartitionx/AverageOntoPartitionx.h" … … 23 21 #include "./ControlInputSetGradientx/ControlInputSetGradientx.h" 24 22 #include "./ControlInputScaleGradientx/ControlInputScaleGradientx.h" 25 #include "./CostFunctionx/CostFunctionx.h"26 23 #include "./CreateNodalConstraintsx/CreateNodalConstraintsx.h" 27 #include "./DakotaResponsesx/DakotaResponsesx.h"28 24 #include "./Delta18oParameterizationx/Delta18oParameterizationx.h" 29 25 #include "./DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.h" … … 38 34 #include "./GroundinglineMigrationx/GroundinglineMigrationx.h" 39 35 #include "./HoleFillerx/HoleFillerx.h" 40 #include "./TotalSmbx/TotalSmbx.h"41 #include "./IceVolumex/IceVolumex.h"42 36 #include "./InputControlUpdatex/InputControlUpdatex.h" 43 37 #include "./InputConvergencex/InputConvergencex.h" … … 67 61 #include "./Krigingx/Krigingx.h" 68 62 #include "./Shp2Kmlx/Shp2Kmlx.h" 69 #include "./MassFluxx/MassFluxx.h"70 #include "./MaxAbsVxx/MaxAbsVxx.h"71 #include "./MaxAbsVyx/MaxAbsVyx.h"72 #include "./MaxAbsVzx/MaxAbsVzx.h"73 #include "./MaxVelx/MaxVelx.h"74 #include "./ElementResponsex/ElementResponsex.h"75 #include "./MaxVxx/MaxVxx.h"76 #include "./MaxVyx/MaxVyx.h"77 #include "./MaxVzx/MaxVzx.h"78 63 #include "./Mergesolutionfromftogx/Mergesolutionfromftogx.h" 79 64 #include "./MeshPartitionx/MeshPartitionx.h" 80 65 #include "./MeshProfileIntersectionx/MeshProfileIntersectionx.h" 81 #include "./MinVelx/MinVelx.h"82 #include "./MinVxx/MinVxx.h"83 #include "./MinVyx/MinVyx.h"84 #include "./MinVzx/MinVzx.h"85 66 #include "./SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.h" 86 67 #include "./SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.h" … … 99 80 #include "./PositiveDegreeDayx/PositiveDegreeDayx.h" 100 81 #include "./PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h" 101 #include "./Dakotax/Dakotax.h"102 82 #include "./Reduceloadx/Reduceloadx.h" 103 83 #include "./Reducevectorgtosx/Reducevectorgtosx.h" 104 84 #include "./Reducevectorgtofx/Reducevectorgtofx.h" 105 #include "./RequestedOutputsx/RequestedOutputsx.h"106 #include "./RequestedDependentsx/RequestedDependentsx.h"107 85 #include "./ResetConstraintsx/ResetConstraintsx.h" 108 86 #include "./ResetCoordinateSystemx/ResetCoordinateSystemx.h" 109 #include "./Responsex/Responsex.h"110 87 #include "./RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h" 111 88 #include "./Scotchx/Scotchx.h" … … 114 91 #include "./SpcNodesx/SpcNodesx.h" 115 92 #include "./SurfaceAreax/SurfaceAreax.h" 116 #include "./SystemMatricesx/SystemMatricesx.h"117 #include "./CreateJacobianMatrixx/CreateJacobianMatrixx.h"118 #include "./TimeAdaptx/TimeAdaptx.h"119 93 #include "./TriaSearchx/TriaSearchx.h" 120 94 #include "./TriMeshx/TriMeshx.h" 95 #include "./TriMeshProcessRiftsx/TriMeshProcessRiftsx.h" 121 96 #include "./ThicknessAbsMisfitx/ThicknessAbsMisfitx.h" 122 #include "./ThicknessAbsGradientx/ThicknessAbsGradientx.h"123 97 #include "./ThicknessAlongGradientx/ThicknessAlongGradientx.h" 124 98 #include "./ThicknessAcrossGradientx/ThicknessAcrossGradientx.h" 125 #include "./UpdateVertexPositionsx/UpdateVertexPositionsx.h"126 #include "./UpdateConstraintsx/UpdateConstraintsx.h"127 99 #include "./UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.h" 128 100 #include "./VerticesDofx/VerticesDofx.h" -
issm/trunk/src/c/shared/Alloc/alloc.cpp
r13395 r13975 11 11 * the allocation routines described here do not work. 12 12 */ 13 14 13 15 14 #ifdef HAVE_CONFIG_H … … 28 27 29 28 void xdelete(Matrix<IssmDouble>** pv){ 30 29 31 30 if (pv && *pv){ 32 31 /*There is no mxDelete in the Matlab API -> using delete trips up Matlab. So we -
issm/trunk/src/c/shared/Alloc/xNewDelete.h
r13395 r13975 8 8 #include <cassert> 9 9 10 11 10 // memory management of types 12 11 // T with non-trivial constructors require 13 12 // C++ style memory management 14 13 #define USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES 15 // but for speed on may alternatively use C memory manag ment14 // but for speed on may alternatively use C memory management 16 15 // but can do so safely only for T that are at most 17 16 // plain old data structures (POD) … … 69 68 assert(aT_p); 70 69 return aT_p; 70 #endif 71 } 72 73 template <class T> 74 T** xNewZeroInit(unsigned int dim1, unsigned int dim2) { 75 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES 76 T** aT_pp=xNew<T>(dim1,dim2); 77 for (unsigned int i=0; i<dim1*dim2;++i) 78 (*aT_pp)[i]=(T)0; 79 return aT_pp; 80 #else 81 T* buf=(T*)calloc(dim1*dim2*sizeof(T)); 82 assert(buf ); 83 T** aT_pp =(T**)malloc(dim1*sizeof(T*)); 84 assert(aT_pp ); 85 for (unsigned int i=0;i<dim1;++i) { 86 aT_pp [i]=buf; 87 buf+=dim2; 88 } 89 return aT_pp ; 71 90 #endif 72 91 } … … 134 153 135 154 #endif 136 -
issm/trunk/src/c/shared/Bamg/shared.h
r3913 r13975 2 2 * \brief: header file for all shared routines. 3 3 */ 4 5 4 6 5 #ifndef _SHAREDBamg_H_ -
issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp
r12706 r13975 9 9 int* ndof_list=NULL; 10 10 int *doflist = NULL; 11 12 11 13 12 if(numnodes){ -
issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp
r12706 r13975 15 15 ndof_list=xNew<int>(numnodes); 16 16 ngdof_list_cumulative=xNew<int>(numnodes); 17 18 17 19 18 /*Get number of dofs per node, and total for this given set*/ -
issm/trunk/src/c/shared/Elements/Paterson.cpp
r12706 r13975 10 10 11 11 IssmDouble Paterson(IssmDouble temperature){ 12 12 13 13 /*output: */ 14 14 IssmDouble B; … … 29 29 // % fittedmodel=fit(Temp,B,'cubicspline'); 30 30 // % B=fittedmodel(temperature); 31 32 31 33 32 if(T<=-45.0){ … … 61 60 B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.003748937622487*pow(T+5,3)+0.015290593619213*pow(T+5,2) -0.048160403003748*(T+5)+ 0.854987973338348); 62 61 } 63 else if(T>=-2.0){62 else{ 64 63 B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.003748937622488*pow(T+2,3)-0.018449844983174*pow(T+2,2) -0.057638157095631*(T+2)+ 0.746900791092860); 65 64 } … … 70 69 return B; 71 70 } 72 73 74 -
issm/trunk/src/c/shared/Elements/PddSurfaceMassBalance.cpp
r13395 r13975 10 10 IssmDouble B; // surface mass balance, melt+accumulation 11 11 12 int iqj,imonth , j;13 12 int iqj,imonth; 13 14 14 IssmDouble saccu; // yearly surface accumulation 15 15 IssmDouble smelt; // yearly melt … … 19 19 IssmDouble runoff; //meltwater only, does not include rain 20 20 IssmDouble sconv; //rhow_rain/rhoi / 12 months 21 22 IssmDouble density; 21 23 22 IssmDouble lapser=6.5/1000., sealev=0.; // lapse rate. degrees per meter. 7.5 lev's 99 paper, 9 Marshall 99 paper 24 23 IssmDouble desfac = 0.5; // desert elevation factor … … 27 26 IssmDouble st; // elevation between altitude of the temp record and current altitude 28 27 IssmDouble sp; // elevation between altitude of the prec record and current altitude 29 28 30 29 // PDD and PD constants and variables 31 30 IssmDouble siglim; // sigma limit for the integration which is equal to 2.5 sigmanorm … … 35 34 IssmDouble DT = 0.02; 36 35 IssmDouble pddt, pd; // pd: snow/precip fraction, precipitation falling as snow 37 36 38 37 IssmDouble q, qmpt; // q is desert/elev. fact, hnpfac is huybrect fact, and pd is normal dist. 39 38 IssmDouble qm = 0.; // snow part of the precipitation … … 42 41 IssmDouble pdd = 0.; 43 42 IssmDouble frzndd = 0.; 44 43 45 44 IssmDouble tstar; // monthly mean surface temp 46 45 IssmDouble Tsum= 0.; // average summer (JJA) temperature 47 46 IssmDouble Tsurf = 0.; // average annual temperature 48 49 47 50 48 IssmDouble deltm=1./12.; 51 49 int ismon[12]={11,0,1,2,3,4,5,6,7,8,9,10}; 52 50 53 51 IssmDouble snwm; // snow that could have been melted in a year. 54 52 IssmDouble snwmf; // ablation factor for snow per positive degree day. 55 53 IssmDouble smf; // ablation factor for ice per pdd (Braithwaite 1995 from tarasov 2002). 56 54 57 55 IssmDouble dfrz=1.5, CovrLm=2009./3.35e+5, dCovrLm=dfrz*CovrLm; //m*J kg^-1 C^-1 /(J kg^-1)=m/C yr 58 56 IssmDouble supice,supcap,diffndd; 59 57 IssmDouble fsupT=0.5, fsupndd=0.5; // Tsurf mode factors for supice 60 58 IssmDouble pddtj, hmx2; 61 59 62 60 sconv=(rho_water/rho_ice)/12.; //rhow_rain/rhoi / 12 months 63 61 … … 68 66 siglim0c = siglimc/DT + 0.5; 69 67 PDup = siglimc+PDCUT; 70 68 71 69 // seasonal loop 72 70 for (iqj = 0; iqj < 12; iqj++){ 73 71 imonth = ismon[iqj]; 74 72 75 73 st=(s-s0t)/1000.; 76 74 tstar = monthlytemperatures[imonth] - lapser *max(st,sealev); 77 75 Tsurf = tstar*deltm+Tsurf; 78 76 79 77 /*********compute PD ****************/ 80 78 if (tstar < PDup){ … … 83 81 else { 84 82 pd = 0.;} 85 83 86 84 /******exp des/elev precip reduction*******/ 87 85 sp=(s-s0p)/1000.; // deselev effect is wrt chng in topo 88 86 if (sp>0.0){q = exp(-desfac*sp);} 89 87 else {q = 1.0;} 90 88 91 89 qmt= qmt + monthlyprec[imonth]*sconv; //*sconv to convert in m of ice equivalent per month 92 90 qmpt= q*monthlyprec[imonth]*sconv; 93 91 qmp= qmp + qmpt; 94 92 qm= qm + qmpt*pd; 95 93 96 94 /*********compute PDD************/ 97 95 // ndd(month)=-(tstar-pdd(month)) since ndd+pdd gives expectation of … … 105 103 else{frzndd = frzndd - tstar*deltm; } 106 104 } // end of seasonal loop 107 105 108 106 //****************************************************************** 109 107 saccu = qm; 110 108 prect = qmp; // total precipitation during 1 year taking into account des. ef. 111 109 Tsum=Tsum/3; 112 110 113 111 /***** determine PDD factors *****/ 114 112 if(Tsum< -1.) { … … 126 124 snwmf=0.95*snwmf; 127 125 smf=0.95*smf; 128 126 129 127 /***** compute PDD ablation and refreezing *****/ 130 128 pddt = pdd *365; 131 129 snwm = snwmf*pddt; // snow that could have been melted in a year 132 130 hmx2 = min(h,dfrz); // refreeze active layer max depth: dfrz 133 131 134 132 if(snwm < saccu) { 135 133 water=prect-saccu + snwm; //water=rain + snowmelt … … 147 145 // hold the meltwater around for refreezing? And melt-time will have 148 146 // low seasonal frzndd 149 147 150 148 // Superimposed ice : Pfeffer et al. 1991, Tarasov 2002 151 149 152 150 supice= min(hmx2*CovrLm*frzndd+2.2*(saccu-snwm), water); // superimposed ice 153 151 supcap=min(2.2*(saccu-snwm),water); … … 172 170 // does supice make sense when H< 0.1m? then d=thermoactive ice layer //// 173 171 // < 0.1 174 172 175 173 // make more sense to just use residual pdd-ndd except that pdd 176 174 // residual not clear yet … … 197 195 if(Tsurf<0) { 198 196 Tsurf= min(Tsurf+fsupT*diffndd , 0.);} 199 197 200 198 B = -smelt+saccu; 201 199 B = B/yts; 202 200 pddtj=pddt; 203 201 204 202 return B; 205 203 } -
issm/trunk/src/c/shared/Elements/PrintArrays.cpp
r13395 r13975 10 10 for(int j=0;j<cols;j++) _printString_( " " << setw(11) << setprecision (5) << array[i*cols+j]); 11 11 _printLine_(" ]"); 12 } 13 _printLine_(""); 14 } 15 void printsparsity(IssmPDouble* array,int lines,int cols){ 16 int count; 17 _printLine_(""); 18 for(int i=0;i<lines;i++){ 19 _printString_(" [ "); 20 count = 0; 21 for(int j=0;j<cols;j++){ 22 if(array[i*cols+j]!=0.0){ 23 _printString_( " X"); count++; 24 } 25 else 26 _printString_( " ."); 27 } 28 _printLine_(" ] "<<i<<" => "<<count); 12 29 } 13 30 _printLine_(""); -
issm/trunk/src/c/shared/Elements/TransformLoadVectorCoord.cpp
r13395 r13975 20 20 void TransformLoadVectorCoord(ElementVector* pe,Node** nodes,int numnodes,int* cs_array){ 21 21 22 int i ,j;22 int i; 23 23 int numdofs = 0; 24 24 IssmDouble *transform = NULL; -
issm/trunk/src/c/shared/Elements/TransformSolutionCoord.cpp
r13395 r13975 21 21 void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int* cs_array){ 22 22 23 int i ,j;23 int i; 24 24 int numdofs = 0; 25 25 IssmDouble *transform = NULL; -
issm/trunk/src/c/shared/Elements/elements.h
r13395 r13975 40 40 void printarray(IssmPDouble* array,int lines,int cols=1); 41 41 void printarray(int* array,int lines,int cols=1); 42 void printsparsity(IssmPDouble* array,int lines,int cols=1); 42 43 void printbinary(int n); 43 44 #endif //ifndef _SHARED_ELEMENTS_H_ -
issm/trunk/src/c/shared/Exceptions/Exceptions.cpp
r13395 r13975 12 12 #include "../../include/include.h" 13 13 14 ErrorException::ErrorException(const string &what_arg){ 14 ErrorException::ErrorException(const string &what_arg){/*{{{*/ 15 15 16 16 what_str=what_arg; … … 18 18 function_name=""; 19 19 file_line=0; 20 } 21 22 ErrorException::ErrorException(const string& what_file, const string& what_function,int what_line, const string& what_arg){ 20 }/*}}}*/ 21 ErrorException::ErrorException(const string& what_file, const string& what_function,int what_line, const string& what_arg){/*{{{*/ 23 22 24 23 what_str=what_arg; … … 26 25 function_name=what_function; 27 26 file_line=what_line; 28 } 27 }/*}}}*/ 28 ErrorException::~ErrorException() throw(){/*{{{*/ 29 }/*}}}*/ 30 const char* ErrorException::what() const throw(){/*{{{*/ 31 return what_str.c_str(); 32 }/*}}}*/ 33 void ErrorException::Report() const{/*{{{*/ 29 34 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(); 35 } 35 int my_rank; 36 int num_procs; 36 37 37 const char* ErrorException::what() const throw(){ 38 return what_str.c_str(); 39 } 40 41 void ErrorException::Report() const{ 42 extern int my_rank; 43 extern int num_procs; 38 /*recover my_rank and num_procs:*/ 39 my_rank=IssmComm::GetRank(); 40 num_procs=IssmComm::GetSize(); 44 41 45 42 if (function_name=="" || file_line==0){ //WINDOWS … … 48 45 else{ 49 46 if(num_procs==1){ 50 _printLine_("\n??? Error using==> " << file_name.c_str() << ":" << file_line);47 _printLine_("\n??? Error in ==> " << file_name.c_str() << ":" << file_line); 51 48 _printLine_(function_name.c_str() << " error message: " << what() << "\n"); 52 49 } 53 50 else{ 54 _printLine_("\n[" << my_rank 55 _printLine_( "[" << my_rank << "] " << function_name.c_str() << " error message: " << what() << "\n");51 _printLine_("\n[" << my_rank<< "] ??? Error using ==> " << file_name.c_str() << ":" << file_line); 52 _printLine_( "[" << my_rank << "] " << function_name.c_str() << " error message: " << what() << "\n"); 56 53 } 57 54 } 58 55 return; 59 } 56 }/*}}}*/ 57 const char* ErrorException::MatlabReport() const{/*{{{*/ 58 59 /*Output*/ 60 std::ostringstream buffer; 61 62 if (this->file_line==0){ //WINDOWS 63 buffer << " error message: " << (this->what_str).c_str(); 64 } 65 else{ 66 buffer << "\nError in ==> " << (this->file_name).c_str() << ":" << file_line << "\n"; 67 buffer << (this->function_name).c_str() << " error message: " << (this->what_str).c_str(); 68 } 69 70 const string buffer2 = buffer.str(); 71 return buffer2.c_str(); 72 }/*}}}*/ 73 const char* ErrorException::PythonReport() const{/*{{{*/ 74 75 /*Output*/ 76 std::ostringstream buffer; 77 78 if (this->file_line==0){ //WINDOWS 79 buffer << " error message: " << (this->what_str).c_str(); 80 } 81 else{ 82 buffer << "\nError in ==> " << (this->file_name).c_str() << ":" << file_line << "\n"; 83 buffer << (this->function_name).c_str() << " error message: " << (this->what_str).c_str(); 84 } 85 86 const string buffer2 = buffer.str(); 87 return buffer2.c_str(); 88 }/*}}}*/ -
issm/trunk/src/c/shared/Exceptions/exceptions.h
r13395 r13975 16 16 /*We derive our classes from the c++ exception class: */ 17 17 class ErrorException: public exception { 18 18 19 19 string what_str; 20 20 string function_name; … … 28 28 virtual const char *what() const throw(); 29 29 void Report() const; 30 const char* MatlabReport() const; 31 const char* PythonReport() const; 30 32 31 33 }; -
issm/trunk/src/c/shared/Exceptions/exprintf.cpp
r12706 r13975 5 5 * ErrorException(exprintf("%s%i\n","test failed for id:",id)); 6 6 */ 7 8 7 9 8 #include <stdarg.h> … … 17 16 char *buffer = NULL; 18 17 int n,size = 100; 19 int string_size;20 18 21 19 //variable list of arguments -
issm/trunk/src/c/shared/Exp/DomainOutlineWrite.cpp
r13395 r13975 12 12 13 13 int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname){ 14 14 15 15 /*Error management: */ 16 16 int noerr=1; … … 33 33 fprintf(fid,"%s %s\n","##","Icon:0"); 34 34 fprintf(fid,"%s %s %s %s\n","#","Points","Count","Value"); 35 35 36 36 /*Write number of profile vertices: */ 37 37 fprintf(fid,"%u %s\n",profnvertices[counter] ,"1."); 38 38 39 39 /*Write next line: */ 40 40 fprintf(fid,"%s %s %s %s %s\n","#","X","pos","Y","pos"); -
issm/trunk/src/c/shared/Exp/IsInPoly.cpp
r13395 r13975 18 18 int i, j, c = 0; 19 19 double n1, n2, normp, scalar; 20 20 21 21 /*first test, are they colinear? if yes, is the point in the middle of the segment*/ 22 22 if (edgevalue != 2 ){ -
issm/trunk/src/c/shared/Exp/IsInPolySerial.cpp
r13395 r13975 5 5 #include <math.h> 6 6 7 8 7 #include "./exp.h" 9 10 8 11 9 int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue){ 12 10 13 int i,j;14 11 double x0,y0; 15 12 16 13 /*Go through all vertices of the mesh:*/ 17 for (i=0;i<nods;i++){14 for(int i=0;i<nods;i++){ 18 15 if (in[i]){ 19 16 /*this vertex already is inside one of the contours, continue*/ -
issm/trunk/src/c/shared/Exp/exp.h
r13395 r13975 60 60 template <class doubletype> 61 61 int DomainOutlineRead(int* pnprof,int** pprofnvertices,doubletype*** ppprofx,doubletype*** ppprofy,bool** pclosed,char* domainname){ 62 62 63 63 /*indexing: */ 64 64 int i,counter; … … 90 90 nprof=1; 91 91 for(;;){ 92 fscanf(fid,"%25 6s %256s\n",chardummy,chardummy);93 fscanf(fid,"%25 6s %256s\n",chardummy,chardummy);94 fscanf(fid,"%25 6s %256s %256s %256s\n",chardummy,chardummy,chardummy,chardummy);95 fscanf(fid,"%20u %25 6s\n",&n,chardummy);96 fscanf(fid,"%25 6s %256s %256s %256s %256s\n",chardummy,chardummy,chardummy,chardummy,chardummy);92 fscanf(fid,"%255s %255s\n",chardummy,chardummy); 93 fscanf(fid,"%255s %255s\n",chardummy,chardummy); 94 fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy); 95 fscanf(fid,"%20u %255s\n",&n,chardummy); 96 fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy); 97 97 for (i=0;i<n;i++) fscanf(fid,"%20lf %20lf\n",&ddummy,&ddummy); 98 98 /*check whether we are at the end of the file, otherwise, keep reading next profile:*/ … … 100 100 nprof++; 101 101 } 102 102 103 103 /*Allocate and initialize all the profiles: */ 104 104 profnvertices = xNew<int>(nprof); … … 118 118 119 119 /*Skip header: */ 120 fscanf(fid,"%25 6s %256s\n",chardummy,chardummy);121 fscanf(fid,"%25 6s %256s\n",chardummy,chardummy);122 fscanf(fid,"%25 6s %256s %256s %256s\n",chardummy,chardummy,chardummy,chardummy);123 120 fscanf(fid,"%255s %255s\n",chardummy,chardummy); 121 fscanf(fid,"%255s %255s\n",chardummy,chardummy); 122 fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy); 123 124 124 /*Get number of profile vertices: */ 125 fscanf(fid,"%20u %25 6s\n",&n,chardummy);126 125 fscanf(fid,"%20u %255s\n",&n,chardummy); 126 127 127 /*Skip next line: */ 128 fscanf(fid,"%25 6s %256s %256s %256s %256s\n",chardummy,chardummy,chardummy,chardummy,chardummy);128 fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy); 129 129 130 130 /*Allocate vertices: */ 131 131 x=xNew<doubletype>(n); 132 132 y=xNew<doubletype>(n); 133 133 134 134 /*Read vertices: */ 135 135 for (i=0;i<n;i++){ … … 170 170 doubletype **pprofx = NULL; 171 171 doubletype **pprofy = NULL; 172 Contour<doubletype> *contour = NULL;173 172 174 173 /*output: */ -
issm/trunk/src/c/shared/MemOps/xMemCpy.h
r12706 r13975 17 17 18 18 #endif 19 -
issm/trunk/src/c/shared/Numerics/BrentSearch.cpp
r13395 r13975 40 40 maxiter=optpars->maxiter; 41 41 cm_jump=optpars->cm_jump; 42 42 43 43 /*initialize counter and get response at the boundaries*/ 44 44 iter=0; -
issm/trunk/src/c/shared/Numerics/IsInputConverged.cpp
r13395 r13975 20 20 /*output: */ 21 21 IssmDouble eps; 22 22 23 23 /*intermediary: */ 24 24 IssmDouble *newvalues = NULL; -
issm/trunk/src/c/shared/Numerics/OptimalSearch.cpp
r13395 r13975 38 38 x2 =optpars->xmax; 39 39 maxiter =optpars->maxiter; 40 40 41 41 //get the value of the function at the first boundary 42 42 fx1= (*f)(x1,optargs); -
issm/trunk/src/c/shared/Numerics/OptionsFromAnalysis.cpp
r13395 r13975 16 16 17 17 char* OptionsFromAnalysis(Parameters* parameters,int analysis_type){ 18 18 19 19 /*output: */ 20 20 char* outstring=NULL; -
issm/trunk/src/c/shared/Numerics/Synchronize.sh
r12706 r13975 2 2 #Synchronize Verbosity 3 3 #first remove existing files 4 rm $ISSM_DIR/src/m/ shared/Verb*.m4 rm $ISSM_DIR/src/m/classes/Verb*.m 5 5 6 6 echo "Synchronizing Verbosity levels..." … … 50 50 echo "$FILENAME -> 2^$POWER = $BINARY" 51 51 52 #Add Verbosity Matlab file{{{53 cat <<END > $ISSM_DIR"/src/m/shared/"$(echo $FILENAME".m")54 function bool=$(echo $FILENAME)()55 %$(echo $FILENAME | awk {'print toupper($1)'}) - Return true if $(echo $LEVELNAME | awk {'print tolower($1)'}) level is activated56 %57 % WARNING: DO NOT MODIFY THIS FILE58 % this file has been automatically generated by src/c/shared/Numerics/Synchronize.sh59 % Please read src/c/shared/Numerics/README for more information60 %61 % Usage:62 % bool=$FILENAME()63 64 bool=logical(bitand(GetVerbosityLevel(),$BINARY));65 END66 #}}}67 52 #Add case to verbose.m FIELDS{{{ 68 53 if [ $i -eq 1 ]; then cat <<END >> FIELDS … … 135 120 void SetVerbosityLevel(int level){ 136 121 137 if(level<0) _error 2_("vebosity level should be a positive integer (user provided " << level << ")");122 if(level<0) _error_("vebosity level should be a positive integer (user provided " << level << ")"); 138 123 139 124 verbositylevel = level; -
issm/trunk/src/c/shared/Numerics/UnitConversion.cpp
r13395 r13975 40 40 } 41 41 42 43 42 IssmDouble UnitConversionScaleFactor(int type_enum){ 44 43 45 44 IssmDouble yts=365.0*24.0*3600.0; 46 45 47 46 IssmDouble scale; 48 47 switch(type_enum){ … … 72 71 case SurfaceforcingsANegEnum: scale=yts;break; //m/yr 73 72 case SurfaceforcingsBNegEnum: scale=yts;break; //m/yr 73 case SurfaceforcingsSmbrefEnum: scale=yts;break; //m/yr 74 74 case MisfitEnum: scale=pow(yts,2);break; //(m/yr)^2 75 75 case MassFluxEnum: scale=pow((IssmDouble)10,-12)*yts;break; // (GigaTon/year) -
issm/trunk/src/c/shared/Numerics/Verbosity.cpp
r13395 r13975 28 28 bool VerboseControl(void){return (GetVerbosityLevel() & 32);} /* 2^5*/ 29 29 bool VerboseQmu(void){return (GetVerbosityLevel() & 64);} /* 2^6*/ 30 bool VerboseAutodiff(void){return (GetVerbosityLevel() & 128);} /* 2^7*/ 30 31 31 32 /*Verbosity Setup*/ … … 41 42 /*FUNCTION GetVerbosityLevel {{{*/ 42 43 int GetVerbosityLevel(void){ 43 44 44 _assert_(verbositylevel>=0); 45 45 return verbositylevel; 46 47 46 }/*}}}*/ -
issm/trunk/src/c/shared/Numerics/Verbosity.h
r6324 r13975 14 14 bool VerboseControl(void); 15 15 bool VerboseQmu(void); 16 bool VerboseAutodiff(void); 16 17 17 18 /*Setup Verbosity level*/ -
issm/trunk/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp
r12706 r13975 7 7 void XZvectorsToCoordinateSystem(IssmDouble* T,IssmDouble* xzvectors){ 8 8 9 int i,j;10 9 IssmDouble x[3],y[3],z[3]; 11 10 IssmDouble x_norm, y_norm, z_norm; 12 11 13 for(i =0;i<6;i++){12 for(int i=0;i<6;i++){ 14 13 if(xIsNan<IssmDouble>(xzvectors[i])){ 15 14 /*At least one NaN found: default to Id*/ -
issm/trunk/src/c/shared/Numerics/cross.cpp
r12706 r13975 20 20 21 21 } 22 -
issm/trunk/src/c/shared/Numerics/isnan.h
r12706 r13975 6 6 #define _XISNAN_H_ 7 7 8 #include <cmath> 8 #ifdef HAVE_CONFIG_H 9 #include <config.h> 10 #else 11 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 12 #endif 13 14 /*If include cmath instead of math, isnan on linux64 murdo does not work: */ 15 #include <math.h> 9 16 10 17 template <class T> int xIsNan(const T& X) { … … 16 23 } 17 24 18 #if def _HAVE_ADOLC_25 #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_) 19 26 template <> int xIsNan<adouble> (const adouble& X); 20 27 #endif -
issm/trunk/src/c/shared/Numerics/recast.h
r12706 r13975 9 9 #define _RECAST_H_ 10 10 11 #ifndef _HAVE_ADOLC_ 11 #ifdef HAVE_CONFIG_H 12 #include <config.h> 13 #else 14 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 15 #endif 16 17 #if !defined(_HAVE_ADOLC_) || defined(_WRAPPERS_) 12 18 13 19 template<class To, class From> -
issm/trunk/src/c/shared/Sorting/binary_search.cpp
r12330 r13975 11 11 #include <stdio.h> 12 12 13 int binary_search(int* poffset,int target,int* sorted_integers,int num_integers){ 13 int binary_search(int* poffset,int target,int* sorted_integers,int num_integers){ /*{{{*/ 14 14 15 15 /*output: */ … … 18 18 19 19 /*intermediary: */ 20 int * beg=NULL;21 int * end=NULL;22 int * mid=NULL;20 int *beg = NULL; 21 int *end = NULL; 22 int *mid = NULL; 23 23 24 24 // point to beginning and end of the array … … 47 47 } 48 48 } 49 49 50 50 //did we find the target? 51 51 if (*mid == target) { … … 60 60 /*Assign output pointers:*/ 61 61 *poffset=offset; 62 62 63 63 /*Return result: */ 64 64 return found; 65 } 65 } /*}}}*/ -
issm/trunk/src/c/shared/Sorting/sorting.h
r12330 r13975 7 7 8 8 int binary_search(int* poffset,int target,int* sorted_integers,int num_integers); 9 template <typename doubletype> int binary_search(int* poffset,doubletype target,doubletype* list,int length){ /*{{{*/ 10 /* 11 * l[0] l[1] l[2] l[n] l[n+1] l[length-1] 12 * <-------+-----+-----+-----+ ... +-----+........+--------------> 13 * offset: -1 0 1 2 n length -1 14 * 15 * offset = -1 target < list[0] 16 * offset = n list[n] <= target < list[n+1] 17 * offset = length-1 list[length-1] <= target 18 */ 19 20 /*output: */ 21 int offset = 0; 22 int found = 0; 23 24 /*intermediary: */ 25 int n0 = 0; 26 int n1 = int(length/2); 27 int n2 = length-1; 28 29 if(target<list[n0]){ 30 found = 1; 31 offset = -1; 32 } 33 else if(target>=list[n2]){ 34 found = 1; 35 offset = length-1; 36 } 37 else{ 38 for(;;){ 39 /*did we find the target?*/ 40 if(list[n1]<=target && list[n1+1]>target){ 41 found = 1; 42 offset = n1; 43 break; 44 } 45 else if(target < list[n1]){ 46 n2 = n1; 47 n1 = n0 + int((n2-n0)/2); 48 } 49 else{ 50 n0 = n1; 51 n1 = n0 + int((n2-n0)/2); 52 } 53 } 54 } 55 56 /*Assign output pointer and return*/ 57 *poffset=offset; 58 return found; 59 } /*}}}*/ 9 60 10 61 #endif //ifndef _SORTING_H_ -
issm/trunk/src/c/shared/String/DescriptorIndex.cpp
r13395 r13975 18 18 19 19 int DescriptorIndex(char* root, int* pindex,char* descriptor){ //We assume root has already been allocated, and we just have to copy into it. 20 20 21 21 char * pch=NULL; 22 22 -
issm/trunk/src/c/shared/String/sharedstring.h
r5469 r13975 8 8 int DescriptorIndex(char* root, int* pindex,char* descriptor); 9 9 10 #ifndef WIN32 11 int stricmp(const char* a,const char* b); 12 #endif 13 10 14 #endif //ifndef _SHAREDSTRING_H_ 11 -
issm/trunk/src/c/shared/Threads/LaunchThread.cpp
r13395 r13975 31 31 pthread_t *threads = NULL; 32 32 pthread_handle *handles = NULL; 33 33 34 34 /*dynamically allocate: */ 35 35 threads=xNew<pthread_t>(num_threads); … … 52 52 } 53 53 } 54 54 55 55 /*Free ressources:*/ 56 56 xDelete<pthread_t>(threads); … … 62 62 handle.id=0; 63 63 handle.num=1; 64 64 65 65 function((void*)&handle); 66 66 #endif -
issm/trunk/src/c/shared/Threads/PartitionRange.cpp
r9320 r13975 16 16 int i0=-1; 17 17 int i1=-1; 18 18 19 19 int step; 20 20 int i; 21 22 21 23 22 /*distribute elements across threads :*/ … … 29 28 } 30 29 31 32 30 /*Assign output pointers:*/ 33 31 *pi0=i0; -
issm/trunk/src/c/shared/Threads/issm_threads.h
r2549 r13975 14 14 } pthread_handle; 15 15 16 17 16 /*routine that launches "function" in a multi-threaded way if requested, 18 17 * or just serially if not requested: */ -
issm/trunk/src/c/shared/TriMesh/AssociateSegmentToElement.cpp
r8301 r13975 6 6 7 7 int AssociateSegmentToElement(double** psegments,int nseg, double* index,int nel){ 8 8 9 9 /*Error management: */ 10 10 int i; … … 30 30 return noerr; 31 31 } 32 33 -
issm/trunk/src/c/shared/TriMesh/OrderSegments.cpp
r11237 r13975 6 6 7 7 int OrderSegments(double** psegments,int nseg, double* index,int nel){ 8 8 9 9 /*Error management: */ 10 10 int i; … … 18 18 /*element indices: */ 19 19 int el; 20 21 20 22 21 /*Recover segments: */ -
issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp
r13395 r13975 12 12 x and y of size nodsx1 13 13 segments of size nsegsx3*/ 14 14 15 15 /*Error management: */ 16 16 int noerr=1; 17 17 18 18 int i,j,k,l; 19 19 int node; … … 23 23 int* riftsegments=NULL; 24 24 int* flags=NULL; 25 25 26 26 int NumGridElementListOnOneSideOfRift; 27 27 int* GridElementListOnOneSideOfRift=NULL; … … 55 55 for (i=0;i<nriftsegs;i++){ 56 56 for (j=0;j<2;j++){ 57 57 58 58 node=riftsegments[4*i+j+2]; 59 59 if(flags[node-1]){ … … 66 66 67 67 if(IsGridOnRift(riftsegments,nriftsegs,node)){ 68 68 69 69 DetermineGridElementListOnOneSideOfRift(&NumGridElementListOnOneSideOfRift,&GridElementListOnOneSideOfRift,i,nriftsegs,riftsegments,node,index,nel); 70 70 71 71 /*Summary: we have for node, a list of elements 72 72 * (GridElementListOnOneSideOfRift, of size -
issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp
r13395 r13975 17 17 /*Does this node belong to 4 elements, or just 2? If it belongs to 4 elements, it is inside a rift, 18 18 *if it belongs to 2 elements, it is on the tip of a rift, or it has already been split across the rift (see below).*/ 19 19 20 20 int i; 21 21 int j; … … 119 119 /*FUNCTION RiftSegmentsFromSegments{{{*/ 120 120 void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments){ 121 121 122 122 int i,counter; 123 123 int el,el2; 124 124 125 125 int nriftsegs; 126 126 int* riftsegments=NULL; … … 179 179 180 180 xDelete<int>(riftsegments_uncompressed); 181 181 182 182 /*Assign output pointers: */ 183 183 *priftsegments=riftsegments; … … 266 266 /*Reallocate segments: */ 267 267 segments =xReNew<double>(segments, nsegs*3,(nsegs+nriftsegs)*3); 268 segmentmarkerlist=xReNew<double>(segmentmarkerlist,nsegs *3,(nsegs+nriftsegs)*3);268 segmentmarkerlist=xReNew<double>(segmentmarkerlist,nsegs,(nsegs+nriftsegs)); 269 269 270 270 /*First, update the existing segments to the new nodes :*/ … … 344 344 *psegmentmarkerlist=segmentmarkerlist; 345 345 *pnsegs=nsegs; 346 346 347 347 return noerr; 348 }/*}}}*/349 /*FUNCTION pnpoly{{{*/350 int pnpoly(int npol, double *xp, double *yp, double x, double y) {351 int i, j, c = 0;352 for (i = 0, j = npol-1; i < npol; j = i++) {353 if ((((yp[i]<=y) && (y<yp[j])) ||354 ((yp[j]<=y) && (y<yp[i]))) &&355 (x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i]))356 c = !c;357 }358 return c;359 348 }/*}}}*/ 360 349 /*FUNCTION FindElement{{{*/ … … 384 373 double *segmentmarkerlist = NULL; 385 374 int numsegs; 386 375 387 376 /*output: */ 388 377 int new_numsegs; … … 460 449 /*FUNCTION PairRiftElements{{{*/ 461 450 int PairRiftElements(int** priftsnumpairs, double*** priftspairs,int numrifts,int* riftsnumsegments, double** riftssegments,double* x,double* y){ 462 463 451 464 452 int noerr=1; … … 693 681 int i; 694 682 int noerr=1; 695 683 696 684 /*output: */ 697 685 int riftflag=0; … … 717 705 /*FUNCTION OrderRifts{{{*/ 718 706 int OrderRifts(double** priftstips, double** riftssegments,double** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y,int nods,int nels){ 719 707 720 708 int noerr=1; 721 709 int i,j,k,counter; … … 747 735 riftpairs=riftspairs[i]; 748 736 numsegs=riftsnumsegments[i]; 749 737 750 738 /*Allocate copy of riftsegments and riftpairs, 751 739 *as well as ordering vector: */ … … 793 781 } 794 782 } 795 783 796 784 if (node4==node2){ 797 785 /*node2 is a tip*/ … … 818 806 node1=(int)*(riftsegments+3*j+0); 819 807 node2=(int)*(riftsegments+3*j+1); 820 808 821 809 if ((node1==node) || (node2==node)){ 822 810 /*Ok, this segment is connected to node, plug its index into order, unless we already plugged it before: */ … … 851 839 *(riftpairs_copy+2*j+1)=*(riftpairs+2*order[j]+1); 852 840 } 853 841 854 842 for (j=0;j<numsegs;j++){ 855 843 *(riftsegments+3*j+0)=*(riftsegments_copy+3*j+0); … … 873 861 int PenaltyPairs(double*** priftspenaltypairs,int** priftsnumpenaltypairs,int numrifts,double** riftssegments, 874 862 int* riftsnumsegs,double** riftspairs,double* riftstips,double* x,double* y){ 875 876 863 877 864 int noerr=1; … … 906 893 /*allocate riftpenaltypairs, and riftnumpenaltypairs: */ 907 894 if((numsegs/2-1)!=0)riftpenaltypairs=xNewZeroInit<double>((numsegs/2-1)*RIFTPENALTYPAIRSWIDTH); 908 895 909 896 /*Go through only one flank of the rifts, not counting the tips: */ 910 897 counter=0; … … 997 984 *(riftpenaltypairs+j*7+5)=*(riftpenaltypairs+j*7+5)/magnitude; 998 985 } 999 986 1000 987 riftspenaltypairs[i]=riftpenaltypairs; 1001 988 riftsnumpenaltypairs[i]=(numsegs/2-1); … … 1035 1022 y=*py; 1036 1023 nods=*pnods; 1037 1038 1024 1039 1025 for (i=0;i<num_seg;i++){ -
issm/trunk/src/c/shared/TriMesh/trimesh.h
r12330 r13975 22 22 int DetermineGridElementListOnOneSideOfRift(int* pNumGridElementListOnOneSideOfRift, int** pGridElementListOnOneSideOfRift, int segmentnumber, int nriftsegs, int* riftsegments, int node,double* index,int nel); 23 23 int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs,int nods,int nel); 24 int pnpoly(int npol, double *xp, double *yp, double x, double y);25 24 int FindElement(double A,double B,double* index,int nel); 26 25 int RemoveRifts(double** pindex,double** px,double** py,int* pnods,double** psegments,int* pnumsegs,int numrifts1,int* rifts1numsegs,double** rifts1segments,double** rifts1pairs,int nel); -
issm/trunk/src/c/shared/shared.h
r13395 r13975 6 6 #define _SHARED_H_ 7 7 8 #include "Alloc/alloc.h" 9 #include "Alloc/xNewDelete.h" 10 #include "Bamg/shared.h" 11 #include "Elements/elements.h" 12 #include "Exceptions/exceptions.h" 13 #include "Exp/exp.h" 14 #include "Matrix/matrix.h" 15 #include "MemOps/xMemCpy.h" 16 #include "Numerics/numerics.h" 17 #include "Sorting/sorting.h" 18 #include "Sys/sys.h" 19 #include "Threads/issm_threads.h" 20 #include "TriMesh/trimesh.h" 21 #include "Wrapper/wrappershared.h" 8 #include "./Alloc/alloc.h" 9 #include "./Alloc/xNewDelete.h" 10 #include "./Bamg/shared.h" 11 #include "./Elements/elements.h" 12 #include "./Exceptions/exceptions.h" 13 #include "./Exp/exp.h" 14 #include "./Matrix/matrix.h" 15 #include "./MemOps/xMemCpy.h" 16 #include "./Numerics/numerics.h" 17 #include "./Sorting/sorting.h" 18 #include "./String/sharedstring.h" 19 #include "./Threads/issm_threads.h" 20 #include "./TriMesh/trimesh.h" 22 21 23 22 #endif -
issm/trunk/src/c/solutions/AdjointCorePointerFromSolutionEnum.cpp
r13395 r13975 1 /*!\file: CorePointerFromSolutionEnum.cpp1 /*!\file: AdjointCorePointerFromSolutionEnum.cpp 2 2 * \brief: return type of analyses, number of analyses and core solution function. 3 3 */ … … 24 24 25 25 switch(solutiontype){ 26 26 27 27 case DiagnosticSolutionEnum: 28 28 adjointcore=&adjointdiagnostic_core; … … 38 38 break; 39 39 } 40 40 41 41 /*Assign output pointer:*/ 42 42 _assert_(padjointcore); -
issm/trunk/src/c/solutions/AnalysisConfiguration.cpp
r13395 r13975 26 26 /*Analyses lists*/ 27 27 switch(solutiontype){ 28 28 29 29 case DiagnosticSolutionEnum: 30 30 numanalyses=5; … … 56 56 analyses[1]=MeltingAnalysisEnum; 57 57 break; 58 58 59 59 case EnthalpySolutionEnum: 60 60 numanalyses=1; … … 62 62 analyses[0]=EnthalpyAnalysisEnum; 63 63 break; 64 64 65 65 case HydrologySolutionEnum: 66 66 numanalyses=3; … … 108 108 analyses[8]=PrognosticAnalysisEnum; 109 109 break; 110 110 111 111 default: 112 112 _error_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!"); -
issm/trunk/src/c/solutions/CorePointerFromSolutionEnum.cpp
r13395 r13975 24 24 25 25 switch(solutiontype){ 26 26 27 27 case DiagnosticSolutionEnum: 28 28 #ifdef _HAVE_DIAGNOSTIC_ … … 99 99 break; 100 100 } 101 101 102 102 /*Assign output pointer:*/ 103 103 _assert_(psolutioncore); -
issm/trunk/src/c/solutions/ProcessArguments.cpp
r13395 r13975 19 19 char *rootpatharg = NULL; 20 20 21 *solution_type=StringToEnumx(argv[1]);21 /*Check input arguments*/ 22 22 if(argc<2)_error_("Usage error: no solution requested"); 23 23 if(argc<3)_error_("Usage error: missing execution directory"); 24 24 if(argc<4)_error_("Usage error: missing model name"); 25 26 /*Get requested solution*/ 27 *solution_type=StringToEnumx(argv[1]); 25 28 26 29 rootpatharg=argv[2]; -
issm/trunk/src/c/solutions/ResetBoundaryConditions.cpp
r13395 r13975 9 9 10 10 void ResetBoundaryConditions(FemModel* femmodel, int analysis_type){ 11 11 12 12 /*variables: */ 13 13 Vector<IssmDouble>* yg = NULL; 14 14 Nodes *nodes = NULL; 15 int i;16 15 17 16 if(VerboseSolution()) _pprintLine_(" updating boundary conditions..."); 18 17 19 18 /*set current analysis: */ 20 19 femmodel->SetCurrentConfiguration(analysis_type); -
issm/trunk/src/c/solutions/adjointbalancethickness_core.cpp
r13395 r13975 14 14 15 15 void adjointbalancethickness_core(FemModel* femmodel){ 16 16 17 17 /*parameters: */ 18 18 bool save_results; … … 33 33 femmodel->SetCurrentConfiguration(BalancethicknessAnalysisEnum,AdjointBalancethicknessAnalysisEnum); 34 34 solver_adjoint_linear(femmodel); 35 35 36 36 /*Save results*/ 37 37 if(save_results){ -
issm/trunk/src/c/solutions/adjointdiagnostic_core.cpp
r13395 r13975 14 14 15 15 void adjointdiagnostic_core(FemModel* femmodel){ 16 16 17 17 /*parameters: */ 18 18 bool isstokes; … … 36 36 femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum,AdjointHorizAnalysisEnum); 37 37 solver_adjoint_linear(femmodel); 38 38 39 39 /*Save results*/ 40 40 if(save_results){ -
issm/trunk/src/c/solutions/balancethickness_core.cpp
r13395 r13975 20 20 /*activate formulation: */ 21 21 femmodel->SetCurrentConfiguration(BalancethicknessAnalysisEnum); 22 22 23 23 /*recover parameters: */ 24 24 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); -
issm/trunk/src/c/solutions/bedslope_core.cpp
r13395 r13975 26 26 femmodel->SetCurrentConfiguration(BedSlopeAnalysisEnum,BedSlopeYAnalysisEnum); 27 27 solver_linear(femmodel); 28 28 29 29 if(save_results){ 30 30 if(VerboseSolution()) _pprintLine_(" saving results"); -
issm/trunk/src/c/solutions/control_core.cpp
r13395 r13975 16 16 17 17 int i,n; 18 18 19 19 /*parameters: */ 20 20 int num_controls,num_responses; … … 32 32 IssmDouble* maxiter=NULL; 33 33 IssmDouble* cm_jump=NULL; 34 34 35 35 /*intermediary: */ 36 36 IssmDouble search_scalar=1; … … 72 72 J=xNew<IssmDouble>(nsteps); 73 73 step_responses=xNew<int>(num_responses); 74 74 75 75 /*Initialize some of the BrentSearch arguments: */ 76 76 optargs.femmodel=femmodel; 77 77 optpars.xmin=0; optpars.xmax=1; 78 78 79 79 /*Start looping: */ 80 80 for(n=0;n<nsteps;n++){ … … 84 84 for(i=0;i<num_responses;i++) step_responses[i]=reCast<int,IssmDouble>(responses[n*num_responses+i]); 85 85 femmodel->parameters->SetParam(step_responses,1,num_responses,StepResponsesEnum); 86 86 87 87 /*In steady state inversion, compute new temperature field now*/ 88 88 if(solution_type==SteadystateSolutionEnum) solutioncore(femmodel); … … 104 104 if(VerboseControl()) _pprintLine_(" updating parameter using optimized search scalar"); //true means update save controls 105 105 InputControlUpdatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,search_scalar,true); 106 106 107 107 if(controlconvergence(J[n],tol_cm)) break; 108 108 } -
issm/trunk/src/c/solutions/controlconvergence.cpp
r13395 r13975 19 19 bool controlconvergence(IssmDouble J, IssmDouble tol_cm){ 20 20 21 int i;22 21 bool converged=false; 23 22 -
issm/trunk/src/c/solutions/controltao_core.cpp
r13395 r13975 54 54 55 55 /*Initialize TAO*/ 56 TaoCreate( PETSC_COMM_WORLD,&tao);56 TaoCreate(IssmComm::GetComm(),&tao); 57 57 if(VerboseControl()) _pprintLine_(" Initializing the Toolkit for Advanced Optimization (TAO)"); 58 58 TaoSetFromOptions(tao); … … 99 99 /*Clean up and return*/ 100 100 xDelete<int>(control_list); 101 xDelete<double>(user.J); 101 102 xdelete(&X); 102 103 TaoDestroy(&tao); … … 141 142 142 143 /*Compute objective function*/ 143 CostFunctionx(fcn,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);144 femmodel->CostFunctionx(fcn); 144 145 145 146 /*Compute gradient*/ … … 173 174 /*Retrieve objective functions independently*/ 174 175 for(i=0;i<num_responses;i++){ 175 Responsex(&f,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,EnumToStringx(responses[i]),false,i);176 femmodel->Responsex(&f,EnumToStringx(responses[i]),false,i); 176 177 _pprintString_(" "<<setw(12)<<setprecision(7)<<f); 177 178 } -
issm/trunk/src/c/solutions/diagnostic_core.cpp
r13395 r13975 60 60 61 61 if(ishutter){ 62 62 63 63 if(VerboseSolution()) _pprintLine_(" computing hutter velocities"); 64 64 … … 68 68 femmodel->SetCurrentConfiguration(DiagnosticHutterAnalysisEnum); 69 69 solver_linear(femmodel); 70 70 71 71 if (ismacayealpattyn) ResetBoundaryConditions(femmodel,DiagnosticHorizAnalysisEnum); 72 72 } 73 73 74 74 if ((ismacayealpattyn || isl1l2) ^ isstokes){ // ^ = xor 75 75 76 76 if(VerboseSolution()) _pprintLine_(" computing velocities"); 77 77 femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum); … … 95 95 } 96 96 97 98 97 if(save_results){ 99 98 if(VerboseSolution()) _pprintLine_(" saving results"); … … 103 102 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,PressureEnum); 104 103 if(dim==3) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VzEnum); 105 RequestedOutputsx(femmodel->results,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,requested_outputs,numoutputs);104 femmodel->RequestedOutputsx(requested_outputs,numoutputs); 106 105 } 106 107 if(solution_type==DiagnosticSolutionEnum)femmodel->RequestedDependentsx(); 107 108 108 109 /*Free ressources:*/ -
issm/trunk/src/c/solutions/hydrology_core.cpp
r13395 r13975 44 44 /*Loop through time: */ 45 45 for(i=0;i<nsteps;i++){ 46 46 47 47 if(nsteps)if(VerboseSolution()) _pprintLine_("time step:" << i+1 << "/" << nsteps); 48 48 time+=dt; … … 57 57 //InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,HydrologyWaterVxEnum,i+1,time); 58 58 //InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,HydrologyWaterVyEnum,i+1,time); 59 59 60 60 /*unload results*/ 61 61 if(VerboseSolution()) _pprintLine_(" saving temporary results"); … … 64 64 } 65 65 } 66 -
issm/trunk/src/c/solutions/hydrology_core_step.cpp
r13395 r13975 14 14 15 15 void hydrology_core_step(FemModel* femmodel,int step, IssmDouble time){ 16 16 17 17 bool modify_loads=true; 18 18 -
issm/trunk/src/c/solutions/issm.cpp
r13395 r13975 1 1 /*!\file: issm.cpp 2 * \brief: ISSM main p arallel program2 * \brief: ISSM main program 3 3 */ 4 4 5 5 #include "../issm.h" 6 #include "../include/globals.h"7 #include "../shared/Numerics/adolc_edf.h"8 6 9 7 int main(int argc,char **argv){ 10 8 11 /*I/O: */ 12 FILE *output_fid = NULL; 13 FILE *petscoptionsfid = NULL; 14 bool waitonlock = false; 15 bool dakota_analysis,control_analysis,tao_analysis; 9 /*Initialize exception trapping: */ 10 ExceptionTrapBegin(); 16 11 17 /*AD: */ 18 bool autodiff=false; 19 size_t tape_stats[11]; 12 /*Initialize environment (MPI, PETSC, MUMPS, etc ...)*/ 13 COMM comm_init=EnvironmentInit(argc,argv); 20 14 21 /* FemModel: */22 FemModel *femmodel = NULL;15 /*Initialize femmodel from arguments provided command line: */ 16 FemModel *femmodel = new FemModel(argc,argv,comm_init); 23 17 24 /*configuration: */ 25 void (*solutioncore)(FemModel*)=NULL; //core solution function pointer 26 int* analyses=NULL; 27 int numanalyses; 28 int solution_type; 18 /*Solve: */ 19 femmodel->Solve(); 29 20 30 /*File names*/ 31 char *lockfilename = NULL; 32 char *binfilename = NULL; 33 char *outbinfilename = NULL; 34 char *petscfilename = NULL; 35 char *rootpath = NULL; 21 /*Output results: */ 22 femmodel->OutputResults(); 36 23 37 /*time*/ 38 IssmPDouble start, finish; 39 IssmPDouble start_core, finish_core; 40 IssmPDouble start_init, finish_init; 41 int ierr; 42 43 /*profiling*/ 44 bool profiling = false; 45 IssmPDouble Time_start, Flops_start; 46 IssmPDouble Solution_time, Memory_use, Current_flops; 47 48 ISSMBOOT(); 49 50 51 /*Initialize environments: Petsc, MPI, etc...: */ 52 #ifdef _HAVE_PETSC_ 53 ierr=PetscInitialize(&argc,&argv,(char*)0,""); 54 if(ierr) _error_("Could not initialize Petsc"); 55 #else 56 #ifdef _HAVE_MPI_ 57 MPI_Init(&argc,&argv); 58 #endif 59 #endif 60 61 #ifdef _HAVE_MPI_ 62 MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime(); 63 #else 64 start=(IssmPDouble)clock(); 65 #endif 66 67 /*Size and rank: */ 68 #ifdef _HAVE_MPI_ 69 MPI_Comm_rank(MPI_COMM_WORLD,&my_rank); 70 MPI_Comm_size(MPI_COMM_WORLD,&num_procs); 71 #endif 72 73 /*First process inputs*/ 74 _pprintLine_(""); 75 _pprintLine_("Ice Sheet System Model (" << PACKAGE_NAME << ") version " << PACKAGE_VERSION); 76 _pprintLine_("(website: " << PACKAGE_URL << " contact: " << PACKAGE_BUGREPORT << ")"); 77 _pprintLine_(""); 78 ProcessArguments(&solution_type,&binfilename,&outbinfilename,&petscfilename,&lockfilename,&rootpath,argc,argv); 79 80 /*out of solution_type, figure out types of analyses needed in the femmodel: */ 81 AnalysisConfiguration(&analyses,&numanalyses,solution_type); 82 83 /*before we create the model, start the trace on for AD mode: */ 84 #ifdef _HAVE_ADOLC_ 85 trace_on(1); 86 #endif 87 88 /*Create femmodel, using input file: */ 89 #ifdef _HAVE_MPI_ 90 MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime(); 91 #else 92 start_init=(IssmPDouble)clock(); 93 #endif 94 femmodel=new FemModel(rootpath,binfilename,outbinfilename,solution_type,analyses,numanalyses); 95 96 /*get type of solution we are going to run: */ 97 CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type); 98 99 /*Open output file once for all*/ 100 output_fid=pfopen(outbinfilename,"wb"); 101 femmodel->parameters->SetParam(output_fid,OutputFilePointerEnum); 102 103 /*add petsc options to parameters: */ 104 petscoptionsfid=pfopen(petscfilename,"r"); 105 ParsePetscOptionsx(femmodel->parameters,petscoptionsfid); 106 pfclose(petscoptionsfid,petscfilename); 107 108 /*get parameters: */ 109 femmodel->parameters->FindParam(&waitonlock,SettingsWaitonlockEnum); 110 femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum); 111 femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum); 112 femmodel->parameters->FindParam(&tao_analysis,InversionTaoEnum); 113 femmodel->parameters->FindParam(&profiling,DebugProfilingEnum); 114 femmodel->parameters->FindParam(&autodiff,AutodiffIsautodiffEnum); 115 116 #ifdef _HAVE_MPI_ 117 MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime(); 118 #else 119 finish_init=(IssmPDouble)clock(); 120 #endif 121 122 /*If running AD, then initialize the tape: */ 123 #ifdef _HAVE_ADOLC_ 124 GenericParam<Adolc_edf> *theAdolcEDF_p=new GenericParam<Adolc_edf>(AdolcParamEnum); 125 theAdolcEDF_p->GetParameterValue().myEDF_for_solverx_p=reg_ext_fct(EDF_for_solverx); 126 femmodel->parameters->AddObject(theAdolcEDF_p); 127 #else 128 if(autodiff) _error_("ISSM was not compiled with ADOLC support, cannot carry out autodiff analysis!"); 129 #endif 130 131 _pprintLine_("call computational core:"); 132 #ifdef _HAVE_MPI_ 133 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( ); 134 #else 135 start_core=(IssmPDouble)clock(); 136 #endif 137 138 if(profiling)ProfilingStart(&Time_start,&Flops_start); 139 140 if(dakota_analysis){ 141 #ifdef _HAVE_DAKOTA_ 142 Dakotax(femmodel); 143 #else 144 _error_("ISSM was not compiled with dakota support, cannot carry out dakota analysis!"); 145 #endif 146 } 147 else if(control_analysis){ 148 #ifdef _HAVE_CONTROL_ 149 if(tao_analysis) 150 controltao_core(femmodel); 151 else 152 control_core(femmodel); 153 #else 154 _error_("ISSM was not compiled with control support, cannot carry out dakota analysis!"); 155 #endif 156 } 157 else{ 158 solutioncore(femmodel); 159 } 160 161 if(profiling){ 162 ProfilingEnd(&Solution_time,&Memory_use,&Current_flops,Time_start,Flops_start); 163 femmodel->results->AddObject(new GenericExternalResult<double>(femmodel->results->Size()+1, ProfilingSolutionTimeEnum, Solution_time, 1, 0)); 164 femmodel->results->AddObject(new GenericExternalResult<double>(femmodel->results->Size()+1, ProfilingCurrentMemEnum, Memory_use, 1, 0)); 165 femmodel->results->AddObject(new GenericExternalResult<double>(femmodel->results->Size()+1, ProfilingCurrentFlopsEnum, Current_flops, 1, 0)); 166 } 167 168 #ifdef _HAVE_ADOLC_ 169 if(autodiff){ 170 trace_off(); 171 AutodiffDriversx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results); 172 } 173 #endif 174 175 176 #ifdef _HAVE_MPI_ 177 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( ); 178 #else 179 finish_core=(IssmPDouble)clock(); 180 #endif 181 182 _pprintLine_("write results to disk:"); 183 OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results); 184 185 /*If running AD, close our tape, print statistics: {{{*/ 186 #ifdef _HAVE_ADOLC_ 187 if(autodiff){ 188 tapestats(1,tape_stats); //reading of tape statistics 189 _pprintLine_(" ADOLC statistics: "); 190 _pprintLine_(" "<<setw(45)<<left<<"Number of independents: " <<tape_stats[0]); 191 _pprintLine_(" "<<setw(45)<<left<<"Number of dependents: " <<tape_stats[1]); 192 _pprintLine_(" "<<setw(45)<<left<<"Maximal number of live active variables: " <<tape_stats[2]); 193 _pprintLine_(" "<<setw(45)<<left<<"Size of value stack (number of overwrites): " <<tape_stats[3]); 194 _pprintLine_(" "<<setw(45)<<left<<"Buffer size (a multiple of eight): " <<tape_stats[4]); 195 _pprintLine_(" "<<setw(45)<<left<<"Total number of operations recorded: " <<tape_stats[5]); 196 } 197 #endif /*}}}*/ 198 199 /*Close output and petsc options file and write lock file if requested*/ 200 pfclose(output_fid,lockfilename); 201 if (waitonlock>0){ 202 _pprintLine_("write lock file:"); 203 WriteLockFile(lockfilename); 204 } 205 206 /*Free resources */ 207 xDelete<int>(analyses); 208 xDelete<char>(lockfilename); 209 xDelete<char>(binfilename); 210 xDelete<char>(outbinfilename); 211 xDelete<char>(petscfilename); 212 xDelete<char>(rootpath); 24 /*Wrap up: */ 213 25 delete femmodel; 214 26 215 /*Get finish time and close*/ 216 #ifdef _HAVE_MPI_ 217 MPI_Barrier(MPI_COMM_WORLD); finish = MPI_Wtime( ); 218 _pprintLine_(""); 219 _pprintLine_(" "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<finish_init-start_init); 220 _pprintLine_(" "<<setw(40)<<left<<"Core solution elapsed time:"<<finish_core-start_core); 221 _pprintLine_(""); 222 _pprintLine_(" Total elapsed time:"<<int((finish-start)/3600)<<" hrs "<<int(int(finish-start)%3600/60)<<" min "<<int(finish-start)%60<<" sec"); 223 _pprintLine_(""); 224 #else 225 finish=(IssmPDouble)clock(); 226 _pprintLine_(""); 227 _pprintLine_(" "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<(finish_init-start_init)/CLOCKS_PER_SEC); 228 _pprintLine_(" "<<setw(40)<<left<<"Core solution elapsed time:"<<(finish_core-start_core)/CLOCKS_PER_SEC); 229 _pprintLine_(""); 230 _pprintLine_(" Total elapsed time:" 231 <<int((finish-start)/CLOCKS_PER_SEC/3600)<<" hrs " 232 <<int(int(finish-start)/CLOCKS_PER_SEC%3600/60)<<" min " 233 <<int(finish-start)/CLOCKS_PER_SEC%60<<" sec"); 234 _pprintLine_(""); 235 #endif 236 237 #ifdef _HAVE_PETSC_ 238 _pprintLine_("closing MPI and Petsc"); 239 PetscFinalize(); 240 #else 241 #ifdef _HAVE_MPI_ 242 _pprintLine_("closing MPI and Petsc"); 243 MPI_Finalize(); 244 #endif 245 #endif 27 /*Finalize environment:*/ 28 EnvironmentFinalize(); 246 29 247 248 /*end module: */ 249 ISSMEND(); 30 /*Finalize exception trapping: */ 31 ExceptionTrapEnd(); 250 32 251 return 0; //unix success return; 33 /*Return unix success: */ 34 return 0; 252 35 } -
issm/trunk/src/c/solutions/kriging.cpp
r13395 r13975 4 4 5 5 #include "../issm.h" 6 #include "../include/globals.h"7 6 8 7 /*Local prototypes*/ 9 8 void ProcessArguments2(char** pbinfilename,char** poutbinfilename,char** plockfilename,char** prootpath,int argc,char **argv); 10 9 void ProcessInputfile(IssmDouble **px,IssmDouble **py,IssmDouble **pdata,int *pnobs,IssmDouble **px_interp,IssmDouble **py_interp,int *pninterp,Options **poptions,FILE* fid); 10 11 int my_rank; 12 int num_procs; 11 13 12 14 int main(int argc,char **argv){ … … 23 25 char *rootpath = NULL; 24 26 27 MPI_Comm comm; 28 extern int my_rank; 29 extern int num_procs; 30 25 31 /*Input*/ 26 32 int ninterp,nobs; … … 36 42 IssmDouble *error = NULL; 37 43 38 ISSMBOOT(); 44 /*Initialize exception trapping: */ 45 ExceptionTrapBegin(); 39 46 40 /*Initialize environments: Petsc, MPI, etc...: */ 41 #ifdef _HAVE_PETSC_ 42 int ierr=PetscInitialize(&argc,&argv,(char*)0,""); 43 if(ierr) _error_("Could not initialize Petsc"); 44 #else 45 #ifdef _HAVE_MPI_ 46 MPI_Init(&argc,&argv); 47 #endif 48 #endif 47 /*Initialize environment (MPI, PETSC, MUMPS, etc ...)*/ 48 comm=EnvironmentInit(argc,argv); 49 49 50 /*Size and rank: */ 51 #ifdef _HAVE_MPI_ 52 MPI_Comm_rank(MPI_COMM_WORLD,&my_rank); 53 MPI_Comm_size(MPI_COMM_WORLD,&num_procs); 54 #endif 50 MPI_Comm_size(comm,&num_procs); 51 MPI_Comm_rank(comm,&my_rank); 55 52 56 53 /*First process inputs*/ … … 76 73 results->AddObject(new GenericExternalResult<double*>(results->Size()+1,1,error,ninterp,1,1,0)); 77 74 for(int i=0;i<results->Size();i++){ 78 ExternalResult* result= (ExternalResult*)results->GetObjectByOffset(i);75 ExternalResult* result=dynamic_cast<ExternalResult*>(results->GetObjectByOffset(i)); 79 76 result->WriteData(output_fid,1); 80 77 } … … 101 98 delete results; 102 99 103 #ifdef _HAVE_PETSC_ 104 _pprintLine_("closing MPI and Petsc"); 105 PetscFinalize(); 106 #else 107 #ifdef _HAVE_MPI_ 108 _pprintLine_("closing MPI and Petsc"); 109 MPI_Finalize(); 110 #endif 111 #endif 100 /*Finalize environment:*/ 101 EnvironmentFinalize(); 112 102 113 /* end module: */114 ISSMEND();103 /*Finalize exception trapping: */ 104 ExceptionTrapEnd(); 115 105 116 106 return 0; //unix success return; … … 166 156 Option *option = NULL; 167 157 168 int dummy,M,N;158 int M,N; 169 159 IoModel* iomodel = new IoModel(); 170 160 iomodel->fid=fid; -
issm/trunk/src/c/solutions/objectivefunction.cpp
r13395 r13975 22 22 IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs){ 23 23 24 int i;25 26 24 /*output: */ 27 25 IssmDouble J; 28 26 29 27 /*parameters: */ 30 28 int solution_type,analysis_type; … … 70 68 71 69 /*Compute misfit for this velocity field.*/ 72 CostFunctionx(&J, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters);70 femmodel->CostFunctionx(&J); 73 71 74 72 /*Free ressources:*/ -
issm/trunk/src/c/solutions/prognostic_core.cpp
r13395 r13975 17 17 bool save_results; 18 18 bool issmbgradients,ispdd,isdelta18o; 19 int solution_type; 20 int *requested_outputs = NULL; 21 int numoutputs=0; 19 22 20 23 /*activate formulation: */ 21 24 femmodel->SetCurrentConfiguration(PrognosticAnalysisEnum); 22 25 23 26 /*recover parameters: */ 24 27 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); … … 26 29 femmodel->parameters->FindParam(&ispdd,SurfaceforcingsIspddEnum); 27 30 femmodel->parameters->FindParam(&isdelta18o,SurfaceforcingsIsdelta18oEnum); 31 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum); 32 femmodel->parameters->FindParam(&numoutputs,PrognosticNumRequestedOutputsEnum); 33 if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,PrognosticRequestedOutputsEnum); 28 34 29 35 if(issmbgradients){ … … 41 47 if(VerboseSolution()) _pprintLine_(" call computational core"); 42 48 solver_linear(femmodel); 43 49 44 50 if(save_results){ 45 51 if(VerboseSolution()) _pprintLine_(" saving results"); 46 52 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ThicknessEnum); 53 femmodel->RequestedOutputsx(requested_outputs,numoutputs); 47 54 } 55 56 if(solution_type==PrognosticSolutionEnum)femmodel->RequestedDependentsx(); 57 58 /*Free ressources:*/ 59 xDelete<int>(requested_outputs); 48 60 } -
issm/trunk/src/c/solutions/solutions.h
r13395 r13975 8 8 #include "../classes/objects/objects.h" 9 9 #include "../io/io.h" 10 #include "../toolkits/toolkits.h" 10 11 11 12 struct OptArgs; … … 30 31 void steadystate_core(FemModel* femmodel); 31 32 void transient_core(FemModel* femmodel); 33 void dakota_core(FemModel* femmodel); 34 void ad_core(FemModel* femmodel); 32 35 IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs); 33 36 … … 45 48 void controlrestart(FemModel* femmodel,IssmDouble* J); 46 49 void ResetBoundaryConditions(FemModel* femmodel, int analysis_type); 50 COMM EnvironmentInit(int argc,char** argv); 51 void EnvironmentFinalize(void); 52 int DakotaSpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter); 53 void PrintBanner(void); 47 54 48 55 //solution configuration 49 56 void AnalysisConfiguration(int** panalyses,int* pnumanalyses, int solutiontype); 50 57 void CorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype); 58 void WrapperCorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype,bool nodakotacore=false); 51 59 void AdjointCorePointerFromSolutionEnum(void (**padjointcore)(FemModel*),int solutiontype); 52 60 -
issm/trunk/src/c/solutions/steadystate_core.cpp
r13395 r13975 29 29 int numoutputs = 0; 30 30 int *requested_outputs = NULL; 31 31 32 32 /* recover parameters:*/ 33 33 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); … … 42 42 43 43 for(;;){ 44 44 45 45 if(VerboseSolution()) _pprintLine_(" computing temperature and velocity for step: " << step); 46 46 #ifdef _HAVE_THERMAL_ … … 66 66 break; 67 67 } 68 68 69 69 if(VerboseSolution()) _pprintLine_(" saving velocity, temperature and pressure to check for convergence at next step"); 70 70 InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum,VxPicardEnum); … … 73 73 InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,PressureEnum,PressurePicardEnum); 74 74 InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,TemperatureEnum,TemperatureOldEnum); 75 75 76 76 //increase counter 77 77 step++; 78 78 } 79 79 80 80 if(save_results){ 81 81 if(VerboseSolution()) _pprintLine_(" saving results"); … … 89 89 if(isenthalpy) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,EnthalpyEnum); 90 90 if(!isenthalpy) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BasalforcingsMeltingRateEnum); 91 RequestedOutputsx(femmodel->results,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,requested_outputs,numoutputs);91 femmodel->RequestedOutputsx(requested_outputs,numoutputs); 92 92 } 93 93 -
issm/trunk/src/c/solutions/steadystateconvergence.cpp
r13395 r13975 18 18 19 19 bool steadystateconvergence(FemModel* femmodel){ 20 20 21 21 /*output: */ 22 22 bool converged=false; … … 32 32 /*retrieve parameters: */ 33 33 femmodel->parameters->FindParam(&convergencecriterionvalue[0],SteadystateReltolEnum); 34 34 35 35 /*figure out convergence at the input level, because we don't have the solution vectors!: */ 36 36 velocity_converged=InputConvergencex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,&velocityenums[0],8,&convergencecriterion[0],&convergencecriterionvalue[0],1); -
issm/trunk/src/c/solutions/surfaceslope_core.cpp
r13395 r13975 26 26 femmodel->SetCurrentConfiguration(SurfaceSlopeAnalysisEnum,SurfaceSlopeYAnalysisEnum); 27 27 solver_linear(femmodel); 28 28 29 29 if(save_results){ 30 30 if(VerboseSolution()) _pprintLine_("saving results:"); -
issm/trunk/src/c/solutions/thermal_core.cpp
r13395 r13975 16 16 17 17 /*intermediary*/ 18 IssmDouble melting_offset;19 18 bool save_results; 20 19 bool dakota_analysis = false; -
issm/trunk/src/c/solutions/transient_core.cpp
r13395 r13975 31 31 int numoutputs = 0; 32 32 int *requested_outputs = NULL; 33 33 34 34 /*intermediary: */ 35 35 int step; … … 78 78 /*Increment*/ 79 79 if(time_adapt){ 80 TimeAdaptx(&dt,femmodel->elements, femmodel->nodes,femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters);80 femmodel->TimeAdaptx(&dt); 81 81 if(time+dt>finaltime) dt=finaltime-time; 82 82 femmodel->parameters->SetParam(dt,TimesteppingTimeStepEnum); … … 107 107 #endif 108 108 } 109 109 110 110 if(isdiagnostic){ 111 111 if(VerboseSolution()) _pprintLine_(" computing new velocity"); … … 121 121 prognostic_core(femmodel); 122 122 if(VerboseSolution()) _pprintLine_(" updating vertices positions"); 123 UpdateVertexPositionsx(femmodel->elements, femmodel->nodes,femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters);123 femmodel->UpdateVertexPositionsx(); 124 124 } 125 125 … … 140 140 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceforcingsMassBalanceEnum); 141 141 InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,MaskElementonfloatingiceEnum); 142 RequestedOutputsx(femmodel->results,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,requested_outputs,numoutputs);142 femmodel->RequestedOutputsx(requested_outputs,numoutputs); 143 143 144 144 if(isdelta18o){ … … 152 152 } 153 153 154 RequestedDependentsx(femmodel->results,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);155 154 femmodel->RequestedDependentsx(); 155 156 156 /*Free ressources:*/ 157 157 xDelete<int>(requested_outputs); -
issm/trunk/src/c/solvers/solver_adjoint_linear.cpp
r13395 r13975 24 24 /*Recover parameters: */ 25 25 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 26 UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);26 femmodel->UpdateConstraintsx(); 27 27 28 SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);28 femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL); 29 29 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 30 30 Reduceloadx(pf, Kfs, ys,true); xdelete(&Kfs); //true means spc = 0 -
issm/trunk/src/c/solvers/solver_linear.cpp
r13395 r13975 22 22 /*Recover parameters: */ 23 23 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 24 UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);24 femmodel->UpdateConstraintsx(); 25 25 26 SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);26 femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL); 27 27 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 28 28 Reduceloadx(pf, Kfs, ys); xdelete(&Kfs); -
issm/trunk/src/c/solvers/solver_newton.cpp
r13395 r13975 15 15 /*intermediary: */ 16 16 bool converged; 17 int num_unstable_constraints;18 17 int count; 19 18 IssmDouble kmax; … … 38 37 femmodel->parameters->FindParam(&max_nonlinear_iterations,DiagnosticMaxiterEnum); 39 38 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 40 UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);39 femmodel->UpdateConstraintsx(); 41 40 42 41 count=1; … … 57 56 58 57 /*Solver forward model*/ 59 SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);58 femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL); 60 59 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 61 60 Reduceloadx(pf,Kfs,ys);xdelete(&Kfs); … … 84 83 85 84 /*Prepare next iteration using Newton's method*/ 86 SystemMatricesx(&Kff,&Kfs,&pf,NULL,&kmax,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);85 femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL); 87 86 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 88 87 Reduceloadx(pf,Kfs,ys); xdelete(&Kfs); … … 91 90 pJf->Scale(-1.0); pJf->AXPY(pf,+1.0); xdelete(&pf); 92 91 93 CreateJacobianMatrixx(&Jff,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,kmax);92 femmodel->CreateJacobianMatrixx(&Jff,kmax); 94 93 Solverx(&duf,Jff,pJf,NULL,NULL,femmodel->parameters); xdelete(&Jff); xdelete(&pJf); 95 94 uf->AXPY(duf, 1.0); xdelete(&duf); -
issm/trunk/src/c/solvers/solver_nonlinear.cpp
r13395 r13975 23 23 Vector<IssmDouble>* df = NULL; 24 24 Vector<IssmDouble>* ys = NULL; 25 26 Loads* loads=NULL;25 26 Loads* savedloads=NULL; 27 27 bool converged; 28 28 int constraints_converged; … … 33 33 int min_mechanical_constraints; 34 34 int max_nonlinear_iterations; 35 int 35 int configuration_type; 36 36 37 37 /*Recover parameters: */ … … 39 39 femmodel->parameters->FindParam(&max_nonlinear_iterations,DiagnosticMaxiterEnum); 40 40 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 41 UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);41 femmodel->UpdateConstraintsx(); 42 42 43 43 /*Were loads requested as output? : */ 44 if(conserve_loads) loads=(Loads*)femmodel->loads->Copy(); //protect loads from being modified by the solution 45 else loads=(Loads*)femmodel->loads; //modify loads in this solution 44 if(conserve_loads){ 45 savedloads = static_cast<Loads*>(femmodel->loads->Copy()); 46 } 46 47 47 48 count=1; … … 49 50 50 51 /*Start non-linear iteration using input velocity: */ 51 GetSolutionFromInputsx(&ug, femmodel->elements, femmodel->nodes, femmodel->vertices, 52 GetSolutionFromInputsx(&ug, femmodel->elements, femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters); 52 53 Reducevectorgtofx(&uf, ug, femmodel->nodes,femmodel->parameters); 53 54 … … 62 63 xdelete(&old_uf);old_uf=uf; 63 64 64 SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,loads,femmodel->materials,femmodel->parameters);65 femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL); 65 66 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 66 67 Reduceloadx(pf, Kfs, ys); xdelete(&Kfs); … … 72 73 InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug); 73 74 74 ConstraintsStatex(&constraints_converged, &num_unstable_constraints, femmodel->elements,femmodel->nodes,femmodel->vertices, loads,femmodel->materials,femmodel->parameters);75 ConstraintsStatex(&constraints_converged, &num_unstable_constraints, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 75 76 if(VerboseConvergence()) _pprintLine_(" number of unstable constraints: " << num_unstable_constraints); 76 77 … … 108 109 109 110 /*clean-up*/ 110 if(conserve_loads) delete loads; 111 if(conserve_loads){ 112 delete femmodel->loads; 113 femmodel->loads=savedloads; 114 } 111 115 xdelete(&uf); 112 116 xdelete(&ug); -
issm/trunk/src/c/solvers/solver_stokescoupling_nonlinear.cpp
r13395 r13975 14 14 15 15 /*intermediary: */ 16 Matrix<IssmDouble> * Kff_horiz= NULL;17 Matrix<IssmDouble> * Kfs_horiz= NULL;18 Vector<IssmDouble> * ug_horiz= NULL;19 Vector<IssmDouble> * uf_horiz= NULL;20 Vector<IssmDouble> *old_uf_horiz = NULL;21 Vector<IssmDouble> * pf_horiz= NULL;22 Vector<IssmDouble> * df_horiz= NULL;23 Matrix<IssmDouble> * Kff_vert= NULL;24 Matrix<IssmDouble> * Kfs_vert= NULL;25 Vector<IssmDouble> * ug_vert= NULL;26 Vector<IssmDouble> * uf_vert= NULL;27 Vector<IssmDouble> * pf_vert= NULL;28 Vector<IssmDouble> * df_vert= NULL;29 Vector<IssmDouble> * ys= NULL;16 Matrix<IssmDouble> *Kff_horiz = NULL; 17 Matrix<IssmDouble> *Kfs_horiz = NULL; 18 Vector<IssmDouble> *ug_horiz = NULL; 19 Vector<IssmDouble> *uf_horiz = NULL; 20 Vector<IssmDouble> *old_uf_horiz = NULL; 21 Vector<IssmDouble> *pf_horiz = NULL; 22 Vector<IssmDouble> *df_horiz = NULL; 23 Matrix<IssmDouble> *Kff_vert = NULL; 24 Matrix<IssmDouble> *Kfs_vert = NULL; 25 Vector<IssmDouble> *ug_vert = NULL; 26 Vector<IssmDouble> *uf_vert = NULL; 27 Vector<IssmDouble> *pf_vert = NULL; 28 Vector<IssmDouble> *df_vert = NULL; 29 Vector<IssmDouble> *ys = NULL; 30 30 bool converged; 31 int constraints_converged;32 int num_unstable_constraints;33 31 int count; 34 32 … … 41 39 femmodel->parameters->FindParam(&min_mechanical_constraints,DiagnosticRiftPenaltyThresholdEnum); 42 40 femmodel->parameters->FindParam(&max_nonlinear_iterations,DiagnosticMaxiterEnum); 43 UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);44 41 femmodel->UpdateConstraintsx(); 42 45 43 count=1; 46 44 converged=false; … … 56 54 femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum); 57 55 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 58 56 59 57 //Update once again the solution to make sure that vx and vxold are similar (for next step in transient or steadystate) 60 58 InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug_horiz); … … 65 63 66 64 /*solve: */ 67 SystemMatricesx(&Kff_horiz, &Kfs_horiz, &pf_horiz, &df_horiz, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);65 femmodel->SystemMatricesx(&Kff_horiz, &Kfs_horiz, &pf_horiz, &df_horiz, NULL); 68 66 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 69 67 Reduceloadx(pf_horiz, Kfs_horiz, ys); xdelete(&Kfs_horiz); … … 77 75 femmodel->SetCurrentConfiguration(DiagnosticVertAnalysisEnum); 78 76 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 79 77 80 78 /*solve: */ 81 SystemMatricesx(&Kff_vert, &Kfs_vert, &pf_vert, &df_vert,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);79 femmodel->SystemMatricesx(&Kff_vert, &Kfs_vert, &pf_vert, &df_vert,NULL); 82 80 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 83 81 Reduceloadx(pf_vert, Kfs_vert, ys); xdelete(&Kfs_vert); -
issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp
r13395 r13975 36 36 int configuration_type; 37 37 38 39 38 /*Recover parameters: */ 40 39 kflag=1; pflag=1; … … 50 49 InputUpdateFromConstantx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,true,ResetPenaltiesEnum); 51 50 InputUpdateFromConstantx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,false,ConvergedEnum); 52 UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);51 femmodel->UpdateConstraintsx(); 53 52 54 53 for(;;){ 55 54 56 SystemMatricesx(&Kff, &Kfs, &pf,&df, &melting_offset,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);55 femmodel->SystemMatricesx(&Kff, &Kfs, &pf,&df, &melting_offset); 57 56 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 58 57 Reduceloadx(pf, Kfs, ys); xdelete(&Kfs); xdelete(&tf); … … 76 75 77 76 InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum); 78 77 79 78 if(converged)break; 80 79 } -
issm/trunk/src/c/toolkits/issm/SeqMat.h
r13395 r13975 30 30 31 31 public: 32 32 33 33 int M,N; 34 34 doubletype* matrix; /*here, doubletype is either IssmDouble or IssmPDouble*/ … … 61 61 } 62 62 /*}}}*/ 63 /*FUNCTION SeqMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){{{*/ 64 SeqMat(int m,int n,int pM,int pN,int* d_nnz,int* o_nnz){ 65 66 this->M=pM; 67 this->N=pN; 68 this->matrix=NULL; 69 if(pM*pN) this->matrix=xNewZeroInit<doubletype>(pM*pN); 70 } 71 /*}}}*/ 63 72 /*FUNCTION SeqMat(doubletype* serial_mat,int M,int N,doubletype sparsity){{{*/ 64 73 SeqMat(doubletype* serial_mat,int pM,int pN,doubletype sparsity){ 65 66 int i,j;67 74 68 75 this->M=pM; -
issm/trunk/src/c/toolkits/issm/SeqVec.h
r13395 r13975 29 29 30 30 public: 31 31 32 32 doubletype* vector; 33 33 int M; … … 49 49 } 50 50 /*}}}*/ 51 /*FUNCTION SeqVec(int m,int M){{{*/ 52 SeqVec(int pm,int pM){ 53 54 this->M=pM; 55 this->vector=NULL; 56 if(this->M) this->vector=xNewZeroInit<doubletype>(pM); 57 } 58 /*}}}*/ 51 59 /*FUNCTION SeqVec(int M,bool fromlocalsize){{{*/ 52 60 SeqVec(int pM,bool fromlocalsize){ … … 59 67 /*FUNCTION SeqVec(doubletype* serial_vec,int M){{{*/ 60 68 SeqVec(doubletype* buffer,int pM){ 61 62 int i,j;63 69 64 70 this->M=pM; -
issm/trunk/src/c/toolkits/mpi/mpiincludes.h
r1 r13975 7 7 8 8 /*MPI includes: */ 9 #include "mpi.h"9 #include <mpi.h> 10 10 11 11 /*Patches: */ -
issm/trunk/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp
r12706 r13975 6 6 #include <math.h> 7 7 #include "../../../shared/shared.h" 8 #include "../../../include/types.h" 8 9 9 int DetermineLocalSize(int global_size ){10 int DetermineLocalSize(int global_size,COMM comm){ 10 11 11 12 /*output: */ … … 18 19 19 20 /*from MPI: */ 20 extern int num_procs; 21 extern int my_rank; 22 21 int num_procs; 22 int my_rank; 23 24 /*recover my_rank*/ 25 MPI_Comm_rank(comm,&my_rank); 26 MPI_Comm_size(comm,&num_procs); 27 23 28 /*We are not bound by any library, just use what seems most logical*/ 24 29 num_local_rows=xNew<int>(num_procs); … … 30 35 num_local_rows[i]=(int)floor((double)global_size/(double)num_procs); 31 36 } 32 37 33 38 /*There may be some rows left. Distribute evenly.*/ 34 39 row_rest=global_size - num_procs*(int)floor((double)global_size/(double)num_procs); … … 37 42 } 38 43 local_size=num_local_rows[my_rank]; 39 44 40 45 /*free ressources: */ 41 46 xDelete<int>(num_local_rows); -
issm/trunk/src/c/toolkits/mpi/patches/mpipatches.h
r11995 r13975 3 3 */ 4 4 5 6 5 #ifndef MPI_PATCHES_H_ 7 6 #define MPI_PATCHES_H_ 8 7 8 #include "../../../include/types.h" 9 9 10 int MPI_Boundariesfromrange(int* plower_row, int* pupper_row,int range); 11 int MPI_Lowerrow(int n); 12 int MPI_Upperrow(int n); 13 int DetermineLocalSize(int global_size); 14 15 16 10 int DetermineLocalSize(int global_size,COMM comm); 17 11 18 12 #endif -
issm/trunk/src/c/toolkits/petsc/objects/PetscMat.cpp
r13395 r13975 31 31 PetscMat::PetscMat(int M,int N){ 32 32 33 this->matrix=NewMat(M,N );33 this->matrix=NewMat(M,N,IssmComm::GetComm()); 34 34 } 35 35 /*}}}*/ … … 37 37 PetscMat::PetscMat(int M,int N, IssmDouble sparsity){ 38 38 39 this->matrix=NewMat(M,N,sparsity );39 this->matrix=NewMat(M,N,sparsity,IssmComm::GetComm()); 40 40 } 41 41 /*}}}*/ 42 /*FUNCTION PetscMat(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity){{{*/ 42 /*FUNCTION PetscMat::PetscMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){{{*/ 43 PetscMat::PetscMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){ 44 45 MatCreate(IssmComm::GetComm(),&this->matrix); 46 MatSetSizes(this->matrix,m,n,M,N); 47 MatSetFromOptions(this->matrix); 48 MatMPIAIJSetPreallocation(this->matrix,0,d_nnz,0,o_nnz); 49 //MatSetOption(this->matrix,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE); 50 51 } 52 /*}}}*/ 53 /*FUNCTION PetscMat::PetscMat(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity){{{*/ 43 54 PetscMat::PetscMat(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity){ 44 55 … … 46 57 int* idxm=NULL; 47 58 int* idxn=NULL; 48 59 49 60 if(M)idxm=xNew<int>(M); 50 61 if(N)idxn=xNew<int>(N); … … 53 64 for(i=0;i<N;i++)idxn[i]=i; 54 65 55 56 this->matrix=NewMat(M,N,sparsity); 66 this->matrix=NewMat(M,N,sparsity,IssmComm::GetComm()); 57 67 MatSetValues(this->matrix,M,idxm,N,idxn,serial_mat,INSERT_VALUES); 58 68 MatAssemblyBegin(this->matrix,MAT_FINAL_ASSEMBLY); … … 66 76 /*FUNCTION PetscMat::PetscMat(int M,int N, int connectivity, int numberofdofspernode){{{*/ 67 77 PetscMat::PetscMat(int M,int N, int connectivity,int numberofdofspernode){ 68 69 this->matrix=NewMat(M,N,connectivity,numberofdofspernode );78 79 this->matrix=NewMat(M,N,connectivity,numberofdofspernode,IssmComm::GetComm()); 70 80 71 81 } … … 78 88 79 89 /*PetscMat specific routines: */ 90 /*FUNCTION PetscMat::AllocationInfo{{{*/ 91 void PetscMat::AllocationInfo(void){ 92 93 MatInfo info; 94 MatGetInfo(this->matrix,MAT_GLOBAL_SUM,&info); 95 _pprintLine_("=========================== Stiffness matrix allocation info ==========================="); 96 _pprintLine_(""); 97 _pprintLine_(" nz_allocated: "<<info.nz_allocated); 98 _pprintLine_(" nz_used : "<<info.nz_used); 99 _pprintLine_(" nz_unneeded : "<<info.nz_unneeded<<" ("<<double(info.nz_unneeded)/double(info.nz_allocated)*100.<<"%)"); 100 _pprintLine_(""); 101 _pprintLine_("========================================================================================"); 102 } 103 /*}}}*/ 80 104 /*FUNCTION PetscMat::Echo{{{*/ 81 105 void PetscMat::Echo(void){ … … 90 114 MatAssemblyBegin(this->matrix,MAT_FINAL_ASSEMBLY); 91 115 MatAssemblyEnd(this->matrix,MAT_FINAL_ASSEMBLY); 92 #if _PETSC_MAJOR_ == 293 MatCompress(this->matrix);94 #endif95 116 96 117 } … … 99 120 IssmDouble PetscMat::Norm(NormMode mode){ 100 121 101 102 122 IssmDouble norm=0; 103 123 _assert_(this->matrix); 104 124 MatNorm(this->matrix,ISSMToPetscNormMode(mode),&norm); 105 125 106 126 return norm; 107 127 … … 128 148 _assert_(this->matrix); 129 149 _assert_(X->vector); 130 MatMultPatch(this->matrix,X->vector,AX->vector );150 MatMultPatch(this->matrix,X->vector,AX->vector,IssmComm::GetComm()); 131 151 132 152 } … … 135 155 PetscMat* PetscMat::Duplicate(void){ 136 156 137 PetscMat* output=NULL; 138 139 output=new PetscMat(); 157 PetscMat* output=new PetscMat(); 140 158 _assert_(this->matrix); 141 159 MatDuplicate(this->matrix,MAT_COPY_VALUES,&output->matrix); … … 150 168 IssmDouble* output=NULL; 151 169 152 MatToSerial(&output,this->matrix );170 MatToSerial(&output,this->matrix,IssmComm::GetComm()); 153 171 return output; 154 172 -
issm/trunk/src/c/toolkits/petsc/objects/PetscMat.h
r13395 r13975 31 31 #endif 32 32 33 /*PetscMat constructors, destructors {{{*/33 /*PetscMat constructors, destructors*/ 34 34 PetscMat(); 35 35 PetscMat(int M,int N); 36 36 PetscMat(int M,int N,IssmDouble sparsity); 37 PetscMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz); 37 38 PetscMat(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity); 38 39 PetscMat(int M,int N,int connectivity,int numberofdofspernode); 39 40 ~PetscMat(); 40 /*}}}*/ 41 /*PetscMat specific routines {{{*/ 41 42 /*PetscMat specific routines*/ 43 void AllocationInfo(void); 42 44 void Echo(void); 43 45 void Assemble(void); … … 50 52 void SetValues(int m,int* idxm,int n,int* idxn,IssmDouble* values,InsMode mode); 51 53 void Convert(MatrixType type); 52 /*}}}*/ 54 }; 53 55 54 };55 56 56 #endif //#ifndef _PETSCMAT_H_ -
issm/trunk/src/c/toolkits/petsc/objects/PetscVec.cpp
r13395 r13975 29 29 /*FUNCTION PetscVec::PetscVec(int M,bool fromlocalsize){{{*/ 30 30 PetscVec::PetscVec(int M,bool fromlocalsize){ 31 32 this->vector=NewVec(M,fromlocalsize); 31 32 this->vector=NewVec(M,IssmComm::GetComm(),fromlocalsize); 33 34 } 35 /*}}}*/ 36 /*FUNCTION PetscVec::PetscVec(int m,int M){{{*/ 37 PetscVec::PetscVec(int m,int M){ 38 39 VecCreate(IssmComm::GetComm(),&this->vector); 40 VecSetSizes(this->vector,m,M); 41 VecSetFromOptions(this->vector); 42 VecSet(this->vector,0.0); 33 43 34 44 } … … 38 48 39 49 if(petsc_vec==NULL){ 40 this->vector=NewVec(0 );50 this->vector=NewVec(0,IssmComm::GetComm()); 41 51 } 42 52 else{ … … 55 65 for(int i=0;i<M;i++) idxm[i]=i; 56 66 57 this->vector=NewVec(M );67 this->vector=NewVec(M,IssmComm::GetComm()); 58 68 VecSetValues(this->vector,M,idxm,serial_vec,INSERT_VALUES); 59 69 VecAssemblyBegin(this->vector); … … 79 89 /*FUNCTION PetscVec::Assemble{{{*/ 80 90 void PetscVec::Assemble(void){ 81 91 82 92 _assert_(this->vector); 83 93 VecAssemblyBegin(this->vector); … … 88 98 /*FUNCTION PetscVec::SetValues{{{*/ 89 99 void PetscVec::SetValues(int ssize, int* list, IssmDouble* values, InsMode mode){ 90 100 91 101 _assert_(this->vector); 92 102 VecSetValues(this->vector,ssize,list,values,ISSMToPetscInsertMode(mode)); … … 128 138 /*FUNCTION PetscVec::Duplicate{{{*/ 129 139 PetscVec* PetscVec::Duplicate(void){ 130 131 PetscVec* output=NULL; 140 132 141 _assert_(this->vector); 133 142 Vec vec_output=NULL; 134 143 VecDuplicate(this->vector,&vec_output); 135 output=new PetscVec(vec_output);144 PetscVec* output=new PetscVec(vec_output); 136 145 VecFree(&vec_output); 137 146 … … 165 174 /*FUNCTION PetscVec::ToMPISerial{{{*/ 166 175 IssmDouble* PetscVec::ToMPISerial(void){ 167 176 168 177 IssmDouble* vec_serial=NULL; 169 VecToMPISerial(&vec_serial, this->vector );178 VecToMPISerial(&vec_serial, this->vector,IssmComm::GetComm()); 170 179 return vec_serial; 171 180 -
issm/trunk/src/c/toolkits/petsc/objects/PetscVec.h
r13395 r13975 19 19 #include "../../../include/include.h" 20 20 21 22 21 /*}}}*/ 23 22 … … 31 30 #endif 32 31 33 34 /*PetscVec constructors, destructors {{{*/ 32 /*PetscVec constructors, destructors*/ 35 33 PetscVec(); 36 34 PetscVec(int M,bool fromlocalsize=false); 35 PetscVec(int m,int M); 37 36 PetscVec(IssmDouble* buffer, int M); 38 37 PetscVec(Vec petsc_vec); 39 38 ~PetscVec(); 40 /*}}}*/ 41 /*PetscVec specific routines {{{*/39 40 /*PetscVec specific routines*/ 42 41 void Echo(void); 43 42 void Assemble(void); … … 57 56 void PointwiseDivide(PetscVec* x,PetscVec* y); 58 57 IssmDouble Dot(PetscVec* vector); 59 /*}}}*/60 58 }; 61 59 -
issm/trunk/src/c/toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp
r12706 r13975 3 3 * lower row and upper row from a matrix a cpu owns. 4 4 */ 5 6 5 7 6 #ifdef HAVE_CONFIG_H … … 14 13 #include "../../../shared/shared.h" 15 14 16 void GetOwnershipBoundariesFromRange(int* plower_row,int* pupper_row,int range ){15 void GetOwnershipBoundariesFromRange(int* plower_row,int* pupper_row,int range,COMM comm){ 17 16 18 17 /*externals :*/ 19 extern int my_rank; 20 extern int num_procs; 21 18 int my_rank; 19 int num_procs; 20 21 /*recover my_rank and num_procs:*/ 22 MPI_Comm_size(comm,&num_procs); 23 MPI_Comm_rank(comm,&my_rank); 24 22 25 /*output: */ 23 26 int lower_row,upper_row; 24 25 /*intermediary :*/26 int i;27 int* allranges=NULL;28 27 29 28 /*Gather all range values into allranges, for all nodes*/ 30 allranges=xNew<int>(num_procs);31 MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT, MPI_COMM_WORLD);29 int* allranges=xNew<int>(num_procs); 30 MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,comm); 32 31 33 32 /*From all ranges, get lower row and upper row*/ 34 33 lower_row=0; 35 34 upper_row=lower_row+allranges[0]; 36 for (i=1;i<=my_rank;i++){35 for(int i=1;i<=my_rank;i++){ 37 36 lower_row=lower_row+allranges[i-1]; 38 37 upper_row=upper_row+allranges[i]; -
issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscInsertMode.cpp
r13395 r13975 2 2 * \brief: convert InsertMode from ISSM to Petsc 3 3 */ 4 5 4 6 5 #ifdef HAVE_CONFIG_H … … 11 10 12 11 /*Petsc includes: */ 13 #include "petscmat.h"14 #include "petscvec.h"15 #include "petscksp.h"12 #include <petscmat.h> 13 #include <petscvec.h> 14 #include <petscksp.h> 16 15 17 16 /*ISSM includes: */ 18 17 #include "../../toolkitsenums.h" 19 18 #include "../../../shared/shared.h" 20 21 19 22 20 InsertMode ISSMToPetscInsertMode(InsMode mode){ -
issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscMatrixType.cpp
r13395 r13975 2 2 * \brief: convert MatrixType from ISSM to Petsc 3 3 */ 4 5 4 6 5 #ifdef HAVE_CONFIG_H … … 11 10 12 11 /*Petsc includes: */ 13 #include "petscmat.h"14 #include "petscvec.h"15 #include "petscksp.h"12 #include <petscmat.h> 13 #include <petscvec.h> 14 #include <petscksp.h> 16 15 17 16 /*ISSM includes: */ … … 19 18 #include "../../../shared/shared.h" 20 19 21 22 MatType ISSMToPetscMatrixType(MatrixType type){ 20 const MatType ISSMToPetscMatrixType(MatrixType type){ 23 21 24 22 switch(type){ -
issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscNormMode.cpp
r13395 r13975 2 2 * \brief: convert NormMode from ISSM to Petsc 3 3 */ 4 5 4 6 5 #ifdef HAVE_CONFIG_H … … 11 10 12 11 /*Petsc includes: */ 13 #include "petscmat.h"14 #include "petscvec.h"15 #include "petscksp.h"12 #include <petscmat.h> 13 #include <petscvec.h> 14 #include <petscksp.h> 16 15 17 16 /*ISSM includes: */ 18 17 #include "../../toolkitsenums.h" 19 18 #include "../../../shared/shared.h" 20 21 19 22 20 NormType ISSMToPetscNormMode(NormMode mode){ -
issm/trunk/src/c/toolkits/petsc/patches/KSPFree.cpp
r9826 r13975 9 9 #endif 10 10 11 12 11 /*Petsc includes: */ 13 #include "petscmat.h"14 #include "petscvec.h"15 #include "petscksp.h"12 #include <petscmat.h> 13 #include <petscvec.h> 14 #include <petscksp.h> 16 15 17 16 void KSPFree(KSP* pksp){ … … 26 25 27 26 } 28 -
issm/trunk/src/c/toolkits/petsc/patches/MatFree.cpp
r9826 r13975 9 9 #endif 10 10 11 12 11 /*Petsc includes: */ 13 #include "petscmat.h"14 #include "petscmat.h"15 #include "petscksp.h"12 #include <petscmat.h> 13 #include <petscmat.h> 14 #include <petscksp.h> 16 15 17 16 void MatFree(Mat* pmat){ … … 26 25 27 26 } 28 -
issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp
r12706 r13975 10 10 11 11 /*Petsc includes: */ 12 #include "petscmat.h"13 #include "petscvec.h"14 #include "petscksp.h"12 #include <petscmat.h> 13 #include <petscvec.h> 14 #include <petscksp.h> 15 15 16 16 #include "../../../shared/shared.h" 17 17 18 18 /*Function prototypes: */ 19 int MatMultCompatible(Mat A,Vec x );20 void VecRelocalize(Vec* outvector,Vec vector,int m );19 int MatMultCompatible(Mat A,Vec x,COMM comm); 20 void VecRelocalize(Vec* outvector,Vec vector,int m,COMM comm); 21 21 22 void MatMultPatch(Mat A,Vec X, Vec AX ){ //same prototype as MatMult in Petsc22 void MatMultPatch(Mat A,Vec X, Vec AX,COMM comm){ //same prototype as MatMult in Petsc 23 23 24 24 int m,n; … … 27 27 _assert_(A); _assert_(X); 28 28 29 if (MatMultCompatible(A,X )){29 if (MatMultCompatible(A,X,comm)){ 30 30 MatMult(A,X,AX); 31 31 } 32 32 else{ 33 33 MatGetLocalSize(A,&m,&n);; 34 VecRelocalize(&X_rel,X,n );34 VecRelocalize(&X_rel,X,n,comm); 35 35 MatMult(A,X_rel,AX); ; 36 36 #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2) … … 42 42 } 43 43 44 int MatMultCompatible(Mat A,Vec x ){45 44 int MatMultCompatible(Mat A,Vec x,COMM comm){ 45 46 46 /*error management*/ 47 47 48 48 int local_m,local_n; 49 int lower_row,upper_row,range;49 int range; 50 50 int result=1; 51 51 int sumresult; 52 extern int num_procs; 52 int num_procs; 53 54 /*recover num_procs:*/ 55 MPI_Comm_size(comm,&num_procs); 53 56 54 57 MatGetLocalSize(A,&local_m,&local_n);; 55 58 VecGetLocalSize(x,&range);; 56 59 57 60 if (local_n!=range)result=0; 58 61 59 62 /*synchronize result: */ 60 MPI_Reduce (&result,&sumresult,1,MPI_INT,MPI_SUM,0, MPI_COMM_WORLD);61 MPI_Bcast(&sumresult,1,MPI_INT,0, MPI_COMM_WORLD);63 MPI_Reduce (&result,&sumresult,1,MPI_INT,MPI_SUM,0,comm ); 64 MPI_Bcast(&sumresult,1,MPI_INT,0,comm); 62 65 if (sumresult!=num_procs){ 63 66 result=0; … … 69 72 } 70 73 71 void VecRelocalize(Vec* poutvector,Vec vector,int m ){74 void VecRelocalize(Vec* poutvector,Vec vector,int m,COMM comm){ 72 75 73 76 /*vector index and vector values*/ … … 78 81 /*output: */ 79 82 Vec outvector=NULL; 80 83 81 84 /*Create outvector with local size m*/ 82 VecCreate( PETSC_COMM_WORLD,&outvector); ;85 VecCreate(comm,&outvector); ; 83 86 VecSetSizes(outvector,m,PETSC_DECIDE); ; 84 87 VecSetFromOptions(outvector); ; -
issm/trunk/src/c/toolkits/petsc/patches/MatToSerial.cpp
r12706 r13975 9 9 #endif 10 10 11 12 11 #include "../petscincludes.h" 13 12 #include "../../../shared/shared.h" 14 13 15 void MatToSerial(double** poutmatrix,Mat matrix ){14 void MatToSerial(double** poutmatrix,Mat matrix,COMM comm){ 16 15 17 16 int i; 18 externint my_rank;19 externint num_procs;20 17 int my_rank; 18 int num_procs; 19 21 20 /*Petsc variables*/ 22 21 PetscInt lower_row,upper_row; … … 28 27 double* local_matrix=NULL; /*matrix local to each node used for temporary holding matrix values*/ 29 28 int buffer[3]; 30 29 30 /*recover my_rank and num_procs:*/ 31 MPI_Comm_size(comm,&num_procs); 32 MPI_Comm_rank(comm,&my_rank); 33 31 34 /*Output*/ 32 35 double* outmatrix=NULL; 33 36 34 37 /*get matrix size: */ 35 38 MatGetSize(matrix,&M,&N); … … 39 42 upper_row--; 40 43 range=upper_row-lower_row+1; 41 44 42 45 /*Local and global allocation*/ 43 46 if (my_rank==0)outmatrix=xNew<double>(M*N); 44 47 45 48 if (range){ 46 49 local_matrix=xNew<double>(N*range); 47 50 idxm=xNew<int>(range); 48 51 idxn=xNew<int>(N); 49 52 50 53 for (i=0;i<N;i++){ 51 54 *(idxn+i)=i; … … 54 57 *(idxm+i)=lower_row+i; 55 58 } 56 59 57 60 MatGetValues(matrix,range,idxm,N,idxn,local_matrix); 58 61 } … … 60 63 /*Now each node holds its local_matrix containing range rows. 61 64 * We send these rows to the matrix on node 0*/ 62 65 63 66 for (i=1;i<num_procs;i++){ 64 67 if (my_rank==i){ … … 66 69 buffer[1]=lower_row; 67 70 buffer[2]=range; 68 MPI_Send(buffer,3,MPI_INT,0,1, MPI_COMM_WORLD);69 if (range)MPI_Send(local_matrix,N*range,MPI_DOUBLE,0,1, MPI_COMM_WORLD);71 MPI_Send(buffer,3,MPI_INT,0,1,comm); 72 if (range)MPI_Send(local_matrix,N*range,MPI_DOUBLE,0,1,comm); 70 73 } 71 74 if (my_rank==0){ 72 MPI_Recv(buffer,3,MPI_INT,i,1, MPI_COMM_WORLD,&status);73 if (buffer[2])MPI_Recv(outmatrix+(buffer[1]*N),N*buffer[2],MPI_DOUBLE,i,1, MPI_COMM_WORLD,&status);75 MPI_Recv(buffer,3,MPI_INT,i,1,comm,&status); 76 if (buffer[2])MPI_Recv(outmatrix+(buffer[1]*N),N*buffer[2],MPI_DOUBLE,i,1,comm,&status); 74 77 } 75 78 } … … 78 81 memcpy(outmatrix,local_matrix,N*range*sizeof(double)); 79 82 } 80 83 81 84 /*Assign output pointer: */ 82 85 *poutmatrix=outmatrix; -
issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp
r13395 r13975 10 10 11 11 /*Petsc includes: */ 12 #include "petscmat.h"13 #include "petscvec.h"14 #include "petscksp.h"12 #include <petscmat.h> 13 #include <petscvec.h> 14 #include <petscksp.h> 15 15 16 16 #include "./petscpatches.h" … … 21 21 22 22 /*NewMat(int M,int N){{{*/ 23 Mat NewMat(int M,int N ){23 Mat NewMat(int M,int N,COMM comm){ 24 24 25 25 /*output:*/ … … 32 32 33 33 /*Determine local sizes: */ 34 m=DetermineLocalSize(M );35 n=DetermineLocalSize(N );36 34 m=DetermineLocalSize(M,comm); 35 n=DetermineLocalSize(N,comm); 36 37 37 nnz=(int)((double)M*(double)N*sparsity); //number of non zeros. 38 38 d_nz=(int)((double)nnz/(double)M/2.0); //number of non zeros per row/2 … … 40 40 41 41 #if _PETSC_MAJOR_ == 3 && _PETSC_MINOR_ > 2 42 MatCreateAIJ( MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix);42 MatCreateAIJ(comm,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 43 43 #else 44 MatCreateMPIAIJ( MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix);44 MatCreateMPIAIJ(comm,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 45 45 #endif 46 46 … … 48 48 } 49 49 /*}}}*/ 50 /*NewMat(int M,int N,double sparsity ){{{*/51 Mat NewMat(int M,int N,double sparsity ){50 /*NewMat(int M,int N,double sparsity,COMM comm){{{*/ 51 Mat NewMat(int M,int N,double sparsity,COMM comm){ 52 52 53 53 /*output:*/ … … 60 60 61 61 /*Determine local sizes: */ 62 m=DetermineLocalSize(M );63 n=DetermineLocalSize(N );64 62 m=DetermineLocalSize(M,comm); 63 n=DetermineLocalSize(N,comm); 64 65 65 nnz=(int)((double)M*(double)N*sparsity); //number of non zeros. 66 66 d_nz=(int)((double)nnz/(double)M/2.0); //number of non zeros per row/2 … … 69 69 #if _PETSC_MAJOR_ == 3 && _PETSC_MINOR_ > 2 70 70 if(sparsity==1){ 71 MatCreateDense( MPI_COMM_WORLD,m,n,M,N,NULL,&outmatrix);71 MatCreateDense(comm,m,n,M,N,NULL,&outmatrix); 72 72 } 73 73 else{ 74 MatCreateAIJ( MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix);74 MatCreateAIJ(comm,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 75 75 } 76 76 #else 77 MatCreateMPIAIJ( MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix);77 MatCreateMPIAIJ(comm,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 78 78 #endif 79 79 … … 82 82 /*}}}*/ 83 83 /*NewMat(int M,int N,int connectivity,int numberofdofspernode){{{*/ 84 Mat NewMat(int M,int N,int connectivity,int numberofdofspernode ){84 Mat NewMat(int M,int N,int connectivity,int numberofdofspernode,COMM comm){ 85 85 86 86 /*output:*/ … … 90 90 int m,n; 91 91 int d_nz,o_nz; 92 int nnz;93 92 94 93 #if _PETSC_MAJOR_ >= 3 94 #ifdef _HAVE_PETSCDEV_ 95 MatType type; 96 #else 95 97 const MatType type; 98 #endif 96 99 #else 97 100 MatType type; … … 99 102 100 103 /*Determine local sizes: */ 101 m=DetermineLocalSize(M );102 n=DetermineLocalSize(N );104 m=DetermineLocalSize(M,comm); 105 n=DetermineLocalSize(N,comm); 103 106 104 107 /*Figure out number of non zeros per row: */ … … 106 109 o_nz=(int)connectivity*numberofdofspernode/2; 107 110 108 MatCreate( MPI_COMM_WORLD,&outmatrix);111 MatCreate(comm,&outmatrix); 109 112 MatSetSizes(outmatrix,m,n,M,N); 110 113 MatSetFromOptions(outmatrix); … … 112 115 /*preallocation according to type: */ 113 116 MatGetType(outmatrix,&type); 114 117 115 118 #if _PETSC_MAJOR_ == 2 116 119 if((strcmp(type,"mpiaij")==0) || (strcmp(type,"aijmumps")==0)){ -
issm/trunk/src/c/toolkits/petsc/patches/NewVec.cpp
r11995 r13975 17 17 #include "../../mpi/patches/mpipatches.h" 18 18 19 Vec NewVec(int size, bool fromlocalsize){19 Vec NewVec(int size,COMM comm,bool fromlocalsize){ 20 20 21 int ierr;22 21 int local_size; 23 22 … … 30 29 } 31 30 else{ 32 local_size=DetermineLocalSize(size );31 local_size=DetermineLocalSize(size,comm); 33 32 } 34 35 VecCreate( PETSC_COMM_WORLD,&vector);36 33 34 VecCreate(comm,&vector); 35 37 36 VecSetSizes(vector,local_size,PETSC_DECIDE); 38 37 VecSetFromOptions(vector); -
issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp
r12706 r13975 2 2 * \brief: convert a sparse or dense Petsc matrix into a matlab matrix 3 3 */ 4 5 4 6 5 #ifdef HAVE_CONFIG_H … … 13 12 14 13 /*Petsc includes: */ 15 #include "petscmat.h"16 #include "petscvec.h"17 #include "petscksp.h"14 #include <petscmat.h> 15 #include <petscvec.h> 16 #include <petscksp.h> 18 17 19 18 /*Petsc includes: */ 20 19 #include "../../../shared/shared.h" 21 20 22 23 21 void PetscMatrixToDoubleMatrix(double** pmatrix, int* prows, int* pcols,Mat petsc_matrix){ 24 22 25 int i,j,k;26 27 23 /*output: */ 24 int i; 28 25 double* matrix=NULL; 29 26 int rows,cols; 30 31 /*intermediary: */32 int* idxm=NULL;33 int* idxn=NULL;34 27 35 28 /*Some needed information: */ 36 29 MatGetSize(petsc_matrix,&rows,&cols); 37 30 38 i dxm=xNew<int>(rows);39 i dxn=xNew<int>(cols);31 int* idxm=xNew<int>(rows); 32 int* idxn=xNew<int>(cols); 40 33 41 34 for(i=0;i<rows;i++)idxm[i]=i; -
issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp
r11527 r13975 53 53 } 54 54 55 56 55 #if _PETSC_MAJOR_ >= 3 57 56 PetscOptionsGetString(PETSC_NULL,"-pc_factor_mat_solver_package",&option[0],100,&flag); … … 61 60 #endif 62 61 63 64 62 PetscOptionsGetString(PETSC_NULL,"-issm_option_solver",&option[0],100,&flag); 65 63 if (strcmp(option,"stokes")==0){ -
issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp
r13395 r13975 10 10 11 11 /*Petsc includes: */ 12 #include "petscmat.h"13 #include "petscvec.h"14 #include "petscksp.h"12 #include <petscmat.h> 13 #include <petscvec.h> 14 #include <petscksp.h> 15 15 16 16 #include "./petscpatches.h" … … 20 20 21 21 void PetscOptionsInsertMultipleString(char* options_string){ 22 23 22 24 23 /*The list of options is going to be pairs of the type "-option option_value"*/ … … 30 29 char* first=NULL; 31 30 char* second=NULL; 32 char* final=NULL;33 31 size_t len; 34 int ignore_second;35 32 int first_token=1; 36 37 33 38 34 PetscTokenCreate(options_string,' ',&token); 39 35 for (;;){ 40 41 36 42 37 /*Read next tokens*/ … … 45 40 } 46 41 PetscTokenFind(token,&second); 47 42 48 43 if (!first){ 49 44 /*We are at the end of options*/ … … 59 54 /*Reduce first to bare option value*/ 60 55 PetscStrlen(first,&len); 61 while (len > 0 && (first[len-1] == ' ' || first[len-1] == 'n')) {56 while (len > 0 && first[len-1] == ' ') { 62 57 len--; first[len] = 0; 63 58 } … … 70 65 /*Second is another option, ignore it*/ 71 66 PetscStrlen(first,&len); 72 while (len > 0 && (first[len-1] == ' ' || first[len-1] == 'n')) {67 while (len > 0 && first[len-1] == ' ' ) { 73 68 len--; first[len] = 0; 74 69 } … … 81 76 /*Second is 'first' option's value*/ 82 77 PetscStrlen(second,&len); 83 while (len > 0 && (second[len-1] == ' ' || second[len-1] == 'n')) {78 while (len > 0 && second[len-1] == ' ') { 84 79 len--; second[len] = 0; 85 80 } -
issm/trunk/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp
r12706 r13975 11 11 12 12 /*Petsc includes: */ 13 #include "petscmat.h"14 #include "petscvec.h"15 #include "petscksp.h"13 #include <petscmat.h> 14 #include <petscvec.h> 15 #include <petscksp.h> 16 16 17 17 #include "../../../shared/shared.h" … … 19 19 void PetscVectorToDoubleVector(double** pvector, int* prows, Vec petsc_vector){ 20 20 21 int i;22 21 int rows; 23 int *idxm = NULL;24 22 double *vector = NULL; 25 23 … … 28 26 VecGetSize(petsc_vector,&rows); 29 27 if(rows){ 30 i dxm=xNew<int>(rows);28 int* idxm=xNew<int>(rows); 31 29 vector=xNew<double>(rows); 32 for(i =0;i<rows;i++)idxm[i]=i;30 for(int i=0;i<rows;i++)idxm[i]=i; 33 31 VecGetValues(petsc_vector,rows,idxm,vector); 34 32 xDelete<int>(idxm); -
issm/trunk/src/c/toolkits/petsc/patches/SolverEnum.h
r9291 r13975 15 15 } EXTERNALPACKAGES; 16 16 17 18 17 #endif //ifndef _SOLVERENUM_H_ 19 -
issm/trunk/src/c/toolkits/petsc/patches/VecDuplicatePatch.cpp
r9320 r13975 9 9 #endif 10 10 11 12 11 /*Petsc includes: */ 13 #include "petscmat.h"14 #include "petscvec.h"15 #include "petscksp.h"12 #include <petscmat.h> 13 #include <petscvec.h> 14 #include <petscksp.h> 16 15 17 16 void VecDuplicatePatch(Vec* output, Vec input){ -
issm/trunk/src/c/toolkits/petsc/patches/VecFree.cpp
r9826 r13975 9 9 #endif 10 10 11 12 11 /*Petsc includes: */ 13 #include "petscmat.h"14 #include "petscvec.h"15 #include "petscksp.h"12 #include <petscmat.h> 13 #include <petscvec.h> 14 #include <petscksp.h> 16 15 17 16 void VecFree(Vec* pvec){ … … 25 24 26 25 } 27 -
issm/trunk/src/c/toolkits/petsc/patches/VecMerge.cpp
r13395 r13975 10 10 11 11 /*Petsc includes: */ 12 #include "petscmat.h"13 #include "petscvec.h"14 #include "petscksp.h"12 #include <petscmat.h> 13 #include <petscvec.h> 14 #include <petscksp.h> 15 15 16 16 #include "./petscpatches.h" … … 21 21 void VecMerge(Vec A, Vec B, double* row_partition_vector,int row_partition_size){ 22 22 23 int i;24 25 23 /*Petsc matrix*/ 26 24 int lower_row,upper_row,range; … … 29 27 30 28 /*Vector sizes: */ 31 int M A,MB;29 int MB; 32 30 33 31 VecGetSize(B,&MB); 34 32 35 33 /*If the dimension of the partitioning vector is not the same as that of vector B, we have a problem: */ 36 if ( 34 if ((row_partition_size !=MB) ){ 37 35 _error_("Dimensions of partitioning vector incompatible with dimensions of input vector\n"); 38 36 } … … 47 45 idxm=xNew<int>(range); 48 46 values=xNew<double>(range); 49 for (i=0;i<range;i++){50 *(idxm+i)=lower_row+i;47 for(int i=0;i<range;i++){ 48 idxm[i]=lower_row+i; 51 49 } 52 50 VecGetValues(B,range,idxm,values); 53 51 /*Now, modify idxm using the partition vector, and plug values into A*/ 54 for (i=0;i<range;i++){55 *(idxm+i)=(int)*(row_partition_vector+lower_row+i)-1; //-1 because partition vector comes from Matlab, where indices start at 1.52 for(int i=0;i<range;i++){ 53 idxm[i]=int(row_partition_vector[lower_row+i])-1; //-1 because partition vector comes from Matlab, where indices start at 1. 56 54 } 57 55 VecSetValues(A,range,idxm,values,INSERT_VALUES); 58 56 } 59 57 60 58 /*Assemble vector*/ 61 59 VecAssemblyBegin(A); -
issm/trunk/src/c/toolkits/petsc/patches/VecToMPISerial.cpp
r12706 r13975 9 9 #endif 10 10 11 12 11 #include "../petscincludes.h" 13 12 #include "../../../shared/shared.h" 14 13 15 int VecToMPISerial(double** pgathered_vector, Vec vector ){16 14 int VecToMPISerial(double** pgathered_vector, Vec vector,COMM comm){ 15 17 16 int i; 18 externint num_procs;19 externint my_rank;17 int num_procs; 18 int my_rank; 20 19 21 20 /*Petsc*/ … … 25 24 int * idxn=NULL; 26 25 int buffer[3]; 27 26 28 27 /*intermediary results*/ 29 28 double* local_vector=NULL; … … 31 30 /*input*/ 32 31 int vector_size; 33 32 34 33 /*Output*/ 35 34 double* gathered_vector=NULL; //Global vector holding the final assembled vector on all nodes. 35 36 /*recover my_rank and num_procs*/ 37 MPI_Comm_size(comm,&num_procs); 38 MPI_Comm_rank(comm,&my_rank); 36 39 37 40 VecGetSize(vector,&vector_size); … … 43 46 /*Allocate gathered vector on all nodes .*/ 44 47 gathered_vector=xNew<double>(vector_size); 45 48 46 49 /*Allocate local vectors*/ 47 50 VecGetOwnershipRange(vector,&lower_row,&upper_row); … … 66 69 buffer[1]=lower_row; 67 70 buffer[2]=range; 68 MPI_Send(buffer,3,MPI_INT,0,1, MPI_COMM_WORLD);69 if (range)MPI_Send(local_vector,range,MPI_DOUBLE,0,1, MPI_COMM_WORLD);71 MPI_Send(buffer,3,MPI_INT,0,1,comm); 72 if (range)MPI_Send(local_vector,range,MPI_DOUBLE,0,1,comm); 70 73 } 71 74 if (my_rank==0){ 72 MPI_Recv(buffer,3,MPI_INT,i,1, MPI_COMM_WORLD,&status);73 if (buffer[2])MPI_Recv(gathered_vector+buffer[1],buffer[2],MPI_DOUBLE,i,1, MPI_COMM_WORLD,&status);75 MPI_Recv(buffer,3,MPI_INT,i,1,comm,&status); 76 if (buffer[2])MPI_Recv(gathered_vector+buffer[1],buffer[2],MPI_DOUBLE,i,1,comm,&status); 74 77 } 75 78 } … … 81 84 82 85 /*Now, broadcast gathered_vector from node 0 to other nodes: */ 83 MPI_Bcast(gathered_vector,vector_size,MPI_DOUBLE,0, MPI_COMM_WORLD);86 MPI_Bcast(gathered_vector,vector_size,MPI_DOUBLE,0,comm); 84 87 85 88 /*Assign output pointers: */ 86 89 *pgathered_vector=gathered_vector; 87 90 88 91 /*free ressources: */ 89 92 xDelete<int>(idxn); 90 93 xDelete<double>(local_vector); 91 94 92 95 return 1; 93 96 } -
issm/trunk/src/c/toolkits/petsc/patches/petscpatches.h
r12330 r13975 6 6 #define _PETSC_PATCHES_H_ 7 7 8 #include "petscmat.h"9 #include "petscvec.h"10 #include "petscksp.h"11 #include "petscsys.h"8 #include <petscmat.h> 9 #include <petscvec.h> 10 #include <petscksp.h> 11 #include <petscsys.h> 12 12 13 13 #include "./SolverEnum.h" 14 14 #include "../../toolkitsenums.h" 15 #include "../../../include/types.h" 15 16 16 17 class Parameters; 17 18 18 Vec NewVec(int size, bool fromlocalsize=false);19 Mat NewMat(int M,int N );20 Mat NewMat(int M,int N,double sparsity );21 Mat NewMat(int M,int N,int connectivity,int numberofdofspernode );19 Vec NewVec(int size,COMM comm,bool fromlocalsize=false); 20 Mat NewMat(int M,int N,COMM comm); 21 Mat NewMat(int M,int N,double sparsity,COMM comm); 22 Mat NewMat(int M,int N,int connectivity,int numberofdofspernode, COMM comm); 22 23 23 int VecTranspose(Vec* tvector,Vec vector); 24 int VecToMPISerial(double** pgathered_vector, Vec vector); 25 void GetOwnershipBoundariesFromRange(int* plower_row,int* pupper_row,int range); 24 int VecToMPISerial(double** pgathered_vector, Vec vector,COMM comm); 26 25 void MatFree(Mat* pmat); 27 26 void ISFree(IS* pis); 28 27 void VecFree(Vec* pvec); 29 28 void KSPFree(KSP* pksp); 30 void VecPartition(Vec* poutvector,Vec vectorA, double* row_partition_vector, int row_partition_vector_size,bool kffpartitioning);31 29 int MatPartition(Mat* poutmatrix,Mat matrixA,double* row_partition_vector,int row_partition_vector_size , 32 30 double* col_partition_vector,int col_partition_vector_size); 33 void MatInvert(Mat* pInv, Mat Matrix);34 31 void PetscOptionsInsertMultipleString(char* options_string); 35 32 void PetscOptionsDetermineSolverType(int* psolver_type); 36 33 void VecMerge(Vec A, Vec B, double* row_partition_vector,int row_partition_size); 37 void MatMultPatch(Mat A,Vec X, Vec AX );38 void MatToSerial(double** poutmatrix,Mat matrix );34 void MatMultPatch(Mat A,Vec X, Vec AX,COMM comm); 35 void MatToSerial(double** poutmatrix,Mat matrix,COMM comm); 39 36 void VecDuplicatePatch(Vec* output, Vec input); 40 37 Vec SerialToVec(double* vector,int vector_size); 41 38 InsertMode ISSMToPetscInsertMode(InsMode mode); 42 39 NormType ISSMToPetscNormMode(NormMode mode); 43 MatType ISSMToPetscMatrixType(MatrixType type);40 const MatType ISSMToPetscMatrixType(MatrixType type); 44 41 45 42 void PetscMatrixToDoubleMatrix(double** pmatrix, int* prows, int* pcols,Mat matrix); -
issm/trunk/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp
r12706 r13975 3 3 */ 4 4 #include <math.h> 5 6 5 7 6 #include "../../../shared/shared.h" … … 10 9 11 10 int CyclicalFactorization(int* pnprows,int* pnpcols,int num_procs){ 12 11 13 12 int nprows,npcols; 14 13 int last_diff; … … 40 39 int PrimeDecomp(int** pdecomp,int* pdecomp_size,int input){ 41 40 42 int* decomp=NULL;43 41 int prime_factor; 44 42 int i; 45 43 46 decomp=xNew<int>(input);44 int* decomp=xNew<int>(input); 47 45 *decomp=input; 48 46 for (i=0;i<input;i++){ … … 65 63 */ 66 64 int SmallestPrimeFactor(int* output,int input){ 67 65 68 66 int found=0; 69 67 int i; -
issm/trunk/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp
r13395 r13975 14 14 15 15 void PlapackInvertMatrixLocalCleanup(PLA_Obj* pa,PLA_Template* ptempl,double** parrayA,int** pidxnA,MPI_Comm* pcomm_2d); 16 17 int PlapackInvertMatrix(Mat* A,Mat* inv_A,int status,int con ){16 17 int PlapackInvertMatrix(Mat* A,Mat* inv_A,int status,int con,COMM comm){ 18 18 /*inv_A does not yet exist, inv_A was just allocated, that's all*/ 19 19 20 20 /*Error management*/ 21 int i ,j;21 int i; 22 22 23 23 /*input*/ 24 24 int mA,nA; 25 25 int local_mA,local_nA; 26 int lower_row,upper_row ,range,this_range,this_lower_row;26 int lower_row,upper_row; 27 27 MatType type; 28 28 29 29 /*Plapack: */ 30 30 MPI_Datatype datatype; … … 36 36 int nb,nb_alg; 37 37 int nprows,npcols; 38 int initialized=0;39 38 40 39 /*Petsc to Plapack: */ 41 40 double *arrayA=NULL; 42 41 int* idxnA=NULL; 43 int d_nz,o_nz;44 45 /*Feedback to client*/46 int computation_status;47 42 48 43 /*Verify that A is square*/ … … 76 71 if(PLA_Initialized(NULL)==TRUE)PLA_Finalize(); 77 72 /* Create a 2D communicator */ 78 PLA_Comm_1D_to_2D( MPI_COMM_WORLD,nprows,npcols,&comm_2d);73 PLA_Comm_1D_to_2D(comm,nprows,npcols,&comm_2d); 79 74 80 75 /*Initlialize plapack: */ … … 92 87 /* Set the datatype */ 93 88 datatype = MPI_DOUBLE; 94 89 95 90 /* Copy A into a*/ 96 91 PLA_Matrix_create(datatype,mA,nA,templ,PLA_ALIGN_FIRST,PLA_ALIGN_FIRST,&a); … … 100 95 MatGetOwnershipRange(*A,&lower_row,&upper_row); 101 96 upper_row--; 102 range=upper_row-lower_row+1;103 97 arrayA = xNew<double>(nA); 104 98 idxnA = xNew<int>(nA); … … 127 121 xDelete<double>(arrayA); 128 122 xDelete<int>(idxnA); 129 123 130 124 /*Finalize PLAPACK*/ 131 125 PLA_Finalize(); -
issm/trunk/src/c/toolkits/plapack/patches/PlapackToPetsc.cpp
r12706 r13975 6 6 #include "../plapackincludes.h" 7 7 8 int PlapackToPetsc(Mat* A,int local_mA,int local_nA,int mA,int nA,MatType type,PLA_Obj a,PLA_Template templ,int nprows,int npcols,int nb ){8 int PlapackToPetsc(Mat* A,int local_mA,int local_nA,int mA,int nA,MatType type,PLA_Obj a,PLA_Template templ,int nprows,int npcols,int nb,COMM comm){ 9 9 10 11 10 int i; 12 11 13 int lower_row,upper_row ,range;12 int lower_row,upper_row; 14 13 int* row_nodes=NULL; 15 14 int* col_nodes=NULL; … … 22 21 double* local_buffer=NULL; 23 22 24 25 23 /*Create matrix A (right now, we just have an allocated pointer A*/ 26 24 if (strcasecmp_eq(type,MATMPIAIJ)){ … … 28 26 d_nz=nA/2; 29 27 o_nz=nA/2; 30 MatCreateMPIAIJ( MPI_COMM_WORLD,local_mA,local_nA, mA,nA,d_nz,PETSC_NULL,o_nz,PETSC_NULL,A);28 MatCreateMPIAIJ(comm,local_mA,local_nA, mA,nA,d_nz,PETSC_NULL,o_nz,PETSC_NULL,A); 31 29 } 32 30 else if(strcasecmp_eq(type,MATMPIDENSE)){ 33 MatCreateMPIDense( MPI_COMM_WORLD,local_mA,local_nA, mA,nA,PETSC_NULL,A);31 MatCreateMPIDense(comm,local_mA,local_nA, mA,nA,PETSC_NULL,A); 34 32 } 35 33 36 34 MatGetOwnershipRange(*A,&lower_row,&upper_row); 37 35 upper_row--; 38 range=upper_row-lower_row+1; 39 36 40 37 /*Build the Plapack row and column indices corresponding to the local_buffer stored in a. 41 38 We need those indices to directly plug local_buffer into the Petsc matrix A. We do not … … 43 40 problem size becomes big. We rely therefore on MatAssembly from Petsc to gather the plapack 44 41 matrix into a Petsc Matrix.*/ 45 42 46 43 /*Vector physically based block cyclic distribution: */ 47 44 row_nodes=xNew<int>(mA); … … 82 79 /*Get local buffer: */ 83 80 PLA_Obj_local_buffer(a,(void**)&local_buffer); 84 81 85 82 /*Insert into invA matrix. Use col oriented insertion, for Plapack is column oriented*/ 86 83 MatSetOption(*A,MAT_COLUMN_ORIENTED); -
issm/trunk/src/c/toolkits/plapack/patches/plapackpatches.h
r831 r13975 6 6 #define _PLAPACK_PATCHES_H_ 7 7 8 int PlapackInvertMatrix(Mat* A,Mat* inv_A,int status,int con );9 int PlapackToPetsc(Mat* A,int local_mA,int local_nA,int mA,int nA,MatType type,PLA_Obj a,PLA_Template templ,int nprows,int npcols,int nb );8 int PlapackInvertMatrix(Mat* A,Mat* inv_A,int status,int con,COMM comm); 9 int PlapackToPetsc(Mat* A,int local_mA,int local_nA,int mA,int nA,MatType type,PLA_Obj a,PLA_Template templ,int nprows,int npcols,int nb,COMM comm); 10 10 int CyclicalFactorization(int* pnprows,int* pnpcols,int num_procs); 11 11 -
issm/trunk/src/c/toolkits/plapack/plapackincludes.h
r11995 r13975 12 12 #endif 13 13 14 15 #include "PLA.h" 14 #include <PLA.h> 16 15 17 16 /* missing Plapack prototypes: */ … … 20 19 /*our own patches: */ 21 20 #ifdef _HAVE_PETSC_ 22 #include " patches/petscpatches.h"21 #include "./patches/petscpatches.h" 23 22 #endif 24 23 25 26 24 #endif 27 -
issm/trunk/src/c/toolkits/scalapack/FortranMapping.h
r831 r13975 5 5 * Description: Fortran to C define to use Scalapack in a C program 6 6 */ 7 8 7 9 8 /*We transform every call to Fortran functions into their real symbolic name in the Scalapack, Blacs, Lapack and Blas libraries. … … 22 21 #define PDGETRF(...) pdgetrf_(__VA_ARGS__) 23 22 #define PDGETRI(...) pdgetri_(__VA_ARGS__) 24 25 23 26 24 /*Here, we clobber the fortran definition of these routines. Remember, every variable in fortran is passed by a pointer, and the -
issm/trunk/src/c/toolkits/toolkits.h
r12330 r13975 10 10 #else 11 11 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 12 #endif13 14 #ifdef _HAVE_PYTHON_15 #include "./python/pythonincludes.h"16 12 #endif 17 13 … … 31 27 #include "./toolkitsenums.h" 32 28 #include "./issm/issmtoolkit.h" 33 34 29 #endif -
issm/trunk/src/c/toolkits/triangle/triangleincludes.h
r12330 r13975 11 11 #endif //#ifdef _C_ 12 12 13 14 13 #endif -
issm/trunk/src/dox/issm.dox
r12706 r13975 46 46 </th> 47 47 <tr> 48 <th bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td bgcolor=#FFFFFF style="text-align:right;">50 8</td><td bgcolor=#FFFFFF style="text-align:right;">14595</td><td bgcolor=#FFFFFF style="text-align:right;">16762</td><td bgcolor=#FFFFFF style="text-align:right;">56036</td><td bgcolor=#FFFFFF style="text-align:right;">87393</td>48 <th bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td bgcolor=#FFFFFF style="text-align:right;">505</td><td bgcolor=#FFFFFF style="text-align:right;">14316</td><td bgcolor=#FFFFFF style="text-align:right;">16564</td><td bgcolor=#FFFFFF style="text-align:right;">56522</td><td bgcolor=#FFFFFF style="text-align:right;">87402</td> 49 49 </tr> 50 50 <tr> 51 <th bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td bgcolor=#C6E2FF style="text-align:right;">9 25</td><td bgcolor=#C6E2FF style="text-align:right;">6851</td><td bgcolor=#C6E2FF style="text-align:right;">13228</td><td bgcolor=#C6E2FF style="text-align:right;">30468</td><td bgcolor=#C6E2FF style="text-align:right;">50547</td>51 <th bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td bgcolor=#C6E2FF style="text-align:right;">913</td><td bgcolor=#C6E2FF style="text-align:right;">6625</td><td bgcolor=#C6E2FF style="text-align:right;">13054</td><td bgcolor=#C6E2FF style="text-align:right;">30160</td><td bgcolor=#C6E2FF style="text-align:right;">49839</td> 52 52 </tr> 53 53 <tr> 54 <th bgcolor=#FFFFFF style="text-align:left;"> C/C++ Header </th><td bgcolor=#FFFFFF style="text-align:right;">3 78</td><td bgcolor=#FFFFFF style="text-align:right;">2758</td><td bgcolor=#FFFFFF style="text-align:right;">2612</td><td bgcolor=#FFFFFF style="text-align:right;">9818</td><td bgcolor=#FFFFFF style="text-align:right;">15188</td>54 <th bgcolor=#FFFFFF style="text-align:left;"> C/C++ Header </th><td bgcolor=#FFFFFF style="text-align:right;">388</td><td bgcolor=#FFFFFF style="text-align:right;">3069</td><td bgcolor=#FFFFFF style="text-align:right;">2983</td><td bgcolor=#FFFFFF style="text-align:right;">11855</td><td bgcolor=#FFFFFF style="text-align:right;">17907</td> 55 55 </tr> 56 56 <tr> 57 <th bgcolor=#C6E2FF style="text-align:left;"> m4 </th><td bgcolor=#C6E2FF style="text-align:right;"> 7</td><td bgcolor=#C6E2FF style="text-align:right;">997</td><td bgcolor=#C6E2FF style="text-align:right;">80</td><td bgcolor=#C6E2FF style="text-align:right;">8259</td><td bgcolor=#C6E2FF style="text-align:right;">9336</td>57 <th bgcolor=#C6E2FF style="text-align:left;"> m4 </th><td bgcolor=#C6E2FF style="text-align:right;">6</td><td bgcolor=#C6E2FF style="text-align:right;">1052</td><td bgcolor=#C6E2FF style="text-align:right;">79</td><td bgcolor=#C6E2FF style="text-align:right;">8993</td><td bgcolor=#C6E2FF style="text-align:right;">10124</td> 58 58 </tr> 59 59 <tr> 60 <th bgcolor=#FFFFFF style="text-align:left;"> Python </th><td bgcolor=#FFFFFF style="text-align:right;"> 53</td><td bgcolor=#FFFFFF style="text-align:right;">400</td><td bgcolor=#FFFFFF style="text-align:right;">610</td><td bgcolor=#FFFFFF style="text-align:right;">1424</td><td bgcolor=#FFFFFF style="text-align:right;">2434</td>60 <th bgcolor=#FFFFFF style="text-align:left;"> Python </th><td bgcolor=#FFFFFF style="text-align:right;">81</td><td bgcolor=#FFFFFF style="text-align:right;">2677</td><td bgcolor=#FFFFFF style="text-align:right;">3936</td><td bgcolor=#FFFFFF style="text-align:right;">5169</td><td bgcolor=#FFFFFF style="text-align:right;">11782</td> 61 61 </tr> 62 62 <tr> … … 64 64 </tr> 65 65 <tr> 66 <th bgcolor=#FFFFFF style="text-align:left;"> Perl </th><td bgcolor=#FFFFFF style="text-align:right;">3</td><td bgcolor=#FFFFFF style="text-align:right;">21</td><td bgcolor=#FFFFFF style="text-align:right;">23</td><td bgcolor=#FFFFFF style="text-align:right;">240</td><td bgcolor=#FFFFFF style="text-align:right;">284</td>66 <th bgcolor=#FFFFFF style="text-align:left;"> Bourne Shell </th><td bgcolor=#FFFFFF style="text-align:right;">5</td><td bgcolor=#FFFFFF style="text-align:right;">58</td><td bgcolor=#FFFFFF style="text-align:right;">81</td><td bgcolor=#FFFFFF style="text-align:right;">268</td><td bgcolor=#FFFFFF style="text-align:right;">407</td> 67 67 </tr> 68 68 <tr> 69 <th bgcolor=#C6E2FF style="text-align:left;"> Bourne Shell </th><td bgcolor=#C6E2FF style="text-align:right;">5</td><td bgcolor=#C6E2FF style="text-align:right;">47</td><td bgcolor=#C6E2FF style="text-align:right;">75</td><td bgcolor=#C6E2FF style="text-align:right;">239</td><td bgcolor=#C6E2FF style="text-align:right;">361</td>69 <th bgcolor=#C6E2FF style="text-align:left;"> Perl </th><td bgcolor=#C6E2FF style="text-align:right;">3</td><td bgcolor=#C6E2FF style="text-align:right;">21</td><td bgcolor=#C6E2FF style="text-align:right;">23</td><td bgcolor=#C6E2FF style="text-align:right;">240</td><td bgcolor=#C6E2FF style="text-align:right;">284</td> 70 70 </tr> 71 71 <tr> … … 76 76 </tr> 77 77 <tr> 78 <th bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td bgcolor=#FFFFFF style="text-align:right;">1 890</td><td bgcolor=#FFFFFF style="text-align:right;">25787</td><td bgcolor=#FFFFFF style="text-align:right;">33397</td><td bgcolor=#FFFFFF style="text-align:right;">106984</td><td bgcolor=#FFFFFF style="text-align:right;">166168</td>78 <th bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td bgcolor=#FFFFFF style="text-align:right;">1912</td><td bgcolor=#FFFFFF style="text-align:right;">27936</td><td bgcolor=#FFFFFF style="text-align:right;">36727</td><td bgcolor=#FFFFFF style="text-align:right;">113707</td><td bgcolor=#FFFFFF style="text-align:right;">178370</td> 79 79 </tr> 80 80 </table> -
issm/trunk/src/m/Makefile.am
r13395 r13975 3 3 #find . -type d -exec ls -d {} \; 4 4 5 if WRAPPERS 5 6 bin_SCRIPTS= ./qmu/*.m \ 6 7 ./qmu/setupdesign/*.m \ … … 49 50 ./solvers/*.m \ 50 51 ./materials/*.m 52 endif -
issm/trunk/src/m/array/array_numel.m
r13395 r13975 17 17 inum=numel(varargin{iarg}); 18 18 end 19 19 20 20 if ~isequal(inum,1) 21 21 if isequal(anum,1) -
issm/trunk/src/m/array/array_size.m
r13395 r13975 17 17 isize=size(varargin{iarg}); 18 18 end 19 19 20 20 if ~isequal(isize,[1 1]) 21 21 if isequal(asize,[1 1]) -
issm/trunk/src/m/array/str2int.m
r13395 r13975 5 5 % function [aint]=str2int(astr,cfl) 6 6 % 7 function [aint]=str2int(astr,cfl) ;7 function [aint]=str2int(astr,cfl) 8 8 9 9 aint=[]; … … 44 44 45 45 end 46 -
issm/trunk/src/m/array/struc_desc.m
r13395 r13975 22 22 desc=cellstr(varargin{iarg}); 23 23 end 24 24 25 25 for i=1:length(desc) 26 26 sarrayoi=struc_desci(sarray,desc{i}); -
issm/trunk/src/m/boundaryconditions/SetIceSheetBC.m
r13395 r13975 58 58 pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface 59 59 if (length(md.basalforcings.geothermalflux)~=md.mesh.numberofvertices), 60 md.basalforcings.geothermalflux=50 *10^-3*ones(md.mesh.numberofvertices,1); %50 mW/m^260 md.basalforcings.geothermalflux=50.*10^-3*ones(md.mesh.numberofvertices,1); %50 mW/m^2 61 61 end 62 62 else -
issm/trunk/src/m/boundaryconditions/SetIceShelfBC.py
r13395 r13975 1 1 import os 2 2 import numpy 3 from ContourToMesh import * 3 4 4 5 def SetIceShelfBC(md,icefrontfile=''): … … 6 7 SETICESHELFBC - Create the boundary conditions for diagnostic and thermal models for a Ice Shelf with Ice Front 7 8 8 Neumann BC are used on the ice front (an A NRGUS contour around the ice front9 Neumann BC are used on the ice front (an ARGUS contour around the ice front 9 10 must be given in input) 10 11 Dirichlet BC are used elsewhere for diagnostic … … 24 25 if not os.path.exists(icefrontfile): 25 26 raise IOError("SetIceShelfBC error message: ice front file '%s' not found." % icefrontfile) 26 nodeinsideicefront=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,icefrontfile,'node',2)27 nodeonicefront= double(md.mesh.vertexonboundary and nodeinsideicefront)27 [nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),icefrontfile,'node',2) 28 nodeonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront.reshape(-1)).astype(float) 28 29 else: 29 nodeonicefront=numpy.zeros( md.mesh.numberofvertices)30 nodeonicefront=numpy.zeros((md.mesh.numberofvertices)) 30 31 31 32 # pos=find(md.mesh.vertexonboundary & ~nodeonicefront); 32 pos= [i for i,(vob,noif) in enumerate(zip(md.mesh.vertexonboundary,nodeonicefront)) if vob and not noif]33 md.diagnostic.spcvx=float(' NaN')*numpy.ones(md.mesh.numberofvertices)34 md.diagnostic.spcvy=float(' NaN')*numpy.ones(md.mesh.numberofvertices)35 md.diagnostic.spcvz=float(' NaN')*numpy.ones(md.mesh.numberofvertices)33 pos=numpy.nonzero(numpy.logical_and(md.mesh.vertexonboundary,numpy.logical_not(nodeonicefront)))[0] 34 md.diagnostic.spcvx=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 35 md.diagnostic.spcvy=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 36 md.diagnostic.spcvz=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 36 37 md.diagnostic.spcvx[pos]=0 37 38 md.diagnostic.spcvy[pos]=0 38 39 md.diagnostic.spcvz[pos]=0 39 md.diagnostic.referential=float(' NaN')*numpy.ones((md.mesh.numberofvertices,6))40 md.diagnostic.referential=float('nan')*numpy.ones((md.mesh.numberofvertices,6)) 40 41 41 42 #Dirichlet Values 42 if numpy.size(md.inversion.vx_obs)==md.mesh.numberofvertices and numpy.size(md.inversion.vy_obs)==md.mesh.numberofvertices: 43 print ' boundary conditions for diagnostic model: spc set as observed velocities' 43 if isinstance(md.inversion.vx_obs,numpy.ndarray) and numpy.size(md.inversion.vx_obs,axis=0)==md.mesh.numberofvertices and isinstance(md.inversion.vy_obs,numpy.ndarray) and numpy.size(md.inversion.vy_obs,axis=0)==md.mesh.numberofvertices: 44 #reshape to rank-2 if necessary to match spc arrays 45 if numpy.ndim(md.inversion.vx_obs)==1: 46 md.inversion.vx_obs=md.inversion.vx_obs.reshape(-1,1) 47 if numpy.ndim(md.inversion.vy_obs)==1: 48 md.inversion.vy_obs=md.inversion.vy_obs.reshape(-1,1) 49 print " boundary conditions for diagnostic model: spc set as observed velocities" 44 50 md.diagnostic.spcvx[pos]=md.inversion.vx_obs[pos] 45 51 md.diagnostic.spcvy[pos]=md.inversion.vy_obs[pos] 46 52 else: 47 print ' boundary conditions for diagnostic model: spc set as zero'53 print " boundary conditions for diagnostic model: spc set as zero" 48 54 49 55 #segment on Ice Front 50 56 #segment on Neumann (Ice Front) 51 57 # pos=find(nodeonicefront(md.mesh.segments(:,1)) | nodeonicefront(md.mesh.segments(:,2))); 52 pos= [i for i,(noif1,noif2) in enumerate(zip(nodeonicefront[md.mesh.segments[:,0].astype('int')-1],nodeonicefront[md.mesh.segments[:,1].astype('int')-1])) if noif1 or noif2]58 pos=numpy.nonzero(numpy.logical_or(nodeonicefront[md.mesh.segments[:,0].astype(int)-1],nodeonicefront[md.mesh.segments[:,1].astype(int)-1]))[0] 53 59 if md.mesh.dimension==2: 54 60 pressureload=md.mesh.segments[pos,:] 55 61 elif md.mesh.dimension==3: 56 62 # pressureload_layer1=[md.mesh.segments(pos,1:2) md.mesh.segments(pos,2)+md.mesh.numberofvertices2d md.mesh.segments(pos,1)+md.mesh.numberofvertices2d md.mesh.segments(pos,3)]; 57 pressureload_layer1=numpy. concatenate((md.mesh.segments[pos,0:2],md.mesh.segments[pos,1]+md.mesh.numberofvertices2d,md.mesh.segments[pos,0]+md.mesh.numberofvertices2d,md.mesh.segments[pos,2]),axis=1)63 pressureload_layer1=numpy.hstack((md.mesh.segments[pos,0:2],md.mesh.segments[pos,1]+md.mesh.numberofvertices2d,md.mesh.segments[pos,0]+md.mesh.numberofvertices2d,md.mesh.segments[pos,2])) 58 64 pressureload=numpy.zeros((0,5)) 59 65 for i in xrange(1,md.mesh.numberoflayers): 60 66 # pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d ]; 61 pressureload=numpy. concatenate((pressureload,numpy.concatenate((pressureload_layer1[:,0:3]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d),axis=1)),axis=0)67 pressureload=numpy.vstack((pressureload,numpy.hstack((pressureload_layer1[:,0:4]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d)))) 62 68 63 69 #Add water or air enum depending on the element 64 70 # pressureload=[pressureload 1*md.mask.elementonfloatingice(pressureload(:,end))]; 65 pressureload=numpy. concatenate((pressureload,1*md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape((-1,1))),axis=1)71 pressureload=numpy.hstack((pressureload,1.*md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape(-1,1))) 66 72 67 73 #plug onto model … … 70 76 #Create zeros basalforcings and surfaceforcings 71 77 if numpy.all(numpy.isnan(md.surfaceforcings.precipitation)) and (md.surfaceforcings.ispdd==1): 72 md.surfaceforcings.precipitation=numpy.zeros( md.mesh.numberofvertices)73 print ' no surfaceforcings.precipitation specified: values set as zero'78 md.surfaceforcings.precipitation=numpy.zeros((md.mesh.numberofvertices,1)) 79 print " no surfaceforcings.precipitation specified: values set as zero" 74 80 if numpy.all(numpy.isnan(md.surfaceforcings.mass_balance)) and (md.surfaceforcings.ispdd==0): 75 md.surfaceforcings.mass_balance=numpy.zeros( md.mesh.numberofvertices)76 print ' no surfaceforcings.mass_balance specified: values set as zero'81 md.surfaceforcings.mass_balance=numpy.zeros((md.mesh.numberofvertices,1)) 82 print " no surfaceforcings.mass_balance specified: values set as zero" 77 83 if numpy.all(numpy.isnan(md.basalforcings.melting_rate)): 78 md.basalforcings.melting_rate=numpy.zeros( md.mesh.numberofvertices)79 print ' no basalforcings.melting_rate specified: values set as zero'84 md.basalforcings.melting_rate=numpy.zeros((md.mesh.numberofvertices,1)) 85 print " no basalforcings.melting_rate specified: values set as zero" 80 86 if numpy.all(numpy.isnan(md.balancethickness.thickening_rate)): 81 md.balancethickness.thickening_rate=numpy.zeros( md.mesh.numberofvertices)82 print ' no balancethickness.thickening_rate specified: values set as zero'87 md.balancethickness.thickening_rate=numpy.zeros((md.mesh.numberofvertices,1)) 88 print " no balancethickness.thickening_rate specified: values set as zero" 83 89 84 md.prognostic.spcthickness=float(' NaN')*numpy.ones(md.mesh.numberofvertices)85 md.balancethickness.spcthickness=float(' NaN')*numpy.ones(md.mesh.numberofvertices)90 md.prognostic.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 91 md.balancethickness.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 86 92 87 if numpy.size(md.initialization.temperature)==md.mesh.numberofvertices:88 md.thermal.spctemperature=float(' NaN')*numpy.ones(md.mesh.numberofvertices)93 if isinstance(md.initialization.temperature,numpy.ndarray) and numpy.size(md.initialization.temperature,axis=0)==md.mesh.numberofvertices: 94 md.thermal.spctemperature=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 89 95 # pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface 90 pos= [i for i,vos in enumerate(md.mesh.vertexonsurface) if vos]91 md.thermal.spctemperature[pos]=md.initialization.temperature[pos] # 92 if not numpy.size(md.basalforcings.geothermalflux)==md.mesh.numberofvertices:93 md.basalforcings.geothermalflux=numpy.zeros( md.mesh.numberofvertices)96 pos=numpy.nonzero(md.mesh.vertexonsurface)[0] 97 md.thermal.spctemperature[pos]=md.initialization.temperature[pos] #impose observed temperature on surface 98 if not isinstance(md.basalforcings.geothermalflux,numpy.ndarray) or not numpy.size(md.basalforcings.geothermalflux,axis=0)==md.mesh.numberofvertices: 99 md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices,1)) 94 100 else: 95 print ' no thermal boundary conditions created: no observed temperature found'101 print " no thermal boundary conditions created: no observed temperature found" 96 102 97 103 return md -
issm/trunk/src/m/boundaryconditions/SetMarineIceSheetBC.m
r13395 r13975 53 53 54 54 md.hydrology.spcwatercolumn=zeros(md.mesh.numberofvertices,2); 55 pos=find(md.mesh.vertexonboundary); 55 pos=find(md.mesh.vertexonboundary); 56 56 md.hydrology.spcwatercolumn(pos,1)=1; 57 57 … … 73 73 %plug onto model 74 74 md.diagnostic.icefront=pressureload; 75 76 75 77 76 %Create zeros basalforcings and surfaceforcings … … 101 100 if (length(md.basalforcings.geothermalflux)~=md.mesh.numberofvertices), 102 101 md.basalforcings.geothermalflux=zeros(md.mesh.numberofvertices,1); 103 md.basalforcings.geothermalflux(find(md.mask.vertexongroundedice))=50 *10^-3; %50mW/m2102 md.basalforcings.geothermalflux(find(md.mask.vertexongroundedice))=50.*10.^-3; %50mW/m2 104 103 end 105 104 else -
issm/trunk/src/m/classes/autodiff.m
r13395 r13975 9 9 dependents = {}; 10 10 independents = {}; 11 driver = 'fos_forward'; 11 12 end 12 13 methods … … 24 25 function md = checkconsistency(obj,md,solution,analyses) % {{{ 25 26 26 %Early return 27 if ~obj.isautodiff, return; end 27 %Early return 28 if ~obj.isautodiff, return; end 29 30 %Driver value: 31 md = checkfield(md,'autodiff.driver','values',{'fos_forward','fov_forward','fov_forward_all','fos_reverse','fov_reverse','fov_reverse_all'}); 32 33 %go through our dependents and independents and check consistency: 34 for i=1:numel(obj.dependents), 35 dep=obj.dependents{i}; 36 md=checkconsistency(dep,md,solution,analyses); 37 end 38 for i=1:numel(obj.independents), 39 indep=obj.independents{i}; 40 md=checkconsistency(indep,md,i,solution,analyses,obj.driver); 41 end 28 42 29 43 end % }}} 30 44 function disp(obj) % {{{ 31 disp(sprintf(' automatic differentiation parameters:'));45 disp(sprintf(' automatic differentiation parameters:')); 32 46 fielddisplay(obj,'isautodiff','indicates if the automatic differentiation is activated'); 33 fielddisplay(obj,'dependents','list of dependent variables ; ex: {''Thickness'',''FrictionCoefficient''}'); 34 fielddisplay(obj,'independents','list of independent variables ; ex: {''IceVolume'',''MassFlux''}'); 47 fielddisplay(obj,'dependents','list of dependent variables'); 48 fielddisplay(obj,'independents','list of independent variables'); 49 fielddisplay(obj,'driver','ADOLC driver (''fos_forward'' or ''fov_forward'')'); 35 50 end % }}} 36 51 function marshall(obj,fid) % {{{ 37 52 38 53 WriteData(fid,'object',obj,'fieldname','isautodiff','format','Boolean'); 39 54 WriteData(fid,'object',obj,'fieldname','driver','format','String'); 55 40 56 %early return 41 if ~obj.isautodiff, return; end 42 43 %process dependent variables 44 num_dependents=numel(obj.dependents); 45 WriteData(fid,'data',num_dependents,'enum',AutodiffNumDependentsEnum(),'format','Integer'); 46 47 if(num_dependents), 48 data=zeros(1,num_dependents); 49 for i=1:num_dependents, 50 data(i)=StringToEnum(obj.dependents{i}); 51 end 52 WriteData(fid,'data',data,'enum',AutodiffDependentsEnum(),'format','DoubleMat','mattype',3); 53 end 54 55 %process independent variables 56 num_independents=numel(obj.independents); 57 WriteData(fid,'data',num_independents,'enum',AutodiffNumIndependentsEnum(),'format','Integer'); 58 59 if(num_independents) 60 data=zeros(1,num_independents); 61 for i=1:num_independents, 62 data(i)=StringToEnum(obj.independents{i}); 63 end 64 WriteData(fid,'data',data,'enum',AutodiffIndependentsEnum(),'format','DoubleMat','mattype',3); 65 end 57 if ~obj.isautodiff, 58 WriteData(fid,'data',false,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean'); 59 WriteData(fid,'data',false,'enum',AutodiffKeepEnum(),'format','Boolean'); 60 return; 61 end 62 63 %process dependent variables {{{ 64 num_dependent_objects=numel(obj.dependents); 65 WriteData(fid,'data',num_dependent_objects,'enum',AutodiffNumDependentObjectsEnum(),'format','Integer'); 66 67 if(num_dependent_objects), 68 names=zeros(num_dependent_objects,1); 69 types=zeros(num_dependent_objects,1); 70 indices=zeros(num_dependent_objects,1); 71 72 for i=1:num_dependent_objects, 73 dep=obj.dependents{i}; 74 75 names(i)=StringToEnum(dep.name); 76 types(i)=dep.typetoscalar(); 77 indices(i)=dep.index; 78 end 79 WriteData(fid,'data',names,'enum',AutodiffDependentObjectNamesEnum(),'format','IntMat','mattype',3); 80 WriteData(fid,'data',types,'enum',AutodiffDependentObjectTypesEnum(),'format','IntMat','mattype',3); 81 WriteData(fid,'data',indices,'enum',AutodiffDependentObjectIndicesEnum(),'format','IntMat','mattype',3); 82 end 83 %}}} 84 %process independent variables {{{ 85 num_independent_objects=numel(obj.independents); 86 WriteData(fid,'data',num_independent_objects,'enum',AutodiffNumIndependentObjectsEnum(),'format','Integer'); 87 88 if(num_independent_objects), 89 names=zeros(num_independent_objects,1); 90 types=zeros(num_independent_objects,1); 91 92 for i=1:num_independent_objects, 93 indep=obj.independents{i}; 94 95 names(i)=StringToEnum(indep.name); 96 types(i)=indep.typetoscalar(); 97 end 98 WriteData(fid,'data',names,'enum',AutodiffIndependentObjectNamesEnum(),'format','IntMat','mattype',3); 99 WriteData(fid,'data',types,'enum',AutodiffIndependentObjectTypesEnum(),'format','IntMat','mattype',3); 100 end 101 %}}} 102 %if driver is fos_forward, build index: {{{ 103 if strcmpi(obj.driver,'fos_forward'), 104 index=0; 105 106 for i=1:num_independent_objects, 107 indep=obj.independents{i}; 108 if ~isnan(indep.fos_forward_index), 109 index=index+indep.fos_forward_index; 110 break; 111 else 112 if strcmpi(indep.type,'scalar'), 113 index=index+1; 114 else 115 index=index+indep.nods; 116 end 117 end 118 end 119 index=index-1; %get c-index numbering going 120 WriteData(fid,'data',index,'enum',AutodiffFosForwardIndexEnum(),'format','Integer'); 121 end 122 %}}} 123 %if driver is fos_reverse, build index: {{{ 124 if strcmpi(obj.driver,'fos_reverse'), 125 index=0; 126 127 for i=1:num_dependent_objects, 128 dep=obj.dependents{i}; 129 if ~isnan(dep.fos_reverse_index), 130 index=index+dep.fos_reverse_index; 131 break; 132 else 133 if strcmpi(dep.type,'scalar'), 134 index=index+1; 135 else 136 index=index+dep.nods; 137 end 138 end 139 end 140 index=index-1; %get c-index numbering going 141 WriteData(fid,'data',index,'enum',AutodiffFosReverseIndexEnum(),'format','Integer'); 142 end 143 %}}} 144 %if driver is fov_forward, build indices: {{{ 145 if strcmpi(obj.driver,'fov_forward'), 146 indices=0; 147 148 for i=1:num_independent_objects, 149 indep=obj.independents{i}; 150 if ~isempty(indep.fos_forward_index), 151 indices=indices+indep.fov_forward_indices; 152 break; 153 else 154 if strcmpi(indep.type,'scalar'), 155 indices=indices+1; 156 else 157 indices=indices+indep.nods; 158 end 159 end 160 end 161 indices=indices-1; %get c-indices numbering going 162 WriteData(fid,'data',indices,'enum',AutodiffFovForwardIndicesEnum(),'format','IntMat','mattype',3); 163 end 164 %}}} 165 %deal with mass fluxes: {{{ 166 mass_flux_segments=cell(0,1); 167 for i=1:num_dependent_objects, 168 dep=obj.dependents{i}; 169 if strcmpi(dep.name,'MassFlux'), 170 mass_flux_segments{end+1,1}=dep.segments; 171 end 172 end 173 if ~isempty(mass_flux_segments), 174 WriteData(fid,'data',mass_flux_segments,'enum',MassFluxSegmentsEnum(),'format','MatArray'); 175 flag=true; 176 else 177 flag=false; 178 end 179 WriteData(fid,'data',flag,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean'); 180 %}}} 181 %deal with trace keep on: {{{ 182 keep=false; 183 184 %From ADOLC userdoc: 185 % The optional integer argument keep of trace on determines whether the numerical values of all active variables are 186 % recorded in a buffered temporary array or file called the taylor stack. This option takes effect if keep = 1 and 187 % prepares the scene for an immediately following gradient evaluation by a call to a routine implementing the reverse 188 % mode as described in the Section 4 and Section 5. 189 % 190 191 if length(obj.driver)<=3, 192 keep=false; %there is no "_reverse" string within the driver string: 193 else 194 if strncmpi(obj.driver(4:end),'_reverse',8), 195 keep=true; 196 else 197 keep=false; 198 end 199 end 200 WriteData(fid,'data',keep,'enum',AutodiffKeepEnum(),'format','Boolean'); 201 %}}} 66 202 67 203 end % }}} -
issm/trunk/src/m/classes/autodiff.py
r13395 r13975 1 1 #module imports 2 import numpy 3 from dependent import * 4 from independent import * 2 5 from fielddisplay import fielddisplay 3 6 from EnumDefinitions import * … … 14 17 15 18 #properties 16 def __init__(self): 17 # {{{ Properties 18 self.isautodiff = False 19 def __init__(self,*args): # {{{ 20 self.isautodiff = False 21 self.dependents = [] 22 self.independents = [] 23 self.driver = 'fos_forward' 19 24 20 #set defaults 21 self.setdefaultparameters() 25 if not len(args): 26 self.setdefaultparameters() 27 else: 28 raise RuntimeError("constructor not supported") 29 # }}} 22 30 23 #}}} 24 def __repr__(self): 25 # {{{ Display 26 string=' automatic differentiation parameters:' 27 string="%s\n%s"%(string,fielddisplay(self,'isautodiff','indicates if the automatic differentiation is activated')) 28 return string 29 #}}} 30 def setdefaultparameters(self): 31 # {{{setdefaultparameters 31 def __repr__(self): # {{{ 32 s =" automatic differentiation parameters:\n" 33 34 s+="%s\n" % fielddisplay(self,'isautodiff',"indicates if the automatic differentiation is activated") 35 s+="%s\n" % fielddisplay(self,'dependents',"list of dependent variables") 36 s+="%s\n" % fielddisplay(self,'independents',"list of independent variables") 37 s+="%s\n" % fielddisplay(self,'driver',"ADOLC driver ('fos_forward' or 'fov_forward')") 38 39 return s 40 # }}} 41 42 def setdefaultparameters(self): # {{{ 32 43 return self 33 # }}}44 # }}} 34 45 35 46 def checkconsistency(self,md,solution,analyses): # {{{ 47 48 #Early return 49 if not self.isautodiff: 50 return md 51 52 #Driver value: 53 md = checkfield(md,'autodiff.driver','values',['fos_forward','fov_forward','fov_forward_all','fos_reverse','fov_reverse','fov_reverse_all']) 54 55 #go through our dependents and independents and check consistency: 56 for dep in self.dependents: 57 dep.checkconsistency(md,solution,analyses) 58 for i,indep in enumerate(self.independents): 59 indep.checkconsistency(md,i,solution,analyses,self.driver) 60 36 61 return md 37 62 # }}} … … 39 64 def marshall(self,fid): # {{{ 40 65 WriteData(fid,'object',self,'fieldname','isautodiff','format','Boolean') 66 WriteData(fid,'object',self,'fieldname','driver','format','String') 67 68 #early return 69 if not self.isautodiff: 70 WriteData(fid,'data',False,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean') 71 WriteData(fid,'data',False,'enum',AutodiffKeepEnum(),'format','Boolean') 72 return 73 74 #process dependent variables {{{ 75 num_dependent_objects=len(self.dependents) 76 WriteData(fid,'data',num_dependent_objects,'enum',AutodiffNumDependentObjectsEnum(),'format','Integer') 77 78 if num_dependent_objects: 79 names=numpy.zeros(num_dependent_objects) 80 types=numpy.zeros(num_dependent_objects) 81 indices=numpy.zeros(num_dependent_objects) 82 83 for i,dep in enumerate(self.dependents): 84 names[i]=StringToEnum(dep.name)[0] 85 types[i]=dep.typetoscalar() 86 indices[i]=dep.index 87 88 WriteData(fid,'data',names,'enum',AutodiffDependentObjectNamesEnum(),'format','IntMat','mattype',3) 89 WriteData(fid,'data',types,'enum',AutodiffDependentObjectTypesEnum(),'format','IntMat','mattype',3) 90 WriteData(fid,'data',indices,'enum',AutodiffDependentObjectIndicesEnum(),'format','IntMat','mattype',3) 91 #}}} 92 93 #process independent variables {{{ 94 num_independent_objects=len(self.independents) 95 WriteData(fid,'data',num_independent_objects,'enum',AutodiffNumIndependentObjectsEnum(),'format','Integer') 96 97 if num_independent_objects: 98 names=numpy.zeros(num_independent_objects) 99 types=numpy.zeros(num_independent_objects) 100 101 for i,indep in enumerate(self.independents): 102 names[i]=StringToEnum(indep.name)[0] 103 types[i]=indep.typetoscalar() 104 105 WriteData(fid,'data',names,'enum',AutodiffIndependentObjectNamesEnum(),'format','IntMat','mattype',3) 106 WriteData(fid,'data',types,'enum',AutodiffIndependentObjectTypesEnum(),'format','IntMat','mattype',3) 107 #}}} 108 109 #if driver is fos_forward, build index: {{{ 110 if strcmpi(self.driver,'fos_forward'): 111 index=0 112 113 for indep in self.independents: 114 if not numpy.isnan(indep.fos_forward_index): 115 index+=indep.fos_forward_index 116 break 117 else: 118 if strcmpi(indep.type,'scalar'): 119 index+=1 120 else: 121 index+=indep.nods 122 123 index-=1 #get c-index numbering going 124 WriteData(fid,'data',index,'enum',AutodiffFosForwardIndexEnum(),'format','Integer') 125 #}}} 126 127 #if driver is fos_reverse, build index: {{{ 128 if strcmpi(self.driver,'fos_reverse'): 129 index=0 130 131 for dep in self.dependents: 132 if not numpy.isnan(dep.fos_reverse_index): 133 index+=dep.fos_reverse_index 134 break 135 else: 136 if strcmpi(dep.type,'scalar'): 137 index+=1 138 else: 139 index+=dep.nods 140 141 index-=1 #get c-index numbering going 142 WriteData(fid,'data',index,'enum',AutodiffFosReverseIndexEnum(),'format','Integer') 143 #}}} 144 145 #if driver is fov_forward, build indices: {{{ 146 if strcmpi(self.driver,'fov_forward'): 147 indices=0 148 149 for indep in self.independents: 150 if indep.fos_forward_index: 151 indices+=indep.fov_forward_indices 152 break 153 else: 154 if strcmpi(indep.type,'scalar'): 155 indices+=1 156 else: 157 indices+=indep.nods 158 159 indices-=1 #get c-indices numbering going 160 WriteData(fid,'data',indices,'enum',AutodiffFovForwardIndicesEnum(),'format','IntMat','mattype',3) 161 #}}} 162 163 #deal with mass fluxes: {{{ 164 mass_flux_segments=[dep.segments for dep in self.dependents if strcmpi(dep.name,'MassFlux')] 165 166 if mass_flux_segments: 167 WriteData(fid,'data',mass_flux_segments,'enum',MassFluxSegmentsEnum(),'format','MatArray') 168 flag=True 169 else: 170 flag=False 171 WriteData(fid,'data',flag,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean') 172 #}}} 173 174 #deal with trace keep on: {{{ 175 keep=False 176 177 #From ADOLC userdoc: 178 # The optional integer argument keep of trace on determines whether the numerical values of all active variables are 179 # recorded in a buffered temporary array or file called the taylor stack. This option takes effect if keep = 1 and 180 # prepares the scene for an immediately following gradient evaluation by a call to a routine implementing the reverse 181 # mode as described in the Section 4 and Section 5. 182 # 183 184 if len(self.driver)<=3: 185 keep=False #there is no "_reverse" string within the driver string: 186 else: 187 if strncmpi(self.driver[3:],'_reverse',8): 188 keep=True 189 else: 190 keep=False 191 WriteData(fid,'data',keep,'enum',AutodiffKeepEnum(),'format','Boolean') 192 #}}} 193 194 return 41 195 # }}} 42 196 -
issm/trunk/src/m/classes/bamggeom.py
r13395 r13975 1 import numpy 2 1 3 class bamggeom(object): 2 4 """ … … 8 10 9 11 def __init__(self,*args): # {{{ 10 self.Vertices= []11 self.Edges= []12 self.TangentAtEdges= []13 self.Corners= []14 self.RequiredVertices= []15 self.RequiredEdges= []16 self.CrackedEdges= []17 self.SubDomains= []12 self.Vertices=numpy.empty((0,3)) 13 self.Edges=numpy.empty((0,3)) 14 self.TangentAtEdges=numpy.empty((0,4)) 15 self.Corners=numpy.empty((0,1)) 16 self.RequiredVertices=numpy.empty((0,1)) 17 self.RequiredEdges=numpy.empty((0,1)) 18 self.CrackedEdges=numpy.empty((0,0)) 19 self.SubDomains=numpy.empty((0,4)) 18 20 19 21 if not len(args): -
issm/trunk/src/m/classes/bamgmesh.py
r13395 r13975 1 import numpy 2 1 3 class bamgmesh(object): 2 4 """ … … 8 10 9 11 def __init__(self,*args): # {{{ 10 self.Vertices= []11 self.Edges= []12 self.Triangles= []13 self.Quadrilaterals= []14 self.IssmEdges= []15 self.IssmSegments= []16 self.VerticesOnGeomVertex= []17 self.VerticesOnGeomEdge= []18 self.EdgesOnGeomEdge= []19 self.SubDomains= []20 self.SubDomainsFromGeom= []21 self.ElementConnectivity= []22 self.NodalConnectivity= []23 self.NodalElementConnectivity= []24 self.CrackedVertices= []25 self.CrackedEdges= []12 self.Vertices=numpy.empty((0,3)) 13 self.Edges=numpy.empty((0,3)) 14 self.Triangles=numpy.empty((0,0)) 15 self.Quadrilaterals=numpy.empty((0,0)) 16 self.IssmEdges=numpy.empty((0,0)) 17 self.IssmSegments=numpy.empty((0,0)) 18 self.VerticesOnGeomVertex=numpy.empty((0,0)) 19 self.VerticesOnGeomEdge=numpy.empty((0,0)) 20 self.EdgesOnGeomEdge=numpy.empty((0,0)) 21 self.SubDomains=numpy.empty((0,4)) 22 self.SubDomainsFromGeom=numpy.empty((0,0)) 23 self.ElementConnectivity=numpy.empty((0,0)) 24 self.NodalConnectivity=numpy.empty((0,0)) 25 self.NodalElementConnectivity=numpy.empty((0,0)) 26 self.CrackedVertices=numpy.empty((0,0)) 27 self.CrackedEdges=numpy.empty((0,0)) 26 28 27 29 if not len(args): -
issm/trunk/src/m/classes/clusters/discover.m
r13395 r13975 106 106 fprintf(fid,'#PBS -e %s.errlog \n\n',modelname); 107 107 fprintf(fid,'. /usr/share/modules/init/bash\n\n'); 108 fprintf(fid,'module load comp/intel-10.1.023\n'); 108 fprintf(fid,'module purge\n'); 109 fprintf(fid,'module load comp/intel-11.1.038\n'); 109 110 fprintf(fid,'module load mpi/impi-4.0.3.008\n'); 110 111 fprintf(fid,'module load lib/mkl-10.1.2.024\n\n'); -
issm/trunk/src/m/classes/clusters/generic.m
r13395 r13975 14 14 interactive=1; 15 15 codepath=[issmdir() '/bin']; 16 etcpath=[issmdir() '/etc']; 16 17 executionpath=[issmdir() '/execution']; 17 18 valgrind=[issmdir() '/externalpackages/valgrind/install/bin/valgrind']; … … 45 46 disp(sprintf(' codepath: %s',cluster.codepath)); 46 47 disp(sprintf(' executionpath: %s',cluster.executionpath)); 48 disp(sprintf(' etcpath: %s',cluster.executionpath)); 47 49 disp(sprintf(' valgrind: %s',cluster.valgrind)); 48 50 disp(sprintf(' valgrindlib: %s',cluster.valgrindlib)); … … 190 192 191 193 disp('launching solution sequence on remote cluster'); 192 launchcommand=['source ' issmdir '/etc/environment.sh && cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...194 launchcommand=['source ' cluster.etcpath '/environment.sh && cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ... 193 195 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz && source ' modelname '.queue ']; 194 196 issmssh(cluster.name,cluster.login,cluster.port,launchcommand); -
issm/trunk/src/m/classes/diagnostic.m
r13395 r13975 38 38 %maximum of non-linear iterations. 39 39 obj.maxiter=100; 40 40 41 41 %Convergence criterion: absolute, relative and residual 42 42 obj.restol=10^-4; 43 43 obj.reltol=0.01; 44 44 obj.abstol=10; 45 45 46 46 obj.stokesreconditioning=10^13; 47 47 obj.shelf_dampening=0; … … 92 92 93 93 %singular solution 94 if ~ any((~isnan(md.diagnostic.spcvx)+~isnan(md.diagnostic.spcvy))==2),94 if ~(any(~isnan(md.diagnostic.spcvx)) & any(~isnan(md.diagnostic.spcvy))), 95 95 md = checkmessage(md,['model is not well posed (singular). You need at least one node with fixed velocity!']); 96 96 end -
issm/trunk/src/m/classes/diagnostic.py
r13395 r13975 2 2 import numpy 3 3 import sys 4 import copy 4 5 from fielddisplay import fielddisplay 5 6 from EnumDefinitions import * … … 186 187 187 188 #marshall ice front 188 data= self.icefront189 data=copy.deepcopy(self.icefront) 189 190 data[numpy.nonzero(data[:,-1]==0),-1]=AirEnum() 190 191 data[numpy.nonzero(data[:,-1]==1),-1]=WaterEnum() -
issm/trunk/src/m/classes/flaim.m
r13395 r13975 59 59 fielddisplay(obj,'usevalueordering' ,'flag to consider target values for flight path evaluation'); 60 60 fielddisplay(obj,'split_antimeridian' ,'flag to split polygons on the antimeridian'); 61 61 62 62 disp(sprintf('\n Optimization:')); 63 63 fielddisplay(obj,'path_optimize' ,'optimize? (default false)'); -
issm/trunk/src/m/classes/flowequation.py
r13395 r13975 1 1 #module imports 2 2 import numpy 3 import copy 3 4 from fielddisplay import fielddisplay 4 5 from EnumDefinitions import * … … 67 68 md = checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements],'values',[1,2]) 68 69 else: 69 md = checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values', range(0,7+1))70 md = checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements],'values', range(0,7+1))70 md = checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',numpy.arange(0,7+1)) 71 md = checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements],'values',numpy.arange(0,7+1)) 71 72 if not (self.ismacayealpattyn or self.ishutter or self.isstokes or self.isl1l2): 72 73 md.checkmessage("no element types set for this model. At least one of ismacayealpattyn, ishutter or isstokes need to be =1") … … 89 90 WriteData(fid,'object',self,'fieldname','borderstokes','format','DoubleMat','mattype',1) 90 91 #convert approximations to enums 91 data= self.vertex_equation92 data=copy.deepcopy(self.vertex_equation) 92 93 data[numpy.nonzero(data==0)]=NoneApproximationEnum() 93 94 data[numpy.nonzero(data==1)]=HutterApproximationEnum() … … 100 101 data[numpy.nonzero(data==8)]=L1L2ApproximationEnum() 101 102 WriteData(fid,'data',data,'enum',FlowequationVertexEquationEnum(),'format','DoubleMat','mattype',1) 102 data= self.element_equation103 data=copy.deepcopy(self.element_equation) 103 104 data[numpy.nonzero(data==0)]=NoneApproximationEnum() 104 105 data[numpy.nonzero(data==1)]=HutterApproximationEnum() -
issm/trunk/src/m/classes/groundingline.m
r13395 r13975 25 25 %basal melting rate correction: 26 26 obj.melting_rate=0; 27 28 27 29 28 end % }}} -
issm/trunk/src/m/classes/initialization.py
r13395 r13975 24 24 self.pressure = float('NaN') 25 25 self.temperature = float('NaN') 26 self.surfacetemp = float('NaN') 27 self.basaltemp = float('NaN') 26 28 self.watercolumn = float('NaN') 27 29 self.waterfraction = float('NaN') … … 41 43 string="%s\n%s"%(string,fielddisplay(self,'pressure','pressure field')) 42 44 string="%s\n%s"%(string,fielddisplay(self,'temperature','temperature in Kelvins')) 45 string="%s\n%s"%(string,fielddisplay(self,'surfacetemp','surface temperature in Kelvins')) 46 string="%s\n%s"%(string,fielddisplay(self,'basaltemp','basal temperature in Kelvins')) 43 47 string="%s\n%s"%(string,fielddisplay(self,'watercolumn','thickness of subglacial water')) 44 48 string="%s\n%s"%(string,fielddisplay(self,'waterfraction','fraction of water in the ice')) … … 86 90 WriteData(fid,'data',self.pressure,'format','DoubleMat','mattype',1,'enum',PressureEnum()) 87 91 WriteData(fid,'data',self.temperature,'format','DoubleMat','mattype',1,'enum',TemperatureEnum()) 92 WriteData(fid,'data',self.surfacetemp,'format','DoubleMat','mattype',1,'enum',TemperatureSurfaceEnum()) 93 WriteData(fid,'data',self.basaltemp,'format','DoubleMat','mattype',1,'enum',TemperatureBasalEnum()) 88 94 WriteData(fid,'data',self.watercolumn,'format','DoubleMat','mattype',1,'enum',WatercolumnEnum()) 89 95 WriteData(fid,'data',self.waterfraction,'format','DoubleMat','mattype',1,'enum',WaterfractionEnum()) -
issm/trunk/src/m/classes/inversion.py
r13395 r13975 1 1 #module imports 2 2 import numpy 3 import copy 3 4 from fielddisplay import fielddisplay 4 5 from EnumDefinitions import * … … 96 97 #inversed parameter (10^8 for B, 50 for drag) and can be decreased 97 98 #after the first iterations 98 self.gradient_scaling=50*numpy.ones( self.nsteps)99 self.gradient_scaling=50*numpy.ones((self.nsteps,1)) 99 100 100 101 #several responses can be used: 101 self.cost_functions=101*numpy.ones( self.nsteps)102 self.cost_functions=101*numpy.ones((self.nsteps,1)) 102 103 103 104 #step_threshold is used to speed up control method. When … … 124 125 125 126 num_controls=numpy.size(md.inversion.control_parameters) 126 num_costfunc=numpy.size(md.inversion.cost_functions, 1)127 num_costfunc=numpy.size(md.inversion.cost_functions,axis=1) 127 128 128 129 md = checkfield(md,'inversion.iscontrol','values',[0,1]) 129 130 md = checkfield(md,'inversion.tao','values',[0,1]) 130 131 md = checkfield(md,'inversion.incomplete_adjoint','values',[0,1]) 131 md = checkfield(md,'inversion.control_parameters','cell',1,'values',['BalancethicknessThickeningRate','FrictionCoefficient','MaterialsRheologyBbar',' Vx','Vy'])132 md = checkfield(md,'inversion.control_parameters','cell',1,'values',['BalancethicknessThickeningRate','FrictionCoefficient','MaterialsRheologyBbar','MaterialsRheologyZbar','Vx','Vy']) 132 133 md = checkfield(md,'inversion.nsteps','numel',[1],'>=',1) 133 134 md = checkfield(md,'inversion.maxiter_per_step','size',[md.inversion.nsteps],'>=',0) … … 171 172 172 173 #process control parameters 173 num_control_parameters= numpy.size(self.control_parameters)174 data= [StringToEnum(self.control_parameters[i])[0] for i in xrange(0,num_control_parameters)]174 num_control_parameters=len(self.control_parameters) 175 data=numpy.array([StringToEnum(control_parameter)[0] for control_parameter in self.control_parameters]).reshape(1,-1) 175 176 WriteData(fid,'data',data,'enum',InversionControlParametersEnum(),'format','DoubleMat','mattype',3) 176 177 WriteData(fid,'data',num_control_parameters,'enum',InversionNumControlParametersEnum(),'format','Integer') 177 178 178 179 #process cost functions 179 num_cost_functions= size(self.cost_functions,1)180 data= self.cost_functions180 num_cost_functions=numpy.size(self.cost_functions,axis=1) 181 data=copy.deepcopy(self.cost_functions) 181 182 data[numpy.nonzero(data==101)]=SurfaceAbsVelMisfitEnum() 182 183 data[numpy.nonzero(data==102)]=SurfaceRelVelMisfitEnum() -
issm/trunk/src/m/classes/matice.py
r13395 r13975 8 8 class matice(object): 9 9 """ 10 MAT ERIALSclass definition10 MATICE class definition 11 11 12 12 Usage: -
issm/trunk/src/m/classes/mesh.m
r13395 r13975 15 15 numberofvertices = 0; 16 16 numberofedges = 0; 17 17 18 18 lat = NaN 19 19 long = NaN … … 158 158 fielddisplay(obj,'lowerelements','lower element list (NaN for element on the lower layer'); 159 159 fielddisplay(obj,'vertexonboundary','vertices on the boundary of the domain flag list'); 160 160 161 161 fielddisplay(obj,'segments','edges on domain boundary (vertex1 vertex2 element)'); 162 162 fielddisplay(obj,'segmentmarkers','number associated to each segment'); -
issm/trunk/src/m/classes/mesh.py
r13395 r13975 132 132 md = checkfield(md,'mesh.y','NaN',1,'size',[md.mesh.numberofvertices]) 133 133 md = checkfield(md,'mesh.z','NaN',1,'size',[md.mesh.numberofvertices]) 134 md = checkfield(md,'mesh.elements','NaN',1,'>',0,'values', range(1,md.mesh.numberofvertices+1))134 md = checkfield(md,'mesh.elements','NaN',1,'>',0,'values',numpy.arange(1,md.mesh.numberofvertices+1)) 135 135 if md.mesh.dimension==2: 136 136 md = checkfield(md,'mesh.elements','size',[md.mesh.numberofelements,3]) 137 137 else: 138 138 md = checkfield(md,'mesh.elements','size',[md.mesh.numberofelements,6]) 139 if numpy.any(numpy.logical_not(ismember( range(1,md.mesh.numberofvertices+1),md.mesh.elements))):139 if numpy.any(numpy.logical_not(ismember(numpy.arange(1,md.mesh.numberofvertices+1),md.mesh.elements))): 140 140 md.checkmessage("orphan nodes have been found. Check the mesh outline") 141 141 md = checkfield(md,'mesh.dimension','values',[2,3]) -
issm/trunk/src/m/classes/model/model.m
r13395 r13975 5 5 6 6 classdef model 7 properties (SetAccess=public) %Model fields 8 % {{{ 9 %Careful here: no other class should be used as default value this is a bug of matlab 10 mesh = 0; 11 mask = 0; 12 13 geometry = 0; 14 constants = 0; 15 surfaceforcings = 0; 16 basalforcings = 0; 17 materials = 0; 18 friction = 0; 19 flowequation = 0; 20 timestepping = 0; 21 initialization = 0; 22 rifts = 0; 23 24 debug = 0; 25 verbose = 0; 26 settings = 0; 27 solver = 0; 28 cluster = 0; 29 30 balancethickness = 0; 31 diagnostic = 0; 32 groundingline = 0; 33 hydrology = 0; 34 prognostic = 0; 35 thermal = 0; 36 steadystate = 0; 37 transient = 0; 38 39 autodiff = 0; 40 flaim = 0; 41 inversion = 0; 42 qmu = 0; 43 44 results = 0; 45 radaroverlay = 0; 46 miscellaneous = 0; 47 private = 0; 48 49 %}}} 50 end 51 methods (Static) 52 function md = loadobj(md) % {{{ 53 % This function is directly called by matlab when a model object is 54 % loaded. If the input is a struct it is an old version of model and 55 % old fields must be recovered (make sure they are in the deprecated 56 % model properties) 57 58 if verLessThan('matlab','7.9'), 59 disp('Warning: your matlab version is old and there is a risk that load does not work correctly'); 60 disp(' if the model is not loaded correctly, rename temporarily loadobj so that matlab does not use it'); 61 62 % This is a Matlab bug: all the fields of md have their default value 63 % Example of error message: 64 % Warning: Error loading an object of class 'model': 65 % Undefined function or method 'exist' for input arguments of type 'cell' 66 % 67 % This has been fixed in MATLAB 7.9 (R2009b) and later versions 68 end 69 70 if isstruct(md) 71 disp('Recovering model object from a previous version'); 72 md = structtomodel(model,md); 73 end 74 75 %2012 August 4th 76 if isa(md.materials,'materials'), 77 disp('Recovering old materials'); 78 if numel(md.materials.rheology_Z)==1 & isnan(md.materials.rheology_Z), 79 md.materials=matice(md.materials); 80 else 81 md.materials=matdamageice(md.materials); 82 end 83 end 84 85 end% }}} 86 end 87 methods 88 function md = model(varargin) % {{{ 89 90 switch nargin 91 case 0 92 md=setdefaultparameters(md); 93 otherwise 94 error('model constructor error message: 0 of 1 argument only in input.'); 95 end 96 end 97 %}}} 98 function md = checkmessage(md,string) % {{{ 99 if(nargout~=1) error('wrong usage, model must be an output'); end 100 disp(['model not consistent: ' string]); 101 md.private.isconsistent=false; 102 end 103 %}}} 104 function md = collapse(md)% {{{ 105 %COLLAPSE - collapses a 3d mesh into a 2d mesh 106 % 107 % This routine collapses a 3d model into a 2d model 108 % and collapses all the fileds of the 3d model by 109 % taking their depth-averaged values 110 % 111 % Usage: 112 % md=collapse(md) 113 % 114 % See also: EXTRUDE, MODELEXTRACT 115 116 %Check that the model is really a 3d model 117 if ~md.mesh.dimension==3, 118 error('collapse error message: only 3d mesh can be collapsed') 119 end 120 121 %Start with changing alle the fields from the 3d mesh 122 123 %drag is limited to nodes that are on the bedrock. 124 md.friction.coefficient=project2d(md,md.friction.coefficient,1); 125 126 %p and q (same deal, except for element that are on the bedrock: ) 127 md.friction.p=project2d(md,md.friction.p,1); 128 md.friction.q=project2d(md,md.friction.q,1); 129 130 %observations 131 if ~isnan(md.inversion.vx_obs), md.inversion.vx_obs=project2d(md,md.inversion.vx_obs,md.mesh.numberoflayers); end; 132 if ~isnan(md.inversion.vy_obs), md.inversion.vy_obs=project2d(md,md.inversion.vy_obs,md.mesh.numberoflayers); end; 133 if ~isnan(md.inversion.vel_obs), md.inversion.vel_obs=project2d(md,md.inversion.vel_obs,md.mesh.numberoflayers); end; 134 if ~isnan(md.inversion.cost_functions_coefficients), md.inversion.cost_functions_coefficients=project2d(md,md.inversion.cost_functions_coefficients,md.mesh.numberoflayers); end; 135 if numel(md.inversion.min_parameters)>1, md.inversion.min_parameters=project2d(md,md.inversion.min_parameters,md.mesh.numberoflayers); end; 136 if numel(md.inversion.max_parameters)>1, md.inversion.max_parameters=project2d(md,md.inversion.max_parameters,md.mesh.numberoflayers); end; 137 if ~isnan(md.surfaceforcings.mass_balance), 138 md.surfaceforcings.mass_balance=project2d(md,md.surfaceforcings.mass_balance,md.mesh.numberoflayers); 139 end; 140 if ~isnan(md.balancethickness.thickening_rate), md.balancethickness.thickening_rate=project2d(md,md.balancethickness.thickening_rate,md.mesh.numberoflayers); end; 141 142 %results 143 if ~isnan(md.initialization.vx),md.initialization.vx=DepthAverage(md,md.initialization.vx);end; 144 if ~isnan(md.initialization.vy),md.initialization.vy=DepthAverage(md,md.initialization.vy);end; 145 if ~isnan(md.initialization.vz),md.initialization.vz=DepthAverage(md,md.initialization.vz);end; 146 if ~isnan(md.initialization.vel),md.initialization.vel=DepthAverage(md,md.initialization.vel);end; 147 if ~isnan(md.initialization.temperature),md.initialization.temperature=DepthAverage(md,md.initialization.temperature);end; 148 149 %bedinfo and surface info 150 md.mesh.elementonbed=ones(md.mesh.numberofelements2d,1); 151 md.mesh.elementonsurface=ones(md.mesh.numberofelements2d,1); 152 md.mesh.vertexonbed=ones(md.mesh.numberofvertices2d,1); 153 md.mesh.vertexonsurface=ones(md.mesh.numberofvertices2d,1); 154 155 %elementstype 156 if ~isnan(md.flowequation.element_equation) 157 md.flowequation.element_equation=project2d(md,md.flowequation.element_equation,1); 158 md.flowequation.vertex_equation=project2d(md,md.flowequation.vertex_equation,1); 159 md.flowequation.bordermacayeal=project2d(md,md.flowequation.bordermacayeal,1); 160 md.flowequation.borderpattyn=project2d(md,md.flowequation.borderpattyn,1); 161 md.flowequation.borderstokes=project2d(md,md.flowequation.borderstokes,1); 162 end 163 164 %boundary conditions 165 md.diagnostic.spcvx=project2d(md,md.diagnostic.spcvx,md.mesh.numberoflayers); 166 md.diagnostic.spcvy=project2d(md,md.diagnostic.spcvy,md.mesh.numberoflayers); 167 md.diagnostic.spcvz=project2d(md,md.diagnostic.spcvz,md.mesh.numberoflayers); 168 md.diagnostic.referential=project2d(md,md.diagnostic.referential,md.mesh.numberoflayers); 169 md.prognostic.spcthickness=project2d(md,md.prognostic.spcthickness,md.mesh.numberoflayers); 170 md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.mesh.numberoflayers); 171 172 %Extrusion of Neumann BC 173 if ~isnan(md.diagnostic.icefront), 174 numberofneumann2d=size(md.diagnostic.icefront,1)/(md.mesh.numberoflayers-1); 175 md.diagnostic.icefront=[md.diagnostic.icefront(1:numberofneumann2d,1:2) md.diagnostic.icefront(1:numberofneumann2d,5:6)]; %Add two columns on the first layer 176 end 177 178 %materials 179 md.materials.rheology_B=DepthAverage(md,md.materials.rheology_B); 180 md.materials.rheology_n=project2d(md,md.materials.rheology_n,1); 181 if isa(md.materials,'matdamageice') 182 md.materials.rheology_Z=DepthAverage(md,md.materials.rheology_Z); 183 end 184 185 %special for thermal modeling: 186 md.basalforcings.melting_rate=project2d(md,md.basalforcings.melting_rate,1); 187 md.basalforcings.geothermalflux=project2d(md,md.basalforcings.geothermalflux,1); %bedrock only gets geothermal flux 188 189 %update of connectivity matrix 190 md.mesh.average_vertex_connectivity=25; 191 192 %Collapse the mesh 193 nodes2d=md.mesh.numberofvertices2d; 194 elements2d=md.mesh.numberofelements2d; 195 196 %parameters 197 md.geometry.surface=project2d(md,md.geometry.surface,1); 198 md.geometry.thickness=project2d(md,md.geometry.thickness,1); 199 md.geometry.bed=project2d(md,md.geometry.bed,1); 200 md.geometry.bathymetry=project2d(md,md.geometry.bathymetry,1); 201 md.mesh.vertexonboundary=project2d(md,md.mesh.vertexonboundary,1); 202 md.mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1); 203 md.mask.elementonfloatingice=project2d(md,md.mask.elementonfloatingice,1); 204 md.mask.vertexonfloatingice=project2d(md,md.mask.vertexonfloatingice,1); 205 md.mask.elementongroundedice=project2d(md,md.mask.elementongroundedice,1); 206 md.mask.vertexongroundedice=project2d(md,md.mask.vertexongroundedice,1); 207 md.mask.elementonwater=project2d(md,md.mask.elementonwater,1); 208 md.mask.vertexonwater=project2d(md,md.mask.vertexonwater,1); 209 210 %lat long 211 if numel(md.mesh.lat) ==md.mesh.numberofvertices, md.mesh.lat=project2d(md,md.mesh.lat,1); end 212 if numel(md.mesh.long)==md.mesh.numberofvertices, md.mesh.long=project2d(md,md.mesh.long,1); end 213 214 %Initialize with the 2d mesh 215 md.mesh.x=md.mesh.x2d; 216 md.mesh.y=md.mesh.y2d; 217 md.mesh.z=zeros(size(md.mesh.x2d)); 218 md.mesh.numberofvertices=md.mesh.numberofvertices2d; 219 md.mesh.numberofelements=md.mesh.numberofelements2d; 220 md.mesh.elements=md.mesh.elements2d; 221 222 %Keep a trace of lower and upper nodes 223 md.mesh.lowervertex=NaN; 224 md.mesh.uppervertex=NaN; 225 md.mesh.lowerelements=NaN; 226 md.mesh.upperelements=NaN; 227 228 %Remove old mesh 229 md.mesh.x2d=NaN; 230 md.mesh.y2d=NaN; 231 md.mesh.elements2d=NaN; 232 md.mesh.numberofelements2d=md.mesh.numberofelements; 233 md.mesh.numberofvertices2d=md.mesh.numberofvertices; 234 md.mesh.numberoflayers=0; 235 236 %Update mesh type 237 md.mesh.dimension=2; 238 end % }}} 239 function md2 = extract(md,area) % {{{ 240 %extract - extract a model according to an Argus contour or flag list 241 % 242 % This routine extracts a submodel from a bigger model with respect to a given contour 243 % md must be followed by the corresponding exp file or flags list 244 % It can either be a domain file (argus type, .exp extension), or an array of element flags. 245 % If user wants every element outside the domain to be 246 % extract2d, add '~' to the name of the domain file (ex: '~Pattyn.exp'); 247 % an empty string '' will be considered as an empty domain 248 % a string 'all' will be considered as the entire domain 249 % add an argument 0 if you do not want the elements to be checked (faster) 250 % 251 % Usage: 252 % md2=extract(md,area); 253 % 254 % Examples: 255 % md2=extract(md,'Domain.exp'); 256 % md2=extract(md,md.mask.elementonfloatingice); 257 % 258 % See also: EXTRUDE, COLLAPSE 259 260 %copy model 261 md1=md; 262 263 %some checks 264 if ((nargin~=2) | (nargout~=1)), 265 help extract 266 error('extract error message: bad usage'); 267 end 268 269 %get check option 270 if (nargin==3 & varargin{1}==0), 271 checkoutline=0; 272 else 273 checkoutline=1; 274 end 275 276 %get elements that are inside area 277 flag_elem=FlagElements(md1,area); 278 if ~any(flag_elem), 279 error('extracted model is empty'); 280 end 281 282 %kick out all elements with 3 dirichlets 283 spc_elem=find(~flag_elem); 284 spc_node=sort(unique(md1.mesh.elements(spc_elem,:))); 285 flag=ones(md1.mesh.numberofvertices,1); 286 flag(spc_node)=0; 287 pos=find(sum(flag(md1.mesh.elements),2)==0); 288 flag_elem(pos)=0; 289 290 %extracted elements and nodes lists 291 pos_elem=find(flag_elem); 292 pos_node=sort(unique(md1.mesh.elements(pos_elem,:))); 293 294 %keep track of some fields 295 numberofvertices1=md1.mesh.numberofvertices; 296 numberofelements1=md1.mesh.numberofelements; 297 numberofvertices2=length(pos_node); 298 numberofelements2=length(pos_elem); 299 flag_node=zeros(numberofvertices1,1); 300 flag_node(pos_node)=1; 301 302 %Create Pelem and Pnode (transform old nodes in new nodes and same thing for the elements) 303 Pelem=zeros(numberofelements1,1); 304 Pelem(pos_elem)=[1:numberofelements2]'; 305 Pnode=zeros(numberofvertices1,1); 306 Pnode(pos_node)=[1:numberofvertices2]'; 307 308 %renumber the elements (some node won't exist anymore) 309 elements_1=md1.mesh.elements; 310 elements_2=elements_1(pos_elem,:); 311 elements_2(:,1)=Pnode(elements_2(:,1)); 312 elements_2(:,2)=Pnode(elements_2(:,2)); 313 elements_2(:,3)=Pnode(elements_2(:,3)); 314 if md1.mesh.dimension==3, 315 elements_2(:,4)=Pnode(elements_2(:,4)); 316 elements_2(:,5)=Pnode(elements_2(:,5)); 317 elements_2(:,6)=Pnode(elements_2(:,6)); 318 end 319 320 %OK, now create the new model ! 321 322 %take every fields from model 323 md2=md1; 324 325 %automatically modify fields 326 327 %loop over model fields 328 model_fields=fields(md1); 329 for i=1:length(model_fields), 330 %get field 331 field=md1.(model_fields{i}); 332 fieldsize=size(field); 333 if isobject(field), %recursive call 334 object_fields=fields(md1.(model_fields{i})); 335 for j=1:length(object_fields), 336 %get field 337 field=md1.(model_fields{i}).(object_fields{j}); 338 fieldsize=size(field); 339 %size = number of nodes * n 340 if fieldsize(1)==numberofvertices1 341 md2.(model_fields{i}).(object_fields{j})=field(pos_node,:); 342 elseif (fieldsize(1)==numberofvertices1+1) 343 md2.(model_fields{i}).(object_fields{j})=[field(pos_node,:); field(end,:)]; 344 %size = number of elements * n 345 elseif fieldsize(1)==numberofelements1 346 md2.(model_fields{i}).(object_fields{j})=field(pos_elem,:); 347 end 348 end 349 else 350 %size = number of nodes * n 351 if fieldsize(1)==numberofvertices1 352 md2.(model_fields{i})=field(pos_node,:); 353 elseif (fieldsize(1)==numberofvertices1+1) 354 md2.(model_fields{i})=[field(pos_node,:); field(end,:)]; 355 %size = number of elements * n 356 elseif fieldsize(1)==numberofelements1 357 md2.(model_fields{i})=field(pos_elem,:); 358 end 359 end 360 end 361 362 %modify some specific fields 363 364 %Mesh 365 md2.mesh.numberofelements=numberofelements2; 366 md2.mesh.numberofvertices=numberofvertices2; 367 md2.mesh.elements=elements_2; 368 369 %mesh.uppervertex mesh.lowervertex 370 if md1.mesh.dimension==3 371 md2.mesh.uppervertex=md1.mesh.uppervertex(pos_node); 372 pos=find(~isnan(md2.mesh.uppervertex)); 373 md2.mesh.uppervertex(pos)=Pnode(md2.mesh.uppervertex(pos)); 374 375 md2.mesh.lowervertex=md1.mesh.lowervertex(pos_node); 376 pos=find(~isnan(md2.mesh.lowervertex)); 377 md2.mesh.lowervertex(pos)=Pnode(md2.mesh.lowervertex(pos)); 378 379 md2.mesh.upperelements=md1.mesh.upperelements(pos_elem); 380 pos=find(~isnan(md2.mesh.upperelements)); 381 md2.mesh.upperelements(pos)=Pelem(md2.mesh.upperelements(pos)); 382 383 md2.mesh.lowerelements=md1.mesh.lowerelements(pos_elem); 384 pos=find(~isnan(md2.mesh.lowerelements)); 385 md2.mesh.lowerelements(pos)=Pelem(md2.mesh.lowerelements(pos)); 386 end 387 388 %Initial 2d mesh 389 if md1.mesh.dimension==3 390 flag_elem_2d=flag_elem(1:md1.mesh.numberofelements2d); 391 pos_elem_2d=find(flag_elem_2d); 392 flag_node_2d=flag_node(1:md1.mesh.numberofvertices2d); 393 pos_node_2d=find(flag_node_2d); 394 395 md2.mesh.numberofelements2d=length(pos_elem_2d); 396 md2.mesh.numberofvertices2d=length(pos_node_2d); 397 md2.mesh.elements2d=md1.mesh.elements2d(pos_elem_2d,:); 398 md2.mesh.elements2d(:,1)=Pnode(md2.mesh.elements2d(:,1)); 399 md2.mesh.elements2d(:,2)=Pnode(md2.mesh.elements2d(:,2)); 400 md2.mesh.elements2d(:,3)=Pnode(md2.mesh.elements2d(:,3)); 401 402 md2.mesh.x2d=md1.mesh.x(pos_node_2d); 403 md2.mesh.y2d=md1.mesh.y(pos_node_2d); 404 end 405 406 %Edges 407 if size(md2.mesh.edges,2)>1, %do not use ~isnan because there are some NaNs... 408 %renumber first two columns 409 pos=find(md2.mesh.edges(:,4)~=-1); 410 md2.mesh.edges(: ,1)=Pnode(md2.mesh.edges(:,1)); 411 md2.mesh.edges(: ,2)=Pnode(md2.mesh.edges(:,2)); 412 md2.mesh.edges(: ,3)=Pelem(md2.mesh.edges(:,3)); 413 md2.mesh.edges(pos,4)=Pelem(md2.mesh.edges(pos,4)); 414 %remove edges when the 2 vertices are not in the domain. 415 md2.mesh.edges=md2.mesh.edges(find(md2.mesh.edges(:,1) & md2.mesh.edges(:,2)),:); 416 %Replace all zeros by -1 in the last two columns; 417 pos=find(md2.mesh.edges(:,3)==0); 418 md2.mesh.edges(pos,3)=-1; 419 pos=find(md2.mesh.edges(:,4)==0); 420 md2.mesh.edges(pos,4)=-1; 421 %Invert -1 on the third column with last column (Also invert first two columns!!) 422 pos=find(md2.mesh.edges(:,3)==-1); 423 md2.mesh.edges(pos,3)=md2.mesh.edges(pos,4); 424 md2.mesh.edges(pos,4)=-1; 425 values=md2.mesh.edges(pos,2); 426 md2.mesh.edges(pos,2)=md2.mesh.edges(pos,1); 427 md2.mesh.edges(pos,1)=values; 428 %Finally remove edges that do not belong to any element 429 pos=find(md2.mesh.edges(:,3)==-1 & md2.mesh.edges(:,4)==-1); 430 md2.mesh.edges(pos,:)=[]; 431 end 432 433 %Penalties 434 if ~isnan(md2.diagnostic.vertex_pairing), 435 for i=1:size(md1.diagnostic.vertex_pairing,1); 436 md2.diagnostic.vertex_pairing(i,:)=Pnode(md1.diagnostic.vertex_pairing(i,:)); 437 end 438 md2.diagnostic.vertex_pairing=md2.diagnostic.vertex_pairing(find(md2.diagnostic.vertex_pairing(:,1)),:); 439 end 440 if ~isnan(md2.prognostic.vertex_pairing), 441 for i=1:size(md1.prognostic.vertex_pairing,1); 442 md2.prognostic.vertex_pairing(i,:)=Pnode(md1.prognostic.vertex_pairing(i,:)); 443 end 444 md2.prognostic.vertex_pairing=md2.prognostic.vertex_pairing(find(md2.prognostic.vertex_pairing(:,1)),:); 445 end 446 447 %recreate segments 448 if md1.mesh.dimension==2 449 md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices); 450 md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity); 451 md2.mesh.segments=contourenvelope(md2); 452 md2.mesh.vertexonboundary=zeros(numberofvertices2,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2))=1; 453 else 454 %First do the connectivity for the contourenvelope in 2d 455 md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements2d,md2.mesh.numberofvertices2d); 456 md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements2d,md2.mesh.vertexconnectivity); 457 md2.mesh.segments=contourenvelope(md2); 458 md2.mesh.vertexonboundary=zeros(numberofvertices2/md2.mesh.numberoflayers,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2))=1; 459 md2.mesh.vertexonboundary=repmat(md2.mesh.vertexonboundary,md2.mesh.numberoflayers,1); 460 %Then do it for 3d as usual 461 md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices); 462 md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity); 463 end 464 465 %Boundary conditions: Dirichlets on new boundary 466 %Catch the elements that have not been extracted 467 orphans_elem=find(~flag_elem); 468 orphans_node=unique(md1.mesh.elements(orphans_elem,:))'; 469 %Figure out which node are on the boundary between md2 and md1 470 nodestoflag1=intersect(orphans_node,pos_node); 471 nodestoflag2=Pnode(nodestoflag1); 472 if numel(md1.diagnostic.spcvx)>1 & numel(md1.diagnostic.spcvy)>2 & numel(md1.diagnostic.spcvz)>2, 473 if numel(md1.inversion.vx_obs)>1 & numel(md1.inversion.vy_obs)>1 474 md2.diagnostic.spcvx(nodestoflag2)=md2.inversion.vx_obs(nodestoflag2); 475 md2.diagnostic.spcvy(nodestoflag2)=md2.inversion.vy_obs(nodestoflag2); 476 else 477 md2.diagnostic.spcvx(nodestoflag2)=NaN; 478 md2.diagnostic.spcvy(nodestoflag2)=NaN; 479 disp(' ') 480 disp('!! extract warning: spc values should be checked !!') 481 disp(' ') 482 end 483 %put 0 for vz 484 md2.diagnostic.spcvz(nodestoflag2)=0; 485 end 486 if ~isnan(md1.thermal.spctemperature), 487 md2.thermal.spctemperature(nodestoflag2,1)=1; 488 end 489 490 %Diagnostic 491 if ~isnan(md2.diagnostic.icefront) 492 md2.diagnostic.icefront(:,1)=Pnode(md1.diagnostic.icefront(:,1)); 493 md2.diagnostic.icefront(:,2)=Pnode(md1.diagnostic.icefront(:,2)); 494 md2.diagnostic.icefront(:,end-1)=Pelem(md1.diagnostic.icefront(:,end-1)); 495 if md1.mesh.dimension==3 496 md2.diagnostic.icefront(:,3)=Pnode(md1.diagnostic.icefront(:,3)); 497 md2.diagnostic.icefront(:,4)=Pnode(md1.diagnostic.icefront(:,4)); 498 end 499 md2.diagnostic.icefront=md2.diagnostic.icefront(find(md2.diagnostic.icefront(:,1) & md2.diagnostic.icefront(:,2) & md2.diagnostic.icefront(:,end)),:); 500 end 501 502 %Results fields 503 if isstruct(md1.results), 504 md2.results=struct(); 505 solutionfields=fields(md1.results); 506 for i=1:length(solutionfields), 507 %get subfields 508 solutionsubfields=fields(md1.results.(solutionfields{i})); 509 for j=1:length(solutionsubfields), 510 field=md1.results.(solutionfields{i}).(solutionsubfields{j}); 511 if length(field)==numberofvertices1, 512 md2.results.(solutionfields{i}).(solutionsubfields{j})=field(pos_node); 513 elseif length(field)==numberofelements1, 514 md2.results.(solutionfields{i}).(solutionsubfields{j})=field(pos_elem); 515 else 516 md2.results.(solutionfields{i}).(solutionsubfields{j})=field; 517 end 518 end 519 end 520 end 521 522 %Keep track of pos_node and pos_elem 523 md2.mesh.extractedvertices=pos_node; 524 md2.mesh.extractedelements=pos_elem; 525 end % }}} 526 function md = extrude(md,varargin) % {{{ 527 %EXTRUDE - vertically extrude a 2d mesh 528 % 529 % vertically extrude a 2d mesh and create corresponding 3d mesh. 530 % The vertical distribution can: 531 % - follow a polynomial law 532 % - follow two polynomial laws, one for the lower part and one for the upper part of the mesh 533 % - be discribed by a list of coefficients (between 0 and 1) 534 % 535 % 536 % Usage: 537 % md=extrude(md,numlayers,extrusionexponent); 538 % md=extrude(md,numlayers,lowerexponent,upperexponent); 539 % md=extrude(md,listofcoefficients); 540 % 541 % Example: 542 % md=extrude(md,8,3); 543 % md=extrude(md,8,3,2); 544 % md=extrude(md,[0 0.2 0.5 0.7 0.9 0.95 1]); 545 % 546 % See also: MODELEXTRACT, COLLAPSE 547 548 %some checks on list of arguments 549 if ((nargin>4) | (nargin<2) | (nargout~=1)), 550 help extrude; 551 error('extrude error message'); 552 end 553 554 %Extrude the mesh 555 if nargin==2, %list of coefficients 556 clist=varargin{1}; 557 if any(clist<0) | any(clist>1), 558 error('extrusioncoefficients must be between 0 and 1'); 559 end 560 extrusionlist=sort(unique([clist(:);0;1])); 561 numlayers=length(extrusionlist); 562 elseif nargin==3, %one polynomial law 563 if varargin{2}<=0, 564 help extrude; 565 error('extrusionexponent must be >=0'); 566 end 567 numlayers=varargin{1}; 568 extrusionlist=((0:1:numlayers-1)/(numlayers-1)).^varargin{2}; 569 elseif nargin==4, %two polynomial laws 570 numlayers=varargin{1}; 571 lowerexp=varargin{2}; 572 upperexp=varargin{3}; 573 574 if varargin{2}<=0 | varargin{3}<=0, 575 help extrude; 576 error('lower and upper extrusionexponents must be >=0'); 577 end 578 579 lowerextrusionlist=[(0:2/(numlayers-1):1).^lowerexp]/2; 580 upperextrusionlist=[(0:2/(numlayers-1):1).^upperexp]/2; 581 extrusionlist=sort(unique([lowerextrusionlist 1-upperextrusionlist])); 582 583 end 584 585 if numlayers<2, 586 error('number of layers should be at least 2'); 587 end 588 if md.mesh.dimension==3, 589 error('Cannot extrude a 3d mesh (extrude cannot be called more than once)'); 590 end 591 592 %Initialize with the 2d mesh 593 x3d=[]; 594 y3d=[]; 595 z3d=[]; %the lower node is on the bed 596 thickness3d=md.geometry.thickness; %thickness and bed for these nodes 597 bed3d=md.geometry.bed; 598 599 %Create the new layers 600 for i=1:numlayers, 601 x3d=[x3d; md.mesh.x]; 602 y3d=[y3d; md.mesh.y]; 603 %nodes are distributed between bed and surface accordingly to the given exponent 604 z3d=[z3d; bed3d+thickness3d*extrusionlist(i)]; 605 end 606 number_nodes3d=size(x3d,1); %number of 3d nodes for the non extruded part of the mesh 607 608 %Extrude elements 609 elements3d=[]; 610 for i=1:numlayers-1, 611 elements3d=[elements3d;[md.mesh.elements+(i-1)*md.mesh.numberofvertices md.mesh.elements+i*md.mesh.numberofvertices]]; %Create the elements of the 3d mesh for the non extruded part 612 end 613 number_el3d=size(elements3d,1); %number of 3d nodes for the non extruded part of the mesh 614 615 %Keep a trace of lower and upper nodes 616 mesh.lowervertex=NaN*ones(number_nodes3d,1); 617 mesh.uppervertex=NaN*ones(number_nodes3d,1); 618 mesh.lowervertex(md.mesh.numberofvertices+1:end)=1:(numlayers-1)*md.mesh.numberofvertices; 619 mesh.uppervertex(1:(numlayers-1)*md.mesh.numberofvertices)=md.mesh.numberofvertices+1:number_nodes3d; 620 md.mesh.lowervertex=mesh.lowervertex; 621 md.mesh.uppervertex=mesh.uppervertex; 622 623 %same for lower and upper elements 624 mesh.lowerelements=NaN*ones(number_el3d,1); 625 mesh.upperelements=NaN*ones(number_el3d,1); 626 mesh.lowerelements(md.mesh.numberofelements+1:end)=1:(numlayers-2)*md.mesh.numberofelements; 627 mesh.upperelements(1:(numlayers-2)*md.mesh.numberofelements)=md.mesh.numberofelements+1:(numlayers-1)*md.mesh.numberofelements; 628 md.mesh.lowerelements=mesh.lowerelements; 629 md.mesh.upperelements=mesh.upperelements; 630 631 %Save old mesh 632 md.mesh.x2d=md.mesh.x; 633 md.mesh.y2d=md.mesh.y; 634 md.mesh.elements2d=md.mesh.elements; 635 md.mesh.numberofelements2d=md.mesh.numberofelements; 636 md.mesh.numberofvertices2d=md.mesh.numberofvertices; 637 638 %Update mesh type 639 md.mesh.dimension=3; 640 641 %Build global 3d mesh 642 md.mesh.elements=elements3d; 643 md.mesh.x=x3d; 644 md.mesh.y=y3d; 645 md.mesh.z=z3d; 646 md.mesh.numberofelements=number_el3d; 647 md.mesh.numberofvertices=number_nodes3d; 648 md.mesh.numberoflayers=numlayers; 649 650 %Ok, now deal with the other fields from the 2d mesh: 651 652 %lat long 653 md.mesh.lat=project3d(md,'vector',md.mesh.lat,'type','node'); 654 md.mesh.long=project3d(md,'vector',md.mesh.long,'type','node'); 655 656 %drag coefficient is limited to nodes that are on the bedrock. 657 md.friction.coefficient=project3d(md,'vector',md.friction.coefficient,'type','node','layer',1); 658 659 %p and q (same deal, except for element that are on the bedrock: ) 660 md.friction.p=project3d(md,'vector',md.friction.p,'type','element'); 661 md.friction.q=project3d(md,'vector',md.friction.q,'type','element'); 662 663 %observations 664 md.inversion.vx_obs=project3d(md,'vector',md.inversion.vx_obs,'type','node'); 665 md.inversion.vy_obs=project3d(md,'vector',md.inversion.vy_obs,'type','node'); 666 md.inversion.vel_obs=project3d(md,'vector',md.inversion.vel_obs,'type','node'); 667 md.surfaceforcings.mass_balance=project3d(md,'vector',md.surfaceforcings.mass_balance,'type','node'); 668 md.surfaceforcings.precipitation=project3d(md,'vector',md.surfaceforcings.precipitation,'type','node'); 669 md.balancethickness.thickening_rate=project3d(md,'vector',md.balancethickness.thickening_rate,'type','node'); 670 md.surfaceforcings.monthlytemperatures=project3d(md,'vector',md.surfaceforcings.monthlytemperatures,'type','node'); 671 672 %results 673 if ~isnan(md.initialization.vx),md.initialization.vx=project3d(md,'vector',md.initialization.vx,'type','node');end; 674 if ~isnan(md.initialization.vy),md.initialization.vy=project3d(md,'vector',md.initialization.vy,'type','node');end; 675 if ~isnan(md.initialization.vz),md.initialization.vz=project3d(md,'vector',md.initialization.vz,'type','node');end; 676 if ~isnan(md.initialization.vel),md.initialization.vel=project3d(md,'vector',md.initialization.vel,'type','node');end; 677 if ~isnan(md.initialization.temperature),md.initialization.temperature=project3d(md,'vector',md.initialization.temperature,'type','node');end; 678 if ~isnan(md.initialization.waterfraction),md.initialization.waterfraction=project3d(md,'vector',md.initialization.waterfraction,'type','node');end; 679 680 %bedinfo and surface info 681 md.mesh.elementonbed=project3d(md,'vector',ones(md.mesh.numberofelements2d,1),'type','element','layer',1); 682 md.mesh.elementonsurface=project3d(md,'vector',ones(md.mesh.numberofelements2d,1),'type','element','layer',md.mesh.numberoflayers-1); 683 md.mesh.vertexonbed=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',1); 684 md.mesh.vertexonsurface=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',md.mesh.numberoflayers); 685 686 %elementstype 687 if ~isnan(md.flowequation.element_equation) 688 oldelements_type=md.flowequation.element_equation; 689 md.flowequation.element_equation=zeros(number_el3d,1); 690 md.flowequation.element_equation=project3d(md,'vector',oldelements_type,'type','element'); 691 end 692 693 %verticestype 694 if ~isnan(md.flowequation.vertex_equation) 695 oldvertices_type=md.flowequation.vertex_equation; 696 md.flowequation.vertex_equation=zeros(number_nodes3d,1); 697 md.flowequation.vertex_equation=project3d(md,'vector',oldvertices_type,'type','node'); 698 end 699 md.flowequation.bordermacayeal=project3d(md,'vector',md.flowequation.bordermacayeal,'type','node'); 700 md.flowequation.borderpattyn=project3d(md,'vector',md.flowequation.borderpattyn,'type','node'); 701 md.flowequation.borderstokes=project3d(md,'vector',md.flowequation.borderstokes,'type','node'); 702 703 %boundary conditions 704 md.diagnostic.spcvx=project3d(md,'vector',md.diagnostic.spcvx,'type','node'); 705 md.diagnostic.spcvy=project3d(md,'vector',md.diagnostic.spcvy,'type','node'); 706 md.diagnostic.spcvz=project3d(md,'vector',md.diagnostic.spcvz,'type','node'); 707 md.thermal.spctemperature=project3d(md,'vector',md.thermal.spctemperature,'type','node','layer',md.mesh.numberoflayers,'padding',NaN); 708 md.prognostic.spcthickness=project3d(md,'vector',md.prognostic.spcthickness,'type','node'); 709 md.balancethickness.spcthickness=project3d(md,'vector',md.balancethickness.spcthickness,'type','node'); 710 md.diagnostic.referential=project3d(md,'vector',md.diagnostic.referential,'type','node'); 711 712 %in 3d, pressureload: [node1 node2 node3 node4 element] 713 pressureload_layer1=[md.diagnostic.icefront(:,1:2) md.diagnostic.icefront(:,2)+md.mesh.numberofvertices2d md.diagnostic.icefront(:,1)+md.mesh.numberofvertices2d md.diagnostic.icefront(:,3:4)]; %Add two columns on the first layer 714 pressureload=[]; 715 for i=1:numlayers-1, 716 pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d pressureload_layer1(:,6)]; 717 end 718 md.diagnostic.icefront=pressureload; 719 720 %connectivity 721 md.mesh.elementconnectivity=repmat(md.mesh.elementconnectivity,numlayers-1,1); 722 md.mesh.elementconnectivity(find(md.mesh.elementconnectivity==0))=NaN; 723 for i=2:numlayers-1, 724 md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)... 725 =md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)+md.mesh.numberofelements2d; 726 end 727 md.mesh.elementconnectivity(find(isnan(md.mesh.elementconnectivity)))=0; 728 729 %materials 730 md.materials.rheology_B=project3d(md,'vector',md.materials.rheology_B,'type','node'); 731 md.materials.rheology_n=project3d(md,'vector',md.materials.rheology_n,'type','element'); 732 if isa(md.materials,'matdamageice') 733 md.materials.rheology_Z=project3d(md,'vector',md.materials.rheology_Z,'type','node'); 734 end 735 736 %parameters 737 md.geometry.surface=project3d(md,'vector',md.geometry.surface,'type','node'); 738 md.geometry.thickness=project3d(md,'vector',md.geometry.thickness,'type','node'); 739 md.geometry.hydrostatic_ratio=project3d(md,'vector',md.geometry.hydrostatic_ratio,'type','node'); 740 md.geometry.bed=project3d(md,'vector',md.geometry.bed,'type','node'); 741 md.geometry.bathymetry=project3d(md,'vector',md.geometry.bathymetry,'type','node'); 742 md.mesh.vertexonboundary=project3d(md,'vector',md.mesh.vertexonboundary,'type','node'); 743 md.mask.elementonfloatingice=project3d(md,'vector',md.mask.elementonfloatingice,'type','element'); 744 md.mask.vertexonfloatingice=project3d(md,'vector',md.mask.vertexonfloatingice,'type','node'); 745 md.mask.elementongroundedice=project3d(md,'vector',md.mask.elementongroundedice,'type','element'); 746 md.mask.vertexongroundedice=project3d(md,'vector',md.mask.vertexongroundedice,'type','node'); 747 md.mask.elementonwater=project3d(md,'vector',md.mask.elementonwater,'type','element'); 748 md.mask.vertexonwater=project3d(md,'vector',md.mask.vertexonwater,'type','node'); 749 if ~isnan(md.inversion.cost_functions_coefficients),md.inversion.cost_functions_coefficients=project3d(md,'vector',md.inversion.cost_functions_coefficients,'type','node');end; 750 if ~isnan(md.inversion.min_parameters),md.inversion.min_parameters=project3d(md,'vector',md.inversion.min_parameters,'type','node');end; 751 if ~isnan(md.inversion.max_parameters),md.inversion.max_parameters=project3d(md,'vector',md.inversion.max_parameters,'type','node');end; 752 if ~isnan(md.qmu.partition),md.qmu.partition=project3d(md,'vector',md.qmu.partition','type','node');end 753 if(md.surfaceforcings.isdelta18o),md.surfaceforcings.temperatures_lgm=project3d(md,'vector',md.surfaceforcings.temperatures_lgm,'type','node');end 754 if(md.surfaceforcings.isdelta18o),md.surfaceforcings.temperatures_presentday=project3d(md,'vector',md.surfaceforcings.temperatures_presentday,'type','node');end 755 if(md.surfaceforcings.isdelta18o),md.surfaceforcings.precipitations_presentday=project3d(md,'vector',md.surfaceforcings.precipitations_presentday,'type','node');end 756 757 %Put lithostatic pressure if there is an existing pressure 758 if ~isnan(md.initialization.pressure), 759 md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z); 760 end 761 762 %special for thermal modeling: 763 md.basalforcings.melting_rate=project3d(md,'vector',md.basalforcings.melting_rate,'type','node','layer',1); 764 if ~isnan(md.basalforcings.geothermalflux) 765 md.basalforcings.geothermalflux=project3d(md,'vector',md.basalforcings.geothermalflux,'type','node','layer',1); %bedrock only gets geothermal flux 766 end 767 768 %increase connectivity if less than 25: 769 if md.mesh.average_vertex_connectivity<=25, 770 md.mesh.average_vertex_connectivity=100; 771 end 7 properties (SetAccess=public) %Model fields 8 % {{{ 9 %Careful here: no other class should be used as default value this is a bug of matlab 10 mesh = 0; 11 mask = 0; 12 13 geometry = 0; 14 constants = 0; 15 surfaceforcings = 0; 16 basalforcings = 0; 17 materials = 0; 18 friction = 0; 19 flowequation = 0; 20 timestepping = 0; 21 initialization = 0; 22 rifts = 0; 23 24 debug = 0; 25 verbose = 0; 26 settings = 0; 27 solver = 0; 28 cluster = 0; 29 30 balancethickness = 0; 31 diagnostic = 0; 32 groundingline = 0; 33 hydrology = 0; 34 prognostic = 0; 35 thermal = 0; 36 steadystate = 0; 37 transient = 0; 38 39 autodiff = 0; 40 flaim = 0; 41 inversion = 0; 42 qmu = 0; 43 44 results = 0; 45 radaroverlay = 0; 46 miscellaneous = 0; 47 private = 0; 48 49 %}}} 50 end 51 methods (Static) 52 function md = loadobj(md) % {{{ 53 % This function is directly called by matlab when a model object is 54 % loaded. If the input is a struct it is an old version of model and 55 % old fields must be recovered (make sure they are in the deprecated 56 % model properties) 57 58 if verLessThan('matlab','7.9'), 59 disp('Warning: your matlab version is old and there is a risk that load does not work correctly'); 60 disp(' if the model is not loaded correctly, rename temporarily loadobj so that matlab does not use it'); 61 62 % This is a Matlab bug: all the fields of md have their default value 63 % Example of error message: 64 % Warning: Error loading an object of class 'model': 65 % Undefined function or method 'exist' for input arguments of type 'cell' 66 % 67 % This has been fixed in MATLAB 7.9 (R2009b) and later versions 68 end 69 70 if isstruct(md) 71 disp('Recovering model object from a previous version'); 72 md = structtomodel(model,md); 73 end 74 75 %2012 August 4th 76 if isa(md.materials,'materials'), 77 disp('Recovering old materials'); 78 if numel(md.materials.rheology_Z)==1 & isnan(md.materials.rheology_Z), 79 md.materials=matice(md.materials); 80 else 81 md.materials=matdamageice(md.materials); 82 end 83 end 84 %2012 June 28th 85 if sum(sum(isnan(md.mesh.edges)))>0 86 disp('Update model edges from previous version'); 87 md.mesh.edges(isnan(md.mesh.edges))=-1; 88 end 89 90 end% }}} 91 end 92 methods 93 function md = model(varargin) % {{{ 94 95 switch nargin 96 case 0 97 md=setdefaultparameters(md); 98 otherwise 99 error('model constructor error message: 0 of 1 argument only in input.'); 100 end 101 end 102 %}}} 103 function md = checkmessage(md,string) % {{{ 104 if(nargout~=1) error('wrong usage, model must be an output'); end 105 disp(['model not consistent: ' string]); 106 md.private.isconsistent=false; 107 end 108 %}}} 109 function md = collapse(md)% {{{ 110 %COLLAPSE - collapses a 3d mesh into a 2d mesh 111 % 112 % This routine collapses a 3d model into a 2d model 113 % and collapses all the fileds of the 3d model by 114 % taking their depth-averaged values 115 % 116 % Usage: 117 % md=collapse(md) 118 % 119 % See also: EXTRUDE, MODELEXTRACT 120 121 %Check that the model is really a 3d model 122 if ~md.mesh.dimension==3, 123 error('collapse error message: only 3d mesh can be collapsed') 124 end 125 126 %Start with changing alle the fields from the 3d mesh 127 128 %drag is limited to nodes that are on the bedrock. 129 md.friction.coefficient=project2d(md,md.friction.coefficient,1); 130 131 %p and q (same deal, except for element that are on the bedrock: ) 132 md.friction.p=project2d(md,md.friction.p,1); 133 md.friction.q=project2d(md,md.friction.q,1); 134 135 %observations 136 if ~isnan(md.inversion.vx_obs), md.inversion.vx_obs=project2d(md,md.inversion.vx_obs,md.mesh.numberoflayers); end; 137 if ~isnan(md.inversion.vy_obs), md.inversion.vy_obs=project2d(md,md.inversion.vy_obs,md.mesh.numberoflayers); end; 138 if ~isnan(md.inversion.vel_obs), md.inversion.vel_obs=project2d(md,md.inversion.vel_obs,md.mesh.numberoflayers); end; 139 if ~isnan(md.inversion.cost_functions_coefficients), md.inversion.cost_functions_coefficients=project2d(md,md.inversion.cost_functions_coefficients,md.mesh.numberoflayers); end; 140 if numel(md.inversion.min_parameters)>1, md.inversion.min_parameters=project2d(md,md.inversion.min_parameters,md.mesh.numberoflayers); end; 141 if numel(md.inversion.max_parameters)>1, md.inversion.max_parameters=project2d(md,md.inversion.max_parameters,md.mesh.numberoflayers); end; 142 if ~isnan(md.surfaceforcings.mass_balance), 143 md.surfaceforcings.mass_balance=project2d(md,md.surfaceforcings.mass_balance,md.mesh.numberoflayers); 144 end; 145 if ~isnan(md.balancethickness.thickening_rate), md.balancethickness.thickening_rate=project2d(md,md.balancethickness.thickening_rate,md.mesh.numberoflayers); end; 146 147 %results 148 if ~isnan(md.initialization.vx),md.initialization.vx=DepthAverage(md,md.initialization.vx);end; 149 if ~isnan(md.initialization.vy),md.initialization.vy=DepthAverage(md,md.initialization.vy);end; 150 if ~isnan(md.initialization.vz),md.initialization.vz=DepthAverage(md,md.initialization.vz);end; 151 if ~isnan(md.initialization.vel),md.initialization.vel=DepthAverage(md,md.initialization.vel);end; 152 if ~isnan(md.initialization.temperature),md.initialization.temperature=DepthAverage(md,md.initialization.temperature);end; 153 154 %bedinfo and surface info 155 md.mesh.elementonbed=ones(md.mesh.numberofelements2d,1); 156 md.mesh.elementonsurface=ones(md.mesh.numberofelements2d,1); 157 md.mesh.vertexonbed=ones(md.mesh.numberofvertices2d,1); 158 md.mesh.vertexonsurface=ones(md.mesh.numberofvertices2d,1); 159 160 %elementstype 161 if ~isnan(md.flowequation.element_equation) 162 md.flowequation.element_equation=project2d(md,md.flowequation.element_equation,1); 163 md.flowequation.vertex_equation=project2d(md,md.flowequation.vertex_equation,1); 164 md.flowequation.bordermacayeal=project2d(md,md.flowequation.bordermacayeal,1); 165 md.flowequation.borderpattyn=project2d(md,md.flowequation.borderpattyn,1); 166 md.flowequation.borderstokes=project2d(md,md.flowequation.borderstokes,1); 167 end 168 169 %boundary conditions 170 md.diagnostic.spcvx=project2d(md,md.diagnostic.spcvx,md.mesh.numberoflayers); 171 md.diagnostic.spcvy=project2d(md,md.diagnostic.spcvy,md.mesh.numberoflayers); 172 md.diagnostic.spcvz=project2d(md,md.diagnostic.spcvz,md.mesh.numberoflayers); 173 md.diagnostic.referential=project2d(md,md.diagnostic.referential,md.mesh.numberoflayers); 174 md.prognostic.spcthickness=project2d(md,md.prognostic.spcthickness,md.mesh.numberoflayers); 175 md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.mesh.numberoflayers); 176 177 %Extrusion of Neumann BC 178 if ~isnan(md.diagnostic.icefront), 179 numberofneumann2d=size(md.diagnostic.icefront,1)/(md.mesh.numberoflayers-1); 180 md.diagnostic.icefront=[md.diagnostic.icefront(1:numberofneumann2d,1:2) md.diagnostic.icefront(1:numberofneumann2d,5:6)]; %Add two columns on the first layer 181 end 182 183 %materials 184 md.materials.rheology_B=DepthAverage(md,md.materials.rheology_B); 185 md.materials.rheology_n=project2d(md,md.materials.rheology_n,1); 186 if isa(md.materials,'matdamageice') 187 md.materials.rheology_Z=DepthAverage(md,md.materials.rheology_Z); 188 end 189 190 %special for thermal modeling: 191 md.basalforcings.melting_rate=project2d(md,md.basalforcings.melting_rate,1); 192 md.basalforcings.geothermalflux=project2d(md,md.basalforcings.geothermalflux,1); %bedrock only gets geothermal flux 193 194 %update of connectivity matrix 195 md.mesh.average_vertex_connectivity=25; 196 197 %Collapse the mesh 198 nodes2d=md.mesh.numberofvertices2d; 199 elements2d=md.mesh.numberofelements2d; 200 201 %parameters 202 md.geometry.surface=project2d(md,md.geometry.surface,1); 203 md.geometry.thickness=project2d(md,md.geometry.thickness,1); 204 md.geometry.bed=project2d(md,md.geometry.bed,1); 205 md.geometry.bathymetry=project2d(md,md.geometry.bathymetry,1); 206 md.mesh.vertexonboundary=project2d(md,md.mesh.vertexonboundary,1); 207 md.mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1); 208 md.mask.elementonfloatingice=project2d(md,md.mask.elementonfloatingice,1); 209 md.mask.vertexonfloatingice=project2d(md,md.mask.vertexonfloatingice,1); 210 md.mask.elementongroundedice=project2d(md,md.mask.elementongroundedice,1); 211 md.mask.vertexongroundedice=project2d(md,md.mask.vertexongroundedice,1); 212 md.mask.elementonwater=project2d(md,md.mask.elementonwater,1); 213 md.mask.vertexonwater=project2d(md,md.mask.vertexonwater,1); 214 215 %lat long 216 if numel(md.mesh.lat) ==md.mesh.numberofvertices, md.mesh.lat=project2d(md,md.mesh.lat,1); end 217 if numel(md.mesh.long)==md.mesh.numberofvertices, md.mesh.long=project2d(md,md.mesh.long,1); end 218 219 %Initialize with the 2d mesh 220 md.mesh.x=md.mesh.x2d; 221 md.mesh.y=md.mesh.y2d; 222 md.mesh.z=zeros(size(md.mesh.x2d)); 223 md.mesh.numberofvertices=md.mesh.numberofvertices2d; 224 md.mesh.numberofelements=md.mesh.numberofelements2d; 225 md.mesh.elements=md.mesh.elements2d; 226 227 %Keep a trace of lower and upper nodes 228 md.mesh.lowervertex=NaN; 229 md.mesh.uppervertex=NaN; 230 md.mesh.lowerelements=NaN; 231 md.mesh.upperelements=NaN; 232 233 %Remove old mesh 234 md.mesh.x2d=NaN; 235 md.mesh.y2d=NaN; 236 md.mesh.elements2d=NaN; 237 md.mesh.numberofelements2d=md.mesh.numberofelements; 238 md.mesh.numberofvertices2d=md.mesh.numberofvertices; 239 md.mesh.numberoflayers=0; 240 241 %Update mesh type 242 md.mesh.dimension=2; 243 end % }}} 244 function md2 = extract(md,area) % {{{ 245 %extract - extract a model according to an Argus contour or flag list 246 % 247 % This routine extracts a submodel from a bigger model with respect to a given contour 248 % md must be followed by the corresponding exp file or flags list 249 % It can either be a domain file (argus type, .exp extension), or an array of element flags. 250 % If user wants every element outside the domain to be 251 % extract2d, add '~' to the name of the domain file (ex: '~Pattyn.exp'); 252 % an empty string '' will be considered as an empty domain 253 % a string 'all' will be considered as the entire domain 254 % 255 % Usage: 256 % md2=extract(md,area); 257 % 258 % Examples: 259 % md2=extract(md,'Domain.exp'); 260 % md2=extract(md,md.mask.elementonfloatingice); 261 % 262 % See also: EXTRUDE, COLLAPSE 263 264 %copy model 265 md1=md; 266 267 %some checks 268 if ((nargin~=2) | (nargout~=1)), 269 help extract 270 error('extract error message: bad usage'); 271 end 272 273 %get elements that are inside area 274 flag_elem=FlagElements(md1,area); 275 if ~any(flag_elem), 276 error('extracted model is empty'); 277 end 278 279 %kick out all elements with 3 dirichlets 280 spc_elem=find(~flag_elem); 281 spc_node=sort(unique(md1.mesh.elements(spc_elem,:))); 282 flag=ones(md1.mesh.numberofvertices,1); 283 flag(spc_node)=0; 284 pos=find(sum(flag(md1.mesh.elements),2)==0); 285 flag_elem(pos)=0; 286 287 %extracted elements and nodes lists 288 pos_elem=find(flag_elem); 289 pos_node=sort(unique(md1.mesh.elements(pos_elem,:))); 290 291 %keep track of some fields 292 numberofvertices1=md1.mesh.numberofvertices; 293 numberofelements1=md1.mesh.numberofelements; 294 numberofvertices2=length(pos_node); 295 numberofelements2=length(pos_elem); 296 flag_node=zeros(numberofvertices1,1); 297 flag_node(pos_node)=1; 298 299 %Create Pelem and Pnode (transform old nodes in new nodes and same thing for the elements) 300 Pelem=zeros(numberofelements1,1); 301 Pelem(pos_elem)=[1:numberofelements2]'; 302 Pnode=zeros(numberofvertices1,1); 303 Pnode(pos_node)=[1:numberofvertices2]'; 304 305 %renumber the elements (some nodes won't exist anymore) 306 elements_1=md1.mesh.elements; 307 elements_2=elements_1(pos_elem,:); 308 elements_2(:,1)=Pnode(elements_2(:,1)); 309 elements_2(:,2)=Pnode(elements_2(:,2)); 310 elements_2(:,3)=Pnode(elements_2(:,3)); 311 if md1.mesh.dimension==3, 312 elements_2(:,4)=Pnode(elements_2(:,4)); 313 elements_2(:,5)=Pnode(elements_2(:,5)); 314 elements_2(:,6)=Pnode(elements_2(:,6)); 315 end 316 317 %OK, now create the new model! 318 319 %take every field from model 320 md2=md1; 321 322 %automatically modify fields 323 324 %loop over model fields 325 model_fields=fields(md1); 326 for i=1:length(model_fields), 327 %get field 328 field=md1.(model_fields{i}); 329 fieldsize=size(field); 330 if isobject(field), %recursive call 331 object_fields=fields(md1.(model_fields{i})); 332 for j=1:length(object_fields), 333 %get field 334 field=md1.(model_fields{i}).(object_fields{j}); 335 fieldsize=size(field); 336 %size = number of nodes * n 337 if fieldsize(1)==numberofvertices1 338 md2.(model_fields{i}).(object_fields{j})=field(pos_node,:); 339 elseif (fieldsize(1)==numberofvertices1+1) 340 md2.(model_fields{i}).(object_fields{j})=[field(pos_node,:); field(end,:)]; 341 %size = number of elements * n 342 elseif fieldsize(1)==numberofelements1 343 md2.(model_fields{i}).(object_fields{j})=field(pos_elem,:); 344 end 345 end 346 else 347 %size = number of nodes * n 348 if fieldsize(1)==numberofvertices1 349 md2.(model_fields{i})=field(pos_node,:); 350 elseif (fieldsize(1)==numberofvertices1+1) 351 md2.(model_fields{i})=[field(pos_node,:); field(end,:)]; 352 %size = number of elements * n 353 elseif fieldsize(1)==numberofelements1 354 md2.(model_fields{i})=field(pos_elem,:); 355 end 356 end 357 end 358 359 %modify some specific fields 360 361 %Mesh 362 md2.mesh.numberofelements=numberofelements2; 363 md2.mesh.numberofvertices=numberofvertices2; 364 md2.mesh.elements=elements_2; 365 366 %mesh.uppervertex mesh.lowervertex 367 if md1.mesh.dimension==3 368 md2.mesh.uppervertex=md1.mesh.uppervertex(pos_node); 369 pos=find(~isnan(md2.mesh.uppervertex)); 370 md2.mesh.uppervertex(pos)=Pnode(md2.mesh.uppervertex(pos)); 371 372 md2.mesh.lowervertex=md1.mesh.lowervertex(pos_node); 373 pos=find(~isnan(md2.mesh.lowervertex)); 374 md2.mesh.lowervertex(pos)=Pnode(md2.mesh.lowervertex(pos)); 375 376 md2.mesh.upperelements=md1.mesh.upperelements(pos_elem); 377 pos=find(~isnan(md2.mesh.upperelements)); 378 md2.mesh.upperelements(pos)=Pelem(md2.mesh.upperelements(pos)); 379 380 md2.mesh.lowerelements=md1.mesh.lowerelements(pos_elem); 381 pos=find(~isnan(md2.mesh.lowerelements)); 382 md2.mesh.lowerelements(pos)=Pelem(md2.mesh.lowerelements(pos)); 383 end 384 385 %Initial 2d mesh 386 if md1.mesh.dimension==3 387 flag_elem_2d=flag_elem(1:md1.mesh.numberofelements2d); 388 pos_elem_2d=find(flag_elem_2d); 389 flag_node_2d=flag_node(1:md1.mesh.numberofvertices2d); 390 pos_node_2d=find(flag_node_2d); 391 392 md2.mesh.numberofelements2d=length(pos_elem_2d); 393 md2.mesh.numberofvertices2d=length(pos_node_2d); 394 md2.mesh.elements2d=md1.mesh.elements2d(pos_elem_2d,:); 395 md2.mesh.elements2d(:,1)=Pnode(md2.mesh.elements2d(:,1)); 396 md2.mesh.elements2d(:,2)=Pnode(md2.mesh.elements2d(:,2)); 397 md2.mesh.elements2d(:,3)=Pnode(md2.mesh.elements2d(:,3)); 398 399 md2.mesh.x2d=md1.mesh.x(pos_node_2d); 400 md2.mesh.y2d=md1.mesh.y(pos_node_2d); 401 end 402 403 %Edges 404 if size(md2.mesh.edges,2)>1, %do not use ~isnan because there are some NaNs... 405 %renumber first two columns 406 pos=find(md2.mesh.edges(:,4)~=-1); 407 md2.mesh.edges(: ,1)=Pnode(md2.mesh.edges(:,1)); 408 md2.mesh.edges(: ,2)=Pnode(md2.mesh.edges(:,2)); 409 md2.mesh.edges(: ,3)=Pelem(md2.mesh.edges(:,3)); 410 md2.mesh.edges(pos,4)=Pelem(md2.mesh.edges(pos,4)); 411 %remove edges when the 2 vertices are not in the domain. 412 md2.mesh.edges=md2.mesh.edges(find(md2.mesh.edges(:,1) & md2.mesh.edges(:,2)),:); 413 %Replace all zeros by -1 in the last two columns 414 pos=find(md2.mesh.edges(:,3)==0); 415 md2.mesh.edges(pos,3)=-1; 416 pos=find(md2.mesh.edges(:,4)==0); 417 md2.mesh.edges(pos,4)=-1; 418 %Invert -1 on the third column with last column (Also invert first two columns!!) 419 pos=find(md2.mesh.edges(:,3)==-1); 420 md2.mesh.edges(pos,3)=md2.mesh.edges(pos,4); 421 md2.mesh.edges(pos,4)=-1; 422 values=md2.mesh.edges(pos,2); 423 md2.mesh.edges(pos,2)=md2.mesh.edges(pos,1); 424 md2.mesh.edges(pos,1)=values; 425 %Finally remove edges that do not belong to any element 426 pos=find(md2.mesh.edges(:,3)==-1 & md2.mesh.edges(:,4)==-1); 427 md2.mesh.edges(pos,:)=[]; 428 end 429 430 %Penalties 431 if ~isnan(md2.diagnostic.vertex_pairing), 432 for i=1:size(md1.diagnostic.vertex_pairing,1); 433 md2.diagnostic.vertex_pairing(i,:)=Pnode(md1.diagnostic.vertex_pairing(i,:)); 434 end 435 md2.diagnostic.vertex_pairing=md2.diagnostic.vertex_pairing(find(md2.diagnostic.vertex_pairing(:,1)),:); 436 end 437 if ~isnan(md2.prognostic.vertex_pairing), 438 for i=1:size(md1.prognostic.vertex_pairing,1); 439 md2.prognostic.vertex_pairing(i,:)=Pnode(md1.prognostic.vertex_pairing(i,:)); 440 end 441 md2.prognostic.vertex_pairing=md2.prognostic.vertex_pairing(find(md2.prognostic.vertex_pairing(:,1)),:); 442 end 443 444 %recreate segments 445 if md1.mesh.dimension==2 446 md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices); 447 md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity); 448 md2.mesh.segments=contourenvelope(md2); 449 md2.mesh.vertexonboundary=zeros(numberofvertices2,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2))=1; 450 else 451 %First do the connectivity for the contourenvelope in 2d 452 md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements2d,md2.mesh.numberofvertices2d); 453 md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements2d,md2.mesh.vertexconnectivity); 454 md2.mesh.segments=contourenvelope(md2); 455 md2.mesh.vertexonboundary=zeros(numberofvertices2/md2.mesh.numberoflayers,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2))=1; 456 md2.mesh.vertexonboundary=repmat(md2.mesh.vertexonboundary,md2.mesh.numberoflayers,1); 457 %Then do it for 3d as usual 458 md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices); 459 md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity); 460 end 461 462 %Boundary conditions: Dirichlets on new boundary 463 %Catch the elements that have not been extracted 464 orphans_elem=find(~flag_elem); 465 orphans_node=unique(md1.mesh.elements(orphans_elem,:))'; 466 %Figure out which node are on the boundary between md2 and md1 467 nodestoflag1=intersect(orphans_node,pos_node); 468 nodestoflag2=Pnode(nodestoflag1); 469 if numel(md1.diagnostic.spcvx)>1 & numel(md1.diagnostic.spcvy)>2 & numel(md1.diagnostic.spcvz)>2, 470 if numel(md1.inversion.vx_obs)>1 & numel(md1.inversion.vy_obs)>1 471 md2.diagnostic.spcvx(nodestoflag2)=md2.inversion.vx_obs(nodestoflag2); 472 md2.diagnostic.spcvy(nodestoflag2)=md2.inversion.vy_obs(nodestoflag2); 473 else 474 md2.diagnostic.spcvx(nodestoflag2)=NaN; 475 md2.diagnostic.spcvy(nodestoflag2)=NaN; 476 disp(' ') 477 disp('!! extract warning: spc values should be checked !!') 478 disp(' ') 479 end 480 %put 0 for vz 481 md2.diagnostic.spcvz(nodestoflag2)=0; 482 end 483 if ~isnan(md1.thermal.spctemperature), 484 md2.thermal.spctemperature(nodestoflag2,1)=1; 485 end 486 487 %Diagnostic 488 if ~isnan(md2.diagnostic.icefront) 489 md2.diagnostic.icefront(:,1)=Pnode(md1.diagnostic.icefront(:,1)); 490 md2.diagnostic.icefront(:,2)=Pnode(md1.diagnostic.icefront(:,2)); 491 md2.diagnostic.icefront(:,end-1)=Pelem(md1.diagnostic.icefront(:,end-1)); 492 if md1.mesh.dimension==3 493 md2.diagnostic.icefront(:,3)=Pnode(md1.diagnostic.icefront(:,3)); 494 md2.diagnostic.icefront(:,4)=Pnode(md1.diagnostic.icefront(:,4)); 495 end 496 md2.diagnostic.icefront=md2.diagnostic.icefront(find(md2.diagnostic.icefront(:,1) & md2.diagnostic.icefront(:,2) & md2.diagnostic.icefront(:,end)),:); 497 end 498 499 %Results fields 500 if isstruct(md1.results), 501 md2.results=struct(); 502 solutionfields=fields(md1.results); 503 for i=1:length(solutionfields), 504 %get subfields 505 solutionsubfields=fields(md1.results.(solutionfields{i})); 506 for j=1:length(solutionsubfields), 507 field=md1.results.(solutionfields{i}).(solutionsubfields{j}); 508 if length(field)==numberofvertices1, 509 md2.results.(solutionfields{i}).(solutionsubfields{j})=field(pos_node); 510 elseif length(field)==numberofelements1, 511 md2.results.(solutionfields{i}).(solutionsubfields{j})=field(pos_elem); 512 else 513 md2.results.(solutionfields{i}).(solutionsubfields{j})=field; 514 end 515 end 516 end 517 end 518 519 %Keep track of pos_node and pos_elem 520 md2.mesh.extractedvertices=pos_node; 521 md2.mesh.extractedelements=pos_elem; 522 end % }}} 523 function md = extrude(md,varargin) % {{{ 524 %EXTRUDE - vertically extrude a 2d mesh 525 % 526 % vertically extrude a 2d mesh and create corresponding 3d mesh. 527 % The vertical distribution can: 528 % - follow a polynomial law 529 % - follow two polynomial laws, one for the lower part and one for the upper part of the mesh 530 % - be discribed by a list of coefficients (between 0 and 1) 531 % 532 % 533 % Usage: 534 % md=extrude(md,numlayers,extrusionexponent); 535 % md=extrude(md,numlayers,lowerexponent,upperexponent); 536 % md=extrude(md,listofcoefficients); 537 % 538 % Example: 539 % md=extrude(md,8,3); 540 % md=extrude(md,8,3,2); 541 % md=extrude(md,[0 0.2 0.5 0.7 0.9 0.95 1]); 542 % 543 % See also: MODELEXTRACT, COLLAPSE 544 545 %some checks on list of arguments 546 if ((nargin>4) | (nargin<2) | (nargout~=1)), 547 help extrude; 548 error('extrude error message'); 549 end 550 551 %Extrude the mesh 552 if nargin==2, %list of coefficients 553 clist=varargin{1}; 554 if any(clist<0) | any(clist>1), 555 error('extrusioncoefficients must be between 0 and 1'); 556 end 557 extrusionlist=sort(unique([clist(:);0;1])); 558 numlayers=length(extrusionlist); 559 elseif nargin==3, %one polynomial law 560 if varargin{2}<=0, 561 help extrude; 562 error('extrusionexponent must be >=0'); 563 end 564 numlayers=varargin{1}; 565 extrusionlist=((0:1:numlayers-1)/(numlayers-1)).^varargin{2}; 566 elseif nargin==4, %two polynomial laws 567 numlayers=varargin{1}; 568 lowerexp=varargin{2}; 569 upperexp=varargin{3}; 570 571 if varargin{2}<=0 | varargin{3}<=0, 572 help extrude; 573 error('lower and upper extrusionexponents must be >=0'); 574 end 575 576 lowerextrusionlist=[(0:2/(numlayers-1):1).^lowerexp]/2; 577 upperextrusionlist=[(0:2/(numlayers-1):1).^upperexp]/2; 578 extrusionlist=sort(unique([lowerextrusionlist 1-upperextrusionlist])); 579 580 end 581 582 if numlayers<2, 583 error('number of layers should be at least 2'); 584 end 585 if md.mesh.dimension==3, 586 error('Cannot extrude a 3d mesh (extrude cannot be called more than once)'); 587 end 588 589 %Initialize with the 2d mesh 590 x3d=[]; 591 y3d=[]; 592 z3d=[]; %the lower node is on the bed 593 thickness3d=md.geometry.thickness; %thickness and bed for these nodes 594 bed3d=md.geometry.bed; 595 596 %Create the new layers 597 for i=1:numlayers, 598 x3d=[x3d; md.mesh.x]; 599 y3d=[y3d; md.mesh.y]; 600 %nodes are distributed between bed and surface accordingly to the given exponent 601 z3d=[z3d; bed3d+thickness3d*extrusionlist(i)]; 602 end 603 number_nodes3d=size(x3d,1); %number of 3d nodes for the non extruded part of the mesh 604 605 %Extrude elements 606 elements3d=[]; 607 for i=1:numlayers-1, 608 elements3d=[elements3d;[md.mesh.elements+(i-1)*md.mesh.numberofvertices md.mesh.elements+i*md.mesh.numberofvertices]]; %Create the elements of the 3d mesh for the non extruded part 609 end 610 number_el3d=size(elements3d,1); %number of 3d nodes for the non extruded part of the mesh 611 612 %Keep a trace of lower and upper nodes 613 mesh.lowervertex=NaN*ones(number_nodes3d,1); 614 mesh.uppervertex=NaN*ones(number_nodes3d,1); 615 mesh.lowervertex(md.mesh.numberofvertices+1:end)=1:(numlayers-1)*md.mesh.numberofvertices; 616 mesh.uppervertex(1:(numlayers-1)*md.mesh.numberofvertices)=md.mesh.numberofvertices+1:number_nodes3d; 617 md.mesh.lowervertex=mesh.lowervertex; 618 md.mesh.uppervertex=mesh.uppervertex; 619 620 %same for lower and upper elements 621 mesh.lowerelements=NaN*ones(number_el3d,1); 622 mesh.upperelements=NaN*ones(number_el3d,1); 623 mesh.lowerelements(md.mesh.numberofelements+1:end)=1:(numlayers-2)*md.mesh.numberofelements; 624 mesh.upperelements(1:(numlayers-2)*md.mesh.numberofelements)=md.mesh.numberofelements+1:(numlayers-1)*md.mesh.numberofelements; 625 md.mesh.lowerelements=mesh.lowerelements; 626 md.mesh.upperelements=mesh.upperelements; 627 628 %Save old mesh 629 md.mesh.x2d=md.mesh.x; 630 md.mesh.y2d=md.mesh.y; 631 md.mesh.elements2d=md.mesh.elements; 632 md.mesh.numberofelements2d=md.mesh.numberofelements; 633 md.mesh.numberofvertices2d=md.mesh.numberofvertices; 634 635 %Update mesh type 636 md.mesh.dimension=3; 637 638 %Build global 3d mesh 639 md.mesh.elements=elements3d; 640 md.mesh.x=x3d; 641 md.mesh.y=y3d; 642 md.mesh.z=z3d; 643 md.mesh.numberofelements=number_el3d; 644 md.mesh.numberofvertices=number_nodes3d; 645 md.mesh.numberoflayers=numlayers; 646 647 %Ok, now deal with the other fields from the 2d mesh: 648 649 %lat long 650 md.mesh.lat=project3d(md,'vector',md.mesh.lat,'type','node'); 651 md.mesh.long=project3d(md,'vector',md.mesh.long,'type','node'); 652 653 %drag coefficient is limited to nodes that are on the bedrock. 654 md.friction.coefficient=project3d(md,'vector',md.friction.coefficient,'type','node','layer',1); 655 656 %p and q (same deal, except for element that are on the bedrock: ) 657 md.friction.p=project3d(md,'vector',md.friction.p,'type','element'); 658 md.friction.q=project3d(md,'vector',md.friction.q,'type','element'); 659 660 %observations 661 md.inversion.vx_obs=project3d(md,'vector',md.inversion.vx_obs,'type','node'); 662 md.inversion.vy_obs=project3d(md,'vector',md.inversion.vy_obs,'type','node'); 663 md.inversion.vel_obs=project3d(md,'vector',md.inversion.vel_obs,'type','node'); 664 md.surfaceforcings.mass_balance=project3d(md,'vector',md.surfaceforcings.mass_balance,'type','node'); 665 md.surfaceforcings.precipitation=project3d(md,'vector',md.surfaceforcings.precipitation,'type','node'); 666 md.balancethickness.thickening_rate=project3d(md,'vector',md.balancethickness.thickening_rate,'type','node'); 667 md.surfaceforcings.monthlytemperatures=project3d(md,'vector',md.surfaceforcings.monthlytemperatures,'type','node'); 668 669 %results 670 if ~isnan(md.initialization.vx),md.initialization.vx=project3d(md,'vector',md.initialization.vx,'type','node');end; 671 if ~isnan(md.initialization.vy),md.initialization.vy=project3d(md,'vector',md.initialization.vy,'type','node');end; 672 if ~isnan(md.initialization.vz),md.initialization.vz=project3d(md,'vector',md.initialization.vz,'type','node');end; 673 if ~isnan(md.initialization.vel),md.initialization.vel=project3d(md,'vector',md.initialization.vel,'type','node');end; 674 if ~isnan(md.initialization.temperature),md.initialization.temperature=project3d(md,'vector',md.initialization.temperature,'type','node');end; 675 if ~isnan(md.initialization.waterfraction),md.initialization.waterfraction=project3d(md,'vector',md.initialization.waterfraction,'type','node');end; 676 677 %bedinfo and surface info 678 md.mesh.elementonbed=project3d(md,'vector',ones(md.mesh.numberofelements2d,1),'type','element','layer',1); 679 md.mesh.elementonsurface=project3d(md,'vector',ones(md.mesh.numberofelements2d,1),'type','element','layer',md.mesh.numberoflayers-1); 680 md.mesh.vertexonbed=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',1); 681 md.mesh.vertexonsurface=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',md.mesh.numberoflayers); 682 683 %elementstype 684 if ~isnan(md.flowequation.element_equation) 685 oldelements_type=md.flowequation.element_equation; 686 md.flowequation.element_equation=zeros(number_el3d,1); 687 md.flowequation.element_equation=project3d(md,'vector',oldelements_type,'type','element'); 688 end 689 690 %verticestype 691 if ~isnan(md.flowequation.vertex_equation) 692 oldvertices_type=md.flowequation.vertex_equation; 693 md.flowequation.vertex_equation=zeros(number_nodes3d,1); 694 md.flowequation.vertex_equation=project3d(md,'vector',oldvertices_type,'type','node'); 695 end 696 md.flowequation.bordermacayeal=project3d(md,'vector',md.flowequation.bordermacayeal,'type','node'); 697 md.flowequation.borderpattyn=project3d(md,'vector',md.flowequation.borderpattyn,'type','node'); 698 md.flowequation.borderstokes=project3d(md,'vector',md.flowequation.borderstokes,'type','node'); 699 700 %boundary conditions 701 md.diagnostic.spcvx=project3d(md,'vector',md.diagnostic.spcvx,'type','node'); 702 md.diagnostic.spcvy=project3d(md,'vector',md.diagnostic.spcvy,'type','node'); 703 md.diagnostic.spcvz=project3d(md,'vector',md.diagnostic.spcvz,'type','node'); 704 md.thermal.spctemperature=project3d(md,'vector',md.thermal.spctemperature,'type','node','layer',md.mesh.numberoflayers,'padding',NaN); 705 md.prognostic.spcthickness=project3d(md,'vector',md.prognostic.spcthickness,'type','node'); 706 md.balancethickness.spcthickness=project3d(md,'vector',md.balancethickness.spcthickness,'type','node'); 707 md.diagnostic.referential=project3d(md,'vector',md.diagnostic.referential,'type','node'); 708 709 %in 3d, pressureload: [node1 node2 node3 node4 element] 710 pressureload_layer1=[md.diagnostic.icefront(:,1:2) md.diagnostic.icefront(:,2)+md.mesh.numberofvertices2d md.diagnostic.icefront(:,1)+md.mesh.numberofvertices2d md.diagnostic.icefront(:,3:4)]; %Add two columns on the first layer 711 pressureload=[]; 712 for i=1:numlayers-1, 713 pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d pressureload_layer1(:,6)]; 714 end 715 md.diagnostic.icefront=pressureload; 716 717 %connectivity 718 md.mesh.elementconnectivity=repmat(md.mesh.elementconnectivity,numlayers-1,1); 719 md.mesh.elementconnectivity(find(md.mesh.elementconnectivity==0))=NaN; 720 for i=2:numlayers-1, 721 md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)... 722 =md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)+md.mesh.numberofelements2d; 723 end 724 md.mesh.elementconnectivity(find(isnan(md.mesh.elementconnectivity)))=0; 725 726 %materials 727 md.materials.rheology_B=project3d(md,'vector',md.materials.rheology_B,'type','node'); 728 md.materials.rheology_n=project3d(md,'vector',md.materials.rheology_n,'type','element'); 729 if isa(md.materials,'matdamageice') 730 md.materials.rheology_Z=project3d(md,'vector',md.materials.rheology_Z,'type','node'); 731 end 732 733 %parameters 734 md.geometry.surface=project3d(md,'vector',md.geometry.surface,'type','node'); 735 md.geometry.thickness=project3d(md,'vector',md.geometry.thickness,'type','node'); 736 md.geometry.hydrostatic_ratio=project3d(md,'vector',md.geometry.hydrostatic_ratio,'type','node'); 737 md.geometry.bed=project3d(md,'vector',md.geometry.bed,'type','node'); 738 md.geometry.bathymetry=project3d(md,'vector',md.geometry.bathymetry,'type','node'); 739 md.mesh.vertexonboundary=project3d(md,'vector',md.mesh.vertexonboundary,'type','node'); 740 md.mask.elementonfloatingice=project3d(md,'vector',md.mask.elementonfloatingice,'type','element'); 741 md.mask.vertexonfloatingice=project3d(md,'vector',md.mask.vertexonfloatingice,'type','node'); 742 md.mask.elementongroundedice=project3d(md,'vector',md.mask.elementongroundedice,'type','element'); 743 md.mask.vertexongroundedice=project3d(md,'vector',md.mask.vertexongroundedice,'type','node'); 744 md.mask.elementonwater=project3d(md,'vector',md.mask.elementonwater,'type','element'); 745 md.mask.vertexonwater=project3d(md,'vector',md.mask.vertexonwater,'type','node'); 746 if ~isnan(md.inversion.cost_functions_coefficients),md.inversion.cost_functions_coefficients=project3d(md,'vector',md.inversion.cost_functions_coefficients,'type','node');end; 747 if ~isnan(md.inversion.min_parameters),md.inversion.min_parameters=project3d(md,'vector',md.inversion.min_parameters,'type','node');end; 748 if ~isnan(md.inversion.max_parameters),md.inversion.max_parameters=project3d(md,'vector',md.inversion.max_parameters,'type','node');end; 749 if ~isnan(md.qmu.partition),md.qmu.partition=project3d(md,'vector',md.qmu.partition','type','node');end 750 if(md.surfaceforcings.isdelta18o),md.surfaceforcings.temperatures_lgm=project3d(md,'vector',md.surfaceforcings.temperatures_lgm,'type','node');end 751 if(md.surfaceforcings.isdelta18o),md.surfaceforcings.temperatures_presentday=project3d(md,'vector',md.surfaceforcings.temperatures_presentday,'type','node');end 752 if(md.surfaceforcings.isdelta18o),md.surfaceforcings.precipitations_presentday=project3d(md,'vector',md.surfaceforcings.precipitations_presentday,'type','node');end 753 754 %Put lithostatic pressure if there is an existing pressure 755 if ~isnan(md.initialization.pressure), 756 md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z); 757 end 758 759 %special for thermal modeling: 760 md.basalforcings.melting_rate=project3d(md,'vector',md.basalforcings.melting_rate,'type','node','layer',1); 761 if ~isnan(md.basalforcings.geothermalflux) 762 md.basalforcings.geothermalflux=project3d(md,'vector',md.basalforcings.geothermalflux,'type','node','layer',1); %bedrock only gets geothermal flux 763 end 764 765 %increase connectivity if less than 25: 766 if md.mesh.average_vertex_connectivity<=25, 767 md.mesh.average_vertex_connectivity=100; 768 end 772 769 end % }}} 773 function md = structtomodel(md,structmd) % {{{ 774 775 if ~isstruct(structmd) error('input model is not a structure'); end 776 777 %loaded model is a struct, initialize output and recover all fields 778 md = structtoobj(model,structmd); 779 780 %Old field now classes 781 if (isfield(structmd,'timestepping') & isnumeric(md.timestepping)), md.timestepping=timestepping(); end 782 if (isfield(structmd,'mask') & isnumeric(md.mask)),md.mask=mask(); end 783 784 %Field name change 785 if isfield(structmd,'drag'), md.friction.coefficient=structmd.drag; end 786 if isfield(structmd,'p'), md.friction.p=structmd.p; end 787 if isfield(structmd,'q'), md.friction.q=structmd.p; end 788 if isfield(structmd,'melting'), md.basalforcings.melting_rate=structmd.melting; end 789 if isfield(structmd,'melting_rate'), md.basalforcings.melting_rate=structmd.melting_rate; end 790 if isfield(structmd,'accumulation'), md.surfaceforcings.mass_balance=structmd.accumulation; end 791 if isfield(structmd,'numberofgrids'), md.mesh.numberofvertices=structmd.numberofgrids; end 792 if isfield(structmd,'numberofgrids2d'), md.mesh.numberofvertices2d=structmd.numberofgrids2d; end 793 if isfield(structmd,'uppergrids'), md.mesh.uppervertex=structmd.uppergrids; end 794 if isfield(structmd,'lowergrids'), md.mesh.lowervertex=structmd.lowergrids; end 795 if isfield(structmd,'gridonbed'), md.mesh.vertexonbed=structmd.gridonbed; end 796 if isfield(structmd,'gridonsurface'), md.mesh.vertexonsurface=structmd.gridonsurface; end 797 if isfield(structmd,'extractedgrids'), md.mesh.extractedvertices=structmd.extractedgrids; end 798 if isfield(structmd,'gridoniceshelf'), md.mask.vertexonfloatingice=structmd.gridoniceshelf; end 799 if isfield(structmd,'gridonicesheet'), md.mask.vertexongroundedice=structmd.gridonicesheet; end 800 if isfield(structmd,'gridonwater'), md.mask.vertexonwater=structmd.gridonwater; end 801 if isfield(structmd,'gridonboundary'), md.mesh.vertexonboundary=structmd.gridonboundary; end 802 if isfield(structmd,'petscoptions') & ~isempty(structmd.petscoptions), md.solver=structmd.petscoptions; end 803 if isfield(structmd,'g'), md.constants.g=structmd.g; end 804 if isfield(structmd,'yts'), md.constants.yts=structmd.yts; end 805 if isfield(structmd,'surface_mass_balance'), md.surfaceforcings.mass_balance=structmd.surface_mass_balance; end 806 if isfield(structmd,'basal_melting_rate'), md.basalforcings.melting_rate=structmd.basal_melting_rate; end 807 if isfield(structmd,'basal_melting_rate_correction'), md.basalforcings.melting_rate_correction=structmd.basal_melting_rate_correction; end 808 if isfield(structmd,'geothermalflux'), md.basalforcings.geothermalflux=structmd.geothermalflux; end 809 if isfield(structmd,'drag'), md.friction.coefficient=structmd.drag; end 810 if isfield(structmd,'drag_coefficient'), md.friction.coefficient=structmd.drag_coefficient; end 811 if isfield(structmd,'drag_p'), md.friction.p=structmd.drag_p; end 812 if isfield(structmd,'drag_q'), md.friction.q=structmd.drag_q; end 813 if isfield(structmd,'riftproperties'), %old implementation 814 md.rifts=rifts(); 815 md.rifts.riftproperties=structmd.riftproperties; 816 md.rifts.riftstruct=structmd.rifts; 817 md.rifts.riftproperties=structmd.riftinfo; 818 end 819 if isfield(structmd,'bamg'), md.private.bamg=structmd.bamg; end 820 if isfield(structmd,'lowmem'), md.settings.lowmem=structmd.lowmem; end 821 if isfield(structmd,'io_gather'), md.settings.io_gather=structmd.io_gather; end 822 if isfield(structmd,'spcwatercolumn'), md.hydrology.spcwatercolumn=structmd.spcwatercolumn; end 823 if isfield(structmd,'hydro_n'), md.hydrology.n=structmd.hydro_n; end 824 if isfield(structmd,'hydro_p'), md.hydrology.p=structmd.hydro_p; end 825 if isfield(structmd,'hydro_q'), md.hydrology.q=structmd.hydro_q; end 826 if isfield(structmd,'hydro_CR'), md.hydrology.CR=structmd.hydro_CR; end 827 if isfield(structmd,'hydro_kn'), md.hydrology.kn=structmd.hydro_kn; end 828 if isfield(structmd,'spctemperature'), md.thermal.spctemperature=structmd.spctemperature; end 829 if isfield(structmd,'min_thermal_constraints'), md.thermal.penalty_threshold=structmd.min_thermal_constraints; end 830 if isfield(structmd,'artificial_diffusivity'), md.thermal.stabilization=structmd.artificial_diffusivity; end 831 if isfield(structmd,'max_nonlinear_iterations'), md.thermal.maxiter=structmd.max_nonlinear_iterations; end 832 if isfield(structmd,'stabilize_constraints'), md.thermal.penalty_lock=structmd.stabilize_constraints; end 833 if isfield(structmd,'penalty_offset'), md.thermal.penalty_factor=structmd.penalty_offset; end 834 if isfield(structmd,'name'), md.miscellaneous.name=structmd.name; end 835 if isfield(structmd,'notes'), md.miscellaneous.notes=structmd.notes; end 836 if isfield(structmd,'dummy'), md.miscellaneous.dummy=structmd.dummy; end 837 if isfield(structmd,'dt'), md.timestepping.time_step=structmd.dt; end 838 if isfield(structmd,'ndt'), md.timestepping.final_time=structmd.ndt; end 839 if isfield(structmd,'time_adapt'), md.timestepping.time_adapt=structmd.time_adapt; end 840 if isfield(structmd,'cfl_coefficient'), md.timestepping.cfl_coefficient=structmd.cfl_coefficient; end 841 if isfield(structmd,'spcthickness'), md.prognostic.spcthickness=structmd.spcthickness; end 842 if isfield(structmd,'artificial_diffusivity'), md.prognostic.stabilization=structmd.artificial_diffusivity; end 843 if isfield(structmd,'hydrostatic_adjustment'), md.prognostic.hydrostatic_adjustment=structmd.hydrostatic_adjustment; end 844 if isfield(structmd,'penalties'), md.prognostic.vertex_pairing=structmd.penalties; end 845 if isfield(structmd,'penalty_offset'), md.prognostic.penalty_factor=structmd.penalty_offset; end 846 if isfield(structmd,'B'), md.materials.rheology_B=structmd.B; end 847 if isfield(structmd,'n'), md.materials.rheology_n=structmd.n; end 848 if isfield(structmd,'rheology_B'), md.materials.rheology_B=structmd.rheology_B; end 849 if isfield(structmd,'rheology_n'), md.materials.rheology_n=structmd.rheology_n; end 850 if isfield(structmd,'elementoniceshelf'), md.mask.elementonfloatingice=structmd.elementoniceshelf; end 851 if isfield(structmd,'elementonicesheet'), md.mask.elementongroundedice=structmd.elementonicesheet; end 852 if isfield(structmd,'elementonwater'), md.mask.elementonwater=structmd.elementonwater; end 853 if isfield(structmd,'nodeoniceshelf'), md.mask.vertexonfloatingice=structmd.nodeoniceshelf; end 854 if isfield(structmd,'nodeonicesheet'), md.mask.vertexongroundedice=structmd.nodeonicesheet; end 855 if isfield(structmd,'nodeonwater'), md.mask.vertexonwater=structmd.nodeonwater; end 856 if isfield(structmd,'spcthickness'), md.balancethickness.spcthickness=structmd.spcthickness; end 857 if isfield(structmd,'artificial_diffusivity'), md.balancethickness.stabilization=structmd.artificial_diffusivity; end 858 if isfield(structmd,'dhdt'), md.balancethickness.thickening_rate=structmd.dhdt; end 859 if isfield(structmd,'ismacayealpattyn'), md.flowequation.ismacayealpattyn=structmd.ismacayealpattyn; end 860 if isfield(structmd,'ishutter'), md.flowequation.ishutter=structmd.ishutter; end 861 if isfield(structmd,'isstokes'), md.flowequation.isstokes=structmd.isstokes; end 862 if isfield(structmd,'elements_type'), md.flowequation.element_equation=structmd.elements_type; end 863 if isfield(structmd,'vertices_type'), md.flowequation.vertex_equation=structmd.vertices_type; end 864 if isfield(structmd,'eps_rel'), md.steadystate.reltol=structmd.eps_rel; end 865 if isfield(structmd,'max_steadystate_iterations'), md.steadystate.maxiter=structmd.max_steadystate_iterations; end 866 if isfield(structmd,'isdiagnostic'), md.transient.isdiagnostic=structmd.isdiagnostic; end 867 if isfield(structmd,'isprognostic'), md.transient.isprognostic=structmd.isprognostic; end 868 if isfield(structmd,'isthermal'), md.transient.isthermal=structmd.isthermal; end 869 if isfield(structmd,'control_analysis'), md.inversion.iscontrol=structmd.control_analysis; end 870 if isfield(structmd,'weights'), md.inversion.cost_functions_coefficients=structmd.weights; end 871 if isfield(structmd,'nsteps'), md.inversion.nsteps=structmd.nsteps; end 872 if isfield(structmd,'maxiter_per_step'), md.inversion.maxiter_per_step=structmd.maxiter_per_step; end 873 if isfield(structmd,'cm_min'), md.inversion.min_parameters=structmd.cm_min; end 874 if isfield(structmd,'cm_max'), md.inversion.max_parameters=structmd.cm_max; end 875 if isfield(structmd,'vx_obs'), md.inversion.vx_obs=structmd.vx_obs; end 876 if isfield(structmd,'vy_obs'), md.inversion.vy_obs=structmd.vy_obs; end 877 if isfield(structmd,'vel_obs'), md.inversion.vel_obs=structmd.vel_obs; end 878 if isfield(structmd,'thickness_obs'), md.inversion.thickness_obs=structmd.thickness_obs; end 879 if isfield(structmd,'vx'), md.initialization.vx=structmd.vx; end 880 if isfield(structmd,'vy'), md.initialization.vy=structmd.vy; end 881 if isfield(structmd,'vz'), md.initialization.vz=structmd.vz; end 882 if isfield(structmd,'vel'), md.initialization.vel=structmd.vel; end 883 if isfield(structmd,'pressure'), md.initialization.pressure=structmd.pressure; end 884 if isfield(structmd,'temperature'), md.initialization.temperature=structmd.temperature; end 885 if isfield(structmd,'waterfraction'), md.initialization.waterfraction=structmd.waterfraction; end 886 if isfield(structmd,'watercolumn'), md.initialization.watercolumn=structmd.watercolumn; end 887 if isfield(structmd,'surface'), md.geometry.surface=structmd.surface; end 888 if isfield(structmd,'bed'), md.geometry.bed=structmd.bed; end 889 if isfield(structmd,'thickness'), md.geometry.thickness=structmd.thickness; end 890 if isfield(structmd,'bathymetry'), md.geometry.bathymetry=structmd.bathymetry; end 891 if isfield(structmd,'thickness_coeff'), md.geometry.hydrostatic_ratio=structmd.thickness_coeff; end 892 if isfield(structmd,'connectivity'), md.mesh.average_vertex_connectivity=structmd.connectivity; end 893 if isfield(structmd,'extractednodes'), md.mesh.extractedvertices=structmd.extractednodes; end 894 if isfield(structmd,'extractedelements'), md.mesh.extractedelements=structmd.extractedelements; end 895 if isfield(structmd,'nodeonboundary'), md.mesh.vertexonboundary=structmd.nodeonboundary; end 896 if isfield(structmd,'hemisphere'), md.mesh.hemisphere=structmd.hemisphere; end 897 if isfield(structmd,'lat'), md.mesh.lat=structmd.lat; end 898 if isfield(structmd,'long'), md.mesh.long=structmd.long; end 899 if isfield(structmd,'segments'), md.mesh.segments=structmd.segments; end 900 if isfield(structmd,'segmentmarkers'), md.mesh.segmentmarkers=structmd.segmentmarkers; end 901 if isfield(structmd,'dim'), md.mesh.dimension=structmd.dim; end 902 if isfield(structmd,'numlayers'), md.mesh.numberoflayers=structmd.numlayers; end 903 if isfield(structmd,'numberofelements'), md.mesh.numberofelements=structmd.numberofelements; end 904 if isfield(structmd,'numberofvertices'), md.mesh.numberofvertices=structmd.numberofvertices; end 905 if isfield(structmd,'numberofnodes'), md.mesh.numberofvertices=structmd.numberofnodes; end 906 if isfield(structmd,'numberofedges'), md.mesh.numberofedges=structmd.numberofedges; end 907 if isfield(structmd,'numberofelements2d'), md.mesh.numberofelements2d=structmd.numberofelements2d; end 908 if isfield(structmd,'numberofnodes2d'), md.mesh.numberofvertices2d=structmd.numberofnodes2d; end 909 if isfield(structmd,'nodeconnectivity'), md.mesh.vertexconnectivity=structmd.nodeconnectivity; end 910 if isfield(structmd,'elementconnectivity'), md.mesh.elementconnectivity=structmd.elementconnectivity; end 911 if isfield(structmd,'uppernodes'), md.mesh.uppervertex=structmd.uppernodes; end 912 if isfield(structmd,'lowernodes'), md.mesh.lowervertex=structmd.lowernodes; end 913 if isfield(structmd,'upperelements'), md.mesh.upperelements=structmd.upperelements; end 914 if isfield(structmd,'lowerelements'), md.mesh.lowerelements=structmd.lowerelements; end 915 if isfield(structmd,'elementonbed'), md.mesh.elementonbed=structmd.elementonbed; end 916 if isfield(structmd,'elementonsurface'), md.mesh.elementonsurface=structmd.elementonsurface; end 917 if isfield(structmd,'nodeonsurface'), md.mesh.vertexonsurface=structmd.nodeonsurface; end 918 if isfield(structmd,'nodeonbed'), md.mesh.vertexonbed=structmd.nodeonbed; end 919 if isfield(structmd,'elements2d'), md.mesh.elements2d=structmd.elements2d; end 920 if isfield(structmd,'y2d'), md.mesh.y2d=structmd.y2d; end 921 if isfield(structmd,'x2d'), md.mesh.x2d=structmd.x2d; end 922 if isfield(structmd,'elements'), md.mesh.elements=structmd.elements; end 923 if isfield(structmd,'edges'), md.mesh.edges=structmd.edges; end 924 if isfield(structmd,'y'), md.mesh.y=structmd.y; end 925 if isfield(structmd,'x'), md.mesh.x=structmd.x; end 926 if isfield(structmd,'z'), md.mesh.z=structmd.z; end 927 if isfield(structmd,'mask'), md.flaim.criterion=structmd.mask; end 928 if isfield(structmd,'pressureload'), md.diagnostic.icefront=structmd.pressureload; end 929 if isfield(structmd,'diagnostic_ref'), md.diagnostic.referential=structmd.diagnostic_ref; end 930 if isfield(structmd,'npart'); md.qmu.numberofpartitions=structmd.npart; end 931 if isfield(structmd,'part'); md.qmu.partition=structmd.part; end 932 933 %Field changes 934 if (isfield(structmd,'type') & ischar(structmd.type)), 935 if strcmpi(structmd.type,'2d'), md.mesh.dimension=2; end 936 if strcmpi(structmd.type,'3d'), md.mesh.dimension=3; end 937 end 938 if isnumeric(md.verbose), 939 md.verbose=verbose; 940 end 941 if size(md.diagnostic.icefront,2)==3 || size(md.diagnostic.icefront,2)==5, 942 front=md.diagnostic.icefront; 943 md.diagnostic.icefront=[front 1*md.mask.elementonfloatingice(front(:,end))]; 944 end 945 if isfield(structmd,'spcvelocity'), 946 md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1); 947 md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1); 948 md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1); 949 pos=find(structmd.spcvelocity(:,1)); md.diagnostic.spcvx(pos)=structmd.spcvelocity(pos,4); 950 pos=find(structmd.spcvelocity(:,2)); md.diagnostic.spcvy(pos)=structmd.spcvelocity(pos,5); 951 pos=find(structmd.spcvelocity(:,3)); md.diagnostic.spcvz(pos)=structmd.spcvelocity(pos,6); 952 end 953 if isfield(structmd,'spcvx'), 954 md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1); 955 pos=find(~isnan(structmd.spcvx)); md.diagnostic.spcvx(pos)=structmd.spcvx(pos); 956 end 957 if isfield(structmd,'spcvy'), 958 md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1); 959 pos=find(~isnan(structmd.spcvy)); md.diagnostic.spcvy(pos)=structmd.spcvy(pos); 960 end 961 if isfield(structmd,'spcvz'), 962 md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1); 963 pos=find(~isnan(structmd.spcvz)); md.diagnostic.spcvz(pos)=structmd.spcvz(pos); 964 end 965 if ~isempty(structmd.pressureload) & ismember(structmd.pressureload(end,end),[118 119 120]), 966 pos=find(structmd.pressureload(:,end)==120); md.diagnostic.icefront(pos,end)=0; 967 pos=find(structmd.pressureload(:,end)==118); md.diagnostic.icefront(pos,end)=1; 968 pos=find(structmd.pressureload(:,end)==119); md.diagnostic.icefront(pos,end)=2; 969 end 970 if isfield(structmd,'elements_type') & structmd.elements_type(end,end)>50, 971 pos=find(structmd.elements_type==59); md.flowequation.element_equation(pos,end)=0; 972 pos=find(structmd.elements_type==55); md.flowequation.element_equation(pos,end)=1; 973 pos=find(structmd.elements_type==56); md.flowequation.element_equation(pos,end)=2; 974 pos=find(structmd.elements_type==60); md.flowequation.element_equation(pos,end)=3; 975 pos=find(structmd.elements_type==62); md.flowequation.element_equation(pos,end)=4; 976 pos=find(structmd.elements_type==57); md.flowequation.element_equation(pos,end)=5; 977 pos=find(structmd.elements_type==58); md.flowequation.element_equation(pos,end)=6; 978 pos=find(structmd.elements_type==61); md.flowequation.element_equation(pos,end)=7; 979 end 980 if isfield(structmd,'vertices_type') & structmd.vertices_type(end,end)>50, 981 pos=find(structmd.vertices_type==59); md.flowequation.vertex_equation(pos,end)=0; 982 pos=find(structmd.vertices_type==55); md.flowequation.vertex_equation(pos,end)=1; 983 pos=find(structmd.vertices_type==56); md.flowequation.vertex_equation(pos,end)=2; 984 pos=find(structmd.vertices_type==60); md.flowequation.vertex_equation(pos,end)=3; 985 pos=find(structmd.vertices_type==62); md.flowequation.vertex_equation(pos,end)=4; 986 pos=find(structmd.vertices_type==57); md.flowequation.vertex_equation(pos,end)=5; 987 pos=find(structmd.vertices_type==58); md.flowequation.vertex_equation(pos,end)=6; 988 pos=find(structmd.vertices_type==61); md.flowequation.vertex_equation(pos,end)=7; 989 end 990 if isfield(structmd,'rheology_law') & isnumeric(structmd.rheology_law), 991 if (structmd.rheology_law==272), md.materials.rheology_law='None'; end 992 if (structmd.rheology_law==368), md.materials.rheology_law='Paterson'; end 993 if (structmd.rheology_law==369), md.materials.rheology_law='Arrhenius'; end 994 end 995 if isfield(structmd,'groundingline_migration') & isnumeric(structmd.groundingline_migration), 996 if (structmd.groundingline_migration==272), md.groundingline.migration='None'; end 997 if (structmd.groundingline_migration==273), md.groundingline.migration='AgressiveMigration'; end 998 if (structmd.groundingline_migration==274), md.groundingline.migration='SoftMigration'; end 999 end 1000 if isfield(structmd,'control_type') & isnumeric(structmd.control_type), 1001 if (structmd.control_type==143), md.inversion.control_parameters={'FrictionCoefficient'}; end 1002 if (structmd.control_type==190), md.inversion.control_parameters={'RheologyBbar'}; end 1003 if (structmd.control_type==147), md.inversion.control_parameters={'Thickeningrate'}; end 1004 end 1005 if isfield(structmd,'cm_responses') & ismember(structmd.cm_responses(end,end),[165:170 383 388 389]), 1006 pos=find(structmd.cm_responses==166); md.inversion.cost_functions(pos)=101; 1007 pos=find(structmd.cm_responses==167); md.inversion.cost_functions(pos)=102; 1008 pos=find(structmd.cm_responses==168); md.inversion.cost_functions(pos)=103; 1009 pos=find(structmd.cm_responses==169); md.inversion.cost_functions(pos)=104; 1010 pos=find(structmd.cm_responses==170); md.inversion.cost_functions(pos)=105; 1011 pos=find(structmd.cm_responses==165); md.inversion.cost_functions(pos)=201; 1012 pos=find(structmd.cm_responses==389); md.inversion.cost_functions(pos)=501; 1013 pos=find(structmd.cm_responses==388); md.inversion.cost_functions(pos)=502; 1014 pos=find(structmd.cm_responses==382); md.inversion.cost_functions(pos)=503; 1015 end 1016 1017 if isfield(structmd,'artificial_diffusivity') & structmd.artificial_diffusivity==2, 1018 md.thermal.stabilization=2; 1019 md.prognostic.stabilization=1; 1020 md.balancethickness.stabilization=1; 1021 end 1022 if isnumeric(md.prognostic.hydrostatic_adjustment) 1023 if md.prognostic.hydrostatic_adjustment==269, 1024 md.prognostic.hydrostatic_adjustment='Incremental'; 1025 else 1026 md.prognostic.hydrostatic_adjustment='Absolute'; 1027 end 1028 end 1029 1030 %New fields 1031 if ~isfield(structmd,'upperelements'); 1032 md.mesh.upperelements=transpose(1:md.mesh.numberofelements)+md.mesh.numberofelements2d; 1033 md.mesh.upperelements(end-md.mesh.numberofelements2d+1:end)=NaN; 1034 end 1035 if ~isfield(structmd,'lowerelements'); 1036 md.mesh.lowerelements=transpose(1:md.mesh.numberofelements)-md.mesh.numberofelements2d; 1037 md.mesh.lowerelements(1:md.mesh.numberofelements2d)=NaN; 1038 end 1039 1040 if ~isfield(structmd,'diagnostic_ref'); 1041 md.diagnostic.referential=NaN*ones(md.mesh.numberofvertices,6); 1042 end 1043 1044 end% }}} 1045 function md = setdefaultparameters(md) % {{{ 1046 1047 %initialize subclasses 1048 md.mesh = mesh(); 1049 md.mask = mask(); 1050 md.constants = constants(); 1051 md.geometry = geometry(); 1052 md.initialization = initialization(); 1053 md.surfaceforcings = surfaceforcings(); 1054 md.basalforcings = basalforcings(); 1055 md.friction = friction(); 1056 md.rifts = rifts(); 1057 md.timestepping = timestepping(); 1058 md.groundingline = groundingline(); 1059 md.materials = matice(); 1060 md.flowequation = flowequation(); 1061 md.debug = debug(); 1062 md.verbose = verbose('solution',true,'qmu',true,'control',true); 1063 md.settings = settings(); 1064 md.solver = solver(); 1065 if ismumps(), 1066 md.solver = addoptions(md.solver,DiagnosticVertAnalysisEnum(),mumpsoptions()); 1067 else 1068 md.solver = addoptions(md.solver,DiagnosticVertAnalysisEnum(),iluasmoptions()); 1069 end 1070 md.cluster = generic(); 1071 md.balancethickness = balancethickness(); 1072 md.diagnostic = diagnostic(); 1073 md.hydrology = hydrology(); 1074 md.prognostic = prognostic(); 1075 md.thermal = thermal(); 1076 md.steadystate = steadystate(); 1077 md.transient = transient(); 1078 md.autodiff = autodiff(); 1079 md.flaim = flaim(); 1080 md.inversion = inversion(); 1081 md.qmu = qmu(); 1082 md.radaroverlay = radaroverlay(); 1083 md.results = struct(); 1084 md.miscellaneous = miscellaneous(); 1085 md.private = private(); 1086 end 1087 %}}} 1088 function disp(obj) % {{{ 1089 disp(sprintf('%19s: %-22s -- %s','mesh' ,['[1x1 ' class(obj.mesh) ']'],'mesh properties')); 1090 disp(sprintf('%19s: %-22s -- %s','mask' ,['[1x1 ' class(obj.mask) ']'],'defines grounded and floating elements')); 1091 disp(sprintf('%19s: %-22s -- %s','geometry' ,['[1x1 ' class(obj.geometry) ']'],'surface elevation, bedrock topography, ice thickness,...')); 1092 disp(sprintf('%19s: %-22s -- %s','constants' ,['[1x1 ' class(obj.constants) ']'],'physical constants')); 1093 disp(sprintf('%19s: %-22s -- %s','surfaceforcings' ,['[1x1 ' class(obj.surfaceforcings) ']'],'surface forcings')); 1094 disp(sprintf('%19s: %-22s -- %s','basalforcings' ,['[1x1 ' class(obj.basalforcings) ']'],'bed forcings')); 1095 disp(sprintf('%19s: %-22s -- %s','materials' ,['[1x1 ' class(obj.materials) ']'],'material properties')); 1096 disp(sprintf('%19s: %-22s -- %s','friction' ,['[1x1 ' class(obj.friction) ']'],'basal friction/drag properties')); 1097 disp(sprintf('%19s: %-22s -- %s','flowequation' ,['[1x1 ' class(obj.flowequation) ']'],'flow equations')); 1098 disp(sprintf('%19s: %-22s -- %s','timestepping' ,['[1x1 ' class(obj.timestepping) ']'],'time stepping for transient models')); 1099 disp(sprintf('%19s: %-22s -- %s','initialization' ,['[1x1 ' class(obj.initialization) ']'],'initial guess/state')); 1100 disp(sprintf('%19s: %-22s -- %s','rifts' ,['[1x1 ' class(obj.rifts) ']'],'rifts properties')); 1101 disp(sprintf('%19s: %-22s -- %s','debug' ,['[1x1 ' class(obj.debug) ']'],'debugging tools (valgrind, gprof)')); 1102 disp(sprintf('%19s: %-22s -- %s','verbose' ,['[1x1 ' class(obj.verbose) ']'],'verbosity level in solve')); 1103 disp(sprintf('%19s: %-22s -- %s','settings' ,['[1x1 ' class(obj.settings) ']'],'settings properties')); 1104 disp(sprintf('%19s: %-22s -- %s','solver' ,['[1x1 ' class(obj.solver) ']'],'PETSc options for each solution')); 1105 disp(sprintf('%19s: %-22s -- %s','cluster' ,['[1x1 ' class(obj.cluster) ']'],'cluster parameters (number of cpus...)')); 1106 disp(sprintf('%19s: %-22s -- %s','balancethickness',['[1x1 ' class(obj.balancethickness) ']'],'parameters for balancethickness solution')); 1107 disp(sprintf('%19s: %-22s -- %s','diagnostic' ,['[1x1 ' class(obj.diagnostic) ']'],'parameters for diagnostic solution')); 1108 disp(sprintf('%19s: %-22s -- %s','groundingline' ,['[1x1 ' class(obj.groundingline) ']'],'parameters for groundingline solution')); 1109 disp(sprintf('%19s: %-22s -- %s','hydrology' ,['[1x1 ' class(obj.hydrology) ']'],'parameters for hydrology solution')); 1110 disp(sprintf('%19s: %-22s -- %s','prognostic' ,['[1x1 ' class(obj.prognostic) ']'],'parameters for prognostic solution')); 1111 disp(sprintf('%19s: %-22s -- %s','thermal' ,['[1x1 ' class(obj.thermal) ']'],'parameters for thermal solution')); 1112 disp(sprintf('%19s: %-22s -- %s','steadystate' ,['[1x1 ' class(obj.steadystate) ']'],'parameters for steadystate solution')); 1113 disp(sprintf('%19s: %-22s -- %s','transient' ,['[1x1 ' class(obj.transient) ']'],'parameters for transient solution')); 1114 disp(sprintf('%19s: %-22s -- %s','autodiff' ,['[1x1 ' class(obj.autodiff) ']'],'automatic differentiation parameters')); 1115 disp(sprintf('%19s: %-22s -- %s','flaim' ,['[1x1 ' class(obj.flaim) ']'],'flaim parameters')); 1116 disp(sprintf('%19s: %-22s -- %s','inversion' ,['[1x1 ' class(obj.inversion) ']'],'parameters for inverse methods')); 1117 disp(sprintf('%19s: %-22s -- %s','qmu' ,['[1x1 ' class(obj.qmu) ']'],'dakota properties')); 1118 disp(sprintf('%19s: %-22s -- %s','results' ,['[1x1 ' class(obj.results) ']'],'model results')); 1119 disp(sprintf('%19s: %-22s -- %s','radaroverlay' ,['[1x1 ' class(obj.radaroverlay) ']'],'radar image for plot overlay')); 1120 disp(sprintf('%19s: %-22s -- %s','miscellaneous' ,['[1x1 ' class(obj.miscellaneous) ']'],'miscellaneous fields')); 1121 end % }}} 1122 end 770 function md = structtomodel(md,structmd) % {{{ 771 772 if ~isstruct(structmd) error('input model is not a structure'); end 773 774 %loaded model is a struct, initialize output and recover all fields 775 md = structtoobj(model,structmd); 776 777 %Old field now classes 778 if (isfield(structmd,'timestepping') & isnumeric(md.timestepping)), md.timestepping=timestepping(); end 779 if (isfield(structmd,'mask') & isnumeric(md.mask)),md.mask=mask(); end 780 781 %Field name change 782 if isfield(structmd,'drag'), md.friction.coefficient=structmd.drag; end 783 if isfield(structmd,'p'), md.friction.p=structmd.p; end 784 if isfield(structmd,'q'), md.friction.q=structmd.p; end 785 if isfield(structmd,'melting'), md.basalforcings.melting_rate=structmd.melting; end 786 if isfield(structmd,'melting_rate'), md.basalforcings.melting_rate=structmd.melting_rate; end 787 if isfield(structmd,'accumulation'), md.surfaceforcings.mass_balance=structmd.accumulation; end 788 if isfield(structmd,'numberofgrids'), md.mesh.numberofvertices=structmd.numberofgrids; end 789 if isfield(structmd,'numberofgrids2d'), md.mesh.numberofvertices2d=structmd.numberofgrids2d; end 790 if isfield(structmd,'uppergrids'), md.mesh.uppervertex=structmd.uppergrids; end 791 if isfield(structmd,'lowergrids'), md.mesh.lowervertex=structmd.lowergrids; end 792 if isfield(structmd,'gridonbed'), md.mesh.vertexonbed=structmd.gridonbed; end 793 if isfield(structmd,'gridonsurface'), md.mesh.vertexonsurface=structmd.gridonsurface; end 794 if isfield(structmd,'extractedgrids'), md.mesh.extractedvertices=structmd.extractedgrids; end 795 if isfield(structmd,'gridoniceshelf'), md.mask.vertexonfloatingice=structmd.gridoniceshelf; end 796 if isfield(structmd,'gridonicesheet'), md.mask.vertexongroundedice=structmd.gridonicesheet; end 797 if isfield(structmd,'gridonwater'), md.mask.vertexonwater=structmd.gridonwater; end 798 if isfield(structmd,'gridonboundary'), md.mesh.vertexonboundary=structmd.gridonboundary; end 799 if isfield(structmd,'petscoptions') & ~isempty(structmd.petscoptions), md.solver=structmd.petscoptions; end 800 if isfield(structmd,'g'), md.constants.g=structmd.g; end 801 if isfield(structmd,'yts'), md.constants.yts=structmd.yts; end 802 if isfield(structmd,'surface_mass_balance'), md.surfaceforcings.mass_balance=structmd.surface_mass_balance; end 803 if isfield(structmd,'basal_melting_rate'), md.basalforcings.melting_rate=structmd.basal_melting_rate; end 804 if isfield(structmd,'basal_melting_rate_correction'), md.basalforcings.melting_rate_correction=structmd.basal_melting_rate_correction; end 805 if isfield(structmd,'geothermalflux'), md.basalforcings.geothermalflux=structmd.geothermalflux; end 806 if isfield(structmd,'drag'), md.friction.coefficient=structmd.drag; end 807 if isfield(structmd,'drag_coefficient'), md.friction.coefficient=structmd.drag_coefficient; end 808 if isfield(structmd,'drag_p'), md.friction.p=structmd.drag_p; end 809 if isfield(structmd,'drag_q'), md.friction.q=structmd.drag_q; end 810 if isfield(structmd,'riftproperties'), %old implementation 811 md.rifts=rifts(); 812 md.rifts.riftproperties=structmd.riftproperties; 813 md.rifts.riftstruct=structmd.rifts; 814 md.rifts.riftproperties=structmd.riftinfo; 815 end 816 if isfield(structmd,'bamg'), md.private.bamg=structmd.bamg; end 817 if isfield(structmd,'lowmem'), md.settings.lowmem=structmd.lowmem; end 818 if isfield(structmd,'io_gather'), md.settings.io_gather=structmd.io_gather; end 819 if isfield(structmd,'spcwatercolumn'), md.hydrology.spcwatercolumn=structmd.spcwatercolumn; end 820 if isfield(structmd,'hydro_n'), md.hydrology.n=structmd.hydro_n; end 821 if isfield(structmd,'hydro_p'), md.hydrology.p=structmd.hydro_p; end 822 if isfield(structmd,'hydro_q'), md.hydrology.q=structmd.hydro_q; end 823 if isfield(structmd,'hydro_CR'), md.hydrology.CR=structmd.hydro_CR; end 824 if isfield(structmd,'hydro_kn'), md.hydrology.kn=structmd.hydro_kn; end 825 if isfield(structmd,'spctemperature'), md.thermal.spctemperature=structmd.spctemperature; end 826 if isfield(structmd,'min_thermal_constraints'), md.thermal.penalty_threshold=structmd.min_thermal_constraints; end 827 if isfield(structmd,'artificial_diffusivity'), md.thermal.stabilization=structmd.artificial_diffusivity; end 828 if isfield(structmd,'max_nonlinear_iterations'), md.thermal.maxiter=structmd.max_nonlinear_iterations; end 829 if isfield(structmd,'stabilize_constraints'), md.thermal.penalty_lock=structmd.stabilize_constraints; end 830 if isfield(structmd,'penalty_offset'), md.thermal.penalty_factor=structmd.penalty_offset; end 831 if isfield(structmd,'name'), md.miscellaneous.name=structmd.name; end 832 if isfield(structmd,'notes'), md.miscellaneous.notes=structmd.notes; end 833 if isfield(structmd,'dummy'), md.miscellaneous.dummy=structmd.dummy; end 834 if isfield(structmd,'dt'), md.timestepping.time_step=structmd.dt; end 835 if isfield(structmd,'ndt'), md.timestepping.final_time=structmd.ndt; end 836 if isfield(structmd,'time_adapt'), md.timestepping.time_adapt=structmd.time_adapt; end 837 if isfield(structmd,'cfl_coefficient'), md.timestepping.cfl_coefficient=structmd.cfl_coefficient; end 838 if isfield(structmd,'spcthickness'), md.prognostic.spcthickness=structmd.spcthickness; end 839 if isfield(structmd,'artificial_diffusivity'), md.prognostic.stabilization=structmd.artificial_diffusivity; end 840 if isfield(structmd,'hydrostatic_adjustment'), md.prognostic.hydrostatic_adjustment=structmd.hydrostatic_adjustment; end 841 if isfield(structmd,'penalties'), md.prognostic.vertex_pairing=structmd.penalties; end 842 if isfield(structmd,'penalty_offset'), md.prognostic.penalty_factor=structmd.penalty_offset; end 843 if isfield(structmd,'B'), md.materials.rheology_B=structmd.B; end 844 if isfield(structmd,'n'), md.materials.rheology_n=structmd.n; end 845 if isfield(structmd,'rheology_B'), md.materials.rheology_B=structmd.rheology_B; end 846 if isfield(structmd,'rheology_n'), md.materials.rheology_n=structmd.rheology_n; end 847 if isfield(structmd,'elementoniceshelf'), md.mask.elementonfloatingice=structmd.elementoniceshelf; end 848 if isfield(structmd,'elementonicesheet'), md.mask.elementongroundedice=structmd.elementonicesheet; end 849 if isfield(structmd,'elementonwater'), md.mask.elementonwater=structmd.elementonwater; end 850 if isfield(structmd,'nodeoniceshelf'), md.mask.vertexonfloatingice=structmd.nodeoniceshelf; end 851 if isfield(structmd,'nodeonicesheet'), md.mask.vertexongroundedice=structmd.nodeonicesheet; end 852 if isfield(structmd,'nodeonwater'), md.mask.vertexonwater=structmd.nodeonwater; end 853 if isfield(structmd,'spcthickness'), md.balancethickness.spcthickness=structmd.spcthickness; end 854 if isfield(structmd,'artificial_diffusivity'), md.balancethickness.stabilization=structmd.artificial_diffusivity; end 855 if isfield(structmd,'dhdt'), md.balancethickness.thickening_rate=structmd.dhdt; end 856 if isfield(structmd,'ismacayealpattyn'), md.flowequation.ismacayealpattyn=structmd.ismacayealpattyn; end 857 if isfield(structmd,'ishutter'), md.flowequation.ishutter=structmd.ishutter; end 858 if isfield(structmd,'isstokes'), md.flowequation.isstokes=structmd.isstokes; end 859 if isfield(structmd,'elements_type'), md.flowequation.element_equation=structmd.elements_type; end 860 if isfield(structmd,'vertices_type'), md.flowequation.vertex_equation=structmd.vertices_type; end 861 if isfield(structmd,'eps_rel'), md.steadystate.reltol=structmd.eps_rel; end 862 if isfield(structmd,'max_steadystate_iterations'), md.steadystate.maxiter=structmd.max_steadystate_iterations; end 863 if isfield(structmd,'isdiagnostic'), md.transient.isdiagnostic=structmd.isdiagnostic; end 864 if isfield(structmd,'isprognostic'), md.transient.isprognostic=structmd.isprognostic; end 865 if isfield(structmd,'isthermal'), md.transient.isthermal=structmd.isthermal; end 866 if isfield(structmd,'control_analysis'), md.inversion.iscontrol=structmd.control_analysis; end 867 if isfield(structmd,'weights'), md.inversion.cost_functions_coefficients=structmd.weights; end 868 if isfield(structmd,'nsteps'), md.inversion.nsteps=structmd.nsteps; end 869 if isfield(structmd,'maxiter_per_step'), md.inversion.maxiter_per_step=structmd.maxiter_per_step; end 870 if isfield(structmd,'cm_min'), md.inversion.min_parameters=structmd.cm_min; end 871 if isfield(structmd,'cm_max'), md.inversion.max_parameters=structmd.cm_max; end 872 if isfield(structmd,'vx_obs'), md.inversion.vx_obs=structmd.vx_obs; end 873 if isfield(structmd,'vy_obs'), md.inversion.vy_obs=structmd.vy_obs; end 874 if isfield(structmd,'vel_obs'), md.inversion.vel_obs=structmd.vel_obs; end 875 if isfield(structmd,'thickness_obs'), md.inversion.thickness_obs=structmd.thickness_obs; end 876 if isfield(structmd,'vx'), md.initialization.vx=structmd.vx; end 877 if isfield(structmd,'vy'), md.initialization.vy=structmd.vy; end 878 if isfield(structmd,'vz'), md.initialization.vz=structmd.vz; end 879 if isfield(structmd,'vel'), md.initialization.vel=structmd.vel; end 880 if isfield(structmd,'pressure'), md.initialization.pressure=structmd.pressure; end 881 if isfield(structmd,'temperature'), md.initialization.temperature=structmd.temperature; end 882 if isfield(structmd,'waterfraction'), md.initialization.waterfraction=structmd.waterfraction; end 883 if isfield(structmd,'watercolumn'), md.initialization.watercolumn=structmd.watercolumn; end 884 if isfield(structmd,'surface'), md.geometry.surface=structmd.surface; end 885 if isfield(structmd,'bed'), md.geometry.bed=structmd.bed; end 886 if isfield(structmd,'thickness'), md.geometry.thickness=structmd.thickness; end 887 if isfield(structmd,'bathymetry'), md.geometry.bathymetry=structmd.bathymetry; end 888 if isfield(structmd,'thickness_coeff'), md.geometry.hydrostatic_ratio=structmd.thickness_coeff; end 889 if isfield(structmd,'connectivity'), md.mesh.average_vertex_connectivity=structmd.connectivity; end 890 if isfield(structmd,'extractednodes'), md.mesh.extractedvertices=structmd.extractednodes; end 891 if isfield(structmd,'extractedelements'), md.mesh.extractedelements=structmd.extractedelements; end 892 if isfield(structmd,'nodeonboundary'), md.mesh.vertexonboundary=structmd.nodeonboundary; end 893 if isfield(structmd,'hemisphere'), md.mesh.hemisphere=structmd.hemisphere; end 894 if isfield(structmd,'lat'), md.mesh.lat=structmd.lat; end 895 if isfield(structmd,'long'), md.mesh.long=structmd.long; end 896 if isfield(structmd,'segments'), md.mesh.segments=structmd.segments; end 897 if isfield(structmd,'segmentmarkers'), md.mesh.segmentmarkers=structmd.segmentmarkers; end 898 if isfield(structmd,'dim'), md.mesh.dimension=structmd.dim; end 899 if isfield(structmd,'numlayers'), md.mesh.numberoflayers=structmd.numlayers; end 900 if isfield(structmd,'numberofelements'), md.mesh.numberofelements=structmd.numberofelements; end 901 if isfield(structmd,'numberofvertices'), md.mesh.numberofvertices=structmd.numberofvertices; end 902 if isfield(structmd,'numberofnodes'), md.mesh.numberofvertices=structmd.numberofnodes; end 903 if isfield(structmd,'numberofedges'), md.mesh.numberofedges=structmd.numberofedges; end 904 if isfield(structmd,'numberofelements2d'), md.mesh.numberofelements2d=structmd.numberofelements2d; end 905 if isfield(structmd,'numberofnodes2d'), md.mesh.numberofvertices2d=structmd.numberofnodes2d; end 906 if isfield(structmd,'nodeconnectivity'), md.mesh.vertexconnectivity=structmd.nodeconnectivity; end 907 if isfield(structmd,'elementconnectivity'), md.mesh.elementconnectivity=structmd.elementconnectivity; end 908 if isfield(structmd,'uppernodes'), md.mesh.uppervertex=structmd.uppernodes; end 909 if isfield(structmd,'lowernodes'), md.mesh.lowervertex=structmd.lowernodes; end 910 if isfield(structmd,'upperelements'), md.mesh.upperelements=structmd.upperelements; end 911 if isfield(structmd,'lowerelements'), md.mesh.lowerelements=structmd.lowerelements; end 912 if isfield(structmd,'elementonbed'), md.mesh.elementonbed=structmd.elementonbed; end 913 if isfield(structmd,'elementonsurface'), md.mesh.elementonsurface=structmd.elementonsurface; end 914 if isfield(structmd,'nodeonsurface'), md.mesh.vertexonsurface=structmd.nodeonsurface; end 915 if isfield(structmd,'nodeonbed'), md.mesh.vertexonbed=structmd.nodeonbed; end 916 if isfield(structmd,'elements2d'), md.mesh.elements2d=structmd.elements2d; end 917 if isfield(structmd,'y2d'), md.mesh.y2d=structmd.y2d; end 918 if isfield(structmd,'x2d'), md.mesh.x2d=structmd.x2d; end 919 if isfield(structmd,'elements'), md.mesh.elements=structmd.elements; end 920 if isfield(structmd,'edges'), 921 md.mesh.edges=structmd.edges; 922 md.mesh.edges(isnan(md.mesh.edges))=-1; 923 end 924 if isfield(structmd,'y'), md.mesh.y=structmd.y; end 925 if isfield(structmd,'x'), md.mesh.x=structmd.x; end 926 if isfield(structmd,'z'), md.mesh.z=structmd.z; end 927 if isfield(structmd,'mask'), md.flaim.criterion=structmd.mask; end 928 if isfield(structmd,'pressureload'), md.diagnostic.icefront=structmd.pressureload; end 929 if isfield(structmd,'diagnostic_ref'), md.diagnostic.referential=structmd.diagnostic_ref; end 930 if isfield(structmd,'npart'); md.qmu.numberofpartitions=structmd.npart; end 931 if isfield(structmd,'part'); md.qmu.partition=structmd.part; end 932 933 %Field changes 934 if (isfield(structmd,'type') & ischar(structmd.type)), 935 if strcmpi(structmd.type,'2d'), md.mesh.dimension=2; end 936 if strcmpi(structmd.type,'3d'), md.mesh.dimension=3; end 937 end 938 if isnumeric(md.verbose), 939 md.verbose=verbose; 940 end 941 if size(md.diagnostic.icefront,2)==3 || size(md.diagnostic.icefront,2)==5, 942 front=md.diagnostic.icefront; 943 md.diagnostic.icefront=[front 1*md.mask.elementonfloatingice(front(:,end))]; 944 end 945 if isfield(structmd,'spcvelocity'), 946 md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1); 947 md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1); 948 md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1); 949 pos=find(structmd.spcvelocity(:,1)); md.diagnostic.spcvx(pos)=structmd.spcvelocity(pos,4); 950 pos=find(structmd.spcvelocity(:,2)); md.diagnostic.spcvy(pos)=structmd.spcvelocity(pos,5); 951 pos=find(structmd.spcvelocity(:,3)); md.diagnostic.spcvz(pos)=structmd.spcvelocity(pos,6); 952 end 953 if isfield(structmd,'spcvx'), 954 md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1); 955 pos=find(~isnan(structmd.spcvx)); md.diagnostic.spcvx(pos)=structmd.spcvx(pos); 956 end 957 if isfield(structmd,'spcvy'), 958 md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1); 959 pos=find(~isnan(structmd.spcvy)); md.diagnostic.spcvy(pos)=structmd.spcvy(pos); 960 end 961 if isfield(structmd,'spcvz'), 962 md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1); 963 pos=find(~isnan(structmd.spcvz)); md.diagnostic.spcvz(pos)=structmd.spcvz(pos); 964 end 965 if ~isempty(structmd.pressureload) & ismember(structmd.pressureload(end,end),[118 119 120]), 966 pos=find(structmd.pressureload(:,end)==120); md.diagnostic.icefront(pos,end)=0; 967 pos=find(structmd.pressureload(:,end)==118); md.diagnostic.icefront(pos,end)=1; 968 pos=find(structmd.pressureload(:,end)==119); md.diagnostic.icefront(pos,end)=2; 969 end 970 if isfield(structmd,'elements_type') & structmd.elements_type(end,end)>50, 971 pos=find(structmd.elements_type==59); md.flowequation.element_equation(pos,end)=0; 972 pos=find(structmd.elements_type==55); md.flowequation.element_equation(pos,end)=1; 973 pos=find(structmd.elements_type==56); md.flowequation.element_equation(pos,end)=2; 974 pos=find(structmd.elements_type==60); md.flowequation.element_equation(pos,end)=3; 975 pos=find(structmd.elements_type==62); md.flowequation.element_equation(pos,end)=4; 976 pos=find(structmd.elements_type==57); md.flowequation.element_equation(pos,end)=5; 977 pos=find(structmd.elements_type==58); md.flowequation.element_equation(pos,end)=6; 978 pos=find(structmd.elements_type==61); md.flowequation.element_equation(pos,end)=7; 979 end 980 if isfield(structmd,'vertices_type') & structmd.vertices_type(end,end)>50, 981 pos=find(structmd.vertices_type==59); md.flowequation.vertex_equation(pos,end)=0; 982 pos=find(structmd.vertices_type==55); md.flowequation.vertex_equation(pos,end)=1; 983 pos=find(structmd.vertices_type==56); md.flowequation.vertex_equation(pos,end)=2; 984 pos=find(structmd.vertices_type==60); md.flowequation.vertex_equation(pos,end)=3; 985 pos=find(structmd.vertices_type==62); md.flowequation.vertex_equation(pos,end)=4; 986 pos=find(structmd.vertices_type==57); md.flowequation.vertex_equation(pos,end)=5; 987 pos=find(structmd.vertices_type==58); md.flowequation.vertex_equation(pos,end)=6; 988 pos=find(structmd.vertices_type==61); md.flowequation.vertex_equation(pos,end)=7; 989 end 990 if isfield(structmd,'rheology_law') & isnumeric(structmd.rheology_law), 991 if (structmd.rheology_law==272), md.materials.rheology_law='None'; end 992 if (structmd.rheology_law==368), md.materials.rheology_law='Paterson'; end 993 if (structmd.rheology_law==369), md.materials.rheology_law='Arrhenius'; end 994 end 995 if isfield(structmd,'groundingline_migration') & isnumeric(structmd.groundingline_migration), 996 if (structmd.groundingline_migration==272), md.groundingline.migration='None'; end 997 if (structmd.groundingline_migration==273), md.groundingline.migration='AgressiveMigration'; end 998 if (structmd.groundingline_migration==274), md.groundingline.migration='SoftMigration'; end 999 end 1000 if isfield(structmd,'control_type') & isnumeric(structmd.control_type), 1001 if (structmd.control_type==143), md.inversion.control_parameters={'FrictionCoefficient'}; end 1002 if (structmd.control_type==190), md.inversion.control_parameters={'RheologyBbar'}; end 1003 if (structmd.control_type==147), md.inversion.control_parameters={'Thickeningrate'}; end 1004 end 1005 if isfield(structmd,'cm_responses') & ismember(structmd.cm_responses(end,end),[165:170 383 388 389]), 1006 pos=find(structmd.cm_responses==166); md.inversion.cost_functions(pos)=101; 1007 pos=find(structmd.cm_responses==167); md.inversion.cost_functions(pos)=102; 1008 pos=find(structmd.cm_responses==168); md.inversion.cost_functions(pos)=103; 1009 pos=find(structmd.cm_responses==169); md.inversion.cost_functions(pos)=104; 1010 pos=find(structmd.cm_responses==170); md.inversion.cost_functions(pos)=105; 1011 pos=find(structmd.cm_responses==165); md.inversion.cost_functions(pos)=201; 1012 pos=find(structmd.cm_responses==389); md.inversion.cost_functions(pos)=501; 1013 pos=find(structmd.cm_responses==388); md.inversion.cost_functions(pos)=502; 1014 pos=find(structmd.cm_responses==382); md.inversion.cost_functions(pos)=503; 1015 end 1016 1017 if isfield(structmd,'artificial_diffusivity') & structmd.artificial_diffusivity==2, 1018 md.thermal.stabilization=2; 1019 md.prognostic.stabilization=1; 1020 md.balancethickness.stabilization=1; 1021 end 1022 if isnumeric(md.prognostic.hydrostatic_adjustment) 1023 if md.prognostic.hydrostatic_adjustment==269, 1024 md.prognostic.hydrostatic_adjustment='Incremental'; 1025 else 1026 md.prognostic.hydrostatic_adjustment='Absolute'; 1027 end 1028 end 1029 1030 %New fields 1031 if ~isfield(structmd,'upperelements'); 1032 md.mesh.upperelements=transpose(1:md.mesh.numberofelements)+md.mesh.numberofelements2d; 1033 md.mesh.upperelements(end-md.mesh.numberofelements2d+1:end)=NaN; 1034 end 1035 if ~isfield(structmd,'lowerelements'); 1036 md.mesh.lowerelements=transpose(1:md.mesh.numberofelements)-md.mesh.numberofelements2d; 1037 md.mesh.lowerelements(1:md.mesh.numberofelements2d)=NaN; 1038 end 1039 1040 if ~isfield(structmd,'diagnostic_ref'); 1041 md.diagnostic.referential=NaN*ones(md.mesh.numberofvertices,6); 1042 end 1043 1044 end% }}} 1045 function md = setdefaultparameters(md) % {{{ 1046 1047 %initialize subclasses 1048 md.mesh = mesh(); 1049 md.mask = mask(); 1050 md.constants = constants(); 1051 md.geometry = geometry(); 1052 md.initialization = initialization(); 1053 md.surfaceforcings = surfaceforcings(); 1054 md.basalforcings = basalforcings(); 1055 md.friction = friction(); 1056 md.rifts = rifts(); 1057 md.timestepping = timestepping(); 1058 md.groundingline = groundingline(); 1059 md.materials = matice(); 1060 md.flowequation = flowequation(); 1061 md.debug = debug(); 1062 md.verbose = verbose('solution',true,'qmu',true,'control',true); 1063 md.settings = settings(); 1064 md.solver = solver(); 1065 if ismumps(), 1066 md.solver = addoptions(md.solver,DiagnosticVertAnalysisEnum(),mumpsoptions()); 1067 else 1068 md.solver = addoptions(md.solver,DiagnosticVertAnalysisEnum(),iluasmoptions()); 1069 end 1070 md.cluster = generic(); 1071 md.balancethickness = balancethickness(); 1072 md.diagnostic = diagnostic(); 1073 md.hydrology = hydrology(); 1074 md.prognostic = prognostic(); 1075 md.thermal = thermal(); 1076 md.steadystate = steadystate(); 1077 md.transient = transient(); 1078 md.autodiff = autodiff(); 1079 md.flaim = flaim(); 1080 md.inversion = inversion(); 1081 md.qmu = qmu(); 1082 md.radaroverlay = radaroverlay(); 1083 md.results = struct(); 1084 md.miscellaneous = miscellaneous(); 1085 md.private = private(); 1086 end 1087 %}}} 1088 function disp(obj) % {{{ 1089 disp(sprintf('%19s: %-22s -- %s','mesh' ,['[1x1 ' class(obj.mesh) ']'],'mesh properties')); 1090 disp(sprintf('%19s: %-22s -- %s','mask' ,['[1x1 ' class(obj.mask) ']'],'defines grounded and floating elements')); 1091 disp(sprintf('%19s: %-22s -- %s','geometry' ,['[1x1 ' class(obj.geometry) ']'],'surface elevation, bedrock topography, ice thickness,...')); 1092 disp(sprintf('%19s: %-22s -- %s','constants' ,['[1x1 ' class(obj.constants) ']'],'physical constants')); 1093 disp(sprintf('%19s: %-22s -- %s','surfaceforcings' ,['[1x1 ' class(obj.surfaceforcings) ']'],'surface forcings')); 1094 disp(sprintf('%19s: %-22s -- %s','basalforcings' ,['[1x1 ' class(obj.basalforcings) ']'],'bed forcings')); 1095 disp(sprintf('%19s: %-22s -- %s','materials' ,['[1x1 ' class(obj.materials) ']'],'material properties')); 1096 disp(sprintf('%19s: %-22s -- %s','friction' ,['[1x1 ' class(obj.friction) ']'],'basal friction/drag properties')); 1097 disp(sprintf('%19s: %-22s -- %s','flowequation' ,['[1x1 ' class(obj.flowequation) ']'],'flow equations')); 1098 disp(sprintf('%19s: %-22s -- %s','timestepping' ,['[1x1 ' class(obj.timestepping) ']'],'time stepping for transient models')); 1099 disp(sprintf('%19s: %-22s -- %s','initialization' ,['[1x1 ' class(obj.initialization) ']'],'initial guess/state')); 1100 disp(sprintf('%19s: %-22s -- %s','rifts' ,['[1x1 ' class(obj.rifts) ']'],'rifts properties')); 1101 disp(sprintf('%19s: %-22s -- %s','debug' ,['[1x1 ' class(obj.debug) ']'],'debugging tools (valgrind, gprof)')); 1102 disp(sprintf('%19s: %-22s -- %s','verbose' ,['[1x1 ' class(obj.verbose) ']'],'verbosity level in solve')); 1103 disp(sprintf('%19s: %-22s -- %s','settings' ,['[1x1 ' class(obj.settings) ']'],'settings properties')); 1104 disp(sprintf('%19s: %-22s -- %s','solver' ,['[1x1 ' class(obj.solver) ']'],'PETSc options for each solution')); 1105 disp(sprintf('%19s: %-22s -- %s','cluster' ,['[1x1 ' class(obj.cluster) ']'],'cluster parameters (number of cpus...)')); 1106 disp(sprintf('%19s: %-22s -- %s','balancethickness',['[1x1 ' class(obj.balancethickness) ']'],'parameters for balancethickness solution')); 1107 disp(sprintf('%19s: %-22s -- %s','diagnostic' ,['[1x1 ' class(obj.diagnostic) ']'],'parameters for diagnostic solution')); 1108 disp(sprintf('%19s: %-22s -- %s','groundingline' ,['[1x1 ' class(obj.groundingline) ']'],'parameters for groundingline solution')); 1109 disp(sprintf('%19s: %-22s -- %s','hydrology' ,['[1x1 ' class(obj.hydrology) ']'],'parameters for hydrology solution')); 1110 disp(sprintf('%19s: %-22s -- %s','prognostic' ,['[1x1 ' class(obj.prognostic) ']'],'parameters for prognostic solution')); 1111 disp(sprintf('%19s: %-22s -- %s','thermal' ,['[1x1 ' class(obj.thermal) ']'],'parameters for thermal solution')); 1112 disp(sprintf('%19s: %-22s -- %s','steadystate' ,['[1x1 ' class(obj.steadystate) ']'],'parameters for steadystate solution')); 1113 disp(sprintf('%19s: %-22s -- %s','transient' ,['[1x1 ' class(obj.transient) ']'],'parameters for transient solution')); 1114 disp(sprintf('%19s: %-22s -- %s','autodiff' ,['[1x1 ' class(obj.autodiff) ']'],'automatic differentiation parameters')); 1115 disp(sprintf('%19s: %-22s -- %s','flaim' ,['[1x1 ' class(obj.flaim) ']'],'flaim parameters')); 1116 disp(sprintf('%19s: %-22s -- %s','inversion' ,['[1x1 ' class(obj.inversion) ']'],'parameters for inverse methods')); 1117 disp(sprintf('%19s: %-22s -- %s','qmu' ,['[1x1 ' class(obj.qmu) ']'],'dakota properties')); 1118 disp(sprintf('%19s: %-22s -- %s','results' ,['[1x1 ' class(obj.results) ']'],'model results')); 1119 disp(sprintf('%19s: %-22s -- %s','radaroverlay' ,['[1x1 ' class(obj.radaroverlay) ']'],'radar image for plot overlay')); 1120 disp(sprintf('%19s: %-22s -- %s','miscellaneous' ,['[1x1 ' class(obj.miscellaneous) ']'],'miscellaneous fields')); 1121 end % }}} 1122 end 1123 1123 end -
issm/trunk/src/m/classes/model/model.py
r13395 r13975 1 1 #module imports {{{ 2 2 import numpy 3 import copy 3 4 from mesh import mesh 4 5 from mask import mask … … 30 31 from inversion import inversion 31 32 from qmu import qmu 33 from results import results 32 34 from radaroverlay import radaroverlay 33 35 from miscellaneous import miscellaneous 34 36 from private import private 35 from collections import OrderedDict36 37 from EnumDefinitions import * 37 38 from ismumps import * … … 39 40 from iluasmoptions import * 40 41 from project3d import * 42 from FlagElements import * 43 from NodeConnectivity import * 44 from ElementConnectivity import * 45 from contourenvelope import * 41 46 #}}} 42 47 … … 82 87 self.qmu = qmu() 83 88 84 self.results = OrderedDict()89 self.results = results() 85 90 self.radaroverlay = radaroverlay() 86 91 self.miscellaneous = miscellaneous() … … 167 172 print ("model not consistent: %s" % string) 168 173 self.private.isconsistent=False 174 return self 175 # }}} 176 177 def extract(md,area): # {{{ 178 """ 179 extract - extract a model according to an Argus contour or flag list 180 181 This routine extracts a submodel from a bigger model with respect to a given contour 182 md must be followed by the corresponding exp file or flags list 183 It can either be a domain file (argus type, .exp extension), or an array of element flags. 184 If user wants every element outside the domain to be 185 extract2d, add '~' to the name of the domain file (ex: '~Pattyn.exp'); 186 an empty string '' will be considered as an empty domain 187 a string 'all' will be considered as the entire domain 188 189 Usage: 190 md2=extract(md,area); 191 192 Examples: 193 md2=extract(md,'Domain.exp'); 194 md2=extract(md,md.mask.elementonfloatingice); 195 196 See also: EXTRUDE, COLLAPSE 197 """ 198 199 #copy model 200 md1=copy.deepcopy(md) 201 202 #get elements that are inside area 203 flag_elem=FlagElements(md1,area) 204 if not numpy.any(flag_elem): 205 raise RuntimeError("extracted model is empty") 206 207 #kick out all elements with 3 dirichlets 208 spc_elem=numpy.nonzero(numpy.logical_not(flag_elem))[0] 209 spc_node=numpy.unique(md1.mesh.elements[spc_elem,:]).astype(int)-1 210 flag=numpy.ones(md1.mesh.numberofvertices) 211 flag[spc_node]=0 212 pos=numpy.nonzero(numpy.logical_not(numpy.sum(flag[md1.mesh.elements.astype(int)-1],axis=1)))[0] 213 flag_elem[pos]=0 214 215 #extracted elements and nodes lists 216 pos_elem=numpy.nonzero(flag_elem)[0] 217 pos_node=numpy.unique(md1.mesh.elements[pos_elem,:]).astype(int)-1 218 219 #keep track of some fields 220 numberofvertices1=md1.mesh.numberofvertices 221 numberofelements1=md1.mesh.numberofelements 222 numberofvertices2=numpy.size(pos_node) 223 numberofelements2=numpy.size(pos_elem) 224 flag_node=numpy.zeros(numberofvertices1) 225 flag_node[pos_node]=1 226 227 #Create Pelem and Pnode (transform old nodes in new nodes and same thing for the elements) 228 Pelem=numpy.zeros(numberofelements1) 229 Pelem[pos_elem]=numpy.arange(1,numberofelements2+1) 230 Pnode=numpy.zeros(numberofvertices1) 231 Pnode[pos_node]=numpy.arange(1,numberofvertices2+1) 232 233 #renumber the elements (some node won't exist anymore) 234 elements_1=copy.deepcopy(md1.mesh.elements) 235 elements_2=elements_1[pos_elem,:] 236 elements_2[:,0]=Pnode[elements_2[:,0].astype(int)-1] 237 elements_2[:,1]=Pnode[elements_2[:,1].astype(int)-1] 238 elements_2[:,2]=Pnode[elements_2[:,2].astype(int)-1] 239 if md1.mesh.dimension==3: 240 elements_2[:,3]=Pnode[elements_2[:,3].astype(int)-1] 241 elements_2[:,4]=Pnode[elements_2[:,4].astype(int)-1] 242 elements_2[:,5]=Pnode[elements_2[:,5].astype(int)-1] 243 244 #OK, now create the new model! 245 246 #take every field from model 247 md2=copy.deepcopy(md1) 248 249 #automatically modify fields 250 251 #loop over model fields 252 model_fields=vars(md1) 253 for fieldi in model_fields: 254 #get field 255 field=getattr(md1,fieldi) 256 fieldsize=numpy.shape(field) 257 if hasattr(field,'__dict__') and not ismember(fieldi,['results'])[0]: #recursive call 258 object_fields=vars(field) 259 for fieldj in object_fields: 260 #get field 261 field=getattr(getattr(md1,fieldi),fieldj) 262 fieldsize=numpy.shape(field) 263 if len(fieldsize): 264 #size = number of nodes * n 265 if fieldsize[0]==numberofvertices1: 266 setattr(getattr(md2,fieldi),fieldj,field[pos_node,:]) 267 elif fieldsize[0]==numberofvertices1+1: 268 setattr(getattr(md2,fieldi),fieldj,numpy.vstack((field[pos_node,:],field[-1,:]))) 269 #size = number of elements * n 270 elif fieldsize[0]==numberofelements1: 271 setattr(getattr(md2,fieldi),fieldj,field[pos_elem,:]) 272 else: 273 if len(fieldsize): 274 #size = number of nodes * n 275 if fieldsize[0]==numberofvertices1: 276 setattr(md2,fieldi,field[pos_node,:]) 277 elif fieldsize[0]==numberofvertices1+1: 278 setattr(md2,fieldi,numpy.hstack((field[pos_node,:],field[-1,:]))) 279 #size = number of elements * n 280 elif fieldsize[0]==numberofelements1: 281 setattr(md2,fieldi,field[pos_elem,:]) 282 283 #modify some specific fields 284 285 #Mesh 286 md2.mesh.numberofelements=numberofelements2 287 md2.mesh.numberofvertices=numberofvertices2 288 md2.mesh.elements=elements_2 289 290 #mesh.uppervertex mesh.lowervertex 291 if md1.mesh.dimension==3: 292 md2.mesh.uppervertex=md1.mesh.uppervertex[pos_node] 293 pos=numpy.nonzero(numpy.logical_not(numpy.isnan(md2.mesh.uppervertex)))[0] 294 md2.mesh.uppervertex[pos]=Pnode[md2.mesh.uppervertex[pos].astype(int)-1] 295 296 md2.mesh.lowervertex=md1.mesh.lowervertex[pos_node] 297 pos=numpy.nonzero(numpy.logical_not(numpy.isnan(md2.mesh.lowervertex)))[0] 298 md2.mesh.lowervertex[pos]=Pnode[md2.mesh.lowervertex[pos].astype(int)-1] 299 300 md2.mesh.upperelements=md1.mesh.upperelements[pos_elem] 301 pos=numpy.nonzero(numpy.logical_not(numpy.isnan(md2.mesh.upperelements)))[0] 302 md2.mesh.upperelements[pos]=Pelem[md2.mesh.upperelements[pos].astype(int)-1] 303 304 md2.mesh.lowerelements=md1.mesh.lowerelements[pos_elem] 305 pos=numpy.nonzero(numpy.logical_not(numpy.isnan(md2.mesh.lowerelements)))[0] 306 md2.mesh.lowerelements[pos]=Pelem[md2.mesh.lowerelements[pos].astype(int)-1] 307 308 #Initial 2d mesh 309 if md1.mesh.dimension==3: 310 flag_elem_2d=flag_elem[numpy.arange(0,md1.mesh.numberofelements2d)] 311 pos_elem_2d=numpy.nonzero(flag_elem_2d)[0] 312 flag_node_2d=flag_node[numpy.arange(0,md1.mesh.numberofvertices2d)] 313 pos_node_2d=numpy.nonzero(flag_node_2d)[0] 314 315 md2.mesh.numberofelements2d=numpy.size(pos_elem_2d) 316 md2.mesh.numberofvertices2d=numpy.size(pos_node_2d) 317 md2.mesh.elements2d=md1.mesh.elements2d[pos_elem_2d,:] 318 md2.mesh.elements2d[:,0]=Pnode[md2.mesh.elements2d[:,0].astype(int)-1] 319 md2.mesh.elements2d[:,1]=Pnode[md2.mesh.elements2d[:,1].astype(int)-1] 320 md2.mesh.elements2d[:,2]=Pnode[md2.mesh.elements2d[:,2].astype(int)-1] 321 322 md2.mesh.x2d=md1.mesh.x[pos_node_2d] 323 md2.mesh.y2d=md1.mesh.y[pos_node_2d] 324 325 #Edges 326 if len(numpy.shape(md2.mesh.edges))>1 and numpy.size(md2.mesh.edges,axis=1)>1: #do not use ~isnan because there are some NaNs... 327 #renumber first two columns 328 pos=numpy.nonzero(md2.mesh.edges[:,3]!=-1)[0] 329 md2.mesh.edges[: ,0]=Pnode[md2.mesh.edges[:,0].astype(int)-1] 330 md2.mesh.edges[: ,1]=Pnode[md2.mesh.edges[:,1].astype(int)-1] 331 md2.mesh.edges[: ,2]=Pelem[md2.mesh.edges[:,2].astype(int)-1] 332 md2.mesh.edges[pos,3]=Pelem[md2.mesh.edges[pos,3].astype(int)-1] 333 #remove edges when the 2 vertices are not in the domain. 334 md2.mesh.edges=md2.mesh.edges[numpy.nonzero(numpy.logical_and(md2.mesh.edges[:,0],md2.mesh.edges[:,1]))[0],:] 335 #Replace all zeros by -1 in the last two columns 336 pos=numpy.nonzero(md2.mesh.edges[:,2]==0)[0] 337 md2.mesh.edges[pos,2]=-1 338 pos=numpy.nonzero(md2.mesh.edges[:,3]==0)[0] 339 md2.mesh.edges[pos,3]=-1 340 #Invert -1 on the third column with last column (Also invert first two columns!!) 341 pos=numpy.nonzero(md2.mesh.edges[:,2]==-1)[0] 342 md2.mesh.edges[pos,2]=md2.mesh.edges[pos,3] 343 md2.mesh.edges[pos,3]=-1 344 values=md2.mesh.edges[pos,1] 345 md2.mesh.edges[pos,1]=md2.mesh.edges[pos,0] 346 md2.mesh.edges[pos,0]=values 347 #Finally remove edges that do not belong to any element 348 pos=numpy.nonzero(numpy.logical_and(md2.mesh.edges[:,1]==-1,md2.mesh.edges[:,2]==-1))[0] 349 md2.mesh.edges=numpy.delete(md2.mesh.edges,pos,axis=0) 350 351 #Penalties 352 if numpy.any(numpy.logical_not(numpy.isnan(md2.diagnostic.vertex_pairing))): 353 for i in xrange(numpy.size(md1.diagnostic.vertex_pairing,axis=0)): 354 md2.diagnostic.vertex_pairing[i,:]=Pnode[md1.diagnostic.vertex_pairing[i,:]] 355 md2.diagnostic.vertex_pairing=md2.diagnostic.vertex_pairing[numpy.nonzero(md2.diagnostic.vertex_pairing[:,0])[0],:] 356 if numpy.any(numpy.logical_not(numpy.isnan(md2.prognostic.vertex_pairing))): 357 for i in xrange(numpy.size(md1.prognostic.vertex_pairing,axis=0)): 358 md2.prognostic.vertex_pairing[i,:]=Pnode[md1.prognostic.vertex_pairing[i,:]] 359 md2.prognostic.vertex_pairing=md2.prognostic.vertex_pairing[numpy.nonzero(md2.prognostic.vertex_pairing[:,0])[0],:] 360 361 #recreate segments 362 if md1.mesh.dimension==2: 363 [md2.mesh.vertexconnectivity]=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices) 364 [md2.mesh.elementconnectivity]=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity) 365 md2.mesh.segments=contourenvelope(md2) 366 md2.mesh.vertexonboundary=numpy.zeros(numberofvertices2) 367 md2.mesh.vertexonboundary[md2.mesh.segments[:,0:2].astype(int)-1]=1 368 else: 369 #First do the connectivity for the contourenvelope in 2d 370 [md2.mesh.vertexconnectivity]=NodeConnectivity(md2.mesh.elements2d,md2.mesh.numberofvertices2d) 371 [md2.mesh.elementconnectivity]=ElementConnectivity(md2.mesh.elements2d,md2.mesh.vertexconnectivity) 372 md2.mesh.segments=contourenvelope(md2) 373 md2.mesh.vertexonboundary=numpy.zeros(numberofvertices2/md2.mesh.numberoflayers) 374 md2.mesh.vertexonboundary[md2.mesh.segments[:,0:2].astype(int)-1]=1 375 md2.mesh.vertexonboundary=numpy.tile(md2.mesh.vertexonboundary,md2.mesh.numberoflayers) 376 #Then do it for 3d as usual 377 [md2.mesh.vertexconnectivity]=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices) 378 [md2.mesh.elementconnectivity]=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity) 379 380 #Boundary conditions: Dirichlets on new boundary 381 #Catch the elements that have not been extracted 382 orphans_elem=numpy.nonzero(numpy.logical_not(flag_elem))[0] 383 orphans_node=numpy.unique(md1.mesh.elements[orphans_elem,:]).astype(int)-1 384 #Figure out which node are on the boundary between md2 and md1 385 nodestoflag1=numpy.intersect1d(orphans_node,pos_node) 386 nodestoflag2=Pnode[nodestoflag1].astype(int)-1 387 if numpy.size(md1.diagnostic.spcvx)>1 and numpy.size(md1.diagnostic.spcvy)>2 and numpy.size(md1.diagnostic.spcvz)>2: 388 if numpy.size(md1.inversion.vx_obs)>1 and numpy.size(md1.inversion.vy_obs)>1: 389 md2.diagnostic.spcvx[nodestoflag2]=md2.inversion.vx_obs[nodestoflag2] 390 md2.diagnostic.spcvy[nodestoflag2]=md2.inversion.vy_obs[nodestoflag2] 391 else: 392 md2.diagnostic.spcvx[nodestoflag2]=float('NaN') 393 md2.diagnostic.spcvy[nodestoflag2]=float('NaN') 394 print "\n!! extract warning: spc values should be checked !!\n\n" 395 #put 0 for vz 396 md2.diagnostic.spcvz[nodestoflag2]=0 397 if numpy.any(numpy.logical_not(numpy.isnan(md1.thermal.spctemperature))): 398 md2.thermal.spctemperature[nodestoflag2,0]=1 399 400 #Diagnostic 401 if numpy.any(numpy.logical_not(numpy.isnan(md2.diagnostic.icefront))): 402 md2.diagnostic.icefront[:,0]=Pnode[md1.diagnostic.icefront[:,0].astype(int)-1] 403 md2.diagnostic.icefront[:,1]=Pnode[md1.diagnostic.icefront[:,1].astype(int)-1] 404 md2.diagnostic.icefront[:,-2]=Pelem[md1.diagnostic.icefront[:,-2].astype(int)-1] 405 if md1.mesh.dimension==3: 406 md2.diagnostic.icefront[:,2]=Pnode[md1.diagnostic.icefront[:,2].astype(int)-1] 407 md2.diagnostic.icefront[:,3]=Pnode[md1.diagnostic.icefront[:,3].astype(int)-1] 408 md2.diagnostic.icefront=md2.diagnostic.icefront[numpy.nonzero(numpy.logical_and(numpy.logical_and(md2.diagnostic.icefront[:,0],md2.diagnostic.icefront[:,1]),md2.diagnostic.icefront[:,-1]))[0],:] 409 410 #Results fields 411 if md1.results: 412 md2.results=results() 413 for solutionfield,field in md1.results.__dict__.iteritems(): 414 if isinstance(field,list): 415 setattr(md2.results,solutionfield,[]) 416 #get time step 417 for i,fieldi in enumerate(field): 418 if isinstance(fieldi,results) and fieldi: 419 getattr(md2.results,solutionfield).append(results()) 420 fieldr=getattr(md2.results,solutionfield)[i] 421 #get subfields 422 for solutionsubfield,subfield in fieldi.__dict__.iteritems(): 423 if numpy.size(subfield)==numberofvertices1: 424 setattr(fieldr,solutionsubfield,subfield[pos_node]) 425 elif numpy.size(subfield)==numberofelements1: 426 setattr(fieldr,solutionsubfield,subfield[pos_elem]) 427 else: 428 setattr(fieldr,solutionsubfield,subfield) 429 else: 430 getattr(md2.results,solutionfield).append(None) 431 elif isinstance(field,results): 432 setattr(md2.results,solutionfield,results()) 433 if isinstance(field,results) and field: 434 fieldr=getattr(md2.results,solutionfield) 435 #get subfields 436 for solutionsubfield,subfield in field.__dict__.iteritems(): 437 if numpy.size(subfield)==numberofvertices1: 438 setattr(fieldr,solutionsubfield,subfield[pos_node]) 439 elif numpy.size(subfield)==numberofelements1: 440 setattr(fieldr,solutionsubfield,subfield[pos_elem]) 441 else: 442 setattr(fieldr,solutionsubfield,subfield) 443 444 #Keep track of pos_node and pos_elem 445 md2.mesh.extractedvertices=pos_node.astype(float)+1 446 md2.mesh.extractedelements=pos_elem.astype(float)+1 447 448 return md2 169 449 # }}} 170 450 … … 242 522 y3d=numpy.concatenate((y3d,md.mesh.y)) 243 523 #nodes are distributed between bed and surface accordingly to the given exponent 244 z3d=numpy.concatenate((z3d, bed3d+thickness3d*extrusionlist[i]))524 z3d=numpy.concatenate((z3d,(bed3d+thickness3d*extrusionlist[i]).reshape(-1))) 245 525 number_nodes3d=numpy.size(x3d) #number of 3d nodes for the non extruded part of the mesh 246 526 … … 402 682 #Put lithostatic pressure if there is an existing pressure 403 683 if not numpy.any(numpy.isnan(md.initialization.pressure)): 404 md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z )684 md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z.reshape(-1,1)) 405 685 406 686 #special for thermal modeling: -
issm/trunk/src/m/classes/modellist.m
r13395 r13975 271 271 end 272 272 273 274 273 %now, tar all the files and then erase them. 275 274 eval(['!find -iname ''' name '-*'' > file_list.txt']); … … 302 301 303 302 %First try and figure out if there is a special script for this particular cluster 304 function_name=['BuildMultipleQueueingScript' cluster] ;303 function_name=['BuildMultipleQueueingScript' cluster] 305 304 306 305 %some specific treatment of identical cluster, gemini, castor and pollux … … 348 347 349 348 %First try and figure out if there is a special script for thie particular cluster 350 function_name=['LaunchMultipleQueueJob' cluster] ;349 function_name=['LaunchMultipleQueueJob' cluster] 351 350 352 351 %some specific treatment of identical cluster, gemini, castor and pollux … … 369 368 % LaunchMultipleQueueJobgemini(cluster,name,executionpath) 370 369 371 372 370 %first, check we have the binary file and the queueing script 373 371 if ~exist([ name '.queue'],'file'), -
issm/trunk/src/m/classes/organizer.m
r12706 r13975 10 10 % org = organizer(varargin) 11 11 % 12 %13 12 % Examples: 14 13 % org = organizer('repository','Models/','prefix','AGU2015','steps',0); %build an empty organizer object with a given repository … … 16 15 classdef organizer 17 16 properties (SetAccess=private) 18 19 20 17 % {{{ 18 currentstep =0; 19 end 21 20 properties (SetAccess=public) 22 23 24 25 26 27 28 29 30 21 repository ='./'; 22 prefix ='model.'; 23 trunkprefix =''; 24 steps =[]; 25 requestedsteps=[0]; 26 %}}} 27 end 28 methods 29 function org=organizer(varargin) % {{{ 31 30 32 33 31 %process options 32 options=pairoptions(varargin{:}); 34 33 35 36 37 38 39 34 %Get prefix 35 prefix=getfieldvalue(options,'prefix','model.'); 36 if ~ischar(prefix), error('prefix is not a string'); end 37 if ~strcmp(regexprep(prefix,'\s+',''),prefix), error('prefix should not have any white space'); end 38 org.prefix=prefix; 40 39 41 42 43 44 45 40 %Get repository 41 repository=getfieldvalue(options,'repository','./'); 42 if ~ischar(repository), error('repository is not a string'); end 43 if exist(repository,'dir')~=7, error(['Directory ' repository ' not found']), end 44 org.repository=repository; 46 45 47 %Get repository48 46 %Get steps 47 org.requestedsteps=getfieldvalue(options,'steps',0); 49 48 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 49 %Get trunk prefix (only if provided by user) 50 if exist(options,'trunkprefix'), 51 trunkprefix=getfieldvalue(options,'trunkprefix',''); 52 if ~ischar(trunkprefix), error('trunkprefix is not a string'); end 53 if ~strcmp(regexprep(trunkprefix,'\s+',''),trunkprefix), error('trunkprefix should not have any white space'); end 54 org.trunkprefix=trunkprefix; 55 end 56 end 57 %}}} 58 function disp(org) % {{{ 59 disp(sprintf(' Repository: ''%s''',org.repository)); 60 disp(sprintf(' Prefix: ''%s''',org.prefix)); 61 if isempty(org.steps) 62 disp(' no step'); 63 else 64 for i=1:length(org.steps), 65 disp(sprintf(' step #%2i: ''%s''',org.steps(i).id,org.steps(i).string)); 66 end 67 end 68 end 69 %}}} 70 function md=load(org,string),% {{{ 72 71 73 74 75 72 %Get model path 73 if ~ischar(string), error('argument provided is not a string'); end 74 path=[org.repository '/' org.prefix string]; 76 75 77 78 79 80 81 82 83 84 85 86 87 88 89 76 %figure out if the model is there 77 if exist(path,'file'), 78 struc=load(path,'-mat'); 79 name=char(fieldnames(struc)); 80 md=struc.(name); 81 if nargout, 82 varargout{1}=md; 83 end 84 else 85 error(['Could not find ' path ]); 86 end 87 end%}}} 88 function md=loadmodel(org,string),% {{{ 90 89 91 92 93 90 %Get model path 91 if ~ischar(string), error('argument provided is not a string'); end 92 path=[org.repository '/' org.prefix string]; 94 93 95 96 97 98 99 94 %figure out if the model is there, otherwise, we have to use the default path supplied by user. 95 if exist(path,'file') | exist([path '.mat'],'file'), 96 md=loadmodel(path); 97 return; 98 end 100 99 101 %If we are here, the model has not been found. Try trunk prefix if provided 102 if ~isempty(org.trunkprefix), 103 path2=[org.repository '/' org.trunkprefix string]; 104 if ~exist(path2,'file'), 105 error(['Could neither find ' path ', nor ' path2]); 106 else 107 disp(['--> Branching ' org.prefix ' from trunk ' org.trunkprefix]); 108 md=loadmodel(path2); 109 return; 110 end 111 else 112 error(['Could not find ' path ]); 113 end 114 end%}}} 115 function bool=perform(org,string) % {{{ 116 117 bool=false; 100 %If we are here, the model has not been found. Try trunk prefix if provided 101 if ~isempty(org.trunkprefix), 102 path2=[org.repository '/' org.trunkprefix string]; 103 if ~exist(path2,'file'), 104 error(['Could find neither ' path ', nor ' path2]); 105 else 106 disp(['--> Branching ' org.prefix ' from trunk ' org.trunkprefix]); 107 md=loadmodel(path2); 108 return; 109 end 110 else 111 error(['Could not find ' path ]); 112 end 113 end%}}} 114 function bool=perform(org,string) % {{{ 118 115 119 %Some checks 120 if ~ischar(string), error('Step provided should be a string'); end 121 if ~strcmp(regexprep(string,'\s+',''),string), error('Step provided should not have any white space'); end 122 if (org.currentstep>0 & ismember({string},{org.steps.string})) 123 error(['Step ' string ' already present. Change name']); 124 end 116 bool=false; 125 117 126 %Add step 127 org.steps(end+1).id=length(org.steps)+1; 128 org.steps(end).string=string; 129 org.currentstep=org.currentstep+1; 118 %Some checks 119 if ~ischar(string), error('Step provided should be a string'); end 120 if ~strcmp(regexprep(string,'\s+',''),string), error('Step provided should not have any white space'); end 121 if (org.currentstep>0 & ismember({string},{org.steps.string})) 122 error(['Step ' string ' already present. Change name']); 123 end 130 124 131 %if requestedsteps = 0, print all steps in org 132 if any(org.requestedsteps==0), 133 if org.currentstep==1, 134 disp(sprintf(' prefix: %s',org.prefix)); 135 end 136 disp(sprintf(' step #%2i : %s',org.steps(org.currentstep).id,org.steps(org.currentstep).string)); 137 end 125 %Add step 126 org.steps(end+1).id=length(org.steps)+1; 127 org.steps(end).string=string; 128 org.currentstep=org.currentstep+1; 138 129 139 %Ok, now if currentstep is a member of steps, return true 140 if ismember(org.currentstep,org.requestedsteps), 141 disp(sprintf('\n step #%i : %s\n',org.steps(org.currentstep).id,org.steps(org.currentstep).string)); 142 bool=true; 143 end 130 %if requestedsteps = 0, print all steps in org 131 if any(org.requestedsteps==0), 132 if org.currentstep==1, 133 disp(sprintf(' prefix: %s',org.prefix)); 134 end 135 disp(sprintf(' step #%2i : %s',org.steps(org.currentstep).id,org.steps(org.currentstep).string)); 136 end 144 137 145 %assign org back to calling workspace 146 assignin('caller',inputname(1),org); 138 %Ok, now if currentstep is a member of steps, return true 139 if ismember(org.currentstep,org.requestedsteps), 140 disp(sprintf('\n step #%i : %s\n',org.steps(org.currentstep).id,org.steps(org.currentstep).string)); 141 bool=true; 142 end 147 143 148 end%}}}149 function savemodel(org,md) % {{{144 %assign org back to calling workspace 145 assignin('caller',inputname(1),org); 150 146 151 %check 152 if (org.currentstep==0), error('Cannot save model because organizer (org) is empty! Make sure you did not skip any perform call'); end 153 if (org.currentstep>length(org.steps)), error('Cannot save model because organizer (org) is not up to date!'); end 147 end%}}} 148 function savemodel(org,md) % {{{ 154 149 155 name=[org.repository '/' org.prefix org.steps(org.currentstep).string ]; 156 disp(['saving model as: ' name]); 157 158 %check that md is a model 159 if ~isa(md,'model'), warning('third argument is not a model'); end 160 if (org.currentstep>length(org.steps)), error(['organizer error message: element with id ' num2str(org.currentstep) ' not found']); end 150 %check 151 if (org.currentstep==0), error('Cannot save model because organizer (org) is empty! Make sure you did not skip any perform call'); end 152 if (org.currentstep>length(org.steps)), error('Cannot save model because organizer (org) is not up to date!'); end 161 153 162 %save model 163 save(name,'md','-v7.3'); 164 end%}}} 154 name=[org.repository '/' org.prefix org.steps(org.currentstep).string ]; 155 disp(['saving model as: ' name]); 156 157 %check that md is a model 158 if ~isa(md,'model'), warning('second argument is not a model'); end 159 if (org.currentstep>length(org.steps)), error(['organizer error message: element with id ' num2str(org.currentstep) ' not found']); end 160 161 %save model 162 save(name,'md','-v7.3'); 163 end%}}} 165 164 end 166 165 end -
issm/trunk/src/m/classes/pairoptions.m
r12706 r13975 175 175 176 176 %some argument checking: 177 if nargin~=2 & nargin~=3,177 if nargin~=2 && nargin~=3, 178 178 help getfieldvalue 179 179 error('getfieldvalue error message: bad usage'); … … 185 185 186 186 %Recover option 187 for i=1:size(obj.list,1), 188 if strcmpi(obj.list{i,1},field) 189 value=obj.list{i,2}; 190 return 191 end 187 pos=find(strcmpi(obj.list(:,1),field)); 188 if ~isempty(pos), 189 value=obj.list{pos(1),2}; %ignore extra entry 190 return; 192 191 end 193 192 -
issm/trunk/src/m/classes/pairoptions.py
r13395 r13975 41 41 else: 42 42 #option is not a string, ignore it 43 print "WARNING: option number %d '%s' is not a string and will be ignored." % (i+1,type(arg[2*i]))43 print "WARNING: option number %d is not a string and will be ignored." % (i+1) 44 44 # }}} 45 45 … … 53 53 54 54 def addfielddefault(self,field,value): # {{{ 55 """ADDFIELDDEFAULT - add a field to an options list if it does not exist"""55 """ADDFIELDDEFAULT - add a field to an options list if it does not already exist""" 56 56 if isinstance(field,(str,unicode)): 57 57 if field not in self.list: … … 128 128 # }}} 129 129 130 # function num = fieldoccurences(obj,field), % {{{ 131 # %FIELDOCCURENCES - get number of occurence of a field 132 # 133 # %check input 134 # if ~ischar(field), 135 # error('fieldoccurences error message: field should be a string'); 136 # end 137 # 138 # %get number of occurence 139 # num=sum(strcmpi(field,obj.list(:,1))); 140 # end % }}} 130 #def fieldoccurences(self,field): #{{{ 131 # ''' 132 # FIELDOCCURENCES - get number of occurence of a field 133 # ''' 134 # 135 # #check input 136 # if not isinstance(field,(str,unicode)): 137 # raise TypeError("fieldoccurences error message: field should be a string") 138 139 # #get number of occurence 140 # # ?? 141 # #return num 142 # #% }}} 141 143 142 144 def getfieldvalue(self,field,default=None): # {{{ -
issm/trunk/src/m/classes/planetmesh.m
r13395 r13975 17 17 numberofelements = 0; 18 18 numberofvertices = 0; 19 19 20 20 lat = NaN 21 21 long = NaN … … 103 103 fielddisplay(obj,'dimension','planetmesh dimension (2d or 3d)'); 104 104 fielddisplay(obj,'numberoflayers','number of extrusion layers'); 105 105 106 106 fielddisplay(obj,'vertexconnectivity','list of vertices connected to vertex_i'); 107 107 fielddisplay(obj,'elementconnectivity','list of vertices connected to element_i'); -
issm/trunk/src/m/classes/prognostic.m
r13395 r13975 12 12 vertex_pairing = NaN; 13 13 penalty_factor = 0; 14 requested_outputs = NaN; 14 15 end 15 16 methods … … 45 46 md = checkfield(md,'prognostic.stabilization','values',[0 1 2 3]); 46 47 md = checkfield(md,'prognostic.min_thickness','>',0); 48 if ~isempty(md.prognostic.requested_outputs), 49 md = checkfield(md,'prognostic.requested_outputs','size',[NaN 1]); 50 end 47 51 48 52 end % }}} … … 57 61 fielddisplay(obj,'penalty_factor','offset used by penalties: penalty = Kmax*10^offset'); 58 62 fielddisplay(obj,'vertex_pairing','pairs of vertices that are penalized'); 63 fielddisplay(obj,'requested_outputs','additional outputs requested'); 59 64 60 65 end % }}} … … 66 71 WriteData(fid,'object',obj,'fieldname','vertex_pairing','format','DoubleMat','mattype',3); 67 72 WriteData(fid,'object',obj,'fieldname','penalty_factor','format','Double'); 73 WriteData(fid,'object',obj,'fieldname','requested_outputs','format','DoubleMat','mattype',3); 68 74 end % }}} 69 75 end -
issm/trunk/src/m/classes/prognostic.py
r13395 r13975 23 23 self.vertex_pairing = float('NaN') 24 24 self.penalty_factor = 0 25 self.requested_outputs = float('NaN') 25 26 26 27 #set defaults … … 35 36 string="%s\n%s"%(string,fielddisplay(self,'hydrostatic_adjustment','adjustment of ice shelves surface and bed elevations: ''Incremental'' or ''Absolute'' ')) 36 37 string="%s\n%s"%(string,fielddisplay(self,'stabilization','0->no, 1->artificial_diffusivity, 2->streamline upwinding, 3->discontinuous Galerkin')) 38 string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested')) 37 39 38 40 return string … … 67 69 md = checkfield(md,'prognostic.stabilization','values',[0,1,2,3]) 68 70 md = checkfield(md,'prognostic.min_thickness','>',0) 71 if not md.prognostic.requested_outputs: 72 md = checkfield(md,'prognostic.requested_outputs','size',[float('NaN'),1]) 69 73 70 74 return md … … 78 82 WriteData(fid,'object',self,'fieldname','vertex_pairing','format','DoubleMat','mattype',3) 79 83 WriteData(fid,'object',self,'fieldname','penalty_factor','format','Double') 84 WriteData(fid,'object',self,'fieldname','requested_outputs','format','DoubleMat','mattype',3); 80 85 # }}} 81 86 -
issm/trunk/src/m/classes/qmu.m
r13395 r13975 33 33 end % }}} 34 34 function obj = setdefaultparameters(obj) % {{{ 35 35 36 36 end % }}} 37 37 function md = checkconsistency(obj,md,solution,analyses) % {{{ … … 142 142 function marshall(obj,fid) % {{{ 143 143 WriteData(fid,'object',obj,'fieldname','isdakota','format','Boolean'); 144 if ~obj.isdakota, return; end 144 if ~obj.isdakota, 145 WriteData(fid,'data',false,'enum',QmuMassFluxSegmentsPresentEnum,'format','Boolean'); 146 return; 147 end 145 148 WriteData(fid,'object',obj,'fieldname','partition','format','DoubleMat','mattype',2); 146 149 WriteData(fid,'object',obj,'fieldname','numberofpartitions','format','Integer'); … … 148 151 WriteData(fid,'object',obj,'fieldname','variabledescriptors','format','StringArray'); 149 152 WriteData(fid,'object',obj,'fieldname','responsedescriptors','format','StringArray'); 150 WriteData(fid,'object',obj,'fieldname','mass_flux_segments','format','MatArray'); 153 if ~isempty(obj.mass_flux_segments), 154 WriteData(fid,'data',obj.mass_flux_segments,'enum',MassFluxSegmentsEnum,'format','MatArray'); 155 flag=true; 156 else 157 flag=false; 158 end 159 WriteData(fid,'data',flag,'enum',QmuMassFluxSegmentsPresentEnum,'format','Boolean'); 151 160 end % }}} 152 161 end -
issm/trunk/src/m/classes/qmu.py
r13395 r13975 45 45 return self 46 46 #}}} 47 48 47 def checkconsistency(self,md,solution,analyses): # {{{ 49 48 … … 68 67 return md 69 68 # }}} 70 71 69 def __repr__(self): # {{{ 72 70 s =' qmu parameters:\n' … … 141 139 return s 142 140 # }}} 143 144 141 def marshall(self,fid): # {{{ 145 142 WriteData(fid,'object',self,'fieldname','isdakota','format','Boolean') 146 143 if not self.isdakota: 144 WriteData(fid,'data',False,'enum',QmuMassFluxSegmentsPresentEnum(),'format','Boolean'); 147 145 return 148 146 WriteData(fid,'object',self,'fieldname','partition','format','DoubleMat','mattype',2) … … 151 149 WriteData(fid,'object',self,'fieldname','variabledescriptors','format','StringArray') 152 150 WriteData(fid,'object',self,'fieldname','responsedescriptors','format','StringArray') 153 WriteData(fid,'object',self,'fieldname','mass_flux_segments','format','MatArray') 151 if not self.mass_flux_segments: 152 WriteData(fid,'data',self.mass_flux_segments,'enum',MassFluxSegmentsEnum(),'format','MatArray'); 153 flag=True; 154 else: 155 flag=False; 156 WriteData(fid,'data',flag,'enum',QmuMassFluxSegmentsPresentEnum(),'format','Boolean'); 154 157 # }}} 155 158 -
issm/trunk/src/m/classes/qmu/@dakota_method/dakota_method.m
r3094 r13975 49 49 params =struct(); 50 50 end 51 51 52 52 methods 53 53 function [dm]=dakota_method(method) … … 828 828 829 829 end 830 830 831 831 % if more than one argument, issue warning 832 832 … … 852 852 disp(sprintf(' responses: %s' ,string_cell(dm(i).responses))); 853 853 disp(sprintf(' ghspec: %s\n' ,string_cell(dm(i).ghspec))); 854 854 855 855 % display the parameters within the object 856 856 … … 860 860 maxlen=max(maxlen,length(fnames{j})); 861 861 end 862 862 863 863 for j=1:numel(fnames) 864 864 disp(sprintf([' params.%-' num2str(maxlen+1) 's: %s'],... … … 870 870 end 871 871 end 872 -
issm/trunk/src/m/classes/qmu/@dakota_method/dmeth_params_write.m
r5424 r13975 46 46 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method); 47 47 end 48 48 49 49 case {'npsol'} 50 50 param_write(fid,sbeg,'max_iterations',' = ','\n',dm.params); … … 64 64 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method); 65 65 end 66 66 67 67 case {'conmin'} 68 68 param_write(fid,sbeg,'max_iterations',' = ','\n',dm.params); … … 80 80 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method); 81 81 end 82 82 83 83 case {'optpp'} 84 84 param_write(fid,sbeg,'max_iterations',' = ','\n',dm.params); … … 120 120 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method); 121 121 end 122 122 123 123 case {'apps'} 124 124 param_write(fid,sbeg,'max_function_evaluations',' = ','\n',dm.params); … … 140 140 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method); 141 141 end 142 142 143 143 case {'coliny'} 144 144 param_write(fid,sbeg,'max_iterations',' = ','\n',dm.params); … … 212 212 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method); 213 213 end 214 214 215 215 case {'ncsu'} 216 216 param_write(fid,sbeg,'max_iterations',' = ','\n',dm.params); … … 226 226 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method); 227 227 end 228 228 229 229 case {'jega'} 230 230 param_write(fid,sbeg,'max_iterations',' = ','\n',dm.params); … … 282 282 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method); 283 283 end 284 284 285 285 case {'lsq'} 286 286 switch dm.method … … 344 344 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method); 345 345 end 346 346 347 347 case {'nond'} 348 348 switch dm.method … … 426 426 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method); 427 427 end 428 428 429 429 case {'dace'} 430 430 switch dm.method … … 484 484 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method); 485 485 end 486 486 487 487 case {'param'} 488 488 param_write(fid,sbeg,'output',' ','\n',dm.params); … … 512 512 case {'multidim_parameter_study'} 513 513 param_write(fid,sbeg,'partitions',' = ','\n',dm.params); 514 514 515 515 otherwise 516 516 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method); -
issm/trunk/src/m/classes/qmu/continuous_design.m
r9548 r13975 39 39 scale = 1.; 40 40 end 41 41 42 42 methods 43 43 function [cdv]=continuous_design(varargin) … … 65 65 cdv(asizec{:})=continuous_design; 66 66 clear asizec 67 67 68 68 if ischar(varargin{1}) 69 69 varargin{1}=cellstr(varargin{1}); … … 212 212 end 213 213 end 214 214 215 215 methods (Static) 216 216 function []=dakota_write(fidi,dvar) -
issm/trunk/src/m/classes/qmu/continuous_state.m
r9548 r13975 35 35 upper = Inf; 36 36 end 37 37 38 38 methods 39 39 function [csv]=continuous_state(varargin) … … 61 61 csv(asizec{:})=continuous_state; 62 62 clear asizec 63 63 64 64 if ischar(varargin{1}) 65 65 varargin{1}=cellstr(varargin{1}); … … 177 177 end 178 178 end 179 179 180 180 methods (Static) 181 181 function []=dakota_write(fidi,dvar) -
issm/trunk/src/m/classes/qmu/least_squares_term.m
r9548 r13975 35 35 weight = 1.; 36 36 end 37 37 38 38 methods 39 39 function [lst]=least_squares_term(varargin) … … 54 54 lst(asizec{:})=least_squares_term; 55 55 clear asizec 56 56 57 57 if ischar(varargin{1}) 58 58 varargin{1}=cellstr(varargin{1}); … … 169 169 end 170 170 end 171 171 172 172 methods (Static) 173 173 function [rdesc]=dakota_write(fidi,dresp,rdesc) -
issm/trunk/src/m/classes/qmu/linear_equality_constraint.m
r9548 r13975 35 35 scale = 1.; 36 36 end 37 37 38 38 methods 39 39 function [lec]=linear_equality_constraint(varargin) … … 69 69 lec(asizec{:})=linear_equality_constraint; 70 70 clear asizec 71 71 72 72 for i=1:numel(lec) 73 73 if (size(varargin{1},1) > 1) … … 167 167 end 168 168 end 169 169 170 170 methods (Static) 171 171 function []=dakota_write(fidi,dvar) -
issm/trunk/src/m/classes/qmu/linear_inequality_constraint.m
r9548 r13975 37 37 scale = 1.; 38 38 end 39 39 40 40 methods 41 41 function [lic]=linear_inequality_constraint(varargin) … … 77 77 lic(asizec{:})=linear_inequality_constraint; 78 78 clear asizec 79 79 80 80 for i=1:numel(lic) 81 81 if (size(varargin{1},1) > 1) … … 189 189 end 190 190 end 191 191 192 192 methods (Static) 193 193 function []=dakota_write(fidi,dvar) … … 203 203 end 204 204 end 205 -
issm/trunk/src/m/classes/qmu/nonlinear_equality_constraint.m
r9548 r13975 35 35 scale = 1.; 36 36 end 37 37 38 38 methods 39 39 function [nec]=nonlinear_equality_constraint(varargin) … … 61 61 nec(asizec{:})=nonlinear_equality_constraint; 62 62 clear asizec 63 63 64 64 if ischar(varargin{1}) 65 65 varargin{1}=cellstr(varargin{1}); … … 171 171 end 172 172 end 173 173 174 174 methods (Static) 175 175 function [rdesc]=dakota_write(fidi,dresp,rdesc) -
issm/trunk/src/m/classes/qmu/nonlinear_inequality_constraint.m
r9548 r13975 37 37 scale = 1.; 38 38 end 39 39 40 40 methods 41 41 function [nic]=nonlinear_inequality_constraint(varargin) … … 69 69 nic(asizec{:})=nonlinear_inequality_constraint; 70 70 clear asizec 71 71 72 72 if ischar(varargin{1}) 73 73 varargin{1}=cellstr(varargin{1}); … … 189 189 end 190 190 end 191 191 192 192 methods (Static) 193 193 function [rdesc]=dakota_write(fidi,dresp,rdesc) -
issm/trunk/src/m/classes/qmu/normal_uncertain.m
r9548 r13975 37 37 upper = Inf; 38 38 end 39 39 40 40 methods 41 41 function [nuv]=normal_uncertain(varargin) … … 69 69 nuv(asizec{:})=normal_uncertain; 70 70 clear asizec 71 71 72 72 if ischar(varargin{1}) 73 73 varargin{1}=cellstr(varargin{1}); … … 193 193 end 194 194 end 195 195 196 196 methods (Static) 197 197 function []=dakota_write(fidi,dvar) -
issm/trunk/src/m/classes/qmu/objective_function.m
r9548 r13975 35 35 weight = 1.; 36 36 end 37 37 38 38 methods 39 39 function [of]=objective_function(varargin) … … 54 54 of(asizec{:})=objective_function; 55 55 clear asizec 56 56 57 57 if ischar(varargin{1}) 58 58 varargin{1}=cellstr(varargin{1}); … … 169 169 end 170 170 end 171 171 172 172 methods (Static) 173 173 function [rdesc]=dakota_write(fidi,dresp,rdesc) -
issm/trunk/src/m/classes/qmu/response_function.m
r9548 r13975 37 37 grell =[]; 38 38 end 39 39 40 40 methods 41 41 function [rf]=response_function(varargin) … … 56 56 rf(asizec{:})=response_function; 57 57 clear asizec 58 58 59 59 if ischar(varargin{1}) 60 60 varargin{1}=cellstr(varargin{1}); … … 166 166 end 167 167 end 168 168 169 169 methods (Static) 170 170 function [rdesc]=dakota_write(fidi,dresp,rdesc) … … 178 178 [rdesc]=rlist_write(fidi,'response_functions','response_function',rf,rdesc); 179 179 end 180 180 181 181 function []=dakota_rlev_write(fidi,dresp,params) 182 182 -
issm/trunk/src/m/classes/qmu/uniform_uncertain.m
r9548 r13975 32 32 upper = Inf; 33 33 end 34 34 35 35 methods 36 36 function [uuv]=uniform_uncertain(varargin) … … 64 64 uuv(asizec{:})=uniform_uncertain; 65 65 clear asizec 66 66 67 67 if ischar(varargin{1}) 68 68 varargin{1}=cellstr(varargin{1}); … … 152 152 end 153 153 end 154 154 155 155 methods (Static) 156 156 function []=dakota_write(fidi,dvar) -
issm/trunk/src/m/classes/rifts.m
r13395 r13975 38 38 md = checkmessage(md,['model should be processed for rifts (run meshprocessrifts)!']); 39 39 end 40 md = checkfield(md,'rifts.riftstruct.fill','values',[WaterEnum() AirEnum() IceEnum() MelangeEnum()]); 40 for i=1:numrifts, 41 md = checkfield(md,sprintf('rifts.riftstruct(%d).fill',i),'values',[WaterEnum() AirEnum() IceEnum() MelangeEnum()]); 42 end 41 43 else 42 44 if ~isnans(obj.riftstruct), 43 md = checkmessage(md,['riftstruct shou d be NaN since numrifts is 0!']);45 md = checkmessage(md,['riftstruct should be NaN since numrifts is 0!']); 44 46 end 45 47 end -
issm/trunk/src/m/classes/rifts.py
r13395 r13975 18 18 def __init__(self): 19 19 # {{{ Properties 20 self.riftstruct = float('NaN')21 self.riftproperties = float('NaN')20 self.riftstruct = [] 21 self.riftproperties = [] 22 22 23 23 #set defaults … … 53 53 #We have segments with rift markers, but no rift structure! 54 54 md.checkmessage("model should be processed for rifts (run meshprocessrifts)!") 55 md = checkfield(md,'rifts.riftstruct.fill','values',[WaterEnum(),AirEnum(),IceEnum(),MelangeEnum()]) 55 for i,rift in enumerate(self.riftstruct): 56 md = checkfield(md,"rifts.riftstruct[%d]['fill']" % i,'values',[WaterEnum(),AirEnum(),IceEnum(),MelangeEnum()]) 56 57 else: 57 if numpy.any(numpy.logical_not(isnans(self.riftstruct))):58 md.checkmessage("riftstruct shou d be NaN since numrifts is 0!")58 if self.riftstruct and numpy.any(numpy.logical_not(isnans(self.riftstruct))): 59 md.checkmessage("riftstruct should be NaN since numrifts is 0!") 59 60 60 61 return md … … 70 71 71 72 numpairs=0 72 for i in xrange(0,numrifts):73 numpairs+=numpy.size( self.riftstruct[i].penaltypairs,0)73 for rift in self.riftstruct: 74 numpairs+=numpy.size(rift['penaltypairs'],axis=0) 74 75 75 76 # 2 for nodes + 2 for elements+ 2 for normals + 1 for length + 1 for fill + 1 for friction + 1 for fraction + 1 for fractionincrement + 1 for state. 76 77 data=numpy.zeros((numpairs,12)) 77 78 count=0 78 for i in xrange(0,numrifts):79 numpairsforthisrift=numpy.size( self.riftstruct[i]['penaltypairs'],0)80 data[count:count+numpairsforthisrift -1,0:6]=self.riftstruct[i]['penaltypairs']81 data[count:count+numpairsforthisrift -1,7]=self.riftstruct[i]['fill']82 data[count:count+numpairsforthisrift -1,8]=self.riftstruct[i]['friction']83 data[count:count+numpairsforthisrift -1,9]=self.riftstruct[i]['fraction']84 data[count:count+numpairsforthisrift -1,10]=self.riftstruct[i]['fractionincrement']85 data[count:count+numpairsforthisrift -1,11]=self.riftstruct[i]['state']79 for rift in self.riftstruct: 80 numpairsforthisrift=numpy.size(rift['penaltypairs'],0) 81 data[count:count+numpairsforthisrift,0:7]=rift['penaltypairs'] 82 data[count:count+numpairsforthisrift,7]=rift['fill'] 83 data[count:count+numpairsforthisrift,8]=rift['friction'] 84 data[count:count+numpairsforthisrift,9]=rift['fraction'] 85 data[count:count+numpairsforthisrift,10]=rift['fractionincrement'] 86 data[count:count+numpairsforthisrift,11]=rift['state'].reshape(-1) 86 87 count+=numpairsforthisrift 87 88 -
issm/trunk/src/m/classes/solver.m
r13395 r13975 98 98 else 99 99 %option with value. value can be string or scalar 100 if is scalar(optionvalue),100 if isnumeric(optionvalue), 101 101 fprintf(fid,'-%s %g\n',optionname,optionvalue); 102 102 elseif ischar(optionvalue), -
issm/trunk/src/m/classes/surfaceforcings.m
r13395 r13975 12 12 isdelta18o = 0; 13 13 hc = NaN; 14 href = NaN; 15 smbref = NaN; 14 16 smb_pos_max = NaN; 15 17 smb_pos_min = NaN; … … 35 37 end % }}} 36 38 function obj = setdefaultparameters(obj) % {{{ 37 39 38 40 %pdd method not used in default mode 39 41 obj.ispdd=0; … … 60 62 elseif(obj.issmbgradients) 61 63 md = checkfield(md,'surfaceforcings.hc','forcing',1,'NaN',1); 64 md = checkfield(md,'surfaceforcings.href','forcing',1,'NaN',1); 65 md = checkfield(md,'surfaceforcings.smbref','forcing',1,'NaN',1); 62 66 md = checkfield(md,'surfaceforcings.smb_pos_max','forcing',1,'NaN',1); 63 67 md = checkfield(md,'surfaceforcings.smb_pos_min','forcing',1,'NaN',1); … … 89 93 fielddisplay(obj,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)'); 90 94 fielddisplay(obj,'hc',' elevation of intersection between accumulation and ablation regime required if smb gradients is activated'); 95 fielddisplay(obj,'href',' reference elevation from which deviation is used to calculate SMB adjustment in smb gradients method'); 96 fielddisplay(obj,'smbref',' reference smb from which deviation is calculated in smb gradients method'); 91 97 fielddisplay(obj,'smb_pos_max',' maximum value of positive smb required if smb gradients is activated'); 92 98 fielddisplay(obj,'smb_pos_min',' minimum value of positive smb required if smb gradients is activated'); … … 117 123 if obj.issmbgradients, 118 124 WriteData(fid,'object',obj,'fieldname','hc','format','DoubleMat','mattype',1); 125 WriteData(fid,'object',obj,'fieldname','href','format','DoubleMat','mattype',1); 126 WriteData(fid,'object',obj,'fieldname','smbref','format','DoubleMat','mattype',1); 119 127 WriteData(fid,'object',obj,'fieldname','smb_pos_max','format','DoubleMat','mattype',1); 120 128 WriteData(fid,'object',obj,'fieldname','smb_pos_min','format','DoubleMat','mattype',1); -
issm/trunk/src/m/classes/surfaceforcings.py
r13395 r13975 22 22 self.isdelta18o = 0 23 23 self.hc = float('NaN') 24 self.href = float('NaN') 25 self.smbref = float('NaN') 24 26 self.smb_pos_max = float('NaN') 25 27 self.smb_pos_min = float('NaN') … … 56 58 string="%s\n%s"%(string,fielddisplay(self,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)')) 57 59 string="%s\n%s"%(string,fielddisplay(self,'hc',' elevation of intersection between accumulation and ablation regime required if smb gradients is activated')) 60 string="%s\n%s"%(string,fielddisplay(self,'href',' reference elevation from which deviation is used to calculate SMB adjustment in smb gradients method')) 61 string="%s\n%s"%(string,fielddisplay(self,'smbref',' reference smb from which deviation is calculated in smb gradients method')) 58 62 string="%s\n%s"%(string,fielddisplay(self,'smb_pos_max',' maximum value of positive smb required if smb gradients is activated')) 59 63 string="%s\n%s"%(string,fielddisplay(self,'smb_pos_min',' minimum value of positive smb required if smb gradients is activated')) … … 94 98 elif self.issmbgradients: 95 99 md = checkfield(md,'surfaceforcings.hc','forcing',1,'NaN',1) 100 md = checkfield(md,'surfaceforcings.href','forcing',1,'NaN',1) 101 md = checkfield(md,'surfaceforcings.smbref','forcing',1,'NaN',1) 96 102 md = checkfield(md,'surfaceforcings.smb_pos_max','forcing',1,'NaN',1) 97 103 md = checkfield(md,'surfaceforcings.smb_pos_min','forcing',1,'NaN',1) … … 130 136 if self.issmbgradients: 131 137 WriteData(fid,'object',self,'fieldname','hc','format','DoubleMat','mattype',1) 138 WriteData(fid,'object',self,'fieldname','href','format','DoubleMat','mattype',1) 139 WriteData(fid,'object',self,'fieldname','smbref','format','DoubleMat','mattype',1) 132 140 WriteData(fid,'object',self,'fieldname','smb_pos_max','format','DoubleMat','mattype',1) 133 141 WriteData(fid,'object',self,'fieldname','smb_pos_min','format','DoubleMat','mattype',1) -
issm/trunk/src/m/classes/thermal.m
r13395 r13975 47 47 md = checkfield(md,'thermal.stabilization','numel',[1],'values',[0 1 2]); 48 48 md = checkfield(md,'thermal.spctemperature','forcing',1); 49 if (ismember(EnthalpyAnalysisEnum(),analyses) & md.thermal.isenthalpy & md.mesh.dimension==3), 50 md = checkfield(md,'thermal.spctemperature','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*(md.geometry.surface-md.mesh.z),'message','spctemperature should be below the adjusted melting point'); 49 if (ismember(EnthalpyAnalysisEnum(),analyses) & (md.thermal.isenthalpy | solution==EnthalpySolutionEnum()) & md.mesh.dimension==3), 50 pos=find(md.thermal.spctemperature(1:md.mesh.numberofvertices,:)~=NaN); 51 replicate=repmat(md.geometry.surface-md.mesh.z,1,size(md.thermal.spctemperature,2)); 52 md = checkfield(md,'thermal.spctemperature(find(md.thermal.spctemperature(1:md.mesh.numberofvertices,:)~=NaN))','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*replicate(pos),'message','spctemperature should be below the adjusted melting point'); 51 53 md = checkfield(md,'thermal.isenthalpy','numel',[1],'values',[0 1]); 52 54 end -
issm/trunk/src/m/classes/thermal.py
r13395 r13975 1 1 #module imports 2 import numpy 2 3 from fielddisplay import fielddisplay 3 4 from EnumDefinitions import * … … 69 70 md = checkfield(md,'thermal.stabilization','numel',[1],'values',[0,1,2]) 70 71 md = checkfield(md,'thermal.spctemperature','forcing',1) 71 if EnthalpyAnalysisEnum() in analyses and md.thermal.isenthalpy and md.mesh.dimension==3: 72 md = checkfield(md,'thermal.spctemperature','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*(md.geometry.surface-md.mesh.z),'message',"spctemperature should be below the adjusted melting point") 72 if EnthalpyAnalysisEnum() in analyses and (md.thermal.isenthalpy or solution==EnthalpySolutionEnum()) and md.mesh.dimension==3: 73 pos=numpy.nonzero(numpy.logical_not(numpy.isnan(md.thermal.spctemperature[0:md.mesh.numberofvertices]))) 74 replicate=numpy.tile(md.geometry.surface-md.mesh.z,(1,numpy.size(md.thermal.spctemperature,axis=1))) 75 md = checkfield(md,'thermal.spctemperature[numpy.nonzero(numpy.logical_not(numpy.isnan(md.thermal.spctemperature[0:md.mesh.numberofvertices,:])))]','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*replicate[pos],'message',"spctemperature should be below the adjusted melting point") 73 76 md = checkfield(md,'thermal.isenthalpy','numel',[1],'values',[0,1]) 74 77 -
issm/trunk/src/m/classes/verbose.m
r13395 r13975 9 9 % control : control method 10 10 % qmu : sensitivity analysis 11 % autodiff : AD analysis 11 12 % 12 13 % Usage: … … 23 24 % {{{ 24 25 %BEGINFIELDS 25 mprocessor = false; 26 module = false; 27 solution = false; 28 solver = false; 29 convergence = false; 30 control = false; 31 qmu = false; 26 mprocessor=false; 27 module=false; 28 solution=false; 29 solver=false; 30 convergence=false; 31 control=false; 32 qmu=false; 33 autodiff=false; 32 34 %ENDFIELDS 33 35 % }}} … … 83 85 if (verbose.control), binary=bitor(binary,32); end 84 86 if (verbose.qmu), binary=bitor(binary,64); end 87 if (verbose.autodiff), binary=bitor(binary,128); end 85 88 %ENDVERB2BIN 86 89 … … 90 93 91 94 %BEGINBIN2VERB 92 verbose.mprocessor =logical(bitand(binary, 1)); 93 verbose.module =logical(bitand(binary, 2)); 94 verbose.solution =logical(bitand(binary, 4)); 95 verbose.solver =logical(bitand(binary, 8)); 96 verbose.convergence=logical(bitand(binary,16)); 97 verbose.control =logical(bitand(binary,32)); 98 verbose.qmu =logical(bitand(binary,64)); 95 if bitand(binary,1), verbose.mprocessor=true; else verbose.mprocessor=false; end 96 if bitand(binary,2), verbose.module=true; else verbose.module=false; end 97 if bitand(binary,4), verbose.solution=true; else verbose.solution=false; end 98 if bitand(binary,8), verbose.solver=true; else verbose.solver=false; end 99 if bitand(binary,16), verbose.convergence=true; else verbose.convergence=false; end 100 if bitand(binary,32), verbose.control=true; else verbose.control=false; end 101 if bitand(binary,64), verbose.qmu=true; else verbose.qmu=false; end 102 if bitand(binary,128), verbose.autodiff=true; else verbose.autodiff=false; end 99 103 %ENDBIN2VERB 100 104 … … 105 109 end % }}} 106 110 function disp(verbose) % {{{ 107 111 108 112 %BEGINDISP 109 113 disp(sprintf('class ''%s'' = ',class(verbose))); … … 115 119 disp(sprintf(' %15s : %s','control',mat2str(verbose.control))); 116 120 disp(sprintf(' %15s : %s','qmu',mat2str(verbose.qmu))); 121 disp(sprintf(' %15s : %s','autodiff',mat2str(verbose.autodiff))); 117 122 %ENDDISP 118 123 -
issm/trunk/src/m/classes/verbose.py
r13395 r13975 16 16 control : control method 17 17 qmu : sensitivity analysis 18 autodiff : AD analysis 18 19 19 20 Usage: … … 36 37 self.control = False 37 38 self.qmu = False 39 self.autodiff = False 38 40 #ENDFIELDS 39 41 … … 61 63 #Cast to logicals 62 64 listproperties=vars(self) 63 for [fieldname,fieldvalue]in listproperties.iteritems():65 for fieldname,fieldvalue in listproperties.iteritems(): 64 66 if isinstance(fieldvalue,bool) or isinstance(fieldvalue,(int,long,float)): 65 67 setattr(self,fieldname,bool(fieldvalue)) 66 68 else: 67 69 raise TypeError("verbose supported field values are logicals only (True or False)") 70 # }}} 71 72 def __repr__(self): # {{{ 73 74 #BEGINDISP 75 s ="class '%s' = \n" % type(self) 76 s+=" %15s : %s\n" % ('mprocessor',self.mprocessor) 77 s+=" %15s : %s\n" % ('module',self.module) 78 s+=" %15s : %s\n" % ('solution',self.solution) 79 s+=" %15s : %s\n" % ('solver',self.solver) 80 s+=" %15s : %s\n" % ('convergence',self.convergence) 81 s+=" %15s : %s\n" % ('control',self.control) 82 s+=" %15s : %s\n" % ('qmu',self.qmu) 83 s+=" %15s : %s\n" % ('autodiff',self.autodiff) 84 #ENDDISP 85 86 return s 68 87 # }}} 69 88 … … 86 105 if self.qmu: 87 106 binary=binary | 64 107 if self.autodiff: 108 binary=binary | 128 88 109 #ENDVERB2BIN 89 110 … … 94 115 95 116 #BEGINBIN2VERB 96 self.mprocessor =bool(binary & 1) 97 self.module =bool(binary & 2) 98 self.solution =bool(binary & 4) 99 self.solver =bool(binary & 8) 100 self.convergence=bool(binary & 16) 101 self.control =bool(binary & 32) 102 self.qmu =bool(binary & 64) 117 self.mprocessor =bool(binary & 1) 118 self.module =bool(binary & 2) 119 self.solution =bool(binary & 4) 120 self.solver =bool(binary & 8) 121 self.convergence=bool(binary & 16) 122 self.control =bool(binary & 32) 123 self.qmu =bool(binary & 64) 124 self.autodiff =bool(binary & 128) 103 125 #ENDBIN2VERB 104 126 # }}} … … 108 130 # }}} 109 131 110 def __repr__(self): # {{{ 111 112 #BEGINDISP 113 s ="class '%s' = \n" % type(self) 114 s+=" %15s : %s\n" % ('mprocessor',self.mprocessor) 115 s+=" %15s : %s\n" % ('module',self.module) 116 s+=" %15s : %s\n" % ('solution',self.solution) 117 s+=" %15s : %s\n" % ('solver',self.solver) 118 s+=" %15s : %s\n" % ('convergence',self.convergence) 119 s+=" %15s : %s\n" % ('control',self.control) 120 s+=" %15s : %s\n" % ('qmu',self.qmu) 121 #ENDDISP 122 123 return s 132 def marshall(self,fid): # {{{ 133 WriteData(fid,'data',self.VerboseToBinary(),'enum',VerboseEnum(),'format','Integer') 124 134 # }}} 125 135 126 def marshall(self,fid): # {{{127 WriteData(fid,'data',self.VerboseToBinary(),'enum',VerboseEnum(),'format','Integer')128 # }}}129 -
issm/trunk/src/m/consistency/ismodelselfconsistent.m
r13395 r13975 28 28 29 29 %Check consistency of the object 30 if verLessThan('matlab', '7.6') 31 md=checkconsistency(md.(field),md,solution,analyses); 32 else 33 md=md.(field).checkconsistency(md,solution,analyses); 34 end 30 md=checkconsistency(md.(field),md,solution,analyses); 35 31 end 36 32 … … 46 42 % Usage: 47 43 % [analyses, numanalyses]=AnalysisConfiguration(solutiontype); 48 49 50 44 51 45 switch solutiontype, -
issm/trunk/src/m/contrib/bamg/YamsCall.m
r13395 r13975 53 53 fprintf(fid,'%i %i %i %i\n',[md.mesh.elements zeros(md.mesh.numberofelements,1)]'); 54 54 numberofelements1=md.mesh.numberofelements; 55 55 56 56 %Deal with rifts 57 57 if ~isnan(md.rifts.riftstruct), 58 58 59 59 %we have the list of triangles that make up the rift. keep those triangles around during refinement. 60 60 triangles=[]; -
issm/trunk/src/m/contrib/bamg/meshread.m
r13395 r13975 1 function Struct=meshread(filename) ;1 function Struct=meshread(filename) 2 2 3 3 %some checks -
issm/trunk/src/m/contrib/bamg/yams.m
r13395 r13975 1 function md=yams(md,varargin) ;1 function md=yams(md,varargin) 2 2 %MESHYAMS - Build model of Antarctica by refining according to observed velocity error estimator 3 3 % … … 102 102 103 103 end 104 104 105 105 disp(['Final mesh, number of elements: ' num2str(md.mesh.numberofelements)]); 106 106 -
issm/trunk/src/m/contrib/gslib/gamv.m
r13395 r13975 1 function output = gamv(x,y,data,varargin) ;1 function output = gamv(x,y,data,varargin) 2 2 %GAMV - use gslib for Kriging 3 3 % -
issm/trunk/src/m/contrib/gslib/gslib.m
r13395 r13975 1 function output = gslib(x,y,data,varargin) ;1 function output = gslib(x,y,data,varargin) 2 2 %GSLIB - use gslib for Kriging 3 3 % -
issm/trunk/src/m/contrib/gslib/pkriging.m
r13395 r13975 1 function [B E]=pkriging(x,y,observations,x_interp,y_interp,varargin) ;1 function [B E]=pkriging(x,y,observations,x_interp,y_interp,varargin) 2 2 %PKRIGING - parallel Kriging 3 3 % -
issm/trunk/src/m/contrib/gslib/varmap.m
r13395 r13975 1 function output = varmap(x,y,data,varargin) ;1 function output = varmap(x,y,data,varargin) 2 2 %VARMAP - use gslib for Kriging 3 3 % -
issm/trunk/src/m/contrib/hack/tres.m
r13395 r13975 22 22 md.initialization.pressure=md.results.DiagnosticSolution.Pressure; 23 23 end 24 if md.rifts.numrifts,24 if ~isempty(md.rifts.riftstruct), 25 25 if isfield(md.results.DiagnosticSolution,'riftproperties'), 26 26 md.rifts.riftproperties=md.results.DiagnosticSolution.riftproperties; 27 end28 end29 if md.inversion.iscontrol==1,30 for control_parameters=md.inversion.control_parameters31 %Will need to be updated... good luck ;)32 md.(EnumToModelField(control_parameters))=md.results.DiagnosticSolution.(EnumToString(control_parameters));33 27 end 34 28 end -
issm/trunk/src/m/contrib/massbalance/outflow.m
r13395 r13975 1 function flag=outflow(md) ;1 function flag=outflow(md) 2 2 %OUTFLOW - flag nodes on outflux boundary 3 3 % -
issm/trunk/src/m/contrib/uci/expremovestraightsegments.m
r13395 r13975 11 11 for i=1:length(a), 12 12 contour=a(i); 13 13 14 14 s=sqrt(contour.x.^2+contour.y.^2); 15 15 d=diff(s); 16 16 17 17 pos=find(abs(d)>cutoff); 18 18 pos=[0;pos;length(contour.x)]; -
issm/trunk/src/m/enum/EnumDefinitions.py
r13395 r13975 19 19 return StringToEnum('AutodiffIsautodiff')[0] 20 20 21 def AutodiffDependentsEnum():22 """23 AUTODIFFDEPENDENTSENUM - Enum of AutodiffDependents24 25 Usage:26 macro=AutodiffDependentsEnum()27 """28 29 return StringToEnum('AutodiffDependents')[0]30 31 21 def AutodiffNumDependentsEnum(): 32 22 """ … … 39 29 return StringToEnum('AutodiffNumDependents')[0] 40 30 41 def AutodiffIndependentsEnum(): 42 """ 43 AUTODIFFINDEPENDENTSENUM - Enum of AutodiffIndependents 44 45 Usage: 46 macro=AutodiffIndependentsEnum() 47 """ 48 49 return StringToEnum('AutodiffIndependents')[0] 31 def AutodiffNumDependentObjectsEnum(): 32 """ 33 AUTODIFFNUMDEPENDENTOBJECTSENUM - Enum of AutodiffNumDependentObjects 34 35 Usage: 36 macro=AutodiffNumDependentObjectsEnum() 37 """ 38 39 return StringToEnum('AutodiffNumDependentObjects')[0] 40 41 def AutodiffDependentObjectNamesEnum(): 42 """ 43 AUTODIFFDEPENDENTOBJECTNAMESENUM - Enum of AutodiffDependentObjectNames 44 45 Usage: 46 macro=AutodiffDependentObjectNamesEnum() 47 """ 48 49 return StringToEnum('AutodiffDependentObjectNames')[0] 50 51 def AutodiffDependentObjectTypesEnum(): 52 """ 53 AUTODIFFDEPENDENTOBJECTTYPESENUM - Enum of AutodiffDependentObjectTypes 54 55 Usage: 56 macro=AutodiffDependentObjectTypesEnum() 57 """ 58 59 return StringToEnum('AutodiffDependentObjectTypes')[0] 60 61 def AutodiffDependentObjectIndicesEnum(): 62 """ 63 AUTODIFFDEPENDENTOBJECTINDICESENUM - Enum of AutodiffDependentObjectIndices 64 65 Usage: 66 macro=AutodiffDependentObjectIndicesEnum() 67 """ 68 69 return StringToEnum('AutodiffDependentObjectIndices')[0] 70 71 def AutodiffDependentObjectsEnum(): 72 """ 73 AUTODIFFDEPENDENTOBJECTSENUM - Enum of AutodiffDependentObjects 74 75 Usage: 76 macro=AutodiffDependentObjectsEnum() 77 """ 78 79 return StringToEnum('AutodiffDependentObjects')[0] 50 80 51 81 def AutodiffNumIndependentsEnum(): … … 59 89 return StringToEnum('AutodiffNumIndependents')[0] 60 90 91 def AutodiffNumIndependentObjectsEnum(): 92 """ 93 AUTODIFFNUMINDEPENDENTOBJECTSENUM - Enum of AutodiffNumIndependentObjects 94 95 Usage: 96 macro=AutodiffNumIndependentObjectsEnum() 97 """ 98 99 return StringToEnum('AutodiffNumIndependentObjects')[0] 100 101 def AutodiffIndependentObjectNamesEnum(): 102 """ 103 AUTODIFFINDEPENDENTOBJECTNAMESENUM - Enum of AutodiffIndependentObjectNames 104 105 Usage: 106 macro=AutodiffIndependentObjectNamesEnum() 107 """ 108 109 return StringToEnum('AutodiffIndependentObjectNames')[0] 110 111 def AutodiffIndependentObjectTypesEnum(): 112 """ 113 AUTODIFFINDEPENDENTOBJECTTYPESENUM - Enum of AutodiffIndependentObjectTypes 114 115 Usage: 116 macro=AutodiffIndependentObjectTypesEnum() 117 """ 118 119 return StringToEnum('AutodiffIndependentObjectTypes')[0] 120 121 def AutodiffIndependentObjectsEnum(): 122 """ 123 AUTODIFFINDEPENDENTOBJECTSENUM - Enum of AutodiffIndependentObjects 124 125 Usage: 126 macro=AutodiffIndependentObjectsEnum() 127 """ 128 129 return StringToEnum('AutodiffIndependentObjects')[0] 130 61 131 def AutodiffJacobianEnum(): 62 132 """ … … 79 149 return StringToEnum('AutodiffXp')[0] 80 150 81 def AutodiffFosForwardOutputEnum(): 82 """ 83 AUTODIFFFOSFORWARDOUTPUTENUM - Enum of AutodiffFosForwardOutput 84 85 Usage: 86 macro=AutodiffFosForwardOutputEnum() 87 """ 88 89 return StringToEnum('AutodiffFosForwardOutput')[0] 151 def AutodiffDriverEnum(): 152 """ 153 AUTODIFFDRIVERENUM - Enum of AutodiffDriver 154 155 Usage: 156 macro=AutodiffDriverEnum() 157 """ 158 159 return StringToEnum('AutodiffDriver')[0] 160 161 def AutodiffFosForwardIndexEnum(): 162 """ 163 AUTODIFFFOSFORWARDINDEXENUM - Enum of AutodiffFosForwardIndex 164 165 Usage: 166 macro=AutodiffFosForwardIndexEnum() 167 """ 168 169 return StringToEnum('AutodiffFosForwardIndex')[0] 170 171 def AutodiffFovForwardIndicesEnum(): 172 """ 173 AUTODIFFFOVFORWARDINDICESENUM - Enum of AutodiffFovForwardIndices 174 175 Usage: 176 macro=AutodiffFovForwardIndicesEnum() 177 """ 178 179 return StringToEnum('AutodiffFovForwardIndices')[0] 180 181 def AutodiffFosReverseIndexEnum(): 182 """ 183 AUTODIFFFOSREVERSEINDEXENUM - Enum of AutodiffFosReverseIndex 184 185 Usage: 186 macro=AutodiffFosReverseIndexEnum() 187 """ 188 189 return StringToEnum('AutodiffFosReverseIndex')[0] 190 191 def AutodiffMassFluxSegmentsPresentEnum(): 192 """ 193 AUTODIFFMASSFLUXSEGMENTSPRESENTENUM - Enum of AutodiffMassFluxSegmentsPresent 194 195 Usage: 196 macro=AutodiffMassFluxSegmentsPresentEnum() 197 """ 198 199 return StringToEnum('AutodiffMassFluxSegmentsPresent')[0] 200 201 def AutodiffKeepEnum(): 202 """ 203 AUTODIFFKEEPENUM - Enum of AutodiffKeep 204 205 Usage: 206 macro=AutodiffKeepEnum() 207 """ 208 209 return StringToEnum('AutodiffKeep')[0] 90 210 91 211 def BalancethicknessSpcthicknessEnum(): … … 199 319 return StringToEnum('ConstantsYts')[0] 200 320 321 def DependentObjectEnum(): 322 """ 323 DEPENDENTOBJECTENUM - Enum of DependentObject 324 325 Usage: 326 macro=DependentObjectEnum() 327 """ 328 329 return StringToEnum('DependentObject')[0] 330 201 331 def DiagnosticAbstolEnum(): 202 332 """ … … 589 719 return StringToEnum('HydrologyStabilization')[0] 590 720 721 def IndependentObjectEnum(): 722 """ 723 INDEPENDENTOBJECTENUM - Enum of IndependentObject 724 725 Usage: 726 macro=IndependentObjectEnum() 727 """ 728 729 return StringToEnum('IndependentObject')[0] 730 591 731 def InversionControlParametersEnum(): 592 732 """ … … 1319 1459 return StringToEnum('PrognosticVertexPairing')[0] 1320 1460 1461 def PrognosticNumRequestedOutputsEnum(): 1462 """ 1463 PROGNOSTICNUMREQUESTEDOUTPUTSENUM - Enum of PrognosticNumRequestedOutputs 1464 1465 Usage: 1466 macro=PrognosticNumRequestedOutputsEnum() 1467 """ 1468 1469 return StringToEnum('PrognosticNumRequestedOutputs')[0] 1470 1471 def PrognosticRequestedOutputsEnum(): 1472 """ 1473 PROGNOSTICREQUESTEDOUTPUTSENUM - Enum of PrognosticRequestedOutputs 1474 1475 Usage: 1476 macro=PrognosticRequestedOutputsEnum() 1477 """ 1478 1479 return StringToEnum('PrognosticRequestedOutputs')[0] 1480 1321 1481 def QmuIsdakotaEnum(): 1322 1482 """ … … 1329 1489 return StringToEnum('QmuIsdakota')[0] 1330 1490 1331 def QmuMassFluxSegmentsEnum(): 1332 """ 1333 QMUMASSFLUXSEGMENTSENUM - Enum of QmuMassFluxSegments 1334 1335 Usage: 1336 macro=QmuMassFluxSegmentsEnum() 1337 """ 1338 1339 return StringToEnum('QmuMassFluxSegments')[0] 1491 def MassFluxSegmentsEnum(): 1492 """ 1493 MASSFLUXSEGMENTSENUM - Enum of MassFluxSegments 1494 1495 Usage: 1496 macro=MassFluxSegmentsEnum() 1497 """ 1498 1499 return StringToEnum('MassFluxSegments')[0] 1500 1501 def MassFluxSegmentsPresentEnum(): 1502 """ 1503 MASSFLUXSEGMENTSPRESENTENUM - Enum of MassFluxSegmentsPresent 1504 1505 Usage: 1506 macro=MassFluxSegmentsPresentEnum() 1507 """ 1508 1509 return StringToEnum('MassFluxSegmentsPresent')[0] 1510 1511 def QmuMassFluxSegmentsPresentEnum(): 1512 """ 1513 QMUMASSFLUXSEGMENTSPRESENTENUM - Enum of QmuMassFluxSegmentsPresent 1514 1515 Usage: 1516 macro=QmuMassFluxSegmentsPresentEnum() 1517 """ 1518 1519 return StringToEnum('QmuMassFluxSegmentsPresent')[0] 1340 1520 1341 1521 def QmuNumberofpartitionsEnum(): … … 1679 1859 return StringToEnum('SurfaceforcingsHc')[0] 1680 1860 1861 def SurfaceforcingsHrefEnum(): 1862 """ 1863 SURFACEFORCINGSHREFENUM - Enum of SurfaceforcingsHref 1864 1865 Usage: 1866 macro=SurfaceforcingsHrefEnum() 1867 """ 1868 1869 return StringToEnum('SurfaceforcingsHref')[0] 1870 1871 def SurfaceforcingsSmbrefEnum(): 1872 """ 1873 SURFACEFORCINGSSMBREFENUM - Enum of SurfaceforcingsSmbref 1874 1875 Usage: 1876 macro=SurfaceforcingsSmbrefEnum() 1877 """ 1878 1879 return StringToEnum('SurfaceforcingsSmbref')[0] 1880 1681 1881 def SurfaceforcingsSmbPosMaxEnum(): 1682 1882 """ … … 2539 2739 return StringToEnum('DoubleInput')[0] 2540 2740 2741 def DataSetParamEnum(): 2742 """ 2743 DATASETPARAMENUM - Enum of DataSetParam 2744 2745 Usage: 2746 macro=DataSetParamEnum() 2747 """ 2748 2749 return StringToEnum('DataSetParam')[0] 2750 2541 2751 def DoubleMatArrayParamEnum(): 2542 2752 """ … … 2829 3039 return StringToEnum('PentaP1Input')[0] 2830 3040 3041 def ProfilerEnum(): 3042 """ 3043 PROFILERENUM - Enum of Profiler 3044 3045 Usage: 3046 macro=ProfilerEnum() 3047 """ 3048 3049 return StringToEnum('Profiler')[0] 3050 2831 3051 def MatrixParamEnum(): 2832 3052 """ … … 4509 4729 return StringToEnum('OutputFilePointer')[0] 4510 4730 4731 def OutputFileNameEnum(): 4732 """ 4733 OUTPUTFILENAMEENUM - Enum of OutputFileName 4734 4735 Usage: 4736 macro=OutputFileNameEnum() 4737 """ 4738 4739 return StringToEnum('OutputFileName')[0] 4740 4741 def LockFileNameEnum(): 4742 """ 4743 LOCKFILENAMEENUM - Enum of LockFileName 4744 4745 Usage: 4746 macro=LockFileNameEnum() 4747 """ 4748 4749 return StringToEnum('LockFileName')[0] 4750 4511 4751 def PetscOptionsAnalysesEnum(): 4512 4752 """ … … 4757 4997 """ 4758 4998 4759 return 4 744760 4999 return 498 5000 -
issm/trunk/src/m/enum/MaximumNumberOfEnums.m
r13395 r13975 9 9 % macro=MaximumNumberOfEnums() 10 10 11 macro=4 74;11 macro=498; -
issm/trunk/src/m/enum/OutputfilenameEnum.m
r8926 r13975 1 function macro=Output filenameEnum()2 %OUTPUTFILENAMEENUM - Enum of Output filename1 function macro=OutputFileNameEnum() 2 %OUTPUTFILENAMEENUM - Enum of OutputFileName 3 3 % 4 4 % WARNING: DO NOT MODIFY THIS FILE … … 7 7 % 8 8 % Usage: 9 % macro=Output filenameEnum()9 % macro=OutputFileNameEnum() 10 10 11 macro=StringToEnum('Output filename');11 macro=StringToEnum('OutputFileName'); -
issm/trunk/src/m/exp/expcoarsen.m
r13395 r13975 1 function expcoarsen(newfile,oldfile,resolution) ;1 function expcoarsen(newfile,oldfile,resolution) 2 2 %EXPCOARSEN - coarsen an exp contour 3 3 % -
issm/trunk/src/m/exp/expcontract.m
r13395 r13975 6 6 % 7 7 % See also EXPMASTER, EXPDOC 8 9 8 10 9 contour=expread(oldfile); -
issm/trunk/src/m/exp/expcreatecontour.m
r13395 r13975 1 function expcreatecontour(filename) ;1 function expcreatecontour(filename) 2 2 %EXPCREATECONTOUR - create a contour from a list of points 3 3 % … … 34 34 %write contour using expwrite 35 35 expwrite(a,filename); 36 -
issm/trunk/src/m/exp/expcreateprofile.m
r13395 r13975 1 function expcreateprofile(filename) ;1 function expcreateprofile(filename) 2 2 %EXPCREATEPROFILE - create an Argus file from a list of points 3 3 % -
issm/trunk/src/m/exp/expexcludeoutliers.m
r13395 r13975 7 7 % 8 8 % See also EXPMASTER, EXPDOC 9 10 9 11 10 contour=expread(contourname); -
issm/trunk/src/m/exp/expflip.m
r13395 r13975 5 5 % 6 6 % 7 8 9 10 11 7 12 8 a=expread(domainname,1); -
issm/trunk/src/m/exp/expll2xy.m
r13395 r13975 5 5 % - sgn = Sign of latitude +1 : north latitude (default is mer=45 lat=70) 6 6 % -1 : south latitude (default is mer=0 lat=71) 7 8 7 9 8 %Get central_meridian and standard_parallel depending on hemisphere -
issm/trunk/src/m/exp/expread.m
r13395 r13975 1 function Struct=expread(filename) ;1 function Struct=expread(filename) 2 2 %EXPREAD - read a file exp and build a Structure 3 3 % -
issm/trunk/src/m/exp/expswapxy.m
r13395 r13975 6 6 % 7 7 % See also EXPMASTER, EXPDOC 8 9 8 10 9 contours=expread(filename,1); -
issm/trunk/src/m/exp/exptool.m
r13395 r13975 308 308 backup{counter,4}=closed; 309 309 310 311 310 case 12 312 311 -
issm/trunk/src/m/exp/expwrite.m
r13395 r13975 1 function expwrite(a,filename) ;1 function expwrite(a,filename) 2 2 %EXPWRITE - write an Argus file from a structure given in input 3 3 % … … 20 20 error('contours x and y coordinates must be of identical size'); 21 21 end 22 22 23 23 if isfield(a,'name'), 24 24 if ~isempty(a(n).name), … … 30 30 fprintf(fid,'%s\n','## Name:'); 31 31 end 32 32 33 33 fprintf(fid,'%s\n','## Icon:0'); 34 34 fprintf(fid,'%s\n','# Points Count Value'); -
issm/trunk/src/m/exp/expxy2ll.m
r13395 r13975 5 5 % - sgn = Sign of latitude +1 : north latitude (default is mer=45 lat=70) 6 6 % -1 : south latitude (default is mer=0 lat=71) 7 8 7 9 8 %Get central_meridian and standard_parallel depending on hemisphere -
issm/trunk/src/m/exp/manipulation/addcontour.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=addcontour(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=addcontour(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %ADDCONTOUR - add a closed contour 3 3 % … … 7 7 % Usage: 8 8 % [A,numprofiles,numpoints,closed]=addcontour(A,numprofiles,numpoints,closed,prevplot,root,options) 9 9 10 10 title('click to add a point to the new profile, RETURN to exit','FontSize',14) 11 11 hold on … … 18 18 19 19 [xi,yi] = ginput(1); 20 20 21 21 if ~isempty(xi) 22 22 x(end+1,1)=xi; -
issm/trunk/src/m/exp/manipulation/addendprofile.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=addendprofile(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=addendprofile(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %ADDENDPROFILE - add point at the end of a n existing profile 3 3 % … … 7 7 % Usage: 8 8 % [A,numprofiles,numpoints,closed]=addendprofile(A,numprofiles,numpoints,closed,prevplot,root,options) 9 9 10 10 %some checks 11 11 if numprofiles==0 -
issm/trunk/src/m/exp/manipulation/addinsideprofile.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=addinsideprofile(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=addinsideprofile(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %ADDINSIDEPROFILE - add apoint inside a profile 3 3 % … … 7 7 % Usage: 8 8 % [A,numprofiles,numpoints,closed]=addinsideprofile(A,numprofiles,numpoints,closed,prevplot,root,options) 9 9 10 10 %some checks 11 11 if numprofiles==0 -
issm/trunk/src/m/exp/manipulation/addprofile.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=addprofile(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=addprofile(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %ADDPROFILE - add a profile 3 3 % … … 7 7 % Usage: 8 8 % [A,numprofiles,numpoints,closed]=addprofile(A,numprofiles,numpoints,closed,prevplot,root,options) 9 9 10 10 title('click to add a point to the new profile, RETURN to exit','FontSize',14) 11 11 hold on … … 18 18 19 19 [xi,yi] = ginput(1); 20 20 21 21 if ~isempty(xi) 22 22 x(end+1,1)=xi; -
issm/trunk/src/m/exp/manipulation/closeprofile.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=closeprofile(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=closeprofile(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %CLOSEPROFILE - close one or several profile 3 3 % … … 13 13 return 14 14 end 15 15 16 16 title('click on the profiles to be closed, RETURN to exit','FontSize',14) 17 17 hold on … … 33 33 34 34 [xi,yi] = ginput(1); 35 35 36 36 if ~isempty(xi) 37 37 -
issm/trunk/src/m/exp/manipulation/cutarea.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=cutarea(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=cutarea(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %CUTAREA - cut several point of a profile 3 3 % … … 10 10 % Usage: 11 11 % [A,numprofiles,numpoints,closed]=cutarea(A,numprofiles,numpoints,closed,prevplot,root,options) 12 12 13 13 hold on 14 14 loop=1; -
issm/trunk/src/m/exp/manipulation/cutprofile.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %CUTPROFILE - cut a profile 3 3 % … … 7 7 % Usage: 8 8 % [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root,options) 9 9 10 10 %some checks 11 11 if numprofiles==0 -
issm/trunk/src/m/exp/manipulation/mergeprofiles.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=mergeprofiles(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=mergeprofiles(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %MERGEPROFILES - merge profiles 3 3 % -
issm/trunk/src/m/exp/manipulation/modifyposition.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=modifyposition(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=modifyposition(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %MODIFYPOSITION - modify the prosition of a point of a profile 3 3 % … … 7 7 % Usage: 8 8 % [A,numprofiles,numpoints,closed]=modifyposition(A,numprofiles,numpoints,closed,prevplot,root,options) 9 9 10 10 %some checks 11 11 if numprofiles==0 -
issm/trunk/src/m/exp/manipulation/orientprofile.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=orientprofile(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=orientprofile(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %ORIENTPROFILE - cahnge profile orientation 3 3 % … … 21 21 return 22 22 end 23 23 24 24 [xi,yi] = ginput(1); 25 25 26 26 if ~isempty(xi) 27 27 -
issm/trunk/src/m/exp/manipulation/removepoints.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=removepoints(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=removepoints(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %REMOVEPOINTS - remove a point from a profile 3 3 % … … 7 7 % Usage: 8 8 % [A,numprofiles,numpoints,closed]=removepoints(A,numprofiles,numpoints,closed,prevplot,root,options) 9 9 10 10 %some checks 11 11 if numprofiles==0 -
issm/trunk/src/m/exp/manipulation/removeprofile.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=removeprofile(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=removeprofile(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %REMOVEPROFILE - delete a profile 3 3 % … … 21 21 return 22 22 end 23 23 24 24 [xi,yi] = ginput(1); 25 25 26 26 if ~isempty(xi) 27 27 -
issm/trunk/src/m/exp/manipulation/removeseveralpoints.m
r13395 r13975 1 function [A,numprofiles,numpoints,closed]=removeseveralpoints(A,numprofiles,numpoints,closed,prevplot,root,options) ;1 function [A,numprofiles,numpoints,closed]=removeseveralpoints(A,numprofiles,numpoints,closed,prevplot,root,options) 2 2 %REMOVESEVERALPOINTS - remove several point 3 3 % … … 7 7 % Usage: 8 8 % [A,numprofiles,numpoints,closed]=removeseveralpoints(A,numprofiles,numpoints,closed,prevplot,root,options) 9 9 10 10 %some checks 11 11 if numprofiles==0 -
issm/trunk/src/m/extrusion/DepthAverage.m
r13395 r13975 1 function vector_average=DepthAverage(md,vector) ;1 function vector_average=DepthAverage(md,vector) 2 2 %DEPTHAVERAGE - computes depth average of 3d vector, and return value on 2d mesh. 3 3 % -
issm/trunk/src/m/extrusion/project3d.m
r13395 r13975 1 function projected_vector=project3d(md,varargin) ;1 function projected_vector=project3d(md,varargin) 2 2 %PROJECT3D - vertically project a vector from 2d mesh 3 3 % -
issm/trunk/src/m/geometry/FlagElements.py
r13395 r13975 2 2 import os 3 3 #from basinzoom import * 4 #from ContourToMesh import *4 from ContourToMesh import * 5 5 from MatlabFuncs import * 6 6 … … 41 41 if len(region)>3 and not strcmp(region[-4:],'.exp'): 42 42 raise IOError("Error: File 'region' not found!" % region) 43 raise RuntimeError("FlagElements.py calling basinzoom.py is not complete.") 43 44 xlim,ylim=basinzoom('basin',region) 44 45 flag_nodes=numpy.logical_and(numpy.logical_and(md.mesh.x<xlim[1],md.mesh.x>xlim[0]),numpy.logical_and(md.mesh.y<ylim[1],md.mesh.y>ylim[0])).astype(float) … … 46 47 else: 47 48 #ok, flag elements 48 flag=ContourToMesh(md.mesh.elements[:,0:3],md.mesh.x,md.mesh.y,region,'element',1)49 [flag,dum]=ContourToMesh(md.mesh.elements[:,0:3].copy(),md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),region,'element',1) 49 50 50 51 if invert: 51 52 flag=numpy.logical_not(flag) 52 53 53 elif isinstance(region,numpy.n parray) or isinstance(region,bool):54 elif isinstance(region,numpy.ndarray) or isinstance(region,bool): 54 55 if not numpy.size(region,0)==md.mesh.numberofelements: 55 56 raise TypeError("Flaglist for region must be of same size as number of elements in model.") -
issm/trunk/src/m/geometry/SegIntersect.m
r13395 r13975 49 49 O1C=O2O1'*O1C; 50 50 O1D=O2O1'*O1D; 51 51 52 52 %test if one point is included in the other segment (->bval=1) 53 53 if (O1C-O1A)*(O1D-O1A)<0 -
issm/trunk/src/m/geometry/SegIntersect.py
r13395 r13975 1 1 import numpy 2 from MatlabFuncs import *3 2 4 3 def SegIntersect(seg1,seg2): … … 48 47 49 48 #if colinear 50 if test1*test2==0 and test3*test4==0 and det(numpy.hstack((n1.reshape((-1,1)),n2.reshape(-1,1))))==0:49 if test1*test2==0 and test3*test4==0 and numpy.linalg.det(numpy.hstack((n1.reshape((-1,1)),n2.reshape(-1,1))))==0: 51 50 52 51 #projection on the axis O1O2 -
issm/trunk/src/m/interp/PatchToVec.m
r13395 r13975 1 function vec=PatchToVec(Patch) ;1 function vec=PatchToVec(Patch) 2 2 %PATCHTOVEC - converts a patch to a vector by averaging over each vertex 3 3 % -
issm/trunk/src/m/interp/SectionValues.m
r13395 r13975 22 22 y=infile.y; 23 23 end 24 25 24 26 25 %get the specified resolution -
issm/trunk/src/m/interp/plugvelocities.m
r13395 r13975 165 165 Names.interp='node'; 166 166 end 167 end -
issm/trunk/src/m/inversions/parametercontrolB.m
r13395 r13975 38 38 md.inversion.nsteps=nsteps; 39 39 end 40 41 40 42 41 %cm_min -
issm/trunk/src/m/kml/edgeadjacency.m
r6312 r13975 31 31 inode1=elem(i,j); 32 32 inode2=elem(i,mod(j,size(elem,2))+1); 33 33 34 34 % loop over the elements containing the first node of the edge to see 35 35 % if they contain the second node of the edge -
issm/trunk/src/m/kml/exp2kml.m
r13395 r13975 6 6 % 7 7 8 9 8 %First, read exp file 10 9 domain=expread(input); 11 12 10 13 11 %then transform: -
issm/trunk/src/m/kml/kml2exp.m
r13395 r13975 6 6 % 7 7 8 9 10 11 8 %First, read polygon kml file. 12 9 structure=kml_shapefile(input); 13 10 14 11 %create exp file: 15 12 domain=struct(); -
issm/trunk/src/m/kml/kml_colorstyle.m
r7460 r13975 18 18 colormode ='normal'; 19 19 end 20 20 21 21 methods 22 22 function [kml]=kml_colorstyle(varargin) … … 160 160 161 161 end 162 162 163 163 % string write the object 164 164 … … 196 196 197 197 end 198 198 199 199 end 200 200 201 201 end 202 -
issm/trunk/src/m/kml/kml_container.m
r7460 r13975 21 21 properties 22 22 end 23 23 24 24 methods 25 25 function [kml]=kml_container(varargin) … … 150 150 151 151 end 152 152 153 153 % string write the object 154 154 … … 180 180 181 181 end 182 182 183 183 % delete the object 184 184 … … 193 193 194 194 end 195 195 196 196 end 197 197 198 198 end 199 -
issm/trunk/src/m/kml/kml_document.m
r7460 r13975 23 23 feature ={}; 24 24 end 25 25 26 26 methods 27 27 function [kml]=kml_document(varargin) … … 162 162 163 163 end 164 164 165 165 % string write the object 166 166 … … 202 202 203 203 end 204 204 205 205 % delete the object 206 206 … … 230 230 231 231 end 232 232 233 233 end 234 234 235 235 end 236 -
issm/trunk/src/m/kml/kml_feature.m
r7460 r13975 28 28 style ={}; 29 29 end 30 30 31 31 methods 32 32 function [kml]=kml_feature(varargin) … … 204 204 205 205 end 206 206 207 207 % string write the object 208 208 … … 262 262 263 263 end 264 264 265 265 % delete the object 266 266 … … 289 289 290 290 end 291 291 292 292 end 293 293 294 294 end 295 -
issm/trunk/src/m/kml/kml_file_swrite.m
r7418 r13975 130 130 131 131 end 132 -
issm/trunk/src/m/kml/kml_file_write.m
r7270 r13975 124 124 125 125 end 126 -
issm/trunk/src/m/kml/kml_folder.m
r7460 r13975 23 23 feature ={}; 24 24 end 25 25 26 26 methods 27 27 function [kml]=kml_folder(varargin) … … 162 162 163 163 end 164 164 165 165 % string write the object 166 166 … … 202 202 203 203 end 204 204 205 205 % delete the object 206 206 … … 230 230 231 231 end 232 232 233 233 end 234 234 235 235 end 236 -
issm/trunk/src/m/kml/kml_geometry.m
r7460 r13975 14 14 properties 15 15 end 16 16 17 17 methods 18 18 function [kml]=kml_geometry(varargin) … … 143 143 144 144 end 145 145 146 146 % string write the object 147 147 … … 173 173 174 174 end 175 175 176 176 end 177 177 178 178 end 179 -
issm/trunk/src/m/kml/kml_linearring.m
r7461 r13975 22 22 coords =zeros(0,3); 23 23 end 24 24 25 25 methods 26 26 function [kml]=kml_linearring(varargin) … … 165 165 166 166 end 167 167 168 168 % string write the object 169 169 … … 203 203 204 204 end 205 205 206 206 end 207 207 208 208 end 209 -
issm/trunk/src/m/kml/kml_linestring.m
r7460 r13975 22 22 coords =zeros(0,3); 23 23 end 24 24 25 25 methods 26 26 function [kml]=kml_linestring(varargin) … … 165 165 166 166 end 167 167 168 168 % string write the object 169 169 … … 203 203 204 204 end 205 205 206 206 end 207 207 208 208 end 209 -
issm/trunk/src/m/kml/kml_linestyle.m
r7460 r13975 18 18 width =1; 19 19 end 20 20 21 21 methods 22 22 function [kml]=kml_linestyle(varargin) … … 143 143 144 144 end 145 145 146 146 % string write the object 147 147 … … 170 170 171 171 end 172 172 173 173 end 174 174 175 175 end 176 -
issm/trunk/src/m/kml/kml_mesh_elem.m
r9733 r13975 100 100 cmap=colormap; 101 101 close(hfig) 102 102 103 103 if exist('edata','var') 104 104 if ~exist('cmin','var') … … 175 175 176 176 end 177 -
issm/trunk/src/m/kml/kml_mesh_write.m
r9733 r13975 193 193 cmap=colormap; 194 194 close(hfig) 195 195 196 196 disp(['Writing ' num2str(size(cmap,1)) ' Matlab colors as KML style templates.']); 197 197 for i=1:size(cmap,1) … … 259 259 260 260 end 261 -
issm/trunk/src/m/kml/kml_multigeometry.m
r7460 r13975 16 16 geometry ={}; 17 17 end 18 18 19 19 methods 20 20 function [kml]=kml_multigeometry(varargin) … … 156 156 157 157 end 158 158 159 159 % string write the object 160 160 … … 197 197 198 198 end 199 199 200 200 % delete the object 201 201 … … 225 225 226 226 end 227 227 228 228 end 229 229 230 230 end 231 -
issm/trunk/src/m/kml/kml_object.m
r7460 r13975 15 15 id =''; 16 16 end 17 17 18 18 methods 19 19 function [kml]=kml_object(varargin) … … 144 144 145 145 end 146 146 147 147 % string write the object 148 148 … … 174 174 175 175 end 176 176 177 177 end 178 178 179 179 end 180 -
issm/trunk/src/m/kml/kml_part_edges.m
r12329 r13975 101 101 cmap=colormap; 102 102 close(hfig) 103 103 104 104 if exist('edata','var') 105 105 if ~exist('cmin','var') … … 139 139 for k=1:md.qmu.numberofpartitions 140 140 % disp(['partition k=' int2str(k)]) 141 141 142 142 % for each partition, find all the included elements and determine the 143 143 % perimeter (including those shared by another partition) … … 154 154 [edgeper,elemper,iloop]=edgeperimeter(elemp,nodeconp,edgeadjp); 155 155 iloop(end+1)=size(edgeper,1)+1; 156 156 157 157 % determine the data to be used for the colors (if any) 158 158 … … 170 170 end 171 171 end 172 172 173 173 % set up the placemark with multigeometry 174 174 … … 211 211 lat=[]; 212 212 long=[]; 213 213 214 214 % loop over the element edges on the loop of the partition 215 215 … … 241 241 slast=0; 242 242 j=j+1; 243 243 244 244 % element not entirely within partition, so figure out boundary 245 245 else … … 327 327 end 328 328 nlast=0; 329 329 330 330 % write out midpoint of first side 331 331 kline.coords(end+1,:)=[(md.mesh.long(elemp(ielem,slast))... … … 481 481 482 482 end 483 -
issm/trunk/src/m/kml/kml_part_elems.m
r9733 r13975 101 101 cmap=colormap; 102 102 close(hfig) 103 103 104 104 if exist('edata','var') 105 105 if ~exist('cmin','var') … … 215 215 216 216 end 217 -
issm/trunk/src/m/kml/kml_part_flagedges.m
r9733 r13975 108 108 109 109 end 110 -
issm/trunk/src/m/kml/kml_partitions.m
r12329 r13975 102 102 cmap=colormap; 103 103 close(hfig) 104 104 105 105 if exist('edata','var') 106 106 if ~exist('cmin','var') … … 140 140 for k=1:md.qmu.numberofpartitions 141 141 % disp(['partition k=' int2str(k)]) 142 142 143 143 % for each partition, find all the included elements and determine the 144 144 % perimeter (including those shared by another partition) … … 171 171 end 172 172 end 173 173 174 174 % set up the placemark with multigeometry 175 175 … … 197 197 kmgeom=kml_multigeometry(); 198 198 kmgeom.geometry ={repmat(kml_polygon(),1,length(iloop)-1)}; 199 199 200 200 % loop over each loop of the perimeter for the given partition 201 201 … … 213 213 lat=[]; 214 214 long=[]; 215 215 216 216 % loop over the element edges on the loop of the partition 217 217 … … 243 243 slast=0; 244 244 j=j+1; 245 245 246 246 % element not entirely within partition, so figure out boundary 247 247 else … … 329 329 end 330 330 nlast=0; 331 331 332 332 % write out midpoint of first side 333 333 kring.coords(end+1,:)=[(md.mesh.long(elemp(ielem,slast))... … … 484 484 485 485 end 486 -
issm/trunk/src/m/kml/kml_placemark.m
r7460 r13975 23 23 geometry =kml_geometry.empty(); 24 24 end 25 25 26 26 methods 27 27 function [kml]=kml_placemark(varargin) … … 163 163 164 164 end 165 165 166 166 % string write the object 167 167 … … 204 204 205 205 end 206 206 207 207 % delete the object 208 208 … … 233 233 234 234 end 235 235 236 236 end 237 237 238 238 end 239 -
issm/trunk/src/m/kml/kml_polygon.m
r7460 r13975 24 24 inner =kml_linearring.empty(); 25 25 end 26 26 27 27 methods 28 28 function [kml]=kml_polygon(varargin) … … 183 183 184 184 end 185 185 186 186 % string write the object 187 187 … … 234 234 235 235 end 236 236 237 237 % delete the object 238 238 … … 266 266 267 267 end 268 268 269 269 end 270 270 271 271 end 272 -
issm/trunk/src/m/kml/kml_polystyle.m
r7460 r13975 20 20 outline =true; 21 21 end 22 22 23 23 methods 24 24 function [kml]=kml_polystyle(varargin) … … 148 148 149 149 end 150 150 151 151 % string write the object 152 152 … … 176 176 177 177 end 178 178 179 179 end 180 180 181 181 end 182 -
issm/trunk/src/m/kml/kml_style.m
r7460 r13975 30 30 list =[]; 31 31 end 32 32 33 33 methods 34 34 function [kml]=kml_style(varargin) … … 206 206 207 207 end 208 208 209 209 % string write the object 210 210 … … 268 268 269 269 end 270 270 271 271 % delete the object 272 272 … … 322 322 323 323 end 324 324 325 325 end 326 326 327 327 end 328 -
issm/trunk/src/m/kml/kml_styleselector.m
r7460 r13975 14 14 properties 15 15 end 16 16 17 17 methods 18 18 function [kml]=kml_styleselector(varargin) … … 143 143 144 144 end 145 145 146 146 % string write the object 147 147 … … 173 173 174 174 end 175 175 176 176 end 177 177 178 178 end 179 -
issm/trunk/src/m/kml/kml_substyle.m
r7460 r13975 14 14 properties 15 15 end 16 16 17 17 methods 18 18 function [kml]=kml_substyle(varargin) … … 143 143 144 144 end 145 145 146 146 % string write the object 147 147 … … 173 173 174 174 end 175 175 176 176 end 177 177 178 178 end 179 -
issm/trunk/src/m/kml/kml_unsh_edges.m
r12329 r13975 114 114 115 115 end 116 -
issm/trunk/src/m/kml/string_buf.m
r7336 r13975 173 173 174 174 end 175 175 176 176 % reset the object 177 177 … … 183 183 184 184 end 185 185 186 186 end 187 187 188 188 end 189 -
issm/trunk/src/m/materials/paterson.m
r13395 r13975 2 2 %PATERSON - figure out the rigidity of ice for a given temperature 3 3 % 4 % rigidi gty (in s^(1/3)Pa) is the flow law paramter in the flow law sigma=B*e(1/3) (Paterson, p97).4 % rigidity (in s^(1/3)Pa) is the flow law paramter in the flow law sigma=B*e(1/3) (Paterson, p97). 5 5 % temperature is in Kelvin degrees 6 6 % -
issm/trunk/src/m/materials/paterson.py
r13395 r13975 1 from numpy import * 1 import numpy 2 2 3 3 def paterson(temperature): 4 """ 5 PATERSON - figure out the rigidity of ice for a given temperature 4 6 5 # Local Variables: pos11, pos5, pos10, temperature, pos, T, pos8, pos9, pos6, pos7, pos4, rigidity, pos2, pos3, pos1 6 # Function calls: length, zeros, argwhere, paterson, error 7 #PATERSON - figure out the rigidity of ice for a given temperature 8 # 9 # rigidigty (in s^(1/3)Pa) is the flow law paramter in the flow law sigma=B*e(1/3) (Paterson, p97). 10 # temperature is in Kelvin degrees 11 # 12 # Usage: 13 # rigidity=paterson(temperature) 14 15 pos=argwhere(temperature<0.) 16 if len(pos): 17 print 'input temperature should be in Kelvin (positive)' 18 return [] 19 7 rigidity (in s^(1/3)Pa) is the flow law paramter in the flow law sigma=B*e(1/3) (Paterson, p97). 8 temperature is in Kelvin degrees 9 10 Usage: 11 rigidity=paterson(temperature) 12 """ 13 14 if numpy.any(temperature<0.): 15 raise RuntimeError("input temperature should be in Kelvin (positive)") 16 20 17 T = temperature-273.15 18 21 19 #The routine below is equivalent to: 20 22 21 # n=3; T=temperature-273; 23 22 # %From paterson, … … 31 30 # rigidity=fittedmodel(temperature); 32 31 33 rigidity=zeros(len(T)) 34 pos1=argwhere(T<=-45); rigidity[pos1]=10**8*(-0.000292866376675*(T[pos1]+50)**3+ 0.011672640664130*(T[pos1]+50)**2 -0.325004442485481*(T[pos1]+50)+ 6.524779401948101) 35 pos2=argwhere(logical_and(-45<=T,T<-40)); rigidity[pos2]=10**8*(-0.000292866376675*(T[pos2]+45)**3+ 0.007279645014004*(T[pos2]+45)**2 -0.230243014094813*(T[pos2]+45)+ 5.154964909039554) 36 pos3=argwhere(logical_and(-40<=T,T<-35)); rigidity[pos3]=10**8*(0.000072737147457*(T[pos3]+40)**3+ 0.002886649363879*(T[pos3]+40)**2 -0.179411542205399*(T[pos3]+40)+ 4.149132666831214) 37 pos4=argwhere(logical_and(-35<=T,T<-30)); rigidity[pos4]=10**8*(-0.000086144770023*(T[pos4]+35)**3+ 0.003977706575736*(T[pos4]+35)**2 -0.145089762507325*(T[pos4]+35)+ 3.333333333333331) 38 pos5=argwhere(logical_and(-30<=T,T<-25)); rigidity[pos5]=10**8*(-0.000043984685769*(T[pos5]+30)**3+ 0.002685535025386*(T[pos5]+30)**2 -0.111773554501713*(T[pos5]+30)+ 2.696559088937191) 39 pos6=argwhere(logical_and(-25<=T,T<-20)); rigidity[pos6]=10**8*(-0.000029799523463*(T[pos6]+25)**3+ 0.002025764738854*(T[pos6]+25)**2 -0.088217055680511*(T[pos6]+25)+ 2.199331606342181) 40 pos7=argwhere(logical_and(-20<=T,T<-15)); rigidity[pos7]=10**8*(0.000136920904777*(T[pos7]+20)**3+ 0.001578771886910*(T[pos7]+20)**2 -0.070194372551690*(T[pos7]+20)+ 1.805165505978111) 41 pos8=argwhere(logical_and(-15<=T,T<-10)); rigidity[pos8]=10**8*(-0.000899763781026*(T[pos8]+15)**3+ 0.003632585458564*(T[pos8]+15)**2 -0.044137585824322*(T[pos8]+15)+ 1.510778053489523) 42 pos9=argwhere(logical_and(-10<=T,T<-5)); rigidity[pos9]=10**8*(0.001676964325070*(T[pos9]+10)**3- 0.009863871256831*(T[pos9]+10)**2 -0.075294014815659*(T[pos9]+10)+ 1.268434288203714) 43 pos10=argwhere(logical_and(-5<=T,T<-2)); rigidity[pos10]=10**8*(-0.003748937622487*(T[pos10]+5)**3+0.015290593619213*(T[pos10]+5)**2 -0.048160403003748*(T[pos10]+5)+ 0.854987973338348) 44 pos11=argwhere(-2<=T); rigidity[pos11]=10**8*(-0.003748937622488*(T[pos11]+2)**3-0.018449844983174*(T[pos11]+2)**2 -0.057638157095631*(T[pos11]+2)+ 0.746900791092860) 32 rigidity=numpy.zeros((numpy.size(T,axis=0),1)) 33 pos1=numpy.nonzero(T<=-45) 34 rigidity[pos1]=10**8*(-0.000292866376675*(T[pos1]+50)**3+ 0.011672640664130*(T[pos1]+50)**2 -0.325004442485481*(T[pos1]+50)+ 6.524779401948101) 35 pos2=numpy.nonzero(numpy.logical_and(-45<=T,T<-40)) 36 rigidity[pos2]=10**8*(-0.000292866376675*(T[pos2]+45)**3+ 0.007279645014004*(T[pos2]+45)**2 -0.230243014094813*(T[pos2]+45)+ 5.154964909039554) 37 pos3=numpy.nonzero(numpy.logical_and(-40<=T,T<-35)) 38 rigidity[pos3]=10**8*(0.000072737147457*(T[pos3]+40)**3+ 0.002886649363879*(T[pos3]+40)**2 -0.179411542205399*(T[pos3]+40)+ 4.149132666831214) 39 pos4=numpy.nonzero(numpy.logical_and(-35<=T,T<-30)) 40 rigidity[pos4]=10**8*(-0.000086144770023*(T[pos4]+35)**3+ 0.003977706575736*(T[pos4]+35)**2 -0.145089762507325*(T[pos4]+35)+ 3.333333333333331) 41 pos5=numpy.nonzero(numpy.logical_and(-30<=T,T<-25)) 42 rigidity[pos5]=10**8*(-0.000043984685769*(T[pos5]+30)**3+ 0.002685535025386*(T[pos5]+30)**2 -0.111773554501713*(T[pos5]+30)+ 2.696559088937191) 43 pos6=numpy.nonzero(numpy.logical_and(-25<=T,T<-20)) 44 rigidity[pos6]=10**8*(-0.000029799523463*(T[pos6]+25)**3+ 0.002025764738854*(T[pos6]+25)**2 -0.088217055680511*(T[pos6]+25)+ 2.199331606342181) 45 pos7=numpy.nonzero(numpy.logical_and(-20<=T,T<-15)) 46 rigidity[pos7]=10**8*(0.000136920904777*(T[pos7]+20)**3+ 0.001578771886910*(T[pos7]+20)**2 -0.070194372551690*(T[pos7]+20)+ 1.805165505978111) 47 pos8=numpy.nonzero(numpy.logical_and(-15<=T,T<-10)) 48 rigidity[pos8]=10**8*(-0.000899763781026*(T[pos8]+15)**3+ 0.003632585458564*(T[pos8]+15)**2 -0.044137585824322*(T[pos8]+15)+ 1.510778053489523) 49 pos9=numpy.nonzero(numpy.logical_and(-10<=T,T<-5)) 50 rigidity[pos9]=10**8*(0.001676964325070*(T[pos9]+10)**3- 0.009863871256831*(T[pos9]+10)**2 -0.075294014815659*(T[pos9]+10)+ 1.268434288203714) 51 pos10=numpy.nonzero(numpy.logical_and(-5<=T,T<-2)) 52 rigidity[pos10]=10**8*(-0.003748937622487*(T[pos10]+5)**3+0.015290593619213*(T[pos10]+5)**2 -0.048160403003748*(T[pos10]+5)+ 0.854987973338348) 53 pos11=numpy.nonzero(-2<=T) 54 rigidity[pos11]=10**8*(-0.003748937622488*(T[pos11]+2)**3-0.018449844983174*(T[pos11]+2)**2 -0.057638157095631*(T[pos11]+2)+ 0.746900791092860) 45 55 46 56 #Now make sure that rigidity is positive 47 pos=argwhere(rigidity<0); rigidity[pos]=1**6 57 pos=numpy.nonzero(rigidity<0) 58 rigidity[pos]=1**6 48 59 49 60 return rigidity -
issm/trunk/src/m/mech/basalstress.m
r13395 r13975 6 6 % 7 7 % See also: plot_basaldrag 8 9 8 10 9 %compute exponents -
issm/trunk/src/m/mech/cfl_step.m
r13395 r13975 1 function maxtime=cfl_step(md,vx,vy) ;1 function maxtime=cfl_step(md,vx,vy) 2 2 %CFL_STEP - return the maximum time step for the model in years 3 3 % -
issm/trunk/src/m/mech/mechanicalproperties.m
r13395 r13975 51 51 power=(md.materials.rheology_n-1)./(2*md.materials.rheology_n); 52 52 second_inv=(ux.^2+vy.^2+((uy+vx).^2)/4+ux.*vy); 53 53 54 %some corrections 54 location=find(second_inv~=0);55 nu(location)=B_bar(location)./(second_inv(location).^power(location));56 55 location=find(second_inv==0 & power~=0); 57 56 nu(location)=10^18; %arbitrary maximum viscosity to apply where there is no effective shear 58 location=find(second_inv==0 & power==0); 59 nu(location)=B_bar(location); 57 58 if isa(md.materials,'matice') 59 location=find(second_inv~=0); 60 nu(location)=B_bar(location)./(second_inv(location).^power(location)); 61 location=find(second_inv==0 & power==0); 62 nu(location)=B_bar(location); 63 elseif isa(md.materials,'matdamageice') 64 Zinv=md.materials.rheology_Z(index)*summation/3; 65 location=find(second_inv~=0); 66 nu(location)=Zinv(location).*B_bar(location)./(second_inv(location).^power(location)); 67 location=find(second_inv==0 & power==0); 68 nu(location)=Zinv(location).*B_bar(location); 69 clear Zinv 70 else 71 error(['class of md.materials (' class(md.materials) ') not recognized or not supported']); 72 end 60 73 clear B_bar location second_inv power 61 74 … … 76 89 %eigen values and vectors 77 90 [directions,value]=eig(stress); 91 %sort by absolute value of eigenvalue in descending order 92 [val,idx]=sort(abs(diag(value)),'descend'); 93 %re-order eigenvalues and associated vectors 94 value=value(idx,idx); 95 directions=directions(:,idx); 78 96 valuesstress(i,:)=[value(1,1) value(2,2)]; 79 97 directionsstress(i,:)=directions(:)'; 80 98 [directions,value]=eig(strain); 99 %same for strainrate 100 [val,idx]=sort(abs(diag(value)),'descend'); 101 value=value(idx,idx); 102 directions=directions(:,idx); 81 103 valuesstrain(i,:)=[value(1,1) value(2,2)]; 82 104 directionsstrain(i,:)=directions(:)'; … … 89 111 stress.yy=tau_yy; 90 112 stress.xy=tau_xy; 91 stress.principalvalue 2=valuesstress(:,1);92 stress.principalaxis 2=directionsstress(:,1:2);93 stress.principalvalue 1=valuesstress(:,2);94 stress.principalaxis 1=directionsstress(:,3:4);113 stress.principalvalue1=valuesstress(:,1); 114 stress.principalaxis1=directionsstress(:,1:2); 115 stress.principalvalue2=valuesstress(:,2); 116 stress.principalaxis2=directionsstress(:,3:4); 95 117 stress.effectivevalue=1/sqrt(2)*sqrt(stress.xx.^2+stress.yy.^2+2*stress.xy.^2); 96 118 md.results.stress=stress; … … 100 122 strainrate.yy=vy; 101 123 strainrate.xy=uyvx; 102 strainrate.principalvalue 2=valuesstrain(:,1)*(365.25*24*3600); %strain rate in 1/a instead of 1/s103 strainrate.principalaxis 2=directionsstrain(:,1:2);104 strainrate.principalvalue 1=valuesstrain(:,2)*(365.25*24*3600); %strain rate in 1/a instead of 1/s105 strainrate.principalaxis 1=directionsstrain(:,3:4);124 strainrate.principalvalue1=valuesstrain(:,1)*(365.25*24*3600); %strain rate in 1/a instead of 1/s 125 strainrate.principalaxis1=directionsstrain(:,1:2); 126 strainrate.principalvalue2=valuesstrain(:,2)*(365.25*24*3600); %strain rate in 1/a instead of 1/s 127 strainrate.principalaxis2=directionsstrain(:,3:4); 106 128 strainrate.effectivevalue=1/sqrt(2)*sqrt(strainrate.xx.^2+strainrate.yy.^2+2*strainrate.xy.^2); 107 129 md.results.strainrate=strainrate; … … 111 133 deviatoricstress.yy=tau_yy; 112 134 deviatoricstress.xy=tau_xy; 113 deviatoricstress.principalvalue 2=valuesstress(:,1);114 deviatoricstress.principalaxis 2=directionsstress(:,1:2);115 deviatoricstress.principalvalue 1=valuesstress(:,2);116 deviatoricstress.principalaxis 1=directionsstress(:,3:4);135 deviatoricstress.principalvalue1=valuesstress(:,1); 136 deviatoricstress.principalaxis1=directionsstress(:,1:2); 137 deviatoricstress.principalvalue2=valuesstress(:,2); 138 deviatoricstress.principalaxis2=directionsstress(:,3:4); 117 139 deviatoricstress.effectivevalue=1/sqrt(2)*sqrt(stress.xx.^2+stress.yy.^2+2*stress.xy.^2); 118 140 md.results.deviatoricstress=deviatoricstress; -
issm/trunk/src/m/mesh/ComputeHessian.m
r13395 r13975 20 20 error('ComputeHessian error message: the given field size not supported yet'); 21 21 end 22 if strcmpi(type,'node') &strcmpi(type,'element'),22 if ~strcmpi(type,'node') & ~strcmpi(type,'element'), 23 23 error('ComputeHessian error message: only ''node'' or ''element'' type supported yet'); 24 24 end … … 28 28 linesize=3*numberofelements; 29 29 30 %get areas and 30 %get areas and nodal functions coefficients N(x,y)=alpha x + beta y + gamma 31 31 [alpha beta]=GetNodalFunctionsCoeff(index,x,y); 32 32 areas=GetAreas(index,x,y); 33 33 34 %comput weights that holdsthe volume of all the element holding the node i34 %compute weights that hold the volume of all the element holding the node i 35 35 weights=sparse(line,ones(linesize,1),repmat(areas,3,1),numberofnodes,1); 36 36 -
issm/trunk/src/m/mesh/ComputeMetric.m
r13395 r13975 9 9 % metric=ComputeMetric(hessian,2/9,10^-1,100,10^5,find(md.nodeonwater) 10 10 11 %first, find the eigen values of ea h line of H=[hessian(i,1) hessian(i,2); hessian(i,2)hessian(i,3)]11 %first, find the eigen values of each line of H=[hessian(i,1) hessian(i,2); hessian(i,2) hessian(i,3)] 12 12 a=hessian(:,1); b=hessian(:,2); d=hessian(:,3); 13 lambda1=0.5*((a+d)+sqrt(4 *b.^2+(a-d).^2));14 lambda2=0.5*((a+d)-sqrt(4 *b.^2+(a-d).^2));13 lambda1=0.5*((a+d)+sqrt(4.*b.^2+(a-d).^2)); 14 lambda2=0.5*((a+d)-sqrt(4.*b.^2+(a-d).^2)); 15 15 pos1=find(lambda1==0); 16 16 pos2=find(lambda2==0); … … 18 18 19 19 %Modify the eigen values to control the shape of the elements 20 lambda1=min(max(abs(lambda1)*scale/epsilon,1 /hmax^2),1/hmin^2);21 lambda2=min(max(abs(lambda2)*scale/epsilon,1 /hmax^2),1/hmin^2);20 lambda1=min(max(abs(lambda1)*scale/epsilon,1./hmax^2),1./hmin^2); 21 lambda2=min(max(abs(lambda2)*scale/epsilon,1./hmax^2),1./hmin^2); 22 22 23 23 %compute eigen vectors 24 norm1=sqrt(8 *b.^2+2*(d-a).^2+2*(d-a).*sqrt((a-d).^2+4*b.^2));25 v1x=2 *b./norm1;26 v1y=((d-a)+sqrt((a-d).^2+4 *b.^2))./norm1;27 norm2=sqrt(8 *b.^2+2*(d-a).^2-2*(d-a).*sqrt((a-d).^2+4*b.^2));28 v2x=2 *b./norm2;29 v2y=((d-a)-sqrt((a-d).^2+4 *b.^2))./norm2;24 norm1=sqrt(8.*b.^2+2.*(d-a).^2+2.*(d-a).*sqrt((a-d).^2+4.*b.^2)); 25 v1x=2.*b./norm1; 26 v1y=((d-a)+sqrt((a-d).^2+4.*b.^2))./norm1; 27 norm2=sqrt(8.*b.^2+2.*(d-a).^2-2.*(d-a).*sqrt((a-d).^2+4.*b.^2)); 28 v2x=2.*b./norm2; 29 v2y=((d-a)-sqrt((a-d).^2+4.*b.^2))./norm2; 30 30 31 v1x(pos3)=1 ; v1y(pos3)=0;32 v2x(pos3)=0 ; v2y(pos3)=1;31 v1x(pos3)=1.; v1y(pos3)=0.; 32 v2x(pos3)=0.; v2y(pos3)=1.; 33 33 34 34 %Compute new metric (for each node M=V*Lambda*V^-1) … … 38 38 39 39 %some corrections for 0 eigen values 40 metric(pos1,:)=repmat([1 /hmax^2 0 1/hmax^2],length(pos1),1);41 metric(pos2,:)=repmat([1 /hmax^2 0 1/hmax^2],length(pos2),1);40 metric(pos1,:)=repmat([1./hmax^2 0. 1./hmax^2],length(pos1),1); 41 metric(pos2,:)=repmat([1./hmax^2 0. 1./hmax^2],length(pos2),1); 42 42 43 43 %take care of water elements 44 metric(pos,:)=repmat([1 /hmax^2 0 1/hmax^2],length(pos),1);44 metric(pos,:)=repmat([1./hmax^2 0. 1./hmax^2],length(pos),1); 45 45 46 46 %take care of NaNs if any (use Matlab eig in a loop) … … 54 54 lambda1=v(1,1); 55 55 lambda2=v(2,2); 56 v(1,1)=min(max(abs(lambda1)*scale/epsilon,1 /hmax^2),1/hmin^2);57 v(2,2)=min(max(abs(lambda2)*scale/epsilon,1 /hmax^2),1/hmin^2);56 v(1,1)=min(max(abs(lambda1)*scale/epsilon,1./hmax^2),1./hmin^2); 57 v(2,2)=min(max(abs(lambda2)*scale/epsilon,1./hmax^2),1./hmin^2); 58 58 59 59 metricTria=u*v*u^(-1); -
issm/trunk/src/m/mesh/ElementsFromEdge.m
r13395 r13975 1 function edgeelements=ElementsFromEdge(elements,A,B) 1 function edgeelements=ElementsFromEdge(elements,A,B) 2 2 %ELEMENTSFROMEDGE: find elements connected to one edge defined by nodes A and B 3 3 % 4 % Usage: edgeelements=ElementsFromEdge(elements,A,B)4 % Usage: edgeelements=ElementsFromEdge(elements,A,B) 5 5 % 6 % Eg: edgeelements=ElementsFromEdge(md.mesh.elements,tip1,tip2)6 % Eg: edgeelements=ElementsFromEdge(md.mesh.elements,tip1,tip2) 7 7 % 8 8 % 9 9 edgeelements=find(... 10 (elements(:,1)==A & elements(:,2)==B )| ...11 (elements(:,1)==A & elements(:,3)==B )| ...12 (elements(:,2)==A & elements(:,3)==B )| ...13 (elements(:,2)==A & elements(:,1)==B )| ...14 (elements(:,3)==A & elements(:,1)==B )| ...15 (elements(:,3)==A & elements(:,2)==B ));10 (elements(:,1)==A & elements(:,2)==B )| ... 11 (elements(:,1)==A & elements(:,3)==B )| ... 12 (elements(:,2)==A & elements(:,3)==B )| ... 13 (elements(:,2)==A & elements(:,1)==B )| ... 14 (elements(:,3)==A & elements(:,1)==B )| ... 15 (elements(:,3)==A & elements(:,2)==B )); -
issm/trunk/src/m/mesh/FixMesh.m
r13395 r13975 32 32 %now, the index: 33 33 pos=find(index2>orphan); index2(pos)=index2(pos)-1; 34 34 35 35 %look again for orphans on new mesh 36 36 flags=zeros(length(x2),1);flags(index2)=1; -
issm/trunk/src/m/mesh/MeshQuality.m
r13395 r13975 1 function quality=MeshQuality(md,epsilon,hmin,hmax) ;1 function quality=MeshQuality(md,epsilon,hmin,hmax) 2 2 %MESHQUALITY - compute mesh quality 3 3 % -
issm/trunk/src/m/mesh/NodeInElement.m
r13395 r13975 1 function node_in_element=NodeInElement(newx,newy,elements,x,y,nodeconnectivity) ;1 function node_in_element=NodeInElement(newx,newy,elements,x,y,nodeconnectivity) 2 2 % NODEINELEMENT - find for a list of nodes (in newx,newy), which elements in the mesh (elements,x,y) they belong to. 3 3 % … … 25 25 x0=newx(i); 26 26 y0=newy(i); 27 27 28 28 %first area coordinate 29 29 area_1=(y3y2.*(x0-x3)-x3x2.*(y0-y3))./delta; … … 32 32 %third area coordinate 33 33 area_3=1-area_1-area_2; 34 34 35 35 %get elements for which all area coordinates are positive (meaning (x0,y0) belongs to these elements 36 36 pos=find((area_1>=0-epsilon) & (area_2>=0-epsilon) & (area_3>=0-epsilon)); -
issm/trunk/src/m/mesh/bamg.m
r13395 r13975 55 55 %initialize the structures required as input of Bamg 56 56 bamg_options=struct(); 57 bamg_geometry=bamggeom ;58 bamg_mesh=bamgmesh ;57 bamg_geometry=bamggeom(); 58 bamg_mesh=bamgmesh(); 59 59 60 60 % Bamg Geometry parameters {{{ … … 63 63 %Check that file exists 64 64 domainfile=getfieldvalue(options,'domain'); 65 if ~exist(domainfile,'file') error(['bamg error message: file ' domainfile ' not found 65 if ~exist(domainfile,'file') error(['bamg error message: file ' domainfile ' not found']); end 66 66 domain=expread(domainfile); 67 67 … … 79 79 flags=ContourToNodes(domain(i).x,domain(i).y,domain(1),0); 80 80 if any(~flags), 81 error('bamg error message: All holes should be stric ly inside the principal domain');81 error('bamg error message: All holes should be strictly inside the principal domain'); 82 82 end 83 83 end … … 86 86 nods=domain(i).nods-1; %the domain are closed 1=end; 87 87 bamg_geometry.Vertices=[bamg_geometry.Vertices; [domain(i).x(1:nods) domain(i).y(1:nods) ones(nods,1)]]; 88 bamg_geometry.Edges =[bamg_geometry.Edges; [transpose(count+1:count+nods) transpose([count+2:count+nods count+1]) 1 *ones(nods,1)]];88 bamg_geometry.Edges =[bamg_geometry.Edges; [transpose(count+1:count+nods) transpose([count+2:count+nods count+1]) 1.*ones(nods,1)]]; 89 89 if i>1, bamg_geometry.SubDomains=[bamg_geometry.SubDomains; 2 count+1 1 1]; end 90 90 … … 105 105 for i=1:length(rift), 106 106 107 %detect w ether all points of the rift are inside the domain107 %detect whether all points of the rift are inside the domain 108 108 flags=ContourToNodes(rift(i).x,rift(i).y,domain(1),0); 109 109 if ~flags, 110 error('one Rift has all his points outside of the domain outline'),110 error('one rift has all its points outside of the domain outline'), 111 111 112 112 elseif any(~flags), … … 114 114 disp('Rift tip outside of or on the domain has been detected and is being processed...'); 115 115 116 %check that only one point is outsi e (for now)116 %check that only one point is outside (for now) 117 117 if sum(~flags)~=1, 118 118 error('bamg error message: only one point outside of the domain is supported yet'); … … 137 137 %Get position of the two nodes of the edge in domain 138 138 i1=j; 139 i2= mod(j+1,domain(1).nods);139 i2=j+1; 140 140 141 141 %rift is crossing edge [i1 i2] of the domain … … 152 152 disp('moving tip-domain intersection point'); 153 153 154 %Get position of the close stpoint154 %Get position of the closer point 155 155 if tipdis(1)>tipdis(2), 156 156 pos=i2; … … 160 160 161 161 %This point is only in Vertices (number pos). 162 %OK, no we can add our own rift162 %OK, now we can add our own rift 163 163 nods=rift(i).nods-1; 164 164 bamg_geometry.Vertices=[bamg_geometry.Vertices; [rift(i).x(2:end) rift(i).y(2:end) ones(nods,1)]]; 165 165 bamg_geometry.Edges=[bamg_geometry.Edges;... 166 166 pos count+1 (1+i);... 167 [transpose(count+1:count+nods-1) transpose( [count+2:count+nods]) (1+i)*ones(nods-1,1)]];167 [transpose(count+1:count+nods-1) transpose(count+2:count+nods) (1+i)*ones(nods-1,1)]]; 168 168 count=count+nods; 169 169 … … 175 175 count=count+1; 176 176 177 %Decompose the crossing edge in 2 subedges177 %Decompose the crossing edge into 2 subedges 178 178 pos=find(bamg_geometry.Edges(:,1)==i1 & bamg_geometry.Edges(:,2)==i2); 179 if isempty(pos) error('bamg error message: a problem occur ed...'); end179 if isempty(pos) error('bamg error message: a problem occurred...'); end 180 180 bamg_geometry.Edges=[bamg_geometry.Edges(1:pos-1,:);... 181 bamg_geometry.Edges(pos,1) count 182 count bamg_geometry.Edges(pos,2) 181 bamg_geometry.Edges(pos,1) count bamg_geometry.Edges(pos,3);... 182 count bamg_geometry.Edges(pos,2) bamg_geometry.Edges(pos,3);... 183 183 bamg_geometry.Edges(pos+1:end,:)]; 184 184 185 %OK, no we can add our own rift185 %OK, now we can add our own rift 186 186 nods=rift(i).nods-1; 187 187 bamg_geometry.Vertices=[bamg_geometry.Vertices; [rift(i).x(2:end) rift(i).y(2:end) ones(nods,1)]]; 188 188 bamg_geometry.Edges=[bamg_geometry.Edges;... 189 189 count count+1 2 ;... 190 [transpose(count+1:count+nods-1) transpose( [count+2:count+nods]) (1+i)*ones(nods-1,1)]];190 [transpose(count+1:count+nods-1) transpose(count+2:count+nods) (1+i)*ones(nods-1,1)]]; 191 191 count=count+nods; 192 192 … … 198 198 nods=rift(i).nods-1; 199 199 bamg_geometry.Vertices=[bamg_geometry.Vertices; [rift(i).x(:) rift(i).y(:) ones(nods+1,1)]]; 200 bamg_geometry.Edges=[bamg_geometry.Edges; [transpose(count+1:count+nods) transpose( [count+2:count+nods+1]) (1+i)*ones(nods,1)]];200 bamg_geometry.Edges=[bamg_geometry.Edges; [transpose(count+1:count+nods) transpose(count+2:count+nods+1) (1+i)*ones(nods,1)]]; 201 201 count=count+nods+1; 202 202 end … … 210 210 track=getfieldvalue(options,'tracks'); 211 211 if all(ischar(track)), 212 A=expread(track); 212 A=expread(track); 213 213 track=[A.x A.y]; 214 214 else 215 215 track=double(track); %for some reason, it is of class "single" 216 216 end 217 if(size(track,2)==2), track=[track 3 *ones(size(track,1),1)]; end217 if(size(track,2)==2), track=[track 3.*ones(size(track,1),1)]; end 218 218 219 219 %only keep those inside … … 224 224 nods=size(track,1); 225 225 bamg_geometry.Vertices=[bamg_geometry.Vertices; track]; 226 bamg_geometry.Edges=[bamg_geometry.Edges; [transpose(count+1:count+nods-1) transpose( [count+2:count+nods]) 3*ones(nods-1,1)]];226 bamg_geometry.Edges=[bamg_geometry.Edges; [transpose(count+1:count+nods-1) transpose(count+2:count+nods) 3.*ones(nods-1,1)]]; 227 227 228 228 %update counter … … 235 235 %recover RequiredVertices 236 236 requiredvertices=double(getfieldvalue(options,'RequiredVertices')); %for some reason, it is of class "single" 237 if(size(requiredvertices,2)==2), requiredvertices=[requiredvertices 4 *ones(size(requiredvertices,1),1)]; end238 237 if(size(requiredvertices,2)==2), requiredvertices=[requiredvertices 4.*ones(size(requiredvertices,1),1)]; end 238 239 239 %only keep those inside 240 240 flags=ContourToNodes(requiredvertices(:,1),requiredvertices(:,2),domain(1),0); … … 276 276 % Bamg Options {{{ 277 277 bamg_options.Crack=getfieldvalue(options,'Crack',0); 278 bamg_options.anisomax=getfieldvalue(options,'anisomax',10 ^30);279 bamg_options.coeff=getfieldvalue(options,'coeff',1 );280 bamg_options.cutoff=getfieldvalue(options,'cutoff',10 ^-5);278 bamg_options.anisomax=getfieldvalue(options,'anisomax',10.^30); 279 bamg_options.coeff=getfieldvalue(options,'coeff',1.); 280 bamg_options.cutoff=getfieldvalue(options,'cutoff',10.^-5); 281 281 bamg_options.err=getfieldvalue(options,'err',0.01); 282 282 bamg_options.errg=getfieldvalue(options,'errg',0.1); … … 284 284 bamg_options.gradation=getfieldvalue(options,'gradation',1.5); 285 285 bamg_options.Hessiantype=getfieldvalue(options,'Hessiantype',0); 286 bamg_options.hmin=getfieldvalue(options,'hmin',10 ^-100);287 bamg_options.hmax=getfieldvalue(options,'hmax',10 ^100);286 bamg_options.hmin=getfieldvalue(options,'hmin',10.^-100); 287 bamg_options.hmax=getfieldvalue(options,'hmax',10.^100); 288 288 bamg_options.hminVertices=getfieldvalue(options,'hminVertices',[]); 289 289 bamg_options.hmaxVertices=getfieldvalue(options,'hmaxVertices',[]); 290 290 bamg_options.hVertices=getfieldvalue(options,'hVertices',[]); 291 291 bamg_options.KeepVertices=getfieldvalue(options,'KeepVertices',1); 292 bamg_options.MaxCornerAngle=getfieldvalue(options,'MaxCornerAngle',10 );292 bamg_options.MaxCornerAngle=getfieldvalue(options,'MaxCornerAngle',10.); 293 293 bamg_options.maxnbv=getfieldvalue(options,'maxnbv',10^6); 294 bamg_options.maxsubdiv=getfieldvalue(options,'maxsubdiv',10 );294 bamg_options.maxsubdiv=getfieldvalue(options,'maxsubdiv',10.); 295 295 bamg_options.metric=getfieldvalue(options,'metric',[]); 296 296 bamg_options.Metrictype=getfieldvalue(options,'Metrictype',0); … … 298 298 bamg_options.nbsmooth=getfieldvalue(options,'nbsmooth',3); 299 299 bamg_options.omega=getfieldvalue(options,'omega',1.8); 300 bamg_options.power=getfieldvalue(options,'power',1 );300 bamg_options.power=getfieldvalue(options,'power',1.); 301 301 bamg_options.splitcorners=getfieldvalue(options,'splitcorners',1); 302 302 bamg_options.geometricalmetric=getfieldvalue(options,'geometricalmetric',0); … … 334 334 335 335 %Check for orphan 336 reshape(md.mesh.elements,3*md.mesh.numberofelements,1);337 (~ismember(1:md.mesh.numberofvertices,sort(unique(reshape(md.mesh.elements,3*md.mesh.numberofelements,1)))));338 336 if any(~ismember(1:md.mesh.numberofvertices,sort(unique(reshape(md.mesh.elements,3*md.mesh.numberofelements,1))))) 339 337 error('Output mesh has orphans. Decrease MaxCornerAngle to prevent outside points (ex: 0.01)'); … … 341 339 end 342 340 343 function geom=processgeometry(geom,tol,outline) ;% {{{341 function geom=processgeometry(geom,tol,outline) % {{{ 344 342 345 343 %Deal with edges -
issm/trunk/src/m/mesh/meshconvert.py
r13395 r13975 52 52 md.mesh.elementonsurface=numpy.ones(md.mesh.numberofelements) 53 53 md.mesh.vertexonboundary=numpy.zeros(md.mesh.numberofvertices) 54 md.mesh.vertexonboundary[md.mesh.segments[:,0: 1].astype(int)-1]=154 md.mesh.vertexonboundary[md.mesh.segments[:,0:2].astype(int)-1]=1 55 55 56 56 return md -
issm/trunk/src/m/mesh/planet/mesh_refine_tri4.m
r13395 r13975 29 29 % 30 30 31 32 31 % ---this method is not implemented, but the idea here remains... 33 32 % This can be done until some minimal distance (D) of the mean … … 36 35 % Alternatively, it could be done until some minimum mean 37 36 % area of faces is achieved. As is, it just refines once. 38 39 37 40 38 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $ … … 80 78 81 79 for f = 1:Nface, 82 80 83 81 % Get the triangle vertex indices 84 82 NA = FV.faces(f,1); 85 83 NB = FV.faces(f,2); 86 84 NC = FV.faces(f,3); 87 85 88 86 % Get the triangle vertex coordinates 89 87 A = FV.vertices(NA,:); 90 88 B = FV.vertices(NB,:); 91 89 C = FV.vertices(NC,:); 92 90 93 91 % Now find the midpoints between vertices 94 92 a = (A + B) ./ 2; 95 93 b = (B + C) ./ 2; 96 94 c = (C + A) ./ 2; 97 95 98 96 % Find the length of each median 99 97 %A2blen = sqrt ( sum( (A - b).^2, 2 ) ); 100 98 %B2clen = sqrt ( sum( (B - c).^2, 2 ) ); 101 99 %C2alen = sqrt ( sum( (C - a).^2, 2 ) ); 102 100 103 101 % Store the midpoint vertices, while 104 102 % checking if midpoint vertex already exists … … 106 104 [FV, Nb] = mesh_find_vertex(FV,b); 107 105 [FV, Nc] = mesh_find_vertex(FV,c); 108 106 109 107 % Create new faces with orig vertices plus midpoints 110 108 F2(f*4-3,:) = [ NA, Na, Nc ]; … … 112 110 F2(f*4-1,:) = [ Nc, Nb, NC ]; 113 111 F2(f*4-0,:) = [ Na, Nb, Nc ]; 114 112 115 113 end 116 114 … … 121 119 122 120 return 123 124 121 125 122 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -
issm/trunk/src/m/mesh/planet/planetmixedmesh.m
r13395 r13975 33 33 for j=1:nthetha-1, 34 34 count=(i-1)*(nthetha-1)+j; 35 35 36 36 A=(i-1)*nthetha+j; 37 37 B=(i-1)*nthetha+j+1; 38 38 C=(i)*nthetha+j+1; 39 39 D=(i)*nthetha+j; 40 40 41 41 quads(count,:)=[A B C D]; 42 42 end … … 64 64 quads=[trias;quads]; 65 65 66 67 66 % now add south pole: 68 67 phii=180*conv; … … 85 84 quads=[quads;trias]; 86 85 87 88 86 md.mesh.elements=quads; 89 87 md.mesh.x=x; -
issm/trunk/src/m/mesh/planet/sphere_project.m
r13395 r13975 50 50 % use of arctan functions, which have branches. 51 51 52 53 52 % Convert Cartesian X,Y,Z to spherical (radians) 54 53 theta = atan2( (Y-yo), (X-xo) ); -
issm/trunk/src/m/mesh/planet/sphere_tri.m
r13395 r13975 43 43 % See also: mesh_refine, sphere_project 44 44 % 45 46 47 45 48 46 % $Revision: 1.2 $ $Date: 2005/07/20 23:07:03 $ … … 80 78 end 81 79 82 83 80 % ----------------- 84 81 % define the starting shapes … … 88 85 switch shape, 89 86 case 'tetra', 90 87 91 88 % Vertices of a tetrahedron 92 89 sqrt_3 = 0.5773502692; 93 90 94 91 tetra.v = [ sqrt_3, sqrt_3, sqrt_3 ; % +X, +Y, +Z - PPP 95 92 -sqrt_3, -sqrt_3, sqrt_3 ; % -X, -Y, +Z - MMP 96 93 -sqrt_3, sqrt_3, -sqrt_3 ; % -X, +Y, -Z - MPM 97 94 sqrt_3, -sqrt_3, -sqrt_3 ]; % +X, -Y, -Z - PMM 98 95 99 96 % Structure describing a tetrahedron 100 97 tetra.f = [ 1, 2, 3; … … 102 99 3, 2, 4; 103 100 4, 1, 3 ]; 104 101 105 102 FV.vertices = tetra.v; 106 103 FV.faces = tetra.f; 107 104 108 105 case 'oct', 109 106 110 107 % Six equidistant points lying on the unit sphere 111 108 oct.v = [ 1, 0, 0 ; % X … … 115 112 0, 0, 1 ; % Z 116 113 0, 0, -1 ]; % -Z 117 114 118 115 % Join vertices to create a unit octahedron 119 116 oct.f = [ 1 5 3 ; % X Z Y - First the top half … … 125 122 2 4 6 ; % -X Z -Z 126 123 4 1 6 ]; % -Y Z -Z 127 124 128 125 FV.vertices = oct.v; 129 126 FV.faces = oct.f; 130 127 131 128 case 'ico', 132 129 133 130 % Twelve vertices of icosahedron on unit sphere 134 131 tau = 0.8506508084; % t=(1+sqrt(5))/2, tau=t/sqrt(1+t^2) 135 132 one = 0.5257311121; % one=1/sqrt(1+t^2) , unit sphere 136 133 137 134 ico.v( 1,:) = [ tau, one, 0 ]; % ZA 138 135 ico.v( 2,:) = [ -tau, one, 0 ]; % ZB … … 147 144 ico.v(11,:) = [ 0 , -tau, -one ]; % XC 148 145 ico.v(12,:) = [ 0 , tau, -one ]; % XD 149 146 150 147 % Structure for unit icosahedron 151 148 ico.f = [ 5, 8, 9 ; … … 169 166 8, 10, 3 ; 170 167 7, 3, 11 ]; 171 168 172 169 FV.vertices = ico.v; 173 170 FV.faces = ico.f; 174 171 end 175 176 172 177 173 % ----------------- 178 174 % refine the starting shapes with subdivisions 179 175 if maxlevel, 180 176 181 177 % Subdivide each starting triangle (maxlevel) times 182 178 for level = 1:maxlevel, 183 179 184 180 % Subdivide each triangle and normalize the new points thus 185 181 % generated to lie on the surface of a sphere radius r. 186 182 FV = mesh_refine_tri4(FV); 187 183 FV.vertices = sphere_project(FV.vertices,r); 188 184 189 185 % An alternative might be to define a min distance 190 186 % between vertices and recurse or use fminsearch 191 187 192 188 end 193 189 end -
issm/trunk/src/m/mesh/rifts/meshaddrifts.m
r13395 r13975 1 function md=meshaddrifts(md,riftname) ;1 function md=meshaddrifts(md,riftname) 2 2 %MESHADDRIFTS - add rifts to a preloaded mesh (typically, an argus mesh) 3 3 % … … 12 12 % be preserved. There can be as many pairs of closed contour and rift contour as wished. 13 13 14 15 14 %read rift: 16 15 domains=expread(riftname,1); … … 20 19 %now loop over rifts: 21 20 for rift_i=1:length(rifts), 22 21 23 22 %refine rift to desired resolution: 24 23 contour=contours(rift_i); 25 24 rift=rifts(rift_i); 26 25 27 26 delete('Meshaddrifts.Rift.exp'); 28 27 expwrite(rift,'Meshaddrifts.Rift.Coarse.exp'); 29 28 expcoarsen('Meshaddrifts.Rift.exp','Meshaddrifts.Rift.Coarse.exp',rift.density); 30 29 delete('Meshaddrifts.Rift.Coarse.exp'); 31 30 32 31 %extract model: 33 32 expwrite(contour,'Meshaddrifts.Contour.exp'); 34 33 md2=modelextract(md,'Meshaddrifts.Contour.exp'); 35 34 36 35 %create domain of md2 model: 37 36 md2.mesh.segments=contourenvelope(md2,'Meshaddrifts.Contour.exp'); … … 41 40 domain_index(end+1)=md2.mesh.segments(pos,2); 42 41 end 43 42 44 43 domain.x=md2.mesh.x(domain_index); 45 44 domain.y=md2.mesh.y(domain_index); … … 47 46 domain.density=1; 48 47 expwrite(domain,'Meshaddrifts.Domain.exp'); 49 48 50 49 %unloop domain index: used for later. 51 50 domain_index=domain_index(1:end-1); 52 51 53 52 %remesh md2 using new domain outline, and rift profile: 54 53 md2=meshnodensity(md2,'Meshaddrifts.Domain.exp','Meshaddrifts.Rift.exp'); 55 54 md2=meshprocessrifts(md2); 56 55 57 56 %plug md2 mesh into md mesh: 58 57 [md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.z,md.mesh.numberofelements,md.mesh.numberofvertices,elconv,nodeconv,elconv2,nodeconv2]=meshplug(md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.z,... … … 61 60 %update md2 rifts using elconv and nodeconv, and plug them into md: 62 61 md2.rifts=updateriftindexing(md2.rifts,elconv2,nodeconv2); 63 62 64 63 for i=1:md.rifts.numrifts, 65 64 md.rifts.riftstruct(i)=updateriftindexing(md.rifts.riftstruct(i),elconv,nodeconv); 66 65 end 67 66 68 67 if md.rifts.numrifts==0, 69 68 md.rifts.riftstruct=md2.rifts; … … 73 72 md.rifts.numrifts=md.rifts.numrifts+1; 74 73 end 75 74 76 75 md.mesh.segments(:,1:2)=nodeconv(md.mesh.segments(:,1:2)); 77 76 md.mesh.segments(:,3)=elconv(md.mesh.segments(:,3)); -
issm/trunk/src/m/mesh/rifts/meshplug.m
r13395 r13975 1 function [elements,x,y,z,numberofelements,numberofnodes,elconv,nodeconv,elconv2,nodeconv2]=meshplug(elements,x,y,z,elements2,x2,y2,z2,extractednodes,extractedelements,domain) ;1 function [elements,x,y,z,numberofelements,numberofnodes,elconv,nodeconv,elconv2,nodeconv2]=meshplug(elements,x,y,z,elements2,x2,y2,z2,extractednodes,extractedelements,domain) 2 2 %MESHPLUG - embed mesh into another one 3 3 % See also meshaddrifts 4 5 4 6 5 %initialize elconv,nodeconv conversion tables from md mesh to new md mesh … … 48 47 end 49 48 50 51 49 %plug elements 52 50 elements=[elements;elements2]; 53 54 51 55 52 %now, increase number of nodes … … 87 84 nodeconv(temp_nodeconv)=temp_nodeconvnum; 88 85 nodeconv(extractednodes_minusborder)=NaN; 89 -
issm/trunk/src/m/mesh/rifts/meshprocessoutsiderifts.m
r13395 r13975 6 6 % 7 7 8 %go through rifts, and figure out which ones touch the domain outline 9 for i=1:length(md.rifts.riftstruct), 8 10 9 10 %go through rifts, and figure out which ones touch the domain outline11 for i=1:md.rifts.numrifts,12 13 11 %first, flag nodes that belong to the domain outline 14 12 flags=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,domainoutline,'node',0); … … 20 18 %we have found outsidetips, tips that touch the domain outline. go through them 21 19 for j=1:length(outsidetips), 22 20 23 21 tip=outsidetips(j); 24 22 %find tip in the segments, take first segment (there should be 2) that holds tip, … … 41 39 elements=[]; 42 40 43 while 41 while flags(B), %as long as B does not belong to the domain outline, keep looking. 44 42 %detect elements on edge A,B: 45 43 edgeelements=ElementsFromEdge(md.mesh.elements,A,B); … … 52 50 B=md.mesh.elements(nextelement,find(~ismember(md.mesh.elements(nextelement,:),[A B]))); 53 51 end 54 52 55 53 %take the list of elements on one side of the rift that connect to the tip, 56 54 %and duplicate the tip on them, so as to open the rift to the outside. … … 59 57 md.mesh.y=[md.mesh.y;md.mesh.y(tip)]; 60 58 md.mesh.numberofvertices=num; 61 59 62 60 %replace tip in elements 63 61 newelements=md.mesh.elements(elements,:); … … 69 67 %deal with segments 70 68 tipsegments=find((md.mesh.segments(:,1)==tip) | (md.mesh.segments(:,2)==tip)); 71 for 69 for k=1:length(tipsegments), 72 70 segment_index=tipsegments(k); 73 71 pos=find(md.mesh.segments(segment_index,1:2)~=tip); … … 81 79 end 82 80 83 84 81 %Fill in rest of fields: 85 82 md.mesh.numberofelements=length(md.mesh.elements); … … 87 84 md.mesh.z=zeros(md.mesh.numberofvertices,1); 88 85 md.mesh.vertexonboundary=zeros(length(md.mesh.x),1); md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1; 89 md.rifts.numrifts=length(md.rifts.riftstruct);90 86 md.flowequation.element_equation=3*ones(md.mesh.numberofelements,1); 91 87 md.mesh.vertexonbed=ones(md.mesh.numberofvertices,1); -
issm/trunk/src/m/mesh/rifts/rifttipsonmesh.m
r13395 r13975 4 4 5 5 %read rifts from outline file 6 rifts=expread(riftoutline ,1);6 rifts=expread(riftoutline); 7 7 8 8 tips=[]; … … 13 13 x_tip=rift.x(1); 14 14 y_tip=rift.y(1); 15 15 16 16 index=find_point(md.mesh.x,md.mesh.y,x_tip,y_tip); 17 17 tips(end+1)=index; … … 19 19 x_tip=rift.x(end); 20 20 y_tip=rift.y(end); 21 21 22 22 index=find_point(md.mesh.x,md.mesh.y,x_tip,y_tip); 23 23 tips(end+1)=index; 24 24 25 25 end 26 -
issm/trunk/src/m/mesh/rifts/rifttipsrefine.m
r13395 r13975 1 function md=rifttipsrefine(md,filename,resolution,circleradius) ;1 function md=rifttipsrefine(md,filename,resolution,circleradius) 2 2 %RIFTTIPSREFINE - refine mesh near rift tips 3 3 % -
issm/trunk/src/m/mesh/roundmesh.m
r13395 r13975 12 12 13 13 %Get number of points on the circle 14 pointsonedge=floor((2 *pi*radius) / resolution);14 pointsonedge=floor((2.*pi*radius) / resolution); 15 15 16 16 %Calculate the cartesians coordinates of the points 17 17 x_list=ones(pointsonedge,1); y_list=ones(pointsonedge,1); 18 theta=(0 :2*pi/pointsonedge:2*pi*(1-1/pointsonedge))';19 x_list=r adius*x_list.*cos(theta);20 y_list=r adius*y_list.*sin(theta);21 A=struct('x',x_list,'y',y_list,'density',1 );18 theta=(0.:2.*pi/pointsonedge:2.*pi*(1.-1./pointsonedge))'; 19 x_list=roundsigfig(radius*x_list.*cos(theta),12); 20 y_list=roundsigfig(radius*y_list.*sin(theta),12); 21 A=struct('x',x_list,'y',y_list,'density',1.); 22 22 expwrite(A,'RoundDomainOutline.exp'); 23 23 … … 28 28 %move the closest node to the center 29 29 [mini pos]=min(md.mesh.x.^2+md.mesh.y.^2); 30 md.mesh.x(pos)=0 ;31 md.mesh.y(pos)=0 ;30 md.mesh.x(pos)=0.; 31 md.mesh.y(pos)=0.; 32 32 33 33 %delete domain 34 34 delete('RoundDomainOutline.exp') 35 end 36 37 function x=roundsigfig(x,n) 38 39 digits=ceil(log10(abs(x))); 40 x=x./10.^digits; 41 x=round(x.*10.^n)./10.^n; 42 x=x.*10.^digits; 43 44 pos=find(isnan(x)); 45 x(pos)=0.; 46 47 end 48 -
issm/trunk/src/m/mesh/triangle.py
r13395 r13975 1 from numpy import * 2 import TriMesh as tm 3 import NodeConnectivity as nc 4 import ElementConnectivity as ec 1 import numpy 2 from TriMesh import * 3 from NodeConnectivity import * 4 from ElementConnectivity import * 5 from MatlabFuncs import * 5 6 6 def triangle(md, domainname, resolution,riftname=''): 7 #TRIANGLE - create model mesh using the triangle package 8 # 9 # This routine creates a model mesh using TriMesh and a domain outline, to within a certain resolution 10 # where md is a @model object, domainname is the name of an Argus domain outline file, 11 # and resolution is a characteristic length for the mesh (same unit as the domain outline 12 # unit). Riftname is an optional argument (Argus domain outline) describing rifts. 13 # 14 # Usage: 15 # md=triangle(md,domainname,resolution) 16 # or md=triangle(md,domainname, resolution, riftname) 17 # 18 # Examples: 19 # md=triangle(md,'DomainOutline.exp',1000); 20 # md=triangle(md,'DomainOutline.exp',1000,'Rifts.exp'); 7 def triangle(md,domainname,*args): 8 """ 9 TRIANGLE - create model mesh using the triangle package 21 10 11 This routine creates a model mesh using TriMesh and a domain outline, to within a certain resolution 12 where md is a @model object, domainname is the name of an Argus domain outline file, 13 and resolution is a characteristic length for the mesh (same unit as the domain outline 14 unit). Riftname is an optional argument (Argus domain outline) describing rifts. 15 16 Usage: 17 md=triangle(md,domainname,resolution) 18 or md=triangle(md,domainname, resolution, riftname) 19 20 Examples: 21 md=triangle(md,'DomainOutline.exp',1000); 22 md=triangle(md,'DomainOutline.exp',1000,'Rifts.exp'); 23 """ 22 24 23 25 #Figure out a characteristic area. Resolution is a node oriented concept (ex a 1000m resolution node would 24 26 #be made of 1000*1000 area squares). 25 27 28 if len(args)==1: 29 resolution=args[0] 30 riftname='' 31 if len(args)==2: 32 riftname=args[0] 33 resolution=args[1] 34 26 35 #Check that mesh was not already run, and warn user: 27 if md.mesh.numberofelements != 0.:28 choice = input('This model already has a mesh. Are you sure you want to go ahead? (y/n)')29 if choice != 'y':36 if md.mesh.numberofelements: 37 choice = raw_input('This model already has a mesh. Are you sure you want to go ahead? (y/n)') 38 if not strcmp(choice,'y'): 30 39 print 'no meshing done ... exiting' 31 return []32 33 area = resolution**2 .40 return None 41 42 area = resolution**2 34 43 35 44 #Mesh using TriMesh 36 [md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers]=tm.TriMesh(domainname,riftname,area) 37 45 [md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers]=TriMesh(domainname,riftname,area) 38 46 39 47 #Fill in rest of fields: 40 md.mesh.numberofelements = len(md.mesh.elements)41 md.mesh.numberofvertices = len(md.mesh.x)42 md.mesh.z = zeros(md.mesh.numberofvertices)43 md.mesh.vertexonboundary = zeros(md.mesh.numberofvertices)48 md.mesh.numberofelements = numpy.size(md.mesh.elements,axis=0) 49 md.mesh.numberofvertices = numpy.size(md.mesh.x) 50 md.mesh.z = numpy.zeros(md.mesh.numberofvertices) 51 md.mesh.vertexonboundary = numpy.zeros(md.mesh.numberofvertices) 44 52 md.mesh.vertexonboundary[md.mesh.segments[:,0:2].astype(int)-1] = 1. 45 md.mesh.vertexonbed = ones(md.mesh.numberofvertices)46 md.mesh.vertexonsurface = ones(md.mesh.numberofvertices)47 md.mesh.elementonbed = ones(md.mesh.numberofelements)48 md.mesh.elementonsurface = ones(md.mesh.numberofelements)53 md.mesh.vertexonbed = numpy.ones(md.mesh.numberofvertices) 54 md.mesh.vertexonsurface = numpy.ones(md.mesh.numberofvertices) 55 md.mesh.elementonbed = numpy.ones(md.mesh.numberofelements) 56 md.mesh.elementonsurface = numpy.ones(md.mesh.numberofelements) 49 57 50 58 #Now, build the connectivity tables for this mesh. 51 [md.mesh.vertexconnectivity]= nc.NodeConnectivity(md.mesh.elements, md.mesh.numberofvertices)52 [md.mesh.elementconnectivity] = ec.ElementConnectivity(md.mesh.elements, md.mesh.vertexconnectivity)53 59 [md.mesh.vertexconnectivity]= NodeConnectivity(md.mesh.elements, md.mesh.numberofvertices) 60 [md.mesh.elementconnectivity] = ElementConnectivity(md.mesh.elements, md.mesh.vertexconnectivity) 61 54 62 #type of model 55 63 md.mesh.dimension = 2. 64 56 65 return md 66 -
issm/trunk/src/m/miscellaneous/MatlabFuncs.py
r13395 r13975 53 53 54 54 else: 55 b=numpy.empty_like(a) 56 for i,item in enumerate(a.flat): 57 b.flat[i]=item in s 55 if not isinstance(s,numpy.ndarray): 56 b=numpy.empty_like(a) 57 for i,item in enumerate(a.flat): 58 b.flat[i]=item in s 59 else: 60 b=numpy.in1d(a.flat,s.flat).reshape(a.shape) 58 61 59 62 return b 60 63 64 def det(a): 65 import numpy 66 67 if a.shape==(1,): 68 return a[0] 69 elif a.shape==(1,1): 70 return a[0,0] 71 elif a.shape==(2,2): 72 return a[0,0]*a[1,1]-a[0,1]*a[1,0] 73 else: 74 raise TypeError("MatlabFunc.det only implemented for shape (2, 2), not for shape %s." % str(a.shape)) 75 76 def sparse(ivec,jvec,svec,m=0,n=0,nzmax=0): 77 import numpy 78 79 if not m: 80 m=numpy.max(ivec) 81 if not n: 82 n=numpy.max(jvec) 83 84 a=numpy.zeros((m,n)) 85 86 for i,j,s in zip(ivec.reshape(-1,order='F'),jvec.reshape(-1,order='F'),svec.reshape(-1,order='F')): 87 a[i-1,j-1]+=s 88 89 return a 90 -
issm/trunk/src/m/miscellaneous/fielddisplay.m
r13395 r13975 13 13 end %function 14 14 15 function parsedisplay(offset,name,field,comment) ;%{{{15 function parsedisplay(offset,name,field,comment) %{{{ 16 16 17 17 %string -
issm/trunk/src/m/miscellaneous/fielddisplay.py
r13395 r13975 50 50 elif isinstance(field,(list,tuple)): 51 51 string=list_display(offset,name,field,comment) 52 53 #None 54 elif field is None: 55 string=displayunit(offset,name,"None",comment) 52 56 53 57 else: … … 128 132 string="%s%-23s: %-15s -- %s" % (offset,name,characterization,comment[0]) 129 133 for commenti in comment: 130 string+="\n%s%-23s %-15s %s" % (offset,'','',comment [i])134 string+="\n%s%-23s %-15s %s" % (offset,'','',commenti) 131 135 else: 132 136 raise RuntimeError("fielddisplay error message: format for comment not supported yet") -
issm/trunk/src/m/miscellaneous/isnans.m
r13395 r13975 5 5 % 6 6 % See also : ISNAN 7 8 7 9 8 if isstruct(array), -
issm/trunk/src/m/miscellaneous/issmdoc.m
r13395 r13975 4 4 ISSM_DIR=issmdir(); 5 5 6 disp( sprintf('\n%s',' A comprehensive documentation is available on http://issm.jpl.nasa.gov'));7 disp( sprintf('\n%s',' Example: how to create a square ice shelf'));8 disp( sprintf('%s',' go to ',ISSM_DIR,'/examples/SquareIceshelf'));9 disp(sprintf('% s',' md=model;%creates a new empty model structure'));10 disp(sprintf('% s',' md=triangle(md,''DomainOutline.exp'',50000); %creates a mesh of the domain outline with a resolution of 50000m'));11 disp(sprintf('% s',' md=setmask(md,''all'','''');%defines the glacier system as an ice shelf (no island)'));12 disp(sprintf('% s',' md=parameterize(md,''Square.par'');%fills all the other fields of the model'));13 disp(sprintf('% s',' md=setflowequation(md,''macayeal'',''all''); %defines all elements as MacAyeal''s'));14 disp(sprintf('% s',' md=solve(md,DiagnosticSolutionEnum()); %generate the velocity field'));15 disp(sprintf('% s',' plotmodel(md,''data'',md.results.DiagnosticSolution.Vel);%displays the velocity (type plotdoc for plotmodel help)'));6 disp(' A comprehensive documentation is available on http://issm.jpl.nasa.gov'); 7 disp(' Example: how to create a square ice shelf'); 8 disp([' go to ',ISSM_DIR,'/examples/SquareIceShelf']); 9 disp(sprintf('%-63s %s',' md=model;','%creates a new empty model structure')); 10 disp(sprintf('%-63s %s',' md=triangle(md,''DomainOutline.exp'',50000);','%creates a mesh of the domain outline with a resolution of 50000 m')); 11 disp(sprintf('%-63s %s',' md=setmask(md,''all'','''');','%defines the glacier system as an ice shelf (no island)')); 12 disp(sprintf('%-63s %s',' md=parameterize(md,''Square.par'');','%fills all the other fields of the model')); 13 disp(sprintf('%-63s %s',' md=setflowequation(md,''macayeal'',''all'');','%defines all elements as MacAyeal''s SSA')); 14 disp(sprintf('%-63s %s',' md=solve(md,DiagnosticSolutionEnum());','%solve for stress balance')); 15 disp(sprintf('%-63s %s',' plotmodel(md,''data'',md.results.DiagnosticSolution.Vel);','%displays the velocity (type plotdoc for plotmodel help)')); -
issm/trunk/src/m/miscellaneous/parallelrange.m
r13395 r13975 12 12 end 13 13 14 15 14 %There may be some rows left. Distribute evenly. 16 15 row_rest=globalsize - numprocs*floor(globalsize/numprocs); -
issm/trunk/src/m/os/ismpi.m
r13395 r13975 4 4 % Usage: 5 5 % flag=ismpi(); 6 7 6 8 7 configfile=[issmdir() '/bin/config.h']; %should find it in the install target -
issm/trunk/src/m/os/ismumps.m
r13395 r13975 4 4 % Usage: 5 5 % flag=ismumps(); 6 7 6 8 7 configfile=[issmdir() '/bin/config.h']; %should find it in the install target -
issm/trunk/src/m/os/ispetsc.m
r13395 r13975 4 4 % Usage: 5 5 % flag=ispetsc(); 6 7 6 8 7 configfile=[issmdir() '/bin/config.h']; %should find it in the install target -
issm/trunk/src/m/os/issmbbftpin.m
r13395 r13975 35 35 end 36 36 command=[command ''' pfe1.nas.nasa.gov']; 37 37 38 38 eval(command); 39 39 … … 45 45 end 46 46 47 48 47 end -
issm/trunk/src/m/os/issmbbftpout.m
r13395 r13975 19 19 end 20 20 else 21 21 22 22 %build a string of the type: bbftp -s -u elarour -e 'setnbstream 8; cd /nobackupp10/elarour/Testing/Interactive3/; put Antarctica.tar.gz' pfe1.nas.nasa.gov 23 23 command=['!bbftp -s -V -u ' login ' -e ''setnbstream 8; cd ' path '; '] … … 26 26 end 27 27 command=[command ''' pfe1.nas.nasa.gov']; 28 28 29 29 eval(command); 30 30 end -
issm/trunk/src/m/os/issmscpin.m
r13395 r13975 31 31 if ispc(), 32 32 %use the putty project pscp.exe: it should be in the path. 33 33 34 34 %get ISSM_DIR variable 35 35 [status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]'); … … 62 62 end 63 63 64 65 64 if port, 66 65 eval(['!scp -P ' num2str(port) ' ' login '@localhost:' path '/' string ' ./']); … … 68 67 eval(['!scp ' login '@' host ':' path '/' string ' ./']); 69 68 end 70 69 71 70 %check scp worked 72 71 for i=1:numel(packages), -
issm/trunk/src/m/os/issmscpout.m
r13395 r13975 22 22 if ispc(), 23 23 %use the putty project pscp.exe: it should be in the path. 24 24 25 25 %get ISSM_DIR variable 26 26 [status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]'); … … 48 48 end 49 49 string=[string ' ']; 50 50 51 51 if port, 52 52 eval(['!scp -P ' num2str(port) ' ' string ' ' login '@localhost:' path]); -
issm/trunk/src/m/os/issmssh.m
r13395 r13975 14 14 if ispc(), 15 15 %use the putty project plink.exe: it should be in the path. 16 16 17 17 %get ISSM_DIR variable 18 18 [status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]'); -
issm/trunk/src/m/os/issmssh.py
r13395 r13975 40 40 subprocess.call('ssh -l %s %s "%s"' % (login,host,command),shell=True) 41 41 42 # The following code was added to fix: 43 # "IOError: [Errno 35] Resource temporarily unavailable" 44 # on the Mac when trying to display md after the solution. 45 # (from http://code.google.com/p/robotframework/issues/detail?id=995) 46 47 # Make FreeBSD use blocking I/O like other platforms 48 import sys 49 import fcntl 50 from os import O_NONBLOCK 51 52 fd = sys.stdin.fileno() 53 flags = fcntl.fcntl(fd, fcntl.F_GETFL) 54 fcntl.fcntl(fd, fcntl.F_SETFL, flags & ~O_NONBLOCK) 55 56 fd = sys.stdout.fileno() 57 flags = fcntl.fcntl(fd, fcntl.F_GETFL) 58 fcntl.fcntl(fd, fcntl.F_SETFL, flags & ~O_NONBLOCK) 59 -
issm/trunk/src/m/os/oshostname.m
r13395 r13975 7 7 8 8 if ispc(), 9 [status,hostname]=system('hostname | sed ''s/-//g''');hostname=hostname(1:end-1); 10 9 [status,hostname]=system('hostname | sed ''s/-//g'''); 11 10 if status, 12 11 error('oshostname error message: could not run hostname command on windows os'); 13 12 end 14 15 13 else 16 14 [status,hostname]=system(['hostname -s | sed ''s/-//g''']); … … 18 16 error('oshostname error message: could not run hostname command on *nix os'); 19 17 end 20 hostname=hostname(1:end-1); 21 hostname=ddewhite(hostname); 18 22 19 end 20 21 %remove carriage return and blank spaces 22 hostname=hostname(1:end-1); 23 hostname=ddewhite(hostname); -
issm/trunk/src/m/parameterization/contourenvelope.m
r13395 r13975 20 20 if ischar(flags), 21 21 file=flags; 22 file=varargin{1};23 22 if ~exist(file), 24 23 error(['contourenvelope error message: file ' file ' not found']); … … 29 28 isfile=0; 30 29 else 31 error('contourenvelope error message: second argument should a file or an elements flag');30 error('contourenvelope error message: second argument should be a file or an elements flag'); 32 31 end 33 32 end … … 70 69 else 71 70 %get flag list of elements and nodes inside the contour 72 nodein=zeros(mesh.numberofvertices,1); 73 elemin=zeros(mesh.numberofelements,1); 74 75 pos=find(flags); 71 nodein=zeros(mesh.numberofvertices,1); 72 elemin=zeros(mesh.numberofelements,1); 73 74 pos=find(flags); 76 75 elemin(pos)=1; 77 76 nodein(mesh.elements(pos,:))=1; … … 95 94 pos=find(elementonboundary); 96 95 num_segments=length(pos); 97 segments=zeros(num_segments ,3);96 segments=zeros(num_segments*3,3); 98 97 count=1; 99 98 … … 138 137 end 139 138 end 139 segments=segments(1:count-1,:); 140 -
issm/trunk/src/m/parameterization/parameterize.m
r13395 r13975 56 56 end 57 57 md.miscellaneous.notes=['Model created by using parameter file: ' parametername ' on: ' datestr(now)]; 58 -
issm/trunk/src/m/parameterization/setflowequation.py
r13395 r13975 94 94 numpy.logical_not(numpy.isnan(md.diagnostic.spcvy)).astype(int)+ \ 95 95 numpy.logical_not(numpy.isnan(md.diagnostic.spcvz)).astype(int)==3, \ 96 numpy.logical_and(nodeonpattyn,nodeonstokes) ).astype(int) #find all the nodes on the boundary of the domain without icefront96 numpy.logical_and(nodeonpattyn,nodeonstokes).reshape(-1,1)).astype(int) #find all the nodes on the boundary of the domain without icefront 97 97 # fullspcelems=double(sum(fullspcnodes(md.mesh.elements),2)==6); %find all the nodes on the boundary of the domain without icefront 98 98 fullspcelems=(numpy.sum(fullspcnodes[md.mesh.elements.astype(int)-1],axis=1)==6).astype(int) #find all the nodes on the boundary of the domain without icefront 99 stokesflag[numpy.nonzero(fullspcelems )]=099 stokesflag[numpy.nonzero(fullspcelems.reshape(-1))]=0 100 100 nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:].astype(int)-1]=1 101 101 … … 123 123 numnodes2d=md.mesh.numberofvertices2d 124 124 numlayers=md.mesh.numberoflayers 125 bordernodes2d=numpy.nonzero(numpy.logical_and(nodeonpattyn[ 1:numnodes2d],nodeonmacayeal[1:numnodes2d]))#Nodes connected to two different types of elements125 bordernodes2d=numpy.nonzero(numpy.logical_and(nodeonpattyn[0:numnodes2d],nodeonmacayeal[0:numnodes2d]))[0]+1 #Nodes connected to two different types of elements 126 126 127 127 #initialize and fill in penalties structure … … 129 129 penalties=numpy.zeros((0,2)) 130 130 for i in xrange(1,numlayers): 131 penalties=numpy. concatenate((penalties,numpy.concatenate((bordernodes2d,bordernodes2d+md.mesh.numberofvertices2d*(i)),axis=1)),axis=0)131 penalties=numpy.vstack((penalties,numpy.hstack((bordernodes2d.reshape(-1,1),bordernodes2d.reshape(-1,1)+md.mesh.numberofvertices2d*(i))))) 132 132 md.diagnostic.vertex_pairing=penalties 133 133 … … 137 137 nodeonmacayealpattyn[numpy.nonzero(numpy.logical_and(nodeonmacayeal,nodeonpattyn))]=1 138 138 #Macayeal elements in contact with this layer become MacAyealPattyn elements 139 matrixelements=ismember(md.mesh.elements ,numpy.nonzero(nodeonmacayealpattyn))139 matrixelements=ismember(md.mesh.elements.astype(int)-1,numpy.nonzero(nodeonmacayealpattyn)[0]) 140 140 commonelements=numpy.sum(matrixelements,axis=1)!=0 141 141 commonelements[numpy.nonzero(pattynflag)]=0 #only one layer: the elements previously in macayeal … … 146 146 147 147 #rule out elements that don't touch the 2 boundaries 148 pos=numpy.nonzero(macayealpattynflag) 149 elist=numpy.zeros( len(pos))150 elist = elist + numpy. any(numpy.sum(nodeonmacayeal[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)151 elist = elist - numpy. any(numpy.sum(nodeonpattyn[md.mesh.elements[pos,:].astype(int)-1] ,axis=1),axis=1)152 pos1=numpy.nonzero(elist==1) 148 pos=numpy.nonzero(macayealpattynflag)[0] 149 elist=numpy.zeros(numpy.size(pos),dtype=int) 150 elist = elist + numpy.sum(nodeonmacayeal[md.mesh.elements[pos,:].astype(int)-1],axis=1).astype(bool) 151 elist = elist - numpy.sum(nodeonpattyn[md.mesh.elements[pos,:].astype(int)-1] ,axis=1).astype(bool) 152 pos1=numpy.nonzero(elist==1)[0] 153 153 macayealflag[pos[pos1]]=1 154 154 macayealpattynflag[pos[pos1]]=0 155 pos2=numpy.nonzero(elist==-1) 155 pos2=numpy.nonzero(elist==-1)[0] 156 156 pattynflag[pos[pos2]]=1 157 157 macayealpattynflag[pos[pos2]]=0 … … 169 169 nodeonpattynstokes[numpy.nonzero(numpy.logical_and(nodeonpattyn,nodeonstokes))]=1 170 170 #Stokes elements in contact with this layer become PattynStokes elements 171 matrixelements=ismember(md.mesh.elements ,numpy.nonzero(nodeonpattynstokes))171 matrixelements=ismember(md.mesh.elements.astype(int)-1,numpy.nonzero(nodeonpattynstokes)[0]) 172 172 commonelements=numpy.sum(matrixelements,axis=1)!=0 173 173 commonelements[numpy.nonzero(pattynflag)]=0 #only one layer: the elements previously in macayeal … … 178 178 179 179 #rule out elements that don't touch the 2 boundaries 180 pos=numpy.nonzero(pattynstokesflag) 181 elist=numpy.zeros( len(pos))182 elist = elist + numpy. any(numpy.sum(nodeonstokes[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)183 elist = elist - numpy. any(numpy.sum(nodeonpattyn[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)184 pos1=numpy.nonzero(elist==1) 180 pos=numpy.nonzero(pattynstokesflag)[0] 181 elist=numpy.zeros(numpy.size(pos),dtype=int) 182 elist = elist + numpy.sum(nodeonstokes[md.mesh.elements[pos,:].astype(int)-1],axis=1).astype(bool) 183 elist = elist - numpy.sum(nodeonpattyn[md.mesh.elements[pos,:].astype(int)-1],axis=1).astype(bool) 184 pos1=numpy.nonzero(elist==1)[0] 185 185 stokesflag[pos[pos1]]=1 186 186 pattynstokesflag[pos[pos1]]=0 187 pos2=numpy.nonzero(elist==-1) 187 pos2=numpy.nonzero(elist==-1)[0] 188 188 pattynflag[pos[pos2]]=1 189 189 pattynstokesflag[pos[pos2]]=0 … … 201 201 nodeonmacayealstokes[numpy.nonzero(numpy.logical_and(nodeonmacayeal,nodeonstokes))]=1 202 202 #Stokes elements in contact with this layer become MacAyealStokes elements 203 matrixelements=ismember(md.mesh.elements ,numpy.nonzero(nodeonmacayealstokes))203 matrixelements=ismember(md.mesh.elements.astype(int)-1,numpy.nonzero(nodeonmacayealstokes)[0]) 204 204 commonelements=numpy.sum(matrixelements,axis=1)!=0 205 205 commonelements[numpy.nonzero(macayealflag)]=0 #only one layer: the elements previously in macayeal … … 210 210 211 211 #rule out elements that don't touch the 2 boundaries 212 pos=numpy.nonzero(macayealstokesflag) 213 elist=numpy.zeros( len(pos))214 elist = elist + numpy. any(numpy.sum(nodeonmacayeal[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)215 elist = elist - numpy. any(numpy.sum(nodeonstokes[md.mesh.elements[pos,:].astype(int)-1] ,axis=1),axis=1)216 pos1=numpy.nonzero(elist==1) 212 pos=numpy.nonzero(macayealstokesflag)[0] 213 elist=numpy.zeros(numpy.size(pos),dtype=int) 214 elist = elist + numpy.sum(nodeonmacayeal[md.mesh.elements[pos,:].astype(int)-1],axis=1).astype(bool) 215 elist = elist - numpy.sum(nodeonstokes[md.mesh.elements[pos,:].astype(int)-1] ,axis=1).astype(bool) 216 pos1=numpy.nonzero(elist==1)[0] 217 217 macayealflag[pos[pos1]]=1 218 218 macayealstokesflag[pos[pos1]]=0 219 pos2=numpy.nonzero(elist==-1) 219 pos2=numpy.nonzero(elist==-1)[0] 220 220 stokesflag[pos[pos2]]=1 221 221 macayealstokesflag[pos[pos2]]=0 -
issm/trunk/src/m/parameterization/setmask.py
r13395 r13975 1 from numpy import * 2 import FlagElements as fe 1 import numpy 2 from FlagElements import * 3 3 4 4 def setmask(md, floatingicename, groundedicename): 5 #SETMASK - establish boundaries between grounded and floating ice. 6 # 7 # By default, ice is considered grounded. The contour floatingicename defines nodes 8 # for which ice is floating. The contour groundedicename defines nodes inside an floatingice, 9 # that are grounded (ie: ice rises, islands, etc ...) 10 # All input files are in the Argus format (extension .exp). 11 # 12 # Usage: 13 # md=setmask(md,floatingicename,groundedicename) 14 # 15 # Examples: 16 # md=setmask(md,'all',''); 17 # md=setmask(md,'Iceshelves.exp','Islands.exp'); 5 """ 6 SETMASK - establish boundaries between grounded and floating ice. 18 7 19 #%Get assigned fields 8 By default, ice is considered grounded. The contour floatingicename defines nodes 9 for which ice is floating. The contour groundedicename defines nodes inside an floatingice, 10 that are grounded (ie: ice rises, islands, etc ...) 11 All input files are in the Argus format (extension .exp). 12 13 Usage: 14 md=setmask(md,floatingicename,groundedicename) 15 16 Examples: 17 md=setmask(md,'all',''); 18 md=setmask(md,'Iceshelves.exp','Islands.exp'); 19 """ 20 21 #Get assigned fields 20 22 x = md.mesh.x 21 23 y = md.mesh.y … … 23 25 24 26 #Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{ 25 elementonfloatingice = fe.FlagElements(md, floatingicename)26 elementongroundedice = fe.FlagElements(md, groundedicename)27 elementonfloatingice = FlagElements(md, floatingicename) 28 elementongroundedice = FlagElements(md, groundedicename) 27 29 28 30 #Because groundedice nodes and elements can be included into an floatingice, we need to update. Remember, all the previous 29 31 #arrays come from domain outlines that can intersect one another: 30 32 31 elementonfloatingice = logical_and(elementonfloatingice,~elementongroundedice)32 elementongroundedice = ~elementonfloatingice33 elementonfloatingice = numpy.logical_and(elementonfloatingice,numpy.logical_not(elementongroundedice)) 34 elementongroundedice = numpy.logical_not(elementonfloatingice) 33 35 34 36 #the order here is important. we choose vertexongroundedice as default on the grounding line. 35 vertexonfloatingice = zeros(md.mesh.numberofvertices,'bool') 36 vertexongroundedice = zeros(md.mesh.numberofvertices,'bool') 37 38 pos=argwhere(elementongroundedice==1) 39 pos=md.mesh.elements[pos,:]-1 40 if pos.size: 41 vertexongroundedice[pos]=True 42 43 pos=argwhere(~vertexongroundedice) 44 if pos.size: 45 vertexonfloatingice[pos]=True; 46 #%}}} 37 vertexonfloatingice = numpy.zeros(md.mesh.numberofvertices,'bool') 38 vertexongroundedice = numpy.zeros(md.mesh.numberofvertices,'bool') 39 vertexongroundedice[md.mesh.elements[numpy.nonzero(elementongroundedice),:].astype(int)-1]=True 40 vertexonfloatingice[numpy.nonzero(numpy.logical_not(vertexongroundedice))]=True 41 #}}} 47 42 48 43 #Return: 49 md.mask.elementonfloatingice = double(elementonfloatingice) 50 md.mask.vertexonfloatingice = double(vertexonfloatingice) 51 md.mask.elementongroundedice = double(elementongroundedice) 52 md.mask.vertexongroundedice = double(vertexongroundedice) 53 md.mask.vertexonwater = zeros(md.mesh.numberofvertices) 54 md.mask.elementonwater = zeros(md.mesh.numberofelements) 44 md.mask.elementonfloatingice = elementonfloatingice.astype(float) 45 md.mask.vertexonfloatingice = vertexonfloatingice.astype(float) 46 md.mask.elementongroundedice = elementongroundedice.astype(float) 47 md.mask.vertexongroundedice = vertexongroundedice.astype(float) 48 md.mask.vertexonwater = numpy.zeros(md.mesh.numberofvertices) 49 md.mask.elementonwater = numpy.zeros(md.mesh.numberofelements) 50 55 51 return md -
issm/trunk/src/m/partition/AreaAverageOntoPartition.m
r13395 r13975 15 15 %save 3D model 16 16 md3d=md; 17 17 18 18 md.mesh.elements=md.mesh.elements2d; 19 19 md.mesh.x=md.mesh.x2d; -
issm/trunk/src/m/partition/adjacency.m
r13395 r13975 1 function md=adjacency(md) ;1 function md=adjacency(md) 2 2 %ADJACENCY - compute adjacency matrix, list of vertices and list of weights. 3 3 % -
issm/trunk/src/m/partition/flagedges.m
r13395 r13975 1 function [xsegments ysegments]=flagedges(elements,x,y,partition) ;1 function [xsegments ysegments]=flagedges(elements,x,y,partition) 2 2 %FLAGEDGES - return pairs of x,y segments, delimiting partitions. 3 3 % -
issm/trunk/src/m/partition/partitioner.m
r13395 r13975 50 50 end 51 51 52 53 52 if strcmpi(package,'chaco'), 54 53 … … 57 56 method(1)=3; % global method (3=inertial (geometric)) 58 57 method(3)=0; % vertex weights (0=off, 1=on) 59 58 60 59 %specify bisection 61 60 method(6)=getfieldvalue(options,'section');% ndims (1=bisection, 2=quadrisection, 3=octasection) … … 68 67 weights=[]; 69 68 end 70 69 71 70 % partition into nparts 72 71 part=Chaco(md.qmu.adjacency,weights,[],md.mesh.x, md.mesh.y ,md.mesh.z,method,npart,[])'+1; %index partitions from 1 up. like metis. … … 79 78 end 80 79 maptab=Scotch(md.qmu.adjacency,[],weights,[],'cmplt',[npart]); 81 80 82 81 part=maptab(:,2);%index partitions from 1 up. like metis. 83 84 82 85 83 elseif strcmpi(package,'linear'), -
issm/trunk/src/m/plot/applyoptions.m
r13395 r13975 6 6 % 7 7 % See also: PLOTMODEL, PARSE_OPTIONS 8 9 8 10 9 %some defaults … … 147 146 end 148 147 if exist(options,'log'), 149 nlab= 5;148 nlab=length(get(c,'YTick')); 150 149 logvalue=getfieldvalue(options,'log'); 151 150 … … 176 175 if exist(options,'colorbarYLabel'), 177 176 set(get(c,'Ylabel'),'FontSize',getfieldvalue(options,'colorbarfontsize',fontsize),'String',getfieldvalue(options,'colorbarYLabel'),... 178 'Color',getfieldvalue(options,'FontColor','k') ,'Interpreter',getfieldvalue(options,'Interpreter','none'));177 'Color',getfieldvalue(options,'FontColor','k')); 179 178 end 180 179 if exist(options,'colorbarwidth'), … … 215 214 end 216 215 end 217 labels = cell(1, size(tick_vals,1));218 for i = 1: size(tick_vals,1)219 labels{i} = sprintf('%-3.4g',round_ice(tick_vals(i),2));216 labels = cell(1,numel(tick_vals)); 217 for i = 1:numel(tick_vals) 218 labels{i} = num2str(tick_vals(i)); 220 219 end 221 220 set(c,'YTickLabel',labels); … … 226 225 else 227 226 %do nothing 228 229 end 230 227 228 end 231 229 232 230 %area … … 269 267 end 270 268 269 %curved arrow 270 if exist(options,'curvedarrow'), 271 curvedoptions=getfieldvalue(options,'curvedarrow'); 272 curvedarrow(curvedoptions{:}); 273 end 274 271 275 %Scale ruler 272 276 if exist(options,'scaleruler'), … … 320 324 end 321 325 322 323 326 %position of figure 324 327 if exist(options,'figposition'), 325 328 326 329 figposition=getfieldvalue(options,'figposition'); 327 330 if ischar(figposition), … … 430 433 data=getfieldvalue(options,'scatter'); 431 434 hold on 432 plot_scatter(data(:,1),data(:,2), getfieldvalue(options,'scattersize',3),data(:,3),options);435 plot_scatter(data(:,1),data(:,2),data(:,3),options); 433 436 end 434 437 -
issm/trunk/src/m/plot/arrow.m
r13395 r13975 8 8 % 'ratio': default .5 (ratio headarrow/length) 9 9 % 'widthratio': default is 1/10 of length 10 11 10 12 11 %recover options -
issm/trunk/src/m/plot/checkplotoptions.m
r13395 r13975 1 function options=checkplotoptions(md,options) ;1 function options=checkplotoptions(md,options) 2 2 %PARSE_OPTIONS - build a structure that holds all plot options 3 3 % … … 53 53 end 54 54 end 55 55 56 56 %text 57 57 if exist(options,'text'), -
issm/trunk/src/m/plot/colormaps/getcolormap.m
r13395 r13975 21 21 22 22 if strcmpi(map,'Ala'), 23 map = jet ;23 map = jet(256); 24 24 map = map(128:end,:); 25 25 elseif strcmpi(map,'redblue'), -
issm/trunk/src/m/plot/colormaps/haxby.m
r13395 r13975 1 function map = haxby(m) ;1 function map = haxby(m) 2 2 %HAXBY - Haxby color map 3 3 % HAXBY(M) returns an M-by-3 matrix containing a colormap with Haxby's -
issm/trunk/src/m/plot/kmlgroundoverlay.m
r13395 r13975 1 function kmlgroundoverlay(md,options) ;1 function kmlgroundoverlay(md,options) 2 2 %KMLGROUNDOVERLAY: create ground overlay image in kml format 3 3 % -
issm/trunk/src/m/plot/latlonoverlay.m
r13395 r13975 117 117 end 118 118 119 120 119 pos=find(x<=xlimits(2) & x>=xlimits(1) & y<=ylimits(2) & y>=ylimits(1)); 121 120 if length(pos)<=1, continue; end -
issm/trunk/src/m/plot/plot_BC.m
r13395 r13975 1 function plot_BC(md,options,width,i,data) ;1 function plot_BC(md,options,width,i,data) 2 2 3 3 %plot neuman -
issm/trunk/src/m/plot/plot_basaldrag.m
r13395 r13975 1 function plot_basaldrag(md,options,width,i,type) ;1 function plot_basaldrag(md,options,width,i,type) 2 2 3 3 %PLOT_BASALDRAG - plot basal drag -
issm/trunk/src/m/plot/plot_boundaries.m
r13395 r13975 1 function plot_boundaries(md,options,width,i) ;1 function plot_boundaries(md,options,width,i) 2 2 %PLOT_BOUNDARIES - plot mesh boundaries 3 3 % -
issm/trunk/src/m/plot/plot_contour.m
r13395 r13975 1 function plot_contour(md,datain,options) ;1 function plot_contour(md,datain,options) 2 2 %PLOT_CONTOUR - plot contours of a given field 3 3 % -
issm/trunk/src/m/plot/plot_drivingstress.m
r13395 r13975 1 function plot_drivingstress(md,options,width,i) ;1 function plot_drivingstress(md,options,width,i) 2 2 %PLOT_DRIVINGSTRESS - plot driving stress 3 3 % -
issm/trunk/src/m/plot/plot_edges.m
r13395 r13975 1 function plot_edges(md,options,width,i,datai) ;1 function plot_edges(md,options,width,i,datai) 2 2 %PLOT_SEGMENTS - plot edges, with different colors according to segment markers. 3 3 % -
issm/trunk/src/m/plot/plot_elementnumbering.m
r13395 r13975 1 function plot_elementnumbering(md,options,width,i) ;1 function plot_elementnumbering(md,options,width,i) 2 2 %PLOT_ELEMENTNUMBERING - plot element numbering 3 3 % -
issm/trunk/src/m/plot/plot_elementstype.m
r13395 r13975 1 function plot_elementstype(md,options,width,i) ;1 function plot_elementstype(md,options,width,i) 2 2 %PLOT_ELEMENTSTYPE - plot elements type 3 3 % -
issm/trunk/src/m/plot/plot_highlightelements.m
r13395 r13975 1 function plot_highlightelements(md,options,width,i) ;1 function plot_highlightelements(md,options,width,i) 2 2 %PLOT_HIGHLIGHTELEMENTS - plot selected elements 3 3 % -
issm/trunk/src/m/plot/plot_highlightvertices.m
r13395 r13975 1 function plot_highlightvertices(md,options,width,i) ;1 function plot_highlightvertices(md,options,width,i) 2 2 %PLOT_HIGHLIGHTVERTICES - plot selected vertices 3 3 % … … 21 21 %Highlight 22 22 pos=getfieldvalue(options,'highlight',[]); 23 text(x(pos),y(pos),z(pos),num2str( transpose(pos)),...23 text(x(pos),y(pos),z(pos),num2str(pos(:)),... 24 24 'backgroundcolor',[1 0 0],'HorizontalAlignment','center','VerticalAlignment','middle'); 25 25 else … … 34 34 %Highlight 35 35 pos=getfieldvalue(options,'highlight',[]); 36 text(x(pos),y(pos),z(pos),num2str( transpose(pos)),...36 text(x(pos),y(pos),z(pos),num2str(pos(:)),... 37 37 'backgroundcolor',[1 0 0],'HorizontalAlignment','center','VerticalAlignment','middle'); 38 38 end -
issm/trunk/src/m/plot/plot_icefront.m
r13395 r13975 1 function plot_icefront(md,options,width,i,data) ;1 function plot_icefront(md,options,width,i,data) 2 2 %PLOT_ICEFRONT - plot segment on neumann BC 3 3 % -
issm/trunk/src/m/plot/plot_importancefactors.m
r13395 r13975 1 function plot_importancefactors(md,options,width,ii) ;1 function plot_importancefactors(md,options,width,ii) 2 2 %PLOT_IMPORTANCEFACTORS - plot importance factors 3 3 % -
issm/trunk/src/m/plot/plot_manager.m
r13395 r13975 1 function plot_manager(md,options,subplotwidth,nlines,ncols,i) ;1 function plot_manager(md,options,subplotwidth,nlines,ncols,i) 2 2 %PLOT__MANAGER - distribute the plots, called by plotmodel 3 3 % … … 33 33 plot_highlightelements(md,options,subplotwidth,i); 34 34 return; 35 35 36 36 case 'qmumean', 37 37 plot_qmumean(md,options,nlines,ncols,i); 38 38 return; 39 39 40 40 case 'qmustddev', 41 41 plot_qmustddev(md,options,nlines,ncols,i); 42 42 return; 43 43 44 44 case 'qmuhistnorm', 45 45 plot_qmuhistnorm(md,options,nlines,ncols,i); … … 118 118 plot_segments(md,options,subplotwidth,i,data) 119 119 return 120 120 121 121 case 'quiver' 122 122 data=[md.initialization.vx md.initialization.vy]; %Go ahead and try plot_unit … … 199 199 error('cannot kmlgroundoverlay on multi-plots'); 200 200 end 201 201 202 202 %call routine to build kml file and image that goes with it. 203 203 kmlgroundoverlay(md,options); -
issm/trunk/src/m/plot/plot_mesh.m
r13395 r13975 1 function plot_mesh(md,options,nlines,ncols,i) ;1 function plot_mesh(md,options,nlines,ncols,i) 2 2 %PLOT_MESH - plot model mesh 3 3 % -
issm/trunk/src/m/plot/plot_none.m
r13395 r13975 1 function plot_none(md,options,nlines,ncols,i) ;1 function plot_none(md,options,nlines,ncols,i) 2 2 %PLOT_NONE - plot nothing, just apply options 3 3 % -
issm/trunk/src/m/plot/plot_overlay.m
r13395 r13975 25 25 error('buildoverlay error message: overlay not supported for quiver plots'); 26 26 end 27 28 27 29 28 %radar power … … 150 149 options=changefieldvalue(options,'caxis',[data_min data_max]); % force caxis so that the colorbar is ready 151 150 end 152 options=addfielddefault(options,'axis','equal off'); % default axis 151 options=addfielddefault(options,'xlim',xlim); % default xlim 152 options=addfielddefault(options,'ylim',ylim); % default ylim 153 options=addfielddefault(options,'axis','equal off'); % default axis 153 154 applyoptions(md,data,options); 154 155 drawnow -
issm/trunk/src/m/plot/plot_parthist.m
r13395 r13975 1 function plot_parthist(md,options,nlines,ncols,i) ;1 function plot_parthist(md,options,nlines,ncols,i) 2 2 %PLOT_PARTHIST - plot partitioning histogram 3 3 % -
issm/trunk/src/m/plot/plot_parthistn.m
r13395 r13975 1 function plot_parthist(md,options,nlines,ncols,i) ;1 function plot_parthist(md,options,nlines,ncols,i) 2 2 %PLOT_PARTHIST - plot partitioning histogram 3 3 % -
issm/trunk/src/m/plot/plot_parthistw.m
r13395 r13975 1 function plot_parthist(md,options,nlines,ncols,i) ;1 function plot_parthist(md,options,nlines,ncols,i) 2 2 %PLOT_PARTHIST - plot partitioning histogram 3 3 % -
issm/trunk/src/m/plot/plot_penalties.m
r13395 r13975 1 function plot_penalties(md,options,width,i) ;1 function plot_penalties(md,options,width,i) 2 2 %PLOT_PENALTIES - plot penalties 3 3 % -
issm/trunk/src/m/plot/plot_qmu_mass_flux_segments.m
r13395 r13975 1 function plot_qmu_mass_flux_segments(md,options,nlines,ncols,i) ;1 function plot_qmu_mass_flux_segments(md,options,nlines,ncols,i) 2 2 %PLOT_QMU_MASS_FLUX_SEGMENTS - plot segments from the qmu analysis of mass fluxes 3 3 % … … 27 27 28 28 %plot normals 29 29 30 30 for j=1:length(segments), 31 31 xstart=mean([segments(j,1) segments(j,3)]); -
issm/trunk/src/m/plot/plot_qmuhistnorm.m
r13395 r13975 1 function plot_qmuhistnorm(md,options,nlines,ncols,index) ;1 function plot_qmuhistnorm(md,options,nlines,ncols,index) 2 2 3 3 %prepare plot 4 4 subplot(nlines,ncols,index); 5 5 hold on 6 7 6 8 7 %recover histnorm data -
issm/trunk/src/m/plot/plot_qmumean.m
r13395 r13975 1 function plot_qmumean(md,options,nlines,ncols,i) ;1 function plot_qmumean(md,options,nlines,ncols,i) 2 2 %PLOT_QMUMEAN - plot mean of a scaled response 3 3 % -
issm/trunk/src/m/plot/plot_qmustddev.m
r13395 r13975 1 function plot_qmustddev(md,options,nlines,ncols,i) ;1 function plot_qmustddev(md,options,nlines,ncols,i) 2 2 %PLOT_QMUMEAN - plot stddev of a scaled response 3 3 % … … 47 47 end 48 48 49 50 49 %now, project onto vertices 51 50 responses_on_node=responses(md.qmu.partition+1); -
issm/trunk/src/m/plot/plot_referential.m
r13395 r13975 1 function plot_referential(md,options,width,i,data) ;1 function plot_referential(md,options,width,i,data) 2 2 %PLOT_PRESSURELOAD - plot segment on neumann BC 3 3 % -
issm/trunk/src/m/plot/plot_riftfraction.m
r13395 r13975 1 function plot_riftfraction(md,options,nlines,ncols,index) ;1 function plot_riftfraction(md,options,nlines,ncols,index) 2 2 %PLOT_RIFTFRACTION - plot rift fractions 3 3 % -
issm/trunk/src/m/plot/plot_riftnumbering.m
r13395 r13975 1 function plot_riftnumbering(md,options,nlines,ncols,index) ;1 function plot_riftnumbering(md,options,nlines,ncols,index) 2 2 %PLOT_RIFTNUMBERING - plot rift penetration + numbering of all rift vertices, as well as rift numbers. 3 3 % … … 88 88 end 89 89 90 91 90 %apply options 92 91 options=addfielddefault(options,'title','Rift/Fault location'); -
issm/trunk/src/m/plot/plot_riftpenetration.m
r13395 r13975 1 function plot_rifpenetration(md,options,nlines,ncols,index) ;1 function plot_rifpenetration(md,options,nlines,ncols,index) 2 2 %PLOT_RIFTPENETRATION - plot rift penetration 3 3 % -
issm/trunk/src/m/plot/plot_riftrelvel.m
r13395 r13975 1 function plot_riftrelvel(md,options,nlines,ncols,index) ;1 function plot_riftrelvel(md,options,nlines,ncols,index) 2 2 %PLOT_RIFTRELVEL - plot rift relative velocities 3 3 % … … 15 15 end 16 16 options=addfielddefault(options,'scaling',2); 17 18 %markersize: 19 markersize=getfieldvalue(options,'markersize',1); 17 20 18 21 %recover vx and vy: … … 38 41 hold on 39 42 40 %plot mesh boundaries41 for i=1:size(md.mesh.segments,1),42 plot(x(md.mesh.segments(i,1:2)),y(md.mesh.segments(i,1:2)),'k-');43 end44 45 43 %plot rifts vel 46 44 h3=[]; … … 63 61 end 64 62 for i=1:size(md.rifts.riftstruct,1), 65 63 66 64 %get nodes on rift 67 65 penaltypairs=md.rifts.riftstruct(i).penaltypairs; … … 81 79 %if penetration is negative, plot in black, positive, plot in red;: ie: if rift is closing, black, if rift is opening, red. 82 80 if(penetration>0), 83 p2=plot(x(penaltypairs(j,1)) ,y(penaltypairs(j,1)),' *'); set(p2,'Color',[140 140 140]/255);81 p2=plot(x(penaltypairs(j,1)) ,y(penaltypairs(j,1)),'.','MarkerSize',markersize); set(p2,'Color',[140 140 140]/255); 84 82 isp2=1; 85 83 else 86 p1=plot(x(penaltypairs(j,1)) ,y(penaltypairs(j,1)),'k *');84 p1=plot(x(penaltypairs(j,1)) ,y(penaltypairs(j,1)),'k.','MarkerSize',markersize); 87 85 isp1=1; 88 86 end … … 90 88 91 89 %point out the tips 92 h2=plot(x(md.rifts.riftstruct(i).tips(1)),y(md.rifts.riftstruct(i).tips(1)),'g *');93 plot(x(md.rifts.riftstruct(i).tips(2)),y(md.rifts.riftstruct(i).tips(2)),'g *');90 h2=plot(x(md.rifts.riftstruct(i).tips(1)),y(md.rifts.riftstruct(i).tips(1)),'g.','MarkerSize',markersize); 91 plot(x(md.rifts.riftstruct(i).tips(2)),y(md.rifts.riftstruct(i).tips(2)),'g.','MarkerSize',markersize); 94 92 segments=md.rifts.riftstruct(i).segments(:,1:2); 95 93 end 94 95 faulttitle=getfieldvalue(options','faulttitle','faults'); 96 rifttitle=getfieldvalue(options','rifttitle','rifts'); 96 97 %legend 97 98 if strcmpi(getfieldvalue(options,'legend','on'),'on'), 98 99 if isp1 & isp2 99 l=legend([h1,h2,p1,p2],'mesh boundaries','crack tips', 'faults','rifts');100 l=legend([h1,h2,p1,p2],'mesh boundaries','crack tips',faulttitle,rifttitle); 100 101 elseif isp1 101 l=legend([h1,h2,p1],'mesh boundaries','crack tips', 'faults');102 l=legend([h1,h2,p1],'mesh boundaries','crack tips',faulttitle); 102 103 elseif isp2 103 l=legend([h1,h2,p2],'mesh boundaries','crack tips', 'rifts');104 l=legend([h1,h2,p2],'mesh boundaries','crack tips',rifttitle); 104 105 else 105 106 l=legend([h1,h2],'mesh boundaries','crack tips'); -
issm/trunk/src/m/plot/plot_rifts.m
r13395 r13975 1 function plot_rifts(md,options,nlines,ncols,index) ;1 function plot_rifts(md,options,nlines,ncols,index) 2 2 %PLOT_RIFTS - plot rifts in a mesh 3 3 % … … 16 16 offset=getfieldvalue(options,'offset',500); 17 17 if isstruct(md.rifts.riftstruct), 18 18 19 19 for i=1:size(md.rifts.riftstruct,1), 20 20 penaltypairs=md.rifts.riftstruct(i).penaltypairs; -
issm/trunk/src/m/plot/plot_riftvel.m
r13395 r13975 1 function plot_riftvel(md,options,nlines,ncols,index) ;1 function plot_riftvel(md,options,nlines,ncols,index) 2 2 %PLOT_RIFTVEL - plot rift velocity 3 3 % … … 89 89 end 90 90 91 92 91 %legend 93 92 if isp1 & isp2 -
issm/trunk/src/m/plot/plot_sarpwr.m
r13395 r13975 1 function plot_sarpwr(md,options,width,i) ;1 function plot_sarpwr(md,options,width,i) 2 2 %PLOT_SARPWR - plot radar image 3 3 % … … 17 17 md.mesh.z=md.mesh.z*unit; 18 18 end 19 19 20 20 imagesc(md.radaroverlay.x,md.radaroverlay.y,double(md.radaroverlay.pwr)),set(gca,'YDir','normal');colormap(gray); 21 21 -
issm/trunk/src/m/plot/plot_scatter.m
r13395 r13975 1 function plot_scatter(x,y,level, options),1 function plot_scatter(x,y,level,varargin), 2 2 3 if nargin==3, options=pairoptions(); end 3 options=pairoptions(varargin{:}); 4 4 5 5 %check input … … 13 13 Siz=length(level); 14 14 nlab=10; 15 %Min=0; 16 %Max=1300; 15 17 16 18 %OK, should we create a new colorbar for the occasion? -
issm/trunk/src/m/plot/plot_section.m
r13395 r13975 115 115 hold on 116 116 117 118 117 %3D 119 118 else -
issm/trunk/src/m/plot/plot_segments.m
r13395 r13975 1 function plot_segments(md,options,width,i,datai) ;1 function plot_segments(md,options,width,i,datai) 2 2 %PLOT_SEGMENTS - plot segments, with different colors according to segment markers. 3 3 % … … 42 42 h3=plot(xstart,ystart,'r*'); 43 43 44 45 44 else 46 45 error('plot_segments: 3d plot of segments not supported yet!'); -
issm/trunk/src/m/plot/plot_tensor.m
r13395 r13975 1 function plot_tensor(md,options,width,i,type) ;1 function plot_tensor(md,options,width,i,type) 2 2 %PLOT_TENSOR - plot tensor components 3 3 % -
issm/trunk/src/m/plot/plot_tensor_components.m
r13395 r13975 1 function plot_tensor_components(md,options,width,i,tensor,type,plot_options) ;1 function plot_tensor_components(md,options,width,i,tensor,type,plot_options) 2 2 %PLOT_TENSOR_COMPONENT - plot component of a tensor 3 3 % -
issm/trunk/src/m/plot/plot_tensor_principal.m
r13395 r13975 1 function plot_tensor_principal(md,options,width,i,tensor,type,plot_options) ;1 function plot_tensor_principal(md,options,width,i,tensor,type,plot_options) 2 2 %PLOT_TENSOR_PRINCIPAL - plot principal values 3 3 % -
issm/trunk/src/m/plot/plot_tensor_principalaxis.m
r13395 r13975 1 function plot_tensor_principalaxis(md,options,width,i,tensor,type,plot_options) ;1 function plot_tensor_principalaxis(md,options,width,i,tensor,type,plot_options) 2 2 %PLOT_TENSOR_PRINCIPALAXIS - plot ytensor principal axis 3 3 % -
issm/trunk/src/m/plot/plot_thermaltransient_results.m
r13395 r13975 22 22 eval(string); 23 23 clear string; 24 -
issm/trunk/src/m/plot/plot_transient_movie.m
r13395 r13975 1 function plot_transient_movie(md,options,width,i) ;1 function plot_transient_movie(md,options,width,i) 2 2 %PLOT_TRANSIENT_MOVIE - plot a transient result as a movie 3 3 % Usage: -
issm/trunk/src/m/plot/plot_vertexnumbering.m
r13395 r13975 1 function plot_vertexnumbering(md,options,width,i) ;1 function plot_vertexnumbering(md,options,width,i) 2 2 %PLOT_VERTEXNUMBERING - plot vertex numbering 3 3 % … … 25 25 %Highlight 26 26 pos=getfieldvalue(options,'highlight',[]); 27 text(x(pos),y(pos),z(pos),num2str( transpose(pos)),...27 text(x(pos),y(pos),z(pos),num2str(pos(:)),... 28 28 'backgroundcolor',[1 0 0],'HorizontalAlignment','center','VerticalAlignment','middle'); 29 29 else … … 42 42 %Highlight 43 43 pos=getfieldvalue(options,'highlight',[]); 44 text(x(pos),y(pos),z(pos),num2str( transpose(pos)),...44 text(x(pos),y(pos),z(pos),num2str(pos(:)),... 45 45 'backgroundcolor',[1 0 0],'HorizontalAlignment','center','VerticalAlignment','middle'); 46 46 end -
issm/trunk/src/m/plot/plotmodel.m
r13395 r13975 32 32 %go through subplots 33 33 if numberofplots, 34 34 35 35 %Create figure 36 36 if strcmpi(getfieldvalue(options.list{1},'visible','on'),'off'), -
issm/trunk/src/m/plot/processdata.m
r13395 r13975 1 function [data datatype]=processdata(md,data,options) ;1 function [data datatype]=processdata(md,data,options) 2 2 %PROCESSDATA - process data to be plotted 3 3 % … … 48 48 end 49 49 50 %get data type50 %get datasize 51 51 datasize=size(data); 52 52 53 %Process NaN if any (do not now before mask is applied)53 %Process NaN if any (do not know before mask is applied) 54 54 if exist(options,'nan') 55 55 data(find(isnan(data)))=getfieldvalue(options,'nan',0); … … 74 74 error('plotmodel error message: data not supported yet'); 75 75 end 76 76 77 77 %quiver? 78 78 if datasize(2)>1, -
issm/trunk/src/m/plot/processmesh.m
r13395 r13975 1 function [x y z elements is2d isplanet]=processmesh(md,data,options) ;1 function [x y z elements is2d isplanet]=processmesh(md,data,options) 2 2 %PROCESSMESH - process mesh to be plotted 3 3 % … … 36 36 z=md.mesh.z; 37 37 end 38 39 38 40 39 if isprop(md.mesh,'elements2d'), elements2d=md.mesh.elements2d; end -
issm/trunk/src/m/plot/quiver_colorbar.m
r13395 r13975 31 31 fontsize=getfieldvalue(options,'fontsize',14); 32 32 set(hcb,'FontSize',fontsize); 33 33 34 34 if exist(options,'colorbartitle'), 35 35 backup=gca; -
issm/trunk/src/m/plot/radarpower.m
r13395 r13975 32 32 if ~exist(options,'overlay_image'), 33 33 if strcmpi(md.mesh.hemisphere,'n'), 34 %if ~exist([ jplsvn() '/projects/ModelData/MOG/mog150_greenland_map.jpg']),35 % error(['radarpower error message: file ' jplsvn() '/projects/ModelData/MOG/mog150_greenland_map.jpg not found.']);34 %if ~exist(['/u/astrid-r1b/ModelData/MOG/mog150_greenland_map.jpg']), 35 % error(['radarpower error message: file ' '/u/astrid-r1b/ModelData/MOG/mog150_greenland_map.jpg not found.']); 36 36 %end 37 37 %name = 'mog150_greenland_map'; 38 38 %name = 'mog100_hp1_v10'; 39 39 %%name = 'mog500_hp1_v10'; 40 %jpgim=[ jplsvn() '/projects/ModelData/MOG/' name '.jpg'];41 %geom=load([ jplsvn() '/projects/ModelData/MOG/' name '.jpgw'],'ascii');40 %jpgim=['/u/astrid-r1b/ModelData/MOG/' name '.jpg']; 41 %geom=load(['/u/astrid-r1b/ModelData/MOG/' name '.jpgw'],'ascii'); 42 42 %%jpgim='/u/astrid-r1b/morlighe/issmjpl/projects/MorlighemGRL2012/Data/Mosaic_amp_asar2010.jpg'; 43 43 %%geom=load('/u/astrid-r1b/morlighe/issmjpl/projects/MorlighemGRL2012/Data/Mosaic_amp_asar2010.jpgw'); … … 65 65 %md.radaroverlay.y=(ymin:(ymax-ymin)/(size(md.radaroverlay.pwr,1)-1):ymax); 66 66 if highres, 67 if ~exist([ jplsvn() '/projects/ModelData/MOG/mog100g_r2_hp1.tif']),68 error(['radarpower error message: file ' jplsvn() '/projects/ModelData/MOG/mog100g_r2_hp1.tif not found.']);67 if ~exist(['/u/astrid-r1b/ModelData/MOG/mog100_r2_hp1.tif']), 68 error(['radarpower error message: file ' '/u/astrid-r1b/ModelData/MOG/mog100_r2_hp1.tif not found.']); 69 69 end 70 geotiff_name=[ jplsvn() '/projects/ModelData/MOG/mog100_r2_hp1.tif'];70 geotiff_name=['/u/astrid-r1b/ModelData/MOG/mog100_r2_hp1.tif']; 71 71 else 72 if ~exist([ jplsvn() '/projects/ModelData/MOG/mog500g_r2_hp1.tif']),73 error(['radarpower error message: file ' jplsvn() '/projects/ModelData/MOG/mog500g_r2_hp1.tif not found.']);72 if ~exist(['/u/astrid-r1b/ModelData/MOG/mog500_r2_hp1.tif']), 73 error(['radarpower error message: file ' '/u/astrid-r1b/ModelData/MOG/mog500_r2_hp1.tif not found.']); 74 74 end 75 geotiff_name=[ jplsvn() '/projects/ModelData/MOG/mog500_r2_hp1.tif'];75 geotiff_name=['/u/astrid-r1b/ModelData/MOG/mog500_r2_hp1.tif']; 76 76 end 77 77 … … 90 90 system('rm -rf ./temp.tif'); 91 91 92 93 92 elseif strcmpi(md.mesh.hemisphere,'s'), 94 93 if highres, 95 if ~exist([ jplsvn() '/projects/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif']),96 error(['radarpower error message: file ' jplsvn() '/projects/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif not found.']);94 if ~exist(['/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif']), 95 error(['radarpower error message: file ' '/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif not found.']); 97 96 end 98 geotiff_name=[ jplsvn() '/projects/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif'];97 geotiff_name=['/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif']; 99 98 else 100 if ~exist([ jplsvn() '/projects/ModelData/MosaicTiffRsat/amm125m_v2_1km.tif']),101 error(['radarpower error message: file ' jplsvn() '/projects/ModelData/MosaicTiffRsat/amm125m_v2_1km.tif not found.']);99 if ~exist(['/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_1km.tif']), 100 error(['radarpower error message: file ' '/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_1km.tif not found.']); 102 101 end 103 geotiff_name=[ jplsvn() '/projects/ModelData/MosaicTiffRsat/amm125m_v2_1km.tif'];102 geotiff_name=['/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_1km.tif']; 104 103 end 105 104 -
issm/trunk/src/m/plot/subplotmodel.m
r13395 r13975 1 function ha=subplotmodel(nlines,ncols,num,options) ;1 function ha=subplotmodel(nlines,ncols,num,options) 2 2 %SUBPLOTMODEL - tight subplot that includes margins 3 3 % -
issm/trunk/src/m/print/printmodel.m
r13395 r13975 23 23 % printmodel('image','tiff') 24 24 % printmodel('image','eps','margin','on','frame','on','hardcopy','on') 25 26 25 27 26 %get options: … … 54 53 %InvertHardcopy off imposes MATLAB to use the same colors 55 54 set(fig, 'InvertHardcopy', getfieldvalue(options,'hardcopy')); 56 57 55 58 56 %we could have several formats, as a cell array of strings. -
issm/trunk/src/m/qmu/MassFluxProcessProfile.m
r4773 r13975 1 function segments=MassFluxProcessProfile(md,directory,profilename) ;1 function segments=MassFluxProcessProfile(md,directory,profilename) 2 2 %MASSFLUXPROCESSPROFILE: process an argus domain outlien profile into a list of segments. 3 3 % … … 7 7 % See also: PROCESS_QMU_RESPONSE_DATA, PREQMU 8 8 9 10 9 %first read the profile points. 11 10 profile=expread([directory '/' profilename]); -
issm/trunk/src/m/qmu/dakota_cdfs.m
r3092 r13975 136 136 end 137 137 end 138 138 139 139 varargout{1}=dresp; 140 140 141 141 elseif exist('samp','var') && ~isempty(samp) 142 142 cdf=zeros(length(resp)+length(prob)+length(rel)+length(grel),... … … 147 147 resp,prob,rel,grel); 148 148 end 149 149 150 150 varargout{1}=cdf; 151 151 152 152 elseif exist('mean','var' ) && ~isempty(mean ) && ... 153 153 exist('stddev','var') && ~isempty(stddev) … … 159 159 resp,prob,rel,grel); 160 160 end 161 161 162 162 varargout{1}=cdf; 163 163 else … … 178 178 mu =mean(samp); 179 179 sigma=std(samp); 180 180 181 181 cdf=zeros(length(resp)+length(prob)+length(rel)+length(grel),4); 182 182 cdf(:,:)=NaN; -
issm/trunk/src/m/qmu/dakota_in_data.m
r11995 r13975 88 88 % dmeth=dmeth_params_merge(dmeth,dparams) 89 89 90 91 90 %% variables 92 91 … … 99 98 100 99 end 101 100 102 101 %% responses 103 102 -
issm/trunk/src/m/qmu/dakota_in_params.m
r5486 r13975 209 209 210 210 end 211 -
issm/trunk/src/m/qmu/dakota_in_parse.m
r1014 r13975 42 42 % 43 43 function [method,dvar,dresp]=dakota_in_parse(filei) 44 44 45 45 if ~nargin 46 46 help dakota_in_parse … … 631 631 632 632 itoken=itoken+1; 633 633 634 634 % read next line if necessary 635 635 … … 644 644 itoken=1; 645 645 end 646 646 647 647 end 648 648 … … 668 668 itoken=1; 669 669 end 670 670 671 671 % check for equal sign and skip 672 672 -
issm/trunk/src/m/qmu/dakota_moments.m
r3092 r13975 89 89 moments_calc(dresp(i).sample,alpha); 90 90 end 91 91 92 92 varargout{1}=dresp; 93 93 94 94 elseif exist('samp','var') && ~isempty(samp) 95 95 mean =zeros(1,size(samp,2)); … … 106 106 moments_calc(samp(:,i),alpha); 107 107 end 108 108 109 109 varargout{1}=mean; 110 110 varargout{2}=stddev; -
issm/trunk/src/m/qmu/dakota_out_parse.m
r6690 r13975 170 170 end 171 171 display(sprintf('Number of columns (Dakota V+R)=%d.',ntokens-1)); 172 172 173 173 % process rows of matrix 174 174 … … 301 301 end 302 302 [ntokens,tokens]=fltokens(fline); 303 303 304 304 % add new response function and moments 305 305 … … 336 336 end 337 337 [ntokens,tokens]=fltokens(fline); 338 338 339 339 % find response function associated with confidence intervals 340 340 … … 464 464 cmat.row =cell(1,1); 465 465 cmat.matrix=zeros(1,ntokens); 466 466 467 467 for i=1:ntokens 468 468 cmat.column(1,i)=cellstr(tokens{1}{i}); 469 469 end 470 470 471 471 % process rows of matrix, reading until blank line 472 472 … … 583 583 display(sprintf(' %s',dresp(idresp).descriptor)); 584 584 end 585 585 586 586 % skip column headings of cdf 587 587 -
issm/trunk/src/m/qmu/examples/direct.m
r9650 r13975 4 4 md.qmu.params.evaluation_concurrency=1; 5 5 6 7 8 6 %or for matlab direct driver 9 7 md.qmu.params.direct=true; -
issm/trunk/src/m/qmu/examples/lrel_mmf.m
r9650 r13975 93 93 %part_hist(md.qmu.partition,md.vertex_weight) 94 94 %plotmodel(md,'data',log10(md.results.dakota.dresp_out(9).impfac(md.qmu.partition+1))) 95 -
issm/trunk/src/m/qmu/expandvariables.m
r9668 r13975 4 4 5 5 for i=1:length(fnames) 6 6 7 7 % for linear constraints, just copy 8 8 -
issm/trunk/src/m/qmu/importancefactors.m
r9742 r13975 8 8 % Example: factors=importancefactors(md,'drag','max_vel'); 9 9 % 10 11 10 12 11 variablenamelength=length(variablename); -
issm/trunk/src/m/qmu/lclist_write.m
r13395 r13975 60 60 61 61 end 62 -
issm/trunk/src/m/qmu/plot/plot_boxplot.m
r7398 r13975 62 62 dresp=varargin{iarg}; 63 63 iarg=iarg+1; 64 64 65 65 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 66 66 if iarg <= nargin && iscell(varargin{iarg}) … … 68 68 iarg=iarg+1; 69 69 end 70 70 71 71 descr=cell (1,length(dresp)); 72 72 lsamp=zeros(1,length(dresp)); … … 84 84 sampr=varargin{iarg}; 85 85 iarg=iarg+1; 86 86 87 87 if iarg <= nargin && iscell(varargin{iarg}) 88 88 descr=varargin{iarg}; … … 119 119 iarg=iarg+2; 120 120 end 121 121 122 122 %% draw the plot 123 123 -
issm/trunk/src/m/qmu/plot/plot_cdf.m
r7398 r13975 77 77 dresp=varargin{iarg}; 78 78 iarg=iarg+1; 79 79 80 80 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 81 81 if iarg <= nargin && iscell(varargin{iarg}) … … 188 188 set(hl1(i),'Color',cmap(imap,:)) 189 189 end 190 190 191 191 xlim('auto') 192 192 [xlims]=xlim; … … 278 278 end 279 279 end 280 280 281 281 if strcmpi(pdfplt,'line') 282 282 xplot=xpdf; -
issm/trunk/src/m/qmu/plot/plot_hist_norm.m
r8732 r13975 89 89 dresp1=varargin{iarg}; 90 90 iarg=iarg+1; 91 91 92 92 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 93 93 if iarg <= nargin && iscell(varargin{iarg}) … … 95 95 iarg=iarg+1; 96 96 end 97 97 98 98 descr=cell (1,length(dresp1)); 99 99 lsamp=zeros(1,length(dresp1)); … … 111 111 sampr=varargin{iarg}; 112 112 iarg=iarg+1; 113 113 114 114 lsamp(1:size(sampr,2))=size(sampr,1); 115 115 … … 142 142 iarg=iarg+1; 143 143 end 144 144 145 145 mu =zeros(1,length(dresp2)); 146 146 sigma=zeros(1,length(dresp2)); … … 298 298 end 299 299 end 300 300 301 301 xlim('auto') 302 302 [xlims]=xlim; -
issm/trunk/src/m/qmu/plot/plot_hist_norm_ci.m
r7398 r13975 78 78 dresp=varargin{iarg}; 79 79 iarg=iarg+1; 80 80 81 81 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 82 82 if iarg <= nargin && iscell(varargin{iarg}) … … 84 84 iarg=iarg+1; 85 85 end 86 86 87 87 descr=cell (1,length(dresp)); 88 88 lsamp=zeros(1,length(dresp)); … … 92 92 sampr=zeros(max(lsamp),length(dresp)); 93 93 sampr(:,:)=NaN; 94 94 95 95 mu =zeros(1,length(dresp)); 96 96 sigma =zeros(1,length(dresp)); … … 109 109 sampr=varargin{iarg}; 110 110 iarg=iarg+1; 111 111 112 112 lsamp(1:size(sampr,2))=size(sampr,1); 113 113 … … 121 121 descr=cell(1,size(sampr,2)); 122 122 end 123 123 124 124 mu =zeros(1,size(sampr,2)); 125 125 sigma =zeros(1,size(sampr,2)); … … 325 325 end 326 326 end 327 327 328 328 xlim('auto') 329 329 [xlims]=xlim; -
issm/trunk/src/m/qmu/plot/plot_if_bars.m
r7398 r13975 66 66 dresp=varargin{iarg}; 67 67 iarg=iarg+1; 68 68 69 69 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 70 70 if iarg <= nargin && iscell(varargin{iarg}) … … 72 72 iarg=iarg+1; 73 73 end 74 74 75 75 descr=cell (1,length(dresp)); 76 76 lifr =zeros(1,length(dresp)); … … 125 125 end 126 126 clear ifmean 127 127 128 128 dvar=dvar(index); 129 129 ifr =ifr (:,index); … … 136 136 dvar(nif+1,1)=cellstr(sprintf('others < %f',ifmin)); 137 137 ifr (:,nif+1)=0.; 138 138 139 139 nif2=0; 140 140 dvar2=cell (size(dvar)); 141 141 ifr2 =zeros(size(ifr )); 142 142 143 143 % sum filtered rows and copy unfiltered rows 144 144 … … 152 152 end 153 153 end 154 154 155 155 % copy sums 156 156 157 157 dvar2(nif2+1) =dvar(nif+1); 158 158 ifr2 (:,nif2+1)=ifr (:,nif+1); 159 159 160 160 % copy back and truncate filtered rows 161 161 -
issm/trunk/src/m/qmu/plot/plot_if_spec.m
r7398 r13975 72 72 dresp=varargin{iarg}; 73 73 iarg=iarg+1; 74 74 75 75 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 76 76 if iarg <= nargin && iscell(varargin{iarg}) … … 78 78 iarg=iarg+1; 79 79 end 80 80 81 81 descr=cell (1,length(dresp)); 82 82 lifr =zeros(1,length(dresp)); … … 137 137 end 138 138 clear ifmean 139 139 140 140 dvar=dvar(index); 141 141 ifr =ifr (:,index); … … 148 148 dvar(nif+1,1)=cellstr(sprintf('others < %f',ifmin)); 149 149 ifr (:,nif+1)=0.; 150 150 151 151 nif2=0; 152 152 dvar2=cell (size(dvar)); 153 153 ifr2 =zeros(size(ifr )); 154 154 155 155 % sum filtered rows and copy unfiltered rows 156 156 … … 164 164 end 165 165 end 166 166 167 167 % copy sums 168 168 169 169 dvar2(nif2+1) =dvar(nif+1); 170 170 ifr2 (:,nif2+1)=ifr (:,nif+1); 171 171 172 172 % copy back and truncate filtered rows 173 173 -
issm/trunk/src/m/qmu/plot/plot_normdist_bars.m
r7398 r13975 73 73 dresp=varargin{iarg}; 74 74 iarg=iarg+1; 75 75 76 76 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 77 77 if iarg <= nargin && iscell(varargin{iarg}) … … 82 82 sampr=varargin{iarg}; 83 83 iarg=iarg+1; 84 84 85 85 if iarg <= nargin && iscell(varargin{iarg}) 86 86 descr=varargin{iarg}; … … 92 92 descr=cell(1:size(sampr,2)); 93 93 end 94 94 95 95 dresp=struct([]); 96 96 for i=1:size(sampr,2) -
issm/trunk/src/m/qmu/plot/plot_normplot.m
r7398 r13975 62 62 dresp=varargin{iarg}; 63 63 iarg=iarg+1; 64 64 65 65 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 66 66 if iarg <= nargin && iscell(varargin{iarg}) … … 68 68 iarg=iarg+1; 69 69 end 70 70 71 71 descr=cell (1,length(dresp)); 72 72 lsamp=zeros(1,length(dresp)); … … 84 84 sampr=varargin{iarg}; 85 85 iarg=iarg+1; 86 86 87 87 if iarg <= nargin && iscell(varargin{iarg}) 88 88 descr=varargin{iarg}; … … 119 119 iarg=iarg+2; 120 120 end 121 121 122 122 %% draw the plot 123 123 -
issm/trunk/src/m/qmu/plot/plot_prob_bars.m
r7398 r13975 57 57 %% assemble the data into a matrix and calculate the increments 58 58 59 60 59 %% process input data and assemble into matrices and increments 61 60 … … 66 65 dresp=varargin{iarg}; 67 66 iarg=iarg+1; 68 67 69 68 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 70 69 if iarg <= nargin && iscell(varargin{iarg}) … … 72 71 iarg=iarg+1; 73 72 end 74 73 75 74 descr=cell (1,length(dresp)); 76 75 lcdfr=zeros(1,length(dresp)); -
issm/trunk/src/m/qmu/plot/plot_rlev_bars.m
r7398 r13975 62 62 dresp=varargin{iarg}; 63 63 iarg=iarg+1; 64 64 65 65 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 66 66 if iarg <= nargin && iscell(varargin{iarg}) … … 68 68 iarg=iarg+1; 69 69 end 70 70 71 71 descr=cell (1,length(dresp)); 72 72 lcdfr=zeros(1,length(dresp)); -
issm/trunk/src/m/qmu/plot/plot_rlev_bars_ci.m
r7398 r13975 74 74 dresp=varargin{iarg}; 75 75 iarg=iarg+1; 76 76 77 77 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 78 78 if iarg <= nargin && iscell(varargin{iarg}) … … 83 83 sampr=varargin{iarg}; 84 84 iarg=iarg+1; 85 85 86 86 if iarg <= nargin && iscell(varargin{iarg}) 87 87 descr=varargin{iarg}; … … 93 93 descr=cell(1:size(sampr,2)); 94 94 end 95 95 96 96 dresp=struct([]); 97 97 for i=1:size(sampr,2) … … 136 136 display('Using calculated normal fits from sample data.') 137 137 end 138 138 139 139 if ~isfield(dresp(i),'cdf') || isempty(dresp(i).cdf) 140 140 % use minus/plus integer standard deviations -
issm/trunk/src/m/qmu/plot/plot_rvsv_line.m
r7398 r13975 74 74 dvar=varargin{iarg}; 75 75 iarg=iarg+1; 76 76 77 77 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 78 78 if iarg <= nargin && iscell(varargin{iarg}) … … 80 80 iarg=iarg+1; 81 81 end 82 82 83 83 descv=cell (1,length(dvar)); 84 84 lsamp=zeros(1,length(dvar)); … … 96 96 sampv=varargin{iarg}; 97 97 iarg=iarg+1; 98 98 99 99 if iarg <= nargin && iscell(varargin{iarg}) 100 100 descv=varargin{iarg}; … … 119 119 dresp=varargin{iarg}; 120 120 iarg=iarg+1; 121 121 122 122 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 123 123 if iarg <= nargin && iscell(varargin{iarg}) … … 125 125 iarg=iarg+1; 126 126 end 127 127 128 128 descr=cell (1,length(dresp)); 129 129 lsamp=zeros(1,length(dresp)); … … 141 141 sampr=varargin{iarg}; 142 142 iarg=iarg+1; 143 143 144 144 if iarg <= nargin && iscell(varargin{iarg}) 145 145 descr=varargin{iarg}; … … 177 177 iarg=iarg+2; 178 178 end 179 179 180 180 if ~exist('nplotr','var') && ~exist('nplotc','var') 181 181 nplotr=1; … … 225 225 'IconDisplayStyle','off'); % Exclude line from legend 226 226 end 227 227 228 228 % add the annotation 229 229 -
issm/trunk/src/m/qmu/plot/plot_rvsv_scat3.m
r7398 r13975 79 79 dvar=varargin{iarg}; 80 80 iarg=iarg+1; 81 81 82 82 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 83 83 if iarg <= nargin && iscell(varargin{iarg}) … … 85 85 iarg=iarg+1; 86 86 end 87 87 88 88 descv=cell (1,length(dvar)); 89 89 lsamp=zeros(1,length(dvar)); … … 101 101 sampv=varargin{iarg}; 102 102 iarg=iarg+1; 103 103 104 104 if iarg <= nargin && iscell(varargin{iarg}) 105 105 descv=varargin{iarg}; … … 128 128 dresp=varargin{iarg}; 129 129 iarg=iarg+1; 130 130 131 131 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 132 132 if iarg <= nargin && iscell(varargin{iarg}) … … 134 134 iarg=iarg+1; 135 135 end 136 136 137 137 descr=cell (1,length(dresp)); 138 138 lsamp=zeros(1,length(dresp)); … … 150 150 sampr=varargin{iarg}; 151 151 iarg=iarg+1; 152 152 153 153 if iarg <= nargin && iscell(varargin{iarg}) 154 154 descr=varargin{iarg}; … … 187 187 iarg=iarg+2; 188 188 end 189 189 190 190 if ~exist('nplotr','var') && ~exist('nplotc','var') 191 191 nplotr=ceil(sqrt(size(sampr,2))); … … 208 208 209 209 for iresp=1:size(sampr,2) 210 210 211 211 % initialize the subplot 212 212 -
issm/trunk/src/m/qmu/plot/plot_rvsv_surf.m
r7398 r13975 76 76 dvar=varargin{iarg}; 77 77 iarg=iarg+1; 78 78 79 79 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 80 80 if iarg <= nargin && iscell(varargin{iarg}) … … 82 82 iarg=iarg+1; 83 83 end 84 84 85 85 descv=cell (1,length(dvar)); 86 86 lsamp=zeros(1,length(dvar)); … … 98 98 sampv=varargin{iarg}; 99 99 iarg=iarg+1; 100 100 101 101 if iarg <= nargin && iscell(varargin{iarg}) 102 102 descv=varargin{iarg}; … … 125 125 dresp=varargin{iarg}; 126 126 iarg=iarg+1; 127 127 128 128 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 129 129 if iarg <= nargin && iscell(varargin{iarg}) … … 131 131 iarg=iarg+1; 132 132 end 133 133 134 134 descr=cell (1,length(dresp)); 135 135 lsamp=zeros(1,length(dresp)); … … 147 147 sampr=varargin{iarg}; 148 148 iarg=iarg+1; 149 149 150 150 if iarg <= nargin && iscell(varargin{iarg}) 151 151 descr=varargin{iarg}; … … 184 184 iarg=iarg+2; 185 185 end 186 186 187 187 if ~exist('nplotr','var') && ~exist('nplotc','var') 188 188 nplotr=ceil(sqrt(size(sampr,2))); … … 208 208 z(ixi(i),iyi(i))=sampr(i,iresp); 209 209 end 210 210 211 211 % initialize the subplot 212 212 -
issm/trunk/src/m/qmu/plot/plot_sampdist_bars.m
r7398 r13975 72 72 dresp=varargin{iarg}; 73 73 iarg=iarg+1; 74 74 75 75 % if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg})) 76 76 if iarg <= nargin && iscell(varargin{iarg}) … … 81 81 sampr=varargin{iarg}; 82 82 iarg=iarg+1; 83 83 84 84 if iarg <= nargin && iscell(varargin{iarg}) 85 85 descr=varargin{iarg}; … … 91 91 descr=cell(1:size(sampr,2)); 92 92 end 93 93 94 94 dresp=struct([]); 95 95 for i=1:size(sampr,2) -
issm/trunk/src/m/qmu/process_qmu_options.m
r8987 r13975 99 99 outoptions.iparams=iparams; 100 100 outoptions.runmpi=runmpi; 101 -
issm/trunk/src/m/qmu/process_qmu_response_data.m
r9742 r13975 5 5 % 6 6 % See also PREQMU, PRESOLVE 7 8 7 9 8 %preliminary data … … 22 21 end 23 22 24 25 23 %deal with mass flux profiles 26 24 if process_mass_flux_profiles, … … 30 28 error('process_qmu_response_data error message: could not find a mass_flux exp profile!'); 31 29 end 32 30 33 31 if ~iscell(md.qmu.mass_flux_profiles), 34 32 error('process_qmu_response_data error message: qmu_mass_flux_profiles field should be a cell array of domain outline names'); -
issm/trunk/src/m/qmu/qmu_correlation.m
r9650 r13975 12 12 error('qmu_correlation error message: could not find dresp_dat field in dakota results. you need to run montecarlo before computing correlations'); 13 13 end 14 14 15 15 data=md.qmu.results.dresp_dat; 16 16 -
issm/trunk/src/m/qmu/qmuisdistributed.m
r5200 r13975 1 1 function found=qmuisdistribted(string) 2 2 %QMUISDISTRIBTED - figure out if a string is a decriptor with a numerical postfix. Like thickness1, or drag10 3 4 3 5 4 %just take last string element, and see if it is numeric. -
issm/trunk/src/m/qmu/qmumarshall.m
r9650 r13975 47 47 end 48 48 end 49 49 50 50 if qmu_segments, 51 51 WriteData(fid,md.qmu.mass_flux_num_profiles,'Integer','qmu_mass_flux_num_profiles'); … … 57 57 WriteData(fid,md.qmu.mass_flux_num_profiles,'Integer','qmu_mass_flux_num_profiles'); 58 58 end 59 60 59 61 60 %write part and npart to disk … … 71 70 end 72 71 73 function qmumarshallusage() ;72 function qmumarshallusage() 74 73 disp(' '); 75 74 disp('function qmumarshall(md.qmu.variables,responses)'); -
issm/trunk/src/m/qmu/qmuresponse.m
r4431 r13975 114 114 error(['qmuresponse error message: unknown descriptor ' descriptor]); 115 115 end 116 -
issm/trunk/src/m/qmu/qmuroot.m
r2157 r13975 11 11 end 12 12 end 13 -
issm/trunk/src/m/qmu/rlist_write.m
r13395 r13975 68 68 69 69 end 70 -
issm/trunk/src/m/qmu/sensitivities.m
r13395 r13975 8 8 % Example: sens=sensitivities(md,'DragCoefficient','MaxVel'); 9 9 % 10 11 10 12 11 variablenamelength=length(variablename); -
issm/trunk/src/m/qmu/setupdesign/IsScaled.m
r9742 r13975 12 12 13 13 case {'RiftsFriction'}, 14 14 15 15 status=2; %special treatment 16 16 -
issm/trunk/src/m/qmu/setupdesign/QmuSetupVariables.m
r9650 r13975 6 6 %decide whether this is a distributed variable, which will drive whether we expand it into npart values, 7 7 %or if we just carry it forward as is. 8 9 8 10 9 %ok, key off according to type of descriptor: -
issm/trunk/src/m/qmu/vector_write.m
r13395 r13975 31 31 nitem=nitem+1; 32 32 lsvec=lsvec+1+length(sitem); 33 33 34 34 if (nitem <= nmax) && (lsvec <= cmax) 35 35 svec=[svec ' ' sitem]; -
issm/trunk/src/m/regional/BasinConstrain.m
r13395 r13975 1 function md=BasinConstrain(md,domain) ;1 function md=BasinConstrain(md,domain) 2 2 %BASINCONSTRAIN - constrain basin 3 3 % -
issm/trunk/src/m/regional/BasinConstrainShelf.m
r13395 r13975 1 function md=BasinConstrainShelf(md,domain) ;1 function md=BasinConstrainShelf(md,domain) 2 2 %BASINCONSTRAIN - constrain basin 3 3 % -
issm/trunk/src/m/regional/basinzoom.m
r13395 r13975 39 39 %Ok, find basin we are talking about: 40 40 load([jplsvn() '/projects/ModelData/Names/Names.mat']); 41 41 42 42 %Go through names: 43 43 found=0; -
issm/trunk/src/m/regional/regionaltransient2d.m
r13395 r13975 31 31 32 32 %take every fields from model 33 mde=m odelextract(md1,area);33 mde=md1.extract(area); 34 34 mde.private.bamg=[]; 35 35 mde.mesh.extractedvertices=nan; … … 131 131 %Diagnostic. Don't spc the icefront vertices. 132 132 if ~isnan(md2.diagnostic.icefront) 133 md1s=m odelextract(md1,area);133 md1s=md1.extract(area); 134 134 %md2.diagnostic.icefront=[md2.mesh.segments 2]; 135 135 e2=md2.mesh.segments(:,end); … … 156 156 md2.results=[]; 157 157 end 158 -
issm/trunk/src/m/regional/showbasins.m
r13395 r13975 21 21 options=pairoptions(varargin{:}); 22 22 end 23 24 23 25 24 %recover some options, and set defaults -
issm/trunk/src/m/solve/MatlabProcessPatch.m
r13395 r13975 1 function structure=MatlabProcessPatch(structure) ;1 function structure=MatlabProcessPatch(structure) 2 2 %PROCESSPATCH - create a structure from a patch 3 3 % -
issm/trunk/src/m/solve/MatlabProcessPatch.py
r13395 r13975 8 8 9 9 #loop over steps 10 for structurei in structure .itervalues():10 for structurei in structure: 11 11 12 12 #return if there is no field Patch 13 if 'Patch' not in structurei:13 if not hasattr(structurei,'Patch'): 14 14 continue 15 15 -
issm/trunk/src/m/solve/WriteData.m
r13395 r13975 231 231 232 232 %Get Enum 233 enum= eval([string 'Enum();']);233 enum=StringToEnum(string); 234 234 end % }}} 235 235 function code=FormatToCode(format) % {{{ -
issm/trunk/src/m/solve/WriteData.py
r13395 r13975 17 17 #process options 18 18 # the import above the function level doesn't work? 19 from pairoptions import *19 from pairoptions import pairoptions 20 20 options=pairoptions(*args) 21 21 … … 101 101 elif strcmpi(format,'BooleanMat'): # {{{ 102 102 103 if isinstance(data,bool):103 if isinstance(data,bool): 104 104 data=numpy.array([data]) 105 elif isinstance(data,(list,tuple)): 106 data=numpy.array(data).reshape(-1,1) 105 107 if len(data.shape) == 1: 106 108 if numpy.size(data): … … 132 134 elif strcmpi(format,'IntMat'): # {{{ 133 135 134 if isinstance(data,(int,long)):136 if isinstance(data,(int,long)): 135 137 data=numpy.array([data]) 138 elif isinstance(data,(list,tuple)): 139 data=numpy.array(data).reshape(-1,1) 136 140 if len(data.shape) == 1: 137 141 if numpy.size(data): … … 163 167 elif strcmpi(format,'DoubleMat'): # {{{ 164 168 165 if isinstance(data,(bool,int,long,float)):169 if isinstance(data,(bool,int,long,float)): 166 170 data=numpy.array([data]) 171 elif isinstance(data,(list,tuple)): 172 data=numpy.array(data).reshape(-1,1) 167 173 if len(data.shape) == 1: 168 174 if numpy.size(data): … … 197 203 recordlength=4+4 #number of records + code 198 204 for matrix in data: 199 if isinstance(matrix,(bool,int,long,float)):205 if isinstance(matrix,(bool,int,long,float)): 200 206 matrix=numpy.array([matrix]) 207 elif isinstance(matrix,(list,tuple)): 208 matrix=numpy.array(matrix).reshape(-1,1) 201 209 if len(matrix.shape) == 1: 202 210 if numpy.size(matrix): … … 219 227 #write each matrix: 220 228 for matrix in data: 221 if isinstance(matrix,(bool,int,long,float)):229 if isinstance(matrix,(bool,int,long,float)): 222 230 matrix=numpy.array([matrix]) 231 elif isinstance(matrix,(list,tuple)): 232 matrix=numpy.array(matrix).reshape(-1,1) 223 233 if len(matrix.shape) == 1: 224 234 matrix=matrix.reshape(numpy.size(matrix),1) … … 276 286 277 287 #Get Enum 278 e xec('enum='+string+'Enum()',globals())288 enum=StringToEnum(string)[0] 279 289 280 290 return enum -
issm/trunk/src/m/solve/loadresultsfromdisk.m
r13395 r13975 50 50 end 51 51 52 53 52 %post processes qmu results if necessary 54 53 else -
issm/trunk/src/m/solve/loadresultsfromdisk.py
r13395 r13975 1 1 import os 2 from collections import OrderedDict2 from results import * 3 3 from parseresultsfromdisk import * 4 4 from EnumToString import EnumToString 5 from MatlabFuncs import * 5 6 6 7 def loadresultsfromdisk(md,filename): … … 23 24 24 25 #initialize md.results if not a structure yet 25 if not isinstance(md.results, dict):26 md.results= OrderedDict()26 if not isinstance(md.results,results): 27 md.results=results() 27 28 28 29 #load results onto model 29 structure=parseresultsfromdisk(filename, ~md.settings.io_gather)30 structure=parseresultsfromdisk(filename,not md.settings.io_gather) 30 31 if not len(structure): 31 32 raise RuntimeError("No result found in binary file '%s'. Check for solution crash." % filename) 32 md.results[structure[1]['SolutionType']]=structure;33 setattr(md.results,structure[0].SolutionType,structure) 33 34 34 35 #recover solution_type from results 35 md.private.solution=structure[ 1]['SolutionType']36 md.private.solution=structure[0].SolutionType 36 37 37 38 #read log files onto fields 38 39 if os.path.exists(md.miscellaneous.name+'.errlog'): 39 40 with open(md.miscellaneous.name+'.errlog','r') as f: 40 md.results[structure[1]['SolutionType']]['errlog']=[line[:-1] for line in f]41 setattr(getattr(md.results,structure[0].SolutionType)[0],'errlog',[line[:-1] for line in f]) 41 42 else: 42 md.results[structure[1]['SolutionType']]['errlog']=[]43 setattr(getattr(md.results,structure[0].SolutionType)[0],'errlog',[]) 43 44 44 45 if os.path.exists(md.miscellaneous.name+'.outlog'): 45 46 with open(md.miscellaneous.name+'.outlog','r') as f: 46 md.results[structure[1]['SolutionType']]['outlog']=[line[:-1] for line in f]47 setattr(getattr(md.results,structure[0].SolutionType)[0],'outlog',[line[:-1] for line in f]) 47 48 else: 48 md.results[structure[1]['SolutionType']]['outlog']=[]49 setattr(getattr(md.results,structure[0].SolutionType)[0],'outlog',[]) 49 50 50 if len( md.results[structure[1]['SolutionType']]['errlog']):51 if len(getattr(md.results,structure[0].SolutionType)[0].errlog): 51 52 print ("loadresultsfromcluster info message: error during solution. Check your errlog and outlog model fields.") 53 54 #if only one solution, extract it from list for user friendliness 55 if len(structure) == 1 and not strcmp(structure[0].SolutionType,'TransientSolution'): 56 setattr(md.results,structure[0].SolutionType,structure[0]) 52 57 53 58 #post processes qmu results if necessary -
issm/trunk/src/m/solve/marshall.m
r13395 r13975 36 36 %Marshall current object 37 37 %disp(['marshalling ' field '...']); 38 if verLessThan('matlab', '7.6') 39 marshall(md.(field),fid); 40 else 41 md.(field).marshall(fid); 42 end 38 marshall(md.(field),fid); 43 39 end 44 40 -
issm/trunk/src/m/solve/parseresultsfromdisk.m
r13395 r13975 19 19 % Usage: 20 20 % results=parseresultsfromdiskioserial(filename) 21 22 21 23 22 %Open file … … 54 53 % Usage: 55 54 % results=parseresultsfromdiskiosplit(filename) 56 57 55 58 56 %Open file … … 177 175 % field=ReadDataDimensions(fid) 178 176 179 180 177 %read field 181 178 [length,count]=fread(fid,1,'int'); -
issm/trunk/src/m/solve/parseresultsfromdisk.py
r13395 r13975 2 2 import numpy 3 3 from collections import OrderedDict 4 import results as resultsclass 4 5 from MatlabFuncs import * 5 6 from MatlabProcessPatch import * … … 37 38 raise IOError("loadresultsfromdisk error message: could not open '%s' for binary reading." % filename) 38 39 39 results= OrderedDict()40 results=[] 40 41 41 42 #Read fields until the end of the file. 42 43 result=ReadData(fid) 43 44 while result: 45 if result['step'] > len(results): 46 for i in xrange(len(results),result['step']-1): 47 results.append(None) 48 results.append(resultsclass.results()) 44 49 #Get time and step 45 if result['step'] not in results: 46 results[result['step']]=OrderedDict() 47 results[result['step']]['step']=result['step'] 48 results[result['step']]['time']=result['time'] 50 setattr(results[result['step']-1],'step',result['step']) 51 setattr(results[result['step']-1],'time',result['time']) 49 52 50 53 #Add result 51 if result['step'] in results and \ 52 result['fieldname'] in results[result['step']] and \ 53 not strcmp(result['fieldname'],'SolutionType'): 54 results[result['step']][result['fieldname']]=numpy.concatenate((results[result['step']][result['fieldname']],result['field']),axis=0) 55 else: 56 results[result['step']][result['fieldname']]=result['field'] 54 if hasattr(results[result['step']-1],result['fieldname']) and not strcmp(result['fieldname'],'SolutionType'): 55 setattr(results[result['step']-1],result['fieldname'],numpy.vstack((getattr(results[result['step']-1],result['fieldname']),result['field']))) 56 else: 57 setattr(results[result['step']-1],result['fieldname'],result['field']) 57 58 58 59 #read next result … … 78 79 raise IOError("loadresultsfromdisk error message: could not open '%s' for binary reading." % filename) 79 80 80 results= OrderedDict()81 results=[] 81 82 82 83 #if we have done split I/O, ie, we have results that are fragmented across patches, … … 86 87 87 88 #Get time and step 88 if result['step'] not in results: 89 results[result['step']]=OrderedDict() 90 results[result['step']]['step']=result['step'] 91 results[result['step']]['time']=result['time'] 89 if result['step'] > len(results): 90 for i in xrange(len(results),result['step']-1): 91 results.append(None) 92 results.append(resultsclass.results()) 93 setattr(results[result['step']-1],'step',result['step']) 94 setattr(results[result['step']-1],'time',result['time']) 92 95 93 96 #Add result 94 97 if strcmpi(result['fieldname'],'Patch'): 95 results[result['step']][result['fieldname']]=[0,result['N']]96 else: 97 results[result['step']][result['fieldname']]=float('NaN')98 setattr(results[result['step']-1],result['fieldname'],[0,result['N']]) 99 else: 100 setattr(results[result['step']-1],result['fieldname'],float('NaN')) 98 101 99 102 #read next result … … 107 110 #Add result 108 111 if strcmpi(result['fieldname'],'Patch'): 109 patchdimensions= results[result['step']][result['fieldname']]110 results[result['step']][result['fieldname']]=[patchdimensions[0]+result['M'],result['N']]112 patchdimensions=getattr(results[result['step']-1],result['fieldname']) 113 setattr(results[result['step']-1],result['fieldname'],[patchdimensions[0]+result['M'],result['N']]) 111 114 112 115 #read next result … … 116 119 for result in results.itervalues(): 117 120 if 'Patch' in result: 118 result['Patch']=numpy.zeros(shape=(result['Patch'][0],result['Patch'][1]),dtype=float)119 result['counter']=0#use to index into the patch121 setattr(result,'Patch',numpy.zeros((result['Patch'][0],result['Patch'][1]))) 122 setattr(result,'counter',0) #use to index into the patch 120 123 121 124 #third pass, this time to read the real information … … 125 128 126 129 #Get time and step 127 if result['step'] not in results: 128 results[result['step']]=OrderedDict() 129 results[result['step']]['step']=result['step'] 130 results[result['step']]['time']=result['time'] 130 if result['step']> len(results): 131 for i in xrange(len(results),result['step']-1): 132 results.append(None) 133 results.append(resultsclass.results()) 134 setattr(results[result['step']-1],'step',result['step']) 135 setattr(results[result['step']-1],'time',result['time']) 131 136 132 137 #Add result 133 138 if strcmpi(result['fieldname'],'Patch'): 134 counter=results[result['step'] ]['counter']139 counter=results[result['step']-1].counter 135 140 counter2=counter+result['field'].shape[0]-1 136 results[result['step']][result['fieldname']][counter:counter2,:]=result['field'] 137 141 getattr(results[result['step']-1],result['fieldname'])[counter:counter2,:]=result['field'] 138 142 #increment counter: 139 results[result['step'] ]['counter']=counter2+1140 else: 141 results[result['step']][result['fieldname']]=result['field']143 results[result['step']-1].counter=counter2+1 144 else: 145 setattr(results[result['step']-1],result['fieldname'],result['field']) 142 146 143 147 #read next result … … 188 192 189 193 except struct.error as e: 190 result= OrderedDict()194 result=None 191 195 192 196 return result … … 230 234 231 235 except struct.error as e: 232 result= OrderedDict()236 result=None 233 237 234 238 return result -
issm/trunk/src/m/solve/solve.m
r13395 r13975 74 74 end 75 75 76 77 76 %Write all input files 78 77 marshall(md); % bin file 79 78 PetscFile(md.solver,[md.miscellaneous.name '.petsc']); % petsc file 80 79 BuildQueueScript(cluster,md.private.runtimename,md.miscellaneous.name,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof); % queue file 81 82 80 83 81 %Stop here if batch mode -
issm/trunk/src/m/solve/waitonlock.m
r13395 r13975 12 12 cluster=md.cluster.name; 13 13 login=md.cluster.login; 14 port=md.cluster.port; 14 if isprop(md.cluster,'port') 15 port=md.cluster.port; 16 end 15 17 timelimit=md.settings.waitonlock; 16 18 filename=[executionpath '/' md.private.runtimename '/' md.miscellaneous.name '.lock']; -
issm/trunk/src/m/solvers/asmoptions.m
r13395 r13975 4 4 % Usage: 5 5 % options=asmoptions; 6 6 7 7 %retrieve options provided in varargin 8 8 options=pairoptions(varargin{:}); -
issm/trunk/src/m/solvers/iluasmoptions.m
r13395 r13975 4 4 % Usage: 5 5 % options=iluasmoptions; 6 6 7 7 %retrieve options provided in varargin 8 8 options=pairoptions(varargin{:}); -
issm/trunk/src/m/solvers/jacobiasmoptions.m
r13395 r13975 4 4 % Usage: 5 5 % options=jacobiasmoptions; 6 6 7 7 %retrieve options provided in varargin 8 8 options=pairoptions(varargin{:}); -
issm/trunk/src/m/solvers/jacobicgoptions.m
r13395 r13975 4 4 % Usage: 5 5 % options=jacobiasmoptions; 6 6 7 7 %retrieve options provided in varargin 8 8 options=pairoptions(varargin{:}); -
issm/trunk/src/m/solvers/matlaboptions.m
r13395 r13975 4 4 % Usage: 5 5 % options=matlaboptions; 6 6 7 7 %retrieve options provided in varargin 8 8 options=pairoptions(varargin{:}); -
issm/trunk/src/m/solvers/soroptions.m
r13395 r13975 4 4 % Usage: 5 5 % options=soroptions; 6 6 7 7 %retrieve options provided in varargin 8 8 options=pairoptions(varargin{:}); -
issm/trunk/src/m/string/issmprintf.m
r13395 r13975 8 8 % Example: 9 9 % issmprintf(1,'%s\n','string to display'); 10 10 11 11 if flag, 12 12 disp(sprintf(format,varargin{:})); -
issm/trunk/src/m/string/strsplit.m
r13395 r13975 16 16 17 17 % mailto: gie.spaepen@ua.ac.be 18 19 20 18 21 19 %Check input arguments … … 87 85 splittedstring = tempsplit; 88 86 end 89 90 87 91 88 end -
issm/trunk/src/m/string/strsplit_strict.m
r13395 r13975 4 4 % Usage: 5 5 % output = strsplit_strict(inpstr,delimiter) 6 7 6 8 7 %Check input arguments
Note:
See TracChangeset
for help on using the changeset viewer.