Debian Codegraph @

packages/trilinoscouplings/examples/scaling/TrilinosCouplings_IntrepidPoissonExampleHelpers.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Trilinos: An Object-Oriented Solver Framework
4 //
5 // Copyright 2001-2024 NTESS and the Trilinos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef __TrilinosCouplings_IntrepidPoissonExampleHelpers_hpp
11 #define __TrilinosCouplings_IntrepidPoissonExampleHelpers_hpp
12
13 /// \file TrilinosCouplings_IntrepidPoissonExampleHelpers.hpp
14 /// \brief Helper functions for Poisson test problem with Intrepid + Pamgen.
15 ///
16 /// This directory contains two versions of a Poisson test problem
17 /// that uses Intrepid to generate a finite element discretization on
18 /// a Pamgen-generated mesh. One version uses Epetra, and the other
19 /// uses Tpetra. This header file contains utility functions that are
20 /// useful for both versions.
21
22 #include <Teuchos_CommandLineProcessor.hpp>
23 #include <string>
24
25
26 namespace TrilinosCouplings {
27 /// \namespace IntrepidPoissonExample
28 /// \brief Intrepid Poisson test problem example: common functionality.
29 ///
30 /// The Intrepid Poisson test problem uses Pamgen to construct a 3-D
31 /// mesh (a simple rectangular prism with hex elements) in parallel,
32 /// Sacado automatic differentiation to construct a right-hand side of
33 /// the PDE corresponding to a given exact solution, and Intrepid to
34 /// build a discretization.
35 ///
36 /// We provide two variants of the Intrepid Poisson test: one that
37 /// fills Epetra objects, and one that fills Tpetra objects. The two
38 /// variants do exactly the same things otherwise, so you can use them
39 /// to compare the performance of Epetra and Tpetra fill.
40 ///
41 /// This namespace contains functions which both variants can share,
42 /// because they do not depend on Epetra or Tpetra. You can include
43 /// this file in your main() test driver in order to set up and read
44 /// in command-line arguments, and prepare the Pamgen mesh
45 /// specification.
46 namespace IntrepidPoissonExample {
47
48 /// \brief Get off-diagonal value for material tensor.
49 ///
50 /// You can use this value to control the iteration count. See the
51 /// documentation of setMaterialTensorOffDiagonalValue() below for
52 /// examples.
53 ///
54 /// This value has to be a double, because we read it from the command
55 /// line; Teuchos' facility for this stores floating-point values as
56 /// double.
57 double getMaterialTensorOffDiagonalValue ();
58
59 /// \brief Set off-diagonal value for material tensor.
60 ///
61 /// You can use this value to control the iteration count. The
62 /// iteration counts below are for Belos' GMRES with no
63 /// preconditioning, using the default problem size.
64 ///
65 /// newVal = -5/4: 209 iterations (CG breaks!)
66 /// newVal = -1/2: 47 iterations
67 /// newVal = 0: 40 iterations (CG works)
68 /// newVal = 1/2: 46 iterations
69 /// newVal = 3/4: 47 iterations
70 /// newVal = 1: 59 iterations
71 /// newVal = 5/4: 183 iterations
72 /// newVal = 3/2: 491 iterations
73 /// newVal = 2: 939 iterations (CG breaks!)
74 void setMaterialTensorOffDiagonalValue (const double newVal);
75
76
77 /// \brief Set parameters for anisotropic diffusion
78 ///
79 /// Q = Rz(theta_z) Ry(theta_y) Rx(theta_x)
80 /// Rotate in x, then y , then z
81 ///
82 /// D = diag(str_x,str_y, str_z)
83 /// Diagonal diffusion strength pre-rotation
84 ///
85 /// Diffusion Tensor = Q D Q^T
86 void setDiffusionRotationAndStrength(const std::vector<double>& diff_rotation_angle, const std::vector<double>& diff_strength);
87
88
89 /// \brief Gets the diffusion Tensor
90 const std::vector<double> & getDiffusionMatrix();
91
92
93 /// \brief Gets the 2D diffusion Tensor (for 2D problems)
94 const std::vector<double> & getDiffusionMatrix2D();
95
96
97 /// \brief Use the diffusion tensor rather than the off-diagonal values
98 bool useDiffusionMatrix();
99
100
101 /// \brief Make a Pamgen mesh specification for the Poisson test problem.
102 ///
103 /// Pamgen accepts mesh descriptions as human-readable strings in a
104 /// Pamgen-specific mesh description language. This function creates
105 /// a mesh description for the Poisson test problem in this directory.
106 /// The mesh description returned by this function describes a
107 /// rectangular prism with cubic elements, with nx elements along the
108 /// x dimension, ny elements along the y dimension, and nz elements
109 /// along the z dimension.
110 ///
111 /// \pre nx > 0 && ny > 0 && nz > 0
112 std::string
113 makeMeshInput (const int nx, const int ny, const int nz);
114
115 /// \brief Set default command-line argument values for Poisson test problem.
116 ///
117 /// nx, ny, and nz mean the same thing as the input arguments of
118 /// makeMeshInput().
119 ///
120 /// \param nx [out] Number of elements along the x dimension.
121 /// \param ny [out] Number of elements along the y dimension.
122 /// \param nz [out] Number of elements along the z dimension.
123 /// \param xmlInputParamsFile [out] Name of XML file encoding
124 /// an input ParameterList for the Poisson test problem.
125 /// \param solverName [out] Name of Belos solver; anything that
126 /// Belos::SolverFactory understands is valid here.
127 /// \param verbose [out] Whether to print verbose status output.
128 /// \param debug [out] Whether to print debugging output.
129 void
130 setCommandLineArgumentDefaults (int& nx,
131 int& ny,
132 int& nz,
133 std::string& xmlInputParamsFile,
134 std::string& solverName,
135 bool& verbose,
136 bool& debug);
137
138 /// \brief Prepare for parsing command-line arguments.
139 ///
140 /// This sets up command-line options for the given arguments, which
141 /// correspond to the arguments of setCommandLineArgumentDefaults.
142 /// This function reads in the default values of the arguments on
143 /// input. When the command-line arguments are parsed (by
144 /// parseCommandLineArguments()), their values will be overwritten
145 /// with the values specified on the command line.
146 void
147 setUpCommandLineArguments (Teuchos::CommandLineProcessor& cmdp,
148 int& nx,
149 int& ny,
150 int& nz,
151 std::string& xmlInputParamsFile,
152 std::string& solverName,
153 double& tol,
154 int& maxNumIters,
155 bool& verbose,
156 bool& debug);
157
158 /// \brief Parse and partially validate the command-line arguments.
159 ///
160 /// \param printedHelp [out] Whether the --help option was specified
161 /// on the command line.
162 /// \param argc [in] Same as the argument to main().
163 /// \param argv [in/out] Same as the argument to main().
164 ///
165 /// All other arguments are the same as
166 /// setCommandLineArgumentDefaults().
167 void
168 parseCommandLineArguments (Teuchos::CommandLineProcessor& cmdp,
169 bool& printedHelp,
170 int argc,
171 char* argv[],
172 int& nx,
173 int& ny,
174 int& nz,
175 std::string& xmlInputParamsFile,
176 std::string& solverName,
177 bool& verbose,
178 bool& debug);
179
180 } // namespace IntrepidPoissonExample
181 } // namespace TrilinosCouplings
182
183 #endif // __TrilinosCouplings_IntrepidPoissonExampleHelpers_hpp