forked from usnistgov/fipy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Old `parallelComm` made heavy assumptions about availability of Trilinos. Comms (particularly the parallel ones) are intimately tied to the solver in use, so they should be instantiated with the solver. No matter what, we need mpi4py, so use it (and only it) to determine number of processes in order to pick a solver. Addresses usnistgov#644
- Loading branch information
Showing
11 changed files
with
280 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/usr/bin/env python | ||
|
||
## -*-Pyth-*- | ||
# ################################################################### | ||
# FiPy - Python-based finite volume PDE solver | ||
# | ||
# FILE: "epetraCommWrapper.py" | ||
# | ||
# Author: Jonathan Guyer <guyer@nist.gov> | ||
# Author: Daniel Wheeler <daniel.wheeler@nist.gov> | ||
# Author: James Warren <jwarren@nist.gov> | ||
# mail: NIST | ||
# www: http://www.ctcms.nist.gov/fipy/ | ||
# | ||
# ======================================================================== | ||
# This software was developed at the National Institute of Standards | ||
# and Technology by employees of the Federal Government in the course | ||
# of their official duties. Pursuant to title 17 Section 105 of the | ||
# United States Code this software is not subject to copyright | ||
# protection and is in the public domain. FiPy is an experimental | ||
# system. NIST assumes no responsibility whatsoever for its use by | ||
# other parties, and makes no guarantees, expressed or implied, about | ||
# its quality, reliability, or any other characteristic. We would | ||
# appreciate acknowledgement if the software is used. | ||
# | ||
# This software can be redistributed and/or modified freely | ||
# provided that any derivative works bear some notice that they are | ||
# derived from it, and any modified versions bear some notice that | ||
# they have been modified. | ||
# ======================================================================== | ||
# See the file "license.terms" for information on usage and redistribution | ||
# of this file, and for a DISCLAIMER OF ALL WARRANTIES. | ||
# | ||
# ################################################################### | ||
## | ||
|
||
__docformat__ = 'restructuredtext' | ||
|
||
from PyTrilinos import Epetra | ||
|
||
from fipy.tools import numerix | ||
from fipy.tools.comms.abstractCommWrapper import AbstractCommWrapper | ||
|
||
__all__ = ["EpetraCommWrapper"] | ||
|
||
class EpetraCommWrapper(AbstractCommWrapper): | ||
"""MPI Communicator wrapper | ||
Encapsulates capabilities needed for Epetra. | ||
Some capabilities are not parallel. | ||
""" | ||
|
||
def __init__(self): | ||
self.epetra_comm = Epetra.PyComm() | ||
super(EpetraCommWrapper, self).__init__() | ||
|
||
@property | ||
def procID(self): | ||
return self.epetra_comm.MyPID() | ||
|
||
@property | ||
def Nproc(self): | ||
return self.epetra_comm.NumProc() | ||
|
||
def Barrier(self): | ||
self.epetra_comm.Barrier() | ||
|
||
def sum(self, a, axis=None): | ||
summed = numerix.array(a).sum(axis=axis) | ||
shape = summed.shape | ||
if shape == (): | ||
summed = summed.reshape((1,)) | ||
parallelSummed = self.epetra_comm.SumAll(summed) | ||
if shape == (): | ||
parallelSummed = parallelSummed.reshape(()) | ||
return parallelSummed | ||
|
||
def __setstate__(self, dict): | ||
self.__init__() | ||
|
||
def Norm2(self, vec): | ||
return vec.Norm2() | ||
|
||
def MaxAll(self, vec): | ||
return self.epetra_comm.MaxAll(numerix.array(vec)) | ||
|
||
def MinAll(self, vec): | ||
return self.epetra_comm.MinAll(numerix.array(vec)) |
34 changes: 16 additions & 18 deletions
34
fipy/tools/comms/mpi4pyCommWrapper.py → ...ilinos/comms/parallelEpetraCommWrapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from fipy.tools import numerix | ||
from fipy.solvers.trilinos.comms.epetraCommWrapper import EpetraCommWrapper | ||
|
||
__all__ = ["SerialEpetraCommWrapper"] | ||
|
||
class SerialEpetraCommWrapper(EpetraCommWrapper): | ||
@property | ||
def procID(self): | ||
return 0 | ||
|
||
@property | ||
def Nproc(self): | ||
return 1 | ||
|
||
def Norm2(self, vec): | ||
return numerix.L2norm(numerix.asarray(vec)) |
Oops, something went wrong.