Skip to content

Commit 99fd078

Browse files
committed
commented out un-needed code
1 parent 4c8efc9 commit 99fd078

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

src/feenox.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ struct mesh_t {
13291329
size_t *tag2index_from_tag_min;
13301330
size_t node_tag_min;
13311331
size_t node_tag_max;
1332-
// tag_index_map_t *index2tag;
1332+
// TODO: we can have a hash map to handle very sparse indexing but I'm not sure it is worth
13331333

13341334
enum {
13351335
data_type_element,
@@ -2412,10 +2412,12 @@ extern int feenox_mesh_init_nodal_indexes(mesh_t *, int dofs);
24122412
extern int feenox_mesh_element2cell(mesh_t *);
24132413

24142414
// tag_index_map.c
2415+
/*
24152416
extern int tag_index_map_init(tag_index_map_t *map, size_t min_id, size_t max_id, size_t n_nodes, double threshold);
24162417
extern int tag_index_map_insert(tag_index_map_t *map, size_t gmsh_id, size_t vtk_idx);
24172418
extern size_t tag_index_map_lookup(tag_index_map_t *map, size_t gmsh_id);
24182419
extern int tag_index_map_free(tag_index_map_t *map);
2420+
*/
24192421

24202422
// vtk.c
24212423
extern int feenox_mesh_read_vtk_field_node(mesh_t *mesh, FILE *fp, const char *name, unsigned int size);

src/mesh/calculix.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ int feenox_mesh_read_frd(mesh_t *this) {
193193

194194
char buffer[BUFFER_SIZE];
195195
char tmp[BUFFER_SIZE];
196-
int *tag2index = NULL;
197196

198197
if (this->file->pointer == NULL) {
199198
feenox_call(feenox_instruction_file_open(this->file));
@@ -259,7 +258,8 @@ int feenox_mesh_read_frd(mesh_t *this) {
259258

260259
feenox_check_alloc(this->node = calloc(this->n_nodes, sizeof(node_t)));
261260

262-
int tag_max = this->n_nodes;
261+
size_t tag_min = 0;
262+
size_t tag_max = this->n_nodes;
263263
for (size_t j = 0; j < this->n_nodes; j++) {
264264
int minusone;
265265
if (fscanf(this->file->pointer, "%d", &minusone) != 1) {
@@ -280,7 +280,11 @@ int feenox_mesh_read_frd(mesh_t *this) {
280280
sparse = 1;
281281
}
282282

283-
if ((this->node[j].tag = tag) > tag_max) {
283+
if ((this->node[j].tag = tag) < tag_min) {
284+
tag_min = this->node[j].tag;
285+
}
286+
287+
if (tag > tag_max) {
284288
tag_max = this->node[j].tag;
285289
}
286290

@@ -316,13 +320,9 @@ int feenox_mesh_read_frd(mesh_t *this) {
316320

317321
// finished reading the nodes, handle sparse node tags
318322
if (sparse) {
319-
// TODO: use the array/map from vtk
320-
feenox_check_alloc(tag2index = malloc((tag_max+1) * sizeof(int)));
321-
for (size_t k = 0; k <= tag_max; k++) {
322-
tag2index[k] = -1;
323-
}
323+
feenox_call(feenox_mesh_tag2index_alloc(this, tag_min, tag_max));
324324
for (size_t j = 0; j < this->n_nodes; j++) {
325-
tag2index[this->node[j].tag] = j;
325+
this->tag2index[this->node[j].tag] = j;
326326
}
327327
}
328328

@@ -465,7 +465,7 @@ int feenox_mesh_read_frd(mesh_t *this) {
465465
j_gmsh = ccx2gmsh_hex20[j];
466466
}
467467

468-
int node_index = (sparse==0) ? node-1 : tag2index[node];
468+
int node_index = (sparse==0) ? node-1 : this->tag2index_from_tag_min[node];
469469
if (node_index < 0) {
470470
feenox_push_error_message("node %d in element %d does not exist", node, tag);
471471
return FEENOX_ERROR;
@@ -663,7 +663,7 @@ int feenox_mesh_read_frd(mesh_t *this) {
663663
return FEENOX_ERROR;
664664
}
665665
if (function[g] != NULL) {
666-
int node_index = (sparse==0) ? node-1 : tag2index[node];
666+
int node_index = (sparse==0) ? node-1 : this->tag2index_from_tag_min[node];
667667
if (node_index < 0) {
668668
feenox_push_error_message("node %d does not exist", node);
669669
return FEENOX_ERROR;
@@ -691,11 +691,6 @@ int feenox_mesh_read_frd(mesh_t *this) {
691691
fclose(this->file->pointer);
692692
this->file->pointer = NULL;
693693

694-
if (tag2index != NULL) {
695-
feenox_free(tag2index);
696-
}
697-
698-
699694
// verificamos que la malla tenga la dimension esperada
700695
if (this->dim_topo == 0) {
701696
this->dim = bulk_dimensions;

src/mesh/tag_index_map.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Portions of this file were developed with the assistance of GitHub Copilot.
2323
*------------------- ------------ ---- -------- -- - - -
2424
*/
25-
25+
/*
2626
#include "feenox.h"
2727
2828
int tag_index_map_init(tag_index_map_t *map, size_t min_id, size_t max_id, size_t n_nodes, double threshold) {
@@ -93,3 +93,4 @@ int tag_index_map_free(tag_index_map_t *map) {
9393
}
9494
return FEENOX_OK;
9595
}
96+
*/

0 commit comments

Comments
 (0)