Exemplo n.º 1
0
 def polygons(self, gfxwindow, skelcontext):
     skeleton = skelcontext.getObject()
     if parallel_enable.enabled():
         nodes = skeleton.all_skeletons["nodes"]
         elements = skeleton.all_skeletons["elements"]
         polys = []
         for i in range(mpitools.Size()):
             for el in elements[i]:
                 polys.append(
                     [primitives.Point(*nodes[i][ni]) for ni in el])
         return polys
     else:
         return [el.perimeter() for el in skeleton.element_iterator()]
Exemplo n.º 2
0
Arquivo: oof.py Projeto: creuzige/OOF2
def start_sockets_Front_End():
    if parallel_enable.enabled():
        try:
            from ooflib.SWIG.common import mpitools
        except ImportError:
            raise ooferror.ErrSetupError(
                "Parallel option requested, but parallel code not present.")
        from ooflib.common.IO import socket2me
        ## Tell back end what port to listen
        s_name = mpitools.Get_processor_name()
        s_address = socket2me.socketPort.getPort()
        mpitools.bcast_string("%i" % s_address, 0)
        mpitools.bcast_string(s_name, 0)
        ## Tell back end the number of processors on the back end
        socket2me.socketPort.connect(mpitools.Size() - 1)
Exemplo n.º 3
0
    def polygons(self, gfxwindow, meshctxt):
        themesh = meshctxt.getObject()
        meshctxt.restoreCachedData(self.getTime(meshctxt, gfxwindow))
        try:
            # PARALLEL_RCL: Make changes here to display parallel mesh
            # There is an issue with clicking on the skeleton or mesh
            # graphics: only the nodes or elements for the front-end
            # process get the cursor or mark

            if parallel_enable.enabled():
                # This snippet taken from SkeletonDisplayMethod
                nodes = themesh.all_meshskeletons["nodes"]
                elements = themesh.all_meshskeletons["elements"]
                polys = []
                for i in range(mpitools.Size()):
                    for el in elements[i]:
                        polys.append(
                            [primitives.Point(*nodes[i][ni]) for ni in el])
                return polys
            else:
                if gfxwindow.settings.hideEmptyElements:
                    edges = [
                        element.perimeter()
                        for element in themesh.element_iterator()
                        if element.material() is not None
                    ]
                else:
                    edges = [
                        element.perimeter()
                        for element in themesh.element_iterator()
                    ]
                flatedges = utils.flatten(edges)
                # corners tells where on each edge to evaluate self.where
                corners = [[0.0]] * len(flatedges)
                # evaluate position output for all edges at once
                polys = self.where.evaluate(themesh, flatedges, corners)
                # give the corner list the same structure as the edge list: a
                # list of lists, where each sublist is the list of corners of
                # an element.
                polys = utils.unflatten(edges, polys)
                if len(polys) == 0:
                    mainthread.runBlock(reporter.warn, (
                        "No mesh elements drawn! Are there no materials assigned?",
                    ))
                return polys
        finally:
            meshctxt.releaseCachedData()
Exemplo n.º 4
0
def parallel_info_subproblem(menuitem, subproblem):
    subpctxt = ooflib.engine.subproblemcontext.subproblems[subproblem]
    subpctxt.begin_reading()
    reportstring = ""
    nGatherNodes = 0
    nElements = 0
    TotalArea = 0
    try:
        nElements = subpctxt.nelements()
        TotalArea = subpctxt.area()
        reportstring = """*** Subproblem Info ***
%s
%d elements
%d nodes
area = %g\n""" % (subpctxt.getObject(), nElements, subpctxt.nnodes(),
                  TotalArea)
        nGatherNodes = subpctxt.getObject().GatherNumNodes()
    finally:
        subpctxt.end_reading()

    if mpitools.Rank() == 0:
        #Get output from other processes
        for proc in range(mpitools.Size()):
            if proc != 0:
                reportstring += "(From remote process %d:)\n" % proc
                reportstring += mpitools.Recv_String(proc)
                nElements += mpitools.Recv_Int(proc)
                TotalArea += mpitools.Recv_Double(proc)
        reportstring += """***** Totals (union) *****
%d elements
%d unique nodes
Total Area = %g""" % (nElements, nGatherNodes, TotalArea)
        reporter.report(reportstring)
    else:
        mpitools.Send_String(reportstring, 0)
        mpitools.Send_Int(nElements, 0)
        mpitools.Send_Double(TotalArea, 0)
