/[escript]/trunk/dudley/src/Assemble_CopyNodalData.cpp
ViewVC logotype

Diff of /trunk/dudley/src/Assemble_CopyNodalData.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1311 by gross, Mon Mar 26 06:17:53 2007 UTC revision 1312 by ksteube, Mon Sep 24 06:18:44 2007 UTC
# Line 1  Line 1 
 /*  
  ************************************************************  
  *          Copyright 2006 by ACcESS MNRF                   *  
  *                                                          *  
  *              http://www.access.edu.au                    *  
  *       Primary Business: Queensland, Australia            *  
  *  Licensed under the Open Software License version 3.0    *  
  *     http://www.opensource.org/licenses/osl-3.0.php       *  
  *                                                          *  
  ************************************************************  
 */  
 /**************************************************************/  
1    
2  /*    assemblage routines: copies data between different types nodal representation   */  /* $Id$ */
3    
4    /*******************************************************
5     *
6     *           Copyright 2003-2007 by ACceSS MNRF
7     *       Copyright 2007 by University of Queensland
8     *
9     *                http://esscc.uq.edu.au
10     *        Primary Business: Queensland, Australia
11     *  Licensed under the Open Software License version 3.0
12     *     http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16  /**************************************************************/  /**************************************************************/
17    
18  /*   author: gross@access.edu.au */  /*    assemblage routines: copies data between different types nodal representation   */
 /*   Version: $Id$ */  
19    
20  /**************************************************************/  /**************************************************************/
21    
# Line 25  Line 24 
24  #ifdef _OPENMP  #ifdef _OPENMP
25  #include <omp.h>  #include <omp.h>
26  #endif  #endif
 #ifdef PASO_MPI  
 #include "./paso/CommBuffer.h"  
 #endif  
   
   
 #ifdef PASO_MPI  
 /*    
   this function does no checking that the input are OK, so it has been put here, to  
   only be used in Finley_Assemble_CopyNodalData() which does the checking for it.  
   
   bufferExternal must be large enough to accomdate the external nodal data (numComps*numExternal)  
 */  
 static bool_t getExternalDOF( Finley_NodeFile *nodes, escriptDataC* in, double *externalBuffer, dim_t numComps, bool_t doReduced )  
 {  
   double *sendBuffer=NULL;  
   index_t n, i, myMax=0;  
   bool_t result=TRUE;  
     Finley_NodeDistribution *distribution=NULL;  
     Paso_CommBuffer *CommBuffer=NULL;  
     if( doReduced ) {  
         distribution = nodes->reducedDegreeOfFreedomDistribution;  
         CommBuffer = nodes->reducedCommBuffer;  
     }  
     else {  
         distribution = nodes->degreeOfFreedomDistribution;  
         CommBuffer = nodes->CommBuffer;  
     }  
   
   for( i=0; i<distribution->numNeighbours; i++ )  
     if( myMax < distribution->edges[i]->numForward )  
       myMax = distribution->edges[i]->numForward;  
   if( myMax )  
     sendBuffer = MEMALLOC( myMax*numComps, double );  
   
   /* pack and send DOF information to neighbour domains */  
   for( n=0; n<distribution->numNeighbours; n++ )  
   {  
     /* pack data */  
       for( i=0; i<distribution->edges[n]->numForward; i++ )  
       memcpy( sendBuffer + i*numComps, getSampleData(in,distribution->edges[n]->indexForward[i]), numComps*sizeof(double) );  
       
     /* place it in the send buffer */  
     Paso_CommBuffer_pack( CommBuffer, distribution->neighbours[n], NULL, sendBuffer, numComps*sizeof(double), 0 );  
     
     /* send it */  
     result = Paso_CommBuffer_send( CommBuffer, distribution->neighbours[n], numComps*sizeof(double) );  
     if( result==FALSE )  
       return FALSE;  
   }  
   
   MEMFREE( sendBuffer );  
   
   /* receive and unpack external DOF information from neigbours */  
   for( n=0; n<distribution->numNeighbours; n++ )  
   {  
     /* receive data */  
     result = Paso_CommBuffer_recv( CommBuffer, distribution->neighbours[n], numComps*sizeof(double) );  
     if( result==FALSE )  
       return FALSE;  
   
     /* unpack the data */  
     Paso_CommBuffer_unpack( CommBuffer, distribution->neighbours[n], distribution->edges[n]->indexBackward, externalBuffer, numComps*sizeof(double), -distribution->numLocal );  
   }  
   
   return TRUE;  
 }  
 #endif  
   
 /******************************************************************************************************/  
   
