@@ -76,9 +76,6 @@ int main(int argc, char **argv) {
7676 Physics phys_ctx ;
7777 PetscCall ( PetscCalloc1 (1 , & phys_ctx ) );
7878
79- OperatorApplyContext op_apply_ctx ;
80- PetscCall ( PetscCalloc1 (1 , & op_apply_ctx ) );
81-
8279 // ---------------------------------------------------------------------------
8380 // Process command line options
8481 // ---------------------------------------------------------------------------
@@ -119,39 +116,35 @@ int main(int argc, char **argv) {
119116 // ---------------------------------------------------------------------------
120117 // Create local Force vector
121118 // ---------------------------------------------------------------------------
122- Vec F_loc ;
123- PetscInt F_loc_size ;
124- CeedScalar * f ;
125- CeedVector force_ceed , target , bc_pressure ;
126- PetscMemType force_mem_type ;
127- PetscCall ( DMCreateLocalVector (dm , & F_loc ) );
119+ Vec U_loc ;
120+ PetscInt U_loc_size ;
121+ //CeedVector bc_pressure;
122+ PetscCall ( DMCreateLocalVector (dm , & U_loc ) );
128123 // Local size for libCEED
129- PetscCall ( VecGetSize (F_loc , & F_loc_size ) );
130- PetscCall ( VecZeroEntries (F_loc ) );
131- PetscCall ( VecGetArrayAndMemType (F_loc , & f , & force_mem_type ) );
132- CeedVectorCreate (ceed , F_loc_size , & force_ceed );
133- CeedVectorSetArray (force_ceed , MemTypeP2C (force_mem_type ), CEED_USE_POINTER , f );
134- CeedVectorCreate (ceed , F_loc_size , & bc_pressure );
135- CeedVectorSetArray (bc_pressure , MemTypeP2C (force_mem_type ), CEED_USE_POINTER ,
136- f );
124+ PetscCall ( VecGetSize (U_loc , & U_loc_size ) );
125+
137126 // ---------------------------------------------------------------------------
138- // Setup libCEED - Compute local F and true solution (target)
127+ // Setup libCEED
139128 // ---------------------------------------------------------------------------
140129 // -- Set up libCEED objects
141130 PetscCall ( SetupLibceed (dm , ceed , app_ctx , problem_data ,
142- F_loc_size , ceed_data , force_ceed , & target ) );
131+ U_loc_size , ceed_data ) );
143132 //CeedVectorView(force_ceed, "%12.8f", stdout);
144- PetscCall ( DMAddBoundariesPressure (ceed , ceed_data , app_ctx , problem_data , dm ,
145- bc_pressure ) );
133+ //PetscCall( DMAddBoundariesPressure(ceed, ceed_data, app_ctx, problem_data, dm,
134+ // bc_pressure) );
135+
136+
146137 // ---------------------------------------------------------------------------
147- // Create global F
138+ // Setup TSSolve for Richard problem
148139 // ---------------------------------------------------------------------------
149- Vec F ;
150- CeedVectorTakeArray (force_ceed , MemTypeP2C (force_mem_type ), NULL );
151- PetscCall ( VecRestoreArrayAndMemType (F_loc , & f ) );
152- PetscCall ( DMCreateGlobalVector (dm , & F ) );
153- PetscCall ( VecZeroEntries (F ) );
154- PetscCall ( DMLocalToGlobal (dm , F_loc , ADD_VALUES , F ) );
140+ if (problem_data -> has_ts ) {
141+ // ---------------------------------------------------------------------------
142+ // Create global initial conditions
143+ // ---------------------------------------------------------------------------
144+ Vec U0 ;
145+ CreateInitialConditions (dm , ceed_data , & U0 );
146+ PetscCall ( VecDestroy (& U0 ) );
147+ }
155148
156149 // ---------------------------------------------------------------------------
157150 // Solve PDE
@@ -162,14 +155,14 @@ int main(int argc, char **argv) {
162155 Vec U ;
163156 PetscCall ( SNESCreate (comm , & snes ) );
164157 PetscCall ( SNESGetKSP (snes , & ksp ) );
165- PetscCall ( PDESolver (comm , dm , ceed , ceed_data , vec_type , snes , ksp , F , & U ) );
158+ PetscCall ( PDESolver (comm , dm , ceed , ceed_data , vec_type , snes , ksp , & U ) );
166159 //VecView(U, PETSC_VIEWER_STDOUT_WORLD);
167160
168161 // ---------------------------------------------------------------------------
169162 // Compute L2 error of mms problem
170163 // ---------------------------------------------------------------------------
171164 CeedScalar l2_error_u , l2_error_p ;
172- PetscCall ( ComputeL2Error (dm , ceed ,ceed_data , U , target , & l2_error_u ,
165+ PetscCall ( ComputeL2Error (dm , ceed ,ceed_data , U , & l2_error_u ,
173166 & l2_error_p ) );
174167
175168 // ---------------------------------------------------------------------------
@@ -194,11 +187,8 @@ int main(int argc, char **argv) {
194187 // Free PETSc objects
195188 PetscCall ( DMDestroy (& dm ) );
196189 PetscCall ( VecDestroy (& U ) );
197- PetscCall ( VecDestroy (& F ) );
198- PetscCall ( VecDestroy (& F_loc ) );
190+ PetscCall ( VecDestroy (& U_loc ) );
199191 PetscCall ( SNESDestroy (& snes ) );
200- PetscCall ( VecDestroy (& op_apply_ctx -> Y_loc ) );
201- PetscCall ( VecDestroy (& op_apply_ctx -> X_loc ) );
202192
203193 // -- Function list
204194 PetscCall ( PetscFunctionListDestroy (& app_ctx -> problems ) );
@@ -207,12 +197,9 @@ int main(int argc, char **argv) {
207197 PetscCall ( PetscFree (app_ctx ) );
208198 PetscCall ( PetscFree (problem_data ) );
209199 PetscCall ( PetscFree (phys_ctx ) );
210- PetscCall ( PetscFree (op_apply_ctx ) );
211200
212201 // Free libCEED objects
213- CeedVectorDestroy (& force_ceed );
214- CeedVectorDestroy (& bc_pressure );
215- CeedVectorDestroy (& target );
202+ //CeedVectorDestroy(&bc_pressure);
216203 PetscCall ( CeedDataDestroy (ceed_data ) );
217204 CeedDestroy (& ceed );
218205
0 commit comments