Lines Matching +full:- +full:e
1 // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
4 // SPDX-License-Identifier: BSD-2-Clause
8 // libCEED + PETSc Example: Navier-Stokes
10 // This example demonstrates a simple usage of libCEED with PETSc to solve a Navier-Stokes problem.
18 // ./navierstokes -ceed /cpu/self -options_file gaussianwave.yml
19 // ./navierstokes -ceed /gpu/cuda -problem advection -degree 1
21 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/gaussianwave.yaml -compare_f…
22 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/gaussianwave.yaml -compare_f…
23 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/gaussianwave.yaml -compare_f…
24 …-ceed {ceed_resource} -test_type solver -problem advection -degree 3 -dm_plex_box_faces 2,2 -dm_pl…
25 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/advection.yaml -ts_max_steps…
26 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/blasius.yaml -ts_max_steps 5…
27 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/advection.yaml -ts_max_steps…
28 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/gaussianwave.yaml -compare_f…
29 …-Green Vortex IC") -ceed {ceed_resource} -problem taylor_green -test_type solver -dm_plex_dim 3 -d…
30 …-ceed {ceed_resource} -test_type diff_filter -options_file examples/fluids/tests-output/blasius_te…
31 …-ceed {ceed_resource} -test_type diff_filter -options_file examples/fluids/tests-output/blasius_te…
32 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/gaussianwave.yaml -compare_f…
33 …-ceed {ceed_resource} -test_type turb_spanstats -options_file examples/fluids/tests-output/stats_t…
34 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/tests-output/blasius_test.ya…
35 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/tests-output/blasius_stgtest…
36 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/tests-output/blasius_stgtest…
37 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/tests-output/blasius_stgtest…
38 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/channel.yaml -compare_final_…
39 …-ceed {ceed_resource} -test_type solver -options_file examples/fluids/channel.yaml -compare_final_…
40 …-ceed {ceed_resource} -test_type solver -degree 3 -q_extra 2 -dm_plex_box_faces 1,1,2 -dm_plex_box…
41 …-ceed {ceed_resource} -test_type solver -degree 3 -dm_plex_box_faces 1,1,2 -dm_plex_box_lower 0,0,…
42 …-ceed {ceed_resource} -test_type solver -problem advection -CtauS .3 -stab supg -degree 3 -dm_plex…
43 …-ceed {ceed_resource} -test_type solver -problem advection -CtauS .3 -stab su -degree 3 -dm_plex_b…
44 …-ceed {ceed_resource} -test_type solver -problem advection -strong_form 1 -degree 3 -dm_plex_box_f…
45 …-ceed {ceed_resource} -test_type solver -problem advection -CtauS .3 -stab supg -degree 3 -dm_plex…
46 …-ceed {ceed_resource} -test_type solver -problem euler_vortex -degree 3 -dm_plex_box_faces 1,1,2 -…
47 …-ceed {ceed_resource} -test_type solver -problem euler_vortex -degree 3 -q_extra 2 -dm_plex_box_fa…
48 …-z-beta shock capturing") -ceed {ceed_resource} -test_type solver -problem shocktube -degree 1 -q_…
51 /// Navier-Stokes example using PETSc
53 const char help[] = "Solve Navier-Stokes using PETSc and libCEED\n";
63 // --------------------------------------------------------------------------- in main()
65 // --------------------------------------------------------------------------- in main()
68 // --------------------------------------------------------------------------- in main()
70 // --------------------------------------------------------------------------- in main()
92 user->app_ctx = app_ctx; in main()
93 user->units = units; in main()
94 user->phys = phys_ctx; in main()
95 problem->set_bc_from_ics = PETSC_TRUE; in main()
99 // --------------------------------------------------------------------------- in main()
101 // --------------------------------------------------------------------------- in main()
102 // -- Register problems to be available on the command line in main()
105 // -- Process general command line options in main()
107 user->comm = comm; in main()
111 // --------------------------------------------------------------------------- in main()
113 // --------------------------------------------------------------------------- in main()
114 // -- Initialize backend in main()
116 …PetscCheck(CeedInit(app_ctx->ceed_resource, &ceed) == CEED_ERROR_SUCCESS, comm, PETSC_ERR_LIB, "Ce… in main()
117 user->ceed = ceed; in main()
121 // -- Check preferred MemType in main()
137 // --------------------------------------------------------------------------- in main()
139 // --------------------------------------------------------------------------- in main()
140 // -- Create DM in main()
161 user->dm = dm; in main()
164 // --------------------------------------------------------------------------- in main()
166 // --------------------------------------------------------------------------- in main()
169 PetscCall(PetscFunctionListFind(app_ctx->problems, app_ctx->problem_name, &p)); in main()
170 PetscCheck(p, PETSC_COMM_SELF, 1, "Problem '%s' not found", app_ctx->problem_name); in main()
174 // -- Set up DM in main()
175 PetscCall(SetUpDM(dm, problem, app_ctx->degree, app_ctx->q_extra, bc, phys_ctx)); in main()
177 // -- Refine DM for high-order viz in main()
178 if (app_ctx->viz_refine) PetscCall(VizRefineDM(dm, user, problem, bc, phys_ctx)); in main()
180 // --------------------------------------------------------------------------- in main()
182 // --------------------------------------------------------------------------- in main()
183 // -- Set up global state vector Q in main()
188 // -- Set up local state vectors Q_loc, Q_dot_loc in main()
189 PetscCall(DMCreateLocalVector(dm, &user->Q_loc)); in main()
190 PetscCall(DMCreateLocalVector(dm, &user->Q_dot_loc)); in main()
191 PetscCall(VecZeroEntries(user->Q_dot_loc)); in main()
193 // --------------------------------------------------------------------------- in main()
195 // --------------------------------------------------------------------------- in main()
196 // -- Set up libCEED objects in main()
199 // --------------------------------------------------------------------------- in main()
201 // --------------------------------------------------------------------------- in main()
202 // -- Fix multiplicity for ICs in main()
203 PetscCall(ICs_FixMultiplicity(dm, ceed_data, user, user->Q_loc, Q, 0.0)); in main()
205 // --------------------------------------------------------------------------- in main()
207 // --------------------------------------------------------------------------- in main()
208 // -- This overrides DMPlexInsertBoundaryValues(). in main()
209 …ause the reference DMPlexInsertBoundaryValues() is very slow on the GPU due to extra device-to-host in main()
210 …// communication. If we disable this, we should still get the same results due to the problem->… in main()
212 if (problem->set_bc_from_ics) { in main()
213 PetscCall(SetBCsFromICs(dm, Q, user->Q_loc)); in main()
216 // --------------------------------------------------------------------------- in main()
218 // --------------------------------------------------------------------------- in main()
222 PetscCall(PetscMkdir(app_ctx->output_dir)); in main()
225 // --------------------------------------------------------------------------- in main()
227 // --------------------------------------------------------------------------- in main()
228 // -- Set up initial values from binary file in main()
229 if (app_ctx->cont_steps) { in main()
233 // -- Zero Q_loc in main()
234 PetscCall(VecZeroEntries(user->Q_loc)); in main()
236 // --------------------------------------------------------------------------- in main()
238 // --------------------------------------------------------------------------- in main()
243 // --------------------------------------------------------------------------- in main()
244 // Post-processing in main()
245 // --------------------------------------------------------------------------- in main()
248 // --------------------------------------------------------------------------- in main()
250 // --------------------------------------------------------------------------- in main()
253 PetscCall(NodalProjectionDataDestroy(user->grad_velo_proj)); in main()
254 PetscCall(DifferentialFilterDataDestroy(user->diff_filter)); in main()
256 // -- Vectors in main()
257 PetscCallCeed(ceed, CeedVectorDestroy(&ceed_data->x_coord)); in main()
258 PetscCallCeed(ceed, CeedVectorDestroy(&ceed_data->q_data)); in main()
259 PetscCallCeed(ceed, CeedVectorDestroy(&user->q_ceed)); in main()
260 PetscCallCeed(ceed, CeedVectorDestroy(&user->q_dot_ceed)); in main()
261 PetscCallCeed(ceed, CeedVectorDestroy(&user->g_ceed)); in main()
263 // -- Bases in main()
264 PetscCallCeed(ceed, CeedBasisDestroy(&ceed_data->basis_q)); in main()
265 PetscCallCeed(ceed, CeedBasisDestroy(&ceed_data->basis_x)); in main()
267 // -- Restrictions in main()
268 PetscCallCeed(ceed, CeedElemRestrictionDestroy(&ceed_data->elem_restr_q)); in main()
269 PetscCallCeed(ceed, CeedElemRestrictionDestroy(&ceed_data->elem_restr_x)); in main()
270 PetscCallCeed(ceed, CeedElemRestrictionDestroy(&ceed_data->elem_restr_qd_i)); in main()
275 PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->apply_inflow.qfunction_context)); in main()
276 …PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->apply_inflow_jacobian.qfunction_context)… in main()
277 PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->apply_outflow.qfunction_context)); in main()
278 …PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->apply_outflow_jacobian.qfunction_context… in main()
279 PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->apply_freestream.qfunction_context)); in main()
280 …PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->apply_freestream_jacobian.qfunction_cont… in main()
281 PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->apply_slip.qfunction_context)); in main()
282 … PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->apply_slip_jacobian.qfunction_context)); in main()
283 PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->ics.qfunction_context)); in main()
284 PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->apply_vol_rhs.qfunction_context)); in main()
285 … PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->apply_vol_ifunction.qfunction_context)); in main()
286 … PetscCallCeed(ceed, CeedQFunctionContextDestroy(&problem->apply_vol_ijacobian.qfunction_context)); in main()
289 // -- Operators in main()
290 PetscCall(OperatorApplyContextDestroy(ceed_data->op_ics_ctx)); in main()
291 PetscCall(OperatorApplyContextDestroy(user->op_rhs_ctx)); in main()
292 PetscCall(OperatorApplyContextDestroy(user->op_strong_bc_ctx)); in main()
293 PetscCallCeed(ceed, CeedOperatorDestroy(&user->op_ifunction)); in main()
295 // -- Ceed in main()
298 if (app_ctx->test_type != TESTTYPE_NONE) { in main()
301 PetscCheck(num_options_left == 0, PETSC_COMM_WORLD, -1, in main()
302 …ions. This is not allowed. See error message for the unused options (or use -options_left directly… in main()
305 // --------------------------------------------------------------------------- in main()
307 // --------------------------------------------------------------------------- in main()
308 // -- Vectors in main()
310 PetscCall(VecDestroy(&user->Q_loc)); in main()
311 PetscCall(VecDestroy(&user->Q_dot_loc)); in main()
313 PetscCall(KSPDestroy(&user->mass_ksp)); in main()
315 // -- Matrices in main()
316 PetscCall(MatDestroy(&user->interp_viz)); in main()
317 PetscCall(MatDestroy(&user->mat_ijacobian)); in main()
319 // -- DM in main()
321 PetscCall(DMDestroy(&user->dm_viz)); in main()
323 // -- TS in main()
326 // -- Function list in main()
327 PetscCall(PetscFunctionListDestroy(&app_ctx->problems)); in main()
329 PetscCall(PetscFree(app_ctx->amat_type)); in main()
330 PetscCall(PetscFree(app_ctx->wall_forces.walls)); in main()
331 PetscCall(PetscViewerDestroy(&app_ctx->wall_forces.viewer)); in main()
332 PetscCall(PetscViewerDestroy(&app_ctx->turb_spanstats_viewer)); in main()
334 // -- Structs in main()
335 for (PetscInt i = 0; i < problem->num_bc_defs; i++) { in main()
336 PetscCall(BCDefinitionDestroy(&problem->bc_defs[i])); in main()
338 PetscCall(PetscFree(problem->bc_defs)); in main()