Skip to content

Commit 4c8efc9

Browse files
committed
use the existing tag2index array
1 parent 7ca003e commit 4c8efc9

File tree

13 files changed

+132
-13
lines changed

13 files changed

+132
-13
lines changed

Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ TESTS_mpi = \
6363

6464
TESTS_laplace = \
6565
tests/airfoil.sh \
66-
tests/laplace2d.sh
66+
tests/laplace2d.sh \
67+
tests/hex8-sparse.sh
6768

6869
TESTS_mechanical_iso = \
6970
tests/bc-groups.sh \

autoclean.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fi
99
rm -f *~ .*~ src/*~
1010
cat .gitignore | grep -v nbproject | grep -v gsl | sed '/^#.*/ d' | sed '/^\s*$/ d' | sed 's/^/rm -rf /' | bash
1111
cd tests
12-
cat .gitignore | grep -v nafems | grep -v Stanford_Bunny.stl | sed '/^#.*/ d' | sed '/^\s*$/ d' | sed 's/^/rm -rf /' | bash
12+
cat .gitignore | grep -v Stanford_Bunny.stl | sed '/^#.*/ d' | sed '/^\s*$/ d' | sed 's/^/rm -rf /' | bash
1313
cd ..
1414
cd utils/fee2ccx
1515
cat .gitignore | sed '/^#.*/ d' | sed '/^\s*$/ d' | sed 's/^/rm -rf /' | bash

src/feenox.h

Lines changed: 1 addition & 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+
// tag_index_map_t *index2tag;
13331333

