Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/Inciter/FieldOutput.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 Extract field output for inciter
9 : : \details Extract field output for inciter.
10 : : */
11 : : // *****************************************************************************
12 : : #ifndef FieldOutput_h
13 : : #define FieldOutput_h
14 : :
15 : : #include "Types.hpp"
16 : : #include "Fields.hpp"
17 : : #include "Centering.hpp"
18 : : #include "ContainerUtil.hpp"
19 : : #include "Inciter/InputDeck/InputDeck.hpp"
20 : : #include "UnsMesh.hpp"
21 : : #include "Discretization.hpp"
22 : : #include "FunctionPrototypes.hpp"
23 : :
24 : : namespace inciter {
25 : :
26 : : extern ctr::InputDeck g_inputdeck;
27 : :
28 : : //! Collect field output names from numerical solution based on user input
29 : : std::vector< std::string >
30 : : numericFieldNames( tk::Centering c, char depvar = 0 );
31 : :
32 : : //! Collect field output from numerical solution based on user input
33 : : std::vector< std::vector< tk::real > >
34 : : numericFieldOutput( const tk::Fields& U, tk::Centering c,
35 : : const std::map< std::string, tk::GetVarFn >& outvarfn,
36 : : const tk::Fields& P = tk::Fields(),
37 : : char depvar = 0 );
38 : :
39 : : //! Evaluate solution on incoming (a potentially refined) mesh
40 : : void
41 : : evalSolution(
42 : : const Discretization& D,
43 : : const std::vector< std::size_t >& inpoel,
44 : : const tk::UnsMesh::Coords& coord,
45 : : const std::unordered_map< std::size_t, std::size_t >& addedTets,
46 : : const std::vector< std::size_t >& ndofel,
47 : : const tk::Fields& U,
48 : : const tk::Fields& P,
49 : : tk::Fields& uElemfields,
50 : : tk::Fields& pElemfields,
51 : : tk::Fields& uNodefields,
52 : : tk::Fields& pNodefields );
53 : :
54 : : //! Collect field output names from analytic solutions based on user input
55 : : //! \tparam PDE Partial differential equation type
56 : : //! \param[in] eq PDE whose analytic solution field names to query
57 : : //! \param[in] c Extract variables only with this centering
58 : : //! \param[in,out] f Output field names augmented
59 : : template< class PDE >
60 : : void
61 : 5911 : analyticFieldNames( const PDE& eq,
62 : : tk::Centering c,
63 : : std::vector< std::string >& f )
64 : : {
65 [ + + ]: 32473 : for (const auto& v : g_inputdeck.get< tag::field_output, tag::outvar >())
66 [ + + ][ + + ]: 26562 : if (v.centering == c && v.analytic())
[ + + ]
67 [ + - ][ + - ]: 2915 : tk::concat( eq.analyticFieldNames(), f );
68 : 5911 : }
69 : :
70 : : //! Collect field output from analytic solutions based on user input
71 : : //! \tparam PDE Partial differential equation type
72 : : //! \param[in] eq PDE whose analytic solution to output
73 : : //! \param[in] c Extract variables only with this centering
74 : : //! \param[in] x x coordinates at which to evaluate the analytic solution
75 : : //! \param[in] y y coordinates at which to evaluate the analytic solution
76 : : //! \param[in] z z coordinates at which to evaluate the analytic solution
77 : : //! \param[in] t Physical time at which to evaluate the analytic solution
78 : : //! \param[in,out] f Output fields augmented by analytic solutions requested
79 : : template< class PDE >
80 : : void
81 : 5911 : analyticFieldOutput( const PDE& eq,
82 : : tk::Centering c,
83 : : const std::vector< tk::real >& x,
84 : : const std::vector< tk::real >& y,
85 : : const std::vector< tk::real >& z,
86 : : tk::real t,
87 : : std::vector< std::vector< tk::real > >& f )
88 : : {
89 [ + + ]: 32473 : for (const auto& v : g_inputdeck.get< tag::field_output, tag::outvar >()) {
90 [ + + ][ + + ]: 26562 : if (v.centering == c && v.analytic()) {
[ + + ]
91 [ + - ]: 2915 : auto ncomp = eq.analyticSolution( x[0], y[0], z[0], t ).size();
92 [ + - ][ + - ]: 2915 : f.resize( f.size() + ncomp, std::vector< tk::real >( x.size() ) );
93 [ + + ]: 1335807 : for (std::size_t i=0; i<x.size(); ++i) {
94 [ + - ]: 2665784 : auto s = eq.analyticSolution( x[i], y[i], z[i], t );
95 [ + + ]: 4545649 : for (std::size_t j=0; j<ncomp; ++j) f[f.size()-ncomp+j][i] = s[j];
96 : : }
97 : : }
98 : : }
99 : 5911 : }
100 : :
101 : : } // inciter::
102 : :
103 : : #endif // FieldOutput_h
|