/[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 2881 by jfenwick, Thu Jan 28 02:03:15 2010 UTC revision 4154 by jfenwick, Tue Jan 22 09:30:23 2013 UTC
# Line 1  Line 1 
1    
2  /*******************************************************  /*****************************************************************************
3  *  *
4  * Copyright (c) 2003-2010 by University of Queensland  * Copyright (c) 2003-2013 by University of Queensland
5  * Earth Systems Science Computational Center (ESSCC)  * http://www.uq.edu.au
 * http://www.uq.edu.au/esscc  
6  *  *
7  * Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
8  * Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
9  * http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
10  *  *
11  *******************************************************/  * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12    * Development since 2012 by School of Earth Sciences
13    *
14    *****************************************************************************/
15    
16    
17  /**************************************************************/  /************************************************************************************/
18    
19  /* Paso: SharedComponents organizes the coupling with in a pattern/matrix   */  /* Paso: SharedComponents organizes the coupling within a     */
20  /*       across processors                                         */  /*       pattern/matrix across processors                     */
21    
22  /**************************************************************/  /************************************************************************************/
23    
24  /* Author: Lutz Gross, l.gross@uq.edu.au */  /* Author: Lutz Gross, l.gross@uq.edu.au                      */
25    
26  /**************************************************************/  /************************************************************************************/
27    
28  #include "SharedComponents.h"  #include "SharedComponents.h"
29    #include "esysUtils/error.h"
30    
31  /**************************************************************/  /************************************************************************************/
   
 /* allocates a SharedComponents  */  
32    
33    /* allocates SharedComponents  */
34    
35  /**************************************************************/  /************************************************************************************/
36    
37  Paso_SharedComponents* Paso_SharedComponents_alloc(dim_t local_length,  Paso_SharedComponents* Paso_SharedComponents_alloc(dim_t local_length,
38                                                     dim_t numNeighbors,                                                     dim_t numNeighbors,
39                                                     Paso_MPI_rank* neighbor,                                                     Esys_MPI_rank* neighbor,
40                                                     index_t* shared,                                                     index_t* shared,
41                                                     index_t* offsetInShared,                                                     index_t* offsetInShared,
42                                                     index_t m, index_t b,                                                     index_t m, index_t b,
43                                                     Paso_MPIInfo *mpi_info)                                                     Esys_MPIInfo *mpi_info)
44  {  {
45    dim_t i,j;    dim_t i,j;
46    register index_t itmp;    register index_t itmp;
47    Paso_SharedComponents* out=NULL;    Paso_SharedComponents* out=NULL;
48    Paso_resetError();    Esys_resetError();
49    out=MEMALLOC(1,Paso_SharedComponents);    out=MEMALLOC(1,Paso_SharedComponents);
50    if (!Paso_checkPtr(out)) {    if (!Esys_checkPtr(out)) {
51        out->local_length=local_length*m;        out->local_length=local_length*m;
52        out->mpi_info = Paso_MPIInfo_getReference(mpi_info);        out->mpi_info = Esys_MPIInfo_getReference(mpi_info);
53        out->numNeighbors=numNeighbors;        out->numNeighbors=numNeighbors;
54        out->neighbor=MEMALLOC(out->numNeighbors,Paso_MPI_rank);        out->neighbor=MEMALLOC(out->numNeighbors,Esys_MPI_rank);
55        if (offsetInShared == NULL) {        if (offsetInShared == NULL) {
56            out->numSharedComponents=0;            out->numSharedComponents=0;
57        } else {        } else {
# Line 58  Paso_SharedComponents* Paso_SharedCompon Line 60  Paso_SharedComponents* Paso_SharedCompon
60        out->shared=MEMALLOC(out->numSharedComponents,index_t);        out->shared=MEMALLOC(out->numSharedComponents,index_t);
61        out->offsetInShared=MEMALLOC(out->numNeighbors+1,index_t);        out->offsetInShared=MEMALLOC(out->numNeighbors+1,index_t);
62        out->reference_counter=1;        out->reference_counter=1;
63        if (! (Paso_checkPtr(out->neighbor) ||        if (! (Esys_checkPtr(out->neighbor) ||
64               Paso_checkPtr(out->shared) ||               Esys_checkPtr(out->shared) ||
65               Paso_checkPtr(out->offsetInShared) ) ) {               Esys_checkPtr(out->offsetInShared) ) ) {
66    
67    
68           if ((out->numNeighbors>0) && (offsetInShared!=NULL) ) {           if ((out->numNeighbors>0) && (offsetInShared!=NULL) ) {
# Line 84  Paso_SharedComponents* Paso_SharedCompon Line 86  Paso_SharedComponents* Paso_SharedCompon
86        }        }
87    
88    }    }
89    if (Paso_noError()) {    if (Esys_noError()) {
90       return out;       return out;
91    } else {    } else {
92       Paso_SharedComponents_free(out);       Paso_SharedComponents_free(out);
# Line 101  Paso_SharedComponents* Paso_SharedCompon Line 103  Paso_SharedComponents* Paso_SharedCompon
103       return in;       return in;
104  }  }
105        
106  /* deallocates a SharedComponents: */  /* deallocates SharedComponents */
107    
108  void Paso_SharedComponents_free(Paso_SharedComponents* in) {  void Paso_SharedComponents_free(Paso_SharedComponents* in) {
109    if (in!=NULL) {    if (in!=NULL) {
# Line 110  void Paso_SharedComponents_free(Paso_Sha Line 112  void Paso_SharedComponents_free(Paso_Sha
112          MEMFREE(in->neighbor);          MEMFREE(in->neighbor);
113          MEMFREE(in->shared);          MEMFREE(in->shared);
114          MEMFREE(in->offsetInShared);          MEMFREE(in->offsetInShared);
115          Paso_MPIInfo_free(in->mpi_info);          Esys_MPIInfo_free(in->mpi_info);
116          MEMFREE(in);          MEMFREE(in);
117          #ifdef Paso_TRACE          #ifdef Paso_TRACE
118          printf("Paso_SharedComponents_dealloc: system matrix pattern as been deallocated.\n");          printf("Paso_SharedComponents_dealloc: system matrix pattern has been deallocated.\n");
119          #endif          #endif
120       }       }
121     }     }
122  }  }
123    

Legend:
Removed from v.2881  
changed lines
  Added in v.4154

  ViewVC Help
Powered by ViewVC 1.1.26