xref: /libCEED/examples/rust/ex1-volume/src/main.rs (revision d275d636ccaa61e594421fac80252590e7a77ccf)
1*d275d636SJeremy L Thompson // Copyright (c) 2017-2025, Lawrence Livermore National Security, LLC and other CEED contributors.
23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3ded9b81dSJeremy L Thompson //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
5ded9b81dSJeremy L Thompson //
63d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
73d8e8822SJeremy L Thompson //
8ded9b81dSJeremy L Thompson //                             libCEED Example 1
9ded9b81dSJeremy L Thompson //
10ded9b81dSJeremy L Thompson // This example illustrates a simple usage of libCEED to compute the volume of a
11ded9b81dSJeremy L Thompson // 3D body using matrix-free application of a mass operator.  Arbitrary mesh and
12ded9b81dSJeremy L Thompson // solution orders in 1D, 2D and 3D are supported from the same code.
13ded9b81dSJeremy L Thompson //
14ded9b81dSJeremy L Thompson // The example has no dependencies, and is designed to be self-contained. For
15ded9b81dSJeremy L Thompson // additional examples that use external discretization libraries (MFEM, PETSc,
16ded9b81dSJeremy L Thompson // etc.) see the subdirectories in libceed/examples.
17ded9b81dSJeremy L Thompson //
18ded9b81dSJeremy L Thompson // All libCEED objects use a Ceed device object constructed based on a command
19ded9b81dSJeremy L Thompson // line argument (-ceed).
20ded9b81dSJeremy L Thompson 
21947f93aaSJed Brown use clap::Parser;
22ded9b81dSJeremy L Thompson use libceed::{prelude::*, Ceed};
23ded9b81dSJeremy L Thompson mod opt;
24ded9b81dSJeremy L Thompson mod transform;
25ded9b81dSJeremy L Thompson 
26ded9b81dSJeremy L Thompson // ----------------------------------------------------------------------------
27ded9b81dSJeremy L Thompson // Example 1
28ded9b81dSJeremy L Thompson // ----------------------------------------------------------------------------
2989d15d5fSJeremy L Thompson fn main() -> libceed::Result<()> {
30947f93aaSJed Brown     let options = opt::Opt::parse();
31ded9b81dSJeremy L Thompson     example_1(options)
32ded9b81dSJeremy L Thompson }
33ded9b81dSJeremy L Thompson 
3489d15d5fSJeremy L Thompson fn example_1(options: opt::Opt) -> libceed::Result<()> {
35ded9b81dSJeremy L Thompson     // Process command line arguments
36ded9b81dSJeremy L Thompson     let opt::Opt {
37ded9b81dSJeremy L Thompson         ceed_spec,
38ded9b81dSJeremy L Thompson         dim,
39ded9b81dSJeremy L Thompson         mesh_degree,
40ded9b81dSJeremy L Thompson         solution_degree,
41ded9b81dSJeremy L Thompson         num_qpts,
42ded9b81dSJeremy L Thompson         problem_size_requested,
43ded9b81dSJeremy L Thompson         test,
44ded9b81dSJeremy L Thompson         quiet,
45ded9b81dSJeremy L Thompson         gallery,
46ded9b81dSJeremy L Thompson     } = options;
47ded9b81dSJeremy L Thompson     assert!(dim >= 1 && dim <= 3);
48ded9b81dSJeremy L Thompson     assert!(mesh_degree >= 1);
49ded9b81dSJeremy L Thompson     assert!(solution_degree >= 1);
50ded9b81dSJeremy L Thompson     assert!(num_qpts >= 1);
51ded9b81dSJeremy L Thompson     let ncomp_x = dim;
52ded9b81dSJeremy L Thompson     let problem_size: i64;
53ded9b81dSJeremy L Thompson     if problem_size_requested < 0 {
54ded9b81dSJeremy L Thompson         problem_size = if test { 8 * 16 } else { 256 * 1024 };
55ded9b81dSJeremy L Thompson     } else {
56ded9b81dSJeremy L Thompson         problem_size = problem_size_requested;
57ded9b81dSJeremy L Thompson     }
58ded9b81dSJeremy L Thompson 
59ded9b81dSJeremy L Thompson     // Summary output
60ded9b81dSJeremy L Thompson     if !quiet {
61ded9b81dSJeremy L Thompson         println!("Selected options: [command line option] : <current value>");
62ded9b81dSJeremy L Thompson         println!("    Ceed specification [-c] : {}", ceed_spec);
63ded9b81dSJeremy L Thompson         println!("    Mesh dimension     [-d] : {}", dim);
64ded9b81dSJeremy L Thompson         println!("    Mesh degree        [-m] : {}", mesh_degree);
65ded9b81dSJeremy L Thompson         println!("    Solution degree    [-p] : {}", solution_degree);
66ded9b81dSJeremy L Thompson         println!("    Num. 1D quadr. pts [-q] : {}", num_qpts);
67ded9b81dSJeremy L Thompson         println!("    Approx. # unknowns [-s] : {}", problem_size);
68ded9b81dSJeremy L Thompson         println!(
69ded9b81dSJeremy L Thompson             "    QFunction source   [-g] : {}",
70ded9b81dSJeremy L Thompson             if gallery { "gallery" } else { "user closure" }
71ded9b81dSJeremy L Thompson         );
72ded9b81dSJeremy L Thompson     }
73ded9b81dSJeremy L Thompson 
74ded9b81dSJeremy L Thompson     // Initalize ceed context
75ded9b81dSJeremy L Thompson     let ceed = Ceed::init(&ceed_spec);
76ded9b81dSJeremy L Thompson 
77ded9b81dSJeremy L Thompson     // Mesh and solution bases
7851d03428SJeremy L Thompson     let basis_mesh =
7951d03428SJeremy L Thompson         ceed.basis_tensor_H1_Lagrange(dim, ncomp_x, mesh_degree + 1, num_qpts, QuadMode::Gauss)?;
8051d03428SJeremy L Thompson     let basis_solution =
8151d03428SJeremy L Thompson         ceed.basis_tensor_H1_Lagrange(dim, 1, solution_degree + 1, num_qpts, QuadMode::Gauss)?;
82ded9b81dSJeremy L Thompson 
83ded9b81dSJeremy L Thompson     // Determine mesh size from approximate problem size
84ded9b81dSJeremy L Thompson     let num_xyz = mesh::cartesian_mesh_size(dim, solution_degree, problem_size);
85ded9b81dSJeremy L Thompson     if !quiet {
86ded9b81dSJeremy L Thompson         print!("\nMesh size                   : nx = {}", num_xyz[0]);
87ded9b81dSJeremy L Thompson         if dim > 1 {
88ded9b81dSJeremy L Thompson             print!(", ny = {}", num_xyz[1]);
89ded9b81dSJeremy L Thompson         }
90ded9b81dSJeremy L Thompson         if dim > 2 {
91ded9b81dSJeremy L Thompson             print!(", nz = {}", num_xyz[2]);
92ded9b81dSJeremy L Thompson         }
93ded9b81dSJeremy L Thompson         print!("\n");
94ded9b81dSJeremy L Thompson     }
95ded9b81dSJeremy L Thompson 
96ded9b81dSJeremy L Thompson     // Build ElemRestriction objects describing the mesh and solution discrete
97ded9b81dSJeremy L Thompson     // representations
98edb2538eSJeremy L Thompson     let (rstr_mesh, _) =
99e15f9bd0SJeremy L Thompson         mesh::build_cartesian_restriction(&ceed, dim, num_xyz, mesh_degree, ncomp_x, num_qpts)?;
100edb2538eSJeremy L Thompson     let (rstr_solution, rstr_qdata) =
101e15f9bd0SJeremy L Thompson         mesh::build_cartesian_restriction(&ceed, dim, num_xyz, solution_degree, 1, num_qpts)?;
102edb2538eSJeremy L Thompson     let mesh_size = rstr_mesh.lvector_size();
103edb2538eSJeremy L Thompson     let solution_size = rstr_solution.lvector_size();
104ded9b81dSJeremy L Thompson     if !quiet {
105ded9b81dSJeremy L Thompson         println!("Number of mesh nodes        : {}", mesh_size / dim);
106ded9b81dSJeremy L Thompson         println!("Number of solution nodes    : {}", solution_size);
107ded9b81dSJeremy L Thompson     }
108ded9b81dSJeremy L Thompson 
109ded9b81dSJeremy L Thompson     // Create a Vector with the mesh coordinates
110e15f9bd0SJeremy L Thompson     let mut mesh_coords = mesh::cartesian_mesh_coords(&ceed, dim, num_xyz, mesh_degree, mesh_size)?;
111ded9b81dSJeremy L Thompson 
112ded9b81dSJeremy L Thompson     // Apply a transformation to the mesh coordinates
113e78171edSJeremy L Thompson     let exact_volume = transform::transform_mesh_coordinates(dim, mesh_size, &mut mesh_coords)?;
114ded9b81dSJeremy L Thompson 
115ded9b81dSJeremy L Thompson     // QFunction that builds the quadrature data for the mass operator
116ded9b81dSJeremy L Thompson     // -- QFunction from user closure
117ded9b81dSJeremy L Thompson     let build_mass = move |[jacobian, weights, ..]: QFunctionInputs,
118ded9b81dSJeremy L Thompson                            [qdata, ..]: QFunctionOutputs| {
119ded9b81dSJeremy L Thompson         // Build quadrature data
120ded9b81dSJeremy L Thompson         match dim {
121ded9b81dSJeremy L Thompson             1 => qdata
122ded9b81dSJeremy L Thompson                 .iter_mut()
123ded9b81dSJeremy L Thompson                 .zip(jacobian.iter().zip(weights.iter()))
124ded9b81dSJeremy L Thompson                 .for_each(|(qdata, (j, weight))| *qdata = j * weight),
125ded9b81dSJeremy L Thompson             2 => {
126ded9b81dSJeremy L Thompson                 let q = qdata.len();
127ded9b81dSJeremy L Thompson                 qdata.iter_mut().zip(weights.iter()).enumerate().for_each(
128ded9b81dSJeremy L Thompson                     |(i, (qdata, weight))| {
129ded9b81dSJeremy L Thompson                         *qdata = (jacobian[i + q * 0] * jacobian[i + q * 3]
130ded9b81dSJeremy L Thompson                             - jacobian[i + q * 1] * jacobian[i + q * 2])
131ded9b81dSJeremy L Thompson                             * weight
132ded9b81dSJeremy L Thompson                     },
133ded9b81dSJeremy L Thompson                 );
134ded9b81dSJeremy L Thompson             }
135ded9b81dSJeremy L Thompson             3 => {
136ded9b81dSJeremy L Thompson                 let q = qdata.len();
137ded9b81dSJeremy L Thompson                 qdata.iter_mut().zip(weights.iter()).enumerate().for_each(
138ded9b81dSJeremy L Thompson                     |(i, (qdata, weight))| {
139ded9b81dSJeremy L Thompson                         *qdata = (jacobian[i + q * 0]
140ded9b81dSJeremy L Thompson                             * (jacobian[i + q * 4] * jacobian[i + q * 8]
141ded9b81dSJeremy L Thompson                                 - jacobian[i + q * 5] * jacobian[i + q * 7])
142ded9b81dSJeremy L Thompson                             - jacobian[i + q * 1]
143ded9b81dSJeremy L Thompson                                 * (jacobian[i + q * 3] * jacobian[i + q * 8]
144ded9b81dSJeremy L Thompson                                     - jacobian[i + q * 5] * jacobian[i + q * 6])
145ded9b81dSJeremy L Thompson                             + jacobian[i + q * 2]
146ded9b81dSJeremy L Thompson                                 * (jacobian[i + q * 3] * jacobian[i + q * 7]
147ded9b81dSJeremy L Thompson                                     - jacobian[i + q * 4] * jacobian[i + q * 6]))
148ded9b81dSJeremy L Thompson                             * weight
149ded9b81dSJeremy L Thompson                     },
150ded9b81dSJeremy L Thompson                 );
151ded9b81dSJeremy L Thompson             }
152ded9b81dSJeremy L Thompson             _ => unreachable!(),
153ded9b81dSJeremy L Thompson         };
154ded9b81dSJeremy L Thompson 
155ded9b81dSJeremy L Thompson         // Return clean error code
156ded9b81dSJeremy L Thompson         0
157ded9b81dSJeremy L Thompson     };
158ded9b81dSJeremy L Thompson     let qf_build_closure = ceed
159e15f9bd0SJeremy L Thompson         .q_function_interior(1, Box::new(build_mass))?
160e15f9bd0SJeremy L Thompson         .input("dx", ncomp_x * dim, EvalMode::Grad)?
161e15f9bd0SJeremy L Thompson         .input("weights", 1, EvalMode::Weight)?
162e15f9bd0SJeremy L Thompson         .output("qdata", 1, EvalMode::None)?;
163ded9b81dSJeremy L Thompson     // -- QFunction from gallery
164ded9b81dSJeremy L Thompson     let qf_build_named = {
165ded9b81dSJeremy L Thompson         let name = format!("Mass{}DBuild", dim);
166e15f9bd0SJeremy L Thompson         ceed.q_function_interior_by_name(&name)?
167ded9b81dSJeremy L Thompson     };
168ded9b81dSJeremy L Thompson     // -- QFunction for use with Operator
169ded9b81dSJeremy L Thompson     let qf_build = if gallery {
170ded9b81dSJeremy L Thompson         QFunctionOpt::SomeQFunctionByName(&qf_build_named)
171ded9b81dSJeremy L Thompson     } else {
172ded9b81dSJeremy L Thompson         QFunctionOpt::SomeQFunction(&qf_build_closure)
173ded9b81dSJeremy L Thompson     };
174ded9b81dSJeremy L Thompson 
175ded9b81dSJeremy L Thompson     // Operator that build the quadrature data for the mass operator
176ded9b81dSJeremy L Thompson     let op_build = ceed
177e15f9bd0SJeremy L Thompson         .operator(qf_build, QFunctionOpt::None, QFunctionOpt::None)?
178ea6b5821SJeremy L Thompson         .name("build qdata")?
179edb2538eSJeremy L Thompson         .field("dx", &rstr_mesh, &basis_mesh, VectorOpt::Active)?
180ded9b81dSJeremy L Thompson         .field(
181ded9b81dSJeremy L Thompson             "weights",
182ded9b81dSJeremy L Thompson             ElemRestrictionOpt::None,
183ded9b81dSJeremy L Thompson             &basis_mesh,
184ded9b81dSJeremy L Thompson             VectorOpt::None,
185e15f9bd0SJeremy L Thompson         )?
186edb2538eSJeremy L Thompson         .field("qdata", &rstr_qdata, BasisOpt::None, VectorOpt::Active)?
1876f97ff0aSJeremy L Thompson         .check()?;
188ded9b81dSJeremy L Thompson 
189ded9b81dSJeremy L Thompson     // Compute the quadrature data for the mass operator
190ded9b81dSJeremy L Thompson     let elem_qpts = num_qpts.pow(dim as u32);
191ded9b81dSJeremy L Thompson     let num_elem: usize = num_xyz.iter().take(dim).product();
192e15f9bd0SJeremy L Thompson     let mut qdata = ceed.vector(num_elem * elem_qpts)?;
193e15f9bd0SJeremy L Thompson     op_build.apply(&mesh_coords, &mut qdata)?;
194ded9b81dSJeremy L Thompson 
195ded9b81dSJeremy L Thompson     // QFunction that applies the mass operator
196ded9b81dSJeremy L Thompson     // -- QFunction from user closure
197ded9b81dSJeremy L Thompson     let apply_mass = |[u, qdata, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| {
198ded9b81dSJeremy L Thompson         // Apply mass operator
199ded9b81dSJeremy L Thompson         v.iter_mut()
200ded9b81dSJeremy L Thompson             .zip(u.iter().zip(qdata.iter()))
201ded9b81dSJeremy L Thompson             .for_each(|(v, (u, w))| *v = u * w);
202ded9b81dSJeremy L Thompson         // Return clean error code
203ded9b81dSJeremy L Thompson         0
204ded9b81dSJeremy L Thompson     };
205ded9b81dSJeremy L Thompson     let qf_mass_closure = ceed
206e15f9bd0SJeremy L Thompson         .q_function_interior(1, Box::new(apply_mass))?
207e15f9bd0SJeremy L Thompson         .input("u", 1, EvalMode::Interp)?
208e15f9bd0SJeremy L Thompson         .input("qdata", 1, EvalMode::None)?
209e15f9bd0SJeremy L Thompson         .output("v", 1, EvalMode::Interp)?;
210ded9b81dSJeremy L Thompson     // -- QFunction from gallery
211e15f9bd0SJeremy L Thompson     let qf_mass_named = ceed.q_function_interior_by_name("MassApply")?;
212ded9b81dSJeremy L Thompson     // -- QFunction for use with Operator
213ded9b81dSJeremy L Thompson     let qf_mass = if gallery {
214ded9b81dSJeremy L Thompson         QFunctionOpt::SomeQFunctionByName(&qf_mass_named)
215ded9b81dSJeremy L Thompson     } else {
216ded9b81dSJeremy L Thompson         QFunctionOpt::SomeQFunction(&qf_mass_closure)
217ded9b81dSJeremy L Thompson     };
218ded9b81dSJeremy L Thompson 
219ded9b81dSJeremy L Thompson     // Mass Operator
220ded9b81dSJeremy L Thompson     let op_mass = ceed
221e15f9bd0SJeremy L Thompson         .operator(qf_mass, QFunctionOpt::None, QFunctionOpt::None)?
222ea6b5821SJeremy L Thompson         .name("mass")?
223edb2538eSJeremy L Thompson         .field("u", &rstr_solution, &basis_solution, VectorOpt::Active)?
224edb2538eSJeremy L Thompson         .field("qdata", &rstr_qdata, BasisOpt::None, &qdata)?
225edb2538eSJeremy L Thompson         .field("v", &rstr_solution, &basis_solution, VectorOpt::Active)?
2266f97ff0aSJeremy L Thompson         .check()?;
227ded9b81dSJeremy L Thompson 
228ded9b81dSJeremy L Thompson     // Solution vectors
229e15f9bd0SJeremy L Thompson     let u = ceed.vector_from_slice(&vec![1.0; solution_size])?;
230e15f9bd0SJeremy L Thompson     let mut v = ceed.vector(solution_size)?;
231ded9b81dSJeremy L Thompson 
232ded9b81dSJeremy L Thompson     // Apply the mass operator
233e15f9bd0SJeremy L Thompson     op_mass.apply(&u, &mut v)?;
234ded9b81dSJeremy L Thompson 
235ded9b81dSJeremy L Thompson     // Compute the mesh volume
236e78171edSJeremy L Thompson     let volume: Scalar = v.view()?.iter().sum();
237ded9b81dSJeremy L Thompson 
238ded9b81dSJeremy L Thompson     // Output results
239ded9b81dSJeremy L Thompson     if !quiet {
240ded9b81dSJeremy L Thompson         println!("Exact mesh volume           : {:.12}", exact_volume);
241ded9b81dSJeremy L Thompson         println!("Computed mesh volume        : {:.12}", volume);
242ded9b81dSJeremy L Thompson         println!(
243ded9b81dSJeremy L Thompson             "Volume error                : {:.12e}",
244ded9b81dSJeremy L Thompson             volume - exact_volume
245ded9b81dSJeremy L Thompson         );
246ded9b81dSJeremy L Thompson     }
247ded9b81dSJeremy L Thompson     let tolerance = match dim {
2482247a93fSRezgar Shakeri         1 => 500.0 * libceed::EPSILON,
249ded9b81dSJeremy L Thompson         _ => 1E-5,
250ded9b81dSJeremy L Thompson     };
251ded9b81dSJeremy L Thompson     let error = (volume - exact_volume).abs();
252ded9b81dSJeremy L Thompson     if error > tolerance {
253ded9b81dSJeremy L Thompson         println!("Volume error too large: {:.12e}", error);
2542ba8e59cSJeremy L Thompson         return Err(libceed::Error {
255e15f9bd0SJeremy L Thompson             message: format!(
256ded9b81dSJeremy L Thompson                 "Volume error too large - expected: {:.12e}, actual: {:.12e}",
257ded9b81dSJeremy L Thompson                 tolerance, error
258e15f9bd0SJeremy L Thompson             ),
259e15f9bd0SJeremy L Thompson         });
260ded9b81dSJeremy L Thompson     }
261ded9b81dSJeremy L Thompson     Ok(())
262ded9b81dSJeremy L Thompson }
263ded9b81dSJeremy L Thompson 
264ded9b81dSJeremy L Thompson // ----------------------------------------------------------------------------
265ded9b81dSJeremy L Thompson // Tests
266ded9b81dSJeremy L Thompson // ----------------------------------------------------------------------------
267ded9b81dSJeremy L Thompson #[cfg(test)]
268ded9b81dSJeremy L Thompson mod tests {
269ded9b81dSJeremy L Thompson     use super::*;
270ded9b81dSJeremy L Thompson 
271ded9b81dSJeremy L Thompson     #[test]
272ded9b81dSJeremy L Thompson     fn example_1_1d() {
273ded9b81dSJeremy L Thompson         let options = opt::Opt {
274ded9b81dSJeremy L Thompson             ceed_spec: "/cpu/self/ref/serial".to_string(),
275ded9b81dSJeremy L Thompson             dim: 1,
276ded9b81dSJeremy L Thompson             mesh_degree: 4,
277ded9b81dSJeremy L Thompson             solution_degree: 4,
278ded9b81dSJeremy L Thompson             num_qpts: 6,
279ded9b81dSJeremy L Thompson             problem_size_requested: -1,
280ded9b81dSJeremy L Thompson             test: true,
281ded9b81dSJeremy L Thompson             quiet: true,
282ded9b81dSJeremy L Thompson             gallery: false,
283ded9b81dSJeremy L Thompson         };
284ded9b81dSJeremy L Thompson         assert!(example_1(options).is_ok());
285ded9b81dSJeremy L Thompson     }
286ded9b81dSJeremy L Thompson 
287ded9b81dSJeremy L Thompson     #[test]
288ded9b81dSJeremy L Thompson     fn example_1_2d() {
289ded9b81dSJeremy L Thompson         let options = opt::Opt {
290ded9b81dSJeremy L Thompson             ceed_spec: "/cpu/self/ref/serial".to_string(),
291ded9b81dSJeremy L Thompson             dim: 2,
292ded9b81dSJeremy L Thompson             mesh_degree: 4,
293ded9b81dSJeremy L Thompson             solution_degree: 4,
294ded9b81dSJeremy L Thompson             num_qpts: 6,
295ded9b81dSJeremy L Thompson             problem_size_requested: -1,
296ded9b81dSJeremy L Thompson             test: true,
297ded9b81dSJeremy L Thompson             quiet: true,
298ded9b81dSJeremy L Thompson             gallery: false,
299ded9b81dSJeremy L Thompson         };
300ded9b81dSJeremy L Thompson         assert!(example_1(options).is_ok());
301ded9b81dSJeremy L Thompson     }
302ded9b81dSJeremy L Thompson 
303ded9b81dSJeremy L Thompson     #[test]
304ded9b81dSJeremy L Thompson     fn example_1_3d() {
305ded9b81dSJeremy L Thompson         let options = opt::Opt {
306ded9b81dSJeremy L Thompson             ceed_spec: "/cpu/self/ref/serial".to_string(),
307ded9b81dSJeremy L Thompson             dim: 3,
308ded9b81dSJeremy L Thompson             mesh_degree: 4,
309ded9b81dSJeremy L Thompson             solution_degree: 4,
310ded9b81dSJeremy L Thompson             num_qpts: 6,
311ded9b81dSJeremy L Thompson             problem_size_requested: -1,
312ded9b81dSJeremy L Thompson             test: true,
313954a6033SJeremy L Thompson             quiet: false,
314ded9b81dSJeremy L Thompson             gallery: false,
315ded9b81dSJeremy L Thompson         };
316ded9b81dSJeremy L Thompson         assert!(example_1(options).is_ok());
317ded9b81dSJeremy L Thompson     }
318ded9b81dSJeremy L Thompson 
319ded9b81dSJeremy L Thompson     #[test]
320ded9b81dSJeremy L Thompson     fn example_1_1d_gallery() {
321ded9b81dSJeremy L Thompson         let options = opt::Opt {
322ded9b81dSJeremy L Thompson             ceed_spec: "/cpu/self/ref/serial".to_string(),
323ded9b81dSJeremy L Thompson             dim: 1,
324ded9b81dSJeremy L Thompson             mesh_degree: 4,
325ded9b81dSJeremy L Thompson             solution_degree: 4,
326ded9b81dSJeremy L Thompson             num_qpts: 6,
327ded9b81dSJeremy L Thompson             problem_size_requested: -1,
328ded9b81dSJeremy L Thompson             test: true,
329ded9b81dSJeremy L Thompson             quiet: true,
330ded9b81dSJeremy L Thompson             gallery: true,
331ded9b81dSJeremy L Thompson         };
332ded9b81dSJeremy L Thompson         assert!(example_1(options).is_ok());
333ded9b81dSJeremy L Thompson     }
334ded9b81dSJeremy L Thompson 
335ded9b81dSJeremy L Thompson     #[test]
336ded9b81dSJeremy L Thompson     fn example_1_2d_gallery() {
337ded9b81dSJeremy L Thompson         let options = opt::Opt {
338ded9b81dSJeremy L Thompson             ceed_spec: "/cpu/self/ref/serial".to_string(),
339ded9b81dSJeremy L Thompson             dim: 2,
340ded9b81dSJeremy L Thompson             mesh_degree: 4,
341ded9b81dSJeremy L Thompson             solution_degree: 4,
342ded9b81dSJeremy L Thompson             num_qpts: 6,
343ded9b81dSJeremy L Thompson             problem_size_requested: -1,
344ded9b81dSJeremy L Thompson             test: true,
345ded9b81dSJeremy L Thompson             quiet: true,
346ded9b81dSJeremy L Thompson             gallery: true,
347ded9b81dSJeremy L Thompson         };
348ded9b81dSJeremy L Thompson         assert!(example_1(options).is_ok());
349ded9b81dSJeremy L Thompson     }
350ded9b81dSJeremy L Thompson 
351ded9b81dSJeremy L Thompson     #[test]
352ded9b81dSJeremy L Thompson     fn example_1_3d_gallery() {
353ded9b81dSJeremy L Thompson         let options = opt::Opt {
354ded9b81dSJeremy L Thompson             ceed_spec: "/cpu/self/ref/serial".to_string(),
355ded9b81dSJeremy L Thompson             dim: 3,
356ded9b81dSJeremy L Thompson             mesh_degree: 4,
357ded9b81dSJeremy L Thompson             solution_degree: 4,
358ded9b81dSJeremy L Thompson             num_qpts: 6,
359ded9b81dSJeremy L Thompson             problem_size_requested: -1,
360ded9b81dSJeremy L Thompson             test: true,
361ded9b81dSJeremy L Thompson             quiet: true,
362ded9b81dSJeremy L Thompson             gallery: true,
363ded9b81dSJeremy L Thompson         };
364ded9b81dSJeremy L Thompson         assert!(example_1(options).is_ok());
365ded9b81dSJeremy L Thompson     }
366ded9b81dSJeremy L Thompson }
367ded9b81dSJeremy L Thompson 
368ded9b81dSJeremy L Thompson // ----------------------------------------------------------------------------
369