PEXSI
 All Classes Namespaces Files Functions Variables Typedefs Pages
SuperLUGrid_impl.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012 The Regents of the University of California,
3  through Lawrence Berkeley National Laboratory.
4 
5  Authors: Mathias Jacquelin and Lin Lin
6 
7  This file is part of PEXSI. All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions are met:
11 
12  (1) Redistributions of source code must retain the above copyright notice, this
13  list of conditions and the following disclaimer.
14  (2) Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17  (3) Neither the name of the University of California, Lawrence Berkeley
18  National Laboratory, U.S. Dept. of Energy nor the names of its contributors may
19  be used to endorse or promote products derived from this software without
20  specific prior written permission.
21 
22  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33  You are under no obligation whatsoever to provide any bug fixes, patches, or
34  upgrades to the features, functionality or performance of the source code
35  ("Enhancements") to anyone; however, if you choose to make your Enhancements
36  available either publicly, or directly to Lawrence Berkeley National
37  Laboratory, without imposing a separate written license agreement for such
38  Enhancements, then you hereby grant the following license: a non-exclusive,
39  royalty-free perpetual license to install, use, modify, prepare derivative
40  works, incorporate into other computer software, distribute, and sublicense
41  such enhancements or derivative works thereof, in binary and source code form.
42  */
46 #ifndef _PEXSI_SUPERLUGRID_IMPL_HPP_
47 #define _PEXSI_SUPERLUGRID_IMPL_HPP_
48 
49 namespace PEXSI{
50 
51 inline SuperLUGrid<Real>::SuperLUGrid ( MPI_Comm comm, Int nprow, Int npcol )
52 {
53 #ifndef _RELEASE_
54  PushCallStack("SuperLUGrid::SuperLUGrid");
55 #endif
56  ptrData = new RealGridData;
57  if( ptrData == NULL )
58  throw std::runtime_error( "SuperLUGrid cannot be allocated." );
59 
60  ptrData->GridInit(comm, nprow, npcol);
61 
62 #ifndef _RELEASE_
63  PopCallStack();
64 #endif
65 
66  return ;
67 } // ----- end of method SuperLUGrid::SuperLUGrid -----
68 
69 inline SuperLUGrid<Real>::~SuperLUGrid ( )
70 {
71 #ifndef _RELEASE_
72  PushCallStack("SuperLUGrid::~SuperLUGrid");
73 #endif
74  // NOTE (07/21/2013): Since superlu_gridinit gets a copy of the
75  // communicator, it is legal to call superlu_gridexit even if
76  // grid->comm is a copy of MPI_COMM_WORLD.
77 
78  ptrData->GridExit();
79 
80  delete ptrData;
81 
82 #ifndef _RELEASE_
83  PopCallStack();
84 #endif
85  return ;
86 } // ----- end of method SuperLUGrid::~SuperLUGrid -----
87 
88 inline SuperLUGrid<Complex>::SuperLUGrid ( MPI_Comm comm, Int nprow, Int npcol )
89 {
90 #ifndef _RELEASE_
91  PushCallStack("SuperLUGrid::SuperLUGrid");
92 #endif
93  ptrData = new ComplexGridData;
94  if( ptrData == NULL )
95  throw std::runtime_error( "SuperLUGrid cannot be allocated." );
96 
97  ptrData->GridInit(comm, nprow, npcol);
98 
99 #ifndef _RELEASE_
100  PopCallStack();
101 #endif
102 
103  return ;
104 } // ----- end of method SuperLUGrid::SuperLUGrid -----
105 
106 
107 inline SuperLUGrid<Complex>::~SuperLUGrid ( )
108 {
109 #ifndef _RELEASE_
110  PushCallStack("SuperLUGrid::~SuperLUGrid");
111 #endif
112  // NOTE (07/21/2013): Since superlu_gridinit gets a copy of the
113  // communicator, it is legal to call superlu_gridexit even if
114  // grid->comm is a copy of MPI_COMM_WORLD.
115 
116  ptrData->GridExit();
117 
118  delete ptrData;
119 
120 #ifndef _RELEASE_
121  PopCallStack();
122 #endif
123  return ;
124 } // ----- end of method SuperLUGrid::~SuperLUGrid -----
125 
126 }
127 
128 
129 #endif //_PEXSI_SUPERLUGRID_IMPL_HPP_
void * ptrData
SuperLUMatrix can have access to the grid information.
Definition: SuperLUGrid.hpp:95