From 88373618fc94aec514d2b2d477e11b141980517f Mon Sep 17 00:00:00 2001 From: James Wright Date: Sat, 13 May 2023 23:02:17 -0400 Subject: [PATCH] fluids: Add put_tensor_interval for sgs training --- examples/fluids/navierstokes.h | 2 +- examples/fluids/problems/sgs_dd_training.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/fluids/navierstokes.h b/examples/fluids/navierstokes.h index 30c0a82047..cffbb7c157 100644 --- a/examples/fluids/navierstokes.h +++ b/examples/fluids/navierstokes.h @@ -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; diff --git a/examples/fluids/problems/sgs_dd_training.c b/examples/fluids/problems/sgs_dd_training.c index 305da38190..ee2985610f 100644 --- a/examples/fluids/problems/sgs_dd_training.c +++ b/examples/fluids/problems/sgs_dd_training.c @@ -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)); @@ -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));