ShedHeaviest.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.2 $
00022 // $Date: 2003/02/14 23:00:58 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/loadBalancer/ShedHeaviest.cpp,v $
00024                                                                         
00025                                                                         
00026  // File: ~/domain/loadBalancer/ShedHeaviest.C
00027 // 
00028 // Written: fmk 
00029 // Created: Fri Aug 29 17:43:25 1997
00030 // Revision: A
00031 //
00032 // Description: This file contains the class definition for ShedHeaviest.
00033 // A ShedHeaviest is an object used to partition a PartitionedDomain.
00034 //
00035 // What: "@(#) ShedHeaviest.C, revA"
00036 
00037 #include <ShedHeaviest.h>
00038 #include <Graph.h>
00039 #include <VertexIter.h>
00040 #include <Vertex.h>
00041  
00042 ShedHeaviest::ShedHeaviest()
00043  :numReleases(1),factorGreater(1.0),disallowDisconnectedGraphs(true)
00044 {
00045     
00046 }
00047 
00048 ShedHeaviest::ShedHeaviest(double fact, int releases, bool disallowDisconnected)
00049  :numReleases(releases),
00050   factorGreater(fact),
00051   disallowDisconnectedGraphs(disallowDisconnected)
00052 {
00053     if (releases < 0)
00054         numReleases = 0;
00055 }
00056 
00057 ShedHeaviest::~ShedHeaviest()
00058 {
00059     
00060 }
00061 
00062 int
00063 ShedHeaviest::balance(Graph &theWeightedGraph)
00064 {
00065     // check to see a domain partitioner has been set
00066     DomainPartitioner *thePartitioner = this->getDomainPartitioner();
00067     if (thePartitioner == 0) {
00068         opserr << "ShedHeaviest::balance - No DomainPartitioner has been set\n";
00069         return -1;
00070     }
00071 
00072     // determine the max loaded partition
00073     VertexIter &theVertices = theWeightedGraph.getVertices();
00074     Vertex *vertexPtr = theVertices();
00075     int maxPartition = vertexPtr->getTag();
00076     double maxLoad = vertexPtr->getWeight();
00077     while ((vertexPtr = theVertices()) != 0)
00078         if (vertexPtr->getWeight() > maxLoad) {
00079             maxLoad = vertexPtr->getWeight();
00080             maxPartition = vertexPtr->getTag();
00081         }
00082     
00083     // release the boundary numReleases times
00084     int res = 0;
00085     for (int j=0; j<numReleases; j++) {
00086         res = thePartitioner->
00087             releaseBoundary(maxPartition,theWeightedGraph,
00088                             true,factorGreater);  
00089         
00090         if (res < 0) {
00091             opserr << "WARNING ShedHeaviest::balance() ";
00092             opserr << " - DomainPartitioner::releaseBoundary returned ";
00093             opserr << res << endln;
00094             j = numReleases;
00095         }
00096     }
00097     
00098     return res;
00099 }

Generated on Mon Oct 23 15:05:01 2006 for OpenSees by doxygen 1.5.0