Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/PDE/DGPDE.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 Partial differential equation base for discontinuous Galerkin PDEs
9 : : \details This file defines a generic partial differential equation (PDE)
10 : : class for PDEs that use discontinuous Galerkin spatial discretization.
11 : : The class uses runtime polymorphism without client-side inheritance:
12 : : inheritance is confined to the internals of the class, invisible to
13 : : client-code. The class exclusively deals with ownership enabling client-side
14 : : value semantics. Credit goes to Sean Parent at Adobe:
15 : : https://github.com/sean-parent/sean-parent.github.com/wiki/
16 : : Papers-and-Presentations.
17 : : */
18 : : // *****************************************************************************
19 : : #ifndef DGPDE_h
20 : : #define DGPDE_h
21 : :
22 : : #include <array>
23 : : #include <string>
24 : : #include <vector>
25 : : #include <memory>
26 : : #include <unordered_set>
27 : : #include <functional>
28 : :
29 : : #include "Types.hpp"
30 : : #include "Fields.hpp"
31 : : #include "FaceData.hpp"
32 : : #include "UnsMesh.hpp"
33 : : #include "Inciter/InputDeck/InputDeck.hpp"
34 : : #include "FunctionPrototypes.hpp"
35 : : #include "History.hpp"
36 : :
37 : : namespace inciter {
38 : :
39 : : extern ctr::InputDeck g_inputdeck;
40 : :
41 : : using ncomp_t = tk::ncomp_t;
42 : : using BCStateFn =
43 : : std::vector< std::tuple< std::vector< std::size_t >, tk::StateFn, tk::StateFn > >;
44 : :
45 : : //! Extract BC configuration ignoring if BC not specified
46 : : //! \note A more preferable way of catching errors such as this function
47 : : //! hides is during parsing, so that we don't even get here if BCs are
48 : : //! not correctly specified. For now we simply ignore if BCs are not
49 : : //! specified by allowing empty BC vectors from the user input.
50 : : struct ConfigBC {
51 : : BCStateFn& state; //!< BC state config: sidesets + statefn
52 : : const std::vector< tk::StateFn >& fn; //!< BC state functions
53 : : const std::vector< tk::StateFn >& gfn; //!< BC gradient functions
54 : : std::size_t c; //!< Counts BC types configured
55 : : //! Constructor
56 : 472 : ConfigBC( BCStateFn& s,
57 : : const std::vector< tk::StateFn >& f,
58 : 472 : const std::vector< tk::StateFn >& gf ) :
59 : 472 : state(s), fn(f), gfn(gf), c(0) {}
60 : : //! Function to call for each BC type
61 : 3304 : template< typename U > void operator()( brigand::type_<U> ) {
62 : 6608 : std::vector< std::size_t > cfg, v;
63 : : // collect sidesets across all meshes
64 [ + + ]: 6608 : for (const auto& ibc : g_inputdeck.get< tag::bc >()) {
65 [ + - ]: 3304 : v.insert(v.end(), ibc.get< U >().begin(), ibc.get< U >().end());
66 : : }
67 [ + + ][ + - ]: 3304 : if (v.size() > 0) cfg = v;
68 [ - + ][ - - ]: 3304 : Assert( fn.size() > c, "StateFn missing for BC type" );
[ - - ][ - - ]
69 [ + - ][ + - ]: 3304 : state.push_back( { cfg, fn[c], gfn[c] } );
70 : 3304 : ++c;
71 : 3304 : }
72 : : };
73 : :
74 : : //! \brief Extract information on inlet BCs, which have a different structure
75 : : //! than other BCs
76 : : void ConfigInletBC( BCStateFn&,
77 : : const tk::StateFn&,
78 : : const tk::StateFn& );
79 : :
80 : : //! \brief Extract information on back pressure BCs, which have a different
81 : : //! structure than other BCs
82 : : void ConfigBackPressureBC( BCStateFn&,
83 : : const tk::StateFn&,
84 : : const tk::StateFn& );
85 : :
86 : : //! State function for invalid/un-configured boundary conditions
87 : : [[noreturn]] tk::StateFn::result_type
88 : : invalidBC( ncomp_t, const std::vector< EOS >&,
89 : : const std::vector< tk::real >&, tk::real, tk::real, tk::real,
90 : : tk::real, const std::array< tk::real, 3> & );
91 : :
92 : : //! \brief Partial differential equation base for discontinuous Galerkin PDEs
93 : : //! \details This class uses runtime polymorphism without client-side
94 : : //! inheritance: inheritance is confined to the internals of the this class,
95 : : //! invisible to client-code. The class exclusively deals with ownership
96 : : //! enabling client-side value semantics. Credit goes to Sean Parent at Adobe:
97 : : //! https://github.com/sean-parent/sean-parent.github.com/wiki/
98 : : //! Papers-and-Presentations. For example client code that models a DGPDE,
99 : : //! see inciter::CompFlow.
100 : : class DGPDE {
101 : :
102 : : private:
103 : : using ncomp_t = tk::ncomp_t;
104 : :
105 : : public:
106 : : //! Default constructor taking no arguments for Charm++
107 : 0 : explicit DGPDE() = default;
108 : :
109 : : //! \brief Constructor taking an object modeling Concept.
110 : : //! \details The object of class T comes pre-constructed.
111 : : //! \param[in] x Instantiated object of type T given by the template
112 : : //! argument.
113 : : template< typename T > explicit DGPDE( T x ) :
114 : : self( std::make_unique< Model<T> >( std::move(x) ) ) {}
115 : :
116 : : //! \brief Constructor taking a function pointer to a constructor of an
117 : : //! object modeling Concept.
118 : : //! \details Passing std::function allows late execution of the constructor,
119 : : //! i.e., as late as inside this class' constructor, and thus usage from
120 : : //! a factory. Note that there are at least two different ways of using
121 : : //! this constructor:
122 : : //! - Bind T's constructor arguments and place it in std::function<T()>
123 : : //! and passing no arguments as args.... This case then instantiates the
124 : : //! model via its constructor and stores it in here.
125 : : //! - Bind a single placeholder argument to T's constructor and pass it in
126 : : //! as host's args..., which then forwards it to model's constructor. This
127 : : //! allows late binding, i.e., binding the argument only here.
128 : : //! \see See also the wrapper tk::recordModel() which does the former and
129 : : //! tk::recordModelLate() which does the latter, both defined in
130 : : //! src/Base/Factory.h.
131 : : //! \param[in] x Function pointer to a constructor of an object modeling
132 : : //! Concept.
133 : : //! \param[in] args Zero or more constructor arguments
134 : : template< typename T, typename...Args >
135 : 396 : explicit DGPDE( std::function<T(Args...)> x, Args&&... args ) :
136 : : self( std::make_unique< Model<T> >(
137 [ + - ]: 396 : std::move( x( std::forward<Args>(args)... ) ) ) ) {}
138 : :
139 : : //! Public interface to find number of primitive quantities for the diff eq
140 : 889 : std::size_t nprim() const
141 : 889 : { return self->nprim(); }
142 : :
143 : : //! Public interface to find number of materials for the diff eq
144 : : std::size_t nmat() const
145 : : { return self->nmat(); }
146 : :
147 : : //! Public interface to find Dofs for each equation in pde system
148 : 889 : void numEquationDofs(std::vector< std::size_t >& numEqDof) const
149 : 889 : { return self->numEquationDofs(numEqDof); }
150 : :
151 : : //! Public interface to find how 'stiff equations', which are the inverse
152 : : //! deformation equations because of plasticity
153 : 3556 : std::size_t nstiffeq() const
154 : 3556 : { return self->nstiffeq(); }
155 : :
156 : : //! Public interface to find how 'nonstiff equations', which are the inverse
157 : : //! deformation equations because of plasticity
158 : 1778 : std::size_t nnonstiffeq() const
159 : 1778 : { return self->nnonstiffeq(); }
160 : :
161 : : //! Public function to locate the stiff equations
162 : 0 : void setStiffEqIdx( std::vector< std::size_t >& stiffEqIdx ) const
163 : 0 : { return self->setStiffEqIdx( stiffEqIdx ); }
164 : :
165 : : //! Public function to locate the nonstiff equations
166 : 0 : void setNonStiffEqIdx( std::vector< std::size_t >& nonStiffEqIdx ) const
167 : 0 : { return self->setNonStiffEqIdx( nonStiffEqIdx ); }
168 : :
169 : : //! Public interface to determine elements that lie inside the IC box
170 : 889 : void IcBoxElems( const tk::Fields& geoElem,
171 : : std::size_t nielem,
172 : : std::vector< std::unordered_set< std::size_t > >& inbox ) const
173 : 889 : { self->IcBoxElems( geoElem, nielem, inbox ); }
174 : :
175 : : //! Public interface to setting the initial conditions for the diff eq
176 : 1021 : void initialize(
177 : : const tk::Fields& L,
178 : : const std::vector< std::size_t >& inpoel,
179 : : const tk::UnsMesh::Coords& coord,
180 : : const std::vector< std::unordered_set< std::size_t > >& inbox,
181 : : const std::unordered_map< std::size_t, std::set< std::size_t > >&
182 : : elemblkid,
183 : : tk::Fields& unk,
184 : : tk::real t,
185 : : const std::size_t nielem ) const
186 : 1021 : { self->initialize( L, inpoel, coord, inbox, elemblkid, unk, t, nielem ); }
187 : :
188 : : //! Public interface for computing density constraint
189 : 2198 : void computeDensityConstr( std::size_t nelem,
190 : : tk::Fields& unk,
191 : : std::vector< tk::real >& densityConstr) const
192 : 2198 : { self->computeDensityConstr( nelem, unk, densityConstr); }
193 : :
194 : : //! Public interface to computing the left-hand side matrix for the diff eq
195 : 1021 : void lhs( const tk::Fields& geoElem, tk::Fields& l ) const
196 : 1021 : { self->lhs( geoElem, l ); }
197 : :
198 : : //! Public interface to updating the interface cells for the diff eq
199 : 71805 : void updateInterfaceCells( tk::Fields& unk,
200 : : std::size_t nielem,
201 : : std::vector< std::size_t >& ndofel,
202 : : std::vector< std::size_t >& interface ) const
203 : 71805 : { self->updateInterfaceCells( unk, nielem, ndofel, interface ); }
204 : :
205 : : //! Public interface to updating the primitives for the diff eq
206 : 72694 : void updatePrimitives( const tk::Fields& unk,
207 : : const tk::Fields& L,
208 : : const tk::Fields& geoElem,
209 : : tk::Fields& prim,
210 : : std::size_t nielem,
211 : : const std::vector< std::size_t >& ndofel ) const
212 : 72694 : { self->updatePrimitives( unk, L, geoElem, prim, nielem, ndofel ); }
213 : :
214 : : //! Public interface to cleaning up trace materials for the diff eq
215 : 71805 : void cleanTraceMaterial( tk::real t,
216 : : const tk::Fields& geoElem,
217 : : tk::Fields& unk,
218 : : tk::Fields& prim,
219 : : std::size_t nielem ) const
220 : 71805 : { self->cleanTraceMaterial( t, geoElem, unk, prim, nielem ); }
221 : :
222 : : //! Public interface to reconstructing the second-order solution
223 : 43965 : void reconstruct( tk::real t,
224 : : const tk::Fields& geoFace,
225 : : const tk::Fields& geoElem,
226 : : const inciter::FaceData& fd,
227 : : const std::map< std::size_t, std::vector< std::size_t > >&
228 : : esup,
229 : : const std::vector< std::size_t >& inpoel,
230 : : const tk::UnsMesh::Coords& coord,
231 : : tk::Fields& U,
232 : : tk::Fields& P,
233 : : const bool pref,
234 : : const std::vector< std::size_t >& ndofel ) const
235 : : {
236 : 43965 : self->reconstruct( t, geoFace, geoElem, fd, esup, inpoel, coord, U, P,
237 : 43965 : pref, ndofel );
238 : 43965 : }
239 : :
240 : : //! Public interface to limiting the second-order solution
241 : 43965 : void limit( tk::real t,
242 : : const bool pref,
243 : : const tk::Fields& geoFace,
244 : : const tk::Fields& geoElem,
245 : : const inciter::FaceData& fd,
246 : : const std::map< std::size_t, std::vector< std::size_t > >& esup,
247 : : const std::vector< std::size_t >& inpoel,
248 : : const tk::UnsMesh::Coords& coord,
249 : : const std::vector< std::size_t >& ndofel,
250 : : const std::vector< std::size_t >& gid,
251 : : const std::unordered_map< std::size_t, std::size_t >& bid,
252 : : const std::vector< std::vector<tk::real> >& uNodalExtrm,
253 : : const std::vector< std::vector<tk::real> >& pNodalExtrm,
254 : : const std::vector< std::vector<tk::real> >& mtInv,
255 : : tk::Fields& U,
256 : : tk::Fields& P,
257 : : std::vector< std::size_t >& shockmarker ) const
258 : : {
259 : 43965 : self->limit( t, pref, geoFace, geoElem, fd, esup, inpoel, coord, ndofel,
260 : 43965 : gid, bid, uNodalExtrm, pNodalExtrm, mtInv, U, P, shockmarker );
261 : 43965 : }
262 : :
263 : : //! Public interface to update the conservative variable solution
264 : 39915 : void CPL( const tk::Fields& prim,
265 : : const tk::Fields& geoElem,
266 : : const std::vector< std::size_t >& inpoel,
267 : : const tk::UnsMesh::Coords& coord,
268 : : tk::Fields& unk,
269 : : std::size_t nielem ) const
270 : : {
271 : 39915 : self->CPL( prim, geoElem, inpoel, coord, unk, nielem );
272 : 39915 : }
273 : :
274 : : //! Public interface to reset the high order solution for p-adaptive scheme
275 : 1770 : void resetAdapSol( const inciter::FaceData& fd,
276 : : tk::Fields& unk,
277 : : tk::Fields& prim,
278 : : const std::vector< std::size_t >& ndofel ) const
279 : : {
280 : 1770 : self->resetAdapSol( fd, unk, prim, ndofel );
281 : 1770 : }
282 : :
283 : : //! Public interface to getting the cell-averaged deformation gradients
284 : : std::array< std::vector< tk::real >, 9 > cellAvgDeformGrad(
285 : : const tk::Fields& U,
286 : : std::size_t nielem ) const
287 : : {
288 : : return self->cellAvgDeformGrad( U, nielem );
289 : : }
290 : :
291 : : //! Public interface to computing the P1 right-hand side vector
292 : 71805 : void rhs( tk::real t,
293 : : const bool pref,
294 : : const tk::Fields& geoFace,
295 : : const tk::Fields& geoElem,
296 : : const inciter::FaceData& fd,
297 : : const std::vector< std::size_t >& inpoel,
298 : : const std::vector< std::unordered_set< std::size_t > >& boxelems,
299 : : const tk::UnsMesh::Coords& coord,
300 : : const tk::Fields& U,
301 : : const tk::Fields& P,
302 : : const std::vector< std::size_t >& ndofel,
303 : : const tk::real dt,
304 : : tk::Fields& R ) const
305 : : {
306 : 71805 : self->rhs( t, pref, geoFace, geoElem, fd, inpoel, boxelems, coord, U, P,
307 : 71805 : ndofel, dt, R );
308 : 71805 : }
309 : :
310 : : //! Evaluate the adaptive indicator and mark the ndof for each element
311 : 1636 : void eval_ndof( std::size_t nunk,
312 : : const tk::UnsMesh::Coords& coord,
313 : : const std::vector< std::size_t >& inpoel,
314 : : const inciter::FaceData& fd,
315 : : const tk::Fields& unk,
316 : : const tk::Fields& prim,
317 : : inciter::ctr::PrefIndicatorType indicator,
318 : : std::size_t ndof,
319 : : std::size_t ndofmax,
320 : : tk::real tolref,
321 : : std::vector< std::size_t >& ndofel ) const
322 : : {
323 : 1636 : self->eval_ndof( nunk, coord, inpoel, fd, unk, prim, indicator, ndof,
324 : 1636 : ndofmax, tolref, ndofel );
325 : 1636 : }
326 : :
327 : : //! Public interface for computing the minimum time step size
328 : 2330 : tk::real dt( const std::array< std::vector< tk::real >, 3 >& coord,
329 : : const std::vector< std::size_t >& inpoel,
330 : : const inciter::FaceData& fd,
331 : : const tk::Fields& geoFace,
332 : : const tk::Fields& geoElem,
333 : : const std::vector< std::size_t >& ndofel,
334 : : const tk::Fields& U,
335 : : const tk::Fields& P,
336 : : const std::size_t nielem ) const
337 : 4660 : { return self->dt( coord, inpoel, fd, geoFace, geoElem, ndofel, U,
338 : 2330 : P, nielem ); }
339 : :
340 : : //! Public interface for computing stiff terms for an element
341 : 0 : void stiff_rhs( std::size_t e,
342 : : const tk::Fields& geoElem,
343 : : const std::vector< std::size_t >& inpoel,
344 : : const tk::UnsMesh::Coords& coord,
345 : : const tk::Fields& U,
346 : : const tk::Fields& P,
347 : : const std::vector< std::size_t >& ndofel,
348 : : tk::Fields& R ) const
349 : 0 : { return self->stiff_rhs( e, geoElem, inpoel, coord, U, P, ndofel, R); }
350 : :
351 : : //! Public interface to returning maps of output var functions
352 : 4396 : std::map< std::string, tk::GetVarFn > OutVarFn() const
353 : 4396 : { return self->OutVarFn(); }
354 : :
355 : : //! Public interface to returning analytic field output labels
356 : 1505 : std::vector< std::string > analyticFieldNames() const
357 : 1505 : { return self->analyticFieldNames(); }
358 : :
359 : : //! Public interface to returning time history field output labels
360 : 0 : std::vector< std::string > histNames() const { return self->histNames(); }
361 : :
362 : : //! Public interface to returning variable names
363 : 88 : std::vector< std::string > names() const { return self->names(); }
364 : :
365 : : //! Public interface to returning surface field output
366 : : std::vector< std::vector< tk::real > >
367 : : surfOutput( const std::map< int, std::vector< std::size_t > >& bnd,
368 : : tk::Fields& U ) const
369 : : { return self->surfOutput( bnd, U ); }
370 : :
371 : : //! Public interface to return point history output
372 : : std::vector< std::vector< tk::real > >
373 : 0 : histOutput( const std::vector< HistData >& h,
374 : : const std::vector< std::size_t >& inpoel,
375 : : const tk::UnsMesh::Coords& coord,
376 : : const tk::Fields& U,
377 : : const tk::Fields& P ) const
378 : 0 : { return self->histOutput( h, inpoel, coord, U, P ); }
379 : :
380 : : //! Public interface to returning analytic solution
381 : : tk::InitializeFn::result_type
382 : 1188068 : analyticSolution( tk::real xi, tk::real yi, tk::real zi, tk::real t ) const
383 : 1188068 : { return self->analyticSolution( xi, yi, zi, t ); }
384 : :
385 : : //! Public interface to returning the analytic solution for conserved vars
386 : : tk::InitializeFn::result_type
387 : 6231923 : solution( tk::real xi, tk::real yi, tk::real zi, tk::real t ) const
388 : 6231923 : { return self->solution( xi, yi, zi, t ); }
389 : :
390 : : //! Public interface to returning the specific total energy
391 : : tk::real
392 : 3380569 : sp_totalenergy( std::size_t e, const tk::Fields& unk ) const
393 : 3380569 : { return self->sp_totalenergy( e, unk ); }
394 : :
395 : : //! Copy assignment
396 : : DGPDE& operator=( const DGPDE& x )
397 : : { DGPDE tmp(x); *this = std::move(tmp); return *this; }
398 : : //! Copy constructor
399 : : DGPDE( const DGPDE& x ) : self( x.self->copy() ) {}
400 : : //! Move assignment
401 : : DGPDE& operator=( DGPDE&& ) noexcept = default;
402 : : //! Move constructor
403 : 396 : DGPDE( DGPDE&& ) noexcept = default;
404 : :
405 : : private:
406 : : //! \brief Concept is a pure virtual base class specifying the requirements
407 : : //! of polymorphic objects deriving from it
408 : : struct Concept {
409 : 396 : Concept() = default;
410 : 0 : Concept( const Concept& ) = default;
411 : 396 : virtual ~Concept() = default;
412 : : virtual Concept* copy() const = 0;
413 : : virtual std::size_t nprim() const = 0;
414 : : virtual std::size_t nmat() const = 0;
415 : : virtual void numEquationDofs(std::vector< std::size_t >&) const = 0;
416 : : virtual std::size_t nstiffeq() const = 0;
417 : : virtual std::size_t nnonstiffeq() const = 0;
418 : : virtual void setStiffEqIdx( std::vector< std::size_t >& ) const = 0;
419 : : virtual void setNonStiffEqIdx( std::vector< std::size_t >& ) const = 0;
420 : : virtual void IcBoxElems( const tk::Fields&,
421 : : std::size_t,
422 : : std::vector< std::unordered_set< std::size_t > >& ) const = 0;
423 : : virtual void initialize(
424 : : const tk::Fields&,
425 : : const std::vector< std::size_t >&,
426 : : const tk::UnsMesh::Coords&,
427 : : const std::vector< std::unordered_set< std::size_t > >&,
428 : : const std::unordered_map< std::size_t, std::set< std::size_t > >&,
429 : : tk::Fields&,
430 : : tk::real,
431 : : const std::size_t nielem ) const = 0;
432 : : virtual void computeDensityConstr( std::size_t nelem,
433 : : tk::Fields& unk,
434 : : std::vector< tk::real >& densityConstr)
435 : : const = 0;
436 : : virtual void lhs( const tk::Fields&, tk::Fields& ) const = 0;
437 : : virtual void updateInterfaceCells( tk::Fields&,
438 : : std::size_t,
439 : : std::vector< std::size_t >&,
440 : : std::vector< std::size_t >& ) const = 0;
441 : : virtual void updatePrimitives( const tk::Fields&,
442 : : const tk::Fields&,
443 : : const tk::Fields&,
444 : : tk::Fields&,
445 : : std::size_t,
446 : : const std::vector< std::size_t >& ) const = 0;
447 : : virtual void cleanTraceMaterial( tk::real,
448 : : const tk::Fields&,
449 : : tk::Fields&,
450 : : tk::Fields&,
451 : : std::size_t ) const = 0;
452 : : virtual void reconstruct( tk::real,
453 : : const tk::Fields&,
454 : : const tk::Fields&,
455 : : const inciter::FaceData&,
456 : : const std::map< std::size_t,
457 : : std::vector< std::size_t > >&,
458 : : const std::vector< std::size_t >&,
459 : : const tk::UnsMesh::Coords&,
460 : : tk::Fields&,
461 : : tk::Fields&,
462 : : const bool,
463 : : const std::vector< std::size_t >& ) const = 0;
464 : : virtual void limit( tk::real,
465 : : const bool,
466 : : const tk::Fields&,
467 : : const tk::Fields&,
468 : : const inciter::FaceData&,
469 : : const std::map< std::size_t,
470 : : std::vector< std::size_t > >&,
471 : : const std::vector< std::size_t >&,
472 : : const tk::UnsMesh::Coords&,
473 : : const std::vector< std::size_t >&,
474 : : const std::vector< std::size_t >&,
475 : : const std::unordered_map< std::size_t, std::size_t >&,
476 : : const std::vector< std::vector<tk::real> >&,
477 : : const std::vector< std::vector<tk::real> >&,
478 : : const std::vector< std::vector<tk::real> >&,
479 : : tk::Fields&,
480 : : tk::Fields&,
481 : : std::vector< std::size_t >& ) const = 0;
482 : : virtual void CPL( const tk::Fields&,
483 : : const tk::Fields&,
484 : : const std::vector< std::size_t >&,
485 : : const tk::UnsMesh::Coords&,
486 : : tk::Fields&,
487 : : std::size_t ) const = 0;
488 : : virtual std::array< std::vector< tk::real >, 9 > cellAvgDeformGrad(
489 : : const tk::Fields&,
490 : : std::size_t ) const = 0;
491 : : virtual void rhs( tk::real,
492 : : const bool,
493 : : const tk::Fields&,
494 : : const tk::Fields&,
495 : : const inciter::FaceData&,
496 : : const std::vector< std::size_t >&,
497 : : const std::vector< std::unordered_set< std::size_t > >&,
498 : : const tk::UnsMesh::Coords&,
499 : : const tk::Fields&,
500 : : const tk::Fields&,
501 : : const std::vector< std::size_t >&,
502 : : const tk::real,
503 : : tk::Fields& ) const = 0;
504 : : virtual void resetAdapSol( const inciter::FaceData&,
505 : : tk::Fields&,
506 : : tk::Fields&,
507 : : const std::vector< std::size_t >& )
508 : : const = 0;
509 : : virtual void eval_ndof( std::size_t,
510 : : const tk::UnsMesh::Coords&,
511 : : const std::vector< std::size_t >&,
512 : : const inciter::FaceData&,
513 : : const tk::Fields&,
514 : : const tk::Fields&,
515 : : inciter::ctr::PrefIndicatorType,
516 : : std::size_t,
517 : : std::size_t,
518 : : tk::real,
519 : : std::vector< std::size_t >& ) const = 0;
520 : : virtual tk::real dt( const std::array< std::vector< tk::real >, 3 >&,
521 : : const std::vector< std::size_t >&,
522 : : const inciter::FaceData&,
523 : : const tk::Fields&,
524 : : const tk::Fields&,
525 : : const std::vector< std::size_t >&,
526 : : const tk::Fields&,
527 : : const tk::Fields&,
528 : : const std::size_t ) const = 0;
529 : : virtual void stiff_rhs( std::size_t,
530 : : const tk::Fields&,
531 : : const std::vector< std::size_t >&,
532 : : const tk::UnsMesh::Coords&,
533 : : const tk::Fields&,
534 : : const tk::Fields&,
535 : : const std::vector< std::size_t >&,
536 : : tk::Fields& ) const = 0;
537 : : virtual std::map< std::string, tk::GetVarFn > OutVarFn() const = 0;
538 : : virtual std::vector< std::string > analyticFieldNames() const = 0;
539 : : virtual std::vector< std::string > histNames() const = 0;
540 : : virtual std::vector< std::string > names() const = 0;
541 : : virtual std::vector< std::vector< tk::real > > surfOutput(
542 : : const std::map< int, std::vector< std::size_t > >&,
543 : : tk::Fields& ) const = 0;
544 : : virtual std::vector< std::vector< tk::real > > histOutput(
545 : : const std::vector< HistData >&,
546 : : const std::vector< std::size_t >&,
547 : : const tk::UnsMesh::Coords&,
548 : : const tk::Fields&,
549 : : const tk::Fields& ) const = 0;
550 : : virtual tk::InitializeFn::result_type analyticSolution(
551 : : tk::real xi, tk::real yi, tk::real zi, tk::real t ) const = 0;
552 : : virtual tk::InitializeFn::result_type solution(
553 : : tk::real xi, tk::real yi, tk::real zi, tk::real t ) const = 0;
554 : : virtual tk::real sp_totalenergy(
555 : : std::size_t, const tk::Fields& ) const = 0;
556 : : };
557 : :
558 : : //! \brief Model models the Concept above by deriving from it and overriding
559 : : //! the virtual functions required by Concept
560 : : template< typename T >
561 : : struct Model : Concept {
562 : 396 : explicit Model( T x ) : data( std::move(x) ) {}
563 [ - - ]: 0 : Concept* copy() const override { return new Model( *this ); }
564 : 889 : std::size_t nprim() const override
565 : 889 : { return data.nprim(); }
566 : 0 : std::size_t nmat() const override
567 : 0 : { return data.nmat(); }
568 : 889 : void numEquationDofs(std::vector< std::size_t >& numEqDof) const override
569 : 889 : { data.numEquationDofs(numEqDof); }
570 : 3556 : std::size_t nstiffeq() const override
571 : 3556 : { return data.nstiffeq(); }
572 : 1778 : std::size_t nnonstiffeq() const override
573 : 1778 : { return data.nnonstiffeq(); }
574 : 0 : void setStiffEqIdx( std::vector< std::size_t >& stiffEqIdx ) const override
575 : 0 : { data.setStiffEqIdx(stiffEqIdx); }
576 : 0 : void setNonStiffEqIdx( std::vector< std::size_t >& nonStiffEqIdx ) const override
577 : 0 : { data.setNonStiffEqIdx(nonStiffEqIdx); }
578 : 889 : void IcBoxElems( const tk::Fields& geoElem,
579 : : std::size_t nielem,
580 : : std::vector< std::unordered_set< std::size_t > >& inbox )
581 : 889 : const override { data.IcBoxElems( geoElem, nielem, inbox ); }
582 : 1021 : void initialize(
583 : : const tk::Fields& L,
584 : : const std::vector< std::size_t >& inpoel,
585 : : const tk::UnsMesh::Coords& coord,
586 : : const std::vector< std::unordered_set< std::size_t > >& inbox,
587 : : const std::unordered_map< std::size_t, std::set< std::size_t > >&
588 : : elemblkid,
589 : : tk::Fields& unk,
590 : : tk::real t,
591 : : const std::size_t nielem )
592 : 1021 : const override { data.initialize( L, inpoel, coord, inbox, elemblkid, unk,
593 : 1021 : t, nielem ); }
594 : 2198 : void computeDensityConstr( std::size_t nelem,
595 : : tk::Fields& unk,
596 : : std::vector< tk::real >& densityConstr)
597 : : const override
598 : 2198 : { data.computeDensityConstr( nelem, unk, densityConstr ); }
599 : 1021 : void lhs( const tk::Fields& geoElem, tk::Fields& l ) const override
600 : 1021 : { data.lhs( geoElem, l ); }
601 : 71805 : void updateInterfaceCells( tk::Fields& unk,
602 : : std::size_t nielem,
603 : : std::vector< std::size_t >& ndofel,
604 : : std::vector< std::size_t >& interface )
605 : 71805 : const override { data.updateInterfaceCells( unk, nielem, ndofel, interface ); }
606 : 72694 : void updatePrimitives( const tk::Fields& unk,
607 : : const tk::Fields& L,
608 : : const tk::Fields& geoElem,
609 : : tk::Fields& prim,
610 : : std::size_t nielem,
611 : : const std::vector< std::size_t >& ndofel )
612 : : const override {
613 : 72694 : data.updatePrimitives( unk, L, geoElem, prim, nielem, ndofel );
614 : 72694 : }
615 : 71805 : void cleanTraceMaterial( tk::real t,
616 : : const tk::Fields& geoElem,
617 : : tk::Fields& unk,
618 : : tk::Fields& prim,
619 : : std::size_t nielem )
620 : 71805 : const override { data.cleanTraceMaterial( t, geoElem, unk, prim, nielem ); }
621 : 43965 : void reconstruct( tk::real t,
622 : : const tk::Fields& geoFace,
623 : : const tk::Fields& geoElem,
624 : : const inciter::FaceData& fd,
625 : : const std::map< std::size_t,
626 : : std::vector< std::size_t > >& esup,
627 : : const std::vector< std::size_t >& inpoel,
628 : : const tk::UnsMesh::Coords& coord,
629 : : tk::Fields& U,
630 : : tk::Fields& P,
631 : : const bool pref,
632 : : const std::vector< std::size_t >& ndofel )const override
633 : : {
634 : 43965 : data.reconstruct( t, geoFace, geoElem, fd, esup, inpoel, coord, U, P,
635 : : pref, ndofel );
636 : 43965 : }
637 : 43965 : void limit( tk::real t,
638 : : const bool pref,
639 : : const tk::Fields& geoFace,
640 : : const tk::Fields& geoElem,
641 : : const inciter::FaceData& fd,
642 : : const std::map< std::size_t, std::vector< std::size_t > >&
643 : : esup,
644 : : const std::vector< std::size_t >& inpoel,
645 : : const tk::UnsMesh::Coords& coord,
646 : : const std::vector< std::size_t >& ndofel,
647 : : const std::vector< std::size_t >& gid,
648 : : const std::unordered_map< std::size_t, std::size_t >& bid,
649 : : const std::vector< std::vector<tk::real> >& uNodalExtrm,
650 : : const std::vector< std::vector<tk::real> >& pNodalExtrm,
651 : : const std::vector< std::vector<tk::real> >& mtInv,
652 : : tk::Fields& U,
653 : : tk::Fields& P,
654 : : std::vector< std::size_t >& shockmarker ) const override
655 : : {
656 : 43965 : data.limit( t, pref, geoFace, geoElem, fd, esup, inpoel, coord, ndofel, gid,
657 : : bid, uNodalExtrm, pNodalExtrm, mtInv, U, P, shockmarker );
658 : 43965 : }
659 : 39915 : void CPL( const tk::Fields& prim,
660 : : const tk::Fields& geoElem,
661 : : const std::vector< std::size_t >& inpoel,
662 : : const tk::UnsMesh::Coords& coord,
663 : : tk::Fields& unk,
664 : : std::size_t nielem ) const override
665 : : {
666 : 39915 : data.CPL( prim, geoElem, inpoel, coord, unk, nielem );
667 : 39915 : }
668 : 1770 : void resetAdapSol( const inciter::FaceData& fd,
669 : : tk::Fields& unk,
670 : : tk::Fields& prim,
671 : : const std::vector< std::size_t >& ndofel ) const override
672 : : {
673 : 1770 : data.resetAdapSol( fd, unk, prim, ndofel );
674 : 1770 : }
675 : 0 : std::array< std::vector< tk::real >, 9 > cellAvgDeformGrad(
676 : : const tk::Fields& U,
677 : : std::size_t nielem ) const override
678 : : {
679 : 0 : return data.cellAvgDeformGrad( U, nielem );
680 : : }
681 : 71805 : void rhs(
682 : : tk::real t,
683 : : const bool pref,
684 : : const tk::Fields& geoFace,
685 : : const tk::Fields& geoElem,
686 : : const inciter::FaceData& fd,
687 : : const std::vector< std::size_t >& inpoel,
688 : : const std::vector< std::unordered_set< std::size_t > >& boxelems,
689 : : const tk::UnsMesh::Coords& coord,
690 : : const tk::Fields& U,
691 : : const tk::Fields& P,
692 : : const std::vector< std::size_t >& ndofel,
693 : : const tk::real dt,
694 : : tk::Fields& R ) const override
695 : : {
696 : 71805 : data.rhs( t, pref, geoFace, geoElem, fd, inpoel, boxelems, coord, U, P,
697 : : ndofel, dt, R );
698 : 71805 : }
699 : 1636 : void eval_ndof( std::size_t nunk,
700 : : const tk::UnsMesh::Coords& coord,
701 : : const std::vector< std::size_t >& inpoel,
702 : : const inciter::FaceData& fd,
703 : : const tk::Fields& unk,
704 : : const tk::Fields& prim,
705 : : inciter::ctr::PrefIndicatorType indicator,
706 : : std::size_t ndof,
707 : : std::size_t ndofmax,
708 : : tk::real tolref,
709 : : std::vector< std::size_t >& ndofel ) const override
710 : 1636 : { data.eval_ndof( nunk, coord, inpoel, fd, unk, prim, indicator, ndof,
711 : 1636 : ndofmax, tolref, ndofel ); }
712 : 2330 : tk::real dt( const std::array< std::vector< tk::real >, 3 >& coord,
713 : : const std::vector< std::size_t >& inpoel,
714 : : const inciter::FaceData& fd,
715 : : const tk::Fields& geoFace,
716 : : const tk::Fields& geoElem,
717 : : const std::vector< std::size_t >& ndofel,
718 : : const tk::Fields& U,
719 : : const tk::Fields& P,
720 : : const std::size_t nielem ) const override
721 : : { return data.dt( coord, inpoel, fd, geoFace, geoElem, ndofel,
722 : 2330 : U, P, nielem ); }
723 : 0 : void stiff_rhs( std::size_t e,
724 : : const tk::Fields& geoElem,
725 : : const std::vector< std::size_t >& inpoel,
726 : : const tk::UnsMesh::Coords& coord,
727 : : const tk::Fields& U,
728 : : const tk::Fields& P,
729 : : const std::vector< std::size_t >& ndofel,
730 : : tk::Fields& R ) const override
731 : 0 : { return data.stiff_rhs( e, geoElem, inpoel, coord, U, P, ndofel, R ); }
732 : 4396 : std::map< std::string, tk::GetVarFn > OutVarFn() const override
733 : 4396 : { return data.OutVarFn(); }
734 : 1505 : std::vector< std::string > analyticFieldNames() const override
735 : 1505 : { return data.analyticFieldNames(); }
736 : 0 : std::vector< std::string > histNames() const override
737 : 0 : { return data.histNames(); }
738 : 88 : std::vector< std::string > names() const override
739 : 88 : { return data.names(); }
740 : 0 : std::vector< std::vector< tk::real > > surfOutput(
741 : : const std::map< int, std::vector< std::size_t > >& bnd,
742 : : tk::Fields& U ) const override
743 : 0 : { return data.surfOutput( bnd, U ); }
744 : 0 : std::vector< std::vector< tk::real > > histOutput(
745 : : const std::vector< HistData >& h,
746 : : const std::vector< std::size_t >& inpoel,
747 : : const tk::UnsMesh::Coords& coord,
748 : : const tk::Fields& U,
749 : : const tk::Fields& P ) const override
750 : 0 : { return data.histOutput( h, inpoel, coord, U, P ); }
751 : : tk::InitializeFn::result_type
752 : 1188068 : analyticSolution( tk::real xi, tk::real yi, tk::real zi, tk::real t )
753 : 1188068 : const override { return data.analyticSolution( xi, yi, zi, t ); }
754 : : tk::InitializeFn::result_type
755 : 6231923 : solution( tk::real xi, tk::real yi, tk::real zi, tk::real t )
756 : 6231923 : const override { return data.solution( xi, yi, zi, t ); }
757 : 3380569 : tk::real sp_totalenergy( std::size_t e, const tk::Fields& unk )
758 : 3380569 : const override { return data.sp_totalenergy( e, unk ); }
759 : : T data;
760 : : };
761 : :
762 : : std::unique_ptr< Concept > self; //!< Base pointer used polymorphically
763 : : };
764 : :
765 : : } // inciter::
766 : :
767 : : #endif // DGPDE_h
|