MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
hyperbolic.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12
13#ifndef MFEM_HYPERBOLIC
14#define MFEM_HYPERBOLIC
15
16#include "nonlinearform.hpp"
17
18namespace mfem
19{
20
21// This file contains general hyperbolic conservation element/face form
22// integrators. HyperbolicFormIntegrator and NumericalFlux are defined.
23//
24// HyperbolicFormIntegrator is a NonlinearFormIntegrator that implements
25// element weak divergence and interface flux
26//
27// ∫_K F(u):∇v, -∫_f F̂(u)⋅n[v]
28//
29// Here, K is an element, f is a face, n normal and [⋅] is jump. This form
30// integrator is coupled with NumericalFlux that implements the numerical flux
31// F̂. For NumericalFlux, the Rusanov flux, also known as local Lax-Friedrichs
32// flux, or component-wise upwinded flux are provided.
33//
34// To implement a specific hyperbolic conservation laws, users can create
35// derived classes from FluxFunction with overloaded ComputeFlux. One can
36// optionally overload ComputeFluxDotN to avoid creating dense matrix when
37// computing normal flux. Several example equations are also defined including:
38// advection, Burgers', shallow water, and Euler equations. Users can control
39// the quadrature rule by either providing the integration rule, or integration
40// order offset. Integration will use 2*p + IntOrderOffset order quadrature
41// rule.
42//
43// At each call of HyperbolicFormIntegrator::AssembleElementVector
44// HyperbolicFormIntegrator::AssembleFaceVector, the maximum characteristic
45// speed will be updated. This will not be reinitialized automatically. To
46// reinitialize, use HyperbolicFormIntegrator::ResetMaxCharSpeed. See, ex18.hpp.
47//
48// Note: To avoid communication overhead, we update the maximum characteristic
49// speed within each MPI process only. Use the appropriate MPI routine to gather
50// the information.
51
52/**
53 * @brief Abstract class for hyperbolic flux for a system of hyperbolic
54 * conservation laws
55 *
56 */
58{
59public:
60 const int num_equations;
61 const int dim;
62
63 FluxFunction(const int num_equations, const int dim)
65
66 virtual ~FluxFunction() {}
67
68 /**
69 * @brief Compute flux F(u, x). Must be implemented in a derived class.
70 *
71 * Used in HyperbolicFormIntegrator::AssembleElementVector() for evaluation
72 * of (F(u), ∇v) and in the default implementation of ComputeFluxDotN()
73 * for evaluation of F(u)⋅n.
74 * @param[in] state state at the current integration point (num_equations)
75 * @param[in] Tr element transformation
76 * @param[out] flux flux from the given element at the current
77 * integration point (num_equations, dim)
78 * @return real_t maximum characteristic speed |dF(u,x)/du|
79 *
80 * @note One can put assertion in here to detect non-physical solution
81 */
83 DenseMatrix &flux) const = 0;
84 /**
85 * @brief Compute normal flux F(u, x)⋅n. Optionally overloaded in a derived
86 * class to avoid creating a full dense matrix for flux.
87 *
88 * Used in NumericalFlux for evaluation of the normal flux on a face.
89 * @param[in] state state at the current integration point (num_equations)
90 * @param[in] normal normal vector, see mfem::CalcOrtho() (dim)
91 * @param[in] Tr face transformation
92 * @param[out] fluxDotN normal flux from the given element at the current
93 * integration point (num_equations)
94 * @return real_t maximum (normal) characteristic speed |dF(u,x)/du⋅n|
95 */
96 virtual real_t ComputeFluxDotN(const Vector &state, const Vector &normal,
98 Vector &fluxDotN) const;
99
100 /**
101 * @brief Compute average flux over the given interval of states.
102 * Optionally overloaded in a derived class.
103 *
104 * The average flux is defined as F̄(u1,u2) = ∫ F(u) du / (u2 - u1) for
105 * u ∈ [u1,u2], where u1 is the first state (@a state1) and the u2 the
106 * second state (@a state2), while F(u) is the flux as defined in
107 * ComputeFlux().
108 *
109 * Used in the default implementation of ComputeAvgFluxDotN().
110 * @param[in] state1 state of the beginning of the interval (num_equations)
111 * @param[in] state2 state of the end of the interval (num_equations)
112 * @param[in] Tr element transformation
113 * @param[out] flux_ average flux from the given element at the current
114 * integration point (num_equations, dim)
115 * @return real_t maximum characteristic speed |dF(u,x)/du| over
116 * the interval [u1,u2]
117 */
118 virtual real_t ComputeAvgFlux(const Vector &state1, const Vector &state2,
120 DenseMatrix &flux_) const
121 { MFEM_ABORT("Not Implemented."); }
122
123 /**
124 * @brief Compute average normal flux over the given interval of states.
125 * Optionally overloaded in a derived class.
126 *
127 * The average normal flux is defined as F̄(u1,u2)n = ∫ F(u)n du / (u2 - u1)
128 * for u ∈ [u1,u2], where u1 is the first state (@a state1) and the u2 the
129 * second state (@a state2), while n is the normal and F(u) is the flux as
130 * defined in ComputeFlux().
131 *
132 * Used in NumericalFlux::Average() and NumericalFlux::AverageGrad() for
133 * evaluation of the average normal flux on a face.
134 * @param[in] state1 state of the beginning of the interval (num_equations)
135 * @param[in] state2 state of the end of the interval (num_equations)
136 * @param[in] normal normal vector, see mfem::CalcOrtho() (dim)
137 * @param[in] Tr face transformation
138 * @param[out] fluxDotN average normal flux from the given element at the
139 * current integration point (num_equations)
140 * @return real_t maximum (normal) characteristic speed |dF(u,x)/du⋅n|
141 * over the interval [u1,u2]
142 */
143 virtual real_t ComputeAvgFluxDotN(const Vector &state1, const Vector &state2,
144 const Vector &normal,
146 Vector &fluxDotN) const;
147
148 /**
149 * @brief Compute flux Jacobian J(u, x). Optionally overloaded in a derived
150 * class when Jacobian is necessary (e.g. Newton iteration, flux limiter)
151 *
152 * Used in HyperbolicFormIntegrator::AssembleElementGrad() for evaluation of
153 * Jacobian of the flux in an element and in the default implementation of
154 * ComputeFluxJacobianDotN().
155 * @param[in] state state at the current integration point (num_equations)
156 * @param[in] Tr element transformation
157 * @param[out] J_ flux Jacobian, $ J(i,j,d) = dF_{id} / du_j $
158 */
159 virtual void ComputeFluxJacobian(const Vector &state,
161 DenseTensor &J_) const
162 { MFEM_ABORT("Not Implemented."); }
163
164 /**
165 * @brief Compute normal flux Jacobian J(u, x)⋅n. Optionally overloaded in
166 * a derived class to avoid creating a full dense tensor for Jacobian.
167 *
168 * Used in NumericalFlux for evaluation of Jacobian of the normal flux on
169 * a face.
170 * @param[in] state state at the current integration point (num_equations)
171 * @param[in] normal normal vector, see mfem::CalcOrtho() (dim)
172 * @param[in] Tr element transformation
173 * @param[out] JDotN normal flux Jacobian, $ JDotN(i,j) = d(F_{id} n_d) / du_j $
174 */
175 virtual void ComputeFluxJacobianDotN(const Vector &state,
176 const Vector &normal,
178 DenseMatrix &JDotN) const;
179
180private:
181#ifndef MFEM_THREAD_SAFE
182 mutable DenseMatrix flux;
183 mutable DenseTensor J;
184#endif
185};
186
187
188/**
189 * @brief Abstract class for numerical flux for a system of hyperbolic
190 * conservation laws on a face with states, fluxes and characteristic speed
191 *
192 */
194{
195public:
196 /**
197 * @brief Constructor for a flux function
198 * @param fluxFunction flux function F(u,x)
199 */
202
203 /**
204 * @brief Evaluates normal numerical flux for the given states and normal.
205 * Must be implemented in a derived class.
206 *
207 * Used in HyperbolicFormIntegrator::AssembleFaceVector() for evaluation of
208 * <F̂(u⁻,u⁺,x) n, [v]> term at the face.
209 * @param[in] state1 state value at a point from the first element
210 * (num_equations)
211 * @param[in] state2 state value at a point from the second element
212 * (num_equations)
213 * @param[in] nor scaled normal vector, see mfem::CalcOrtho() (dim)
214 * @param[in] Tr face transformation
215 * @param[out] flux numerical flux (num_equations)
216 * @return real_t maximum characteristic speed |dF(u,x)/du⋅n|
217 */
218 virtual real_t Eval(const Vector &state1, const Vector &state2,
219 const Vector &nor, FaceElementTransformations &Tr,
220 Vector &flux) const = 0;
221
222 /**
223 * @brief Evaluates Jacobian of the normal numerical flux for the given
224 * states and normal. Optionally overloaded in a derived class.
225 *
226 * Used in HyperbolicFormIntegrator::AssembleFaceGrad() for Jacobian
227 * of the term <F̂(u⁻,u⁺,x) n, [v]> at the face.
228 * @param[in] side indicates gradient w.r.t. the first (side = 1)
229 * or second (side = 2) state
230 * @param[in] state1 state value of the beginning of the interval
231 * (num_equations)
232 * @param[in] state2 state value of the end of the interval
233 * (num_equations)
234 * @param[in] nor scaled normal vector, see mfem::CalcOrtho() (dim)
235 * @param[in] Tr face transformation
236 * @param[out] grad Jacobian of normal numerical flux (num_equations, dim)
237 */
238 virtual void Grad(int side, const Vector &state1, const Vector &state2,
239 const Vector &nor, FaceElementTransformations &Tr,
240 DenseMatrix &grad) const
241 { MFEM_ABORT("Not implemented."); }
242
243 /**
244 * @brief Evaluates average normal numerical flux over the interval between
245 * the given end states in the second argument and for the given normal.
246 * Optionally overloaded in a derived class.
247 *
248 * Presently, not used. Reserved for future use.
249 * @param[in] state1 state value of the beginning of the interval
250 * (num_equations)
251 * @param[in] state2 state value of the end of the interval
252 * (num_equations)
253 * @param[in] nor scaled normal vector, see mfem::CalcOrtho() (dim)
254 * @param[in] Tr face transformation
255 * @param[out] flux numerical flux (num_equations)
256 * @return real_t maximum characteristic speed |dF(u,x)/du⋅n|
257 */
258 virtual real_t Average(const Vector &state1, const Vector &state2,
259 const Vector &nor, FaceElementTransformations &Tr,
260 Vector &flux) const
261 { MFEM_ABORT("Not implemented."); }
262
263 /**
264 * @brief Evaluates Jacobian of the average normal numerical flux over the
265 * interval between the given end states in the second argument and for the
266 * given normal. Optionally overloaded in a derived class.
267 *
268 * Presently, not used. Reserved for future use.
269 * @param[in] side indicates gradient w.r.t. the first (side = 1)
270 * or second (side = 2) state
271 * @param[in] state1 state value of the beginning of the interval
272 * (num_equations)
273 * @param[in] state2 state value of the end of the interval
274 * (num_equations)
275 * @param[in] nor scaled normal vector, see mfem::CalcOrtho() (dim)
276 * @param[in] Tr face transformation
277 * @param[out] grad Jacobian of the average normal numerical flux
278 * (num_equations, dim)
279 */
280 virtual void AverageGrad(int side, const Vector &state1, const Vector &state2,
281 const Vector &nor, FaceElementTransformations &Tr,
282 DenseMatrix &grad) const
283 { MFEM_ABORT("Not implemented."); }
284
285 virtual ~NumericalFlux() = default;
286
287 /// @brief Get flux function F
288 /// @return constant reference to the flux function.
289 const FluxFunction &GetFluxFunction() const { return fluxFunction; }
290
291protected:
293};
294
295/// @deprecated Use NumericalFlux instead.
296MFEM_DEPRECATED typedef NumericalFlux RiemannSolver;
297
298/**
299 * @brief Abstract hyperbolic form integrator, assembling (F(u, x), ∇v) and
300 * <F̂(u⁻,u⁺,x) n, [v]> terms for scalar finite elements.
301 *
302 * This form integrator is coupled with a NumericalFlux that implements the
303 * numerical flux F̂ at the faces. The flux F is obtained from the FluxFunction
304 * assigned to the aforementioned NumericalFlux.
305 */
307{
308private:
309 const NumericalFlux &numFlux; // Numerical flux that maps F(u±,x) to F̂
310 const FluxFunction &fluxFunction;
311 const int IntOrderOffset; // integration order offset, 2*p + IntOrderOffset.
312 const real_t sign;
313
314 // The maximum characteristic speed, updated during element/face vector assembly
315 real_t max_char_speed;
316
317#ifndef MFEM_THREAD_SAFE
318 // Local storage for element integration
319 Vector shape; // shape function value at an integration point
320 Vector state; // state value at an integration point
321 DenseMatrix flux; // flux value at an integration point
322 DenseTensor J; // Jacobian matrix at an integration point
323 DenseMatrix dshape; // derivative of shape function at an integration point
324
325 Vector shape1; // shape function value at an integration point - first elem
326 Vector shape2; // shape function value at an integration point - second elem
327 Vector state1; // state value at an integration point - first elem
328 Vector state2; // state value at an integration point - second elem
329 Vector nor; // normal vector, see mfem::CalcOrtho()
330 Vector fluxN; // F̂(u±,x) n
331 DenseMatrix JDotN; // Ĵ(u±,x) n
332#endif
333
334public:
335 const int num_equations; // the number of equations
336
337 /**
338 * @brief Construct a new HyperbolicFormIntegrator object
339 *
340 * @param[in] numFlux numerical flux
341 * @param[in] IntOrderOffset integration order offset
342 * @param[in] sign sign of the convection term
343 */
345 const NumericalFlux &numFlux,
346 const int IntOrderOffset = 0,
347 const real_t sign = 1.);
348
349 /// Reset the maximum characteristic speed to zero
350 void ResetMaxCharSpeed() { max_char_speed = 0.0; }
351
352 /// Get the maximum characteristic speed
353 real_t GetMaxCharSpeed() const { return max_char_speed; }
354
355 /// Get the associated flux function
356 const FluxFunction &GetFluxFunction() const { return fluxFunction; }
357
358 /**
359 * @brief Implements (F(u), ∇v) with abstract F computed by
360 * FluxFunction::ComputeFlux()
361 *
362 * @param[in] el local finite element
363 * @param[in] Tr element transformation
364 * @param[in] elfun local coefficient of basis
365 * @param[out] elvect evaluated dual vector
366 */
369 const Vector &elfun, Vector &elvect) override;
370
371 /**
372 * @brief Implements (J(u), ∇v) with abstract J computed by
373 * FluxFunction::ComputeFluxJacobian()
374 *
375 * @param[in] el local finite element
376 * @param[in] Tr element transformation
377 * @param[in] elfun local coefficient of basis
378 * @param[out] grad evaluated Jacobian
379 */
380 void AssembleElementGrad(const FiniteElement &el,
382 const Vector &elfun, DenseMatrix &grad) override;
383
384 /**
385 * @brief Implements <-F̂(u⁻,u⁺,x) n, [v]> with abstract F̂ computed by
386 * NumericalFlux::Eval() of the numerical flux object
387 *
388 * @param[in] el1 finite element of the first element
389 * @param[in] el2 finite element of the second element
390 * @param[in] Tr face element transformations
391 * @param[in] elfun local coefficient of basis from both elements
392 * @param[out] elvect evaluated dual vector <-F̂(u⁻,u⁺,x) n, [v]>
393 */
394 void AssembleFaceVector(const FiniteElement &el1,
395 const FiniteElement &el2,
397 const Vector &elfun, Vector &elvect) override;
398
399 /**
400 * @brief Implements <-Ĵ(u⁻,u⁺,x) n, [v]> with abstract Ĵ computed by
401 * NumericalFlux::Grad() of the numerical flux object
402 *
403 * @param[in] el1 finite element of the first element
404 * @param[in] el2 finite element of the second element
405 * @param[in] Tr face element transformations
406 * @param[in] elfun local coefficient of basis from both elements
407 * @param[out] elmat evaluated Jacobian matrix <-Ĵ(u⁻,u⁺,x) n, [v]>
408 */
409 void AssembleFaceGrad(const FiniteElement &el1,
410 const FiniteElement &el2,
412 const Vector &elfun, DenseMatrix &elmat) override;
413};
414
415/**
416 * @brief Abstract boundary hyperbolic form integrator, assembling
417 * <F̂(u⁻,u_b,x) n, [v]> term for scalar finite elements at the boundary.
418 *
419 * This form integrator is coupled with a NumericalFlux that implements the
420 * numerical flux F̂ at the boundary faces. The flux F is obtained from the
421 * FluxFunction assigned to the aforementioned NumericalFlux with the given
422 * boundary coefficient for the state u_b.
423 *
424 * Note the class can be used for imposing conditions on interior interfaces.
425 */
427{
428private:
429 const NumericalFlux &numFlux; // Numerical flux that maps F to F̂
430 const FluxFunction &fluxFunction;
431 VectorCoefficient &u_vcoeff; // Boundary state vector coefficient
432 const int IntOrderOffset; // integration order offset, 2*p + IntOrderOffset.
433 const real_t sign;
434
435 // The maximum characteristic speed, updated during element/face vector assembly
436 real_t max_char_speed;
437
438#ifndef MFEM_THREAD_SAFE
439 // Local storage for element integration
440 Vector shape; // shape function value at an integration point
441 Vector state_in; // state value at an integration point - interior
442 Vector state_out; // state value at an integration point - boundary
443 Vector nor; // normal vector, see mfem::CalcOrtho()
444 Vector fluxN; // F̂(u⁻,u_b,x) n
445 DenseMatrix JDotN; // Ĵ(u⁻,u_b,x) n
446#endif
447
448public:
449 const int num_equations; // the number of equations
450
451 /**
452 * @brief Construct a new BdrHyperbolicDirichletIntegrator object
453 *
454 * @param[in] numFlux numerical flux
455 * @param[in] bdrState boundary state coefficient
456 * @param[in] IntOrderOffset integration order offset
457 * @param[in] sign sign of the convection term
458 */
460 const NumericalFlux &numFlux,
461 VectorCoefficient &bdrState,
462 const int IntOrderOffset = 0,
463 const real_t sign = 1.);
464
465 /// Reset the maximum characteristic speed to zero
466 void ResetMaxCharSpeed() { max_char_speed = 0.0; }
467
468 /// Get the maximum characteristic speed
469 real_t GetMaxCharSpeed() const { return max_char_speed; }
470
471 /// Get the associated flux function
472 const FluxFunction &GetFluxFunction() const { return fluxFunction; }
473
474 /**
475 * @brief Implements <-F̂(u⁻,u_b,x) n, [v]> with abstract F̂ computed by
476 * NumericalFlux::Eval() of the numerical flux object
477 *
478 * @param[in] el1 finite element of the interior element
479 * @param[in] el2 not used
480 * @param[in] Tr face element transformations
481 * @param[in] elfun local coefficient of basis for the interior element
482 * @param[out] elvect evaluated dual vector <-F̂(u⁻,u_b,x) n, [v]>
483 */
484 void AssembleFaceVector(const FiniteElement &el1,
485 const FiniteElement &el2,
487 const Vector &elfun, Vector &elvect) override;
488
489 /**
490 * @brief Implements <-Ĵ(u⁻,u_b,x) n, [v]> with abstract Ĵ computed by
491 * NumericalFlux::Grad() of the numerical flux object
492 *
493 * @param[in] el1 finite element of the interior element
494 * @param[in] el2 not used
495 * @param[in] Tr face element transformations
496 * @param[in] elfun local coefficient of basis for the interior element
497 * @param[out] elmat evaluated Jacobian matrix <-Ĵ(u⁻,u_b,x) n, [v]>
498 */
499 void AssembleFaceGrad(const FiniteElement &el1,
500 const FiniteElement &el2,
502 const Vector &elfun, DenseMatrix &elmat) override;
503};
504
505/**
506 * @brief Abstract boundary hyperbolic linear form integrator, assembling
507 * <ɑ/2 F(u,x) n - β |F(u,x) n|, v> terms for scalar finite elements.
508 *
509 * This form integrator is coupled with a FluxFunction that evaluates the
510 * flux F at the boundary.
511 *
512 * Note the upwinding is performed component-wise. For general boundary
513 * integration with a numerical flux, see BdrHyperbolicDirichletIntegrator.
514 */
516{
517 const FluxFunction &fluxFunction;
518 VectorCoefficient &u_vcoeff;
519 const real_t alpha, beta;
520 const int IntOrderOffset; // integration order offset, 2*p + IntOrderOffset.
521
522 // The maximum characteristic speed, updated during face vector assembly
523 real_t max_char_speed;
524
525#ifndef MFEM_THREAD_SAFE
526 // Local storage for element integration
527 Vector shape; // shape function value at an integration point
528 Vector state; // state value at an integration point
529 Vector nor; // normal vector, see mfem::CalcOrtho()
530 Vector fluxN; // F(u,x) n
531#endif
532
533public:
534 /**
535 * @brief Construct a new BoundaryHyperbolicFlowIntegrator object
536 *
537 * @param[in] flux flux function
538 * @param[in] u vector state coefficient
539 * @param[in] alpha ɑ coefficient (β = ɑ/2)
540 * @param[in] IntOrderOffset integration order offset
541 */
543 real_t alpha = -1., int IntOrderOffset = 0)
544 : BoundaryHyperbolicFlowIntegrator(flux, u, alpha, alpha/2., IntOrderOffset) { }
545
546 /**
547 * @brief Construct a new BoundaryHyperbolicFlowIntegrator object
548 *
549 * @param[in] flux flux function
550 * @param[in] u vector state coefficient
551 * @param[in] alpha ɑ coefficient
552 * @param[in] beta β coefficient
553 * @param[in] IntOrderOffset integration order offset
554 */
556 real_t alpha, real_t beta, int IntOrderOffset = 0);
557
558 /// Reset the maximum characteristic speed to zero
559 void ResetMaxCharSpeed() { max_char_speed = 0.0; }
560
561 /// Get the maximum characteristic speed
562 real_t GetMaxCharSpeed() const { return max_char_speed; }
563
564 /// Get the associated flux function
565 const FluxFunction &GetFluxFunction() const { return fluxFunction; }
566
568
569 /**
570 * @warning Boundary element integration not implemented, use
571 * AssembleRHSElementVect(const FiniteElement&,
572 * FaceElementTransformations &, Vector &) instead
573 */
576 Vector &elvect) override;
577
578 /**
579 * @brief Implements <-F(u,x) n, v> with abstract F computed by
580 * FluxFunction::ComputeFluxDotN() of the flux function object
581 *
582 * @param[in] el finite element
583 * @param[in] Tr face element transformations
584 * @param[out] elvect evaluated dual vector <F(u,x) n, v>
585 */
588 Vector &elvect) override;
589};
590
591
592/**
593 * @brief Rusanov flux, also known as local Lax-Friedrichs,
594 * F̂ n = ½(F(u⁺,x)n + F(u⁻,x)n) - ½λ(u⁺ - u⁻)
595 * where λ is the maximum characteristic speed.
596 * @note The implementation assumes monotonous |dF(u,x)/du⋅n| in u, so the
597 * maximum characteristic speed λ for any interval [u⁻, u⁺] is given by
598 * max(|dF(u⁺,x)/du⁺⋅n|, |dF(u⁻,x)/du⁻⋅n|).
599 */
601{
602public:
603 /**
604 * @brief Constructor for a flux function
605 * @param fluxFunction flux function F(u,x)
606 */
608
609 /**
610 * @brief Normal numerical flux F̂(u⁻,u⁺,x) n
611 * @note Systems of equations are treated component-wise
612 *
613 * @param[in] state1 state value (u⁻) at a point from the first element
614 * (num_equations)
615 * @param[in] state2 state value (u⁺) at a point from the second element
616 * (num_equations)
617 * @param[in] nor normal vector (not a unit vector) (dim)
618 * @param[in] Tr face element transformation
619 * @param[out] flux F̂ n = ½(F(u⁺,x)n + F(u⁻,x)n) - ½λ(u⁺ - u⁻)
620 * @return max(|dF(u⁺,x)/du⁺⋅n|, |dF(u⁻,x)/du⁻⋅n|)
621 */
622 real_t Eval(const Vector &state1, const Vector &state2,
623 const Vector &nor, FaceElementTransformations &Tr,
624 Vector &flux) const override;
625
626 /**
627 * @brief Jacobian of normal numerical flux F̂(u⁻,u⁺,x) n
628 * @note The Jacobian of flux J n is required to be implemented in
629 * FluxFunction::ComputeFluxJacobianDotN()
630 *
631 * @param[in] side gradient w.r.t the first (u⁻) or second argument (u⁺)
632 * @param[in] state1 state value (u⁻) of the beginning of the interval
633 * (num_equations)
634 * @param[in] state2 state value (u⁺) of the end of the interval
635 * (num_equations)
636 * @param[in] nor normal vector (not a unit vector) (dim)
637 * @param[in] Tr face element transformation
638 * @param[out] grad Jacobian of F(u⁻,u⁺,x) n
639 * side = 1:
640 * ½J(u⁻,x)n + ½λ
641 * side = 2:
642 * ½J(u⁺,x)n - ½λ
643 */
644 void Grad(int side, const Vector &state1, const Vector &state2,
645 const Vector &nor, FaceElementTransformations &Tr,
646 DenseMatrix &grad) const override;
647
648 /**
649 * @brief Average normal numerical flux over the interval [u⁻, u⁺] in the
650 * second argument of the flux F̂(u⁻,u,x) n
651 * @note The average normal flux F̄ n is required to be implemented in
652 * FluxFunction::ComputeAvgFluxDotN()
653 * @note Systems of equations are treated component-wise
654 *
655 * @param[in] state1 state value (u⁻) of the beginning of the interval
656 * (num_equations)
657 * @param[in] state2 state value (u⁺) of the end of the interval
658 * (num_equations)
659 * @param[in] nor normal vector (not a unit vector) (dim)
660 * @param[in] Tr face element transformation
661 * @param[out] flux ½(F̄(u⁻,u⁺,x)n + F(u⁻,x)n) - ¼λ(u⁺ - u⁻)
662 * @return max(|dF(u⁺,x)/du⁺⋅n|, |dF(u⁻,x)/du⁻⋅n|)
663 */
664 real_t Average(const Vector &state1, const Vector &state2,
665 const Vector &nor, FaceElementTransformations &Tr,
666 Vector &flux) const override;
667
668 /**
669 * @brief Jacobian of average normal numerical flux over the interval
670 * [u⁻, u⁺] in the second argument of the flux F̂(u⁻,u,x) n
671 * @note The average normal flux F̄ n is required to be implemented in
672 * FluxFunction::ComputeAvgFluxDotN() and the Jacobian of flux J n in
673 * FluxFunction::ComputeFluxJacobianDotN()
674 * @note Only the diagonal terms of the J n are considered, i.e., systems
675 * are treated as a set of independent equations
676 *
677 * @param[in] side gradient w.r.t the first (u⁻) or second argument (u⁺)
678 * @param[in] state1 state value (u⁻) of the beginning of the interval
679 * (num_equations)
680 * @param[in] state2 state value (u⁺) of the end of the interval
681 * (num_equations)
682 * @param[in] nor normal vector (not a unit vector) (dim)
683 * @param[in] Tr face element transformation
684 * @param[out] grad Jacobian of F̄(u⁻,u⁺,x) n
685 * side = 1:
686 * ½(F̄(u⁻,u⁺,x)n - F(u⁻,x)n) / (u⁺ - u⁻) - ½J(u⁻,x)n + ¼λ
687 * side = 2:
688 * ½(F(u⁺,x)n - F̄(u⁻,u⁺,x)n) / (u⁺ - u⁻) - ¼λ
689 */
690 void AverageGrad(int side, const Vector &state1, const Vector &state2,
691 const Vector &nor, FaceElementTransformations &Tr,
692 DenseMatrix &grad) const override;
693
694protected:
695#ifndef MFEM_THREAD_SAFE
698#endif
699};
700
701/**
702 * @brief Component-wise upwinded flux
703 *
704 * Upwinded flux for scalar equations, a special case of Godunov or
705 * Engquist-Osher flux, is defined as follows:
706 * F̂ n = F(u⁺)n for dF(u)/du < 0 on [u⁻,u⁺]
707 * F̂ n = F(u⁻)n for dF(u)/du > 0 on [u⁻,u⁺]
708 * @note This construction assumes monotonous F(u,x) in u
709 * @note Systems of equations are treated component-wise
710 */
712{
713public:
714 /**
715 * @brief Constructor for a flux function
716 * @param fluxFunction flux function F(u,x)
717 */
719
720 /**
721 * @brief Normal numerical flux F̂(u⁻,u⁺,x) n
722 *
723 * @param[in] state1 state value (u⁻) at a point from the first element
724 * (num_equations)
725 * @param[in] state2 state value (u⁺) at a point from the second element
726 * (num_equations)
727 * @param[in] nor normal vector (not a unit vector) (dim)
728 * @param[in] Tr face element transformation
729 * @param[out] flux F̂ n = min(F(u⁻,x)n, F(u⁺,x)n) for u⁻ ≤ u⁺
730 * or F̂ n = max(F(u⁻,x)n, F(u⁺,x)n) for u⁻ > u⁺
731 * @return max(|dF(u⁺,x)/du⁺⋅n|, |dF(u⁻,x)/du⁻⋅n|)
732 */
733 real_t Eval(const Vector &state1, const Vector &state2,
734 const Vector &nor, FaceElementTransformations &Tr,
735 Vector &flux) const override;
736
737 /**
738 * @brief Jacobian of normal numerical flux F̂(u⁻,u⁺,x) n
739 * @note The Jacobian of flux J n is required to be implemented in
740 * FluxFunction::ComputeFluxJacobianDotN()
741 *
742 * @param[in] side gradient w.r.t the first (u⁻) or second argument (u⁺)
743 * @param[in] state1 state value (u⁻) of the beginning of the interval
744 * (num_equations)
745 * @param[in] state2 state value (u⁺) of the end of the interval
746 * (num_equations)
747 * @param[in] nor normal vector (not a unit vector) (dim)
748 * @param[in] Tr face element transformation
749 * @param[out] grad Jacobian of F(u⁻,u⁺,x) n
750 * side = 1:
751 * max(J(u⁻,x)n, 0)
752 * side = 2:
753 * min(J(u⁺,x)n, 0)
754 */
755 void Grad(int side, const Vector &state1, const Vector &state2,
756 const Vector &nor, FaceElementTransformations &Tr,
757 DenseMatrix &grad) const override;
758
759 /**
760 * @brief Average normal numerical flux over the interval [u⁻, u⁺] in the
761 * second argument of the flux F̂(u⁻,u,x) n
762 * @note The average normal flux F̄ n is required to be implemented in
763 * FluxFunction::ComputeAvgFluxDotN()
764 *
765 * @param[in] state1 state value (u⁻) of the beginning of the interval
766 * (num_equations)
767 * @param[in] state2 state value (u⁺) of the end of the interval
768 * (num_equations)
769 * @param[in] nor normal vector (not a unit vector) (dim)
770 * @param[in] Tr face element transformation
771 * @param[out] flux F̂ n = min(F(u⁻)n, F̄(u⁺,x)n) for u⁻ ≤ u⁺
772 * or F̂ n = max(F(u⁻)n, F̄(u⁺,x)n) for u⁻ > u⁺
773 * @return max(|dF(u⁺,x)/du⁺⋅n|, |dF(u⁻,x)/du⁻⋅n|)
774 */
775 real_t Average(const Vector &state1, const Vector &state2,
776 const Vector &nor, FaceElementTransformations &Tr,
777 Vector &flux) const override;
778
779 /**
780 * @brief Jacobian of average normal numerical flux over the interval
781 * [u⁻, u⁺] in the second argument of the flux F̂(u⁻,u,x) n
782 * @note The average normal flux F̄ n is required to be implemented in
783 * FluxFunction::ComputeAvgFluxDotN() and the Jacobian of flux J n in
784 * FluxFunction::ComputeFluxJacobianDotN()
785 *
786 * @param[in] side gradient w.r.t the first (u⁻) or second argument (u⁺)
787 * @param[in] state1 state value (u⁻) of the beginning of the interval
788 * (num_equations)
789 * @param[in] state2 state value (u⁺) of the end of the interval
790 * (num_equations)
791 * @param[in] nor normal vector (not a unit vector) (dim)
792 * @param[in] Tr face element transformation
793 * @param[out] grad Jacobian of F̄(u⁻,u⁺,x) n
794 * side = 1:
795 * (F(u⁺) - F̄(u⁻,u⁺))n / (u⁺ - u⁻) when negative
796 * J(u⁻,x) n otherwise
797 * side = 2:
798 * min((F(u⁺) - F̄(u⁻,u⁺))n / (u⁺ - u⁻), 0)
799 */
800 void AverageGrad(int side, const Vector &state1, const Vector &state2,
801 const Vector &nor, FaceElementTransformations &Tr,
802 DenseMatrix &grad) const override;
803
804protected:
805#ifndef MFEM_THREAD_SAFE
808#endif
809};
810
811/// Advection flux
813{
814private:
815 VectorCoefficient &b; // velocity coefficient
816#ifndef MFEM_THREAD_SAFE
817 mutable Vector bval; // velocity value storage
818#endif
819
820public:
821
822 /**
823 * @brief Construct AdvectionFlux FluxFunction with given velocity
824 *
825 * @param b velocity coefficient, possibly depends on space
826 */
828 : FluxFunction(1, b.GetVDim()), b(b)
829 {
830#ifndef MFEM_THREAD_SAFE
831 bval.SetSize(b.GetVDim());
832#endif
833 }
834
835 /**
836 * @brief Compute F(u)
837 *
838 * @param state state (u) at current integration point
839 * @param Tr current element transformation with the integration point
840 * @param flux F(u) = ubᵀ
841 * @return real_t maximum characteristic speed, |b|
842 */
844 DenseMatrix &flux) const override;
845
846 /**
847 * @brief Compute F(u) n
848 *
849 * @param state state (u) at current integration point
850 * @param normal normal vector, usually not a unit vector
851 * @param Tr current element transformation with the integration point
852 * @param fluxDotN F(u) n = u (bᵀn)
853 * @return real_t maximum characteristic speed, |b|
854 */
855 real_t ComputeFluxDotN(const Vector &state,
856 const Vector &normal, FaceElementTransformations &Tr,
857 Vector &fluxDotN) const override;
858
859 /**
860 * @brief Compute average flux F̄(u)
861 *
862 * @param state1 state value (u⁻) of the beginning of the interval
863 * @param state2 state value (u⁺) of the end of the interval
864 * @param Tr current element transformation with the integration point
865 * @param flux F̄(u) = (u⁻+u⁺)/2*bᵀ
866 * @return real_t maximum characteristic speed, |b|
867 */
868 real_t ComputeAvgFlux(const Vector &state1, const Vector &state2,
869 ElementTransformation &Tr, DenseMatrix &flux) const override;
870
871 /**
872 * @brief Compute average flux F̄(u) n
873 *
874 * @param state1 state value (u⁻) of the beginning of the interval
875 * @param state2 state value (u⁺) of the end of the interval
876 * @param normal normal vector, usually not a unit vector
877 * @param Tr current element transformation with the integration point
878 * @param fluxDotN F̄(u) n = (u⁻+u⁺)/2*(bᵀn)
879 * @return real_t maximum characteristic speed, |b|
880 */
881 real_t ComputeAvgFluxDotN(const Vector &state1, const Vector &state2,
882 const Vector &normal, FaceElementTransformations &Tr,
883 Vector &fluxDotN) const override;
884
885 /**
886 * @brief Compute J(u)
887 *
888 * @param state state (u) at current integration point
889 * @param Tr current element transformation with the integration point
890 * @param J J(u) = diag(b)
891 */
892 void ComputeFluxJacobian(const Vector &state,
894 DenseTensor &J) const override;
895
896 /**
897 * @brief Compute J(u) n
898 *
899 * @param state state (u) at current integration point
900 * @param normal normal vector, usually not a unit vector
901 * @param Tr current element transformation with the integration point
902 * @param JDotN J(u) n = bᵀn
903 */
904 void ComputeFluxJacobianDotN(const Vector &state,
905 const Vector &normal,
907 DenseMatrix &JDotN) const override;
908};
909
910/// Burgers flux
912{
913public:
914 /**
915 * @brief Construct BurgersFlux FluxFunction with given spatial dimension
916 *
917 * @param dim spatial dimension
918 */
919 BurgersFlux(const int dim)
920 : FluxFunction(1, dim) {}
921
922 /**
923 * @brief Compute F(u)
924 *
925 * @param state state (u) at current integration point
926 * @param Tr current element transformation with the integration point
927 * @param flux F(u) = ½u²*1ᵀ where 1 is (dim) vector
928 * @return real_t maximum characteristic speed, |u|
929 */
931 DenseMatrix &flux) const override;
932
933 /**
934 * @brief Compute F(u) n
935 *
936 * @param state state (u) at current integration point
937 * @param normal normal vector, usually not a unit vector
938 * @param Tr current element transformation with the integration point
939 * @param fluxDotN F(u) n = ½u²*(1ᵀn) where 1 is (dim) vector
940 * @return real_t maximum characteristic speed, |u|
941 */
942 real_t ComputeFluxDotN(const Vector &state,
943 const Vector &normal,
945 Vector &fluxDotN) const override;
946
947 /**
948 * @brief Compute average flux F̄(u)
949 *
950 * @param state1 state value (u⁻) of the beginning of the interval
951 * @param state2 state value (u⁺) of the end of the interval
952 * @param Tr current element transformation with the integration point
953 * @param flux F̄(u) = (u⁻²+u⁻*u⁺+u⁺²)/6*1ᵀ where 1 is (dim) vector
954 * @return real_t maximum characteristic speed, |u|
955 */
956 real_t ComputeAvgFlux(const Vector &state1,
957 const Vector &state2,
959 DenseMatrix &flux) const override;
960
961 /**
962 * @brief Compute average flux F̄(u) n
963 *
964 * @param state1 state value (u⁻) of the beginning of the interval
965 * @param state2 state value (u⁺) of the end of the interval
966 * @param normal normal vector, usually not a unit vector
967 * @param Tr current element transformation with the integration point
968 * @param fluxDotN F̄(u) n = (u⁻²+u⁻*u⁺+u⁺²)/6*(1ᵀn) where 1 is (dim) vector
969 * @return real_t maximum characteristic speed, |u|
970 */
971 real_t ComputeAvgFluxDotN(const Vector &state1,
972 const Vector &state2,
973 const Vector &normal,
975 Vector &fluxDotN) const override;
976
977 /**
978 * @brief Compute J(u)
979 *
980 * @param state state (u) at current integration point
981 * @param Tr current element transformation with the integration point
982 * @param J J(u) = diag(u*1) where 1 is (dim) vector
983 */
984 void ComputeFluxJacobian(const Vector &state,
986 DenseTensor &J) const override;
987
988 /**
989 * @brief Compute J(u) n
990 *
991 * @param state state (u) at current integration point
992 * @param normal normal vector, usually not a unit vector
993 * @param Tr current element transformation with the integration point
994 * @param JDotN J(u) n = u*(1ᵀn) where 1 is (dim) vector
995 */
996 void ComputeFluxJacobianDotN(const Vector &state,
997 const Vector &normal,
999 DenseMatrix &JDotN) const override;
1000};
1001
1002/// Shallow water flux
1004{
1005private:
1006 const real_t g; // gravity constant
1007
1008public:
1009 /**
1010 * @brief Construct a new ShallowWaterFlux FluxFunction with given spatial
1011 * dimension and gravity constant
1012 *
1013 * @param dim spatial dimension
1014 * @param g gravity constant
1015 */
1016 ShallowWaterFlux(const int dim, const real_t g=9.8)
1017 : FluxFunction(dim + 1, dim), g(g) {}
1018
1019 /**
1020 * @brief Compute F(h, hu)
1021 *
1022 * @param state state (h, hu) at current integration point
1023 * @param Tr current element transformation with the integration point
1024 * @param flux F(h, hu) = [huᵀ; huuᵀ + ½gh²I]
1025 * @return real_t maximum characteristic speed, |u| + √(gh)
1026 */
1028 DenseMatrix &flux) const override;
1029
1030 /**
1031 * @brief Compute normal flux, F(h, hu)
1032 *
1033 * @param state state (h, hu) at current integration point
1034 * @param normal normal vector, usually not a unit vector
1035 * @param Tr current element transformation with the integration point
1036 * @param fluxN F(ρ, ρu, E)n = [ρu⋅n; ρu(u⋅n) + pn; (u⋅n)(E + p)]
1037 * @return real_t maximum characteristic speed, |u| + √(γp/ρ)
1038 */
1039 real_t ComputeFluxDotN(const Vector &state, const Vector &normal,
1041 Vector &fluxN) const override;
1042};
1043
1044/// Euler flux
1046{
1047private:
1048 const real_t specific_heat_ratio; // specific heat ratio, γ
1049 // const real_t gas_constant; // gas constant
1050
1051public:
1052 /**
1053 * @brief Construct a new EulerFlux FluxFunction with given spatial
1054 * dimension and specific heat ratio
1055 *
1056 * @param dim spatial dimension
1057 * @param specific_heat_ratio specific heat ratio, γ
1058 */
1059 EulerFlux(const int dim, const real_t specific_heat_ratio)
1060 : FluxFunction(dim + 2, dim),
1061 specific_heat_ratio(specific_heat_ratio) {}
1062
1063 /**
1064 * @brief Compute F(ρ, ρu, E)
1065 *
1066 * @param state state (ρ, ρu, E) at current integration point
1067 * @param Tr current element transformation with the integration point
1068 * @param flux F(ρ, ρu, E) = [ρuᵀ; ρuuᵀ + pI; uᵀ(E + p)]
1069 * @return real_t maximum characteristic speed, |u| + √(γp/ρ)
1070 */
1072 DenseMatrix &flux) const override;
1073
1074 /**
1075 * @brief Compute normal flux, F(ρ, ρu, E)n
1076 *
1077 * @param x x (ρ, ρu, E) at current integration point
1078 * @param normal normal vector, usually not a unit vector
1079 * @param Tr current element transformation with the integration point
1080 * @param fluxN F(ρ, ρu, E)n = [ρu⋅n; ρu(u⋅n) + pn; (u⋅n)(E + p)]
1081 * @return real_t maximum characteristic speed, |u| + √(γp/ρ)
1082 */
1083 real_t ComputeFluxDotN(const Vector &x, const Vector &normal,
1085 Vector &fluxN) const override;
1086};
1087
1088} // namespace mfem
1089
1090#endif // MFEM_HYPERBOLIC
Advection flux.
AdvectionFlux(VectorCoefficient &b)
Construct AdvectionFlux FluxFunction with given velocity.
void ComputeFluxJacobian(const Vector &state, ElementTransformation &Tr, DenseTensor &J) const override
Compute J(u)
real_t ComputeFlux(const Vector &state, ElementTransformation &Tr, DenseMatrix &flux) const override
Compute F(u)
void ComputeFluxJacobianDotN(const Vector &state, const Vector &normal, ElementTransformation &Tr, DenseMatrix &JDotN) const override
Compute J(u) n.
real_t ComputeFluxDotN(const Vector &state, const Vector &normal, FaceElementTransformations &Tr, Vector &fluxDotN) const override
Compute F(u) n.
real_t ComputeAvgFlux(const Vector &state1, const Vector &state2, ElementTransformation &Tr, DenseMatrix &flux) const override
Compute average flux F̄(u)
real_t ComputeAvgFluxDotN(const Vector &state1, const Vector &state2, const Vector &normal, FaceElementTransformations &Tr, Vector &fluxDotN) const override
Compute average flux F̄(u) n.
Abstract boundary hyperbolic form integrator, assembling <F̂(u⁻,u_b,x) n, [v]> term for scalar finite...
void AssembleFaceGrad(const FiniteElement &el1, const FiniteElement &el2, FaceElementTransformations &Tr, const Vector &elfun, DenseMatrix &elmat) override
Implements <-Ĵ(u⁻,u_b,x) n, [v]> with abstract Ĵ computed by NumericalFlux::Grad() of the numerical...
void ResetMaxCharSpeed()
Reset the maximum characteristic speed to zero.
const FluxFunction & GetFluxFunction() const
Get the associated flux function.
void AssembleFaceVector(const FiniteElement &el1, const FiniteElement &el2, FaceElementTransformations &Tr, const Vector &elfun, Vector &elvect) override
Implements <-F̂(u⁻,u_b,x) n, [v]> with abstract F̂ computed by NumericalFlux::Eval() of the numerical...
real_t GetMaxCharSpeed() const
Get the maximum characteristic speed.
BdrHyperbolicDirichletIntegrator(const NumericalFlux &numFlux, VectorCoefficient &bdrState, const int IntOrderOffset=0, const real_t sign=1.)
Construct a new BdrHyperbolicDirichletIntegrator object.
Abstract boundary hyperbolic linear form integrator, assembling <ɑ/2 F(u,x) n - β |F(u,...
real_t GetMaxCharSpeed() const
Get the maximum characteristic speed.
BoundaryHyperbolicFlowIntegrator(const FluxFunction &flux, VectorCoefficient &u, real_t alpha=-1., int IntOrderOffset=0)
Construct a new BoundaryHyperbolicFlowIntegrator object.
void ResetMaxCharSpeed()
Reset the maximum characteristic speed to zero.
const FluxFunction & GetFluxFunction() const
Get the associated flux function.
void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) override
Burgers flux.
real_t ComputeAvgFluxDotN(const Vector &state1, const Vector &state2, const Vector &normal, FaceElementTransformations &Tr, Vector &fluxDotN) const override
Compute average flux F̄(u) n.
BurgersFlux(const int dim)
Construct BurgersFlux FluxFunction with given spatial dimension.
void ComputeFluxJacobianDotN(const Vector &state, const Vector &normal, ElementTransformation &Tr, DenseMatrix &JDotN) const override
Compute J(u) n.
real_t ComputeAvgFlux(const Vector &state1, const Vector &state2, ElementTransformation &Tr, DenseMatrix &flux) const override
Compute average flux F̄(u)
real_t ComputeFluxDotN(const Vector &state, const Vector &normal, FaceElementTransformations &Tr, Vector &fluxDotN) const override
Compute F(u) n.
real_t ComputeFlux(const Vector &state, ElementTransformation &Tr, DenseMatrix &flux) const override
Compute F(u)
void ComputeFluxJacobian(const Vector &state, ElementTransformation &Tr, DenseTensor &J) const override
Compute J(u)
Component-wise upwinded flux.
ComponentwiseUpwindFlux(const FluxFunction &fluxFunction)
Constructor for a flux function.
void AverageGrad(int side, const Vector &state1, const Vector &state2, const Vector &nor, FaceElementTransformations &Tr, DenseMatrix &grad) const override
Jacobian of average normal numerical flux over the interval [u⁻, u⁺] in the second argument of the fl...
real_t Average(const Vector &state1, const Vector &state2, const Vector &nor, FaceElementTransformations &Tr, Vector &flux) const override
Average normal numerical flux over the interval [u⁻, u⁺] in the second argument of the flux F̂(u⁻,...
void Grad(int side, const Vector &state1, const Vector &state2, const Vector &nor, FaceElementTransformations &Tr, DenseMatrix &grad) const override
Jacobian of normal numerical flux F̂(u⁻,u⁺,x) n.
real_t Eval(const Vector &state1, const Vector &state2, const Vector &nor, FaceElementTransformations &Tr, Vector &flux) const override
Normal numerical flux F̂(u⁻,u⁺,x) n.
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
Rank 3 tensor (array of matrices)
real_t ComputeFlux(const Vector &state, ElementTransformation &Tr, DenseMatrix &flux) const override
Compute F(ρ, ρu, E)
EulerFlux(const int dim, const real_t specific_heat_ratio)
Construct a new EulerFlux FluxFunction with given spatial dimension and specific heat ratio.
real_t ComputeFluxDotN(const Vector &x, const Vector &normal, FaceElementTransformations &Tr, Vector &fluxN) const override
Compute normal flux, F(ρ, ρu, E)n.
A specialized ElementTransformation class representing a face and its two neighboring elements.
Definition eltrans.hpp:750
Abstract class for all finite elements.
Definition fe_base.hpp:247
Abstract class for hyperbolic flux for a system of hyperbolic conservation laws.
virtual real_t ComputeAvgFlux(const Vector &state1, const Vector &state2, ElementTransformation &Tr, DenseMatrix &flux_) const
Compute average flux over the given interval of states. Optionally overloaded in a derived class.
virtual real_t ComputeAvgFluxDotN(const Vector &state1, const Vector &state2, const Vector &normal, FaceElementTransformations &Tr, Vector &fluxDotN) const
Compute average normal flux over the given interval of states. Optionally overloaded in a derived cla...
FluxFunction(const int num_equations, const int dim)
const int num_equations
virtual ~FluxFunction()
virtual real_t ComputeFlux(const Vector &state, ElementTransformation &Tr, DenseMatrix &flux) const =0
Compute flux F(u, x). Must be implemented in a derived class.
virtual void ComputeFluxJacobian(const Vector &state, ElementTransformation &Tr, DenseTensor &J_) const
Compute flux Jacobian J(u, x). Optionally overloaded in a derived class when Jacobian is necessary (e...
virtual real_t ComputeFluxDotN(const Vector &state, const Vector &normal, FaceElementTransformations &Tr, Vector &fluxDotN) const
Compute normal flux F(u, x)⋅n. Optionally overloaded in a derived class to avoid creating a full dens...
virtual void ComputeFluxJacobianDotN(const Vector &state, const Vector &normal, ElementTransformation &Tr, DenseMatrix &JDotN) const
Compute normal flux Jacobian J(u, x)⋅n. Optionally overloaded in a derived class to avoid creating a ...
Abstract hyperbolic form integrator, assembling (F(u, x), ∇v) and <F̂(u⁻,u⁺,x) n, [v]> terms for scal...
HyperbolicFormIntegrator(const NumericalFlux &numFlux, const int IntOrderOffset=0, const real_t sign=1.)
Construct a new HyperbolicFormIntegrator object.
void AssembleFaceGrad(const FiniteElement &el1, const FiniteElement &el2, FaceElementTransformations &Tr, const Vector &elfun, DenseMatrix &elmat) override
Implements <-Ĵ(u⁻,u⁺,x) n, [v]> with abstract Ĵ computed by NumericalFlux::Grad() of the numerical ...
void AssembleFaceVector(const FiniteElement &el1, const FiniteElement &el2, FaceElementTransformations &Tr, const Vector &elfun, Vector &elvect) override
Implements <-F̂(u⁻,u⁺,x) n, [v]> with abstract F̂ computed by NumericalFlux::Eval() of the numerical ...
void ResetMaxCharSpeed()
Reset the maximum characteristic speed to zero.
const FluxFunction & GetFluxFunction() const
Get the associated flux function.
void AssembleElementGrad(const FiniteElement &el, ElementTransformation &Tr, const Vector &elfun, DenseMatrix &grad) override
Implements (J(u), ∇v) with abstract J computed by FluxFunction::ComputeFluxJacobian()
void AssembleElementVector(const FiniteElement &el, ElementTransformation &Tr, const Vector &elfun, Vector &elvect) override
Implements (F(u), ∇v) with abstract F computed by FluxFunction::ComputeFlux()
real_t GetMaxCharSpeed() const
Get the maximum characteristic speed.
Abstract base class LinearFormIntegrator.
Definition lininteg.hpp:28
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)=0
This class is used to express the local action of a general nonlinear finite element operator....
Abstract class for numerical flux for a system of hyperbolic conservation laws on a face with states,...
NumericalFlux(const FluxFunction &fluxFunction)
Constructor for a flux function.
virtual ~NumericalFlux()=default
const FluxFunction & fluxFunction
virtual real_t Eval(const Vector &state1, const Vector &state2, const Vector &nor, FaceElementTransformations &Tr, Vector &flux) const =0
Evaluates normal numerical flux for the given states and normal. Must be implemented in a derived cla...
const FluxFunction & GetFluxFunction() const
Get flux function F.
virtual real_t Average(const Vector &state1, const Vector &state2, const Vector &nor, FaceElementTransformations &Tr, Vector &flux) const
Evaluates average normal numerical flux over the interval between the given end states in the second ...
virtual void AverageGrad(int side, const Vector &state1, const Vector &state2, const Vector &nor, FaceElementTransformations &Tr, DenseMatrix &grad) const
Evaluates Jacobian of the average normal numerical flux over the interval between the given end state...
virtual void Grad(int side, const Vector &state1, const Vector &state2, const Vector &nor, FaceElementTransformations &Tr, DenseMatrix &grad) const
Evaluates Jacobian of the normal numerical flux for the given states and normal. Optionally overloade...
Rusanov flux, also known as local Lax-Friedrichs, F̂ n = ½(F(u⁺,x)n + F(u⁻,x)n) - ½λ(u⁺ - u⁻) where λ...
RusanovFlux(const FluxFunction &fluxFunction)
Constructor for a flux function.
DenseMatrix JDotN
real_t Average(const Vector &state1, const Vector &state2, const Vector &nor, FaceElementTransformations &Tr, Vector &flux) const override
Average normal numerical flux over the interval [u⁻, u⁺] in the second argument of the flux F̂(u⁻,...
void Grad(int side, const Vector &state1, const Vector &state2, const Vector &nor, FaceElementTransformations &Tr, DenseMatrix &grad) const override
Jacobian of normal numerical flux F̂(u⁻,u⁺,x) n.
void AverageGrad(int side, const Vector &state1, const Vector &state2, const Vector &nor, FaceElementTransformations &Tr, DenseMatrix &grad) const override
Jacobian of average normal numerical flux over the interval [u⁻, u⁺] in the second argument of the fl...
real_t Eval(const Vector &state1, const Vector &state2, const Vector &nor, FaceElementTransformations &Tr, Vector &flux) const override
Normal numerical flux F̂(u⁻,u⁺,x) n.
Shallow water flux.
ShallowWaterFlux(const int dim, const real_t g=9.8)
Construct a new ShallowWaterFlux FluxFunction with given spatial dimension and gravity constant.
real_t ComputeFluxDotN(const Vector &state, const Vector &normal, FaceElementTransformations &Tr, Vector &fluxN) const override
Compute normal flux, F(h, hu)
real_t ComputeFlux(const Vector &state, ElementTransformation &Tr, DenseMatrix &flux) const override
Compute F(h, hu)
Base class for vector Coefficients that optionally depend on time and space.
Vector data type.
Definition vector.hpp:82
void SetSize(int s)
Resize the vector to size s.
Definition vector.hpp:584
const real_t alpha
Definition ex15.cpp:369
real_t b
Definition lissajous.cpp:42
real_t u(const Vector &xvec)
Definition lor_mms.hpp:22
MFEM_DEPRECATED typedef NumericalFlux RiemannSolver
float real_t
Definition config.hpp:46