Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/PDE/MultiMat/Problem/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 Field outputs for multi-material equation solver
9 : : \details This file defines functions for field quantites to be output to
10 : : files for compressible multi-material equations.
11 : : */
12 : : // *****************************************************************************
13 : : #ifndef FieldOutput_h
14 : : #define FieldOutput_h
15 : :
16 : : #include "Types.hpp"
17 : : #include "Fields.hpp"
18 : : #include "EoS/EOS.hpp"
19 : : #include "FaceData.hpp"
20 : : #include "FunctionPrototypes.hpp"
21 : : #include "MultiMat/MultiMatIndexing.hpp"
22 : :
23 : : namespace inciter {
24 : :
25 : : extern ctr::InputDeck g_inputdeck;
26 : :
27 : : using ncomp_t = tk::ncomp_t;
28 : :
29 : : //! Return a map that associates user-specified strings to functions
30 : : std::map< std::string, tk::GetVarFn > MultiMatOutVarFn();
31 : :
32 : : //! Return multi-material field names to be output to file
33 : : std::vector< std::string >
34 : : MultiMatFieldNames( std::size_t nmat );
35 : :
36 : : //! Return field output going to file
37 : : std::vector< std::vector< tk::real > >
38 : : MultiMatFieldOutput(
39 : : ncomp_t,
40 : : std::size_t nmat,
41 : : const std::vector< EOS >& mat_blk,
42 : : std::size_t nunk,
43 : : std::size_t rdof,
44 : : const std::vector< tk::real >& vol,
45 : : const std::array< std::vector< tk::real >, 3 >& coord,
46 : : const tk::Fields& U,
47 : : const tk::Fields& P );
48 : :
49 : :
50 : : //! Return surface field names to be output to file
51 : : std::vector< std::string > MultiMatSurfNames();
52 : :
53 : : //! Return element surface field output (on triangle faces) going to file
54 : : std::vector< std::vector< tk::real > >
55 : : MultiMatSurfOutput(
56 : : const std::size_t nmat,
57 : : const std::size_t rdof,
58 : : const FaceData& fd,
59 : : const tk::Fields& U,
60 : : const tk::Fields& P );
61 : :
62 : : //! Return time history field names to be output to file
63 : : std::vector< std::string > MultiMatHistNames();
64 : :
65 : : //! Return diagnostic var names to be output to file
66 : : std::vector< std::string > MultiMatDiagNames(std::size_t nmat);
67 : :
68 : : /** @name Functions that compute physics variables from the numerical solution for MultiMat */
69 : : ///@{
70 : :
71 : : #if defined(__clang__)
72 : : #pragma clang diagnostic push
73 : : #pragma clang diagnostic ignored "-Wunused-function"
74 : : #endif
75 : :
76 : : namespace multimat {
77 : :
78 : : //! Compute bulk density for output to file
79 : : //! \note Must follow the signature in tk::GetVarFn
80 : : //! \param[in] U Numerical solution
81 : : //! \param[in] rdof Number of reconstructed solution DOFs
82 : : //! \return Bulk density ready to be output to file
83 : : static tk::GetVarFn::result_type
84 : 236 : bulkDensityOutVar( const tk::Fields& U, std::size_t rdof )
85 : : {
86 : : using tk::operator+=;
87 : 236 : auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
88 : 236 : auto r = U.extract_comp( densityDofIdx(nmat,0,rdof,0) );
89 [ + + ]: 487 : for (std::size_t k=1; k<nmat; ++k)
90 [ + - ][ + - ]: 502 : r += U.extract_comp( densityDofIdx(nmat,k,rdof,0) );
[ - - ]
91 : 236 : return r;
92 : : }
93 : :
94 : : //! Compute bulk pressure for output to file
95 : : //! \note Must follow the signature in tk::GetVarFn
96 : : //! \param[in] U Numerical solution
97 : : //! \param[in] rdof Number of reconstructed solution DOFs
98 : : //! \return Bulk pressure ready to be output to file
99 : : static tk::GetVarFn::result_type
100 : 236 : bulkPressureOutVar( const tk::Fields& U, std::size_t rdof )
101 : : {
102 : : using tk::operator+=;
103 : 236 : auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
104 : 236 : auto p = U.extract_comp( pressureDofIdx(nmat,0,rdof,0) );
105 [ + + ]: 487 : for (std::size_t k=1; k<nmat; ++k)
106 [ + - ][ + - ]: 502 : p += U.extract_comp( pressureDofIdx(nmat,k,rdof,0) );
[ - - ]
107 : 236 : return p;
108 : : }
109 : :
110 : : //! Compute bulk specific total energy (energy per unit mass) for output to file
111 : : //! \note Must follow the signature in tk::GetVarFn
112 : : //! \param[in] U Numerical solution
113 : : //! \param[in] rdof Number of reconstructed solution DOFs
114 : : //! \return Bulk specific total energy ready to be output to file
115 : : static tk::GetVarFn::result_type
116 : 179 : bulkSpecificTotalEnergyOutVar( const tk::Fields& U, std::size_t rdof )
117 : : {
118 : : using tk::operator+=;
119 : 179 : auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
120 : 179 : auto e = U.extract_comp( energyDofIdx(nmat,0,rdof,0) );
121 [ + + ]: 373 : for (std::size_t k=1; k<nmat; ++k)
122 [ + - ][ + - ]: 388 : e += U.extract_comp( energyDofIdx(nmat,k,rdof,0) );
[ - - ]
123 : 179 : return e;
124 : : }
125 : :
126 : : //! Compute velocity component for output to file
127 : : //! \note Must follow the signature in tk::GetVarFn
128 : : //! \tparam dir Physical direction, encoded as 0:x, 1:y, 2:z
129 : : //! \param[in] U Numerical solution
130 : : //! \param[in] rdof Number of reconstructed solution DOFs
131 : : //! \return Velocity component ready to be output to file
132 : : template< tk::ncomp_t dir >
133 : : tk::GetVarFn::result_type
134 : 594 : velocityOutVar( const tk::Fields& U, std::size_t rdof )
135 : : {
136 : 594 : auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
137 : 594 : return U.extract_comp( velocityDofIdx(nmat,dir,rdof,0) );
138 : : }
139 : :
140 : : //! Compute material indicator function for output to file
141 : : //! \note Must follow the signature in tk::GetVarFn
142 : : //! \param[in] U Numerical solution
143 : : //! \param[in] rdof Number of reconstructed solution DOFs
144 : : //! \return Material indicator function ready to be output to file
145 : : static tk::GetVarFn::result_type
146 : 2 : matIndicatorOutVar( const tk::Fields& U, std::size_t rdof )
147 : : {
148 : 2 : auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
149 : 2 : std::vector< tk::real > m(U.nunk(), 0.0);
150 [ + + ]: 3034 : for (std::size_t i=0; i<U.nunk(); ++i) {
151 [ + + ]: 9096 : for (std::size_t k=0; k<nmat; ++k)
152 : 6064 : m[i] += U(i, volfracDofIdx(nmat,k,rdof,0)) *
153 : 6064 : static_cast< tk::real >(k+1);
154 : : }
155 : 2 : return m;
156 : : }
157 : :
158 : : //! Compute Cauchy stress component for output to file
159 : : //! \note Must follow the signature in tk::GetVarFn
160 : : //! \tparam idir Physical direction, encoded as 0:x, 1:y, 2:z
161 : : //! \tparam jdir Physical direction, encoded as 0:x, 1:y, 2:z
162 : : //! \param[in] U Numerical solution
163 : : //! \param[in] rdof Number of reconstructed solution DOFs
164 : : //! \return Cauchy stress component ready to be output to file
165 : : template< tk::ncomp_t idir, tk::ncomp_t jdir >
166 : : tk::GetVarFn::result_type
167 : 0 : stressOutVar( const tk::Fields& U, std::size_t rdof )
168 : : {
169 : : const auto& solidx = g_inputdeck.get< tag::matidxmap, tag::solidx >();
170 : 0 : auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
171 : :
172 : 0 : std::vector< tk::real > cs(U.nunk(), 0.0);
173 [ - - ]: 0 : for (std::size_t e=0; e<cs.size(); ++e) {
174 [ - - ]: 0 : for (std::size_t k=0; k<nmat; ++k) {
175 : : tk::real asigij(0.0);
176 : :
177 [ - - ]: 0 : if (solidx[k] > 0) asigij =
178 : : U(e, stressDofIdx(nmat,solidx[k],stressCmp[idir][jdir],rdof,0));
179 : :
180 : : if (idir == jdir)
181 : 0 : asigij -= U(e, pressureDofIdx(nmat,k,rdof,0));
182 : :
183 : 0 : cs[e] += asigij;
184 : : }
185 : : }
186 : :
187 : 0 : return cs;
188 : : }
189 : :
190 : : //! Compute inverse deformation gradient tensor component for output to file
191 : : //! \note Must follow the signature in tk::GetVarFn
192 : : //! \tparam idir Physical direction, encoded as 0:x, 1:y, 2:z
193 : : //! \tparam jdir Physical direction, encoded as 0:x, 1:y, 2:z
194 : : //! \param[in] U Numerical solution
195 : : //! \param[in] rdof Number of reconstructed solution DOFs
196 : : //! \return Inverse deformation gradient tensor component to be output to file
197 : : template< tk::ncomp_t idir, tk::ncomp_t jdir >
198 : : tk::GetVarFn::result_type
199 : 0 : defGradOutVar( const tk::Fields& U, std::size_t rdof )
200 : : {
201 : : const auto& solidx = g_inputdeck.get< tag::matidxmap, tag::solidx >();
202 : 0 : auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
203 : :
204 : 0 : std::vector< tk::real > g(U.nunk(), 0.0);
205 [ - - ]: 0 : for (std::size_t e=0; e<g.size(); ++e) {
206 [ - - ]: 0 : for (std::size_t k=0; k<nmat; ++k) {
207 : : tk::real agij(0.0);
208 : :
209 [ - - ]: 0 : if (solidx[k] > 0) agij = U(e, volfracDofIdx(nmat,k,rdof,0)) *
210 : : U(e, deformDofIdx(nmat,solidx[k],idir,jdir,rdof,0));
211 : :
212 : 0 : g[e] += agij;
213 : : }
214 : : }
215 : :
216 : 0 : return g;
217 : : }
218 : :
219 : : } // multimat::
220 : :
221 : : #if defined(__clang__)
222 : : #pragma clang diagnostic pop
223 : : #endif
224 : :
225 : : //@}
226 : :
227 : : } //inciter::
228 : :
229 : : #endif // FieldOutput_h
|