Exemplo n.º 5
0
# facilitate maintenance we ask that before distributing modified
# versions of this software, you first contact the authors at
# [email protected].

from ooflib.common import debug
from ooflib.common import primitives
from ooflib.common.IO import automatic
from ooflib.common.IO import oofmenu
from ooflib.common.IO import parallelmainmenu
from ooflib.common.IO import parameter
from ooflib.common.IO import socket2me
from ooflib.SWIG.common import mpitools
import ooflib.common.microstructure

_rank = mpitools.Rank()
_size = mpitools.Size()

# OOF.LoadData.IPC.Microstructure
msmenu = parallelmainmenu.ipcmenu.addItem(
    oofmenu.OOFMenuItem('Microstructure', secret=1, no_log=1))


def newMicrostructure_Parallel(menuitem, name, width, height, width_in_pixels,
                               height_in_pixels):
    # Only for the back-end processes
    global _rank
    if _rank == 0:
        return

    ms = ooflib.common.microstructure.Microstructure(
        name, primitives.iPoint(width_in_pixels, height_in_pixels),
Exemplo n.º 6
0
Arquivo: oof.py Projeto: creuzige/OOF2
def run(no_interp=None):
    global _rank
    global startupfiles

    process_inline_options()  # execute well-formed oof options

    # Look for .oof2rc in the user's home directory.
    if not no_rc:
        oofrcpath = os.path.join(os.path.expanduser("~"), ".oof2rc")
        if os.path.exists(oofrcpath):
            startupfiles = [StartUpScriptNoLog(oofrcpath)] + startupfiles

    if thread_enable.query() and not (runtimeflags.text_mode
                                      or config.no_gui()):
        # TODO: Is this still necessary?
        garbage.disable()  # work-around for gtk bug?

    start_parallel_machine()  # start parallel suite (if available)

    if _rank == 0:
        if parallel_enable.enabled():
            from ooflib.SWIG.common import mpitools
            _size = mpitools.Size()
            mpitools.Isend_Bool(thread_enable.enabled(), range(1, _size))

        if parallel_enable.enabled():
            from ooflib.common.IO import socket2me

        if config.petsc():
            print "Going to InitPETSc"
            from ooflib.SWIG.engine.PETSc.petsc_solverdriver import InitPETSc
            InitPETSc(sys.argv)
            for s in sys.argv:
                print s

        start_sockets_Front_End()
        # Import mainmenu only *after* processing command line options, so
        # that the options can affect which menus are loaded.
        global mainmenu
        from ooflib.common.IO import mainmenu
        front_end(no_interp)  # all non-parallel menu items are executed here.
    else:
        # parallel back-end
        parallel_enable.set(True)  # notify back-end of its parallel status

        # thread status at the back-ends
        from ooflib.SWIG.common import mpitools
        thread_enable.set(mpitools.Recv_Bool(0))
        if not thread_enable.enabled():
            lock.disable_all()

        if parallel_enable.enabled():
            from ooflib.common.IO import socket2me

        if config.petsc():
            print "Going to InitPETSc"
            from ooflib.SWIG.engine.PETSc.petsc_solverdriver import InitPETSc
            InitPETSc(sys.argv)
            for s in sys.argv:
                print s

        debug.set_debug_mode()  # set for debugging parallel mode
        from ooflib.common import quit
        quit.set_quiet()  ## back-end exits quietly.
        start_sockets_Back_End()  # socket initialization
        from ooflib.common import backEnd  # import back end machine
        # The back end shouldn't run the gui!
        runtimeflags.text_mode = True
        backEnd.back_end()  # back-end awaits for your command