Skip to content

Commit 3c1de3f

Browse files
committed
handle evaluation of properties outside the mesh
1 parent eb420a7 commit 3c1de3f

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/io/print.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ int feenox_instruction_print(void *arg) {
3737
char default_print_format[] = DEFAULT_PRINT_FORMAT;
3838
int have_to_print = 1;
3939
int have_to_header = 0;
40-
int i, j;
4140
int flag = 1; // flag to know if we already printed something or not (for matrices)
4241

4342
if ((int)feenox_special_var_value(in_static) != 0) {
@@ -116,7 +115,7 @@ int feenox_instruction_print(void *arg) {
116115
if (!print_token->vector->initialized) {
117116
feenox_call(feenox_vector_init(print_token->vector, FEENOX_VECTOR_INITIAL));
118117
}
119-
for (i = 0; i < print_token->vector->size; i++) {
118+
for (int i = 0; i < print_token->vector->size; i++) {
120119
fprintf(print->file->pointer, current_format, gsl_vector_get(feenox_value_ptr(print_token->vector), i));
121120
if (i != print_token->vector->size-1) {
122121
fprintf(print->file->pointer, "%s", print->separator);
@@ -132,8 +131,8 @@ int feenox_instruction_print(void *arg) {
132131
if (!print_token->matrix->initialized) {
133132
feenox_call(feenox_matrix_init(print_token->matrix));
134133
}
135-
for (i = 0; i < print_token->matrix->rows; i++) {
136-
for (j = 0; j < print_token->matrix->cols; j++) {
134+
for (int i = 0; i < print_token->matrix->rows; i++) {
135+
for (int j = 0; j < print_token->matrix->cols; j++) {
137136
fprintf(print->file->pointer, current_format, gsl_matrix_get(feenox_value_ptr(print_token->matrix), i, j));
138137
if (j != print_token->matrix->cols-1) {
139138
fprintf(print->file->pointer, "%s", print->separator);

src/mesh/interpolate.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,15 @@ double feenox_function_property_eval(struct function_t *function, const double *
315315
return 1.0;
316316
}
317317

318-
element_t *element = feenox_mesh_find_element(function->mesh, NULL, x);
318+
node_t *node = feenox_mesh_find_nearest_node(function->mesh, x);
319+
element_t *element = feenox_mesh_find_element(function->mesh, node, x);
320+
321+
if (element == NULL) {
322+
// the point is off and does not enclose an element, get the first one which
323+
// is attached to the nearest node
324+
element = node->element_list->element;
325+
}
326+
319327
if (element != NULL && element->physical_group != NULL && element->physical_group->material != NULL) {
320328
HASH_FIND_STR(element->physical_group->material->property_datums, property->name, property_data);
321329
if (property_data != NULL) {
@@ -327,7 +335,7 @@ double feenox_function_property_eval(struct function_t *function, const double *
327335
}
328336
}
329337

330-
// finally evalaute the expression of the material found
338+
// finally evaluate the expression of the material found
331339
y = feenox_expression_eval(&property_data->expr);
332340
}
333341
}

0 commit comments

Comments
 (0)