Beispiel #1
0
 def edge(self):
     """Construct edge legnths of the 3D model as 1d array."""
     if getattr(self, '_edge', None) is None:
         # Ensure that we are working with column vectors
         vh = self.h
         # The number of cell centers in each direction
         n = self.vnC
         # Compute edge lengths
         if (self.dim == 1):
             self._edge = Utils.mkvc(vh[0])
         elif (self.dim == 2):
             l1 = np.outer(vh[0], np.ones(n[1] + 1))
             l2 = np.outer(np.ones(n[0] + 1), vh[1])
             self._edge = np.r_[Utils.mkvc(l1), Utils.mkvc(l2)]
         elif (self.dim == 3):
             l1 = np.outer(
                 vh[0],
                 Utils.mkvc(np.outer(np.ones(n[1] + 1), np.ones(n[2] + 1))))
             l2 = np.outer(np.ones(n[0] + 1),
                           Utils.mkvc(np.outer(vh[1], np.ones(n[2] + 1))))
             l3 = np.outer(np.ones(n[0] + 1),
                           Utils.mkvc(np.outer(np.ones(n[1] + 1), vh[2])))
             self._edge = np.r_[Utils.mkvc(l1),
                                Utils.mkvc(l2),
                                Utils.mkvc(l3)]
     return self._edge
Beispiel #2
0
 def area(self):
     """Construct face areas of the 3D model as 1d array."""
     if getattr(self, '_area', None) is None:
         # Ensure that we are working with column vectors
         vh = self.h
         # The number of cell centers in each direction
         n = self.vnC
         # Compute areas of cell faces
         if (self.dim == 1):
             self._area = np.ones(n[0] + 1)
         elif (self.dim == 2):
             area1 = np.outer(np.ones(n[0] + 1), vh[1])
             area2 = np.outer(vh[0], np.ones(n[1] + 1))
             self._area = np.r_[Utils.mkvc(area1), Utils.mkvc(area2)]
         elif (self.dim == 3):
             area1 = np.outer(np.ones(n[0] + 1),
                              Utils.mkvc(np.outer(vh[1], vh[2])))
             area2 = np.outer(
                 vh[0], Utils.mkvc(np.outer(np.ones(n[1] + 1), vh[2])))
             area3 = np.outer(
                 vh[0], Utils.mkvc(np.outer(vh[1], np.ones(n[2] + 1))))
             self._area = np.r_[Utils.mkvc(area1),
                                Utils.mkvc(area2),
                                Utils.mkvc(area3)]
     return self._area
Beispiel #3
0
 def vol(self):
     """Construct cell volumes of the 3D model as 1d array."""
     if getattr(self, '_vol', None) is None:
         vh = self.h
         # Compute cell volumes
         if self.dim == 1:
             self._vol = Utils.mkvc(vh[0])
         elif self.dim == 2:
             # Cell sizes in each direction
             self._vol = Utils.mkvc(np.outer(vh[0], vh[1]))
         elif self.dim == 3:
             # Cell sizes in each direction
             self._vol = Utils.mkvc(np.outer(Utils.mkvc(np.outer(vh[0], vh[1])), vh[2]))
     return self._vol
Beispiel #4
0
 def vol(self):
     """Construct cell volumes of the 3D model as 1d array."""
     if getattr(self, '_vol', None) is None:
         vh = self.h
         # Compute cell volumes
         if self.dim == 1:
             self._vol = Utils.mkvc(vh[0])
         elif self.dim == 2:
             # Cell sizes in each direction
             self._vol = Utils.mkvc(np.outer(vh[0], vh[1]))
         elif self.dim == 3:
             # Cell sizes in each direction
             self._vol = Utils.mkvc(np.outer(Utils.mkvc(np.outer(vh[0], vh[1])), vh[2]))
     return self._vol
Beispiel #5
0
 def edge(self):
     """Construct edge legnths of the 3D model as 1d array."""
     if getattr(self, '_edge', None) is None:
         # Ensure that we are working with column vectors
         vh = self.h
         # The number of cell centers in each direction
         n = self.vnC
         # Compute edge lengths
         if(self.dim == 1):
             self._edge = Utils.mkvc(vh[0])
         elif(self.dim == 2):
             l1 = np.outer(vh[0], np.ones(n[1]+1))
             l2 = np.outer(np.ones(n[0]+1), vh[1])
             self._edge = np.r_[Utils.mkvc(l1), Utils.mkvc(l2)]
         elif(self.dim == 3):
             l1 = np.outer(vh[0], Utils.mkvc(np.outer(np.ones(n[1]+1), np.ones(n[2]+1))))
             l2 = np.outer(np.ones(n[0]+1), Utils.mkvc(np.outer(vh[1], np.ones(n[2]+1))))
             l3 = np.outer(np.ones(n[0]+1), Utils.mkvc(np.outer(np.ones(n[1]+1), vh[2])))
             self._edge = np.r_[Utils.mkvc(l1), Utils.mkvc(l2), Utils.mkvc(l3)]
     return self._edge
Beispiel #6
0
 def area(self):
     """Construct face areas of the 3D model as 1d array."""
     if getattr(self, '_area', None) is None:
         # Ensure that we are working with column vectors
         vh = self.h
         # The number of cell centers in each direction
         n = self.vnC
         # Compute areas of cell faces
         if(self.dim == 1):
             self._area = np.ones(n[0]+1)
         elif(self.dim == 2):
             area1 = np.outer(np.ones(n[0]+1), vh[1])
             area2 = np.outer(vh[0], np.ones(n[1]+1))
             self._area = np.r_[Utils.mkvc(area1), Utils.mkvc(area2)]
         elif(self.dim == 3):
             area1 = np.outer(np.ones(n[0]+1), Utils.mkvc(np.outer(vh[1], vh[2])))
             area2 = np.outer(vh[0], Utils.mkvc(np.outer(np.ones(n[1]+1), vh[2])))
             area3 = np.outer(vh[0], Utils.mkvc(np.outer(vh[1], np.ones(n[2]+1))))
             self._area = np.r_[Utils.mkvc(area1), Utils.mkvc(area2), Utils.mkvc(area3)]
     return self._area