Esempio n. 1
0
    def poststep(self, t, dt):
        """
    Hook for doing stuff after advancing time step.
    """
        logEvent = "%spoststep" % self._loggingPrefix
        self._eventLogger.eventBegin(logEvent)

        from pylith.mpi.Communicator import mpi_comm_world
        comm = mpi_comm_world()

        # The velocity and acceleration at time t depends on the
        # displacement at time t+dt, we want to output BEFORE updating the
        # displacement fields so that the displacement, velocity, and
        # acceleration files are all at time t.
        if 0 == comm.rank:
            self._info.log("Writing solution fields.")
        for output in self.output.components():
            output.writeData(t, self.fields)
        self._writeData(t)

        # Update displacement field from time t to time t+dt.
        dispIncr = self.fields.get("dispIncr(t->t+dt)")
        dispT = self.fields.get("disp(t)")
        dispTmdt = self.fields.get("disp(t-dt)")

        dispTmdt.copy(dispT)
        dispT.add(dispIncr)
        dispIncr.zeroAll()

        # Complete post-step processing.
        Formulation.poststep(self, t, dt)

        self._eventLogger.eventEnd(logEvent)
        return
Esempio n. 2
0
  def poststep(self, t, dt):
    """
    Hook for doing stuff after advancing time step.
    """
    logEvent = "%spoststep" % self._loggingPrefix
    self._eventLogger.eventBegin(logEvent)
    
    from pylith.mpi.Communicator import mpi_comm_world
    comm = mpi_comm_world()

    # The velocity and acceleration at time t depends on the
    # displacement at time t+dt, we want to output BEFORE updating the
    # displacement fields so that the displacement, velocity, and
    # acceleration files are all at time t.
    if 0 == comm.rank:
      self._info.log("Writing solution fields.")
    for output in self.output.components():
      output.writeData(t, self.fields)
    self._writeData(t)

    # Update displacement field from time t to time t+dt.
    dispIncr = self.fields.get("dispIncr(t->t+dt)")
    dispT = self.fields.get("disp(t)")
    dispTmdt = self.fields.get("disp(t-dt)")

    dispTmdt.copy(dispT)
    dispT.add(dispIncr)
    dispIncr.zeroAll()

    # Complete post-step processing.
    Formulation.poststep(self, t, dt)

    self._eventLogger.eventEnd(logEvent)    
    return
Esempio n. 3
0
  def poststep(self, t, dt):
    """
    Hook for doing stuff after advancing time step.
    """
    from pylith.mpi.Communicator import mpi_comm_world
    comm = mpi_comm_world()

    # Update displacement field from time t to time t+dt.
    dispIncr = self.fields.get("dispIncr(t->t+dt)")
    disp = self.fields.get("disp(t)")
    disp.add(dispIncr)
    dispIncr.zeroAll()

    # Complete post-step processing, then write data.
    Formulation.poststep(self, t, dt)

    # Write data. Velocity at time t will be based upon displacement
    # at time t-dt and t.
    if 0 == comm.rank:
      self._info.log("Writing solution fields.")
    for output in self.output.components():
      output.writeData(t+dt, self.fields)
    self._writeData(t+dt)

    return
Esempio n. 4
0
 def __init__(self, name="implicit"):
   """
   Constructor.
   """
   Formulation.__init__(self, name)
   ModuleImplicit.__init__(self)
   self._loggingPrefix = "TSIm "
   return
Esempio n. 5
0
 def __init__(self, name="implicit"):
   """
   Constructor.
   """
   Formulation.__init__(self, name)
   ModuleImplicit.__init__(self)
   self._loggingPrefix = "TSIm "
   return
Esempio n. 6
0
 def __init__(self, name="explicit"):
   """
   Constructor.
   """
   Formulation.__init__(self, name)
   ModuleExplicit.__init__(self)
   self._loggingPrefix = "TSEx "
   self.dtStable = None
   return
Esempio n. 7
0
  def _configure(self):
    """
    Set members based using inventory.
    """
    Formulation._configure(self)

    self.normViscosity = self.inventory.normViscosity
    self.solver = self.inventory.solver
    return
Esempio n. 8
0
  def _configure(self):
    """
    Set members based using inventory.
    """
    Formulation._configure(self)

    import journal
    self._debug = journal.debug(self.name)
    return
Esempio n. 9
0
  def _configure(self):
    """
    Set members based using inventory.
    """
    Formulation._configure(self)

    import journal
    self._debug = journal.debug(self.name)
    return
Esempio n. 10
0
 def __init__(self, name="explicit"):
     """
 Constructor.
 """
     Formulation.__init__(self, name)
     ModuleExplicit.__init__(self)
     self._loggingPrefix = "TSEx "
     self.dtStable = None
     return
Esempio n. 11
0
    def _configure(self):
        """
    Set members based using inventory.
    """
        Formulation._configure(self)

        self.normViscosity = self.inventory.normViscosity
        self.solver = self.inventory.solver
        return
Esempio n. 12
0
  def poststep(self, t, dt):
    """
    Hook for doing stuff after advancing time step.
    """
    comm = self.mesh().comm()

    # Update displacement field from time t to time t+dt.
    dispIncr = self.fields.get("dispIncr(t->t+dt)")
    disp = self.fields.get("disp(t)")
    disp.add(dispIncr)
    dispIncr.zeroAll()

    # Complete post-step processing, then write data.
    Formulation.poststep(self, t, dt)

    # Write data. Velocity at time t will be based upon displacement
    # at time t-dt and t.
    if 0 == comm.rank:
      self._info.log("Writing solution fields.")
    for output in self.output.components():
      output.writeData(t+dt, self.fields)
    self._writeData(t+dt)

    return
Esempio n. 13
0
 def finalize(self):
   """
   Cleanup after time stepping.
   """
   Formulation.finalize(self)
   return
Esempio n. 14
0
 def finalize(self):
   """
   Cleanup after time stepping.
   """
   Formulation.finalize(self)
   return
Esempio n. 15
0
    nodes = [Node(i, q[i]) for i in range(1, n)]

    network = Network(source, c, Q)
    network.add_nodes(nodes)

    routes, total_cost = network.build_route()

    print([node.id for route in routes for node in route])

    # the route found by the heuristic should have less or equal number of vehicle
    #assert len(routes[0]) <= m
    m = len(routes)

    # cplex solution

    f = Formulation(A, V, N, q, Q, c, m, n, 3)
    f.set_formulation()
    f.add_formulation_constraints()

    # save initial solution as CPLEX file
    value_map = utils.write_cplex_solution(routes, n)
    solve_solution = SolveSolution(model=f.formulation,
                                   var_value_map=value_map,
                                   obj=total_cost)

    solution, routes_solution = f.run_formulation(solve_solution, True)

    utils.print_routes(routes_solution)

    if solution is None:
        new_value = {