27    
28  void Finley_Assemble_CopyNodalData(Finley_NodeFile* nodes,escriptDataC* out,escriptDataC* in) {  void Finley_Assemble_CopyNodalData(Finley_NodeFile* nodes,escriptDataC* out,escriptDataC* in) {
29      dim_t n,i;      dim_t n,i,k,l, mpiSize;
30      dim_t numComps=getDataPointSize(out);      dim_t numComps=getDataPointSize(out);
31      type_t in_data_type=getFunctionSpaceType(in);      type_t in_data_type=getFunctionSpaceType(in);
32      type_t out_data_type=getFunctionSpaceType(out);      type_t out_data_type=getFunctionSpaceType(out);
33        index_t upperBound;
34        double* recv_buffer;
35        size_t numComps_size=0;
36      Finley_resetError();      Finley_resetError();
37      if (nodes==NULL) return;      if (nodes==NULL) return;
38        mpiSize=nodes->MPIInfo->size;
39    
40      /* check out and in */      /* check out and in */
41      if (numComps!=getDataPointSize(in)) {      if (numComps!=getDataPointSize(in)) {
# Line 111  void Finley_Assemble_CopyNodalData(Finle Line 44  void Finley_Assemble_CopyNodalData(Finle
44         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: expanded Data object is expected for output data.");         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: expanded Data object is expected for output data.");
45      }      }
46    
     /* TODO */  
47      /* more sophisticated test needed for overlapping node/DOF counts */      /* more sophisticated test needed for overlapping node/DOF counts */
48      if (in_data_type == FINLEY_NODES) {      if (in_data_type == FINLEY_NODES) {
49          if (! numSamplesEqual(in,1,nodes->numNodes)) {          if (! numSamplesEqual(in,1,Finley_NodeFile_getNumNodes(nodes))) {
50                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");
51         }         }
52      } else if (in_data_type == FINLEY_REDUCED_NODES) {      } else if (in_data_type == FINLEY_REDUCED_NODES) {
53         /* TODO */         if (! numSamplesEqual(in,1,Finley_NodeFile_getNumReducedNodes(nodes))) {
54         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: reduced nodes is not supported yet.");                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");
55           }
56      } else if (in_data_type == FINLEY_DEGREES_OF_FREEDOM) {      } else if (in_data_type == FINLEY_DEGREES_OF_FREEDOM) {
57  #ifdef PASO_MPI          if (! numSamplesEqual(in,1,Finley_NodeFile_getNumDegreesOfFreedom(nodes))) {
         if (! numSamplesEqual(in,1,nodes->degreeOfFreedomDistribution->numLocal)) {  
 #else  
         if (! numSamplesEqual(in,1,nodes->numDegreesOfFreedom)) {  
 #endif  
58                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");
59         }         }
60           if ( (((out_data_type == FINLEY_NODES) || (out_data_type == FINLEY_DEGREES_OF_FREEDOM)) && !isExpanded(in) && (mpiSize>1))) {
61    
62                   Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: FINLEY_DEGREES_OF_FREEDOM to FINLEY_NODES or FINLEY_DEGREES_OF_FREEDOM requires expanded input data on more than one processor.");
63           }
64      } else if (in_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {      } else if (in_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
65  #ifdef PASO_MPI          if (! numSamplesEqual(in,1,Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes))) {
66          if (! numSamplesEqual(in,1,nodes->reducedDegreeOfFreedomDistribution->numLocal)) {              Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");
67  #else         }
68          if (! numSamplesEqual(in,1,nodes->reducedNumDegreesOfFreedom)) {         if ( (out_data_type == FINLEY_DEGREES_OF_FREEDOM) && !isExpanded(in) && (mpiSize>1)) {
69  #endif  
70                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: FINLEY_REDUCED_DEGREES_OF_FREEDOM to FINLEY_DEGREES_OF_FREEDOM requires expanded input data on more than one processor.");
71         }         }
72      } else {      } else {
73         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal function space type for target object");         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal function space type for target object");
74      }      }
75            
76      if (out_data_type == FINLEY_NODES) {      if (out_data_type == FINLEY_NODES) {
77          if (! numSamplesEqual(out,1,nodes->numNodes)) {          if (! numSamplesEqual(out,1,Finley_NodeFile_getNumNodes(nodes))) {
78                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");
79         }         }
80      } else if (out_data_type == FINLEY_REDUCED_NODES) {      } else if (out_data_type == FINLEY_REDUCED_NODES) {
81         /* TODO */         if (! numSamplesEqual(out,1,Finley_NodeFile_getNumReducedNodes(nodes))) {
82         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: reduced nodes is not supported yet.");                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");
83           }
84      } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {      } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
85  #ifdef PASO_MPI          if (! numSamplesEqual(out,1,Finley_NodeFile_getNumDegreesOfFreedom(nodes))) {
         if (! numSamplesEqual(out,1,nodes->degreeOfFreedomDistribution->numLocal)) {  
 #else  
         if (! numSamplesEqual(out,1,nodes->numDegreesOfFreedom)) {  
 #endif  
86                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");
87         }         }
88      } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {      } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
89  #ifdef PASO_MPI          if (! numSamplesEqual(out,1,Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes))) {
         if (! numSamplesEqual(out,1,nodes->reducedDegreeOfFreedomDistribution->numLocal)) {  
 #else  
         if (! numSamplesEqual(out,1,nodes->reducedNumDegreesOfFreedom)) {  
 #endif  
90                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");                 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");
91         }         }
92      } else {      } else {
# Line 169  void Finley_Assemble_CopyNodalData(Finle Line 95  void Finley_Assemble_CopyNodalData(Finle
95    
96      /* now we can start */      /* now we can start */
97    
    /* This is where the "MPI magic" that shares the data accross domain boundaries occurs.  
       when the user asks to copy from DegreesOfFreedom (non-overlapping solution) to  
       Nodes (overlapping continuous), communication is required to get the DOF values  
       corresponding to external nodes from neighbouring domains. Communication is handled by  
       the Paso_CommBuffer that is attached to nodes. Copying the other direction (nodes to DOF)  
       is similar to the serial case, with just a little bit more care required to ensure that  
       only local values are copied. */  
98      if (Finley_noError()) {      if (Finley_noError()) {
99            /*********************** FINLEY_NODES **************************************************/
100            numComps_size=(size_t)numComps*sizeof(double);
101          if (in_data_type == FINLEY_NODES) {          if (in_data_type == FINLEY_NODES) {
102    
103             if  (out_data_type == FINLEY_NODES) {             if  (out_data_type == FINLEY_NODES) {
104                #pragma omp parallel for private(n) schedule(static)                #pragma omp parallel for private(n) schedule(static)
105                for (n=0;n<nodes->numNodes;n++)                for (n=0;n<nodes->nodesMapping->numNodes;n++) {
106                     Finley_copyDouble(numComps,getSampleData(in,n),getSampleData(out,n));                     memcpy(getSampleDataFast(out,n), getSampleDataFast(in,n), numComps_size);
107             } else if (in_data_type == FINLEY_REDUCED_NODES) { /* TODO */                }
108               Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from nodes to reduced nodes.");  
109               } else if (out_data_type == FINLEY_REDUCED_NODES) {
110                  #pragma omp parallel for private(n,i) schedule(static)
111                  for (n=0;n<nodes->reducedNodesMapping->numTargets;n++) {
112                       memcpy(getSampleDataFast(out,n),
113                              getSampleDataFast(in,nodes->reducedNodesMapping->map[n]),
114                              numComps_size);
115                  }
116             } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {             } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
117              int nComps = Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);
118                #pragma omp parallel for private(n) schedule(static)                #pragma omp parallel for private(n) schedule(static)
119                for (n=0;n<nodes->numNodes;n++)                for (n=0;n<nComps;n++) {
120  #ifdef PASO_MPI                     memcpy(getSampleDataFast(out,n),
121                  if( nodes->degreeOfFreedom[n]<nodes->degreeOfFreedomDistribution->numLocal )                            getSampleDataFast(in,nodes->degreesOfFreedomMapping->map[n]),
122  #endif                            numComps_size);
123                     Finley_copyDouble(numComps,getSampleData(in,n),getSampleData(out,nodes->degreeOfFreedom[n]));                }
124    
125             } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {             } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
126              int nComps = Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);
127                #pragma omp parallel for private(n,i) schedule(static)                #pragma omp parallel for private(n,i) schedule(static)
128                for (i=0;i<nodes->numNodes;i++) {                for (n=0;n<nComps;n++) {
129                     n=nodes->reducedDegreeOfFreedom[i];                     memcpy(getSampleDataFast(out,n),
130  #ifdef PASO_MPI                            getSampleDataFast(in,nodes->reducedDegreesOfFreedomMapping->map[n]),
131                  if( n>=0 && nodes->degreeOfFreedom[n]<nodes->degreeOfFreedomDistribution->numLocal )                            numComps_size);
 #else  
                 if (n>=0)  
 #endif            
                   Finley_copyDouble(numComps,getSampleData(in,i),getSampleData(out,n));  
132                }                }
133             }             }
134            /*********************** FINLEY_REDUCED_NODES **************************************************/
135          } else if (in_data_type == FINLEY_REDUCED_NODES) {          } else if (in_data_type == FINLEY_REDUCED_NODES) {
136    
137             if  (out_data_type == FINLEY_NODES) {             if  (out_data_type == FINLEY_NODES) {
138               Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced nodes to nodes.");               Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced nodes to nodes.");
139             } else if (in_data_type == FINLEY_REDUCED_NODES) { /* TODO */  
140               Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced nodes to reduced nodes.");             } else if (out_data_type == FINLEY_REDUCED_NODES) {
141                  #pragma omp parallel for private(n) schedule(static)
142                  for (n=0;n<nodes->reducedNodesMapping->numNodes;n++) {
143                       memcpy(getSampleDataFast(out,n),getSampleDataFast(in,n),numComps_size);
144                  }
145    
146             } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {             } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
147               Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced nodes to degrees of freedom.");               Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced nodes to degrees of freedom.");
148             } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {             } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
149               Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced nodes to reduced degrees of freedom.");            int nComps = Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);
150                  #pragma omp parallel for private(n,k) schedule(static)
151                  for (n=0;n<nComps;n++) {
152                       k=nodes->reducedDegreesOfFreedomMapping->map[n];
153                       memcpy(getSampleDataFast(out,n),
154                              getSampleDataFast(in,nodes->reducedNodesMapping->target[k]),
155                              numComps_size);
156                  }
157             }             }
158    
159            /*********************** FINLEY_DEGREES_OF_FREEDOM **************************************************/
160          } else if (in_data_type == FINLEY_DEGREES_OF_FREEDOM) {          } else if (in_data_type == FINLEY_DEGREES_OF_FREEDOM) {
161              if  (out_data_type == FINLEY_NODES)  
162              {              if  (out_data_type == FINLEY_NODES) {
163  #ifdef PASO_MPI                 Paso_Coupler_allocBuffer(nodes->degreesOfFreedomCoupler,numComps);
164                double *externalBuffer = MEMALLOC( numComps*nodes->degreeOfFreedomDistribution->numExternal, double );                 if (Paso_noError()) {
165                getExternalDOF( nodes, in, externalBuffer, numComps, FALSE );                      Paso_Coupler_startCollect(nodes->degreesOfFreedomCoupler,getSampleDataFast(in,0));
166                for (n=0;n<nodes->numNodes;n++) {                      recv_buffer=Paso_Coupler_finishCollect(nodes->degreesOfFreedomCoupler);
167                  if( nodes->degreeOfFreedom[n]<nodes->degreeOfFreedomDistribution->numLocal )                      upperBound=Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);
168                    Finley_copyDouble(numComps,getSampleData(in,nodes->degreeOfFreedom[n]),getSampleData(out,n));                      #pragma omp parallel for private(n,k) schedule(static)
169                  else                      for (n=0;n<nodes->numNodes;n++) {
170                    Finley_copyDouble(numComps,externalBuffer + numComps*(nodes->degreeOfFreedom[n] - nodes->degreeOfFreedomDistribution->numLocal),getSampleData(out,n));                            k=nodes->degreesOfFreedomMapping->target[n];
171                              }                            if (k < upperBound) {
172                                                  memcpy(getSampleDataFast(out,n),
173                MEMFREE( externalBuffer );                                         getSampleDataFast(in,k),
174  #else                                         numComps_size);
175                #pragma omp parallel for private(n) schedule(static)                             } else {
176                for (n=0;n<nodes->numNodes;n++)                                  memcpy(getSampleDataFast(out,n),
177                     Finley_copyDouble(numComps,getSampleData(in,nodes->degreeOfFreedom[n]),getSampleData(out,n));                                         &recv_buffer[(k-upperBound)*numComps],
178  #endif                                         numComps_size);
179                               }
180                        }
181                        Paso_Coupler_freeBuffer(nodes->degreesOfFreedomCoupler);
182                   }
183    
184                } else if  (out_data_type == FINLEY_REDUCED_NODES) {
185                   Paso_Coupler_allocBuffer(nodes->degreesOfFreedomCoupler,numComps);
186                   if (Paso_noError()) {
187                        Paso_Coupler_startCollect(nodes->degreesOfFreedomCoupler,getSampleDataFast(in,0));
188                        recv_buffer=Paso_Coupler_finishCollect(nodes->degreesOfFreedomCoupler);
189                        upperBound=Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);
190                        #pragma omp parallel for private(n,k,l) schedule(static)
191                        for (n=0;n<nodes->reducedNodesMapping->numTargets;n++) {
192                              l=nodes->reducedNodesMapping->map[n];
193                              k=nodes->degreesOfFreedomMapping->target[l];
194                              if (k < upperBound) {
195                                    memcpy(getSampleDataFast(out,n),
196                                           getSampleDataFast(in,k),
197                                           numComps_size);
198                               } else {
199                                    memcpy(getSampleDataFast(out,n),
200                                           &recv_buffer[(k-upperBound)*numComps],
201                                           numComps_size);
202                               }
203                        }
204                        Paso_Coupler_freeBuffer(nodes->degreesOfFreedomCoupler);
205                   }
206             } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {             } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
207              int nComps = Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);
208                #pragma omp parallel for private(n) schedule(static)                #pragma omp parallel for private(n) schedule(static)
209                for (n=0;n<nodes->numDegreesOfFreedom;n++)                for (n=0;n<nComps;n++) {
210                      Finley_copyDouble(numComps,getSampleData(in,n),getSampleData(out,n));                      memcpy(getSampleDataFast(out,n),getSampleDataFast(in,n),numComps_size);
211                  }
212    
213             } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {             } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
214                #pragma omp parallel for private(n,i) schedule(static)            int nComps = Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);
215                for (i=0;i<nodes->numNodes;i++) {                #pragma omp parallel for private(n,k) schedule(static)
216                    n=nodes->reducedDegreeOfFreedom[i];                for (n=0;n<nComps;n++) {
217  #ifdef PASO_MPI                     k=nodes->reducedDegreesOfFreedomMapping->map[n];
218                  if( n>=0 && n<nodes->reducedDegreeOfFreedomDistribution->numLocal )                     memcpy(getSampleDataFast(out,n),
219  #else                            getSampleDataFast(in,nodes->degreesOfFreedomMapping->target[k]),
220                  if (n>=0)                            numComps_size);
 #endif    
                    Finley_copyDouble(numComps,getSampleData(in,nodes->degreeOfFreedom[i]),getSampleData(out,n));  
221                }                }
222             }             }
223    
224          } else if (in_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {          } else if (in_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
225             if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {  
226                #pragma omp parallel for private(n) schedule(static)             if  (out_data_type == FINLEY_NODES) {
227                for (n=0;n<nodes->reducedNumDegreesOfFreedom;n++)               Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced degrees of freedom to nodes.");
228                      Finley_copyDouble(numComps,getSampleData(in,n),getSampleData(out,n));  
229             } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM ) {             } else if (out_data_type == FINLEY_REDUCED_NODES) {
230                #pragma omp parallel for private(n) schedule(static)                 Paso_Coupler_allocBuffer(nodes->reducedDegreesOfFreedomCoupler,numComps);
231                for (i=0;i<nodes->numNodes;i++) {                 if (Paso_noError()) {
232                    n=nodes->reducedDegreeOfFreedom[i];                      Paso_Coupler_startCollect(nodes->reducedDegreesOfFreedomCoupler,getSampleDataFast(in,0));
233  #ifdef PASO_MPI                      recv_buffer=Paso_Coupler_finishCollect(nodes->reducedDegreesOfFreedomCoupler);
234                      if( n>=0 && nodes->reducedDegreeOfFreedom[n]<nodes->reducedDegreeOfFreedomDistribution->numLocal )                      upperBound=Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);
235  #else                      #pragma omp parallel for private(n,k,l) schedule(static)
236                    if (n>=0)                      for (n=0;n<nodes->reducedNodesMapping->numTargets;n++) {
237  #endif                            l=nodes->reducedNodesMapping->map[n];
238                      Finley_copyDouble(numComps,getSampleData(in,n),getSampleData(out,nodes->degreeOfFreedom[i]));                            k=nodes->reducedDegreesOfFreedomMapping->target[l];
239                }                            if (k < upperBound) {
240             } else if (out_data_type == FINLEY_NODES ) {                                  memcpy(getSampleDataFast(out,n),
241  #ifdef PASO_MPI                                         getSampleDataFast(in,k),
242                double *externalBuffer = MEMALLOC( numComps*nodes->reducedDegreeOfFreedomDistribution->numExternal, double );                                         numComps_size);
243                getExternalDOF( nodes, in, externalBuffer, numComps, TRUE );                             } else {
244                for (n=0;n<nodes->numNodes;n++) {                                  memcpy(getSampleDataFast(out,n),
245                                  i = nodes->reducedDegreeOfFreedom[n];                                         &recv_buffer[(k-upperBound)*numComps],
246                                  if( i>=0 ) {                                         numComps_size);
247                                      if( i<nodes->reducedDegreeOfFreedomDistribution->numLocal )                             }
248                                          Finley_copyDouble(numComps,getSampleData(in,i),getSampleData(out,n));                      }
249                                      else                      Paso_Coupler_freeBuffer(nodes->reducedDegreesOfFreedomCoupler);
250                                          Finley_copyDouble(numComps,externalBuffer + numComps*(i - nodes->reducedDegreeOfFreedomDistribution->numLocal),getSampleData(out,n));                 }
251                                  }  
252                              }             } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
253                            int nComps = Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);
               MEMFREE( externalBuffer );  
 #else  
