source: issm/oecreview/Archive/11730-11748/ISSM-11733-11734.diff@ 11991

Last change on this file since 11991 was 11991, checked in by Eric.Larour, 13 years ago

oecreview from 11518 to present

File size: 20.1 KB
RevLine 
[11991]1Index: /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/ElementMatrix.cpp
2===================================================================
3--- /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/ElementMatrix.cpp (revision 11733)
4+++ /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/ElementMatrix.cpp (revision 11734)
5@@ -259,47 +259,43 @@
6 /*In debugging mode, check consistency (no NaN, and values not too big)*/
7 this->CheckConsistency();
8
9- #ifdef _HAVE_PETSC_
10- if(this->dofsymmetrical){
11- /*only use row dofs to add values into global matrices: */
12-
13- if(this->row_fsize){
14- /*first, retrieve values that are in the f-set from the g-set values matrix: */
15- localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));
16- for(i=0;i<this->row_fsize;i++){
17- for(j=0;j<this->row_fsize;j++){
18- *(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]);
19- }
20- }
21- /*add local values into global matrix, using the fglobaldoflist: */
22- MatSetValues(Kff->matrix,this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,(const double*)localvalues,ADD_VALUES);
23+ if(this->dofsymmetrical){
24+ /*only use row dofs to add values into global matrices: */
25
26- /*Free ressources:*/
27- xfree((void**)&localvalues);
28+ if(this->row_fsize){
29+ /*first, retrieve values that are in the f-set from the g-set values matrix: */
30+ localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));
31+ for(i=0;i<this->row_fsize;i++){
32+ for(j=0;j<this->row_fsize;j++){
33+ *(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]);
34+ }
35 }
36+ /*add local values into global matrix, using the fglobaldoflist: */
37+ Kff->SetValues(this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,localvalues,ADD_VAL);
38
39+ /*Free ressources:*/
40+ xfree((void**)&localvalues);
41+ }
42
43- if((this->row_ssize!=0) && (this->row_fsize!=0)){
44- /*first, retrieve values that are in the f and s-set from the g-set values matrix: */
45- localvalues=(double*)xmalloc(this->row_fsize*this->row_ssize*sizeof(double));
46- for(i=0;i<this->row_fsize;i++){
47- for(j=0;j<this->row_ssize;j++){
48- *(localvalues+this->row_ssize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_slocaldoflist[j]);
49- }
50- }
51- /*add local values into global matrix, using the fglobaldoflist: */
52- MatSetValues(Kfs->matrix,this->row_fsize,this->row_fglobaldoflist,this->row_ssize,this->row_sglobaldoflist,(const double*)localvalues,ADD_VALUES);
53
54- /*Free ressources:*/
55- xfree((void**)&localvalues);
56+ if((this->row_ssize!=0) && (this->row_fsize!=0)){
57+ /*first, retrieve values that are in the f and s-set from the g-set values matrix: */
58+ localvalues=(double*)xmalloc(this->row_fsize*this->row_ssize*sizeof(double));
59+ for(i=0;i<this->row_fsize;i++){
60+ for(j=0;j<this->row_ssize;j++){
61+ *(localvalues+this->row_ssize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_slocaldoflist[j]);
62+ }
63 }
64+ /*add local values into global matrix, using the fglobaldoflist: */
65+ Kfs->SetValues(this->row_fsize,this->row_fglobaldoflist,this->row_ssize,this->row_sglobaldoflist,localvalues,ADD_VAL);
66+
67+ /*Free ressources:*/
68+ xfree((void**)&localvalues);
69 }
70- else{
71- _error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!");
72- }
73- #else
74- _error_("not supported yet!");
75- #endif
76+ }
77+ else{
78+ _error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!");
79+ }
80
81 }
82 /*}}}*/
83@@ -315,33 +311,29 @@
84 /*In debugging mode, check consistency (no NaN, and values not too big)*/
85 this->CheckConsistency();
86
87- #ifdef _HAVE_PETSC_
88- if(this->dofsymmetrical){
89- /*only use row dofs to add values into global matrices: */
90+ if(this->dofsymmetrical){
91+ /*only use row dofs to add values into global matrices: */
92
93- if(this->row_fsize){
94- /*first, retrieve values that are in the f-set from the g-set values matrix: */
95- localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));
96- for(i=0;i<this->row_fsize;i++){
97- for(j=0;j<this->row_fsize;j++){
98- *(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]);
99- }
100+ if(this->row_fsize){
101+ /*first, retrieve values that are in the f-set from the g-set values matrix: */
102+ localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));
103+ for(i=0;i<this->row_fsize;i++){
104+ for(j=0;j<this->row_fsize;j++){
105+ *(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]);
106 }
107- /*add local values into global matrix, using the fglobaldoflist: */
108- MatSetValues(Jff->matrix,this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,(const double*)localvalues,ADD_VALUES);
109-
110- /*Free ressources:*/
111- xfree((void**)&localvalues);
112 }
113+ /*add local values into global matrix, using the fglobaldoflist: */
114+ Jff->SetValues(this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,localvalues,ADD_VAL);
115
116+ /*Free ressources:*/
117+ xfree((void**)&localvalues);
118 }
119- else{
120- _error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!");
121- }
122- #else
123- _error_("not supported yet!");
124- #endif
125
126+ }
127+ else{
128+ _error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!");
129+ }
130+
131 }
132 /*}}}*/
133 /*FUNCTION ElementMatrix::CheckConsistency{{{1*/
134Index: /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/Vector.cpp
135===================================================================
136--- /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/Vector.cpp (revision 11733)
137+++ /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/Vector.cpp (revision 11734)
138@@ -24,7 +24,6 @@
139 /*FUNCTION Vector::Vector(){{{1*/
140 Vector::Vector(){
141
142- this->M=0;
143 #ifdef _HAVE_PETSC_
144 this->vector=NULL;
145 #else
146@@ -41,8 +40,7 @@
147 #ifdef _HAVE_PETSC_
148 this->vector=NewVec(pM,fromlocalsize);
149 #else
150- this->M=pM;
151- this->vector=(double*)xcalloc(pM,sizeof(double));
152+ this->vector=new SeqVec(pM,fromlocalsize);
153 #endif
154 #ifdef _HAVE_ADOLC_
155 this->avector=(adouble*)xmalloc(pM*sizeof(adouble));
156@@ -50,14 +48,14 @@
157 }
158 /*}}}*/
159 /*FUNCTION Vector::Vector(double* serial_vec,int M){{{1*/
160-Vector::Vector(double* serial_vec,int pM){
161+Vector::Vector(double* serial_vec,int M){
162
163 int i,j;
164
165 #ifdef _HAVE_PETSC_
166 int* idxm=NULL;
167
168- this->vector=NewVec(pM);
169+ this->vector=NewVec(M);
170
171 idxm=(int*)xmalloc(M*sizeof(int));
172 for(i=0;i<M;i++)idxm[i]=i;
173@@ -69,11 +67,10 @@
174 xfree((void**)&idxm);
175
176 #else
177- this->M=pM;
178- this->vector=(double*)xcalloc(pM,sizeof(double));
179+ this->vector=new SeqVec(serial_vec,M);
180 #endif
181 #ifdef _HAVE_ADOLC_
182- this->avector=(adouble*)xmalloc(pM*sizeof(adouble));
183+ this->avector=(adouble*)xmalloc(M*sizeof(adouble));
184 #endif
185 }
186 /*}}}*/
187@@ -81,9 +78,6 @@
188 /*FUNCTION Vector::Vector(Vec petsc_vec){{{1*/
189 Vector::Vector(Vec petsc_vec){
190
191- /*Get Vector size*/
192- VecGetSize(petsc_vec,&this->M);
193-
194 /*copy vector*/
195 VecDuplicate(petsc_vec,&this->vector);
196 VecCopy(petsc_vec,this->vector);
197@@ -97,7 +91,7 @@
198 #ifdef _HAVE_PETSC_
199 VecFree(&this->vector);
200 #else
201- xfree((void**)&this->vector);
202+ delete this->vector;
203 #endif
204 #ifdef _HAVE_ADOLC_
205 xfree((void**)&this->avector);
206@@ -114,18 +108,11 @@
207 #ifdef _HAVE_PETSC_
208 VecView(this->vector,PETSC_VIEWER_STDOUT_WORLD);
209 #else
210- printf("Vector size: %i\n",M);
211- for(i=0;i<M;i++){
212- printf("%g\n ",*(vector+i));
213- }
214+ this->vector->Echo();
215 #endif
216
217 #ifdef _HAVE_ADOLC_
218- /*Not sure about that one. Should we use the overloaded operator >>?*/
219- printf("ADOLC Vector equivalent:" );
220- for(i=0;i<M;i++){
221- printf("%g\n ",*(avector+i));
222- }
223+ /*do nothing for now: */
224 #endif
225 }
226 /*}}}*/
227@@ -138,12 +125,30 @@
228 #ifdef _HAVE_PETSC_
229 PetscVectorToMatlabVector(&dataref,this->vector);
230 #else
231- _error_("not implemented yet!");
232+ dataref=this->vector->ToMatlabVector();
233 #endif
234 return dataref;
235
236 }
237 /*}}}*/
238+/*FUNCTION MatlabVectorToVector{{{1*/
239+Vector* MatlabVectorToVector(const mxArray* mxvector){
240+
241+ int dummy;
242+ Vector* vector=NULL;
243+
244+ /*allocate vector object: */
245+ vector=new Vector();
246+
247+ #ifdef _HAVE_PETSC_
248+ MatlabVectorToPetscVector(&vector->vector,&dummy,mxvector);
249+ #else
250+ vector->vector=MatlabVectorToSeqVec(mxvector);
251+ #endif
252+
253+ return vector;
254+}
255+/*}}}*/
256 #endif
257 /*FUNCTION Vector::Assemble{{{1*/
258 void Vector::Assemble(void){
259@@ -153,7 +158,7 @@
260 VecAssemblyBegin(this->vector);
261 VecAssemblyEnd(this->vector);
262 #else
263- /*do nothing*/
264+ this->vector->Assemble();
265 #endif
266
267 }
268@@ -166,7 +171,7 @@
269 _assert_(this->vector);
270 VecSetValues(this->vector,ssize,list,values,ISSMToPetscInsertMode(mode));
271 #else
272- _error_("not implemented yet!");
273+ this->vector->SetValues(ssize,list,values,mode);
274 #endif
275
276 }
277@@ -178,7 +183,7 @@
278 _assert_(this->vector);
279 VecSetValues(this->vector,1,&dof,&value,ISSMToPetscInsertMode(mode));
280 #else
281- _error_("not implemented yet!");
282+ this->vector->SetValue(dof,value,mode);
283 #endif
284
285 }
286@@ -190,7 +195,7 @@
287 _assert_(this->vector);
288 VecGetValues(this->vector,1,&dof,pvalue);
289 #else
290- _error_("not implemented yet!");
291+ this->vector->GetValue(pvalue,dof);
292 #endif
293 }
294 /*}}}*/
295@@ -201,7 +206,7 @@
296 _assert_(this->vector);
297 VecGetSize(this->vector,pM);
298 #else
299- _error_("not implemented yet!");
300+ this->vector->GetSize(pM);
301 #endif
302
303 }
304@@ -213,7 +218,7 @@
305 _assert_(this->vector);
306 VecGetLocalSize(this->vector,pM);
307 #else
308- _error_("not implemented yet!");
309+ this->vector->GetLocalSize(pM);
310 #endif
311
312 }
313@@ -228,9 +233,8 @@
314 _assert_(this->vector);
315 VecDuplicate(this->vector,&vec_output);
316 output->vector=vec_output;
317- VecGetSize(output->vector,&output->M);
318 #else
319- _error_("not implemented yet!");
320+ output->vector=this->vector->Duplicate();
321 #endif
322 return output;
323
324@@ -243,7 +247,7 @@
325 _assert_(this->vector);
326 VecSet(this->vector,value);
327 #else
328- _error_("not implemented yet!");
329+ this->vector->Set(value);
330 #endif
331
332 }
333@@ -255,7 +259,7 @@
334 _assert_(this->vector);
335 VecAXPY(this->vector,a,X->vector);
336 #else
337- _error_("not implemented yet!");
338+ this->vector->AXPY(X->vector,a);
339 #endif
340 }
341 /*}}}*/
342@@ -266,7 +270,7 @@
343 _assert_(this->vector);
344 VecAYPX(this->vector,a,X->vector);
345 #else
346- _error_("not implemented yet!");
347+ this->vector->AYPX(X->vector,a);
348 #endif
349
350 }
351@@ -279,7 +283,7 @@
352 #ifdef _HAVE_PETSC_
353 VecToMPISerial(&vec_serial, this->vector);
354 #else
355- _error_("not implemented yet!");
356+ vec_serial=this->vector->ToMPISerial();
357 #endif
358
359 return vec_serial;
360@@ -292,7 +296,7 @@
361 #ifdef _HAVE_PETSC_
362 VecCopy(this->vector,to->vector);
363 #else
364- _error_("not implemented yet!");
365+ this->vector->Copy(to->vector);
366 #endif
367
368 }
369@@ -305,7 +309,7 @@
370 _assert_(this->vector);
371 VecNorm(this->vector,ISSMToPetscNormMode(norm_type),&norm);
372 #else
373- _error_("not implemented yet!");
374+ norm=this->vector->Norm(norm_type);
375 #endif
376 return norm;
377 }
378@@ -317,7 +321,7 @@
379 _assert_(this->vector);
380 VecScale(this->vector,scale_factor);
381 #else
382- _error_("not implemented yet!");
383+ this->vector->Scale(scale_factor);
384 #endif
385 }
386 /*}}}*/
387@@ -329,7 +333,7 @@
388 _assert_(this->vector);
389 VecDot(this->vector,vector->vector,&dot);
390 #else
391- _error_("not implemented yet!");
392+ dot=this->vector->Dot(vector->vector);
393 #endif
394 return dot;
395 }
396@@ -341,7 +345,7 @@
397 _assert_(this->vector);
398 VecPointwiseDivide(this->vector,x->vector,y->vector);
399 #else
400- _error_("not implemented yet!");
401+ this->vector->PointwiseDivide(x->vector,y->vector);
402 #endif
403 }
404 /*}}}*/
405Index: /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/Matrix.cpp
406===================================================================
407--- /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/Matrix.cpp (revision 11733)
408+++ /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/Matrix.cpp (revision 11734)
409@@ -47,7 +47,7 @@
410 #ifdef _HAVE_PETSC_
411 this->matrix=NewMat(pM,pN);
412 #else
413- this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
414+ this->matrix=new SeqMat(pM,pN);
415 #endif
416 #ifdef _HAVE_ADOLC_
417 this->amatrix=(adouble*)xmalloc(pM*pN*sizeof(adouble));
418@@ -63,7 +63,7 @@
419 #ifdef _HAVE_PETSC_
420 this->matrix=NewMat(pM,pN,sparsity);
421 #else
422- this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
423+ this->matrix=new SeqMat(pM,pN,sparsity);
424 #endif
425 #ifdef _HAVE_ADOLC_
426 this->amatrix=(adouble*)xmalloc(pM*pN*sizeof(adouble));
427@@ -96,7 +96,7 @@
428 xfree((void**)&idxm);
429 xfree((void**)&idxn);
430 #else
431- this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
432+ this->matrix=new SeqMat(serial_mat,pM,pN,sparsity);
433 #endif
434 #ifdef _HAVE_ADOLC_
435 this->amatrix=(adouble*)xmalloc(pM*pN*sizeof(adouble));
436@@ -112,7 +112,7 @@
437 #ifdef _HAVE_PETSC_
438 this->matrix=NewMat(pM,pN,connectivity,numberofdofspernode);
439 #else
440- this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
441+ this->matrix=new SeqMat(pM,pN,connectivity,numberofdofspernode);
442 #endif
443 #ifdef _HAVE_ADOLC_
444 this->amatrix=(adouble*)xmalloc(pM*pN*sizeof(adouble));
445@@ -125,7 +125,7 @@
446 #ifdef _HAVE_PETSC_
447 MatFree(&this->matrix);
448 #else
449- xfree((void**)&this->matrix);
450+ delete this->matrix;
451 #endif
452 #ifdef _HAVE_ADOLC_
453 xfree((void**)&this->amatrix);
454@@ -142,13 +142,7 @@
455 #ifdef _HAVE_PETSC_
456 MatView(this->matrix,PETSC_VIEWER_STDOUT_WORLD);
457 #else
458- printf("Matrix size: %i-%i\n",M,N);
459- for(i=0;i<M;i++){
460- for(j=0;j<N;j++){
461- printf("%g ",*(matrix+N*i+j));
462- }
463- printf("\n");
464- }
465+ this->matrix->Echo();
466 #endif
467
468 #ifdef _HAVE_ADOLC_
469@@ -172,12 +166,30 @@
470 #ifdef _HAVE_PETSC_
471 PetscMatrixToMatlabMatrix(&dataref,this->matrix);
472 #else
473- _error_("not implemented yet!");
474+ dataref=this->matrix->ToMatlabMatrix();
475 #endif
476 return dataref;
477
478 }
479 /*}}}*/
480+/*FUNCTION MatlabMatrixToMatrix{{{1*/
481+Matrix* MatlabMatrixToMatrix(const mxArray* mxmatrix){
482+
483+ int dummy;
484+ Matrix* matrix=NULL;
485+
486+ /*allocate matrix object: */
487+ matrix=new Matrix();
488+
489+ #ifdef _HAVE_PETSC_
490+ MatlabMatrixToPetscMatrix(&matrix->matrix,&matrix->M,&matrix->N,mxmatrix);
491+ #else
492+ matrix->matrix=MatlabMatrixToSeqMat(mxmatrix);
493+ #endif
494+
495+ return matrix;
496+}
497+/*}}}*/
498 #endif
499 /*FUNCTION Matrix::Assemble{{{1*/
500 void Matrix::Assemble(void){
501@@ -189,7 +201,7 @@
502 MatCompress(this->matrix);
503 #endif
504 #else
505- /*do nothing:*/
506+ this->matrix->Assemble();
507 #endif
508
509 }
510@@ -202,7 +214,7 @@
511 _assert_(this->matrix);
512 MatNorm(this->matrix,ISSMToPetscNormMode(norm_type),&norm);
513 #else
514- _error_("not implemented yet!");
515+ norm=this->matrix->Norm(norm_type);
516 #endif
517 return norm;
518 }
519@@ -214,7 +226,7 @@
520 _assert_(this->matrix);
521 MatGetSize(this->matrix,pM,pN);
522 #else
523- _error_("not implemented yet!");
524+ this->matrix->GetSize(pM,pN);
525 #endif
526 }
527 /*}}}*/
528@@ -225,7 +237,7 @@
529 _assert_(this->matrix);
530 MatGetLocalSize(this->matrix,pM,pN);
531 #else
532- _error_("not implemented yet!");
533+ this->matrix->GetLocalSize(pM,pN);
534 #endif
535 }
536 /*}}}*/
537@@ -237,7 +249,7 @@
538 _assert_(X->vector);
539 MatMultPatch(this->matrix,X->vector,AX->vector);
540 #else
541- _error_("not implemented yet!");
542+ this->matrix->MatMult(X->vector,AX->vector);
543 #endif
544 }
545 /*}}}*/
546@@ -248,11 +260,11 @@
547
548 output=new Matrix();
549
550- #ifdef _HAVE_PETSC
551+ #ifdef _HAVE_PETSC_
552 _assert_(this->matrix);
553 MatDuplicate(this->matrix,MAT_COPY_VALUES,&output->matrix);
554 #else
555- _error_("not implemented yet!");
556+ output->matrix=this->matrix->Duplicate();
557 #endif
558 }
559 /*}}}*/
560@@ -261,11 +273,21 @@
561
562 double* output=NULL;
563
564- #ifdef _HAVE_PETSC
565+ #ifdef _HAVE_PETSC_
566 MatToSerial(&output,this->matrix);
567 #else
568- _error_("not implemented yet!");
569+ output=this->matrix->ToSerial();
570 #endif
571 return output;
572 }
573 /*}}}*/
574+/*FUNCTION Matrix::SetValues{{{1*/
575+void Matrix::SetValues(int m,int* idxm,int n,int* idxn,double* values,InsMode mode){
576+
577+ #ifdef _HAVE_PETSC_
578+ MatSetValues(this->matrix,m,idxm,n,idxn,values,ISSMToPetscInsertMode(mode));
579+ #else
580+ this->matrix->SetValues(m,idxm,n,idxn,values,mode);
581+ #endif
582+}
583+/*}}}*/
584Index: /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/Vector.h
585===================================================================
586--- /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/Vector.h (revision 11733)
587+++ /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/Vector.h (revision 11734)
588@@ -30,12 +30,10 @@
589
590 public:
591
592- int M;
593-
594 #ifdef _HAVE_PETSC_
595 Vec vector;
596 #else
597- double* vector;
598+ SeqVec* vector;
599 #endif
600 #ifdef _HAVE_ADOLC_
601 adouble* avector;
602@@ -73,4 +71,10 @@
603 double Dot(Vector* vector);
604 /*}}}*/
605 };
606+
607+/*API: */
608+#ifdef _SERIAL_
609+Vector* MatlabVectorToVector(const mxArray* mxvector);
610+#endif
611+
612 #endif //#ifndef _VECTOR_H_
613Index: /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/Matrix.h
614===================================================================
615--- /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/Matrix.h (revision 11733)
616+++ /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/Matrix.h (revision 11734)
617@@ -36,7 +36,7 @@
618 #ifdef _HAVE_PETSC_
619 Mat matrix;
620 #else
621- double* matrix;
622+ SeqMat* matrix;
623 #endif
624 #ifdef _HAVE_ADOLC_
625 adouble* amatrix;
626@@ -62,7 +62,13 @@
627 void MatMult(Vector* X,Vector* AX);
628 Matrix* Duplicate(void);
629 double* ToSerial(void);
630+ void SetValues(int m,int* idxm,int n,int* idxn,double* values,InsMode mode);
631 /*}}}*/
632
633 };
634+/*API: */
635+#ifdef _SERIAL_
636+Matrix* MatlabMatrixToMatrix(const mxArray* mxmatrix);
637+#endif
638+
639 #endif //#ifndef _MATRIX_H_
640Index: /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/ElementVector.cpp
641===================================================================
642--- /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/ElementVector.cpp (revision 11733)
643+++ /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/Numerics/ElementVector.cpp (revision 11734)
644@@ -165,22 +165,18 @@
645 int i;
646 double* localvalues=NULL;
647
648- #ifdef _HAVE_PETSC_
649- if(this->fsize){
650- /*first, retrieve values that are in the f-set from the g-set values vector: */
651- localvalues=(double*)xmalloc(this->fsize*sizeof(double));
652- for(i=0;i<this->fsize;i++){
653- localvalues[i]=this->values[this->flocaldoflist[i]];
654- }
655- /*add local values into global vector, using the fglobaldoflist: */
656- VecSetValues(pf->vector,this->fsize,this->fglobaldoflist,(const double*)localvalues,ADD_VALUES);
657-
658- /*Free ressources:*/
659- xfree((void**)&localvalues);
660+ if(this->fsize){
661+ /*first, retrieve values that are in the f-set from the g-set values vector: */
662+ localvalues=(double*)xmalloc(this->fsize*sizeof(double));
663+ for(i=0;i<this->fsize;i++){
664+ localvalues[i]=this->values[this->flocaldoflist[i]];
665 }
666- #else
667- _error_("not supported yet!");
668- #endif
669+ /*add local values into global vector, using the fglobaldoflist: */
670+ pf->SetValues(this->fsize,this->fglobaldoflist,localvalues,ADD_VAL);
671+
672+ /*Free ressources:*/
673+ xfree((void**)&localvalues);
674+ }
675
676 }
677 /*}}}*/
678@@ -190,23 +186,19 @@
679 int i;
680 double* localvalues=NULL;
681
682- #ifdef _HAVE_PETSC_
683- if(this->fsize){
684- /*first, retrieve values that are in the f-set from the g-set values vector: */
685- localvalues=(double*)xmalloc(this->fsize*sizeof(double));
686- for(i=0;i<this->fsize;i++){
687- localvalues[i]=this->values[this->flocaldoflist[i]];
688- }
689- /*add local values into global vector, using the fglobaldoflist: */
690- VecSetValues(pf->vector,this->fsize,this->fglobaldoflist,(const double*)localvalues,INSERT_VALUES);
691-
692- /*Free ressources:*/
693- xfree((void**)&localvalues);
694+ if(this->fsize){
695+ /*first, retrieve values that are in the f-set from the g-set values vector: */
696+ localvalues=(double*)xmalloc(this->fsize*sizeof(double));
697+ for(i=0;i<this->fsize;i++){
698+ localvalues[i]=this->values[this->flocaldoflist[i]];
699 }
700- #else
701- _error_("not supported yet!");
702- #endif
703+ /*add local values into global vector, using the fglobaldoflist: */
704+ pf->SetValues(this->fsize,this->fglobaldoflist,localvalues,INS_VAL);
705
706+ /*Free ressources:*/
707+ xfree((void**)&localvalues);
708+ }
709+
710 }
711 /*}}}*/
712 /*FUNCTION ElementVector::Echo{{{1*/
Note: See TracBrowser for help on using the repository browser.