@@ -245,33 +245,6 @@ PetscErrorCode SetupLibceed(DM dm, Ceed ceed, AppCtx app_ctx,
245245 (PetscScalar * )coordArray );
246246 PetscCall ( VecRestoreArrayRead (coords , & coordArray ) );
247247
248- // ---------------------------------------------------------------------------
249- // Setup true solution and force
250- // ---------------------------------------------------------------------------
251- CeedVector true_vec , true_force ;
252- CeedVectorCreate (ceed , num_elem * num_qpts * (dim + 1 ), & true_vec );
253- CeedVectorCreate (ceed , num_elem * num_qpts * 1 , & true_force );
254- // Create the q-function that sets up the RHS and true solution
255- CeedQFunctionCreateInterior (ceed , 1 , problem_data -> true_solution ,
256- problem_data -> true_solution_loc , & qf_true );
257- CeedQFunctionSetContext (qf_true , problem_data -> qfunction_context );
258- //CeedQFunctionContextDestroy(&problem_data->qfunction_context);
259- CeedQFunctionAddInput (qf_true , "x" , num_comp_x , CEED_EVAL_INTERP );
260- CeedQFunctionAddOutput (qf_true , "true force" , 1 , CEED_EVAL_NONE );
261- CeedQFunctionAddOutput (qf_true , "true solution" , dim + 1 , CEED_EVAL_NONE );
262- // Create the operator that builds the RHS and true solution
263- CeedOperatorCreate (ceed , qf_true , CEED_QFUNCTION_NONE , CEED_QFUNCTION_NONE ,
264- & op_true );
265- CeedOperatorSetField (op_true , "x" , ceed_data -> elem_restr_x ,
266- ceed_data -> basis_x , ceed_data -> x_coord );
267- CeedOperatorSetField (op_true , "true force" , ceed_data -> elem_restr_p_i ,
268- CEED_BASIS_COLLOCATED , true_force );
269- CeedOperatorSetField (op_true , "true solution" , ceed_data -> elem_restr_U_i ,
270- CEED_BASIS_COLLOCATED , CEED_VECTOR_ACTIVE );
271- // Setup RHS and true solution
272- CeedOperatorApply (op_true , ceed_data -> x_coord , true_vec ,
273- CEED_REQUEST_IMMEDIATE );
274-
275248 if (problem_data -> has_ts ) {
276249 // ---------------------------------------------------------------------------
277250 // Setup qfunction for initial conditions
@@ -299,12 +272,46 @@ PetscErrorCode SetupLibceed(DM dm, Ceed ceed, AppCtx app_ctx,
299272 ceed_data -> qf_ics = qf_ics ;
300273 ceed_data -> op_ics = op_ics ;
301274 }
275+
276+ // ---------------------------------------------------------------------------
277+ // Setup true solution and force
278+ // ---------------------------------------------------------------------------
279+ CeedVector true_vec , true_force ;
280+ CeedVectorCreate (ceed , num_elem * num_qpts * (dim + 1 ), & true_vec );
281+ CeedVectorCreate (ceed , num_elem * num_qpts * 1 , & true_force );
282+ // Create the q-function that sets up the RHS and true solution
283+ CeedQFunctionCreateInterior (ceed , 1 , problem_data -> true_solution ,
284+ problem_data -> true_solution_loc , & qf_true );
285+ CeedQFunctionSetContext (qf_true , problem_data -> qfunction_context );
286+ CeedQFunctionAddInput (qf_true , "x" , num_comp_x , CEED_EVAL_INTERP );
287+ CeedQFunctionAddOutput (qf_true , "true force" , 1 , CEED_EVAL_NONE );
288+ CeedQFunctionAddOutput (qf_true , "true solution" , dim + 1 , CEED_EVAL_NONE );
289+ // Create the operator that builds the RHS and true solution
290+ CeedOperatorCreate (ceed , qf_true , CEED_QFUNCTION_NONE , CEED_QFUNCTION_NONE ,
291+ & op_true );
292+ if (problem_data -> has_ts ) {
293+ double value_time = 2.0 ;
294+ CeedOperatorContextGetFieldLabel (op_true , "time" ,
295+ & app_ctx -> solution_time_label );
296+ CeedOperatorContextSetDouble (op_true ,
297+ app_ctx -> solution_time_label , & value_time );
298+ }
299+ CeedOperatorSetField (op_true , "x" , ceed_data -> elem_restr_x ,
300+ ceed_data -> basis_x , ceed_data -> x_coord );
301+ CeedOperatorSetField (op_true , "true force" , ceed_data -> elem_restr_p_i ,
302+ CEED_BASIS_COLLOCATED , true_force );
303+ CeedOperatorSetField (op_true , "true solution" , ceed_data -> elem_restr_U_i ,
304+ CEED_BASIS_COLLOCATED , CEED_VECTOR_ACTIVE );
305+ // Setup RHS and true solution
306+ CeedOperatorApply (op_true , ceed_data -> x_coord , true_vec ,
307+ CEED_REQUEST_IMMEDIATE );
302308 // ---------------------------------------------------------------------------
303309 // Persistent libCEED vectors
304310 // ---------------------------------------------------------------------------
305311 // -- Operator action variables: we use them in setup-solvers.c
306312 CeedVectorCreate (ceed , U_loc_size , & ceed_data -> x_ceed );
307313 CeedVectorCreate (ceed , U_loc_size , & ceed_data -> y_ceed );
314+ if (!problem_data -> has_ts ) {
308315 // Local residual evaluator
309316 // ---------------------------------------------------------------------------
310317 // Create the QFunction and Operator that computes the residual of the PDE.
@@ -443,6 +450,7 @@ PetscErrorCode SetupLibceed(DM dm, Ceed ceed, AppCtx app_ctx,
443450 CeedVectorDestroy (& true_force );
444451 CeedQFunctionDestroy (& qf_true );
445452 CeedOperatorDestroy (& op_true );
453+ }
446454 PetscFunctionReturn (0 );
447455};
448456// -----------------------------------------------------------------------------
0 commit comments