xref: /libCEED/examples/rust/ex1-volume/src/main.rs (revision ea6b58218a3c4883c2efd66165b4d6b684f89f5a)
13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, 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 
21ded9b81dSJeremy L Thompson use libceed::{prelude::*, Ceed};
22ded9b81dSJeremy L Thompson use mesh;
23ded9b81dSJeremy L Thompson use structopt::StructOpt;
24ded9b81dSJeremy L Thompson 
25ded9b81dSJeremy L Thompson mod opt;
26ded9b81dSJeremy L Thompson mod transform;
27ded9b81dSJeremy L Thompson 
28ded9b81dSJeremy L Thompson // ----------------------------------------------------------------------------
29ded9b81dSJeremy L Thompson // Example 1
30ded9b81dSJeremy L Thompson // ----------------------------------------------------------------------------
31954a6033SJeremy L Thompson #[cfg(not(tarpaulin_include))]
3289d15d5fSJeremy L Thompson fn main() -> libceed::Result<()> {
33ded9b81dSJeremy L Thompson     let options = opt::Opt::from_args();
34ded9b81dSJeremy L Thompson     example_1(options)
35ded9b81dSJeremy L Thompson }
36ded9b81dSJeremy L Thompson 
3789d15d5fSJeremy L Thompson fn example_1(options: opt::Opt) -> libceed::Result<()> {
38ded9b81dSJeremy L Thompson     // Process command line arguments
39ded9b81dSJeremy L Thompson     let opt::Opt {
40ded9b81dSJeremy L Thompson         ceed_spec,
41ded9b81dSJeremy L Thompson         dim,
42ded9b81dSJeremy L Thompson         mesh_degree,
43ded9b81dSJeremy L Thompson         solution_degree,
44ded9b81dSJeremy L Thompson         num_qpts,
45ded9b81dSJeremy L Thompson         problem_size_requested,
46ded9b81dSJeremy L Thompson         test,
47ded9b81dSJeremy L Thompson         quiet,
48ded9b81dSJeremy L Thompson         gallery,
49ded9b81dSJeremy L Thompson     } = options;
50ded9b81dSJeremy L Thompson     assert!(dim >= 1 && dim <= 3);
51ded9b81dSJeremy L Thompson     assert!(mesh_degree >= 1);
52ded9b81dSJeremy L Thompson     assert!(solution_degree >= 1);
53ded9b81dSJeremy L Thompson     assert!(num_qpts >= 1);
54ded9b81dSJeremy L Thompson     let ncomp_x = dim;
55ded9b81dSJeremy L Thompson     let problem_size: i64;
56ded9b81dSJeremy L Thompson     if problem_size_requested < 0 {
57ded9b81dSJeremy L Thompson         problem_size = if test { 8 * 16 } else { 256 * 1024 };
58ded9b81dSJeremy L Thompson     } else {
59ded9b81dSJeremy L Thompson         problem_size = problem_size_requested;
60ded9b81dSJeremy L Thompson     }
61ded9b81dSJeremy L Thompson 
62ded9b81dSJeremy L Thompson     // Summary output
63ded9b81dSJeremy L Thompson     if !quiet {
64ded9b81dSJeremy L Thompson         println!("Selected options: [command line option] : <current value>");
65ded9b81dSJeremy L Thompson         println!("    Ceed specification [-c] : {}", ceed_spec);
66ded9b81dSJeremy L Thompson         println!("    Mesh dimension     [-d] : {}", dim);
67ded9b81dSJeremy L Thompson         println!("    Mesh degree        [-m] : {}", mesh_degree);
68ded9b81dSJeremy L Thompson         println!("    Solution degree    [-p] : {}", solution_degree);
69ded9b81dSJeremy L Thompson         println!("    Num. 1D quadr. pts [-q] : {}", num_qpts);
70ded9b81dSJeremy L Thompson         println!("    Approx. # unknowns [-s] : {}", problem_size);
71ded9b81dSJeremy L Thompson         println!(
72ded9b81dSJeremy L Thompson             "    QFunction source   [-g] : {}",
73ded9b81dSJeremy L Thompson             if gallery { "gallery" } else { "user closure" }
74ded9b81dSJeremy L Thompson         );
75ded9b81dSJeremy L Thompson     }
76ded9b81dSJeremy L Thompson 
77ded9b81dSJeremy L Thompson     // Initalize ceed context
78ded9b81dSJeremy L Thompson     let ceed = Ceed::init(&ceed_spec);
79ded9b81dSJeremy L Thompson 
80ded9b81dSJeremy L Thompson     // Mesh and solution bases
8151d03428SJeremy L Thompson     let basis_mesh =
8251d03428SJeremy L Thompson         ceed.basis_tensor_H1_Lagrange(dim, ncomp_x, mesh_degree + 1, num_qpts, QuadMode::Gauss)?;
8351d03428SJeremy L Thompson     let basis_solution =
8451d03428SJeremy L Thompson         ceed.basis_tensor_H1_Lagrange(dim, 1, solution_degree + 1, num_qpts, QuadMode::Gauss)?;
85ded9b81dSJeremy L Thompson 
86ded9b81dSJeremy L Thompson     // Determine mesh size from approximate problem size
87ded9b81dSJeremy L Thompson     let num_xyz = mesh::cartesian_mesh_size(dim, solution_degree, problem_size);
88ded9b81dSJeremy L Thompson     if !quiet {
89ded9b81dSJeremy L Thompson         print!("\nMesh size                   : nx = {}", num_xyz[0]);
90ded9b81dSJeremy L Thompson         if dim > 1 {
91ded9b81dSJeremy L Thompson             print!(", ny = {}", num_xyz[1]);
92ded9b81dSJeremy L Thompson         }
93ded9b81dSJeremy L Thompson         if dim > 2 {
94ded9b81dSJeremy L Thompson             print!(", nz = {}", num_xyz[2]);
95ded9b81dSJeremy L Thompson         }
96ded9b81dSJeremy L Thompson         print!("\n");
97ded9b81dSJeremy L Thompson     }
98ded9b81dSJeremy L Thompson 
99ded9b81dSJeremy L Thompson     // Build ElemRestriction objects describing the mesh and solution discrete
100ded9b81dSJeremy L Thompson     // representations
101ded9b81dSJeremy L Thompson     let (restr_mesh, _) =
102e15f9bd0SJeremy L Thompson         mesh::build_cartesian_restriction(&ceed, dim, num_xyz, mesh_degree, ncomp_x, num_qpts)?;
103ded9b81dSJeremy L Thompson     let (restr_solution, restr_qdata) =
104e15f9bd0SJeremy L Thompson         mesh::build_cartesian_restriction(&ceed, dim, num_xyz, solution_degree, 1, num_qpts)?;
105ded9b81dSJeremy L Thompson     let mesh_size = restr_mesh.lvector_size();
106ded9b81dSJeremy L Thompson     let solution_size = restr_solution.lvector_size();
107ded9b81dSJeremy L Thompson     if !quiet {
108ded9b81dSJeremy L Thompson         println!("Number of mesh nodes        : {}", mesh_size / dim);
109ded9b81dSJeremy L Thompson         println!("Number of solution nodes    : {}", solution_size);
110ded9b81dSJeremy L Thompson     }
111ded9b81dSJeremy L Thompson 
112ded9b81dSJeremy L Thompson     // Create a Vector with the mesh coordinates
113e15f9bd0SJeremy L Thompson     let mut mesh_coords = mesh::cartesian_mesh_coords(&ceed, dim, num_xyz, mesh_degree, mesh_size)?;
114ded9b81dSJeremy L Thompson 
115ded9b81dSJeremy L Thompson     // Apply a transformation to the mesh coordinates
116e78171edSJeremy L Thompson     let exact_volume = transform::transform_mesh_coordinates(dim, mesh_size, &mut mesh_coords)?;
117ded9b81dSJeremy L Thompson 
118ded9b81dSJeremy L Thompson     // QFunction that builds the quadrature data for the mass operator
119ded9b81dSJeremy L Thompson     // -- QFunction from user closure
120ded9b81dSJeremy L Thompson     let build_mass = move |[jacobian, weights, ..]: QFunctionInputs,
121ded9b81dSJeremy L Thompson                            [qdata, ..]: QFunctionOutputs| {
122ded9b81dSJeremy L Thompson         // Build quadrature data
123ded9b81dSJeremy L Thompson         match dim {
124ded9b81dSJeremy L Thompson             1 => qdata
125ded9b81dSJeremy L Thompson                 .iter_mut()
126ded9b81dSJeremy L Thompson                 .zip(jacobian.iter().zip(weights.iter()))
127ded9b81dSJeremy L Thompson                 .for_each(|(qdata, (j, weight))| *qdata = j * weight),
128ded9b81dSJeremy L Thompson             2 => {
129ded9b81dSJeremy L Thompson                 let q = qdata.len();
130ded9b81dSJeremy L Thompson                 qdata.iter_mut().zip(weights.iter()).enumerate().for_each(
131ded9b81dSJeremy L Thompson                     |(i, (qdata, weight))| {
132ded9b81dSJeremy L Thompson                         *qdata = (jacobian[i + q * 0] * jacobian[i + q * 3]
133ded9b81dSJeremy L Thompson                             - jacobian[i + q * 1] * jacobian[i + q * 2])
134ded9b81dSJeremy L Thompson                             * weight
135ded9b81dSJeremy L Thompson                     },
136ded9b81dSJeremy L Thompson                 );
137ded9b81dSJeremy L Thompson             }
138ded9b81dSJeremy L Thompson             3 => {
139ded9b81dSJeremy L Thompson                 let q = qdata.len();
140ded9b81dSJeremy L Thompson                 qdata.iter_mut().zip(weights.iter()).enumerate().for_each(
141ded9b81dSJeremy L Thompson                     |(i, (qdata, weight))| {
142ded9b81dSJeremy L Thompson                         *qdata = (jacobian[i + q * 0]
143ded9b81dSJeremy L Thompson                             * (jacobian[i + q * 4] * jacobian[i + q * 8]
144ded9b81dSJeremy L Thompson                                 - jacobian[i + q * 5] * jacobian[i + q * 7])
145ded9b81dSJeremy L Thompson                             - jacobian[i + q * 1]
146ded9b81dSJeremy L Thompson                                 * (jacobian[i + q * 3] * jacobian[i + q * 8]
147ded9b81dSJeremy L Thompson                                     - jacobian[i + q * 5] * jacobian[i + q * 6])
148ded9b81dSJeremy L Thompson                             + jacobian[i + q * 2]
149ded9b81dSJeremy L Thompson                                 * (jacobian[i + q * 3] * jacobian[i + q * 7]
150ded9b81dSJeremy L Thompson                                     - jacobian[i + q * 4] * jacobian[i + q * 6]))
151ded9b81dSJeremy L Thompson                             * weight
152ded9b81dSJeremy L Thompson                     },
153ded9b81dSJeremy L Thompson                 );
154ded9b81dSJeremy L Thompson             }
155ded9b81dSJeremy L Thompson             _ => unreachable!(),
156ded9b81dSJeremy L Thompson         };
157ded9b81dSJeremy L Thompson 
158ded9b81dSJeremy L Thompson         // Return clean error code
159ded9b81dSJeremy L Thompson         0
160ded9b81dSJeremy L Thompson     };
161ded9b81dSJeremy L Thompson     let qf_build_closure = ceed
162e15f9bd0SJeremy L Thompson         .q_function_interior(1, Box::new(build_mass))?
163e15f9bd0SJeremy L Thompson         .input("dx", ncomp_x * dim, EvalMode::Grad)?
164e15f9bd0SJeremy L Thompson         .input("weights", 1, EvalMode::Weight)?
165e15f9bd0SJeremy L Thompson         .output("qdata", 1, EvalMode::None)?;
166ded9b81dSJeremy L Thompson     // -- QFunction from gallery
167ded9b81dSJeremy L Thompson     let qf_build_named = {
168ded9b81dSJeremy L Thompson         let name = format!("Mass{}DBuild", dim);
169e15f9bd0SJeremy L Thompson         ceed.q_function_interior_by_name(&name)?
170ded9b81dSJeremy L Thompson     };
171ded9b81dSJeremy L Thompson     // -- QFunction for use with Operator
172ded9b81dSJeremy L Thompson     let qf_build = if gallery {
173ded9b81dSJeremy L Thompson         QFunctionOpt::SomeQFunctionByName(&qf_build_named)
174ded9b81dSJeremy L Thompson     } else {
175ded9b81dSJeremy L Thompson         QFunctionOpt::SomeQFunction(&qf_build_closure)
176ded9b81dSJeremy L Thompson     };
177ded9b81dSJeremy L Thompson 
178ded9b81dSJeremy L Thompson     // Operator that build the quadrature data for the mass operator
179ded9b81dSJeremy L Thompson     let op_build = ceed
180e15f9bd0SJeremy L Thompson         .operator(qf_build, QFunctionOpt::None, QFunctionOpt::None)?
181*ea6b5821SJeremy L Thompson         .name("build qdata")?
182e15f9bd0SJeremy L Thompson         .field("dx", &restr_mesh, &basis_mesh, VectorOpt::Active)?
183ded9b81dSJeremy L Thompson         .field(
184ded9b81dSJeremy L Thompson             "weights",
185ded9b81dSJeremy L Thompson             ElemRestrictionOpt::None,
186ded9b81dSJeremy L Thompson             &basis_mesh,
187ded9b81dSJeremy L Thompson             VectorOpt::None,
188e15f9bd0SJeremy L Thompson         )?
189ded9b81dSJeremy L Thompson         .field(
190ded9b81dSJeremy L Thompson             "qdata",
191ded9b81dSJeremy L Thompson             &restr_qdata,
192ded9b81dSJeremy L Thompson             BasisOpt::Collocated,
193ded9b81dSJeremy L Thompson             VectorOpt::Active,
1946f97ff0aSJeremy L Thompson         )?
1956f97ff0aSJeremy L Thompson         .check()?;
196ded9b81dSJeremy L Thompson 
197ded9b81dSJeremy L Thompson     // Compute the quadrature data for the mass operator
198ded9b81dSJeremy L Thompson     let elem_qpts = num_qpts.pow(dim as u32);
199ded9b81dSJeremy L Thompson     let num_elem: usize = num_xyz.iter().take(dim).product();
200e15f9bd0SJeremy L Thompson     let mut qdata = ceed.vector(num_elem * elem_qpts)?;
201e15f9bd0SJeremy L Thompson     op_build.apply(&mesh_coords, &mut qdata)?;
202ded9b81dSJeremy L Thompson 
203ded9b81dSJeremy L Thompson     // QFunction that applies the mass operator
204ded9b81dSJeremy L Thompson     // -- QFunction from user closure
205ded9b81dSJeremy L Thompson     let apply_mass = |[u, qdata, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| {
206ded9b81dSJeremy L Thompson         // Apply mass operator
207ded9b81dSJeremy L Thompson         v.iter_mut()
208ded9b81dSJeremy L Thompson             .zip(u.iter().zip(qdata.iter()))
209ded9b81dSJeremy L Thompson             .for_each(|(v, (u, w))| *v = u * w);
210ded9b81dSJeremy L Thompson         // Return clean error code
211ded9b81dSJeremy L Thompson         0
212ded9b81dSJeremy L Thompson     };
213ded9b81dSJeremy L Thompson     let qf_mass_closure = ceed
214e15f9bd0SJeremy L Thompson         .q_function_interior(1, Box::new(apply_mass))?
215e15f9bd0SJeremy L Thompson         .input("u", 1, EvalMode::Interp)?
216e15f9bd0SJeremy L Thompson         .input("qdata", 1, EvalMode::None)?
217e15f9bd0SJeremy L Thompson         .output("v", 1, EvalMode::Interp)?;
218ded9b81dSJeremy L Thompson     // -- QFunction from gallery
219e15f9bd0SJeremy L Thompson     let qf_mass_named = ceed.q_function_interior_by_name("MassApply")?;
220ded9b81dSJeremy L Thompson     // -- QFunction for use with Operator
221ded9b81dSJeremy L Thompson     let qf_mass = if gallery {
222ded9b81dSJeremy L Thompson         QFunctionOpt::SomeQFunctionByName(&qf_mass_named)
223ded9b81dSJeremy L Thompson     } else {
224ded9b81dSJeremy L Thompson         QFunctionOpt::SomeQFunction(&qf_mass_closure)
225ded9b81dSJeremy L Thompson     };
226ded9b81dSJeremy L Thompson 
227ded9b81dSJeremy L Thompson     // Mass Operator
228ded9b81dSJeremy L Thompson     let op_mass = ceed
229e15f9bd0SJeremy L Thompson         .operator(qf_mass, QFunctionOpt::None, QFunctionOpt::None)?
230*ea6b5821SJeremy L Thompson         .name("mass")?
231e15f9bd0SJeremy L Thompson         .field("u", &restr_solution, &basis_solution, VectorOpt::Active)?
232e15f9bd0SJeremy L Thompson         .field("qdata", &restr_qdata, BasisOpt::Collocated, &qdata)?
2336f97ff0aSJeremy L Thompson         .field("v", &restr_solution, &basis_solution, VectorOpt::Active)?
2346f97ff0aSJeremy L Thompson         .check()?;
235ded9b81dSJeremy L Thompson 
236ded9b81dSJeremy L Thompson     // Solution vectors
237e15f9bd0SJeremy L Thompson     let u = ceed.vector_from_slice(&vec![1.0; solution_size])?;
238e15f9bd0SJeremy L Thompson     let mut v = ceed.vector(solution_size)?;
239ded9b81dSJeremy L Thompson 
240ded9b81dSJeremy L Thompson     // Apply the mass operator
241e15f9bd0SJeremy L Thompson     op_mass.apply(&u, &mut v)?;
242ded9b81dSJeremy L Thompson 
243ded9b81dSJeremy L Thompson     // Compute the mesh volume
244e78171edSJeremy L Thompson     let volume: Scalar = v.view()?.iter().sum();
245ded9b81dSJeremy L Thompson 
246ded9b81dSJeremy L Thompson     // Output results
247ded9b81dSJeremy L Thompson     if !quiet {
248ded9b81dSJeremy L Thompson         println!("Exact mesh volume           : {:.12}", exact_volume);
249ded9b81dSJeremy L Thompson         println!("Computed mesh volume        : {:.12}", volume);
250ded9b81dSJeremy L Thompson         println!(
251ded9b81dSJeremy L Thompson             "Volume error                : {:.12e}",
252ded9b81dSJeremy L Thompson             volume - exact_volume
253ded9b81dSJeremy L Thompson         );
254ded9b81dSJeremy L Thompson     }
255ded9b81dSJeremy L Thompson     let tolerance = match dim {
25680a9ef05SNatalie Beams         1 => 100.0 * libceed::EPSILON,
257ded9b81dSJeremy L Thompson         _ => 1E-5,
258ded9b81dSJeremy L Thompson     };
259ded9b81dSJeremy L Thompson     let error = (volume - exact_volume).abs();
260ded9b81dSJeremy L Thompson     if error > tolerance {
261ded9b81dSJeremy L Thompson         println!("Volume error too large: {:.12e}", error);
2622ba8e59cSJeremy L Thompson         return Err(libceed::Error {
263e15f9bd0SJeremy L Thompson             message: format!(
264ded9b81dSJeremy L Thompson                 "Volume error too large - expected: {:.12e}, actual: {:.12e}",
265ded9b81dSJeremy L Thompson                 tolerance, error
266e15f9bd0SJeremy L Thompson             ),
267e15f9bd0SJeremy L Thompson         });
268ded9b81dSJeremy L Thompson     }
269ded9b81dSJeremy L Thompson     Ok(())
270ded9b81dSJeremy L Thompson }
271ded9b81dSJeremy L Thompson 
272ded9b81dSJeremy L Thompson // ----------------------------------------------------------------------------
273ded9b81dSJeremy L Thompson // Tests
274ded9b81dSJeremy L Thompson // ----------------------------------------------------------------------------
275ded9b81dSJeremy L Thompson #[cfg(test)]
276ded9b81dSJeremy L Thompson mod tests {
277ded9b81dSJeremy L Thompson     use super::*;
278ded9b81dSJeremy L Thompson 
279ded9b81dSJeremy L Thompson     #[test]
280ded9b81dSJeremy L Thompson     fn example_1_1d() {
281ded9b81dSJeremy L Thompson         let options = opt::Opt {
282ded9b81dSJeremy L Thompson             ceed_spec: "/cpu/self/ref/serial".to_string(),
283ded9b81dSJeremy L Thompson             dim: 1,
284ded9b81dSJeremy L Thompson             mesh_degree: 4,
285ded9b81dSJeremy L Thompson             solution_degree: 4,
286ded9b81dSJeremy L Thompson             num_qpts: 6,
287ded9b81dSJeremy L Thompson             problem_size_requested: -1,
288ded9b81dSJeremy L Thompson             test: true,
289ded9b81dSJeremy L Thompson             quiet: true,
290ded9b81dSJeremy L Thompson             gallery: false,
291ded9b81dSJeremy L Thompson         };
292ded9b81dSJeremy L Thompson         assert!(example_1(options).is_ok());
293ded9b81dSJeremy L Thompson     }
294ded9b81dSJeremy L Thompson 
295ded9b81dSJeremy L Thompson     #[test]
296ded9b81dSJeremy L Thompson     fn example_1_2d() {
297ded9b81dSJeremy L Thompson         let options = opt::Opt {
298ded9b81dSJeremy L Thompson             ceed_spec: "/cpu/self/ref/serial".to_string(),
299ded9b81dSJeremy L Thompson             dim: 2,
300ded9b81dSJeremy L Thompson             mesh_degree: 4,
301ded9b81dSJeremy L Thompson             solution_degree: 4,
302ded9b81dSJeremy L Thompson             num_qpts: 6,
303ded9b81dSJeremy L Thompson             problem_size_requested: -1,
304ded9b81dSJeremy L Thompson             test: true,
305ded9b81dSJeremy L Thompson             quiet: true,
306ded9b81dSJeremy L Thompson             gallery: false,
307ded9b81dSJeremy L Thompson         };
308ded9b81dSJeremy L Thompson         assert!(example_1(options).is_ok());
309ded9b81dSJeremy L Thompson     }
310ded9b81dSJeremy L Thompson 
311ded9b81dSJeremy L Thompson     #[test]
312ded9b81dSJeremy L Thompson     fn example_1_3d() {
313ded9b81dSJeremy L Thompson         let options = opt::Opt {
314ded9b81dSJeremy L Thompson             ceed_spec: "/cpu/self/ref/serial".to_string(),
315ded9b81dSJeremy L Thompson             dim: 3,
316ded9b81dSJeremy L Thompson             mesh_degree: 4,
317ded9b81dSJeremy L Thompson             solution_degree: 4,
318ded9b81dSJeremy L Thompson             num_qpts: 6,
319ded9b81dSJeremy L Thompson             problem_size_requested: -1,
320ded9b81dSJeremy L Thompson             test: true,
321954a6033SJeremy L Thompson             quiet: false,
322ded9b81dSJeremy L Thompson             gallery: false,
323ded9b81dSJeremy L Thompson         };
324ded9b81dSJeremy L Thompson         assert!(example_1(options).is_ok());
325ded9b81dSJeremy L Thompson     }
326ded9b81dSJeremy L Thompson 
327ded9b81dSJeremy L Thompson     #[test]
328ded9b81dSJeremy L Thompson     fn example_1_1d_gallery() {
329ded9b81dSJeremy L Thompson         let options = opt::Opt {
330ded9b81dSJeremy L Thompson             ceed_spec: "/cpu/self/ref/serial".to_string(),
331ded9b81dSJeremy L Thompson             dim: 1,
332ded9b81dSJeremy L Thompson             mesh_degree: 4,
333ded9b81dSJeremy L Thompson             solution_degree: 4,
334ded9b81dSJeremy L Thompson             num_qpts: 6,
335ded9b81dSJeremy L Thompson             problem_size_requested: -1,
336ded9b81dSJeremy L Thompson             test: true,
337ded9b81dSJeremy L Thompson             quiet: true,
338ded9b81dSJeremy L Thompson             gallery: true,
339ded9b81dSJeremy L Thompson         };
340ded9b81dSJeremy L Thompson         assert!(example_1(options).is_ok());
341ded9b81dSJeremy L Thompson     }
342ded9b81dSJeremy L Thompson 
343ded9b81dSJeremy L Thompson     #[test]
344ded9b81dSJeremy L Thompson     fn example_1_2d_gallery() {
345ded9b81dSJeremy L Thompson         let options = opt::Opt {
346ded9b81dSJeremy L Thompson             ceed_spec: "/cpu/self/ref/serial".to_string(),
347ded9b81dSJeremy L Thompson             dim: 2,
348ded9b81dSJeremy L Thompson             mesh_degree: 4,
349ded9b81dSJeremy L Thompson             solution_degree: 4,
350ded9b81dSJeremy L Thompson             num_qpts: 6,
351ded9b81dSJeremy L Thompson             problem_size_requested: -1,
352ded9b81dSJeremy L Thompson             test: true,
353ded9b81dSJeremy L Thompson             quiet: true,
354ded9b81dSJeremy L Thompson             gallery: true,
355ded9b81dSJeremy L Thompson         };
356ded9b81dSJeremy L Thompson         assert!(example_1(options).is_ok());
357ded9b81dSJeremy L Thompson     }
358ded9b81dSJeremy L Thompson 
359ded9b81dSJeremy L Thompson     #[test]
360ded9b81dSJeremy L Thompson     fn example_1_3d_gallery() {
361ded9b81dSJeremy L Thompson         let options = opt::Opt {
362ded9b81dSJeremy L Thompson             ceed_spec: "/cpu/self/ref/serial".to_string(),
363ded9b81dSJeremy L Thompson             dim: 3,
364ded9b81dSJeremy L Thompson             mesh_degree: 4,
365ded9b81dSJeremy L Thompson             solution_degree: 4,
366ded9b81dSJeremy L Thompson             num_qpts: 6,
367ded9b81dSJeremy L Thompson             problem_size_requested: -1,
368ded9b81dSJeremy L Thompson             test: true,
369ded9b81dSJeremy L Thompson             quiet: true,
370ded9b81dSJeremy L Thompson             gallery: true,
371ded9b81dSJeremy L Thompson         };
372ded9b81dSJeremy L Thompson         assert!(example_1(options).is_ok());
373ded9b81dSJeremy L Thompson     }
374ded9b81dSJeremy L Thompson }
375ded9b81dSJeremy L Thompson 
376ded9b81dSJeremy L Thompson // ----------------------------------------------------------------------------
377