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