Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh1d node (x,y)-coordinates are not computed when the location of a node is specified by network geometry id and offset on that geometry #1

Open
mooiman opened this issue Dec 20, 2021 · 1 comment

Comments

@mooiman
Copy link

mooiman commented Dec 20, 2021

No description provided.

@mooiman mooiman changed the title Mesh1d node (x,y-coordinates are not computed when the location of a node is specified by netweork geometry id and offset on that geometry Mesh1d node (x,y)-coordinates are not computed when the location of a node is specified by netweork geometry id and offset on that geometry Dec 20, 2021
@mooiman mooiman changed the title Mesh1d node (x,y)-coordinates are not computed when the location of a node is specified by netweork geometry id and offset on that geometry Mesh1d node (x,y)-coordinates are not computed when the location of a node is specified by network geometry id and offset on that geometry Dec 20, 2021
@mooiman
Copy link
Author

mooiman commented Dec 20, 2021

Example file in attached ugrid_1d2d_map.zip file
ugrid_1d2d_map.zip

Code used:

long UGRIDAPI_WRAPPER::read_mesh_1d()
{
    int error_code = -1;
    long status = -1;
#ifdef NATIVE_C
    std::cerr << "UGRIDAPI_WRAPPER::read_mesh_1d()" << std::endl;
#endif   
    int topology_type;
    error_code = ugridapi::ug_topology_get_mesh1d_enum(topology_type);
    int nr_mesh1d;
    error_code = ugridapi::ug_topology_get_count(m_ncid, topology_type, nr_mesh1d);

    if (nr_mesh1d > 0)  // there is a 1D network in the file
    {
        // Get the dimensions
        error_code = ug_mesh1d_inq(m_ncid, 0, m_mesh1d);

        int long_name_length;
        error_code = ugridapi::ug_name_get_long_length(long_name_length);
        mesh1d_name.reserve(long_name_length);
        m_mesh1d.name = &mesh1d_name[0];
        
        error_code = ugridapi::ug_name_get_long_length(long_name_length);
        mesh1d_network_name.reserve(long_name_length);
        m_mesh1d.network_name = &mesh1d_network_name[0];

        mesh1d_node_x.resize(m_mesh1d.num_nodes);
        m_mesh1d.node_x = &mesh1d_node_x[0];
        mesh1d_node_y.resize(m_mesh1d.num_nodes);
        m_mesh1d.node_y = &mesh1d_node_y[0];

        mesh1d_edge_nodes_vector.resize(m_mesh1d.num_edges * 2);
        m_mesh1d.edge_node = &mesh1d_edge_nodes_vector[0];

        mesh1d_edge_edge_id_vector.resize(m_mesh1d.num_edges);
        m_mesh1d.edge_edge_id = &mesh1d_edge_edge_id_vector[0];

        mesh1d_edge_edge_offset_vector.resize(m_mesh1d.num_edges);
        m_mesh1d.edge_edge_offset = &mesh1d_edge_edge_offset_vector[0];

        error_code = ug_mesh1d_get(m_ncid, 0, m_mesh1d);
    }
    return status;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant