Click or drag to resize

DfsuFile Class

Class for exposing data from a dfsu file.

Use the DfsFileFactory to open an existing dfsu file.

Use the DfsuBuilder to create a new dfsu file.

You can read, write and append item-timesteps to the file.

The geometry can be altered, by moving the nodes, but the element connectivity can not be changed.

Inheritance Hierarchy
SystemObject
  DHI.Generic.MikeZero.DFS.dfsuDfsuFile

Namespace:  DHI.Generic.MikeZero.DFS.dfsu
Assembly:  DHI.Generic.MIKEZero.DFS (in DHI.Generic.MIKEZero.DFS.dll) Version: 19.0.0.0 (11.1.1.1111)
Syntax
public class DfsuFile : IDfsuFile, IDfsFileIO, 
	IDisposable, IDfsFile, IDfsFileStaticIO

The DfsuFile type exposes the following members.

Constructors
  NameDescription
Public methodDfsuFile
Wrap a dfs file in the DfsuFile object.

It will throw an exception if file is not a dfsu file.

Top
Properties
  NameDescription
Public propertyApplicationTitle
Title of application creating the file
Public propertyApplicationVersion
Version number of appliation creating the file.
Public propertyCode
Boundary code of node. 0 means not a boundary node.
Public propertyDeleteValueFloat
Delete (undefined/missing) value
Public propertyDfsuFileType
Type of dfsu file.
Public propertyElementIds
Id for each element. Usually starts from 1 and increases, but needs not to.
Public propertyElementTable
The ElementTable defines for each element which nodes that defines the element.

The numbers in the ElementTable are node numbers, not indices! Each value in the table are between 1 and number-of-nodes.

Public propertyElementType
Type of element.
Public propertyFileName
Name of file
Public propertyFileTitle
Title of file
Public propertyItemInfo
List of dynamic item info.
Public propertyNodeIds
Id for each node. Usually starts from 1 and increases, but needs not to.
Public propertyNumberOfElements
Number of elements in the mesh.
Public propertyNumberOfLayers
For files with a vertical dimension, returns the maximum number of layers.
Public propertyNumberOfNodes
Number of nodes in the mesh.
Public propertyNumberOfSigmaLayers
For files with a vertical dimension, returns the number of sigma layers.
Public propertyNumberOfTimeSteps
Number of time steps in the file
Public propertyProjection
Geographical projection.
Public propertyStartDateTime
Start date time of the file. If time axis is not a calendar type axis, MinValue is returned.

Setting the StartDateTime for an axis that is not of calendar type, will throw an exception.

Public propertyTimeAxis
Temporal axis of dfsu file.
Public propertyTimeStepInSeconds
Time step in seconds. If time axis is not an equidistant type axis, zero is returned.

Setting the time step for an axis that is not of equidistant type, will throw an exception.

Public propertyX
X coordinates of nodes
Public propertyY
Y coordinates of nodes
Public propertyZ
Z coordinates of nodes
Public propertyZUnit
Unit of the z coordinate. The unit must be a length unit (convertable to meters).
Top
Methods
  NameDescription
Public methodClose
Public methodDfsCurrentVersion
Returns the current version of the Dfs file library
Public methodDispose
Close file and release ressources on the unmanaged side.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodFindItem
Positions the file pointer at the location in the file where the specified dynamic item at the specified time step starts.
Public methodFindTimeStep
Positions the file pointer at the location in the file where the specified time step starts.
Public methodFlush
Public methodFlushTimeStep
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberOpen(Stream)
Open a dfsu stream for reading
Public methodStatic memberOpen(String)
Open a dfsu file for reading
Public methodStatic memberOpenAppend
Open a dfsu file for appending/editing. File pointer is pointing to the end of the file data.
Public methodStatic memberOpenEdit
Open a dfsu file for editing. File pointer is pointing to the start of the file data.
Public methodReadItemTimeStep(Int32, Int32)
Public methodReadItemTimeStep(IDfsItemData, Int32)
Public methodReadItemTimeStepNext
Public methodReset
Resets the file pointer to point on the first dynamic item time step in the file.

Can also be used if it is required to restart reading the static items.

Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWriteItemTimeStep
Writes data to the specified item and timestep in the file.

