Package hec.rss.model

Class Element

All Implemented Interfaces:
AsciiSerializable, FieldAccessor, TSLocation, PlotVariableConstants, RssModelVariableConstants, RssReturnStatusConstants, RssTSLocation, hec.watershed.res.model.PlottableObject, Serializable, Cloneable, Comparable, Observer, rma.lang.Modifiable
Direct Known Subclasses:
DiversionElement, JunctionElement, OutletGroupElement, ReservoirElement, ReservoirOutletElement, TimeStepRoutingElement

public class Element extends NamedType implements RssTSLocation, RssReturnStatusConstants, hec.watershed.res.model.PlottableObject, PlotVariableConstants, RssModelVariableConstants
See Also:
  • Field Details

  • Constructor Details

    • Element

      public Element()
    • Element

      public Element(RssSystem sys, int idx)
  • Method Details

    • initTSVals

      protected void initTSVals(int istep)
      set estimated values for un-initialized time series variables at the given time step
      Parameters:
      istep -
    • hasWaterControlDevice

      public boolean hasWaterControlDevice()
    • getWaterControlDevice

      public WaterControlDevice getWaterControlDevice()
      returns the water control device, may return null
    • setWaterControlDevice

      public void setWaterControlDevice(WaterControlDevice waterControlDevice)
    • hasForebayHeadLoss

      public boolean hasForebayHeadLoss()
      returns true if the element has a forebay head loss object, otherwise returns false.
    • setHasForebayHeadLoss

      public void setHasForebayHeadLoss(boolean b)
      creates or deletes a forebay head loss object based on the given boolean. if the forebay head loss object already exists, setHasForebayHeadLoss(true) has no effect.
    • getForebayHeadLoss

      public ForebayHeadLoss getForebayHeadLoss()
      returns the forebay head loss object, may return null
    • getEffectiveElev

      public double getEffectiveElev(RunTimeStep rts)
      returns elevation for the given RunTimeStep at the upstream end of this element. Considers any "forebay" head loss associated with this and all parent elements For the first implementation, this method will only work for reservoirs and their child elements
      Returns:
      double elevation or RMAConst.UNDEF_DOUBLE if elevation data not available
    • getPrevEffectiveElev

      public double getPrevEffectiveElev(RunTimeStep rts)
      returns elevation for one time step prior to the given RunTimeStep at the upstream end of this element. Considers any "forebay" head loss associated with this and all parent elements For the first implementation, this method will only work for reservoirs and their child elements
      Returns:
      double elevation or RMAConst.UNDEF_DOUBLE if elevation data not available
    • getTailwaterElevationObjects

      public List getTailwaterElevationObjects(List list)
      walks over all children and their functions collecting a list of TailwaterElevation Objects
      Parameters:
      list - an existing List object or null
      Returns:
      a List object containing TailwaterElevation Objects
    • getRuleConnectivityRefs

      public List getRuleConnectivityRefs()
      Returns a List of RuleConnectivityRef objects identifying all rule references to other objects in the network. The default implementation here retuns null (no references). The method is overriden by ReservoirElement, ReservoirOutletElement, and DiversionElement.
      Returns:
      default implementation returns null
    • getObjectTypeId

      public static int getObjectTypeId(ModelVariable mv)
      get the element object type id for the object type
      Returns:
      the element object type
    • toString

      public String toString()
      toString method decodes key string
      Overrides:
      toString in class NamedType
    • setupForSerialization

      public void setupForSerialization()
      called just before ascii serialization
    • cleanupFromDeSerialization

      public void cleanupFromDeSerialization()
    • getReleaseElements

      public List getReleaseElements(List vec)
      Deprecated.
      returns a vector containing all elements belonging to and including this element that implement the ReleaseElement interface are release element to which rules can be attached
    • getDisplayName

      public String getDisplayName()
      returns the the elements name appended to its parents full name
      Overrides:
      getDisplayName in class NamedType
    • getOutputBPart

      protected String getOutputBPart()
      Generates a B Part that is used during storage to DSS when this function is saved.
      Returns:
      String
    • getFullName

      public String getFullName()
      returns the the elements name appended to its parents full name
    • getTopParentName

      public String getTopParentName()
      get the name of the top most parent element
    • applyHindcastData

      public void applyHindcastData(HindcastData hd)
      applies specific hindcast data for compute
    • getHindcastDataList

      public void getHindcastDataList(Vector hvec)
      compiles a vector of required hindcast data
    • getOutletElementList

      public Vector getOutletElementList()
    • getOutletElementList

      public void getOutletElementList(Vector vec)
    • getChildElementCount

      public int getChildElementCount()
    • getChildElementAt

      public Element getChildElementAt(int i)
    • children

      public Enumeration children()
    • getUnitSystem

      public int getUnitSystem()
    • clone

      public Object clone()
      clone method
      Overrides:
      clone in class NamedType
    • copyInto

      public void copyInto(Element re)
      Performs a deep copy that clones data of the given Element. This method is used by the reservoir editor.
    • downStreamFrom

      public boolean downStreamFrom(Element element)
      This tests to see if this element is downstream of the passed in parameter element.
      Parameters:
      element - The element to test if it is downstream of.
      Returns:
      returns true if this element is downstream of the given element.
    • resetParentElement

      public void resetParentElement()
      reset parent element assignment to all child elements
    • isActive

      public boolean isActive()
      returns whether element is active for computation
    • setActive

      public void setActive(boolean active)
      Sets whether element is active for computation. Also sets nodes computed by this element to the sam active or inactive state.
    • setActive

      public void setActive(boolean active, boolean recurse)
      Sets whether element is active for computation. Also sets nodes computed by this element to the sam active or inactive state.
    • isDirty

      public boolean isDirty()
      returns whether element is dirty and needs to be recomputed
    • setDirty

      public void setDirty(boolean dirty)
      Sets whether element is dirty and needs to be recomputed.
    • getKeyStringForObject

      public String getKeyStringForObject(Object obj)
      Takes a object of class Element, Function, RssNode, OpController, or OpRule and returns a unique string identifying that object pass request to RssSystem This should be a TSLocation method
    • getObjectForKeyString

      public Object getObjectForKeyString(String keystr)
      Takes a key string and returns the object of class Element, Function, Node, OpController, or OpRule Pass request to RssSystem This should be a TSLocation method
    • getTopParent

      public Element getTopParent()
      gets the top most parent element
    • getParent

      public Element getParent()
      gets the immediate parent element
    • setParentElement

      public void setParentElement(Element e)
    • addChildElement

      public void addChildElement(Element child)
    • addChildElementAt

      public void addChildElementAt(Element child, int idx)
    • removeChild

      public void removeChild(Element child)
    • removeAllChildElements

      public void removeAllChildElements()
    • initialize

      public boolean initialize(RunTimeWindow rtw)
      initialize prior to a compute
    • initForPostProcessing

      public boolean initForPostProcessing(RunTimeWindow rtw)
      Prepares this run for post processing in the ResSim Simulation Module. This routing sets up all data model connectivity, but does not load time series arrays.
      Returns:
      RTN_NOPROBLEM if successful
    • initHindcastLoop

      public boolean initHindcastLoop(RunTimeWindow rtw)
      initialize prior to hindcast computation loop
    • initForecastLoop

      public boolean initForecastLoop(RunTimeWindow rtw)
      initialize prior to Forecast computation loop
    • saveElementState

      public void saveElementState(int stateid)
      save the current state of the element and its function with the given identifier
      Parameters:
      stateid - identifier for the state
    • saveHotstartState

      public void saveHotstartState(HotstartState parentState, int stateId)
    • restoreHotstartState

      public boolean restoreHotstartState(HotstartState parentState)
    • createHotstartState

      protected ElementHotstartState createHotstartState()
    • restoreElementState

      public void restoreElementState(int stateid)
      restore the state of the element and its function matching the given identifier
      Parameters:
      stateid - identifier for the state
    • getSystem

      public RssSystem getSystem()
      get the parent system of this element
    • getElementVector

      public Vector getElementVector()
      provide access to the child element vector - use carefully!
    • getElementsByClass

      public Vector getElementsByClass(Class eclass, Vector vec)
      returns a vector of child elements of the given class or the elements function is of the given class
    • hasElementsOfClass

      public boolean hasElementsOfClass(Class eclass)
      returns a vector of child elements of the given class or the elements function is of the given class
    • getElementByName

      public Element getElementByName(String name)
      returns the child element with the given index, else returns null
    • getElement

      public Element getElement(int idx)
      returns the child element with the given index, else returns null
    • dispose

      public void dispose()
      dispose element and downstream nodes
    • dispose

      public void dispose(boolean disposeAllNodes)
      Release references to other objects
    • cleanVectors

      public void cleanVectors()
    • isNodeComputed

      public boolean isNodeComputed(RssNode nd)
    • isDisposed

      public boolean isDisposed()
      Checks if this object can be thrown away
    • getNodeVector

      public Vector getNodeVector()
    • getNodeDirVector

      public Vector getNodeDirVector()
    • getDownstreamNode

      public RssNode getDownstreamNode()
      returns the first downstream node in the node list
    • getUpstreamNode

      public RssNode getUpstreamNode()
      returns the first upstream node in the node list
      Returns:
      the first upstream node in the node list
    • getDownstreamNodes

      public List getDownstreamNodes(List vec)
      returns all downstream nodes in the node list does not recurse through child elements
    • getUpstreamNodes

      public List<RssNode> getUpstreamNodes(List<RssNode> vec)
      returns all upstream nodes in the node list does not recurse through child elements
    • getDownstreamElements

      public Vector<Element> getDownstreamElements(Vector<Element> vec)
      returns all elements downstream of this element
      Parameters:
      vec - a vector to hold the downstream elements (may be null)
      Returns:
      the vector of downstream elements
    • getLinkedElementList

      public List<Element> getLinkedElementList(int direction)
      return a new List object with either upstream (INFLOW) or downstream (OUTFLOW) linked elements
      Parameters:
      direction - : Element.OUTFLOW or Element.INFLOW
      Returns:
    • addNode

      public void addNode(RssNode node, int idir, boolean makeTS)
      Deprecated.
    • addNode

      public void addNode(RssNode node, int idir)
      adds a node to this element
    • removeNode

      public void removeNode(RssNode node)
    • getReferencePt

      public hec.map.WorldPt getReferencePt()
    • getFunction

      public Function getFunction()
    • setFunction

      public void setFunction(Function f)
    • findAdjParam

      public AdjustableParameter findAdjParam(String fname, String param)
    • findAdjParam

      public AdjustableParameter findAdjParam(String elemName, String function, String param)
    • findElement

      public Element findElement(String name)
    • getTSDataSet

      public TSDataSet getTSDataSet(boolean isInput)
      Description copied from interface: TSLocation
      returns the input or output TSData set currently associated with this loation
      Specified by:
      getTSDataSet in interface TSLocation
    • getNodeCount

      public int getNodeCount()
    • getNode

      public RssNode getNode(int idx)
    • getNodeDir

      public int getNodeDir(int idx)
    • computeHindcastStep

      public int computeHindcastStep(RunTimeStep rts)
      computes a single hindcast time step
    • computeForecastStep

      public int computeForecastStep(RunTimeStep rts)
      computes a single forecast time step
    • computeForecastStep

      public int computeForecastStep(RunTimeStep rts, double[] xt, double[] et, int tcount)
      computes a single forecast time step with additional arguments containing an elevation trace over the time step
    • computeSubStepFlow

      public double computeSubStepFlow(RunTimeStep rts, double xt, double et)
      computes a single forecast time step with additional arguments containing an elevation trace over the time step
    • computeHindcast

      public int computeHindcast(RunTimeWindow rtw, int computeType)
      performs a compute over the runtime window using hindcast logic
    • computeForecast

      public int computeForecast(RunTimeWindow rtw, int computeType)
      performs a compute over the runtime window using forecast logic
    • getForecastEquation

      public boolean getForecastEquation(RunTime runtime)
      Deprecated.
    • getHindcastEquation

      public boolean getHindcastEquation(RunTime runtime)
      Deprecated.
    • readData

      public boolean readData(BufferedReader input)
      Deprecated.
      Retrieves the Element data from the specified BufferedReader. This method is called by RssSystem.readFile after encountering an Element line type. Control of the file processing is passed back to the RssSystem object once an Element End line type is found or if "Element" is not contained in the line type. The later case is an error condition.

      The data stream must have type=param formatting. The following types and parameters are defined.

      Element Name= (String) name of the Element
      Element Nodes= (comma delimited ints) list of nodes connected by this element
      Element NodeDir= (comma delimited ints) list of node directions
      Element Function= (String) function type name
      Element End

      There must one NodeDir value for each RssNode associated with the element. A NodeDir value of 1 indicates positive flow at the node is an inflow to this element, 0 indicates a positive flow is an outflow.

      The function type name must be a valid Function Class name. The currently implemented classes include CoefRouting, Storage, Junction, Dam, and AdjustableFlow.
      The Element Function line type generate new Function according to the specified class name. The readData method of the new object is called to process class specific data. Control is returned to this method when a Element Function End line type is found. Note that a Element Function= line type must be matched by a Element Function End line type or the file will not be processed correctly.

      Parameters:
      input - BufferedReader connected to the ASCII file containing the RssSystem data.
      See Also:
    • writeData

      public boolean writeData(BufferedWriter out)
      Deprecated.
    • getRequiredTSRecordProxies

      public Vector getRequiredTSRecordProxies()
      returns the flow TSRecordProxies from upstream nodes on this element
    • getFlowContolTSRecordProxies

      public Vector getFlowContolTSRecordProxies()
    • getComputedTSRecordProxies_old

      public Vector getComputedTSRecordProxies_old()
      Deprecated.
      old method that assumes downstream records are computed
    • getComputedTSRecordProxies

      public Vector getComputedTSRecordProxies()
      requests vector of computed ts proxies from function
    • clearTSProxyList

      public void clearTSProxyList()
      dumps all ts proxies
    • updateTSProxyList

      public void updateTSProxyList()
      loops through function and child elements telling them to update there sets of TSRecordProxies()
    • updateWQTSProxyList

      public void updateWQTSProxyList(List<ModelVariable> conList)
      update set of TSRecordProxies associated with Water Quality
      Parameters:
      conList -
    • getActiveTSProxies

      public Vector getActiveTSProxies(Vector vec, int iotype)
      returns a vector of required input, or generated output TSRecordProxies used in the current alternative default implementation elements, assume all records are active
    • getTSRecordProxies

      public Vector getTSRecordProxies()
      Deprecated.
    • getActiveStateVariables

      public List getActiveStateVariables(List svlist)
      returns a vector of state variables in physical parts of element
    • getTSRecordProxy

      public TSRecordProxy getTSRecordProxy(int varid)
      gets TSRecordProxy from its function or child elements
      Specified by:
      getTSRecordProxy in interface RssTSLocation
    • getTSRecordProxy

      public TSRecordProxy getTSRecordProxy(String param)
      Deprecated.
    • setName

      public void setName(String name)
      echo name change to nodes whose names are based on this elements name not needed any more?? with use of key strings??
      Overrides:
      setName in class NamedType
    • calcSeepageFlow

      public double calcSeepageFlow(double flow)
    • getModelVariables

      public Vector getModelVariables(Vector variableList)
      Specified by:
      getModelVariables in interface hec.watershed.res.model.PlottableObject
    • getDefaultModelVariables

      public Vector getDefaultModelVariables()
      Description copied from interface: hec.watershed.res.model.PlottableObject
      return the list of Default ModelVariables to be used by the default plot
      Specified by:
      getDefaultModelVariables in interface hec.watershed.res.model.PlottableObject
      Returns:
      the default ModelVariables
    • getPlotTypes

      public Vector getPlotTypes()
      Specified by:
      getPlotTypes in interface hec.watershed.res.model.PlottableObject
    • getPlotTypeFile

      public BufferedReader getPlotTypeFile(String name)
      given the name of a system PlotType return a File for it
    • getPlotTypeDirectory

      public String getPlotTypeDirectory()
    • getPlotTypeNames

      public Vector getPlotTypeNames()
    • getElementType

      public String getElementType()
    • getElementTypeId

      public int getElementTypeId()
      get the unique element type Id. 1 = ReservoirElement 2 = ReachElement 4 = JunctionElement) 8 = DiversionElement
      Returns:
    • getTSRecords

      public Vector getTSRecords(ModelVariable modelVariable, Vector vec)
    • getTSRecords

      public Vector getTSRecords(ModelVariable modelVariable, Vector vec, Vector runs)
      Specified by:
      getTSRecords in interface hec.watershed.res.model.PlottableObject
    • setObsDataVector

      public void setObsDataVector(Vector obsDataList)
      Parameters:
      obsDataList -
    • getObsDataVector

      public Vector getObsDataVector()
      Returns:
    • importObservedData

      protected void importObservedData(Element fromElem, StringBuffer results)
      Parameters:
      fromElem -
      results -
    • getFieldObject

      public Object getFieldObject(Field fld)
      Description copied from interface: FieldAccessor
      This method allows access to java.lang.reflect.Field objects within the implementing class.
      Specified by:
      getFieldObject in interface FieldAccessor
      Overrides:
      getFieldObject in class NamedType
      Parameters:
      fld - The field to get.
      Returns:
      The data object that is stored in the given field
    • setFieldObject

      public boolean setFieldObject(Field fld, Object fobj)
      Description copied from interface: FieldAccessor
      This allows access to fields withing the implementing object to set there data.
      Specified by:
      setFieldObject in interface FieldAccessor
      Overrides:
      setFieldObject in class NamedType
      Parameters:
      fld - The java field object representing the member field to be set
      fobj - The data to set in that field
      Returns:
      returns true if successful