Esempio n. 1
0
 def aveEz2CC(self):
     "Construct the averaging operator on cell edges in the z direction to cell centers."
     if self.dim < 3: return None
     if getattr(self, '_aveEz2CC', None) is None:
         # The number of cell centers in each direction
         n = self.vnC
         if(self.dim == 3):
             self._aveEz2CC = kron3(speye(n[2]), av(n[1]), av(n[0]))
     return self._aveEz2CC
Esempio n. 2
0
 def aveEz2CC(self):
     "Construct the averaging operator on cell edges in the z direction to cell centers."
     if self.dim < 3: return None
     if getattr(self, '_aveEz2CC', None) is None:
         # The number of cell centers in each direction
         n = self.vnC
         if(self.dim == 3):
             self._aveEz2CC = kron3(speye(n[2]), av(n[1]), av(n[0]))
     return self._aveEz2CC
Esempio n. 3
0
 def aveFy2CC(self):
     "Construct the averaging operator on cell faces in the y direction to cell centers."
     if self.dim < 2: return None
     if getattr(self, '_aveFy2CC', None) is None:
         n = self.vnC
         if(self.dim == 2):
             self._aveFy2CC = sp.kron(av(n[1]), speye(n[0]))
         elif(self.dim == 3):
             self._aveFy2CC = kron3(speye(n[2]), av(n[1]), speye(n[0]))
     return self._aveFy2CC
Esempio n. 4
0
 def aveFy2CC(self):
     "Construct the averaging operator on cell faces in the y direction to cell centers."
     if self.dim < 2: return None
     if getattr(self, '_aveFy2CC', None) is None:
         n = self.vnC
         if(self.dim == 2):
             self._aveFy2CC = sp.kron(av(n[1]), speye(n[0]))
         elif(self.dim == 3):
             self._aveFy2CC = kron3(speye(n[2]), av(n[1]), speye(n[0]))
     return self._aveFy2CC
Esempio n. 5
0
 def aveF2CCV(self):
     "Construct the averaging operator on cell faces to cell centers."
     if getattr(self, '_aveF2CCV', None) is None:
         n = self.vnC
         if self.isSymmetric:
             avR = av(n[0])[:,1:]
             avR[0,0] = 1.
             self._aveF2CCV = sp.block_diag((sp.kron(speye(n[2]), avR),
                                             sp.kron(av(n[2]), speye(n[0]))), format="csr")
         else:
             raise NotImplementedError('wrapping in the averaging is not yet implemented')
     return self._aveF2CCV
Esempio n. 6
0
 def aveEx2CC(self):
     "Construct the averaging operator on cell edges in the x direction to cell centers."
     if getattr(self, '_aveEx2CC', None) is None:
         # The number of cell centers in each direction
         n = self.vnC
         if(self.dim == 1):
             self._aveEx2CC = speye(n[0])
         elif(self.dim == 2):
             self._aveEx2CC = sp.kron(av(n[1]), speye(n[0]))
         elif(self.dim == 3):
             self._aveEx2CC = kron3(av(n[2]), av(n[1]), speye(n[0]))
     return self._aveEx2CC
Esempio n. 7
0
 def aveEx2CC(self):
     "Construct the averaging operator on cell edges in the x direction to cell centers."
     if getattr(self, '_aveEx2CC', None) is None:
         # The number of cell centers in each direction
         n = self.vnC
         if(self.dim == 1):
             self._aveEx2CC = speye(n[0])
         elif(self.dim == 2):
             self._aveEx2CC = sp.kron(av(n[1]), speye(n[0]))
         elif(self.dim == 3):
             self._aveEx2CC = kron3(av(n[2]), av(n[1]), speye(n[0]))
     return self._aveEx2CC
Esempio n. 8
0
 def aveF2CC(self):
     "Construct the averaging operator on cell faces to cell centers."
     if getattr(self, '_aveF2CC', None) is None:
         n = self.vnC
         if self.isSymmetric:
             avR = av(n[0])[:,1:]
             avR[0,0] = 1.
             self._aveF2CC = (0.5)*sp.hstack((sp.kron(speye(n[2]), avR), sp.kron(av(n[2]), speye(n[0]))), format="csr")
         else:
             raise NotImplementedError('wrapping in the averaging is not yet implemented')
             # self._aveF2CC = (1./3.)*sp.hstack((kron3(speye(n[2]), speye(n[1]), av(n[0])),
             #                                    kron3(speye(n[2]), av(n[1]), speye(n[0])),
             #                                    kron3(av(n[2]), speye(n[1]), speye(n[0]))), format="csr")
     return self._aveF2CC
Esempio n. 9
0
 def aveF2CCV(self):
     "Construct the averaging operator on cell faces to cell centers."
     if getattr(self, '_aveF2CCV', None) is None:
         n = self.vnC
         if self.isSymmetric:
             avR = av(n[0])[:, 1:]
             avR[0, 0] = 1.
             self._aveF2CCV = sp.block_diag((sp.kron(speye(
                 n[2]), avR), sp.kron(av(n[2]), speye(n[0]))),
                                            format="csr")
         else:
             raise NotImplementedError(
                 'wrapping in the averaging is not yet implemented')
     return self._aveF2CCV
