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 [ - - ][ + - ]: 296 : class Transport {
[ + - ][ + - ]
[ - - ]
57 : :
58 : : private:
59 : : using eq = tag::transport;
60 : :
61 : : public:
62 : : //! Constructor
63 : 148 : explicit Transport() :
64 : : m_physics( Physics() ),
65 : : m_problem( Problem() ),
66 [ + - ]: 148 : 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 [ + - ][ + - ]: 2220 : 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 [ + - ][ + - ]: 296 : ConfigInletBC(m_bc, inlet, noOpGrad);
[ - - ]
92 : :
93 [ - - ]: 0 : m_problem.errchk( m_ncomp );
94 : 148 : }
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 : : std::size_t nprim() const
100 : : {
101 : : // transport does not need/store any primitive quantities currently
102 : : 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 : : std::size_t nmat() const
108 : : {
109 : : 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 : : void numEquationDofs(std::vector< std::size_t >& numEqDof) const
116 : : {
117 : : // all equation-dofs initialized to ndofs
118 [ - - ][ + + ]: 1060 : for (std::size_t i=0; i<m_ncomp; ++i) {
[ + + ][ + + ]
[ - - ]
119 : 530 : numEqDof.push_back(g_inputdeck.get< tag::ndof >());
120 : : }
121 : : }
122 : :
123 : : //! Find how 'stiff equations', which we currently
124 : : //! have none for Transport
125 : : //! \return number of stiff equations
126 : : std::size_t nstiffeq() const
127 : : { 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 : : std::size_t nnonstiffeq() const
133 : : { return 0; }
134 : :
135 : : //! Locate the stiff equations. Unused for transport.
136 : : //! \param[out] stiffEqIdx list
137 : : void setStiffEqIdx( std::vector< std::size_t >& stiffEqIdx ) const
138 : : {
139 : 0 : stiffEqIdx.resize(0);
140 : : }
141 : :
142 : : //! Locate the nonstiff equations. Unused for transport.
143 : : //! \param[out] nonStiffEqIdx list
144 : : void setNonStiffEqIdx( std::vector< std::size_t >& nonStiffEqIdx ) const
145 : : {
146 : 0 : nonStiffEqIdx.resize(0);
147 : : }
148 : :
149 : : //! Determine elements that lie inside the user-defined IC box
150 : : void IcBoxElems( const tk::Fields&,
151 : : std::size_t,
152 : : std::vector< std::unordered_set< std::size_t > >& ) const
153 : : {}
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 [ + - ]: 654 : 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 [ + - ]: 654 : tk::initialize( m_ncomp, m_mat_blk, L, inpoel, coord,
174 : : Problem::initialize, unk, t, nielem );
175 : 654 : }
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 : : void computeDensityConstr( std::size_t /*nelem*/,
182 : : tk::Fields& /*unk*/,
183 : : std::vector< tk::real >& densityConstr) const
184 : : {
185 : 993 : densityConstr.resize(0);
186 : : }
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 : : void lhs( const tk::Fields& geoElem, tk::Fields& l ) const {
192 : 654 : const auto ndof = g_inputdeck.get< tag::ndof >();
193 : 654 : tk::mass( m_ncomp, ndof, geoElem, l );
194 : : }
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 : : void updateInterfaceCells( tk::Fields&,
200 : : std::size_t,
201 : : std::vector< std::size_t >&,
202 : : 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 : : void updatePrimitives( const tk::Fields&,
208 : : const tk::Fields&,
209 : : const tk::Fields&,
210 : : tk::Fields&,
211 : : std::size_t,
212 : : 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 : : void cleanTraceMaterial( tk::real,
218 : : const tk::Fields&,
219 : : tk::Fields&,
220 : : tk::Fields&,
221 : : 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 : 19125 : 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 [ + + ]: 19125 : if (g_inputdeck.get< tag::rdof >() == 4 &&
247 [ - + ]: 18750 : g_inputdeck.get< tag::ndof >() == 1)
248 [ - - ][ - - ]: 0 : Throw("P0P1 not supported for Transport.");
[ - - ][ - - ]
[ - - ][ - - ]
249 : 19125 : }
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 : 19125 : 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 : 19125 : const auto limiter = g_inputdeck.get< tag::limiter >();
284 : :
285 [ + + ]: 19125 : if (limiter == ctr::LimiterType::WENOP1)
286 : 6000 : WENO_P1( fd.Esuel(), U );
287 [ + + ]: 13125 : else if (limiter == ctr::LimiterType::SUPERBEEP1)
288 : 12750 : Superbee_P1( fd.Esuel(), inpoel, ndofel, coord, U );
289 [ - + ]: 375 : else if (limiter == ctr::LimiterType::VERTEXBASEDP1)
290 : 0 : VertexBasedTransport_P1( esup, inpoel, ndofel, fd.Esuel().size()/4,
291 : : coord, U );
292 : 19125 : }
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 : : 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 : : 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 : : std::array< std::vector< tk::real >, 9 > cellAvgDeformGrad(
308 : : const tk::Fields&,
309 : : std::size_t ) const
310 : : {
311 : : 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 : : void resetAdapSol( const inciter::FaceData&,
318 : : tk::Fields&,
319 : : tk::Fields&,
320 : : 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 : 44280 : 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 : 44280 : const auto ndof = g_inputdeck.get< tag::ndof >();
350 : 44280 : const auto rdof = g_inputdeck.get< tag::rdof >();
351 : 44280 : const auto intsharp = g_inputdeck.get< tag::transport,
352 : : tag::intsharp >();
353 : :
354 : : Assert( U.nunk() == P.nunk(), "Number of unknowns in solution "
355 : : "vector and primitive vector at recent time step incorrect" );
356 : : Assert( U.nunk() == R.nunk(), "Number of unknowns in solution "
357 : : "vector and right-hand side at recent time step incorrect" );
358 : : Assert( U.nprop() == rdof*m_ncomp, "Number of components in solution "
359 : : "vector must equal "+ std::to_string(rdof*m_ncomp) );
360 : : Assert( P.nprop() == 0, "Number of components in primitive "
361 : : "vector must equal "+ std::to_string(0) );
362 : : Assert( R.nprop() == ndof*m_ncomp, "Number of components in right-hand "
363 : : "side vector must equal "+ std::to_string(ndof*m_ncomp) );
364 : : Assert( fd.Inpofa().size()/3 == fd.Esuf().size()/2,
365 : : "Mismatch in inpofa size" );
366 : :
367 : : // set rhs to zero
368 : : 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 : 44280 : std::vector< std::vector < tk::real > > riemannDeriv;
374 : :
375 : : // compute internal surface flux integrals
376 [ + - ][ + - ]: 44280 : std::vector< std::size_t > solidx(1, 0);
377 [ + - ][ + - ]: 88560 : 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 [ + + ]: 44280 : if(ndof > 1)
383 : : // compute volume integrals
384 [ + - ][ + - ]: 57375 : tk::volInt( m_ncomp, t, m_mat_blk, ndof, rdof,
[ - - ]
385 [ + - ]: 19125 : fd.Esuel().size()/4, inpoel, coord, geoElem, flux,
386 : : Problem::prescribedVelocity, U, P, ndofel, R, intsharp );
387 : :
388 : : // compute boundary surface flux integrals
389 [ + + ]: 369120 : for (const auto& b : m_bc)
390 [ + - ][ + - ]: 974520 : tk::bndSurfInt( pref, m_ncomp, m_mat_blk, ndof, rdof,
[ - - ][ - - ]
391 : : std::get<0>(b), fd, geoFace, geoElem, inpoel, coord, t, Upwind::flux,
392 : : Problem::prescribedVelocity, std::get<1>(b), U, P, ndofel, R,
393 : : riemannDeriv, intsharp );
394 : 44280 : }
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 : : 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 : : 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 : : tk::real mindt = std::numeric_limits< tk::real >::max();
444 : : return mindt;
445 : : }
446 : :
447 : : //! Compute stiff terms for a single element, not implemented here
448 : : // //! \param[in] e Element number
449 : : // //! \param[in] geoElem Element geometry array
450 : : // //! \param[in] inpoel Element-node connectivity
451 : : // //! \param[in] coord Array of nodal coordinates
452 : : // //! \param[in] U Solution vector at recent time step
453 : : // //! \param[in] P Primitive vector at recent time step
454 : : // //! \param[in] ndofel Vector of local number of degrees of freedom
455 : : // //! \param[in,out] R Right-hand side vector computed
456 : : void stiff_rhs( std::size_t /*e*/,
457 : : const tk::Fields& /*geoElem*/,
458 : : const std::vector< std::size_t >& /*inpoel*/,
459 : : const tk::UnsMesh::Coords& /*coord*/,
460 : : const tk::Fields& /*U*/,
461 : : const tk::Fields& /*P*/,
462 : : const std::vector< std::size_t >& /*ndofel*/,
463 : : tk::Fields& /*R*/ ) const
464 : : {}
465 : :
466 : : //! Return a map that associates user-specified strings to functions
467 : : //! \return Map that associates user-specified strings to functions that
468 : : //! compute relevant quantities to be output to file
469 [ + - ]: 1986 : std::map< std::string, tk::GetVarFn > OutVarFn() const {
470 : : std::map< std::string, tk::GetVarFn > OutFnMap;
471 [ + - ][ + - ]: 1986 : OutFnMap["material_indicator"] = transport::matIndicatorOutVar;
472 : :
473 : 1986 : return OutFnMap;
474 : : }
475 : :
476 : : //! Return analytic field names to be output to file
477 : : //! \return Vector of strings labelling analytic fields output in file
478 : 917 : std::vector< std::string > analyticFieldNames() const {
479 : : std::vector< std::string > n;
480 : 917 : auto depvar = g_inputdeck.get< tag::depvar >()[0];
481 [ + + ]: 1834 : for (ncomp_t c=0; c<m_ncomp; ++c)
482 [ + - ][ + - ]: 1834 : n.push_back( depvar + std::to_string(c) + "_analytic" );
[ - + ][ - + ]
[ - - ][ - - ]
483 : 917 : return n;
484 : : }
485 : :
486 : : //! Return surface field output going to file
487 : : std::vector< std::vector< tk::real > >
488 : : surfOutput( const std::map< int, std::vector< std::size_t > >&,
489 : : tk::Fields& ) const
490 : : {
491 : : std::vector< std::vector< tk::real > > s; // punt for now
492 : : return s;
493 : : }
494 : :
495 : : //! Return time history field names to be output to file
496 : : //! \return Vector of strings labelling time history fields output in file
497 : : std::vector< std::string > histNames() const {
498 : : std::vector< std::string > s; // punt for now
499 : : return s;
500 : : }
501 : :
502 : : //! Return names of integral variables to be output to diagnostics file
503 : : //! \return Vector of strings labelling integral variables output
504 [ + - ]: 38 : std::vector< std::string > names() const {
505 : : std::vector< std::string > n;
506 : : const auto& depvar =
507 : : g_inputdeck.get< tag::depvar >().at(0);
508 : : // construct the name of the numerical solution for all components
509 [ + + ]: 76 : for (ncomp_t c=0; c<m_ncomp; ++c)
510 [ + - ][ - + ]: 76 : n.push_back( depvar + std::to_string(c) );
[ - - ]
511 : 38 : return n;
512 : : }
513 : :
514 : : //! Return analytic solution (if defined by Problem) at xi, yi, zi, t
515 : : //! \param[in] xi X-coordinate at which to evaluate the analytic solution
516 : : //! \param[in] yi Y-coordinate at which to evaluate the analytic solution
517 : : //! \param[in] zi Z-coordinate at which to evaluate the analytic solution
518 : : //! \param[in] t Physical time at which to evaluate the analytic solution
519 : : //! \return Vector of analytic solution at given spatial location and time
520 : : std::vector< tk::real >
521 : : analyticSolution( tk::real xi, tk::real yi, tk::real zi, tk::real t ) const
522 : 839522 : { return Problem::analyticSolution( m_ncomp, m_mat_blk, xi, yi,
523 : : zi, t ); }
524 : :
525 : : //! Return analytic solution for conserved variables
526 : : //! \param[in] xi X-coordinate at which to evaluate the analytic solution
527 : : //! \param[in] yi Y-coordinate at which to evaluate the analytic solution
528 : : //! \param[in] zi Z-coordinate at which to evaluate the analytic solution
529 : : //! \param[in] t Physical time at which to evaluate the analytic solution
530 : : //! \return Vector of analytic solution at given location and time
531 : : std::vector< tk::real >
532 : : solution( tk::real xi, tk::real yi, tk::real zi, tk::real t ) const
533 : 2211605 : { return Problem::initialize( m_ncomp, m_mat_blk, xi, yi, zi, t ); }
534 : :
535 : : //! Return time history field output evaluated at time history points
536 : : //! \param[in] h History point data
537 : : std::vector< std::vector< tk::real > >
538 : : histOutput( const std::vector< HistData >& h,
539 : : const std::vector< std::size_t >&,
540 : : const tk::UnsMesh::Coords&,
541 : : const tk::Fields&,
542 : : const tk::Fields& ) const
543 : : {
544 : 0 : std::vector< std::vector< tk::real > > Up(h.size()); //punt for now
545 : : return Up;
546 : : }
547 : :
548 : : //! Return cell-averaged total component mass per unit volume for an element
549 : : //! \param[in] e Element id for which total energy is required
550 : : //! \param[in] unk Vector of conserved quantities
551 : : //! \return Cell-averaged total component mass per unit volume for given
552 : : //! element. Since transport does not have an associated total energy,
553 : : //! return total mass.
554 : : tk::real sp_totalenergy(std::size_t e, const tk::Fields& unk) const
555 : : {
556 : 1315427 : const auto rdof = g_inputdeck.get< tag::rdof >();
557 : :
558 : : tk::real sp_m(0.0);
559 [ - - ][ + + ]: 2630854 : for (std::size_t c=0; c<m_ncomp; ++c) {
[ + + ][ + + ]
[ - - ]
560 : 1315427 : sp_m += unk(e,c*rdof);
561 : : }
562 : : return sp_m;
563 : : }
564 : :
565 : : private:
566 : : const Physics m_physics; //!< Physics policy
567 : : const Problem m_problem; //!< Problem policy
568 : : const ncomp_t m_ncomp; //!< Number of components in this PDE
569 : : //! BC configuration
570 : : BCStateFn m_bc;
571 : : //! \brief EOS material block - This PDE does not require an EOS block,
572 : : //! thus this variable has not been intialized.
573 : : std::vector< EOS > m_mat_blk;
574 : :
575 : : //! Evaluate physical flux function for this PDE system
576 : : //! \param[in] ncomp Number of scalar components in this PDE system
577 : : //! \param[in] ugp Numerical solution at the Gauss point at which to
578 : : //! evaluate the flux
579 : : //! \param[in] v Prescribed velocity evaluated at the Gauss point at which
580 : : //! to evaluate the flux
581 : : //! \return Flux vectors for all components in this PDE system
582 : : //! \note The function signature must follow tk::FluxFn
583 : : static tk::FluxFn::result_type
584 : 19672200 : flux( ncomp_t ncomp,
585 : : const std::vector< EOS >&,
586 : : const std::vector< tk::real >& ugp,
587 : : const std::vector< std::array< tk::real, 3 > >& v )
588 : :
589 : : {
590 : : Assert( ugp.size() == ncomp, "Size mismatch" );
591 : : Assert( v.size() == ncomp, "Size mismatch" );
592 : :
593 : 19672200 : std::vector< std::array< tk::real, 3 > > fl( ugp.size() );
594 : :
595 [ + + ]: 39344400 : for (ncomp_t c=0; c<ncomp; ++c)
596 : 19672200 : fl[c] = {{ v[c][0] * ugp[c], v[c][1] * ugp[c], v[c][2] * ugp[c] }};
597 : :
598 : 19672200 : return fl;
599 : : }
600 : :
601 : : //! \brief Boundary state function providing the left and right state of a
602 : : //! face at extrapolation boundaries
603 : : //! \param[in] ul Left (domain-internal) state
604 : : //! \return Left and right states for all scalar components in this PDE
605 : : //! system
606 : : //! \note The function signature must follow tk::StateFn
607 : : static tk::StateFn::result_type
608 : 8834220 : extrapolate( ncomp_t, const std::vector< EOS >&,
609 : : const std::vector< tk::real >& ul, tk::real, tk::real,
610 : : tk::real, tk::real, const std::array< tk::real, 3 >& )
611 : : {
612 : 8834220 : return {{ ul, ul }};
613 : : }
614 : :
615 : : //! \brief Boundary state function providing the left and right state of a
616 : : //! face at extrapolation boundaries
617 : : //! \param[in] ul Left (domain-internal) state
618 : : //! \return Left and right states for all scalar components in this PDE
619 : : //! system
620 : : //! \note The function signature must follow tk::StateFn
621 : : static tk::StateFn::result_type
622 : 163200 : inlet( ncomp_t, const std::vector< EOS >&,
623 : : const std::vector< tk::real >& ul, tk::real, tk::real, tk::real,
624 : : tk::real, const std::array< tk::real, 3 >& )
625 : : {
626 : 163200 : auto ur = ul;
627 : : std::fill( begin(ur), end(ur), 0.0 );
628 [ + - ]: 163200 : return {{ ul, std::move(ur) }};
629 : : }
630 : :
631 : : //! \brief Boundary state function providing the left and right state of a
632 : : //! face at outlet boundaries
633 : : //! \param[in] ul Left (domain-internal) state
634 : : //! \return Left and right states for all scalar components in this PDE
635 : : //! system
636 : : //! \note The function signature must follow tk::StateFn
637 : : static tk::StateFn::result_type
638 : 715200 : outlet( ncomp_t, const std::vector< EOS >&,
639 : : const std::vector< tk::real >& ul, tk::real, tk::real, tk::real,
640 : : tk::real, const std::array< tk::real, 3 >& )
641 : : {
642 : 715200 : return {{ ul, ul }};
643 : : }
644 : :
645 : : //! \brief Boundary state function providing the left and right state of a
646 : : //! face at Dirichlet boundaries
647 : : //! \param[in] ncomp Number of scalar components in this PDE system
648 : : //! \param[in] ul Left (domain-internal) state
649 : : //! \param[in] x X-coordinate at which to compute the states
650 : : //! \param[in] y Y-coordinate at which to compute the states
651 : : //! \param[in] z Z-coordinate at which to compute the states
652 : : //! \param[in] t Physical time
653 : : //! \return Left and right states for all scalar components in this PDE
654 : : //! system
655 : : //! \note The function signature must follow tk::StateFn
656 : : static tk::StateFn::result_type
657 : 972540 : dirichlet( ncomp_t ncomp,
658 : : const std::vector< EOS >& mat_blk,
659 : : const std::vector< tk::real >& ul, tk::real x, tk::real y,
660 : : tk::real z, tk::real t, const std::array< tk::real, 3 >& )
661 : : {
662 : 972540 : return {{ ul, Problem::initialize( ncomp, mat_blk, x, y, z, t ) }};
663 : : }
664 : :
665 : : //----------------------------------------------------------------------------
666 : : // Boundary Gradient functions
667 : : //----------------------------------------------------------------------------
668 : :
669 : : //! \brief Boundary gradient function copying the left gradient to the right
670 : : //! gradient at a face
671 : : //! \param[in] dul Left (domain-internal) state
672 : : //! \return Left and right states for all scalar components in this PDE
673 : : //! system
674 : : //! \note The function signature must follow tk::StateFn.
675 : : static tk::StateFn::result_type
676 : 0 : noOpGrad( ncomp_t,
677 : : const std::vector< EOS >&,
678 : : const std::vector< tk::real >& dul,
679 : : tk::real, tk::real, tk::real, tk::real,
680 : : const std::array< tk::real, 3 >& )
681 : : {
682 : 0 : return {{ dul, dul }};
683 : : }
684 : : };
685 : :
686 : : } // dg::
687 : : } // inciter::
688 : :
689 : : #endif // DGTransport_h
|