254                #pragma omp parallel for private(n) schedule(static)                #pragma omp parallel for private(n) schedule(static)
255                for (i=0;i<nodes->numNodes;i++) {                for (n=0;n<nComps;n++) {
256                    n=nodes->reducedDegreeOfFreedom[i];                      memcpy(getSampleDataFast(out,n),getSampleDataFast(in,n),numComps_size);
                   if (n>=0)  
                                         Finley_copyDouble(numComps,getSampleData(in,n),getSampleData(out,i));  
257                }                }
258  #endif  
259             } else {             } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM ) {
260               Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from data on reduced degrees of freedom");               Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced degrees of freedom to degrees of freedom.");
261             }             }
262          }          }
263     }     }
264     return;     return;
265  }  }
266    
   
   
 /*  
  * $Log$  
  * Revision 1.4  2005/09/15 03:44:21  jgs  
  * Merge of development branch dev-02 back to main trunk on 2005-09-15  
  *  
  * Revision 1.3  2005/08/12 01:45:42  jgs  
  * erge of development branch dev-02 back to main trunk on 2005-08-12  
  *  
  * Revision 1.2.2.3  2005/09/07 06:26:17  gross  
  * the solver from finley are put into the standalone package paso now  
  *  
  * Revision 1.2.2.2  2005/08/09 02:23:12  gross  
  * print statement removed  
  *  
  * Revision 1.2.2.1  2005/08/03 09:55:33  gross  
  * ContactTest is passing now./mk install!  
  *  
  * Revision 1.2  2005/07/08 04:07:45  jgs  
  * Merge of development branch back to main trunk on 2005-07-08  
  *  
  * Revision 1.1.1.1.2.1  2005/06/29 02:34:46  gross  
  * some changes towards 64 integers in finley  
  *  
  * Revision 1.1.1.1  2004/10/26 06:53:56  jgs  
  * initial import of project esys2  
  *  
  * Revision 1.2  2004/07/21 05:00:54  gross  
  * name changes in DataC  
  *  
  * Revision 1.1  2004/07/02 04:21:13  gross  
  * Finley C code has been included  
  *  
  *  
  */  

Legend:
Removed from v.1311  
changed lines
  Added in v.1312

  ViewVC Help
Powered by ViewVC 1.1.26