Esempio n. 10
0
 def aveE2CC(self):
     "Construct the averaging operator on cell edges to cell centers."
     if getattr(self, '_aveE2CC', None) is None:
         # The number of cell centers in each direction
         n = self.vnC
         if self.isSymmetric:
             avR = av(n[0])[:, 1:]
             avR[0, 0] = 1.
             self._aveE2CC = (0.5) * sp.kron(av(n[2]), avR, format="csr")
         else:
             raise NotImplementedError(
                 'wrapping in the averaging is not yet implemented')
             # self._aveE2CC = (1./3)*sp.hstack((kron3(av(n[2]), av(n[1]), speye(n[0])),
             #                                   kron3(av(n[2]), speye(n[1]), av(n[0])),
             #                                   kron3(speye(n[2]), av(n[1]), av(n[0]))), format="csr")
     return self._aveE2CC
Esempio n. 11
0
 def aveN2F(self):
     "Construct the averaging operator on cell nodes to cell faces, keeping each dimension separate."
     if getattr(self, '_aveN2F', None) is None:
         # The number of cell centers in each direction
         n = self.vnC
         if(self.dim == 1):
             self._aveN2F = av(n[0])
         elif(self.dim == 2):
             self._aveN2F = sp.vstack((sp.kron(av(n[1]), speye(n[0]+1)),
                                       sp.kron(speye(n[1]+1), av(n[0]))), format="csr")
         elif(self.dim == 3):
             self._aveN2F = sp.vstack((kron3(av(n[2]), av(n[1]), speye(n[0]+1)),
                                       kron3(av(n[2]), speye(n[1]+1), av(n[0])),
                                       kron3(speye(n[2]+1), av(n[1]), av(n[0]))), format="csr")
     return self._aveN2F
Esempio n. 12
0
 def aveN2F(self):
     "Construct the averaging operator on cell nodes to cell faces, keeping each dimension separate."
     if getattr(self, '_aveN2F', None) is None:
         # The number of cell centers in each direction
         n = self.vnC
         if(self.dim == 1):
             self._aveN2F = av(n[0])
         elif(self.dim == 2):
             self._aveN2F = sp.vstack((sp.kron(av(n[1]), speye(n[0]+1)),
                                       sp.kron(speye(n[1]+1), av(n[0]))), format="csr")
         elif(self.dim == 3):
             self._aveN2F = sp.vstack((kron3(av(n[2]), av(n[1]), speye(n[0]+1)),
                                       kron3(av(n[2]), speye(n[1]+1), av(n[0])),
                                       kron3(speye(n[2]+1), av(n[1]), av(n[0]))), format="csr")
     return self._aveN2F
Esempio n. 13
0
 def aveFz2CC(self):
     """
     Construct the averaging operator on cell faces in the z direction to
     cell centers.
     """
     if self.dim < 3: return None
     if getattr(self, '_aveFz2CC', None) is None:
         n = self.vnC
         if (self.dim == 3):
             self._aveFz2CC = kron3(av(n[2]), speye(n[1]), speye(n[0]))
     return self._aveFz2CC
Esempio n. 14
0
 def aveFz2CC(self):
     """
     Construct the averaging operator on cell faces in the z direction to
     cell centers.
     """
     if self.dim < 3: return None
     if getattr(self, '_aveFz2CC', None) is None:
         n = self.vnC
         if(self.dim == 3):
             self._aveFz2CC = kron3(av(n[2]), speye(n[1]), speye(n[0]))
     return self._aveFz2CC
Esempio n. 15
0
 def aveN2CC(self):
     "Construct the averaging operator on cell nodes to cell centers."
     if getattr(self, '_aveN2CC', None) is None:
         # The number of cell centers in each direction
         n = self.vnC
         if(self.dim == 1):
             self._aveN2CC = av(n[0])
         elif(self.dim == 2):
             self._aveN2CC = sp.kron(av(n[1]), av(n[0])).tocsr()
         elif(self.dim == 3):
             self._aveN2CC = kron3(av(n[2]), av(n[1]), av(n[0])).tocsr()
     return self._aveN2CC
Esempio n. 16
0
 def aveN2CC(self):
     "Construct the averaging operator on cell nodes to cell centers."
     if getattr(self, '_aveN2CC', None) is None:
         # The number of cell centers in each direction
         n = self.vnC
         if (self.dim == 1):
             self._aveN2CC = av(n[0])
         elif (self.dim == 2):
             self._aveN2CC = sp.kron(av(n[1]), av(n[0])).tocsr()
         elif (self.dim == 3):
             self._aveN2CC = kron3(av(n[2]), av(n[1]), av(n[0])).tocsr()
     return self._aveN2CC