13341334
enum {
13351335
data_type_element,

src/mesh/calculix.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ int feenox_mesh_read_frd(mesh_t *this) {
316316

317317
// finished reading the nodes, handle sparse node tags
318318
if (sparse) {
319+
// TODO: use the array/map from vtk
319320
feenox_check_alloc(tag2index = malloc((tag_max+1) * sizeof(int)));
320321
for (size_t k = 0; k <= tag_max; k++) {
321322
tag2index[k] = -1;

src/mesh/gmsh.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,11 @@ int feenox_mesh_read_gmsh(mesh_t *this) {
470470
// (I asked for this in v4.1, see links above)
471471
if (tag_max < this->n_nodes) {
472472
feenox_push_error_message("maximum node tag %d is less that number of nodes %d", tag_max, this->n_nodes);
473+
return FEENOX_ERROR;
474+
}
475+
if (tag_min <= 0) {
476+
feenox_push_error_message("minumum node tag %d has to be positive", tag_min);
477+
return FEENOX_ERROR;
473478
}
474479
feenox_call(feenox_mesh_tag2index_alloc(this, tag_min, tag_max));
475480
}

src/mesh/mesh.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,13 @@ int feenox_mesh_free(mesh_t *mesh) {
672672
// feenox_free(physical_group);
673673
}
674674
*/
675-
675+
676+
/*
676677
if (mesh->index2tag != NULL) {
677678
feenox_call(tag_index_map_free(mesh->index2tag));
678679
feenox_free(mesh->index2tag);
679-
}
680+
}
681+
*/
680682
mesh->initialized = 0;
681683

682684
return FEENOX_OK;
@@ -705,7 +707,9 @@ int feenox_mesh_create_nodes_argument(mesh_t *this) {
705707
return FEENOX_OK;
706708
}
707709

710+
/*
708711
int feenox_mesh_create_index2tag(mesh_t *this) {
712+
709713
if (this->index2tag != NULL) {
710714
feenox_call(tag_index_map_free(this->index2tag));
711715
feenox_free(this->index2tag);
@@ -723,3 +727,4 @@ int feenox_mesh_create_index2tag(mesh_t *this) {
723727
724728
return FEENOX_OK;
725729
}
730+
*/

src/mesh/tag_index_map.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
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) {
29+
printf("mamoncho\n");
2930
map->min_id = min_id;
3031
map->max_id = max_id;
3132
size_t range = max_id - min_id + 1;

src/mesh/vtk.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,14 @@ int feenox_mesh_write_vtk_cells(mesh_t *mesh, FILE *file, int with_size) {
8383
switch(element->type->id) {
8484
case ELEMENT_TYPE_HEXAHEDRON27:
8585
for (int j = 0; j < 27 ; ++j) {
86-
fprintf(file, " %ld", tag_index_map_lookup(mesh->index2tag, element->node[hexa27fromgmsh[j]]->tag));
86+
// fprintf(file, " %ld", tag_index_map_lookup(mesh->index2tag, element->node[hexa27fromgmsh[j]]->tag));
87+
fprintf(file, " %ld", mesh->tag2index_from_tag_min[element->node[hexa27fromgmsh[j]]->tag]);
8788
}
8889
fprintf(file, "\n");
8990
break;
9091
case ELEMENT_TYPE_HEXAHEDRON20:
9192
for (int j = 0; j < 20 ; ++j) {
92-
fprintf(file, " %ld", tag_index_map_lookup(mesh->index2tag, element->node[hexa20fromgmsh[j]]->tag));
93+
fprintf(file, " %ld", mesh->tag2index_from_tag_min[element->node[hexa20fromgmsh[j]]->tag]);
9394
}
9495
fprintf(file, "\n");
9596
break;
@@ -99,12 +100,12 @@ int feenox_mesh_write_vtk_cells(mesh_t *mesh, FILE *file, int with_size) {
99100
// tet10 has nodes 8 & 9 swapped
100101
if (is_tet10 && (j == 8 || j == 9)) {
101102
if (j == 8) {
102-
fprintf(file, " %ld", tag_index_map_lookup(mesh->index2tag, element->node[9]->tag));
103+
fprintf(file, " %ld", mesh->tag2index_from_tag_min[element->node[9]->tag]);
103104
} else if (j == 9) {
104-
fprintf(file, " %ld", tag_index_map_lookup(mesh->index2tag, element->node[8]->tag));
105+
fprintf(file, " %ld", mesh->tag2index_from_tag_min[element->node[8]->tag]);
105106
}
106107
} else {
107-
fprintf(file, " %ld", tag_index_map_lookup(mesh->index2tag, element->node[j]->tag));
108+
fprintf(file, " %ld", mesh->tag2index_from_tag_min[element->node[j]->tag]);
108109
}
109110
}
110111
fprintf(file, "\n");
@@ -135,10 +136,11 @@ int feenox_mesh_write_mesh_vtk(mesh_t *this, FILE *file, int dummy) {
135136
fprintf(file, "DATASET UNSTRUCTURED_GRID\n");
136137
fprintf(file, "POINTS %ld double\n", this->n_nodes);
137138

139+
/*
138140
if (this->sparse && this->tag2index == NULL) {
139141
feenox_call(feenox_mesh_create_index2tag(this));
140142
}
141-
143+
*/
142144
for (size_t j = 0; j < this->n_nodes; j++) {
143145
fprintf(file, "%g %g %g\n", this->node[j].x[0], this->node[j].x[1], this->node[j].x[2]);
144146
}

src/mesh/vtu.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ int feenox_mesh_write_footer_vtu(mesh_write_t *this) {
5151
}
5252

5353
int feenox_mesh_write_mesh_vtu(mesh_t *mesh, FILE *file, int dummy) {
54-
54+
55+
/*
5556
if (mesh->sparse && mesh->tag2index == NULL) {
5657
feenox_call(feenox_mesh_create_index2tag(mesh));
5758
}
58-
59+
*/
5960
// Points
6061
fprintf(file, " <Points>\n");
6162
fprintf(file, " <DataArray Name=\"Points\" type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\">\n");

tests/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,4 @@ hex8-ldef.dat
8888
hex8-ldef.vt*
8989
spooles.out
9090
beam*.vt*
91+
hex8-sparse.vt*

0 commit comments

Comments
 (0)