xref: /honee/src/smartsim_weak.c (revision 012ff548f79b2fe1ee137cabdcbf2f748d9168ac)
1 // Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3 //
4 // SPDX-License-Identifier: BSD-2-Clause
5 //
6 // This file is part of CEED:  http://github.com/ceed
7 //
8 // @file This creates weak functions for smartsim dependent functions. If the smartsim-dependent functions are actually built, these functions are not
9 // linked to the final executable.
10 
11 #include "../navierstokes.h"
12 
13 PetscErrorCode SGS_DD_TrainingSetup(Ceed ceed, User user, CeedData ceed_data, ProblemData problem) __attribute__((weak));
14 PetscErrorCode SGS_DD_TrainingSetup(Ceed ceed, User user, CeedData ceed_data, ProblemData problem) {
15   PetscFunctionBeginUser;
16   SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_SUP, "Must build with SMARTREDIS_DIR set to run %s", __func__);
17 };
18 
19 PetscErrorCode TSMonitor_SGS_DD_Training(TS ts, PetscInt step_num, PetscReal solution_time, Vec Q, void *ctx) __attribute__((weak));
20 PetscErrorCode TSMonitor_SGS_DD_Training(TS ts, PetscInt step_num, PetscReal solution_time, Vec Q, void *ctx) {
21   PetscFunctionBeginUser;
22   SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_SUP, "Must build with SMARTREDIS_DIR set to run %s", __func__);
23 };
24 
25 PetscErrorCode SGS_DD_TrainingDataDestroy(SGS_DD_TrainingData sgs_dd_train) __attribute__((weak));
26 PetscErrorCode SGS_DD_TrainingDataDestroy(SGS_DD_TrainingData sgs_dd_train) {
27   PetscFunctionBeginUser;
28   if (!sgs_dd_train) PetscFunctionReturn(PETSC_SUCCESS);
29   PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Warning: SGS_DD_TrainingData struct should not be initialized if SMARTREDIS_DIR isn't set on build..."));
30   PetscFunctionReturn(PETSC_SUCCESS);
31 }
32 
33 PetscErrorCode TSPostStep_SGS_DD_Training(TS ts) __attribute__((weak));
34 PetscErrorCode TSPostStep_SGS_DD_Training(TS ts) {
35   PetscFunctionBeginUser;
36   SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_SUP, "Must build with SMARTREDIS_DIR set to run %s", __func__);
37 };
38 
39 PetscErrorCode SmartSimDataDestroy(SmartSimData smartsim) __attribute__((weak));
40 PetscErrorCode SmartSimDataDestroy(SmartSimData smartsim) {
41   PetscFunctionBeginUser;
42   if (!smartsim) PetscFunctionReturn(PETSC_SUCCESS);
43   PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Warning: SmartSimData struct should not be initialized if SMARTREDIS_DIR isn't set on build..."));
44 
45   PetscFunctionReturn(PETSC_SUCCESS);
46 }
47