using System; using System.Runtime.InteropServices; using System.Text; namespace Deltares.UGrid.Entities { /// /// Class containing all static imports for IONetCdf library /// internal static class IoNetCfdImports { internal const string GRIDDLL_NAME = "io_netcdf.dll"; #region Generic #region IO /// /// Tries to open a NetCDF file and initialize based on its specified conventions. /// /// File name for netCDF dataset to be opened. /// NetCDF open mode, e.g. NF90_NOWRITE. /// The io_netcdf dataset id (this is not the NetCDF ncid, which is stored in datasets(ioncid)%ncid. /// The detected conventions in the file. /// /// Result status (IONC_NOERR if successful). [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_open", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_open_dll([In] string c_path, [In] ref int mode, [In, Out] ref int ioncid, [In, Out] ref int iconvtype, ref double convversion); /// /// Tries to close an open io_netcdf data set. /// /// The io_netcdf dataset id (this is not the NetCDF ncid, which is stored in datasets(ioncid)%ncid. /// Result status (IONC_NOERR if successful). [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_close", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_close_dll([In] ref int ioncid); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_write_geom_ugrid", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_write_geom_ugrid_dll(string filename); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_write_map_ugrid", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_write_map_ugrid_dll(string filename); /// /// Adds meta data about modelName, version etc. /// /// /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_add_global_attributes", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_add_global_attributes_dll([In] ref int ioncid, ref InteropMetadata metadata); /// /// This function creates a new netCDF file for writing /// /// The path where the file will be created (in) /// The netCDF opening mode (in) /// The netCDF file id (out) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_create", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_create_dll([In] string c_path, [In] ref int mode, [In, Out] ref int ioncid); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_initialize", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_initialize_dll(IO_NetCDF_Message_Callback c_message_callback, IO_NetCDF_Progress_Callback c_progress_callback); #endregion #region Convention checks /// /// Checks whether the specified data set adheres to a specific set of conventions. /// Datasets may adhere to multiple conventions at the same time, so use this method /// to check for individual conventions. /// /// File Id /// The NetCDF conventions type to check for. /// Whether or not the file adheres to the specified conventions. [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_adheresto_conventions", CallingConvention = CallingConvention.Cdecl)] public static extern bool ionc_adheresto_conventions_dll(ref int ioncid, ref int iconvtype); /// /// Inquire the NetCDF conventions used in the dataset. /// /// The IONC data set id. /// The NetCDF conventions type of the dataset. /// /// Result status, ionc_noerr if successful. [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_inq_conventions", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_inq_conventions_dll(ref int ioncid, ref int iconvtype, ref double convversion); #endregion #region Mesh /// /// Clone the definitions specific mesh from one netCDF file to another netCDF. /// 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) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_clone_mesh_definition", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_clone_mesh_definition_dll([In] ref int ncidin, [In] ref int ncidout, [In] ref int meshidin, [In, Out] ref int meshidout); /// /// Clone the data of a specific mesh from one netCDF file to another netCDF /// /// 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) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_clone_mesh_data", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_clone_mesh_data_dll([In] ref int ncidin, [In] ref int ncidout, [In] ref int meshidin, [In] ref int meshidout); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_def_mesh_ids", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_def_mesh_ids_dll([In] ref int ioncid, [In] ref int meshid, [In] ref int iloctype); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_var_chars", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_var_chars_dll([In] ref int ioncid, [In] ref int meshid, [MarshalAs(UnmanagedType.LPStr)][In, Out] StringBuilder varname, [In] ref IntPtr ids, [In] ref IntPtr longNames, [In] ref int nvalues); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_var_chars", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_var_chars_dll([In] ref int ioncid, [In] ref int meshid, [MarshalAs(UnmanagedType.LPStr)][In, Out] StringBuilder varname, [In, Out] ref IntPtr ids, [In, Out] ref IntPtr longNames, [In] ref int nvalues); /// /// Gets the number of mesh from a data set. /// /// The IONC data set id. /// Number of meshes. /// Result status (IONC_NOERR if successful). [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_mesh_count", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_mesh_count_dll([In, Out] ref int ioncid, [In, Out] ref int nmesh); /// /// Gets the number of meshes /// /// /// Mesh type: 0 = any type, 1 = 1D mesh, 2 = 2D mesh, 3 = 3D mesh /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_number_of_meshes", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_number_of_meshes_dll([In] ref int ioncid, [In] ref int meshType, [In, Out] ref int numMeshes); /// /// Gets the mesh ids /// /// /// /// /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_ug_get_mesh_ids", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_ug_get_mesh_ids_dll([In] ref int ioncid, [In] ref int meshType, [In, Out] ref IntPtr pointerToMeshIds, [In] ref int nnumNetworks); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_coordinate_system", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_coordinate_system_dll([In] ref int ioncid, [In, Out] ref int epsgcode); /// /// Gets the name of mesh from a data set. /// /// The IONC data set id. /// Mesh id. /// The mesh name. /// Result status (IONC_NOERR if successful). [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_mesh_name", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_mesh_name_dll([In, Out] ref int ioncid, [In, Out] ref int meshId, [MarshalAs(UnmanagedType.LPStr)][In, Out] StringBuilder meshName); /// /// Gets the number of nodes in a single mesh from a data set. /// /// The IONC data set id. /// The mesh id in the specified data set. /// Number of nodes. /// Result status (IONC_NOERR if successful). [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_node_count", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_node_count_dll(ref int ioncid, ref int meshId, ref int nnode); /// /// Gets the number of edges in a single mesh from a data set. /// /// The IONC data set id. /// The mesh id in the specified data set. /// Number of edges. /// Result status (IONC_NOERR if successful). [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_edge_count", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_edge_count_dll(ref int ioncid, ref int meshId, ref int nedge); /// /// Gets the number of faces in a single mesh from a data set. /// /// The IONC data set id. /// The mesh id in the specified data set. /// Number of faces. /// Result status (IONC_NOERR if successful). [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_face_count", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_face_count_dll(ref int ioncid, ref int meshId, ref int nface); /// /// Gets the maximum number of nodes for any face in a single mesh from a data set. /// /// The IONC data set id. /// The mesh id in the specified data set. /// The maximum number of nodes per face in the mesh.Number of faces. /// Result status (IONC_NOERR if successful). [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_max_face_nodes", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_max_face_nodes_dll(ref int ioncid, ref int meshId, ref int nmaxfacenodes); /// /// Gets the x,y coordinates for all nodes in a single mesh from a data set. /// /// The IONC data set id. /// The mesh id in the specified data set. /// Pointer to array for x-coordinates /// Pointer to array for y-coordinates /// The number of nodes in the mesh. /// Result status (IONC_NOERR if successful). [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_node_coordinates", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_node_coordinates_dll([In] ref int ioncid, [In, Out] ref int meshId, [In, Out] ref IntPtr c_xptr, [In, Out]ref IntPtr c_yptr, [In, Out] ref int nnode); /// /// Gets the edge-node connectvit table for all edges in the specified mesh. /// The output edge_nodes array is supposed to be of exact correct size already. /// /// The IONC data set id. /// The mesh id in the specified data set. /// Pointer to array for the edge-node connectivity table. /// The number of edges in the mesh. /// /// Result status (IONC_NOERR if successful). [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_edge_nodes", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_edge_nodes_dll(ref int ioncid, ref int meshId, ref IntPtr c_edge_nodes_ptr, ref int nedge, ref int startIndex); /// /// Gets the face-node connectvit table for all faces in the specified mesh. /// The output face_nodes array is supposed to be of exact correct size already. /// /// The IONC data set id. /// The mesh id in the specified data set. /// Pointer to array for the face-node connectivity table. /// The number of faces in the mesh. /// The maximum number of nodes per face in the mesh. /// /// /// Result status (IONC_NOERR if successful). [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_face_nodes", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_face_nodes_dll(ref int ioncid, ref int meshId, ref IntPtr c_face_nodes_ptr, ref int nface, ref int nmaxfacenodes, ref int fillvalue, ref int startIndex); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_node_coordinates", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_node_coordinates_dll(ref int ioncid, ref int meshId, ref IntPtr c_xvalues_ptr, ref IntPtr c_yvalues_ptr, ref int nNode); #endregion #region Variables [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_var_count", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_var_count_dll([In] ref int ioncid, [In] ref int mesh, [In] ref int location, [In, Out] ref int nCount); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_inq_varid", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_inq_varid_dll(ref int ioncid, ref int meshId, string varName, ref int varId); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_inq_varid_by_standard_name", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_inq_varid_by_standard_name_dll(ref int ioncid, ref int meshId, ref int location, string standardName, ref int varId); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_inq_varids", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_inq_varids_dll(ref int ioncid, ref int meshId, ref int location, ref IntPtr ptr, ref int nVar); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_var", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_var_dll(ref int ioncid, ref int meshId, ref int location, string varname, ref IntPtr c_zptr, ref int nNode, ref double c_fillvalue); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_var", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_var_dll(ref int ioncid, ref int meshId, ref int iloctype, string c_varname, ref IntPtr c_values_ptr, ref int nVal); #endregion #region Other /// /// Get the id of the 3d computational mesh /// /// The IONC data set id. /// The 3d computational mesh id (out) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_3d_mesh_id", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_3d_mesh_id_dll([In] ref int ioncid, [In, Out] ref int meshId); #endregion #endregion #region 1D calls #region Network //-Get the network id for a specified mesh [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_contact_id", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_contact_id_dll([In] ref int ioncid, [In] ref int contactId); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_network_id_from_mesh_id", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_network_id_from_mesh_id_dll([In] ref int ioncid, [In] ref int meshId, [In, Out] ref int networkid); /// /// Gets the number of networks /// /// /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_number_of_networks", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_number_of_networks_dll([In] ref int ioncid, [In, Out] ref int nnumNetworks); /// /// Get the network ids /// /// /// /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_network_ids", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_network_ids_dll([In] ref int ncidin, [In, Out] ref IntPtr c_networkids, [In] ref int nnumNetworks); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_network_name", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_network_name_dll([In] ref int ncidin, [In] ref int networkId, [MarshalAs(UnmanagedType.LPStr)][In, Out] StringBuilder networkName); /// /// Defines a new variable on a 1D network in an 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). /// Id of the mesh /// 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). /// Double precision fill value (in). /// Result status (UG_NOERR==NF90_NOERR if successful). [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_def_var", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_def_var_dll(ref int ioncid, ref int meshId, ref int networkId, ref int varId, ref int type, ref int locType, string varName, string standardName, string longName, string unit, ref int fillValueInt, ref double fillValue); /// /// Get the id of the geometry network. /// /// The IONC data set id (in) /// The geometry mesh (out) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_network_id", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_network_id_dll([In] ref int ioncid, [In, Out] ref int networkid); /// /// Create a 1d network in an opened netCDF file /// /// The netCDF file 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) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_create_1d_network", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_create_1d_network_dll([In] ref int ioncid, [In, Out] ref int networkid, [In] string networkName, [In] ref int nNodes, [In] ref int nBranches, [In] ref int nGeometry); /// /// Write the coordinates of the network nodes /// /// The netCDF file id (in) /// The network id (in) /// The x coordinates of the network nodes (in) /// The y coordinates of the network nodes (in) /// The network infos (in) /// The number of network nodes (in) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_write_1d_network_nodes", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_write_1d_network_nodes_dll([In] ref int ioncid, [In] ref int networkid, [In] ref IntPtr c_nodesX, [In] ref IntPtr c_nodesY, [In] ref IntPtr ids, [In] ref IntPtr longNames, [In] ref int nNodes); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_write_1d_network_nodes_v1", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_write_1d_network_nodes_v1_dll([In] ref int ioncid, [In] ref int networkid, [In] ref IntPtr c_nodesX, [In] ref IntPtr c_nodesY, [In] ref IntPtr ids, [In] ref IntPtr longNames, [In] ref int nNodes); /// /// Write the coordinates of the network branches /// /// The netCDF file id (in) /// The network id (in) /// The source node id (in) /// The target node id (in) /// The branch info (in) /// The branch lengths (in) /// The number of geometry points in each branch (in) /// The number of branches (in) /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_1d_network_branches", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_1d_network_branches_dll([In] ref int ioncid, [In] ref int networkid, [In] ref IntPtr c_sourcenodeid, [In] ref IntPtr c_targetnodeid, [In] ref IntPtr ids, [In] ref IntPtr longNames, [In] ref IntPtr c_branchlengths, [In] ref IntPtr c_nbranchgeometrypoints, [In] ref int nBranches, [In] ref int startIndex); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_1d_network_branches_v1", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_1d_network_branches_v1_dll([In] ref int ioncid, [In] ref int networkid, [In] ref IntPtr c_sourcenodeid, [In] ref IntPtr c_targetnodeid, [In] ref IntPtr ids, [In] ref IntPtr longNames, [In] ref IntPtr c_branchlengths, [In] ref IntPtr c_nbranchgeometrypoints, [In] ref int nBranches, [In] ref int startIndex); /// /// Writes the branch geometry (the geometry points) /// /// The netCDF file id (in) /// The network id (in) /// The x coordinates of the geometry points (in) /// The y coordinates of the geometry points (in) /// The number of geometry points (in) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_write_1d_network_branches_geometry", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_write_1d_network_branches_geometry_dll([In] ref int ioncid, [In] ref int networkid, [In] ref IntPtr c_geopointsX, [In] ref IntPtr c_geopointsY, [In] ref int nGeometry); /// /// Get the number of network nodes /// /// The netCDF file id (in) /// The network id (in) /// The number of nodes(out) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_network_nodes_count", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_network_nodes_count_dll([In] ref int ioncid, [In] ref int networkid, [In, Out] ref int nNodes); /// /// Get the number of branches /// /// The netCDF file id (in) /// The network id (in) /// The number of branches (out) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_network_branches_count", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_network_branches_count_dll([In] ref int ioncid, [In] ref int networkid, [In, Out] ref int nBranches); /// /// Get the number of geometry points for all branches /// /// The netCDF file id (in) /// The network id (in) /// The number of geometry points for all branches (out) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_network_branches_geometry_coordinate_count", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_network_branches_geometry_coordinate_count_dll([In] ref int ioncid, [In] ref int networkid, [In, Out] ref int ngeometrypoints); /// /// Read the node coordinates and the charinfo /// /// The netCDF file id /// The network id (in) /// The x coordinates of the network nodes (out) /// The y coordinates of the network nodes (out) /// The network infos (out) /// The number of network nodes (in) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_read_1d_network_nodes", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_read_1d_network_nodes_dll([In] ref int ioncid, [In] ref int networkid, [In, Out] ref IntPtr c_nodesX, [In, Out] ref IntPtr c_nodesY, [In] ref IntPtr ids, [In] ref IntPtr longNames, [In] ref int nNodes); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_read_1d_network_nodes_v1", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_read_1d_network_nodes_v1_dll([In] ref int ioncid, [In] ref int networkid, [In, Out] ref IntPtr c_nodesX, [In, Out] ref IntPtr c_nodesY, [In] ref IntPtr ids, [In] ref IntPtr longNames, [In] ref int nNodes); /// /// Read the coordinates of the network branches /// /// The netCDF file id /// The network id (in) /// The source node id (out) /// The target node id (out) /// The branch lengths (out) /// The branch info (out) /// he number of geometry points in each branch (out) /// The number of branches (in) /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_network_branches", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_network_branches_dll([In] ref int ioncid, [In] ref int networkid, [In, Out] ref IntPtr c_sourcenodeid, [In, Out] ref IntPtr c_targetnodeid, [In, Out] ref IntPtr c_branchlengths, [In] ref IntPtr ids, [In] ref IntPtr longNames, [In, Out] ref IntPtr c_nbranchgeometrypoints, [In] ref int nBranches, [In] ref int startIndex); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_network_branches_v1", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_network_branches_v1_dll([In] ref int ioncid, [In] ref int networkid, [In, Out] ref IntPtr c_sourcenodeid, [In, Out] ref IntPtr c_targetnodeid, [In, Out] ref IntPtr c_branchlengths, [In, Out] ref IntPtr ids, [In, Out] ref IntPtr longNames, [In, Out] ref IntPtr c_nbranchgeometrypoints, [In] ref int nBranches, [In] ref int startIndex); /// /// Reads the branch geometry /// /// The netCDF file id /// The network id (in) /// The x coordinates of the geometry points (out) /// The y coordinates of the geometry points (out) /// The number of nodes (in) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_read_1d_network_branches_geometry", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_read_1d_network_branches_geometry_dll([In] ref int ioncid, [In] ref int networkid, [In, Out] ref IntPtr c_geopointsX, [In, Out] ref IntPtr c_geopointsY, [In] ref int nGeometrypoints); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_1d_network_branchorder", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_1d_network_branchorder_dll([In] ref int ioncId, [In] ref int networkId, [In] ref IntPtr pointerToBranchOrder, [In] ref int numberOfBranches); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_1d_network_branchtype", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_1d_network_branchtype_dll([In] ref int ioncId, [In] ref int networkId, [In] ref IntPtr pointerTobranchtype, [In] ref int numberOfBranches); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_network_branchorder", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_network_branchorder_dll([In] ref int ioncId, [In] ref int networkId, [In, Out] ref IntPtr pointerToBranchOrder, [In] ref int numberOfBranches); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_network_branchtype", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_network_branchtype_dll([In] ref int ioncId, [In] ref int networkId, [In, Out] ref IntPtr pointerToBranchOrder, [In] ref int numberOfBranches); #endregion #region Mesh1D /// /// Get the id of the 1d computational mesh /// /// The IONC data set id. /// The 1d computational mesh id (out) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_mesh_id", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_mesh_id_dll([In] ref int ioncid, [In, Out] ref int meshId); /// /// Writes a 1d mesh. The geometrical features (e.g. the branches and geometry points) are described in the network above /// /// The netCDF file id (in) /// The network name /// The mesh id (out) /// The mesh name (in) /// The number of mesh points (in) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_create_1d_mesh", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_create_1d_mesh_dll([In] ref int ioncid, [In] string networkname, [In, Out] ref int meshId, [In] string meshname, [In] ref int nmeshpoints); /// /// Writes a 1d mesh. The geometrical features (e.g. the branches and geometry points) are described in the network above /// /// The netCDF file id (in) /// The network name /// The mesh id (out) /// The mesh name (in) /// The number of mesh points (in) /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_create_1d_mesh_v1", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_create_1d_mesh_v1_dll([In] ref int ioncid, [In] string networkname, [In, Out] ref int meshId, [In] string meshname, [In] ref int nmeshpoints, [In] ref int nmeshedges, [In, Out] ref int writexy); /// /// Writes the mesh coordinates points /// /// The netCDF file id (in) /// dataset mesh 1d id /// The branch id for each mesh point (in) /// The offset along the branch from the starting point (in) /// The node info (in) /// The number of mesh points (in) /// array start index /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_1d_mesh_discretisation_points", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_1d_mesh_discretisation_points_dll([In] ref int ioncid, [In] ref int meshid, [In] ref IntPtr c_branchidx, [In] ref IntPtr c_offset, [In] ref IntPtr ids, [In] ref IntPtr longNames, [In] ref int nmeshpoints, [In] ref int startIndex); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_1d_mesh_edges", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_1d_mesh_edges_dll([In] ref int ioncid, [In] ref int meshid, [In] ref IntPtr c_edgebranchidx, [In] ref IntPtr c_edgeoffset, [In] ref int nmeshedges, [In] ref int startIndex); /// /// Writes the mesh coordinates points /// /// The netCDF file id (in) /// dataset mesh 1d id /// The branch id for each mesh point (in) /// The offset along the branch from the starting point (in) /// The node info (in) /// The number of mesh points (in) /// array start index /// /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_1d_mesh_discretisation_points_v1", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_1d_mesh_discretisation_points_v1_dll([In] ref int ioncid, [In] ref int meshid, [In] ref IntPtr c_branchidx, [In] ref IntPtr c_offset, [In] ref IntPtr ids, [In] ref IntPtr longNames, [In] ref int nmeshpoints, [In] ref int startIndex, [In] ref IntPtr c_coordx, [In] ref IntPtr c_coordy); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_1d_mesh_discretisation_points_v2", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_1d_mesh_discretisation_points_v2_dll([In] ref int ioncid, [In] ref int meshid, [In] ref IntPtr c_branchidx, [In] ref IntPtr c_offset, [In] ref IntPtr ids, [In] ref IntPtr longNames, [In] ref int nmeshpoints, [In] ref int startIndex, [In] ref IntPtr c_coordx, [In] ref IntPtr c_coordy); /// /// Get the number of mesh discretization points /// /// The netCDF file id (in) /// The mesh id (in) /// The number of mesh points (out) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_mesh_discretisation_points_count", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_mesh_discretisation_points_count_dll([In] ref int ioncid, [In] ref int meshId, [In, Out] ref int nmeshpoints); /// /// Read the coordinates of the mesh points /// /// The netCDF file id (in) /// The mesh id (in) /// The branch id for each mesh point (out) /// The offset along the branch from the starting point (out) /// The number of mesh points (in) /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_mesh_discretisation_points", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_mesh_discretisation_points_dll([In] ref int ioncid, [In] ref int networkid, [In, Out] ref IntPtr c_branchidx, [In, Out] ref IntPtr c_offset, [In, Out] ref IntPtr ids, [In, Out] ref IntPtr longNames, [In] ref int nmeshpoints, [In] ref int startIndex); /// /// Read the coordinates of the mesh points /// /// The netCDF file id (in) /// The mesh id (in) /// The branch id for each mesh point (out) /// The offset along the branch from the starting point (out) /// The number of mesh points (in) /// /// /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_mesh_discretisation_points_v1", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_mesh_discretisation_points_v1_dll([In] ref int ioncid, [In] ref int meshId, [In, Out] ref IntPtr c_branchidx, [In, Out] ref IntPtr c_offset, [In, Out] ref IntPtr ids, [In, Out] ref IntPtr longNames, [In] ref int nmeshpoints, [In] ref int startIndex, [In, Out] ref IntPtr c_coordx, [In, Out] ref IntPtr c_coordy); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_mesh_discretisation_points_v2", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_mesh_discretisation_points_v2_dll([In] ref int ioncid, [In] ref int meshId, [In, Out] ref IntPtr c_branchidx, [In, Out] ref IntPtr c_offset, [In, Out] ref IntPtr ids, [In, Out] ref IntPtr longNames, [In] ref int nmeshpoints, [In] ref int startIndex, [In, Out] ref IntPtr c_coordx, [In, Out] ref IntPtr c_coordy); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_write_mesh_1d_edge_nodes", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_write_mesh_1d_edge_nodes_dll([In] ref int ioncid, [In, Out] ref int meshid, [In, Out] ref int numEdge, [In] ref IntPtr c_mesh_1d_edge_nodes, [In] ref int start_index); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_1d_mesh_edges", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_1d_mesh_edges_dll([In] ref int ioncid, [In, Out] ref int meshid, [In] ref IntPtr c_edgebranchidx, [In] ref IntPtr c_edgeoffset, [In, Out] ref int numEdge, [In] ref int start_index, [In] ref IntPtr c_coordx, [In] ref IntPtr c_coordy); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_1d_mesh_edges", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_1d_mesh_edges_dll([In] ref int ioncid, [In, Out] ref int meshid, [In,Out] ref IntPtr c_edgebranchidx, [In,Out] ref IntPtr c_edgeoffset, [In] ref int numEdge, [In] ref int start_index, [In,Out] ref IntPtr c_coordx, [In,Out] ref IntPtr c_coordy); #endregion #endregion #region Mesh2D /// /// Get the id of the 2d computational mesh /// /// The IONC data set id. /// The 2d computational mesh id (out) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_2d_mesh_id", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_2d_mesh_id_dll([In] ref int ioncid, [In, Out] ref int meshId); /// /// Gets the 1d2d grid. /// /// /// /// /// /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_meshgeom", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_meshgeom_dll(ref int ioncid, ref int meshid, ref int networkId, [In, Out] ref Mesh2DGeometry mesh2DGeometry, ref int startIndex, ref bool includeArrays); /// /// Gets the dimension of the 1d2d grid. /// /// /// /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_meshgeom_dim", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_meshgeom_dim_dll([In] ref int ioncid, [In] ref int meshid, [In] ref int networkId, [In, Out] ref Mesh2DGeometryDimensions mesh2DGeometryDimensions); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_meshgeom", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_meshgeom_dll([In] ref int ioncid, [In, Out] ref int meshid, [In, Out] ref int networkid, [In] ref Mesh2DGeometry mesh2DGeometry, [In] ref Mesh2DGeometryDimensions mesh2DGeometryDimensions, [In] string c_meshname, [In] string c_networkName, [In] ref int start_index); #endregion #region Links1D2D /// /// Defines the contacts structure. /// /// The netCDF file id (in) /// The id of the linksmesh (out) /// The name of the link (in) /// The number of contactss (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) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_def_mesh_contact", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_def_mesh_contact_dll([In] ref int ioncid, [In, Out] ref int linkmesh, string linkmeshname, [In] ref int ncontacts, [In] ref int mesh1, [In] ref int mesh2, [In] ref int locationType1Id, [In] ref int locationType2Id); /// /// Puts the contacts structure. /// /// The netCDF file id (in) /// The id of the linkmesh (in) /// The mesh1 indexes (in) /// The mesh2 indexes (in) /// type of link /// The contacts info containing the ids and longnames (in) /// The number of contactss (in) /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_mesh_contact", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_mesh_contact_dll([In] ref int ioncid, [In] ref int contactsmesh, [In] ref IntPtr c_mesh1indexes, [In] ref IntPtr c_mesh2indexes, [In] ref IntPtr c_contacttype, [In, Out] ref IntPtr ids, [In, Out] ref IntPtr longNames, [In] ref int ncontacts, [In] ref int startIndex); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_put_mesh_contact_v1", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_put_mesh_contact_v1_dll([In] ref int ioncid, [In] ref int contactsmesh, [In] ref IntPtr c_mesh1indexes, [In] ref IntPtr c_mesh2indexes, [In] ref IntPtr c_contacttype, [In, Out] ref IntPtr ids, [In, Out] ref IntPtr longNames, [In] ref int ncontacts, [In] ref int startIndex); /// /// Get the number of contacts from a specific linkmesh /// /// The netCDF file id (in) /// The id of the linkmesh (in) /// The number of contactss (out) /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_contacts_count", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_contacts_count_dll([In] ref int ioncid, [In] ref int linkmesh, [In, Out] ref int nlinks); /// /// Get the the mesh contacts ids from a specific linkmesh /// /// The netCDF file id (in) /// The id of the linkmesh (in) /// The mesh1 indexes (out) /// The mesh2 indexes (out) /// link type /// The contacts info containing the ids and longnames (out) /// The number of contactss (in) /// /// [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_mesh_contact", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_mesh_contact_dll([In] ref int ioncid, [In] ref int contactsmesh, [In, Out] ref IntPtr c_mesh1indexes, [In, Out] ref IntPtr c_mesh2indexes, [In, Out] ref IntPtr c_contacttype, [In, Out] ref IntPtr ids, [In, Out] ref IntPtr longNames, [In] ref int ncontacts, [In] ref int startIndex); [DllImport(GRIDDLL_NAME, EntryPoint = "ionc_get_mesh_contact_v1", CallingConvention = CallingConvention.Cdecl)] public static extern int ionc_get_mesh_contact_v1_dll([In] ref int ioncid, [In] ref int contactsmesh, [In, Out] ref IntPtr c_mesh1indexes, [In, Out] ref IntPtr c_mesh2indexes, [In, Out] ref IntPtr c_contacttype, [In, Out] ref IntPtr ids, [In, Out] ref IntPtr longNames, [In] ref int ncontacts, [In] ref int startIndex); #endregion [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void IO_NetCDF_Message_Callback(int level, [MarshalAs(UnmanagedType.LPStr)]string message); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void IO_NetCDF_Progress_Callback([MarshalAs(UnmanagedType.LPStr)]string message, ref double progress); } }