using System; using System.Text; using Deltares.IONetCDF.Managed.Helpers; // ReSharper disable UnusedMember.Global namespace Deltares.IONetCDF.Managed { /// /// Managed wrapper for the native io_netcdf library. /// public sealed partial class Wrapper { private const int StartIndex = 0; /// /// Checks whether the specified data set adheres to a specific set of conventions. /// /// /// Data sets may adhere to multiple conventions at the same time, so use this method /// to check for individual conventions. /// /// The IONetCDF data set id (in). /// The NetCDF conventions type to check for (in). /// Whether or not the file adheres to the specified conventions. public bool AdheresToConventions(int ioNetCdfDataSetId, int netCdfConventionsType) { return ionc_adheresto_conventions_dll(ref ioNetCdfDataSetId, ref netCdfConventionsType); } /// /// Inquires the NetCDF conventions used in the data set. /// /// The IONetCDF data set id (in). /// The NetCDF conventions type of the data set (out). /// The NetCDF conventions version of the data set (out). /// Result status (IONC_NOERR if successful). public int InquireConventions(int ioNetCdfDataSetId, ref int netCdfConventionsType, ref double netCdfConventionsVersionOfTheDataSet) { return ionc_inq_conventions_dll(ref ioNetCdfDataSetId, ref netCdfConventionsType, ref netCdfConventionsVersionOfTheDataSet); } /// /// Tries to open a NetCDF file and initializes based on the its conventions type. /// /// Path to the NetCDF data set to be opened (in). /// NetCDF open mode (e.g. NF90_NOWRITE) (in). /// The IONetCDF data set id (this is not the NetCDF ncid, which is stored in datasets(ioncid)%ncid) (out). /// The NetCDF conventions type of the data set (out). /// The NetCDF conventions version of the data set (out). /// Result status (IONC_NOERR if successful). public int Open(string path, int mode, ref int ioNetCdfDataSetId, ref int netCdfConventionsType, ref double netCdfConventionsVersionOfTheDataSet) { return ionc_open_dll(path, ref mode, ref ioNetCdfDataSetId, ref netCdfConventionsType, ref netCdfConventionsVersionOfTheDataSet); } /// /// Tries to close an open IONetCDF data set. /// /// The IONetCDF data set id (this is not the NetCDF ncid, which is stored in datasets(ioncid)%ncid) (in). /// Result status (IONC_NOERR if successful). public int Close(int ioNetCdfDataSetId) { return ionc_close_dll(ref ioNetCdfDataSetId); } /// /// Gets the name of the network. /// /// The IONetCDF data set id (in). /// The network id (in). /// The network name (out). /// Result status (IONC_NOERR if successful). public int GetNetworkName(int ioNetCdfDataSetId, int networkId, StringBuilder networkName) { return ionc_1d_get_network_name_dll(ref ioNetCdfDataSetId, ref networkId, networkName); } /// /// Defines a new variable in an existing IONetCDF data set and sets up proper meta-attributes. /// /// /// File should still be in define mode. Does not write the actual data yet. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The id of the NetCDF variable to define. /// The variable type expressed in one of the basic nf90_* types (in). Should match with double fillValue (i.e., nf90_double). /// Specifies at which unique mesh location data will be specified (in). /// The name of the new variable (in). /// Standard name (CF-compliant) for 'standard_name' attribute in this variable (in). /// Long name for 'long_name' attribute in this variable (use empty string if not applicable) (in). /// Unit of this variable (CF-compliant) (use empty string for dimensionless quantities) (in). /// Double precision fill value (in). /// Result status (UG_NOERR==NF90_NOERR if successful). public int DefineVariable(int ioNetCdfDataSetId, int meshId, int varId, int type, IONetCDFConstants.LocationType locationType, string variableName, string standardName, string longName, string unit, double fillValue) { int networkId = 0; // dummy int fillValueInt = -999; // dummy var locType = (int) locationType; return ionc_def_var_dll(ref ioNetCdfDataSetId, ref meshId, ref networkId, ref varId, ref type, ref locType, variableName, standardName, longName, unit, ref fillValueInt, ref fillValue); } /// /// Defines a new double variable on a 1D network in an existing IONetCDF data set and sets up proper meta-attributes. /// /// /// File should still be in define mode. Does not write the actual data yet. /// /// The IONetCDF data set id (in). /// The network id in the specified data set (in). /// The id of the NetCDF variable to define. /// The variable type expressed in one of the basic nf90_* types (in). Should match with double fillValue (i.e., nf90_double). /// Specifies at which unique mesh location data will be specified (in). /// The name of the new variable (in). /// Standard name (CF-compliant) for 'standard_name' attribute in this variable (in). /// Long name for 'long_name' attribute in this variable (use empty string if not applicable) (in). /// Unit of this variable (CF-compliant) (use empty string for dimensionless quantities) (in). /// Double precision fill value (in). /// Result status (UG_NOERR==NF90_NOERR if successful). public int DefineNetworkVariable(int ioNetCdfDataSetId, int networkId, int varId, int type, IONetCDFConstants.LocationType locationType, string variableName, string standardName, string longName, string unit, double fillValue) { int meshId = 0; // dummy int fillValueInt = -999; // dummy var locType = (int) locationType; return ionc_def_var_dll(ref ioNetCdfDataSetId, ref meshId, ref networkId, ref varId, ref type, ref locType, variableName, standardName, longName, unit, ref fillValueInt, ref fillValue); } /// /// Defines a new int variable on a 1D network in an existing IONetCDF data set and sets up proper meta-attributes. /// /// /// File should still be in define mode. Does not write the actual data yet. /// /// The IONetCDF data set id (in). /// The network id in the specified data set (in). /// The id of the NetCDF variable to define. /// The variable type expressed in one of the basic nf90_* types (in). Should match with int fillValueInt (i.e., nf90_integer). /// Specifies at which unique mesh location data will be specified (in). /// The name of the new variable (in). /// Standard name (CF-compliant) for 'standard_name' attribute in this variable (in). /// Long name for 'long_name' attribute in this variable (use empty string if not applicable) (in). /// Unit of this variable (CF-compliant) (use empty string for dimensionless quantities) (in). /// Int precision fill value (in). /// Result status (UG_NOERR==NF90_NOERR if successful). public int DefineNetworkVariable(int ioNetCdfDataSetId, int networkId, int varId, int type, IONetCDFConstants.LocationType locationType, string variableName, string standardName, string longName, string unit, int fillValueInt) { int meshId = 0; // dummy double fillValue = -999.0; // dummy var locType = (int) locationType; return ionc_def_var_dll(ref ioNetCdfDataSetId, ref meshId, ref networkId, ref varId, ref type, ref locType, variableName, standardName, longName, unit, ref fillValueInt, ref fillValue); } /// /// Gets the id of the 1D network. /// /// The IONetCDF data set id (in). /// The network id (out). /// Result status (IONC_NOERR if successful). public int Get1DNetworkId(int ioNetCdfDataSetId, ref int networkId) { return ionc_get_1d_network_id_dll(ref ioNetCdfDataSetId, ref networkId); } /// /// Gets the id of the 1D mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (out). /// Result status (IONC_NOERR if successful). public int Get1DMeshId(int ioNetCdfDataSetId, ref int meshId) { return ionc_get_1d_mesh_id_dll(ref ioNetCdfDataSetId, ref meshId); } /// /// Gets the id of the 2d mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (out). /// Result status (IONC_NOERR if successful). public int Get2DMeshId(int ioNetCdfDataSetId, ref int meshId) { return ionc_get_2d_mesh_id_dll(ref ioNetCdfDataSetId, ref meshId); } /// /// Gets the id of the 3d mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (out). /// Result status (IONC_NOERR if successful). public int Get3DMeshId(int ioNetCdfDataSetId, ref int meshId) { return ionc_get_3d_mesh_id_dll(ref ioNetCdfDataSetId, ref meshId); } /// /// Gets the number of meshes from a data set. /// /// The IONetCDF data set id (in). /// The number of meshes (out). /// Result status (IONC_NOERR if successful). public int GetMeshCount(int ioNetCdfDataSetId, ref int numberOfMesh) { return ionc_get_mesh_count_dll(ref ioNetCdfDataSetId, ref numberOfMesh); } /// /// Gets the name of the mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The mesh name (out). /// Result status (IONC_NOERR if successful). public int GetMeshName(int ioNetCdfDataSetId, int meshId, StringBuilder meshName) { return ionc_get_mesh_name_dll(ref ioNetCdfDataSetId, ref meshId, meshName); } /// /// Gets the number of nodes in a single mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The number of nodes (out). /// Result status (IONC_NOERR if successful). public int GetNodeCount(int ioNetCdfDataSetId, int meshId, ref int numberOfNodes) { return ionc_get_node_count_dll(ref ioNetCdfDataSetId, ref meshId, ref numberOfNodes); } /// /// Gets the number of edges in a single mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The number of edges (out). /// Result status (IONC_NOERR if successful). public int GetEdgeCount(int ioNetCdfDataSetId, int meshId, ref int numberOfEdges) { return ionc_get_edge_count_dll(ref ioNetCdfDataSetId, ref meshId, ref numberOfEdges); } /// /// Gets the number of faces in a single mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The number of faces (out). /// Result status (IONC_NOERR if successful). public int GetFaceCount(int ioNetCdfDataSetId, int meshId, ref int numberOfFaces) { return ionc_get_face_count_dll(ref ioNetCdfDataSetId, ref meshId, ref numberOfFaces); } /// /// Gets the maximum number of nodes for any face in a single mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The maximum number of nodes per face in the mesh (out). /// Result status (IONC_NOERR if successful). public int GetMaxFaceNodes(int ioNetCdfDataSetId, int meshId, ref int numberOfMaxFaceNodes) { return ionc_get_max_face_nodes_dll(ref ioNetCdfDataSetId, ref meshId, ref numberOfMaxFaceNodes); } /// /// Gets the x,y-coordinates for all nodes in a single mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// Pointer to an array for storing the x-coordinates (out). /// Pointer to an array for storing the y-coordinates (out). /// The number of nodes in the mesh (in). /// Result status (IONC_NOERR if successful). public int GetNodeCoordinates(int ioNetCdfDataSetId, int meshId, ref IntPtr pointerToArrayOfXValues, ref IntPtr pointerToArrayOfYValues, int numberOfNodes) { return ionc_get_node_coordinates_dll(ref ioNetCdfDataSetId, ref meshId, ref pointerToArrayOfXValues, ref pointerToArrayOfYValues, ref numberOfNodes); } /// /// Gets the edge-node connectivity table for all edges in the specified mesh. /// /// /// The output edge-nodes array is supposed to be of exact correct size already. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// Pointer to an array for storing the edge-node connectivity table (out). /// The number of edges in the mesh (in). /// Result status (IONC_NOERR if successful). public int GetEdgeNodes(int ioNetCdfDataSetId, int meshId, ref IntPtr pointerToArrayOfEdgeNodes, int numberOfEdges) { // Note: The start index should always be the same for both GetEdgeNodes and GetFaceNodes var startIndex = StartIndex; return ionc_get_edge_nodes_dll(ref ioNetCdfDataSetId, ref meshId, ref pointerToArrayOfEdgeNodes, ref numberOfEdges, ref startIndex); } /// /// Gets the face-node connectivity table for all faces in the specified mesh. /// /// /// The output face-nodes array is supposed to be of exact correct size already. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// Pointer to an array for storing the face-node connectivity table (out). /// The number of faces in the mesh (in). /// The maximum number of nodes per face in the mesh (in). /// Scalar for getting the fill value parameter for the requested variable (out). /// Result status (IONC_NOERR if successful). public int GetFaceNodes(int ioNetCdfDataSetId, int meshId, ref IntPtr pointerToArrayOfFaceNodes, int numberOfFaces, int numberOfMaxFaceNodes, ref int fillValue) { // Note: The start index should always be the same for both GetEdgeNodes and GetFaceNodes var startIndex = StartIndex; return ionc_get_face_nodes_dll(ref ioNetCdfDataSetId, ref meshId, ref pointerToArrayOfFaceNodes, ref numberOfFaces, ref numberOfMaxFaceNodes, ref fillValue, ref startIndex); } /// /// Writes a complete mesh geometry. /// /// File name for NetCDF data set to be created (in). /// Result status (IONC_NOERR if successful). public int WriteGeomUGrid(string fileName) { return ionc_write_geom_ugrid_dll(fileName); } /// /// Writes a complete map file. /// /// File name for NetCDF data set to be created (in). /// Result status (IONC_NOERR if successful). public int WriteMapUGrid(string fileName) { return ionc_write_map_ugrid_dll(fileName); } /// /// Gets the EPSG code of the coordinate system from a data set. /// /// The IONetCDF data set id (in). /// The EPSG code (out). /// Result status (IONC_NOERR if successful). public int GetCoordinateSystem(int ioNetCdfDataSetId, ref int epsgCodeNumber) { return ionc_get_coordinate_system_dll(ref ioNetCdfDataSetId, ref epsgCodeNumber); } /// /// Returns the number of variables that are available in the specified data set on the specified mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The topological location on which to select data (in). /// The number of variables defined on the requested location (out). /// Result status (IONC_NOERR if successful). public int GetVariablesCount(int ioNetCdfDataSetId, int meshId, IONetCDFConstants.LocationType locationType, ref int numberOfVariablesCount) { var locType = (int) locationType; return ionc_get_var_count_dll(ref ioNetCdfDataSetId, ref meshId, ref locType, ref numberOfVariablesCount); } /// /// Gets the id of a variable that is defined in the specified data set on the specified mesh. /// /// /// The variable is searched based on variable name (without any "meshnd_" prefix), and which :mesh it is defined on. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The name of the variable to be found (should be without any "meshnd_" prefix) (in). /// The resulting variable id, if found (out). /// Result status (IONC_NOERR if successful). public int InquireVariableId(int ioNetCdfDataSetId, int meshId, string variableName, ref int varId) { return ionc_inq_varid_dll(ref ioNetCdfDataSetId, ref meshId, variableName, ref varId); } /// /// Gets the id of the variable in the specified data set on the specified mesh, /// that also has the specified value for its ':standard_name' attribute, and /// is defined on the specified topological mesh location (UGRID-compliant, so UG_LOC_FACE/EDGE/NODE/ALL2D). /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The topological location on which to select data (UGRID-compliant, so UG_LOC_FACE/EDGE/NODE/ALL2D) (in). /// The standard_name value that is searched for (in). /// The resulting variable id, if found (out). /// Result status (IONC_NOERR if successful). public int InquireVariableIdByStandardName(int ioNetCdfDataSetId, int meshId, IONetCDFConstants.LocationType locationId, string standardName, ref int varId) { var locId = (int) locationId; return ionc_inq_varid_by_standard_name_dll(ref ioNetCdfDataSetId, ref meshId, ref locId, standardName, ref varId); } /// /// Gets a list of variable ids that are available in the specified data set on the specified mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The topological location on which to select data (in). /// Pointer to an array for storing the variable ids (out). /// The number of variables in the target array (in). /// Result status (IONC_NOERR if successful). public int InquireVariableIds(int ioNetCdfDataSetId, int meshId, IONetCDFConstants.LocationType locationType, ref IntPtr pointerToArrayForTheVariableIds, int numberOfVariableIds) { var locType = (int) locationType; return ionc_inq_varids_dll(ref ioNetCdfDataSetId, ref meshId, ref locType, ref pointerToArrayForTheVariableIds, ref numberOfVariableIds); } /// /// Initializes the io_netcdf library, setting up the logger. /// /// The callback that will be called with new messages (in). /// The callback that will be called with new messages for progress (in). /// Result status (IONC_NOERR if successful). public int Initialize(IO_NetCDF_Message_Callback messageCallback, IO_NetCDF_Progress_Callback progressCallback) { return ionc_initialize_dll(messageCallback, progressCallback); } /// /// Gets the values for a variable that is defined in the specified data set on the specified mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The topological location on which to select data (UGRID-compliant, so UG_LOC_FACE/EDGE/NODE/ALL2D) (in). /// The name of the variable (in). /// Pointer to an array for storing the values of the variable (out). /// The number of values (in). /// Double precision fill value (out). /// Result status (IONC_NOERR if successful). public int GetVariable(int ioNetCdfDataSetId, int meshId, IONetCDFConstants.LocationType locationType, string variableName, ref IntPtr valuesPtr, int numberOfValues, ref double fillValue) { var location = (int) locationType; return ionc_get_var_dll(ref ioNetCdfDataSetId, ref meshId, ref location, variableName, ref valuesPtr, ref numberOfValues, ref fillValue); } /// /// Puts the values for a variable that is defined in the specified data set on the specified mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The topological location on which to set data (in). /// The name of the variable (in). /// Pointer to an array containing the values to set (in). /// The number of values (in). /// Result status (IONC_NOERR if successful). public int PutVariable(int ioNetCdfDataSetId, int meshId, IONetCDFConstants.LocationType locationType, string variableName, IntPtr valuesPtr, int numberOfValues) { var locType = (int) locationType; return ionc_put_var_dll(ref ioNetCdfDataSetId, ref meshId, ref locType, variableName, ref valuesPtr, ref numberOfValues); } /// /// Puts the x,y-coordinates for all nodes in a single mesh from a data set. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// Pointer to an array containing the x-coordinates (in). /// Pointer to an array containing the y-coordinates (in). /// The number of nodes in the mesh (in). /// Result status (IONC_NOERR if successful). public int PutNodeCoordinates(int ioNetCdfDataSetId, int meshId, IntPtr pointerToArrayOfXValues, IntPtr pointerToArrayOfYValues, int numberOfNodes) { return ionc_put_node_coordinates_dll(ref ioNetCdfDataSetId, ref meshId, ref pointerToArrayOfXValues, ref pointerToArrayOfYValues, ref numberOfNodes); } /// /// Adds the global attributes to a NetCDF file. /// /// The IONetCDF data set id (in). /// The global attributes to add (in). /// Result status (IONC_NOERR if successful). public int AddGlobalAttributes(int ioNetCdfDataSetId, interop_metadata metaData) { return ionc_add_global_attributes_dll(ref ioNetCdfDataSetId, ref metaData); } /// /// Creates a new NetCDF file. /// /// The path where the file will be created (in). /// The NetCDF opening mode (in). /// The IONetCDF data set id (out). /// Result status (IONC_NOERR if successful). public int Create(string path, int mode, ref int ioNetCdfDataSetId) { return ionc_create_dll(path, ref mode, ref ioNetCdfDataSetId); } /// /// Creates a 1D network in an opened NetCDF file. /// /// The IONetCDF data set id (in). /// The network id (out). /// The network name (in). /// The number of network nodes (in). /// The number of network branches (in). /// The number of geometry points (in). /// Result status (IONC_NOERR if successful). public int Create1DNetwork(int ioNetCdfDataSetId, ref int networkId, string networkName, int numberOfNodes, int numberOfBranches, int numberOfGeometryPoints) { return ionc_create_1d_network_dll(ref ioNetCdfDataSetId, ref networkId, networkName, ref numberOfNodes, ref numberOfBranches, ref numberOfGeometryPoints); } /// /// Writes the network nodes. /// /// The IONetCDF data set id (in). /// The network id (in). /// Pointer to an array containing the x-coordinates of the network nodes (in). /// Pointer to an array containing the y-coordinates of the network nodes (in). /// Pointer to an array containing the ids of the network nodes (in). /// Pointer to an array containing the long names of the network nodes (in). /// The number of network nodes (in). /// Result status (IONC_NOERR if successful). public int Write1DNetworkNodes(int ioNetCdfDataSetId, int networkId, IntPtr pointerToArrayOfXNodes, IntPtr pointerToArrayOfYNodes, IntPtr pointerToArrayOfIds, IntPtr pointerToArrayOfLongNames, int numberOfNodes) { return ionc_write_1d_network_nodes_v1_dll(ref ioNetCdfDataSetId, ref networkId, ref pointerToArrayOfXNodes, ref pointerToArrayOfYNodes, ref pointerToArrayOfIds, ref pointerToArrayOfLongNames, ref numberOfNodes); } /// /// Writes the network branches. /// /// The IONetCDF data set id (in). /// The network id (in). /// Pointer to an array containing the source node ids of the network branches (in). /// Pointer to an array containing the target node ids of the network branches (in). /// Pointer to an array containing the ids of the network branches (in). /// Pointer to an array containing the long names of the network branches (in). /// Pointer to an array containing the length of the network branches (in). /// Pointer to an array containing the number of geometry points of the network branches (in). /// The number of network branches (in). /// Array start index. /// Result status (IONC_NOERR if successful). public int Write1DNetworkBranches(int ioNetCdfDataSetId, int networkId, IntPtr pointerToArrayOfSourceNodeIds, IntPtr pointerToArrayOfTargetNodeIds, IntPtr pointerToArrayOfIds, IntPtr pointerToArrayOfLongNames, IntPtr pointerToArrayOfBranchLengths, IntPtr pointerToArrayOfNumberOfBranchGeometryPoints, int numberOfBranches, int startIndex = 0) { return ionc_put_1d_network_branches_v1_dll(ref ioNetCdfDataSetId, ref networkId, ref pointerToArrayOfSourceNodeIds, ref pointerToArrayOfTargetNodeIds, ref pointerToArrayOfIds, ref pointerToArrayOfLongNames, ref pointerToArrayOfBranchLengths, ref pointerToArrayOfNumberOfBranchGeometryPoints, ref numberOfBranches, ref startIndex); } /// /// Writes the geometry points of the network branches. /// /// The IONetCDF data set id (in). /// The network id (in). /// Pointer to an array containing the x-coordinates of the geometry points (in). /// Pointer to an array containing the y-coordinates of the geometry points (in). /// The number of geometry points (in). /// Result status (IONC_NOERR if successful). public int Write1DNetworkBranchesGeometry(int ioNetCdfDataSetId, int networkId, IntPtr pointerToArrayOfXGeometryPointsValues, IntPtr pointerToArrayOfYGeometryPointsValues, int numberOfGeometryPoints) { return ionc_write_1d_network_branches_geometry_dll(ref ioNetCdfDataSetId, ref networkId, ref pointerToArrayOfXGeometryPointsValues, ref pointerToArrayOfYGeometryPointsValues, ref numberOfGeometryPoints); } /// /// Writes a 1D mesh. /// /// /// The geometrical features (e.g. the branches and geometry points) are written by using , /// and . /// /// The IONetCDF data set id (in). /// The network name (in). /// The mesh id in the specified data set (out). /// The mesh name (in). /// The number of mesh points (in). /// Result status (IONC_NOERR if successful). public int Create1DMesh(int ioNetCdfDataSetId, string networkName, ref int meshId, string meshName, int numberOfMeshPoints, int numberOfMeshEdges) { var writeXAndY = 1; return ionc_create_1d_mesh_v1_dll(ref ioNetCdfDataSetId, networkName, ref meshId, meshName, ref numberOfMeshPoints, ref numberOfMeshEdges, ref writeXAndY); } /// /// Writes the coordinates of a 1D mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// Pointer to an array containing the branch id of the points (in). /// Pointer to an array containing the offset along the branch (from the starting point) of the points (in). /// Pointer to an array containing the x-coordinates of the points (in). /// Pointer to an array containing the y-coordinates of the points (in). /// Pointer to an array containing the ids of the points (in). /// Pointer to an array containing the long names of the points (in). /// The number of mesh points (in). /// Array start index. /// Result status (IONC_NOERR if successful). public int Write1DMeshDiscretisationPoints(int ioNetCdfDataSetId, int meshId, IntPtr pointerToArrayOfBranchIndexValues, IntPtr pointerToArrayOfOffsets, IntPtr pointerToArrayOfDiscretisationPointsXValues, IntPtr pointerToArrayOfDiscretisationPointsYValues, IntPtr pointerToArrayOfIds, IntPtr pointerToArrayOfLongNames, int numberOfMeshPoints, int startIndex) { return ionc_put_1d_mesh_discretisation_points_v2_dll(ref ioNetCdfDataSetId, ref meshId, ref pointerToArrayOfBranchIndexValues, ref pointerToArrayOfOffsets, ref pointerToArrayOfIds, ref pointerToArrayOfLongNames, ref numberOfMeshPoints, ref startIndex, ref pointerToArrayOfDiscretisationPointsXValues, ref pointerToArrayOfDiscretisationPointsYValues); } /// /// Gets the number of network nodes. /// /// The IONetCDF data set id (in). /// The network id (in). /// The number of nodes (out). /// Result status (IONC_NOERR if successful). public int Get1DNetworkNodesCount(int ioNetCdfDataSetId, int networkId, ref int numberOfNodes) { return ionc_get_1d_network_nodes_count_dll(ref ioNetCdfDataSetId, ref networkId, ref numberOfNodes); } /// /// Gets the number of branches. /// /// The IONetCDF data set id (in). /// The network id (in). /// The number of branches (out). /// Result status (IONC_NOERR if successful). public int Get1DNetworkBranchesCount(int ioNetCdfDataSetId, int networkId, ref int numberOfBranches) { return ionc_get_1d_network_branches_count_dll(ref ioNetCdfDataSetId, ref networkId, ref numberOfBranches); } /// /// Gets the number of geometry points for all branches. /// /// The IONetCDF data set id (in). /// The network id (in). /// The number of geometry points for all branches (out). /// Result status (IONC_NOERR if successful). public int Get1DNetworkBranchesGeometryCoordinateCount(int ioNetCdfDataSetId, int networkId, ref int numberOfGeometryPoints) { return ionc_get_1d_network_branches_geometry_coordinate_count_dll(ref ioNetCdfDataSetId, ref networkId, ref numberOfGeometryPoints); } /// /// Reads the network nodes. /// /// The IONetCDF data set id (in). /// The network id (in) /// Pointer to an array for storing the x-coordinates of the network nodes (out). /// Pointer to an array for storing the y-coordinates of the network nodes (out). /// Pointer to an array for storing the ids of the network nodes (out). /// Pointer to an array for storing the long names of the network nodes (out). /// The number of network nodes (in). /// Result status (IONC_NOERR if successful). public int Read1DNetworkNodes(int ioNetCdfDataSetId, int networkId, ref IntPtr pointerToArrayOfXNodes, ref IntPtr pointerToArrayOfYNodes, ref IntPtr pointerToArrayOfIds, ref IntPtr pointerToArrayOfLongNames, int numberOfNodes) { return ionc_read_1d_network_nodes_v1_dll(ref ioNetCdfDataSetId, ref networkId, ref pointerToArrayOfXNodes, ref pointerToArrayOfYNodes, ref pointerToArrayOfIds, ref pointerToArrayOfLongNames, ref numberOfNodes); } /// /// Reads the network branches. /// /// The IONetCDF data set id (in). /// The network id (in). /// Pointer to an array for storing the source node ids of the network branches (out). /// Pointer to an array for storing the target node ids of the network branches (out). /// Pointer to an array for storing the lengths of the network branches (out). /// Pointer to an array for storing the ids of the network branches (out). /// Pointer to an array for storing the long names of the network branches (out). /// Pointer to an array for storing the number of geometry points of the network branches (out). /// The number of branches (in). /// Result status (IONC_NOERR if successful). public int Read1DNetworkBranches(int ioNetCdfDataSetId, int networkId, ref IntPtr pointerToArrayOfSourceNodeIds, ref IntPtr pointerToArrayOfTargetNodeIds, ref IntPtr pointerToArrayOfBranchLengths, ref IntPtr pointerToArrayOfIds, ref IntPtr pointerToArrayOfLongNames, ref IntPtr pointerToArrayOfNumberOfBranchGeometryPoints, int numberOfBranches) { var startIndex = 0; return ionc_get_1d_network_branches_v1_dll(ref ioNetCdfDataSetId, ref networkId, ref pointerToArrayOfSourceNodeIds,ref pointerToArrayOfTargetNodeIds, ref pointerToArrayOfBranchLengths, ref pointerToArrayOfIds, ref pointerToArrayOfLongNames, ref pointerToArrayOfNumberOfBranchGeometryPoints, ref numberOfBranches, ref startIndex); } /// /// Reads the branch geometry. /// /// The IONetCDF data set id (in). /// The network id (in). /// Pointer to an array for storing the x-coordinates of the geometry points (out). /// Pointer to an array for storing the y-coordinates of the geometry points (out). /// The number of nodes (in). /// Result status (IONC_NOERR if successful). public int Read1DNetworkBranchesGeometry(int ioNetCdfDataSetId, int networkId, ref IntPtr pointerToArrayOfXGeometryPointsValues, ref IntPtr pointerToArrayOfYGeometryPointsValues, int numberOfNodes) { return ionc_read_1d_network_branches_geometry_dll(ref ioNetCdfDataSetId, ref networkId, ref pointerToArrayOfXGeometryPointsValues, ref pointerToArrayOfYGeometryPointsValues, ref numberOfNodes); } /// /// Gets the number of mesh discretisation points. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The number of mesh points (out). /// Result status (IONC_NOERR if successful). public int Get1DMeshDiscretisationPointsCount(int ioNetCdfDataSetId, int meshId, ref int numberOfMeshPoints) { return ionc_get_1d_mesh_discretisation_points_count_dll(ref ioNetCdfDataSetId, ref meshId, ref numberOfMeshPoints); } /// /// Reads the coordinates of the mesh points. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// Pointer to an array for storing the branch id of the mesh points (out). /// Pointer to an array for storing the offset along the branch (from the starting point) for the mesh points (out). /// Pointer to an array for storing the x-coordinates of the mesh points (out). /// Pointer to an array for storing the y-coordinates of the mesh points (out). /// Pointer to an array for storing the ids of the mesh points (out). /// Pointer to an array for storing the long names of the mesh points (out). /// The number of mesh points (in). /// Array start index (in). /// Result status (IONC_NOERR if successful). public int Read1DMeshDiscretisationPoints(int ioNetCdfDataSetId, int meshId, ref IntPtr pointerToArrayOfBranchIndexValues, ref IntPtr pointerToArrayOfOffsets, ref IntPtr pointerToArrayOfDiscretisationPointsXValues, ref IntPtr pointerToArrayOfDiscretisationPointsYValues, ref IntPtr pointerToArrayOfIds, ref IntPtr pointerToArrayOfLongNames, int numberOfMeshPoints, int startIndex) { return ionc_get_1d_mesh_discretisation_points_v2_dll(ref ioNetCdfDataSetId, ref meshId, ref pointerToArrayOfBranchIndexValues, ref pointerToArrayOfOffsets, ref pointerToArrayOfIds, ref pointerToArrayOfLongNames, ref numberOfMeshPoints, ref startIndex, ref pointerToArrayOfDiscretisationPointsXValues, ref pointerToArrayOfDiscretisationPointsYValues); } /// /// Defines the contacts structure. /// /// The IONetCDF data set id (in). /// The id of the links-mesh (out). /// The name of the links-mesh (in). /// The number of contacts (in). /// The id of the first connecting mesh (in). /// The id of the second connecting mesh (in). /// The location type for the first mesh: 0, 1, 2 for node, edge, face respectively (in). /// The location type for the second mesh (in). /// Result status (IONC_NOERR if successful). public int Create1D2DLinks(int ioNetCdfDataSetId, ref int contactsMeshId, string contactsMeshName, int numberOfContacts, int firstMeshId, int secondMeshId, int firstLocationTypeId, int secondLocationTypeId) { return ionc_def_mesh_contact_dll(ref ioNetCdfDataSetId, ref contactsMeshId, contactsMeshName, ref numberOfContacts, ref firstMeshId, ref secondMeshId, ref firstLocationTypeId, ref secondLocationTypeId); } /// /// Puts the contacts structure. /// /// The IONetCDF data set id (in). /// The id of the links-mesh (in). /// Pointer to an array containing the indexes of the first mesh (in). /// Pointer to an array containing the indexes of the second mesh (in). /// Pointer to an array containing the contact types (in). /// Pointer to an array containing the ids of the contacts (in) /// Pointer to an array containing the long names of the contacts (in). /// The number of contacts (in). /// Result status (IONC_NOERR if successful). public int Write1D2DLinks(int ioNetCdfDataSetId, int contactsMeshId, IntPtr pointerToArrayOfFirstMeshIndexValues, IntPtr pointerToArrayOfSecondMeshIndexValues, IntPtr pointerToArrayOfContactTypes, IntPtr pointerToArrayOfIds, IntPtr pointerToArrayOfLongNames, int numberOfContacts) { var startIndex = 0; return ionc_put_mesh_contact_v1_dll(ref ioNetCdfDataSetId, ref contactsMeshId, ref pointerToArrayOfFirstMeshIndexValues, ref pointerToArrayOfSecondMeshIndexValues, ref pointerToArrayOfContactTypes, ref pointerToArrayOfIds, ref pointerToArrayOfLongNames, ref numberOfContacts, ref startIndex); } /// /// Gets the number of contacts from a specific links-mesh. /// /// The IONetCDF data set id (in). /// The id of the links-mesh (in). /// The number of contacts (out). /// Result status (IONC_NOERR if successful). public int GetNumberOf1D2DLinks(ref int ioNetCdfDataSetId, ref int contactsMeshId, ref int numberOfContacts) { return ionc_get_contacts_count_dll(ref ioNetCdfDataSetId, ref contactsMeshId, ref numberOfContacts); } /// /// Gets the the mesh contact ids from a specific links-mesh. /// /// The IONetCDF data set id (in). /// The id of the links-mesh (in). /// Pointer to an array for storing the indexes of the first mesh (out). /// Pointer to an array for storing the indexes of the second mesh (out). /// Pointer to an array for storing the contact types (out). /// Pointer to an array for storing the ids of the contacts (out) /// Pointer to an array for storing the long names of the contacts (out). /// The number of contacts (in). /// Result status (IONC_NOERR if successful). public int Read1D2DLinks(int ioNetCdfDataSetId, int contactsMeshId, ref IntPtr pointerToArrayOfFirstMeshIndexValues, ref IntPtr pointerToArrayOfSecondMeshIndexValues, ref IntPtr pointerToArrayOfContactTypes, ref IntPtr pointerToArrayOfIds, ref IntPtr pointerToArrayOfLongNames, ref int numberOfContacts) { var startIndex = 0; return ionc_get_mesh_contact_v1_dll(ref ioNetCdfDataSetId, ref contactsMeshId, ref pointerToArrayOfFirstMeshIndexValues, ref pointerToArrayOfSecondMeshIndexValues, ref pointerToArrayOfContactTypes, ref pointerToArrayOfIds, ref pointerToArrayOfLongNames, ref numberOfContacts, ref startIndex); } /// /// Clones the mesh definitions from one NetCDF file to another NetCDF file. /// /// /// Clones all related attributes of the mesh, but it can not clone mesh contacts yet. /// /// The input NetCDF file id containing the mesh to clone (in). /// The output NetCDF file id, can be empty/not empty (in). /// The mesh id to copy (in). /// The id of the cloned mesh in the output file (out). /// Result status (IONC_NOERR if successful). public int CloneMeshDefinition(ref int ioNetCdfDataSetIdIn, ref int ioNetCdfDataSetIdOut, ref int meshIdIn, ref int meshIdOut) { return ionc_clone_mesh_definition_dll(ref ioNetCdfDataSetIdIn, ref ioNetCdfDataSetIdOut, ref meshIdIn, ref meshIdOut); } /// /// Clones the data of a specific mesh from one NetCDF file to another NetCDF file. /// /// The input NetCDF file id containing the mesh to clone (in). /// The output NetCDF file id, can be empty/not empty (in). /// The mesh id to copy (in). /// The id of the cloned mesh in the output file (out). /// Result status (IONC_NOERR if successful). public int CloneMeshData(ref int ioNetCdfDataSetIdIn, ref int ioNetCdfDataSetIdOut, ref int meshIdIn, ref int meshIdOut) { return ionc_clone_mesh_data_dll(ref ioNetCdfDataSetIdIn, ref ioNetCdfDataSetIdOut, ref meshIdIn, ref meshIdOut); } /// /// Gets the number of networks. /// /// The IONetCDF data set id (in). /// The number of networks (out). /// Result status (IONC_NOERR if successful). public int GetNumberOfNetworks(int ioNetCdfDataSetId, ref int numberOfNetworks) { return ionc_get_number_of_networks_dll(ref ioNetCdfDataSetId, ref numberOfNetworks); } /// /// Gets the number of meshes. /// /// The IONetCDF data set id (in). /// Mesh type: 0 = any type, 1 = 1D mesh, 2 = 2D mesh, 3 = 3D mesh (in). /// The number of meshes (out). /// Result status (IONC_NOERR if successful). public int GetNumberOfMeshes(int ioNetCdfDataSetId, int meshType, ref int numberOfMeshes) { return ionc_get_number_of_meshes_dll(ref ioNetCdfDataSetId, ref meshType, ref numberOfMeshes); } /// /// Gets the network id based on a mesh id. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The network id (out). /// Result status (IONC_NOERR if successful). public int GetNetworkIdFromMeshId(int ioNetCdfDataSetId, int meshId, ref int networkId) { return ionc_get_network_id_from_mesh_id_dll(ref ioNetCdfDataSetId, ref meshId, ref networkId); } /// /// Gets the network ids. /// /// The IONetCDF data set id (in). /// Pointer to an array for storing the network ids (out). /// The number of networks (in). /// Result status (IONC_NOERR if successful). public int GetNetworkIds(int ioNetCdfDataSetId, ref IntPtr pointerToNetworkIds, int numberOfNetworks) { return ionc_get_network_ids_dll(ref ioNetCdfDataSetId, ref pointerToNetworkIds, ref numberOfNetworks); } /// /// Gets the id of the links-mesh. /// /// The IONetCDF data set id (in). /// The id of the links-mesh (out). /// Result status (IONC_NOERR if successful). public int Get1D2DLinksMeshId(int ioNetCdfDataSetId, ref int contactId) { return ionc_get_contact_id_dll(ref ioNetCdfDataSetId, ref contactId); } /// /// Gets the mesh ids. /// /// The IONetCDF data set id (in). /// Mesh type: 0 = any type, 1 = 1D mesh, 2 = 2D mesh, 3 = 3D mesh (in). /// Pointer to an array for storing the mesh ids (out). /// The number of meshes (in). /// Result status (IONC_NOERR if successful). public int GetMeshIds(int ioNetCdfDataSetId, IONetCDFConstants.UGridMeshType meshType, ref IntPtr pointerToMeshIds, int numberOfMeshes) { var mType = (int) meshType; return ionc_ug_get_mesh_ids_dll(ref ioNetCdfDataSetId, ref mType, ref pointerToMeshIds, ref numberOfMeshes); } /// /// Writes the branch order array. /// /// The IONetCDF data set id (in). /// The network id (in). /// Pointer to an array containing the branch order (in). /// The number of branches (in). /// Result status (IONC_NOERR if successful). public int Put1DNetworkBranchOrder(int ioNetCdfDataSetId, int networkId, IntPtr pointerToArrayOfBranchOrders, int numberOfBranches) { return ionc_put_1d_network_branchorder_dll(ref ioNetCdfDataSetId, ref networkId, ref pointerToArrayOfBranchOrders, ref numberOfBranches); } /// /// Gets the branch order array. /// /// The IONetCDF data set id (in). /// The network id (in). /// Pointer to an array for storing the branch order (out). /// The number of branches (in). /// Result status (IONC_NOERR if successful). public int Get1DNetworkBranchOrder(int ioNetCdfDataSetId, int networkId, ref IntPtr pointerToArrayOfBranchOrders, int numberOfBranches) { return ionc_get_1d_network_branchorder_dll(ref ioNetCdfDataSetId, ref networkId, ref pointerToArrayOfBranchOrders, ref numberOfBranches); } /// /// Gets the 1D2D grid. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The 1D2D grid (out). /// Array start index (in). /// Whether or not to include arrays (in). /// Result status (IONC_NOERR if successful). public int GetMeshGeom(ref int ioNetCdfDataSetId, ref int meshId, ref meshgeom meshGeom, ref int startIndex, bool includeArrays) { var networkId = -1; return ionc_get_meshgeom_dll(ref ioNetCdfDataSetId, ref meshId, ref networkId, ref meshGeom, ref startIndex, ref includeArrays); } /// /// Gets the dimensions of the 1D2D grid. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The dimensions of the 1D2D grid (out). /// Result status (IONC_NOERR if successful). public int GetMeshGeomDimensions(ref int ioNetCdfDataSetId, ref int meshId, ref meshgeomdim meshGeomDimensions) { var networkId = -1; return ionc_get_meshgeom_dim_dll(ref ioNetCdfDataSetId, ref meshId, ref networkId, ref meshGeomDimensions); } /// /// Creates a 2D mesh. /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (out). /// The network id (in). /// The mesh geometry (in). /// The mesh dimensions (in). /// The mesh name (in). /// The network name (in). /// Array start index (in). /// Result status (IONC_NOERR if successful). public int Create2DMesh(int ioNetCdfDataSetId, ref int meshId, ref int networkId, ref meshgeom meshGeom, ref meshgeomdim meshGeomDimensions, string meshName, string networkName, ref int startIndex) { return ionc_put_meshgeom_dll(ref ioNetCdfDataSetId, ref meshId, ref networkId, ref meshGeom, ref meshGeomDimensions, meshName, networkName, ref startIndex); } /// /// Write the two 1d mesh nodes of an edge in a list from where an edge comes from to which 1d mesh node it connects to /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// The number of edges (in). /// The array of the nodes where edges connect to (in). /// Array start index (in). /// Result status (IONC_NOERR if successful). public int Write1dMeshEdgeNodes(int ioNetCdfDataSetId, int meshId, int numberOfEdges, IntPtr pointerToArrayOfMesh1DEdgeNodesConnection, int startIndex) { return ionc_write_mesh_1d_edge_nodes_dll(ref ioNetCdfDataSetId, ref meshId, ref numberOfEdges, ref pointerToArrayOfMesh1DEdgeNodesConnection, ref startIndex); } /// /// Write the edges of a 1d mesh /// /// The IONetCDF data set id (in). /// The mesh id in the specified data set (in). /// Pointer to an array containing the branch index of where the edges is on (in). /// Pointer to an array containing the offset along the branch (from the starting point) of the points (in). /// The number of edges (in). /// Array start index (in). /// Pointer to an array containing the x-coordinates of the edges (in). /// Pointer to an array containing the y-coordinates of the edges (in). /// Result status (IONC_NOERR if successful). public int Write1dMeshEdges(int ioNetCdfDataSetId, int meshId, ref IntPtr pointerToArrayOfBranchIndexesWhereTheEdgesAreOn, IntPtr pointerToArrayOfBranchOffsetWhereTheEdgesAreOn, int numberOfEdges, int startIndex, IntPtr pointerToArrayOfXCoordinatesOfEdge, IntPtr pointerToArrayOfYCoordinatesOfEdge) { return ionc_put_1d_mesh_edges_dll(ref ioNetCdfDataSetId, ref meshId, ref pointerToArrayOfBranchIndexesWhereTheEdgesAreOn, ref pointerToArrayOfBranchOffsetWhereTheEdgesAreOn, ref numberOfEdges, ref startIndex, ref pointerToArrayOfXCoordinatesOfEdge, ref pointerToArrayOfYCoordinatesOfEdge); } } }