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 : 462 : ConfigBC( BCStateFn& s,
57 : : const std::vector< tk::StateFn >& f,
58 : 462 : const std::vector< tk::StateFn >& gf ) :
59 : 462 : state(s), fn(f), gfn(gf), c(0) {}
60 : : //! Function to call for each BC type
61 : 3234 : template< typename U > void operator()( brigand::type_<U> ) {
62 : 6468 : std::vector< std::size_t > cfg, v;
63 : : // collect sidesets across all meshes
64 [ + + ]: 6468 : for (const auto& ibc : g_inputdeck.get< tag::bc >()) {
65 [ + - ]: 3234 : v.insert(v.end(), ibc.get< U >().begin(), ibc.get< U >().end());
66 : : }
67 [ + + ][ + - ]: 3234 : if (v.size() > 0) cfg = v;
68 [ - + ][ - - ]: 3234 : Assert( fn.size() > c, "StateFn missing for BC type" );
[ - - ][ - - ]
69 [ + - ][ + - ]: 3234 : state.push_back( { cfg, fn[c], gfn[c] } );
70 : 3234 : ++c;
71 : 3234 : }
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 : 367 : explicit DGPDE( std::function<T(Args...)> x, Args&&... args ) :
136 : : self( std::make_unique< Model<T> >(
137 [ + - ]: 367 : std::move( x( std::forward<Args>(args)... ) ) ) ) {}
138 : :
139 : : //! Public interface to find number of primitive quantities for the diff eq
140 : 671 : std::size_t nprim() const
141 : 671 : { 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 : 671 : void numEquationDofs(std::vector< std::size_t >& numEqDof) const
149 : 671 : { return self->numEquationDofs(numEqDof); }
150 : :
151 : : //! Public interface to find how 'stiff equations', which are the inverse
152 : : //! deformation equations because of plasticity
153 : 2684 : std::size_t nstiffeq() const
154 : 2684 : { return self->nstiffeq(); }
155 : :
156 : : //! Public interface to find how 'nonstiff equations', which are the inverse
157 : : //! deformation equations because of plasticity
158 : 1342 : std::size_t nnonstiffeq() const
159 : 1342 : { 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 : 671 : void IcBoxElems( const tk::Fields& geoElem,
171 : : std::size_t nielem,
172 : : std::vector< std::unordered_set< std::size_t > >& inbox ) const
173 : 671 : { self->IcBoxElems( geoElem, nielem, inbox ); }
174 : :
175 : : //! Public interface to setting the initial conditions for the diff eq
176 : 803 : void initialize(
177 : : const tk::Fields& geoElem,
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 : 803 : { self->initialize( geoElem, inpoel, coord, inbox, elemblkid, unk, t, nielem ); }
187 : :
188 : : //! Public interface for computing density constraint
189 : 1325 : void computeDensityConstr( std::size_t nelem,
190 : : tk::Fields& unk,
191 : : std::vector< tk::real >& densityConstr) const
192 : 1325 : { self->computeDensityConstr( nelem, unk, densityConstr); }
193 : :
194 : : //! Public interface to updating the interface cells for the diff eq
195 : 38265 : void updateInterfaceCells( tk::Fields& unk,
196 : : std::size_t nielem,
197 : : std::vector< std::size_t >& ndofel,
198 : : std::vector< std::size_t >& interface ) const
199 : 38265 : { self->updateInterfaceCells( unk, nielem, ndofel, interface ); }
200 : :
201 : : //! Public interface to updating the primitives for the diff eq
202 : 38936 : void updatePrimitives( const tk::Fields& unk,
203 : : const tk::Fields& geoElem,
204 : : tk::Fields& prim,
205 : : std::size_t nielem,
206 : : const std::vector< std::size_t >& ndofel ) const
207 : 38936 : { self->updatePrimitives( unk, geoElem, prim, nielem, ndofel ); }
208 : :
209 : : //! Public interface to cleaning up trace materials for the diff eq
210 : 38265 : void cleanTraceMaterial( tk::real t,
211 : : const tk::Fields& geoElem,
212 : : tk::Fields& unk,
213 : : tk::Fields& prim,
214 : : std::size_t nielem ) const
215 : 38265 : { self->cleanTraceMaterial( t, geoElem, unk, prim, nielem ); }
216 : :
217 : : //! Public interface to reconstructing the second-order solution
218 : 24840 : void reconstruct( tk::real t,
219 : : const tk::Fields& geoFace,
220 : : const tk::Fields& geoElem,
221 : : const inciter::FaceData& fd,
222 : : const std::map< std::size_t, std::vector< std::size_t > >&
223 : : esup,
224 : : const std::vector< std::size_t >& inpoel,
225 : : const tk::UnsMesh::Coords& coord,
226 : : tk::Fields& U,
227 : : tk::Fields& P,
228 : : const bool pref,
229 : : const std::vector< std::size_t >& ndofel ) const
230 : : {
231 : 24840 : self->reconstruct( t, geoFace, geoElem, fd, esup, inpoel, coord, U, P,
232 : 24840 : pref, ndofel );
233 : 24840 : }
234 : :
235 : : //! Public interface to limiting the second-order solution
236 : 24840 : void limit( tk::real t,
237 : : const bool pref,
238 : : const tk::Fields& geoFace,
239 : : const tk::Fields& geoElem,
240 : : const inciter::FaceData& fd,
241 : : const std::map< std::size_t, std::vector< std::size_t > >& esup,
242 : : const std::vector< std::size_t >& inpoel,
243 : : const tk::UnsMesh::Coords& coord,
244 : : const std::vector< std::size_t >& ndofel,
245 : : const std::vector< std::size_t >& gid,
246 : : const std::unordered_map< std::size_t, std::size_t >& bid,
247 : : const std::vector< std::vector<tk::real> >& uNodalExtrm,
248 : : const std::vector< std::vector<tk::real> >& pNodalExtrm,
249 : : const std::vector< std::vector<tk::real> >& mtInv,
250 : : tk::Fields& U,
251 : : tk::Fields& P,
252 : : std::vector< std::size_t >& shockmarker ) const
253 : : {
254 : 24840 : self->limit( t, pref, geoFace, geoElem, fd, esup, inpoel, coord, ndofel,
255 : 24840 : gid, bid, uNodalExtrm, pNodalExtrm, mtInv, U, P, shockmarker );
256 : 24840 : }
257 : :
258 : : //! Public interface to update the conservative variable solution
259 : 20790 : void CPL( const tk::Fields& prim,
260 : : const tk::Fields& geoElem,
261 : : const std::vector< std::size_t >& inpoel,
262 : : const tk::UnsMesh::Coords& coord,
263 : : tk::Fields& unk,
264 : : std::size_t nielem ) const
265 : : {
266 : 20790 : self->CPL( prim, geoElem, inpoel, coord, unk, nielem );
267 : 20790 : }
268 : :
269 : : //! Public interface to reset the high order solution for p-adaptive scheme
270 : 1770 : void resetAdapSol( const inciter::FaceData& fd,
271 : : tk::Fields& unk,
272 : : tk::Fields& prim,
273 : : const std::vector< std::size_t >& ndofel ) const
274 : : {
275 : 1770 : self->resetAdapSol( fd, unk, prim, ndofel );
276 : 1770 : }
277 : :
278 : : //! Public interface to getting the cell-averaged deformation gradients
279 : : std::array< std::vector< tk::real >, 9 > cellAvgDeformGrad(
280 : : const tk::Fields& U,
281 : : std::size_t nielem ) const
282 : : {
283 : : return self->cellAvgDeformGrad( U, nielem );
284 : : }
285 : :
286 : : //! Public interface to computing the P1 right-hand side vector
287 : 38265 : void rhs( tk::real t,
288 : : const bool pref,
289 : : const tk::Fields& geoFace,
290 : : const tk::Fields& geoElem,
291 : : const inciter::FaceData& fd,
292 : : const std::vector< std::size_t >& inpoel,
293 : : const std::vector< std::unordered_set< std::size_t > >& boxelems,
294 : : const tk::UnsMesh::Coords& coord,
295 : : const tk::Fields& U,
296 : : const tk::Fields& P,
297 : : const std::vector< std::size_t >& ndofel,
298 : : const tk::real dt,
299 : : tk::Fields& R ) const
300 : : {
301 : 38265 : self->rhs( t, pref, geoFace, geoElem, fd, inpoel, boxelems, coord, U, P,
302 : 38265 : ndofel, dt, R );
303 : 38265 : }
304 : :
305 : : //! Evaluate the adaptive indicator and mark the ndof for each element
306 : 1636 : void eval_ndof( std::size_t nunk,
307 : : const tk::UnsMesh::Coords& coord,
308 : : const std::vector< std::size_t >& inpoel,
309 : : const inciter::FaceData& fd,
310 : : const tk::Fields& unk,
311 : : const tk::Fields& prim,
312 : : inciter::ctr::PrefIndicatorType indicator,
313 : : std::size_t ndof,
314 : : std::size_t ndofmax,
315 : : tk::real tolref,
316 : : std::vector< std::size_t >& ndofel ) const
317 : : {
318 : 1636 : self->eval_ndof( nunk, coord, inpoel, fd, unk, prim, indicator, ndof,
319 : 1636 : ndofmax, tolref, ndofel );
320 : 1636 : }
321 : :
322 : : //! Public interface for computing the minimum time step size
323 : 2830 : tk::real dt( const std::array< std::vector< tk::real >, 3 >& coord,
324 : : const std::vector< std::size_t >& inpoel,
325 : : const inciter::FaceData& fd,
326 : : const tk::Fields& geoFace,
327 : : const tk::Fields& geoElem,
328 : : const std::vector< std::size_t >& ndofel,
329 : : const tk::Fields& U,
330 : : const tk::Fields& P,
331 : : const std::size_t nielem ) const
332 : 5660 : { return self->dt( coord, inpoel, fd, geoFace, geoElem, ndofel, U,
333 : 2830 : P, nielem ); }
334 : :
335 : : //! Public interface for elastic energy balance
336 : 0 : void balance_plastic_energy( std::size_t e,
337 : : std::vector< tk::real > x_star,
338 : : std::vector< tk::real > x,
339 : : tk::Fields& U ) const
340 [ - - ][ - - ]: 0 : { return self->balance_plastic_energy(e, x_star, x, U); }
341 : :
342 : : //! Public interface for computing stiff terms for an element
343 : 0 : void stiff_rhs( std::size_t e,
344 : : const tk::Fields& geoElem,
345 : : const std::vector< std::size_t >& inpoel,
346 : : const tk::UnsMesh::Coords& coord,
347 : : const tk::Fields& U,
348 : : const tk::Fields& P,
349 : : const std::vector< std::size_t >& ndofel,
350 : : tk::Fields& R ) const
351 : 0 : { return self->stiff_rhs( e, geoElem, inpoel, coord, U, P, ndofel, R); }
352 : :
353 : : //! Public interface to returning maps of output var functions
354 : 2650 : std::map< std::string, tk::GetVarFn > OutVarFn() const
355 : 2650 : { return self->OutVarFn(); }
356 : :
357 : : //! Public interface to returning analytic field output labels
358 : 684 : std::vector< std::string > analyticFieldNames() const
359 : 684 : { return self->analyticFieldNames(); }
360 : :
361 : : //! Public interface to returning time history field output labels
362 : 0 : std::vector< std::string > histNames() const { return self->histNames(); }
363 : :
364 : : //! Public interface to returning variable names
365 : 76 : std::vector< std::string > names() const { return self->names(); }
366 : :
367 : : //! Public interface to returning surface output labels
368 : 1325 : std::vector< std::string > surfNames() const { return self->surfNames(); }
369 : :
370 : : //! Public interface to returning surface field output
371 : : std::vector< std::vector< tk::real > >
372 : 1325 : surfOutput( const inciter::FaceData& fd,
373 : : const tk::Fields& U,
374 : : const tk::Fields& P ) const
375 : 1325 : { return self->surfOutput( fd, U, P ); }
376 : :
377 : : //! Public interface to return point history output
378 : : std::vector< std::vector< tk::real > >
379 : 0 : histOutput( const std::vector< HistData >& h,
380 : : const std::vector< std::size_t >& inpoel,
381 : : const tk::UnsMesh::Coords& coord,
382 : : const tk::Fields& U,
383 : : const tk::Fields& P ) const
384 : 0 : { return self->histOutput( h, inpoel, coord, U, P ); }
385 : :
386 : : //! Public interface to returning analytic solution
387 : : tk::InitializeFn::result_type
388 : 669522 : analyticSolution( tk::real xi, tk::real yi, tk::real zi, tk::real t ) const
389 : 669522 : { return self->analyticSolution( xi, yi, zi, t ); }
390 : :
391 : : //! Public interface to returning the analytic solution for conserved vars
392 : : tk::InitializeFn::result_type
393 : 4508294 : solution( tk::real xi, tk::real yi, tk::real zi, tk::real t ) const
394 : 4508294 : { return self->solution( xi, yi, zi, t ); }
395 : :
396 : : //! Public interface to returning the specific total energy
397 : : tk::real
398 : 2553118 : sp_totalenergy( std::size_t e, const tk::Fields& unk ) const
399 : 2553118 : { return self->sp_totalenergy( e, unk ); }
400 : :
401 : : //! Copy assignment
402 : : DGPDE& operator=( const DGPDE& x )
403 : : { DGPDE tmp(x); *this = std::move(tmp); return *this; }
404 : : //! Copy constructor
405 : : DGPDE( const DGPDE& x ) : self( x.self->copy() ) {}
406 : : //! Move assignment
407 : : DGPDE& operator=( DGPDE&& ) noexcept = default;
408 : : //! Move constructor
409 : 367 : DGPDE( DGPDE&& ) noexcept = default;
410 : :
411 : : private:
412 : : //! \brief Concept is a pure virtual base class specifying the requirements
413 : : //! of polymorphic objects deriving from it
414 : : struct Concept {
415 : 367 : Concept() = default;
416 : 0 : Concept( const Concept& ) = default;
417 : 367 : virtual ~Concept() = default;
418 : : virtual Concept* copy() const = 0;
419 : : virtual std::size_t nprim() const = 0;
420 : : virtual std::size_t nmat() const = 0;
421 : : virtual void numEquationDofs(std::vector< std::size_t >&) const = 0;
422 : : virtual std::size_t nstiffeq() const = 0;
423 : : virtual std::size_t nnonstiffeq() const = 0;
424 : : virtual void setStiffEqIdx( std::vector< std::size_t >& ) const = 0;
425 : : virtual void setNonStiffEqIdx( std::vector< std::size_t >& ) const = 0;
426 : : virtual void IcBoxElems( const tk::Fields&,
427 : : std::size_t,
428 : : std::vector< std::unordered_set< std::size_t > >& ) const = 0;
429 : : virtual void initialize(
430 : : const tk::Fields&,
431 : : const std::vector< std::size_t >&,
432 : : const tk::UnsMesh::Coords&,
433 : : const std::vector< std::unordered_set< std::size_t > >&,
434 : : const std::unordered_map< std::size_t, std::set< std::size_t > >&,
435 : : tk::Fields&,
436 : : tk::real,
437 : : const std::size_t nielem ) const = 0;
438 : : virtual void computeDensityConstr( std::size_t nelem,
439 : : tk::Fields& unk,
440 : : std::vector< tk::real >& densityConstr)
441 : : const = 0;
442 : : virtual void updateInterfaceCells( tk::Fields&,
443 : : std::size_t,
444 : : std::vector< std::size_t >&,
445 : : std::vector< std::size_t >& ) const = 0;
446 : : virtual void updatePrimitives( const tk::Fields&,
447 : : const tk::Fields&,
448 : : tk::Fields&,
449 : : std::size_t,
450 : : const std::vector< std::size_t >& ) const = 0;
451 : : virtual void cleanTraceMaterial( tk::real,
452 : : const tk::Fields&,
453 : : tk::Fields&,
454 : : tk::Fields&,
455 : : std::size_t ) const = 0;
456 : : virtual void reconstruct( tk::real,
457 : : const tk::Fields&,
458 : : const tk::Fields&,
459 : : const inciter::FaceData&,
460 : : const std::map< std::size_t,
461 : : std::vector< std::size_t > >&,
462 : : const std::vector< std::size_t >&,
463 : : const tk::UnsMesh::Coords&,
464 : : tk::Fields&,
465 : : tk::Fields&,
466 : : const bool,
467 : : const std::vector< std::size_t >& ) const = 0;
468 : : virtual void limit( tk::real,
469 : : const bool,
470 : : const tk::Fields&,
471 : : const tk::Fields&,
472 : : const inciter::FaceData&,
473 : : const std::map< std::size_t,
474 : : std::vector< std::size_t > >&,
475 : : const std::vector< std::size_t >&,
476 : : const tk::UnsMesh::Coords&,
477 : : const std::vector< std::size_t >&,
478 : : const std::vector< std::size_t >&,
479 : : const std::unordered_map< std::size_t, std::size_t >&,
480 : : const std::vector< std::vector<tk::real> >&,
481 : : const std::vector< std::vector<tk::real> >&,
482 : : const std::vector< std::vector<tk::real> >&,
483 : : tk::Fields&,
484 : : tk::Fields&,
485 : : std::vector< std::size_t >& ) const = 0;
486 : : virtual void CPL( const tk::Fields&,
487 : : const tk::Fields&,
488 : : const std::vector< std::size_t >&,
489 : : const tk::UnsMesh::Coords&,
490 : : tk::Fields&,
491 : : std::size_t ) const = 0;
492 : : virtual std::array< std::vector< tk::real >, 9 > cellAvgDeformGrad(
493 : : const tk::Fields&,
494 : : std::size_t ) const = 0;
495 : : virtual void rhs( tk::real,
496 : : const bool,
497 : : const tk::Fields&,
498 : : const tk::Fields&,
499 : : const inciter::FaceData&,
500 : : const std::vector< std::size_t >&,
501 : : const std::vector< std::unordered_set< std::size_t > >&,
502 : : const tk::UnsMesh::Coords&,
503 : : const tk::Fields&,
504 : : const tk::Fields&,
505 : : const std::vector< std::size_t >&,
506 : : const tk::real,
507 : : tk::Fields& ) const = 0;
508 : : virtual void resetAdapSol( const inciter::FaceData&,
509 : : tk::Fields&,
510 : : tk::Fields&,
511 : : const std::vector< std::size_t >& )
512 : : const = 0;
513 : : virtual void eval_ndof( std::size_t,
514 : : const tk::UnsMesh::Coords&,
515 : : const std::vector< std::size_t >&,
516 : : const inciter::FaceData&,
517 : : const tk::Fields&,
518 : : const tk::Fields&,
519 : : inciter::ctr::PrefIndicatorType,
520 : : std::size_t,
521 : : std::size_t,
522 : : tk::real,
523 : : std::vector< std::size_t >& ) const = 0;
524 : : virtual tk::real dt( const std::array< std::vector< tk::real >, 3 >&,
525 : : const std::vector< std::size_t >&,
526 : : const inciter::FaceData&,
527 : : const tk::Fields&,
528 : : const tk::Fields&,
529 : : const std::vector< std::size_t >&,
530 : : const tk::Fields&,
531 : : const tk::Fields&,
532 : : const std::size_t ) const = 0;
533 : : virtual void balance_plastic_energy( std::size_t,
534 : : std::vector< tk::real >,
535 : : std::vector< tk::real >,
536 : : tk::Fields& ) const = 0;
537 : : virtual void stiff_rhs( std::size_t,
538 : : const tk::Fields&,
539 : : const std::vector< std::size_t >&,
540 : : const tk::UnsMesh::Coords&,
541 : : const tk::Fields&,
542 : : const tk::Fields&,
543 : : const std::vector< std::size_t >&,
544 : : tk::Fields& ) const = 0;
545 : : virtual std::map< std::string, tk::GetVarFn > OutVarFn() const = 0;
546 : : virtual std::vector< std::string > analyticFieldNames() const = 0;
547 : : virtual std::vector< std::string > histNames() const = 0;
548 : : virtual std::vector< std::string > names() const = 0;
549 : : virtual std::vector< std::string > surfNames() const = 0;
550 : : virtual std::vector< std::vector< tk::real > > surfOutput(
551 : : const inciter::FaceData&,
552 : : const tk::Fields&,
553 : : const tk::Fields& ) const = 0;
554 : : virtual std::vector< std::vector< tk::real > > histOutput(
555 : : const std::vector< HistData >&,
556 : : const std::vector< std::size_t >&,
557 : : const tk::UnsMesh::Coords&,
558 : : const tk::Fields&,
559 : : const tk::Fields& ) const = 0;
560 : : virtual tk::InitializeFn::result_type analyticSolution(
561 : : tk::real xi, tk::real yi, tk::real zi, tk::real t ) const = 0;
562 : : virtual tk::InitializeFn::result_type solution(
563 : : tk::real xi, tk::real yi, tk::real zi, tk::real t ) const = 0;
564 : : virtual tk::real sp_totalenergy(
565 : : std::size_t, const tk::Fields& ) const = 0;
566 : : };
567 : :
568 : : //! \brief Model models the Concept above by deriving from it and overriding
569 : : //! the virtual functions required by Concept
570 : : template< typename T >
571 : : struct Model : Concept {
572 : 367 : explicit Model( T x ) : data( std::move(x) ) {}
573 [ - - ]: 0 : Concept* copy() const override { return new Model( *this ); }
574 : 671 : std::size_t nprim() const override
575 : 671 : { return data.nprim(); }
576 : 0 : std::size_t nmat() const override
577 : 0 : { return data.nmat(); }
578 : 671 : void numEquationDofs(std::vector< std::size_t >& numEqDof) const override
579 : 671 : { data.numEquationDofs(numEqDof); }
580 : 2684 : std::size_t nstiffeq() const override
581 : 2684 : { return data.nstiffeq(); }
582 : 1342 : std::size_t nnonstiffeq() const override
583 : 1342 : { return data.nnonstiffeq(); }
584 : 0 : void setStiffEqIdx( std::vector< std::size_t >& stiffEqIdx ) const override
585 : 0 : { data.setStiffEqIdx(stiffEqIdx); }
586 : 0 : void setNonStiffEqIdx( std::vector< std::size_t >& nonStiffEqIdx ) const override
587 : 0 : { data.setNonStiffEqIdx(nonStiffEqIdx); }
588 : 671 : void IcBoxElems( const tk::Fields& geoElem,
589 : : std::size_t nielem,
590 : : std::vector< std::unordered_set< std::size_t > >& inbox )
591 : 671 : const override { data.IcBoxElems( geoElem, nielem, inbox ); }
592 : 803 : void initialize(
593 : : const tk::Fields& geoElem,
594 : : const std::vector< std::size_t >& inpoel,
595 : : const tk::UnsMesh::Coords& coord,
596 : : const std::vector< std::unordered_set< std::size_t > >& inbox,
597 : : const std::unordered_map< std::size_t, std::set< std::size_t > >&
598 : : elemblkid,
599 : : tk::Fields& unk,
600 : : tk::real t,
601 : : const std::size_t nielem )
602 : 803 : const override { data.initialize( geoElem, inpoel, coord, inbox,
603 : 803 : elemblkid, unk, t, nielem ); }
604 : 1325 : void computeDensityConstr( std::size_t nelem,
605 : : tk::Fields& unk,
606 : : std::vector< tk::real >& densityConstr)
607 : : const override
608 : 1325 : { data.computeDensityConstr( nelem, unk, densityConstr ); }
609 : 38265 : void updateInterfaceCells( tk::Fields& unk,
610 : : std::size_t nielem,
611 : : std::vector< std::size_t >& ndofel,
612 : : std::vector< std::size_t >& interface )
613 : 38265 : const override { data.updateInterfaceCells( unk, nielem, ndofel, interface ); }
614 : 38936 : void updatePrimitives( const tk::Fields& unk,
615 : : const tk::Fields& geoElem,
616 : : tk::Fields& prim,
617 : : std::size_t nielem,
618 : : const std::vector< std::size_t >& ndofel )
619 : : const override {
620 : 38936 : data.updatePrimitives( unk, geoElem, prim, nielem, ndofel );
621 : 38936 : }
622 : 38265 : void cleanTraceMaterial( tk::real t,
623 : : const tk::Fields& geoElem,
624 : : tk::Fields& unk,
625 : : tk::Fields& prim,
626 : : std::size_t nielem )
627 : 38265 : const override { data.cleanTraceMaterial( t, geoElem, unk, prim, nielem ); }
628 : 24840 : void reconstruct( tk::real t,
629 : : const tk::Fields& geoFace,
630 : : const tk::Fields& geoElem,
631 : : const inciter::FaceData& fd,
632 : : const std::map< std::size_t,
633 : : std::vector< std::size_t > >& esup,
634 : : const std::vector< std::size_t >& inpoel,
635 : : const tk::UnsMesh::Coords& coord,
636 : : tk::Fields& U,
637 : : tk::Fields& P,
638 : : const bool pref,
639 : : const std::vector< std::size_t >& ndofel )const override
640 : : {
641 : 24840 : data.reconstruct( t, geoFace, geoElem, fd, esup, inpoel, coord, U, P,
642 : : pref, ndofel );
643 : 24840 : }
644 : 24840 : void limit( tk::real t,
645 : : const bool pref,
646 : : const tk::Fields& geoFace,
647 : : const tk::Fields& geoElem,
648 : : const inciter::FaceData& fd,
649 : : const std::map< std::size_t, std::vector< std::size_t > >&
650 : : esup,
651 : : const std::vector< std::size_t >& inpoel,
652 : : const tk::UnsMesh::Coords& coord,
653 : : const std::vector< std::size_t >& ndofel,
654 : : const std::vector< std::size_t >& gid,
655 : : const std::unordered_map< std::size_t, std::size_t >& bid,
656 : : const std::vector< std::vector<tk::real> >& uNodalExtrm,
657 : : const std::vector< std::vector<tk::real> >& pNodalExtrm,
658 : : const std::vector< std::vector<tk::real> >& mtInv,
659 : : tk::Fields& U,
660 : : tk::Fields& P,
661 : : std::vector< std::size_t >& shockmarker ) const override
662 : : {
663 : 24840 : data.limit( t, pref, geoFace, geoElem, fd, esup, inpoel, coord, ndofel, gid,
664 : : bid, uNodalExtrm, pNodalExtrm, mtInv, U, P, shockmarker );
665 : 24840 : }
666 : 20790 : void CPL( const tk::Fields& prim,
667 : : const tk::Fields& geoElem,
668 : : const std::vector< std::size_t >& inpoel,
669 : : const tk::UnsMesh::Coords& coord,
670 : : tk::Fields& unk,
671 : : std::size_t nielem ) const override
672 : : {
673 : 20790 : data.CPL( prim, geoElem, inpoel, coord, unk, nielem );
674 : 20790 : }
675 : 1770 : void resetAdapSol( const inciter::FaceData& fd,
676 : : tk::Fields& unk,
677 : : tk::Fields& prim,
678 : : const std::vector< std::size_t >& ndofel ) const override
679 : : {
680 : 1770 : data.resetAdapSol( fd, unk, prim, ndofel );
681 : 1770 : }
682 : 0 : std::array< std::vector< tk::real >, 9 > cellAvgDeformGrad(
683 : : const tk::Fields& U,
684 : : std::size_t nielem ) const override
685 : : {
686 : 0 : return data.cellAvgDeformGrad( U, nielem );
687 : : }
688 : 38265 : void rhs(
689 : : tk::real t,
690 : : const bool pref,
691 : : const tk::Fields& geoFace,
692 : : const tk::Fields& geoElem,
693 : : const inciter::FaceData& fd,
694 : : const std::vector< std::size_t >& inpoel,
695 : : const std::vector< std::unordered_set< std::size_t > >& boxelems,
696 : : const tk::UnsMesh::Coords& coord,
697 : : const tk::Fields& U,
698 : : const tk::Fields& P,
699 : : const std::vector< std::size_t >& ndofel,
700 : : const tk::real dt,
701 : : tk::Fields& R ) const override
702 : : {
703 : 38265 : data.rhs( t, pref, geoFace, geoElem, fd, inpoel, boxelems, coord, U, P,
704 : : ndofel, dt, R );
705 : 38265 : }
706 : 1636 : void eval_ndof( std::size_t nunk,
707 : : const tk::UnsMesh::Coords& coord,
708 : : const std::vector< std::size_t >& inpoel,
709 : : const inciter::FaceData& fd,
710 : : const tk::Fields& unk,
711 : : const tk::Fields& prim,
712 : : inciter::ctr::PrefIndicatorType indicator,
713 : : std::size_t ndof,
714 : : std::size_t ndofmax,
715 : : tk::real tolref,
716 : : std::vector< std::size_t >& ndofel ) const override
717 : 1636 : { data.eval_ndof( nunk, coord, inpoel, fd, unk, prim, indicator, ndof,
718 : 1636 : ndofmax, tolref, ndofel ); }
719 : 2830 : tk::real dt( const std::array< std::vector< tk::real >, 3 >& coord,
720 : : const std::vector< std::size_t >& inpoel,
721 : : const inciter::FaceData& fd,
722 : : const tk::Fields& geoFace,
723 : : const tk::Fields& geoElem,
724 : : const std::vector< std::size_t >& ndofel,
725 : : const tk::Fields& U,
726 : : const tk::Fields& P,
727 : : const std::size_t nielem ) const override
728 : : { return data.dt( coord, inpoel, fd, geoFace, geoElem, ndofel,
729 : 2830 : U, P, nielem ); }
730 : 0 : void balance_plastic_energy( std::size_t e,
731 : : std::vector< tk::real > x_star,
732 : : std::vector< tk::real > x,
733 : : tk::Fields& U ) const override
734 [ - - ][ - - ]: 0 : { return data.balance_plastic_energy( e, x_star, x, U); }
735 : 0 : void stiff_rhs( std::size_t e,
736 : : const tk::Fields& geoElem,
737 : : const std::vector< std::size_t >& inpoel,
738 : : const tk::UnsMesh::Coords& coord,
739 : : const tk::Fields& U,
740 : : const tk::Fields& P,
741 : : const std::vector< std::size_t >& ndofel,
742 : : tk::Fields& R ) const override
743 : 0 : { return data.stiff_rhs( e, geoElem, inpoel, coord, U, P, ndofel, R ); }
744 : 2650 : std::map< std::string, tk::GetVarFn > OutVarFn() const override
745 : 2650 : { return data.OutVarFn(); }
746 : 684 : std::vector< std::string > analyticFieldNames() const override
747 : 684 : { return data.analyticFieldNames(); }
748 : 0 : std::vector< std::string > histNames() const override
749 : 0 : { return data.histNames(); }
750 : 76 : std::vector< std::string > names() const override
751 : 76 : { return data.names(); }
752 : 1325 : std::vector< std::string > surfNames() const override
753 : 1325 : { return data.surfNames(); }
754 : 1325 : std::vector< std::vector< tk::real > > surfOutput(
755 : : const inciter::FaceData& fd,
756 : : const tk::Fields& U,
757 : : const tk::Fields& P ) const override
758 : 1325 : { return data.surfOutput( fd, U, P ); }
759 : 0 : std::vector< std::vector< tk::real > > histOutput(
760 : : const std::vector< HistData >& h,
761 : : const std::vector< std::size_t >& inpoel,
762 : : const tk::UnsMesh::Coords& coord,
763 : : const tk::Fields& U,
764 : : const tk::Fields& P ) const override
765 : 0 : { return data.histOutput( h, inpoel, coord, U, P ); }
766 : : tk::InitializeFn::result_type
767 : 669522 : analyticSolution( tk::real xi, tk::real yi, tk::real zi, tk::real t )
768 : 669522 : const override { return data.analyticSolution( xi, yi, zi, t ); }
769 : : tk::InitializeFn::result_type
770 : 4508294 : solution( tk::real xi, tk::real yi, tk::real zi, tk::real t )
771 : 4508294 : const override { return data.solution( xi, yi, zi, t ); }
772 : 2553118 : tk::real sp_totalenergy( std::size_t e, const tk::Fields& unk )
773 : 2553118 : const override { return data.sp_totalenergy( e, unk ); }
774 : : T data;
775 : : };
776 : :
777 : : std::unique_ptr< Concept > self; //!< Base pointer used polymorphically
778 : : };
779 : :
780 : : } // inciter::
781 : :
782 : : #endif // DGPDE_h
|