/[escript]/branches/doubleplusgood/paso/src/SharedComponents.cpp
ViewVC logotype

Diff of /branches/doubleplusgood/paso/src/SharedComponents.cpp

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

revision 2548 by jfenwick, Mon Jul 20 06:20:06 2009 UTC revision 3911 by jfenwick, Thu Jun 14 01:01:03 2012 UTC
# Line 1  Line 1 
1    
2  /*******************************************************  /*******************************************************
3  *  *
4  * Copyright (c) 2003-2009 by University of Queensland  * Copyright (c) 2003-2012 by University of Queensland
5  * Earth Systems Science Computational Center (ESSCC)  * Earth Systems Science Computational Center (ESSCC)
6  * http://www.uq.edu.au/esscc  * http://www.uq.edu.au/esscc
7  *  *
# Line 14  Line 14 
14    
15  /**************************************************************/  /**************************************************************/
16    
17  /* Paso: SharedComponents organizes the coupling with in a pattern/matrix   */  /* Paso: SharedComponents organizes the coupling within a     */
18  /*       across processors                                         */  /*       pattern/matrix across processors                     */
19    
20  /**************************************************************/  /**************************************************************/
21    
22  /* Author: gross@access.edu.au */  /* Author: Lutz Gross, l.gross@uq.edu.au                      */
23    
24  /**************************************************************/  /**************************************************************/
25    
26  #include "SharedComponents.h"  #include "SharedComponents.h"
27    #include "esysUtils/error.h"
28    
29  /**************************************************************/  /**************************************************************/
30    
31  /* allocates a SharedComponents  */  /* allocates SharedComponents  */
   
32    
33  /**************************************************************/  /**************************************************************/
34    
35  Paso_SharedComponents* Paso_SharedComponents_alloc(dim_t local_length,  Paso_SharedComponents* Paso_SharedComponents_alloc(dim_t local_length,
36                                                     dim_t numNeighbors,                                                     dim_t numNeighbors,
37                                                     Paso_MPI_rank* neighbor,                                                     Esys_MPI_rank* neighbor,
38                                                     index_t* shared,                                                     index_t* shared,
39                                                     index_t* offsetInShared,                                                     index_t* offsetInShared,
40                                                     index_t m, index_t b,                                                     index_t m, index_t b,
41                                                     Paso_MPIInfo *mpi_info)                                                     Esys_MPIInfo *mpi_info)
42  {  {
43    dim_t i,j;    dim_t i,j;
44    register index_t itmp;    register index_t itmp;
45    Paso_SharedComponents* out=NULL;    Paso_SharedComponents* out=NULL;
46    Paso_resetError();    Esys_resetError();
47    out=MEMALLOC(1,Paso_SharedComponents);    out=MEMALLOC(1,Paso_SharedComponents);
48    if (!Paso_checkPtr(out)) {    if (!Esys_checkPtr(out)) {
49        out->local_length=local_length*m;        out->local_length=local_length*m;
50        out->mpi_info = Paso_MPIInfo_getReference(mpi_info);        out->mpi_info = Esys_MPIInfo_getReference(mpi_info);
51        out->numNeighbors=numNeighbors;        out->numNeighbors=numNeighbors;
52        out->neighbor=MEMALLOC(out->numNeighbors,Paso_MPI_rank);        out->neighbor=MEMALLOC(out->numNeighbors,Esys_MPI_rank);
53        if (offsetInShared == NULL) {        if (offsetInShared == NULL) {
54            out->numSharedComponents=0;            out->numSharedComponents=0;
55        } else {        } else {
# Line 58  Paso_SharedComponents* Paso_SharedCompon Line 58  Paso_SharedComponents* Paso_SharedCompon
58        out->shared=MEMALLOC(out->numSharedComponents,index_t);        out->shared=MEMALLOC(out->numSharedComponents,index_t);
59        out->offsetInShared=MEMALLOC(out->numNeighbors+1,index_t);        out->offsetInShared=MEMALLOC(out->numNeighbors+1,index_t);
60        out->reference_counter=1;        out->reference_counter=1;
61        if (! (Paso_checkPtr(out->neighbor) ||        if (! (Esys_checkPtr(out->neighbor) ||
62               Paso_checkPtr(out->shared) ||               Esys_checkPtr(out->shared) ||
63               Paso_checkPtr(out->offsetInShared) ) ) {               Esys_checkPtr(out->offsetInShared) ) ) {
64    
65    
66           if ((out->numNeighbors>0) && (offsetInShared!=NULL) ) {           if ((out->numNeighbors>0) && (offsetInShared!=NULL) ) {
# Line 84  Paso_SharedComponents* Paso_SharedCompon Line 84  Paso_SharedComponents* Paso_SharedCompon
84        }        }
85    
86    }    }
87    if (Paso_noError()) {    if (Esys_noError()) {
88       return out;       return out;
89    } else {    } else {
90       Paso_SharedComponents_free(out);       Paso_SharedComponents_free(out);
# Line 101  Paso_SharedComponents* Paso_SharedCompon Line 101  Paso_SharedComponents* Paso_SharedCompon
101       return in;       return in;
102  }  }
103        
104  /* deallocates a SharedComponents: */  /* deallocates SharedComponents */
105    
106  void Paso_SharedComponents_free(Paso_SharedComponents* in) {  void Paso_SharedComponents_free(Paso_SharedComponents* in) {
107    if (in!=NULL) {    if (in!=NULL) {
# Line 110  void Paso_SharedComponents_free(Paso_Sha Line 110  void Paso_SharedComponents_free(Paso_Sha
110          MEMFREE(in->neighbor);          MEMFREE(in->neighbor);
111          MEMFREE(in->shared);          MEMFREE(in->shared);
112          MEMFREE(in->offsetInShared);          MEMFREE(in->offsetInShared);
113          Paso_MPIInfo_free(in->mpi_info);          Esys_MPIInfo_free(in->mpi_info);
114          MEMFREE(in);          MEMFREE(in);
115          #ifdef Paso_TRACE          #ifdef Paso_TRACE
116          printf("Paso_SharedComponents_dealloc: system matrix pattern as been deallocated.\n");          printf("Paso_SharedComponents_dealloc: system matrix pattern has been deallocated.\n");
117          #endif          #endif
118       }       }
119     }     }
120  }  }
121    

Legend:
Removed from v.2548  
changed lines
  Added in v.3911

  ViewVC Help
Powered by ViewVC 1.1.26