Skip to content

Commit 254dbcd

Browse files
committed
fix for READ_DATA & default to BFD
1 parent 51bde06 commit 254dbcd

3 files changed

Lines changed: 24 additions & 17 deletions

File tree

src/io/read.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ int feenox_instruction_read_data(void *arg) {
3131
if (read_data->variable != NULL) {
3232
fscanf(read_data->file->pointer, "%lf", read_data->variable->value);
3333
} else {
34+
35+
if (read_data->vector->initialized == 0) {
36+
if (feenox_vector_init(read_data->vector, FEENOX_VECTOR_INITIAL) != FEENOX_OK) {
37+
return FEENOX_ERROR;
38+
}
39+
}
3440
double xi = 0;
3541
for (int i = 0; i < read_data->vector->size; i++) {
3642
fscanf(read_data->file->pointer, "%lf", &xi);

src/parser/parser.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ int feenox_parse_line(void) {
193193
return FEENOX_OK;
194194

195195
///kw+READ_DATA+desc Read data from a file (or standard output, or pipe, or queue, etc.).
196-
///kw+PRINT+usage READ_DATA
196+
///kw+READ_DATA+usage READ_DATA
197197
} else if (strcasecmp(token, "READ_DATA") == 0) {
198198
feenox_call(feenox_parse_read_data());
199199
return FEENOX_OK;
@@ -1581,13 +1581,14 @@ int feenox_parse_read_data(void) {
15811581

15821582
char *token = NULL;
15831583
while ((token = feenox_get_next_token(NULL)) != NULL) {
1584-
///kw+READ_DATA+usage [ FILE { <file_path> | <file_id> } ]
15851584
if (strcasecmp(token, "FILE") == 0 || strcasecmp(token, "FILE_PATH") == 0) {
1585+
///kw+READ_DATA+usage FILE { <file_path> | <file_id> }
15861586
feenox_call(feenox_parser_file(&read_data->file));
15871587
if (read_data->file->mode == NULL) {
15881588
feenox_check_alloc(read_data->file->mode = strdup("r"));
15891589
}
15901590
} else {
1591+
///kw+READ_DATA+usage [ <variable1> [ <variable2> [...] [ <vector1> [...] ] ] ]
15911592
if ((read_data->variable = feenox_get_variable_ptr(token)) == NULL) {
15921593
if ((read_data->vector = feenox_get_vector_ptr(token)) == NULL) {
15931594
feenox_push_error_message("unknown symbol '%s'", token);

src/pdes/petsc_ts.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*------------ -------------- -------- --- ----- --- -- - -
22
* feenox's transient solver using PETSc routines
33
*
4-
* Copyright (C) 2021 Jeremy Theler
4+
* Copyright (C) 2021-2025 Jeremy Theler
55
*
66
* This file is part of FeenoX <https://www.seamplex.com/feenox>.
77
*
@@ -24,7 +24,6 @@
2424
int feenox_problem_solve_petsc_transient(void) {
2525

2626
#ifdef HAVE_PETSC
27-
2827
if (feenox_var_value(feenox_special_var(in_static))) {
2928
// if we are in the static step and no initial condition was given, we solve a steady state
3029
if (feenox.pde.initial_condition == NULL) {
@@ -56,7 +55,7 @@ int feenox_problem_solve_petsc_transient(void) {
5655
} else {
5756
feenox_function_to_phi(feenox.pde.initial_condition, feenox.pde.phi);
5857
}
59-
58+
6059
if (feenox.pde.ts == NULL) {
6160
petsc_call(TSCreate(PETSC_COMM_WORLD, &feenox.pde.ts));
6261
petsc_call(TSSetIFunction(feenox.pde.ts, NULL, feenox_ts_residual, NULL));
@@ -92,16 +91,17 @@ int feenox_problem_solve_petsc_transient(void) {
9291

9392
}
9493

94+
if (feenox.pde.do_not_solve == 0) {
95+
PetscInt ts_step = 0;
96+
petsc_call(TSGetStepNumber(feenox.pde.ts, &ts_step));
97+
petsc_call(TSSetMaxSteps(feenox.pde.ts, ts_step+1));
9598

96-
PetscInt ts_step = 0;
97-
petsc_call(TSGetStepNumber(feenox.pde.ts, &ts_step));
98-
petsc_call(TSSetMaxSteps(feenox.pde.ts, ts_step+1));
99-
100-
petsc_call(TSSetMaxTime(feenox.pde.ts, feenox_special_var_value(end_time)));
101-
petsc_call(TSSetTimeStep(feenox.pde.ts, feenox_special_var_value(dt)));
102-
petsc_call(TSSolve(feenox.pde.ts, feenox.pde.phi));
103-
petsc_call(TSGetTime(feenox.pde.ts, feenox_value_ptr(feenox_special_var(t))));
104-
petsc_call(TSGetTimeStep(feenox.pde.ts, feenox_value_ptr(feenox_special_var(dt))));
99+
petsc_call(TSSetMaxTime(feenox.pde.ts, feenox_special_var_value(end_time)));
100+
petsc_call(TSSetTimeStep(feenox.pde.ts, feenox_special_var_value(dt)));
101+
petsc_call(TSSolve(feenox.pde.ts, feenox.pde.phi));
102+
petsc_call(TSGetTime(feenox.pde.ts, feenox_value_ptr(feenox_special_var(t))));
103+
petsc_call(TSGetTimeStep(feenox.pde.ts, feenox_value_ptr(feenox_special_var(dt))));
104+
}
105105

106106
#endif
107107

@@ -117,9 +117,9 @@ int feenox_problem_setup_ts(TS ts) {
117117

118118
if (feenox.pde.ts_type != NULL) {
119119
petsc_call(TSSetType(ts, feenox.pde.ts_type));
120-
} else if (feenox.pde.transient_type == transient_type_quasistatic) {
121-
// TODO: the default depends on the physics type
122-
petsc_call(TSSetType(ts, TSBEULER));
120+
// } else if (feenox.pde.transient_type == transient_type_quasistatic) {
121+
// // TODO: the default depends on the physics type
122+
// petsc_call(TSSetType(ts, TSBEULER));
123123
} else {
124124
// TODO: the default depends on the physics type
125125
petsc_call(TSSetType(ts, TSBDF));

0 commit comments

Comments
 (0)