If the item-timestep exists already, data is updated. If it does not exist, the item number and timestep index must match exactly the next item-timestep after the last one in the file.

The size of the data must match the data size of the item that is to be written.

The time value is only relevant for files with non-equidistant time axis. For files with an equidistant time axis, the time value is ignored, and a zero can be used.

Public methodWriteItemTimeStepNext

Writes the next dynamic item-timestep.

If the file pointer points to the end of the file, this will append a new item-timestep to the file. If the file pointer points to an existing item-timestep, the data of that item-timestep is updated.

Remember that the file pointer position depends on the mode that the file was opened: In edit mode the file pointer points at the first item-timestep. In append mode the file pointer points initially at the end of file.

It iterates over the item-timesteps as the ReadItemTimeStepNext, see there for more details.

This is the most efficient way to iterate through and update/append the items and timesteps in a file, since it iterates exactly as the data is stored on the disk.

The size of the data must match the data size of the item that is to be written.

The time value is only relevant for files with non-equidistant time axis. For files with an equidistant time axis, the time value is ignored, and a zero can be used.

Top
Extension Methods
  NameDescription
Public Extension MethodCalculateElementCenterCoordinates
For each element, calculates the element center coordinate as the average of all node coordinates of the nodes in each element.
(Defined by DfsuUtil.)
Public Extension MethodCreateEmptyItemData(Int32)Overloaded. (Defined by DfsExtensions.)
Public Extension MethodCreateEmptyItemDataT(Int32)Overloaded.
Create an IDfsItemDataT of the correct type for the item with the given itemNumber.

The result can be used by ReadItemTimeStep(IDfsItemData, Int32)

If not the item is of type {T}, an exception will be thrown.

(Defined by DfsExtensions.)
Public Extension MethodCreateEmptyItemDatasOverloaded. (Defined by DfsExtensions.)
Public Extension MethodCreateEmptyItemDatasTOverloaded.
Create an IDfsItemDataT of the provided type for each of the dynamic items in the file.

The result can be used by ReadItemTimeStep(IDfsItemData, Int32)

If not all items are of type {T}, an exception will be thrown.

(Defined by DfsuUtil.)
Public Extension MethodCreateEmptyItemDatasTOverloaded.
Create an IDfsItemDataT of the provided type for each of the dynamic items in the file.

The result can be used by ReadItemTimeStep(IDfsItemData, Int32)

If not all items are of type {T}, an exception will be thrown.

(Defined by DfsExtensions.)
Public Extension MethodFindTopLayerElements
Find element indices (zero-based) of the elements being the upper-most element in its column.

Each column is identified by matching node id numbers. For 3D elements the last half of the node numbers of the bottom element must match the first half of the node numbers in the top element. For 2D vertical elements the order of the node numbers in the bottom element (last half number of nodes) are reversed compared to those in the top element (first half number of nodes).

(Defined by DfsuUtil.)
Public Extension MethodGetDateTimes
Return an array of DateTimes which are the times for each timestep
(Defined by DfsuUtil.)
Public Extension MethodSearch(DateTime)Overloaded.
Searches the dfs file for the time step index of a time, and returns the zero-based time step index. The time axis of the file must be a calendar type time axis

NOTE: For the non-equidistant time axes, the metod will read the first item in the file for a number of timesteps in random order, performing a binary search in the file data on disc. This will be slow if used many times on the same file. In such a case, use the lazy version of GetDateTimes(IDfsFile, Boolean) or GetDateTimes(IDfsFile, DateTime, Boolean).

For the equidistant time axis, the method will calculate the time step index directly without reading data from the file.

(Defined by DfsExtensions.)
Public Extension MethodSearch(Double)Overloaded.
Searches the dfs file for the time step index of a time, and returns the zero-based time step index.

NOTE: For the non-equidistant time axes, the metod will read the first item in the file for a number of timesteps in random order, performing a binary search in the file data on disc. This will be slow if used many times on the same file. In such a case, use the lazy version of GetDateTimes(IDfsFile, Boolean) or GetDateTimes(IDfsFile, DateTime, Boolean).

For the equidistant time axis, the method will calculate the time step index directly without reading data from the file.

(Defined by DfsExtensions.)
Top
See Also