Skip to content

Commit

Permalink
fluids: Add put_tensor_interval for sgs training
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwrigh committed May 31, 2023
1 parent aa84b68 commit 8837361
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/fluids/navierstokes.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ typedef struct {
typedef struct {
DM dm_dd_inputs;
IS is_dd_inputs, is_velocity_products;
PetscInt num_comp_dd_inputs;
PetscInt num_comp_dd_inputs, put_tensor_interval;
size_t training_data_array_dims[2];
OperatorApplyContext op_nodal_input_evaluation_ctx;
NodalProjectionData filtered_grad_velo_proj;
Expand Down
7 changes: 5 additions & 2 deletions examples/fluids/problems/sgs_dd_training.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,15 @@ PetscErrorCode SGS_DD_TrainingSetup(Ceed ceed, User user, CeedData ceed_data, Pr

PetscCall(PetscNew(&sgsdd_train_ctx));
PetscCall(PetscNew(&sgs_dd_train_setup_data));
PetscCall(PetscNew(&user->sgs_dd_train));

user->sgs_dd_train->put_tensor_interval = 1;
PetscOptionsBegin(user->comm, NULL, "SGS Data-Driven Training Options", NULL);

PetscCall(PetscOptionsInt("-sgs_train_put_tensor_interval", "Number of timesteps between putting data into database", NULL,
user->sgs_dd_train->put_tensor_interval, &user->sgs_dd_train->put_tensor_interval, NULL));
PetscOptionsEnd();

// -- Create DM for storing training data
PetscCall(PetscNew(&user->sgs_dd_train));
PetscCall(SGS_DD_TrainingCreateDM(user->dm, &user->sgs_dd_train->dm_dd_inputs, user->app_ctx->degree, &user->sgs_dd_train->num_comp_dd_inputs));
PetscCall(SGS_DD_TrainingCreateIS(user));

Expand Down Expand Up @@ -381,6 +383,7 @@ PetscErrorCode TSMonitor_SGS_DD_Training(TS ts, PetscInt step_num, PetscReal sol
Vec FilteredFields, FilteredFields_loc, DDModelInputs;

PetscFunctionBeginUser;
if (step_num % sgs_dd_train->put_tensor_interval != 0) PetscFunctionReturn(0);
PetscCall(DMGetGlobalVector(user->diff_filter->dm_filter, &FilteredFields));
PetscCall(DMGetGlobalVector(user->sgs_dd_train->dm_dd_inputs, &DDModelInputs));

Expand Down

0 comments on commit 8837361

Please sign in to comment.