use 'idx' in element structure as global index for global elements and level idx for local elements. We don't need to save the level index for globale elements and it makes no sense to store the local index of a local element.

This commit is contained in:
2010-07-29 11:33:29 +00:00
parent b0bacdc6a7
commit 0137e7ac2a
7 changed files with 90 additions and 202 deletions
-40
View File
@@ -10,24 +10,6 @@ get_loc_elem (
return (h5_generic_elem_t*)&f->t->loc_elems.tets[elem_idx];
}
static h5_id_t
get_loc_elem_idx (
h5_file_t* const f,
const h5_id_t elem_idx
) {
return f->t->loc_elems.tets[elem_idx].idx;
}
static h5_id_t
set_loc_elem_idx (
h5_file_t* const f,
const h5_id_t elem_idx,
const h5_id_t idx
) {
f->t->loc_elems.tets[elem_idx].idx = idx;
return idx;
}
static h5_id_t
get_loc_elem_parent_idx (
h5_file_t* const f,
@@ -202,24 +184,6 @@ set_glb_elem_child_idx (
return child_idx;
}
static h5_id_t
get_glb_elem_level_idx (
h5_file_t* const f,
const h5_id_t elem_idx
) {
return f->t->loc_elems.tets[elem_idx].idx;
}
static h5_id_t
set_glb_elem_level_idx (
h5_file_t* const f,
const h5_id_t elem_idx,
const h5_id_t level_idx
) {
f->t->loc_elems.tets[elem_idx].idx = level_idx;
return level_idx;
}
static h5_id_t*
get_glb_elem_vertex_indices (
h5_file_t* const f,
@@ -278,8 +242,6 @@ set_glb_elem_neighbor_idx (
struct h5t_access_methods h5tpriv_access_tetm_methods = {
get_loc_elem,
get_loc_elem_idx,
set_loc_elem_idx,
get_loc_elem_parent_idx,
set_loc_elem_parent_idx,
get_loc_elem_child_idx,
@@ -299,8 +261,6 @@ struct h5t_access_methods h5tpriv_access_tetm_methods = {
set_glb_elem_parent_idx,
get_glb_elem_child_idx,
set_glb_elem_child_idx,
get_glb_elem_level_idx,
set_glb_elem_level_idx,
get_glb_elem_vertex_indices,
get_glb_elem_vertex_idx,
set_glb_elem_vertex_idx,
-40
View File
@@ -10,24 +10,6 @@ get_loc_elem (
return (h5_generic_elem_t*)&f->t->loc_elems.tris[elem_idx];
}
static h5_id_t
get_loc_elem_idx (
h5_file_t* const f,
const h5_id_t elem_idx
) {
return f->t->loc_elems.tris[elem_idx].idx;
}
static h5_id_t
set_loc_elem_idx (
h5_file_t* const f,
const h5_id_t elem_idx,
const h5_id_t idx
) {
f->t->loc_elems.tris[elem_idx].idx = idx;
return idx;
}
static h5_id_t
get_loc_elem_parent_idx (
h5_file_t* const f,
@@ -202,24 +184,6 @@ set_glb_elem_child_idx (
return child_idx;
}
static h5_id_t
get_glb_elem_level_idx (
h5_file_t* const f,
const h5_id_t elem_idx
) {
return f->t->loc_elems.tris[elem_idx].idx;
}
static h5_id_t
set_glb_elem_level_idx (
h5_file_t* const f,
const h5_id_t elem_idx,
const h5_id_t level_idx
) {
f->t->loc_elems.tris[elem_idx].idx = level_idx;
return level_idx;
}
static h5_id_t*
get_glb_elem_vertex_indices (
h5_file_t* const f,
@@ -278,8 +242,6 @@ set_glb_elem_neighbor_idx (
struct h5t_access_methods h5tpriv_access_trim_methods = {
get_loc_elem,
get_loc_elem_idx,
set_loc_elem_idx,
get_loc_elem_parent_idx,
set_loc_elem_parent_idx,
get_loc_elem_child_idx,
@@ -299,8 +261,6 @@ struct h5t_access_methods h5tpriv_access_trim_methods = {
set_glb_elem_parent_idx,
get_glb_elem_child_idx,
set_glb_elem_child_idx,
get_glb_elem_level_idx,
set_glb_elem_level_idx,
get_glb_elem_vertex_indices,
get_glb_elem_vertex_idx,
set_glb_elem_vertex_idx,
+37 -18
View File
@@ -252,27 +252,27 @@ h5tpriv_sort_local_vertex_indices (
h5_id_t
h5t_map_global_vertex_idx2local (
h5_file_t* const f,
const h5_id_t global_idx
const h5_id_t glb_idx
) {
h5t_fdata_t* t = f->t;
h5_id_t local_idx = h5priv_search_idmap (&t->map_vertex_g2l, global_idx);
if (local_idx < 0)
return h5tpriv_error_global_id_nexist (f, "vertex", global_idx);
return local_idx;
if (glb_idx < 0) return -1;
h5_id_t loc_idx = h5priv_search_idmap (&f->t->map_vertex_g2l, glb_idx);
if (loc_idx < 0)
return h5tpriv_error_global_id_nexist (f, "vertex", glb_idx);
return loc_idx;
}
h5_err_t
h5t_map_global_vertex_indices2local (
h5_file_t* const f,
const h5_id_t* const global_indices,
const h5_id_t* const glb_indices,
const h5_id_t size,
h5_id_t* const local_indices
h5_id_t* const loc_indices
) {
h5_id_t i;
int i;
for (i = 0; i < size; i++) {
TRY( (local_indices[i] = h5t_map_global_vertex_idx2local (
f, global_indices[i])) );
TRY( (loc_indices[i] =
h5t_map_global_vertex_idx2local (f, glb_indices[i])) );
}
return H5_SUCCESS;
}
@@ -288,13 +288,32 @@ h5t_map_global_vertex_indices2local (
h5_id_t
h5t_map_global_elem_idx2local (
h5_file_t* const f,
const h5_id_t global_idx
const h5_id_t glb_idx
) {
h5t_fdata_t* t = f->t;
h5_id_t local_idx = h5priv_search_idmap (&t->map_elem_g2l, global_idx);
if (local_idx < 0)
return h5tpriv_error_global_id_nexist (f, "elem", global_idx);
return local_idx;
if (glb_idx < 0) return -1;
h5_id_t loc_idx = h5priv_search_idmap (&f->t->map_elem_g2l, glb_idx);
if (loc_idx < 0)
return h5tpriv_error_global_id_nexist (f, "elem", glb_idx);
return loc_idx;
}
h5_err_t
h5t_map_global_elem_indices2local (
h5_file_t* const f,
const h5_id_t* glb_indices,
const h5_id_t size,
h5_id_t* loc_indices
) {
const h5_id_t* end = glb_indices+size;
while (glb_indices < end) {
TRY( (*loc_indices =
h5t_map_global_elem_idx2local (f, *glb_indices)) );
loc_indices++;
glb_indices++;
}
return H5_SUCCESS;
}
h5_err_t
+26 -47
View File
@@ -2,11 +2,7 @@
#include "h5_core_private.h"
/*
setup structure "elems_ldta" with local indices for each element:
- translate the global vertex id's of each element to their
local id's
- translate the global parent id of each element to the
corresponding local id.
initialize local element structure
*/
static h5_err_t
init_loc_elems_struct (
@@ -15,60 +11,43 @@ init_loc_elems_struct (
h5t_fdata_t* const t = f->t;
h5_id_t idx = 0;
const h5_id_t num_elems = t->num_elems[t->num_levels-1];
h5_id_t level_id = 0;
h5_id_t level_idx = 0;
int num_vertices = t->ref_elem->num_faces[0];
h5_triangle_t* loc_elems = t->loc_elems.tris;
h5_triangle_t* glb_elems = t->glb_elems.tris;
int num_edges = t->ref_elem->num_faces[1];
h5_tet_t* loc_elem = t->loc_elems.tets;
h5_tet_t* glb_elem = t->glb_elems.tets;
for (idx = 0; idx < num_elems; idx++) {
// local idx
for (idx = 0; idx < num_elems; idx++, loc_elem++, glb_elem++) {
// local parent index
TRY( loc_elem->parent_idx =
h5t_map_global_elem_idx2local (f, glb_elem->parent_idx) );
// local child index
TRY( loc_elem->child_idx =
h5t_map_global_elem_idx2local (f, glb_elem->child_idx) );
// level idx
if (idx >= t->num_elems[level_idx]) {
level_idx++;
}
loc_elem->idx = level_idx;
// vertex indices
// neighbor indices
}
return H5_SUCCESS;
}
#if 0
static h5_err_t
init_struct_elems_ldta (
h5_file_t* const f
) {
h5t_fdata_t* t = f->t;
h5_id_t idx = 0;
h5_id_t num_elems = t->num_elems[t->num_levels-1];
h5_id_t level_id = 0;
for (local_eid=0;
local_eid < num_elems;
local_eid++, elp+=h5tpriv_sizeof_elem[t->mesh_type], el_ldta++) {
el = (h5_elem_t*)elp;
TRY( h5t_map_global_vertex_indices2local (
f,
el->global_vertex_indices,
glb_elem->vertex_indices,
num_vertices,
el_ldta->local_vertex_indices) );
if (el->global_parent_idx >= 0)
TRY( el_ldta->local_parent_idx =
h5t_map_global_elem_idx2local (
f, el->global_parent_idx) );
if (el->global_child_idx >= 0)
TRY( el_ldta->local_child_idx =
h5t_map_global_elem_idx2local (
f, el->global_child_idx) );
if (local_eid >= t->num_elems[level_id]) {
level_id++;
}
el_ldta->level_id = level_id;
loc_elem->vertex_indices) );
// neighbor indices
TRY( h5t_map_global_elem_indices2local (
f,
glb_elem->neighbor_indices,
num_edges,
loc_elem->neighbor_indices) );
}
return H5_SUCCESS;
}
#endif
struct h5t_read_methods h5tpriv_read_tetm_methods = {
init_loc_elems_struct
+26 -47
View File
@@ -2,11 +2,7 @@
#include "h5_core_private.h"
/*
setup structure "elems_ldta" with local indices for each element:
- translate the global vertex id's of each element to their
local id's
- translate the global parent id of each element to the
corresponding local id.
initialize local element structure
*/
static h5_err_t
init_loc_elems_struct (
@@ -15,60 +11,43 @@ init_loc_elems_struct (
h5t_fdata_t* const t = f->t;
h5_id_t idx = 0;
const h5_id_t num_elems = t->num_elems[t->num_levels-1];
h5_id_t level_id = 0;
h5_id_t level_idx = 0;
int num_vertices = t->ref_elem->num_faces[0];
h5_triangle_t* loc_elems = t->loc_elems.tris;
h5_triangle_t* glb_elems = t->glb_elems.tris;
int num_edges = t->ref_elem->num_faces[1];
h5_triangle_t* loc_elem = t->loc_elems.tris;
h5_triangle_t* glb_elem = t->glb_elems.tris;
for (idx = 0; idx < num_elems; idx++) {
// local idx
for (idx = 0; idx < num_elems; idx++, loc_elem++, glb_elem++) {
// local parent index
TRY( loc_elem->parent_idx =
h5t_map_global_elem_idx2local (f, glb_elem->parent_idx) );
// local child index
TRY( loc_elem->child_idx =
h5t_map_global_elem_idx2local (f, glb_elem->child_idx) );
// level idx
if (idx >= t->num_elems[level_idx]) {
level_idx++;
}
loc_elem->idx = level_idx;
// vertex indices
// neighbor indices
}
return H5_SUCCESS;
}
#if 0
static h5_err_t
init_struct_elems_ldta (
h5_file_t* const f
) {
h5t_fdata_t* t = f->t;
h5_id_t idx = 0;
h5_id_t num_elems = t->num_elems[t->num_levels-1];
h5_id_t level_id = 0;
for (local_eid=0;
local_eid < num_elems;
local_eid++, elp+=h5tpriv_sizeof_elem[t->mesh_type], el_ldta++) {
el = (h5_elem_t*)elp;
TRY( h5t_map_global_vertex_indices2local (
f,
el->global_vertex_indices,
glb_elem->vertex_indices,
num_vertices,
el_ldta->local_vertex_indices) );
if (el->global_parent_idx >= 0)
TRY( el_ldta->local_parent_idx =
h5t_map_global_elem_idx2local (
f, el->global_parent_idx) );
if (el->global_child_idx >= 0)
TRY( el_ldta->local_child_idx =
h5t_map_global_elem_idx2local (
f, el->global_child_idx) );
if (local_eid >= t->num_elems[level_id]) {
level_id++;
}
el_ldta->level_id = level_id;
loc_elem->vertex_indices) );
// neighbor indices
TRY( h5t_map_global_elem_indices2local (
f,
glb_elem->neighbor_indices,
num_edges,
loc_elem->neighbor_indices) );
}
return H5_SUCCESS;
}
#endif
struct h5t_read_methods h5tpriv_read_trim_methods = {
init_loc_elems_struct
-1
View File
@@ -257,7 +257,6 @@ h5t_store_elem (
/* store elem data (but neighbors) */
h5_id_t elem_idx = ++t->last_stored_eid;
h5tpriv_set_loc_elem_idx (f, elem_idx, elem_idx);
h5tpriv_set_loc_elem_parent_idx (f, elem_idx, parent_idx);
h5tpriv_set_loc_elem_child_idx (f, elem_idx, -1);
h5tpriv_set_loc_elem_level_idx (f, elem_idx, t->cur_level);
+1 -9
View File
@@ -75,10 +75,6 @@ struct h5t_retrieve_methods {
struct h5t_access_methods {
h5_generic_elem_t* (*get_loc_elem)(
h5_file_t* const, const h5_id_t);
h5_id_t (*get_loc_elem_idx)(
h5_file_t* const, const h5_id_t);
h5_id_t (*set_loc_elem_idx)(
h5_file_t* const, const h5_id_t, const h5_id_t);
h5_id_t (*get_loc_elem_parent_idx)(
h5_file_t* const, const h5_id_t);
h5_id_t (*set_loc_elem_parent_idx)(
@@ -118,10 +114,6 @@ struct h5t_access_methods {
h5_file_t* const, const h5_id_t);
h5_id_t (*set_glb_elem_child_idx)(
h5_file_t* const, const h5_id_t, const h5_id_t);
h5_id_t (*get_glb_elem_level_idx)(
h5_file_t* const, const h5_id_t);
h5_id_t (*set_glb_elem_level_idx)(
h5_file_t* const, const h5_id_t, const h5_id_t);
h5_id_t* (*get_glb_elem_vertex_indices)(
h5_file_t* const, const h5_id_t);
h5_id_t (*get_glb_elem_vertex_idx)(
@@ -208,7 +200,7 @@ typedef struct h5t_fdata {
h5_vertex_t *vertices;
h5_vertex_data_t *vertices_data;
h5_size_t *num_vertices;
h5_idmap_t map_vertex_g2l; /* map global id to local id */
h5_idmap_t map_vertex_g2l; /* map global to local idx */
h5_idlist_t sorted_lvertices;
h5_id_t last_stored_vid;
h5_dsinfo_t dsinfo_vertices;