Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/PDE/Transport/DGTransport.hpp
4 : : \copyright 2012-2015 J. Bakosi,
5 : : 2016-2018 Los Alamos National Security, LLC.,
6 : : 2019-2021 Triad National Security, LLC.
7 : : All rights reserved. See the LICENSE file for details.
8 : : \brief Scalar transport using disccontinous Galerkin discretization
9 : : \details This file implements the physics operators governing transported
10 : : scalars using disccontinuous Galerkin discretization.
11 : : */
12 : : // *****************************************************************************
13 : : #ifndef DGTransport_h
14 : : #define DGTransport_h
15 : :
16 : : #include <vector>
17 : : #include <array>
18 : : #include <limits>
19 : : #include <cmath>
20 : : #include <unordered_set>
21 : : #include <map>
22 : :
23 : : #include "Macro.hpp"
24 : : #include "Exception.hpp"
25 : : #include "Vector.hpp"
26 : : #include "UnsMesh.hpp"
27 : : #include "Integrate/Basis.hpp"
28 : : #include "Integrate/Quadrature.hpp"
29 : : #include "Integrate/Initialize.hpp"
30 : : #include "Integrate/Mass.hpp"
31 : : #include "Integrate/Surface.hpp"
32 : : #include "Integrate/Boundary.hpp"
33 : : #include "Integrate/Volume.hpp"
34 : : #include "Riemann/Upwind.hpp"
35 : : #include "Reconstruction.hpp"
36 : : #include "Limiter.hpp"
37 : : #include "PrefIndicator.hpp"
38 : : #include "EoS/EOS.hpp"
39 : : #include "FunctionPrototypes.hpp"
40 : : #include "ConfigureTransport.hpp"
41 : :
42 : : namespace inciter {
43 : :
44 : : extern ctr::InputDeck g_inputdeck;
45 : :
46 : : namespace dg {
47 : :
48 : : //! \brief Transport equation used polymorphically with tk::DGPDE
49 : : //! \details The template argument(s) specify policies and are used to configure
50 : : //! the behavior of the class. The policies are:
51 : : //! - Physics - physics configuration, see PDE/Transport/Physics.h
52 : : //! - Problem - problem configuration, see PDE/Transport/Problem.h
53 : : //! \note The default physics is DGAdvection, set in
54 : : //! inciter::deck::check_transport()
55 : : template< class Physics, class Problem >
56 : : class Transport {
57 : :
58 : : private:
59 : : using eq = tag::transport;
60 : :
61 : : public:
62 : : //! Constructor
63 : 23 : explicit Transport() :
64 : : m_physics( Physics() ),
65 : : m_problem( Problem() ),
66 : 23 : m_ncomp( g_inputdeck.get< tag::ncomp >() )
67 : : {
68 : : // associate boundary condition configurations with state functions, the
69 : : // order in which the state functions listed matters, see ctr::bc::Keys
70 [ + - ][ + - ]: 345 : brigand::for_each< ctr::bclist::Keys >( ConfigBC( m_bc,
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + + ]
[ + + ][ - - ]
[ - - ]
71 : : // BC State functions
72 : : { dirichlet
73 : : , invalidBC // Symmetry BC not implemented
74 : : , outlet
75 : : , invalidBC // Characteristic BC not implemented
76 : : , extrapolate
77 : : , invalidBC // Slip wall BC not implemented
78 : : , invalidBC }, // No slip wall BC not implemented
79 : : // BC Gradient functions
80 : : { noOpGrad
81 : : , noOpGrad
82 : : , noOpGrad
83 : : , noOpGrad
84 : : , noOpGrad
85 : : , noOpGrad
86 : : , noOpGrad }
87 : : ) );
88 : :
89 : : // Inlet BC has a different structure than above BCs, so it must be
90 : : // handled differently than with ConfigBC
91 [ + - ][ + - ]: 23 : ConfigInletBC(m_bc, inlet, noOpGrad);
[ + - ]
92 : :
93 [ - - ]: 23 : m_problem.errchk( m_ncomp );
94 : 23 : }
95 : :
96 : : //! Find the number of primitive quantities required for this PDE system
97 : : //! \return The number of primitive quantities required to be stored for
98 : : //! this PDE system
99 : 16 : std::size_t nprim() const
100 : : {
101 : : // transport does not need/store any primitive quantities currently
102 : 16 : return 0;
103 : : }
104 : :
105 : : //! Find the number of materials set up for this PDE system
106 : : //! \return The number of materials set up for this PDE system
107 : 0 : std::size_t nmat() const
108 : : {
109 : 0 : return m_ncomp;
110 : : }
111 : :
112 : : //! Assign number of DOFs per equation in the PDE system
113 : : //! \param[in,out] numEqDof Array storing number of Dofs for each PDE
114 : : //! equation
115 : 16 : void numEquationDofs(std::vector< std::size_t >& numEqDof) const
116 : : {
117 : : // all equation-dofs initialized to ndofs
118 [ + + ]: 32 : for (std::size_t i=0; i<m_ncomp; ++i) {
119 : 16 : numEqDof.push_back(g_inputdeck.get< tag::ndof >());
120 : : }
121 : 16 : }
122 : :
123 : : //! Find how 'stiff equations', which we currently
124 : : //! have none for Transport
125 : : //! \return number of stiff equations
126 : 64 : std::size_t nstiffeq() const
127 : 64 : { return 0; }
128 : :
129 : : //! Find how 'nonstiff equations', which we currently
130 : : //! don't use for Transport
131 : : //! \return number of non-stiff equations
132 : 32 : std::size_t nnonstiffeq() const
133 : 32 : { return 0; }
134 : :
135 : : //! Locate the stiff equations. Unused for transport.
136 : : //! \param[out] stiffEqIdx list
137 : 0 : void setStiffEqIdx( std::vector< std::size_t >& stiffEqIdx ) const
138 : : {
139 : 0 : stiffEqIdx.resize(0);
140 : 0 : }
141 : :
142 : : //! Locate the nonstiff equations. Unused for transport.
143 : : //! \param[out] nonStiffEqIdx list
144 : 0 : void setNonStiffEqIdx( std::vector< std::size_t >& nonStiffEqIdx ) const
145 : : {
146 : 0 : nonStiffEqIdx.resize(0);
147 : 0 : }
148 : :
149 : : //! Determine elements that lie inside the user-defined IC box
150 : 16 : void IcBoxElems( const tk::Fields&,
151 : : std::size_t,
152 : : std::vector< std::unordered_set< std::size_t > >& ) const
153 : 16 : {}
154 : :
155 : : //! Initalize the transport equations for DG
156 : : //! \param[in] L Element mass matrix
157 : : //! \param[in] inpoel Element-node connectivity
158 : : //! \param[in] coord Array of nodal coordinates
159 : : //! \param[in,out] unk Array of unknowns
160 : : //! \param[in] t Physical time
161 : : //! \param[in] nielem Number of internal elements
162 : : void
163 : 140 : initialize(
164 : : const tk::Fields& L,
165 : : const std::vector< std::size_t >& inpoel,
166 : : const tk::UnsMesh::Coords& coord,
167 : : const std::vector< std::unordered_set< std::size_t > >& /*inbox*/,
168 : : const std::unordered_map< std::size_t, std::set< std::size_t > >&,
169 : : tk::Fields& unk,
170 : : tk::real t,
171 : : const std::size_t nielem ) const
172 : : {
173 [ + - ]: 140 : tk::initialize( m_ncomp, m_mat_blk, L, inpoel, coord,
174 : : Problem::initialize, unk, t, nielem );
175 : 140 : }
176 : :
177 : : //! Compute density constraint for a given material
178 : : // //! \param[in] nelem Number of elements
179 : : // //! \param[in] unk Array of unknowns
180 : : //! \param[out] densityConstr Density Constraint: rho/(rho0*det(g))
181 : 96 : void computeDensityConstr( std::size_t /*nelem*/,
182 : : tk::Fields& /*unk*/,
183 : : std::vector< tk::real >& densityConstr) const
184 : : {
185 : 96 : densityConstr.resize(0);
186 : 96 : }
187 : :
188 : : //! Compute the left hand side mass matrix
189 : : //! \param[in] geoElem Element geometry array
190 : : //! \param[in,out] l Block diagonal mass matrix
191 : 140 : void lhs( const tk::Fields& geoElem, tk::Fields& l ) const {
192 : 140 : const auto ndof = g_inputdeck.get< tag::ndof >();
193 : 140 : tk::mass( m_ncomp, ndof, geoElem, l );
194 : 140 : }
195 : :
196 : : //! Update the interface cells to first order dofs
197 : : //! \details This function resets the high-order terms in interface cells,
198 : : //! and is currently not used in transport.
199 : 480 : void updateInterfaceCells( tk::Fields&,
200 : : std::size_t,
201 : : std::vector< std::size_t >&,
202 : 480 : std::vector< std::size_t >& ) const {}
203 : :
204 : : //! Update the primitives for this PDE system
205 : : //! \details This function computes and stores the dofs for primitive
206 : : //! quantities, which are currently unused for transport.
207 : 496 : void updatePrimitives( const tk::Fields&,
208 : : const tk::Fields&,
209 : : const tk::Fields&,
210 : : tk::Fields&,
211 : : std::size_t,
212 : 496 : const std::vector< std::size_t >& ) const {}
213 : :
214 : : //! Clean up the state of trace materials for this PDE system
215 : : //! \details This function cleans up the state of materials present in trace
216 : : //! quantities in each cell. This is currently unused for transport.
217 : 480 : void cleanTraceMaterial( tk::real,
218 : : const tk::Fields&,
219 : : tk::Fields&,
220 : : tk::Fields&,
221 : 480 : std::size_t ) const {}
222 : :
223 : : //! Reconstruct second-order solution from first-order
224 : : // //! \param[in] t Physical time
225 : : // //! \param[in] geoFace Face geometry array
226 : : // //! \param[in] geoElem Element geometry array
227 : : // //! \param[in] fd Face connectivity and boundary conditions object
228 : : // //! \param[in] esup Elements-surrounding-nodes connectivity
229 : : // //! \param[in] inpoel Element-node connectivity
230 : : // //! \param[in] coord Array of nodal coordinates
231 : : // //! \param[in,out] U Solution vector at recent time step
232 : : // //! \param[in,out] P Primitive vector at recent time step
233 : 0 : void reconstruct( tk::real,
234 : : const tk::Fields&,
235 : : const tk::Fields&,
236 : : const inciter::FaceData&,
237 : : const std::map< std::size_t, std::vector< std::size_t > >&,
238 : : const std::vector< std::size_t >&,
239 : : const tk::UnsMesh::Coords&,
240 : : tk::Fields&,
241 : : tk::Fields&,
242 : : const bool,
243 : : const std::vector< std::size_t >& ) const
244 : : {
245 : : // do reconstruction only if P0P1
246 [ - - ][ - - ]: 0 : if (g_inputdeck.get< tag::rdof >() == 4 &&
247 [ - - ]: 0 : g_inputdeck.get< tag::ndof >() == 1)
248 [ - - ][ - - ]: 0 : Throw("P0P1 not supported for Transport.");
[ - - ]
249 : 0 : }
250 : :
251 : : //! Limit second-order solution
252 : : //! \param[in] t Physical time
253 : : //! \param[in] geoFace Face geometry array
254 : : //! \param[in] fd Face connectivity and boundary conditions object
255 : : //! \param[in] esup Elements surrounding points
256 : : //! \param[in] inpoel Element-node connectivity
257 : : //! \param[in] coord Array of nodal coordinates
258 : : //! \param[in] ndofel Vector of local number of degrees of freedome
259 : : // //! \param[in] gid Local->global node id map
260 : : // //! \param[in] bid Local chare-boundary node ids (value) associated to
261 : : // //! global node ids (key)
262 : : // //! \param[in] uNodalExtrm Chare-boundary nodal extrema for conservative
263 : : // //! variables
264 : : //! \param[in,out] U Solution vector at recent time step
265 : 0 : void limit( [[maybe_unused]] tk::real t,
266 : : [[maybe_unused]] const bool pref,
267 : : [[maybe_unused]] const tk::Fields& geoFace,
268 : : const tk::Fields&,
269 : : const inciter::FaceData& fd,
270 : : const std::map< std::size_t, std::vector< std::size_t > >& esup,
271 : : const std::vector< std::size_t >& inpoel,
272 : : const tk::UnsMesh::Coords& coord,
273 : : const std::vector< std::size_t >& ndofel,
274 : : const std::vector< std::size_t >&,
275 : : const std::unordered_map< std::size_t, std::size_t >&,
276 : : const std::vector< std::vector<tk::real> >&,
277 : : const std::vector< std::vector<tk::real> >&,
278 : : const std::vector< std::vector<tk::real> >&,
279 : : tk::Fields& U,
280 : : tk::Fields&,
281 : : std::vector< std::size_t >& ) const
282 : : {
283 : 0 : const auto limiter = g_inputdeck.get< tag::limiter >();
284 : :
285 [ - - ]: 0 : if (limiter == ctr::LimiterType::WENOP1)
286 : 0 : WENO_P1( fd.Esuel(), U );
287 [ - - ]: 0 : else if (limiter == ctr::LimiterType::SUPERBEEP1)
288 : 0 : Superbee_P1( fd.Esuel(), inpoel, ndofel, coord, U );
289 [ - - ]: 0 : else if (limiter == ctr::LimiterType::VERTEXBASEDP1)
290 : 0 : VertexBasedTransport_P1( esup, inpoel, ndofel, fd.Esuel().size()/4,
291 : : coord, U );
292 : 0 : }
293 : :
294 : : //! Update the conservative variable solution for this PDE system
295 : : //! \details This function computes the updated dofs for conservative
296 : : //! quantities based on the limited solution and is currently not used in
297 : : //! transport.
298 : 0 : void CPL( const tk::Fields&,
299 : : const tk::Fields&,
300 : : const std::vector< std::size_t >&,
301 : : const tk::UnsMesh::Coords&,
302 : : tk::Fields&,
303 : 0 : std::size_t ) const {}
304 : :
305 : : //! Return cell-average deformation gradient tensor (no-op for transport)
306 : : //! \details This function is a no-op in transport.
307 : 0 : std::array< std::vector< tk::real >, 9 > cellAvgDeformGrad(
308 : : const tk::Fields&,
309 : : std::size_t ) const
310 : : {
311 : 0 : return {};
312 : : }
313 : :
314 : : //! Reset the high order solution for p-adaptive scheme
315 : : //! \details This function reset the high order coefficient for p-adaptive
316 : : //! solution polynomials and is currently not used in transport.
317 : 0 : void resetAdapSol( const inciter::FaceData&,
318 : : tk::Fields&,
319 : : tk::Fields&,
320 : 0 : const std::vector< std::size_t >& ) const {}
321 : :
322 : : //! Compute right hand side
323 : : //! \param[in] t Physical time
324 : : //! \param[in] pref Indicator for p-adaptive algorithm
325 : : //! \param[in] geoFace Face geometry array
326 : : //! \param[in] geoElem Element geometry array
327 : : //! \param[in] fd Face connectivity and boundary conditions object
328 : : //! \param[in] inpoel Element-node connectivity
329 : : //! \param[in] coord Array of nodal coordinates
330 : : //! \param[in] U Solution vector at recent time step
331 : : //! \param[in] P Primitive vector at recent time step
332 : : //! \param[in] ndofel Vector of local number of degrees of freedom
333 : : //! \param[in] dt Delta time
334 : : //! \param[in,out] R Right-hand side vector computed
335 : 480 : void rhs( tk::real t,
336 : : const bool pref,
337 : : const tk::Fields& geoFace,
338 : : const tk::Fields& geoElem,
339 : : const inciter::FaceData& fd,
340 : : const std::vector< std::size_t >& inpoel,
341 : : const std::vector< std::unordered_set< std::size_t > >&,
342 : : const tk::UnsMesh::Coords& coord,
343 : : const tk::Fields& U,
344 : : const tk::Fields& P,
345 : : const std::vector< std::size_t >& ndofel,
346 : : const tk::real dt,
347 : : tk::Fields& R ) const
348 : : {
349 : 480 : const auto ndof = g_inputdeck.get< tag::ndof >();
350 : 480 : const auto rdof = g_inputdeck.get< tag::rdof >();
351 : 480 : const auto intsharp = g_inputdeck.get< tag::transport,
352 : 480 : tag::intsharp >();
353 : :
354 [ - + ][ - - ]: 480 : Assert( U.nunk() == P.nunk(), "Number of unknowns in solution "
[ - - ][ - - ]
355 : : "vector and primitive vector at recent time step incorrect" );
356 [ - + ][ - - ]: 480 : Assert( U.nunk() == R.nunk(), "Number of unknowns in solution "
[ - - ][ - - ]
357 : : "vector and right-hand side at recent time step incorrect" );
358 [ - + ][ - - ]: 480 : Assert( U.nprop() == rdof*m_ncomp, "Number of components in solution "
[ - - ][ - - ]
[ - - ]
359 : : "vector must equal "+ std::to_string(rdof*m_ncomp) );
360 [ - + ][ - - ]: 480 : Assert( P.nprop() == 0, "Number of components in primitive "
[ - - ][ - - ]
[ - - ]
361 : : "vector must equal "+ std::to_string(0) );
362 [ - + ][ - - ]: 480 : Assert( R.nprop() == ndof*m_ncomp, "Number of components in right-hand "
[ - - ][ - - ]
[ - - ]
363 : : "side vector must equal "+ std::to_string(ndof*m_ncomp) );
364 [ - + ][ - - ]: 480 : Assert( fd.Inpofa().size()/3 == fd.Esuf().size()/2,
[ - - ][ - - ]
365 : : "Mismatch in inpofa size" );
366 : :
367 : : // set rhs to zero
368 : 480 : R.fill(0.0);
369 : :
370 : : // empty vector for non-conservative terms. This vector is unused for
371 : : // linear transport since, there are no non-conservative terms in the
372 : : // system of PDEs.
373 : 960 : std::vector< std::vector < tk::real > > riemannDeriv;
374 : :
375 : : // compute internal surface flux integrals
376 [ + - ]: 960 : std::vector< std::size_t > solidx(1, 0);
377 [ + - ][ + - ]: 480 : tk::surfInt( pref, m_ncomp, m_mat_blk, t, ndof, rdof,
[ + - ]
378 : : inpoel, solidx, coord, fd, geoFace, geoElem, Upwind::flux,
379 : : Problem::prescribedVelocity, U, P, ndofel, dt, R,
380 : : riemannDeriv, intsharp );
381 : :
382 [ - + ]: 480 : if(ndof > 1)
383 : : // compute volume integrals
384 [ - - ][ - - ]: 0 : tk::volInt( m_ncomp, t, m_mat_blk, ndof, rdof,
[ - - ]
385 : 0 : fd.Esuel().size()/4, inpoel, coord, geoElem, flux,
386 : : Problem::prescribedVelocity, U, P, ndofel, R, intsharp );
387 : :
388 : : // compute boundary surface flux integrals
389 [ + + ]: 4320 : for (const auto& b : m_bc)
390 [ + - ][ + - ]: 7680 : tk::bndSurfInt( pref, m_ncomp, m_mat_blk, ndof, rdof,
[ + - ]
391 : 3840 : std::get<0>(b), fd, geoFace, geoElem, inpoel, coord, t, Upwind::flux,
392 : 3840 : Problem::prescribedVelocity, std::get<1>(b), U, P, ndofel, R,
393 : : riemannDeriv, intsharp );
394 : 480 : }
395 : :
396 : : //! Evaluate the adaptive indicator and mark the ndof for each element
397 : : //! \param[in] nunk Number of unknowns
398 : : //! \param[in] coord Array of nodal coordinates
399 : : //! \param[in] inpoel Element-node connectivity
400 : : //! \param[in] fd Face connectivity and boundary conditions object
401 : : //! \param[in] unk Array of unknowns
402 : : //! \param[in] prim Array of primitive quantities
403 : : //! \param[in] indicator p-refinement indicator type
404 : : //! \param[in] ndof Number of degrees of freedom in the solution
405 : : //! \param[in] ndofmax Max number of degrees of freedom for p-refinement
406 : : //! \param[in] tolref Tolerance for p-refinement
407 : : //! \param[in,out] ndofel Vector of local number of degrees of freedome
408 : 0 : void eval_ndof( std::size_t nunk,
409 : : [[maybe_unused]] const tk::UnsMesh::Coords& coord,
410 : : [[maybe_unused]] const std::vector< std::size_t >& inpoel,
411 : : const inciter::FaceData& fd,
412 : : const tk::Fields& unk,
413 : : [[maybe_unused]] const tk::Fields& prim,
414 : : inciter::ctr::PrefIndicatorType indicator,
415 : : std::size_t ndof,
416 : : std::size_t ndofmax,
417 : : tk::real tolref,
418 : : std::vector< std::size_t >& ndofel ) const
419 : : {
420 : 0 : const auto& esuel = fd.Esuel();
421 : :
422 [ - - ]: 0 : if(indicator == inciter::ctr::PrefIndicatorType::SPECTRAL_DECAY)
423 : 0 : spectral_decay( 1, nunk, esuel, unk, ndof, ndofmax, tolref, ndofel );
424 : : else
425 [ - - ][ - - ]: 0 : Throw( "No such adaptive indicator type" );
[ - - ]
426 : 0 : }
427 : :
428 : : //! Compute the minimum time step size
429 : : // //! \param[in] U Solution vector at recent time step
430 : : // //! \param[in] coord Mesh node coordinates
431 : : // //! \param[in] inpoel Mesh element connectivity
432 : : //! \return Minimum time step size
433 : 0 : tk::real dt( const std::array< std::vector< tk::real >, 3 >& /*coord*/,
434 : : const std::vector< std::size_t >& /*inpoel*/,
435 : : const inciter::FaceData& /*fd*/,
436 : : const tk::Fields& /*geoFace*/,
437 : : const tk::Fields& /*geoElem*/,
438 : : const std::vector< std::size_t >& /*ndofel*/,
439 : : const tk::Fields& /*U*/,
440 : : const tk::Fields&,
441 : : const std::size_t /*nielem*/ ) const
442 : : {
443 : 0 : tk::real mindt = std::numeric_limits< tk::real >::max();
444 : 0 : return mindt;
445 : : }
446 : :
447 : : //! Balances elastic energy after plastic update. Not implemented here.
448 : : // //! \param[in] e Element number
449 : : // //! \param[in] x_star Stiff variables before implicit update
450 : : // //! \param[in] x Stiff variables after implicit update
451 : : // //! \param[in] U Field of conserved variables
452 : 0 : void balance_plastic_energy( std::size_t /*e*/,
453 : : std::vector< tk::real > /*x_star*/,
454 : : std::vector< tk::real > /*x*/,
455 : 0 : tk::Fields& /*U*/ ) const {}
456 : :
457 : : //! Compute stiff terms for a single element, not implemented here
458 : : // //! \param[in] e Element number
459 : : // //! \param[in] geoElem Element geometry array
460 : : // //! \param[in] inpoel Element-node connectivity
461 : : // //! \param[in] coord Array of nodal coordinates
462 : : // //! \param[in] U Solution vector at recent time step
463 : : // //! \param[in] P Primitive vector at recent time step
464 : : // //! \param[in] ndofel Vector of local number of degrees of freedom
465 : : // //! \param[in,out] R Right-hand side vector computed
466 : 0 : void stiff_rhs( std::size_t /*e*/,
467 : : const tk::Fields& /*geoElem*/,
468 : : const std::vector< std::size_t >& /*inpoel*/,
469 : : const tk::UnsMesh::Coords& /*coord*/,
470 : : const tk::Fields& /*U*/,
471 : : const tk::Fields& /*P*/,
472 : : const std::vector< std::size_t >& /*ndofel*/,
473 : : tk::Fields& /*R*/ ) const
474 : 0 : {}
475 : :
476 : : //! Return a map that associates user-specified strings to functions
477 : : //! \return Map that associates user-specified strings to functions that
478 : : //! compute relevant quantities to be output to file
479 : 192 : std::map< std::string, tk::GetVarFn > OutVarFn() const {
480 : 192 : std::map< std::string, tk::GetVarFn > OutFnMap;
481 [ + - ][ + - ]: 192 : OutFnMap["material_indicator"] = transport::matIndicatorOutVar;
[ + - ]
482 : :
483 : 192 : return OutFnMap;
484 : : }
485 : :
486 : : //! Return analytic field names to be output to file
487 : : //! \return Vector of strings labelling analytic fields output in file
488 : 96 : std::vector< std::string > analyticFieldNames() const {
489 : 96 : std::vector< std::string > n;
490 : 96 : auto depvar = g_inputdeck.get< tag::depvar >()[0];
491 [ + + ]: 192 : for (ncomp_t c=0; c<m_ncomp; ++c)
492 [ + - ][ + - ]: 96 : n.push_back( depvar + std::to_string(c) + "_analytic" );
[ + - ][ + - ]
493 : 96 : return n;
494 : : }
495 : :
496 : : //! Return surface field output going to file
497 : : std::vector< std::vector< tk::real > >
498 : 0 : surfOutput( const std::map< int, std::vector< std::size_t > >&,
499 : : tk::Fields& ) const
500 : : {
501 : 0 : std::vector< std::vector< tk::real > > s; // punt for now
502 : 0 : return s;
503 : : }
504 : :
505 : : //! Return time history field names to be output to file
506 : : //! \return Vector of strings labelling time history fields output in file
507 : 0 : std::vector< std::string > histNames() const {
508 : 0 : std::vector< std::string > s; // punt for now
509 : 0 : return s;
510 : : }
511 : :
512 : : //! Return names of integral variables to be output to diagnostics file
513 : : //! \return Vector of strings labelling integral variables output
514 : 7 : std::vector< std::string > names() const {
515 : 7 : std::vector< std::string > n;
516 : : const auto& depvar =
517 [ + - ]: 7 : g_inputdeck.get< tag::depvar >().at(0);
518 : : // construct the name of the numerical solution for all components
519 [ + + ]: 14 : for (ncomp_t c=0; c<m_ncomp; ++c)
520 [ + - ][ + - ]: 7 : n.push_back( depvar + std::to_string(c) );
[ + - ]
521 : 7 : return n;
522 : : }
523 : :
524 : : //! Return analytic solution (if defined by Problem) at xi, yi, zi, t
525 : : //! \param[in] xi X-coordinate at which to evaluate the analytic solution
526 : : //! \param[in] yi Y-coordinate at which to evaluate the analytic solution
527 : : //! \param[in] zi Z-coordinate at which to evaluate the analytic solution
528 : : //! \param[in] t Physical time at which to evaluate the analytic solution
529 : : //! \return Vector of analytic solution at given spatial location and time
530 : : std::vector< tk::real >
531 : 320976 : analyticSolution( tk::real xi, tk::real yi, tk::real zi, tk::real t ) const
532 : 320976 : { return Problem::analyticSolution( m_ncomp, m_mat_blk, xi, yi,
533 : 320976 : zi, t ); }
534 : :
535 : : //! Return analytic solution for conserved variables
536 : : //! \param[in] xi X-coordinate at which to evaluate the analytic solution
537 : : //! \param[in] yi Y-coordinate at which to evaluate the analytic solution
538 : : //! \param[in] zi Z-coordinate at which to evaluate the analytic solution
539 : : //! \param[in] t Physical time at which to evaluate the analytic solution
540 : : //! \return Vector of analytic solution at given location and time
541 : : std::vector< tk::real >
542 : 320880 : solution( tk::real xi, tk::real yi, tk::real zi, tk::real t ) const
543 : 320880 : { return Problem::initialize( m_ncomp, m_mat_blk, xi, yi, zi, t ); }
544 : :
545 : : //! Return time history field output evaluated at time history points
546 : : //! \param[in] h History point data
547 : : std::vector< std::vector< tk::real > >
548 : 0 : histOutput( const std::vector< HistData >& h,
549 : : const std::vector< std::size_t >&,
550 : : const tk::UnsMesh::Coords&,
551 : : const tk::Fields&,
552 : : const tk::Fields& ) const
553 : : {
554 [ - - ]: 0 : std::vector< std::vector< tk::real > > Up(h.size()); //punt for now
555 : 0 : return Up;
556 : : }
557 : :
558 : : //! Return cell-averaged total component mass per unit volume for an element
559 : : //! \param[in] e Element id for which total energy is required
560 : : //! \param[in] unk Vector of conserved quantities
561 : : //! \return Cell-averaged total component mass per unit volume for given
562 : : //! element. Since transport does not have an associated total energy,
563 : : //! return total mass.
564 : 320880 : tk::real sp_totalenergy(std::size_t e, const tk::Fields& unk) const
565 : : {
566 : 320880 : const auto rdof = g_inputdeck.get< tag::rdof >();
567 : :
568 : 320880 : tk::real sp_m(0.0);
569 [ + + ]: 641760 : for (std::size_t c=0; c<m_ncomp; ++c) {
570 : 320880 : sp_m += unk(e,c*rdof);
571 : : }
572 : 320880 : return sp_m;
573 : : }
574 : :
575 : : private:
576 : : const Physics m_physics; //!< Physics policy
577 : : const Problem m_problem; //!< Problem policy
578 : : const ncomp_t m_ncomp; //!< Number of components in this PDE
579 : : //! BC configuration
580 : : BCStateFn m_bc;
581 : : //! \brief EOS material block - This PDE does not require an EOS block,
582 : : //! thus this variable has not been intialized.
583 : : std::vector< EOS > m_mat_blk;
584 : :
585 : : //! Evaluate physical flux function for this PDE system
586 : : //! \param[in] ncomp Number of scalar components in this PDE system
587 : : //! \param[in] ugp Numerical solution at the Gauss point at which to
588 : : //! evaluate the flux
589 : : //! \param[in] v Prescribed velocity evaluated at the Gauss point at which
590 : : //! to evaluate the flux
591 : : //! \return Flux vectors for all components in this PDE system
592 : : //! \note The function signature must follow tk::FluxFn
593 : : static tk::FluxFn::result_type
594 : 0 : flux( ncomp_t ncomp,
595 : : const std::vector< EOS >&,
596 : : const std::vector< tk::real >& ugp,
597 : : const std::vector< std::array< tk::real, 3 > >& v )
598 : :
599 : : {
600 [ - - ][ - - ]: 0 : Assert( ugp.size() == ncomp, "Size mismatch" );
[ - - ][ - - ]
601 [ - - ][ - - ]: 0 : Assert( v.size() == ncomp, "Size mismatch" );
[ - - ][ - - ]
602 : :
603 [ - - ]: 0 : std::vector< std::array< tk::real, 3 > > fl( ugp.size() );
604 : :
605 [ - - ]: 0 : for (ncomp_t c=0; c<ncomp; ++c)
606 : 0 : fl[c] = {{ v[c][0] * ugp[c], v[c][1] * ugp[c], v[c][2] * ugp[c] }};
607 : :
608 : 0 : return fl;
609 : : }
610 : :
611 : : //! \brief Boundary state function providing the left and right state of a
612 : : //! face at extrapolation boundaries
613 : : //! \param[in] ul Left (domain-internal) state
614 : : //! \return Left and right states for all scalar components in this PDE
615 : : //! system
616 : : //! \note The function signature must follow tk::StateFn
617 : : static tk::StateFn::result_type
618 : 418320 : extrapolate( ncomp_t, const std::vector< EOS >&,
619 : : const std::vector< tk::real >& ul, tk::real, tk::real,
620 : : tk::real, tk::real, const std::array< tk::real, 3 >& )
621 : : {
622 : 418320 : return {{ ul, ul }};
623 : : }
624 : :
625 : : //! \brief Boundary state function providing the left and right state of a
626 : : //! face at extrapolation boundaries
627 : : //! \param[in] ul Left (domain-internal) state
628 : : //! \return Left and right states for all scalar components in this PDE
629 : : //! system
630 : : //! \note The function signature must follow tk::StateFn
631 : : static tk::StateFn::result_type
632 : 67200 : inlet( ncomp_t, const std::vector< EOS >&,
633 : : const std::vector< tk::real >& ul, tk::real, tk::real, tk::real,
634 : : tk::real, const std::array< tk::real, 3 >& )
635 : : {
636 [ + - ]: 134400 : auto ur = ul;
637 : 67200 : std::fill( begin(ur), end(ur), 0.0 );
638 [ + - ]: 134400 : return {{ ul, std::move(ur) }};
639 : : }
640 : :
641 : : //! \brief Boundary state function providing the left and right state of a
642 : : //! face at outlet boundaries
643 : : //! \param[in] ul Left (domain-internal) state
644 : : //! \return Left and right states for all scalar components in this PDE
645 : : //! system
646 : : //! \note The function signature must follow tk::StateFn
647 : : static tk::StateFn::result_type
648 : 67200 : outlet( ncomp_t, const std::vector< EOS >&,
649 : : const std::vector< tk::real >& ul, tk::real, tk::real, tk::real,
650 : : tk::real, const std::array< tk::real, 3 >& )
651 : : {
652 : 67200 : return {{ ul, ul }};
653 : : }
654 : :
655 : : //! \brief Boundary state function providing the left and right state of a
656 : : //! face at Dirichlet boundaries
657 : : //! \param[in] ncomp Number of scalar components in this PDE system
658 : : //! \param[in] ul Left (domain-internal) state
659 : : //! \param[in] x X-coordinate at which to compute the states
660 : : //! \param[in] y Y-coordinate at which to compute the states
661 : : //! \param[in] z Z-coordinate at which to compute the states
662 : : //! \param[in] t Physical time
663 : : //! \return Left and right states for all scalar components in this PDE
664 : : //! system
665 : : //! \note The function signature must follow tk::StateFn
666 : : static tk::StateFn::result_type
667 : 0 : dirichlet( ncomp_t ncomp,
668 : : const std::vector< EOS >& mat_blk,
669 : : const std::vector< tk::real >& ul, tk::real x, tk::real y,
670 : : tk::real z, tk::real t, const std::array< tk::real, 3 >& )
671 : : {
672 : 0 : return {{ ul, Problem::initialize( ncomp, mat_blk, x, y, z, t ) }};
673 : : }
674 : :
675 : : //----------------------------------------------------------------------------
676 : : // Boundary Gradient functions
677 : : //----------------------------------------------------------------------------
678 : :
679 : : //! \brief Boundary gradient function copying the left gradient to the right
680 : : //! gradient at a face
681 : : //! \param[in] dul Left (domain-internal) state
682 : : //! \return Left and right states for all scalar components in this PDE
683 : : //! system
684 : : //! \note The function signature must follow tk::StateFn.
685 : : static tk::StateFn::result_type
686 : 0 : noOpGrad( ncomp_t,
687 : : const std::vector< EOS >&,
688 : : const std::vector< tk::real >& dul,
689 : : tk::real, tk::real, tk::real, tk::real,
690 : : const std::array< tk::real, 3 >& )
691 : : {
692 : 0 : return {{ dul, dul }};
693 : : }
694 : : };
695 : :
696 : : } // dg::
697 : : } // inciter::
698 : :
699 : : #endif // DGTransport_h
|