PartitionedDomainEleIter.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.1.1.1 $
00022 // $Date: 2000/09/15 08:23:18 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/domain/partitioned/PartitionedDomainEleIter.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/OOP/domain/domain/partitioned/PartitionedDomainEleIter.C
00027 //
00028 // Written: fmk 
00029 // Created: Fri Sep 20 15:27:47: 1996
00030 // Revision: A
00031 //
00032 // Description: This file contains the method definitions for class 
00033 // PartitionedDomainEleIter. PartitionedDomainEleIter is a 
00034 // class for iterating through the elements of a ParitionedDomain
00035 // domain. 
00036 //
00037 // What: "@(#) PartitionedDomainEleIter.C, revA"
00038 
00039 #include <PartitionedDomainEleIter.h>
00040 
00041 #include <Subdomain.h>
00042 #include <Element.h>
00043 #include <SingleDomEleIter.h>
00044 #include <PartitionedDomain.h>
00045 #include <ArrayOfTaggedObjectsIter.h>
00046 #include <ArrayOfTaggedObjects.h>
00047 
00048 
00049 
00050 // PartitionedDomainEleIter(SingleDomain &theDomain):
00051 //      constructor that takes the model, just the basic iter
00052 
00053 PartitionedDomainEleIter::
00054 PartitionedDomainEleIter(PartitionedDomain *partitionedDomain)
00055   :subdomainIter(0), currentIter(0), currentSubdomain(0),
00056    thePartitionedDomain(partitionedDomain)
00057 {
00058     mainEleIter = new SingleDomEleIter(thePartitionedDomain->elements); 
00059     subdomainIter = new ArrayOfTaggedObjectsIter(
00060                      *(thePartitionedDomain->theSubdomains));
00061 }
00062 
00063 
00064 PartitionedDomainEleIter::~PartitionedDomainEleIter()
00065 {
00066     delete subdomainIter;
00067 }    
00068 
00069 void
00070 PartitionedDomainEleIter::reset(void)
00071 {
00072     mainDomain = true;
00073     mainEleIter->reset();
00074     subdomainIter->reset();
00075     currentIter = mainEleIter;
00076 
00077     TaggedObject *currentObject = (*subdomainIter)();
00078     if (currentObject != 0)
00079         currentSubdomain = (Subdomain *)currentObject;
00080     else
00081         currentSubdomain = 0;
00082 }
00083 
00084 Element *
00085 PartitionedDomainEleIter::operator()(void)
00086 {
00087     Element *theEle;
00088 
00089     while ((currentSubdomain != 0 || mainDomain == true)) {
00090         if (mainDomain == true) {
00091             theEle = (*currentIter)();
00092 
00093             if (theEle != 0) {
00094                 return theEle;
00095             }
00096             else {
00097                 mainDomain = false;
00098                 Element *res = currentSubdomain;
00099                 TaggedObject *currentObject = (*subdomainIter)();
00100                 currentSubdomain = (Subdomain *)currentObject;
00101                 return res;
00102             }
00103         } else {
00104             Element *res = currentSubdomain;
00105             TaggedObject *currentObject = (*subdomainIter)();
00106             currentSubdomain = (Subdomain *)currentObject;
00107             return res;
00108         }
00109     }
00110     
00111     // we will only get here if we are done 
00112     return 0;
00113 }

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