/[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

trunk/paso/src/SharedComponents.c revision 3259 by jfenwick, Mon Oct 11 01:48:14 2010 UTC branches/doubleplusgood/paso/src/SharedComponents.cpp revision 4324 by jfenwick, Wed Mar 20 00:55:44 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"  #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,
# Line 45  Paso_SharedComponents* Paso_SharedCompon Line 46  Paso_SharedComponents* Paso_SharedCompon
46    register index_t itmp;    register index_t itmp;
47    Paso_SharedComponents* out=NULL;    Paso_SharedComponents* out=NULL;
48    Esys_resetError();    Esys_resetError();
49    out=MEMALLOC(1,Paso_SharedComponents);    out=new Paso_SharedComponents;
50    if (!Esys_checkPtr(out)) {    if (!Esys_checkPtr(out)) {
51        out->local_length=local_length*m;        out->local_length=local_length*m;
52        out->mpi_info = Esys_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,Esys_MPI_rank);        out->neighbor=new Esys_MPI_rank[out->numNeighbors];
55        if (offsetInShared == NULL) {        if (offsetInShared == NULL) {
56            out->numSharedComponents=0;            out->numSharedComponents=0;
57        } else {        } else {
58            out->numSharedComponents=offsetInShared[numNeighbors]*m;            out->numSharedComponents=offsetInShared[numNeighbors]*m;
59        }        }
60        out->shared=MEMALLOC(out->numSharedComponents,index_t);        out->shared=new index_t[out->numSharedComponents];
61        out->offsetInShared=MEMALLOC(out->numNeighbors+1,index_t);        out->offsetInShared=new index_t[out->numNeighbors+1];
62        out->reference_counter=1;        out->reference_counter=1;
63        if (! (Esys_checkPtr(out->neighbor) ||        if (! (Esys_checkPtr(out->neighbor) ||
64               Esys_checkPtr(out->shared) ||               Esys_checkPtr(out->shared) ||
# Line 102  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) {
110       in->reference_counter--;       in->reference_counter--;
111       if (in->reference_counter<=0) {       if (in->reference_counter<=0) {
112          MEMFREE(in->neighbor);          delete[] in->neighbor;
113          MEMFREE(in->shared);          delete[] in->shared;
114          MEMFREE(in->offsetInShared);          delete[] in->offsetInShared;
115          Esys_MPIInfo_free(in->mpi_info);          Esys_MPIInfo_free(in->mpi_info);
116          MEMFREE(in);          delete 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.3259  
changed lines
  Added in v.4324

  ViewVC Help
Powered by ViewVC 1.1.26