source: issm/trunk/src/c/SplitSolutionVectorx/SplitSolutionVectorx.cpp@ 3775

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

Created include.h header file

File size: 1.3 KB
Line 
1/*!\file SplitSolutionVectorx
2 */
3
4#include "./SplitSolutionVectorx.h"
5#include "../shared/shared.h"
6
7void SplitSolutionVectorx(Vec u_g,int numberofnodes,int numberofdofs, ...){
8
9 /*http://www.dreamincode.net/forums/topic/79104-variadic-functions-or-how-printf-works */
10
11 /*Intermediary*/
12 va_list outputlist;
13 double* u_g_serial=NULL;
14 double** pvector;
15 int i,count;
16
17 /*Serialize vector and allocate once for all*/
18 VecToMPISerial(&u_g_serial,u_g);
19
20 /* va_start() takes the arg list type we just declared, as well
21 as the last argument in this function's definition, ie. 'int numberofdofs'*/
22 va_start(outputlist,numberofdofs);
23
24 /*Loop over the arguments*/
25 count=0;
26 while (count<numberofdofs){
27 /* va_arg() takes the arg list from above, and the type
28 the argument is supposed to be and then (hopefully) returns it*/
29 pvector=va_arg(outputlist,double**);
30
31 //continue if the pointer is NULL (output not requested)
32 if (pvector==NULL) continue;
33
34 /*Dynamically allocate single dof vector*/
35 double* vector=NULL;
36 vector=(double*)xmalloc(numberofnodes*sizeof(double));
37
38 /*Fill vector*/
39 for (i=0;i<numberofnodes;i++) vector[i]=u_g_serial[i*numberofdofs+count];
40
41 /*Assign vector*/
42 *pvector=vector;
43
44 /*update counter*/
45 count++;
46 }
47 va_end (outputlist);
48}
Note: See TracBrowser for help on using the repository browser.