Skip to content

Commit 292b535

Browse files
author
jiajiaecho
committed
recommit with the right username
1 parent 6be0f0d commit 292b535

12 files changed

Lines changed: 391 additions & 28 deletions

File tree

src/PDE/CompFlow/DGCompFlow.hpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ class CompFlow {
438438
{
439439
const auto ndof = g_inputdeck.get< tag::ndof >();
440440
const auto rdof = g_inputdeck.get< tag::rdof >();
441+
bool viscous=false;
441442

442443
const auto& solidx = g_inputdeck.get< tag::matidxmap, tag::solidx >();
443444

@@ -468,8 +469,8 @@ class CompFlow {
468469

469470
// compute internal surface flux integrals
470471
tk::surfInt( pref, 1, m_mat_blk, t, ndof, rdof, inpoel, solidx,
471-
coord, fd, geoFace, geoElem, m_riemann, velfn, U, P, ndofel,
472-
dt, R, riemannDeriv );
472+
coord, fd, geoFace, geoElem, m_riemann, visc_flux,
473+
velfn, U, P, ndofel, dt, R, riemannDeriv, viscous);
473474

474475
// compute optional source term
475476
tk::srcInt( m_mat_blk, t, ndof, fd.Esuel().size()/4,
@@ -478,14 +479,14 @@ class CompFlow {
478479
if(ndof > 1)
479480
// compute volume integrals
480481
tk::volInt( 1, t, m_mat_blk, ndof, rdof,
481-
fd.Esuel().size()/4, inpoel, coord, geoElem, flux, velfn,
482-
U, P, ndofel, R );
482+
fd.Esuel().size()/4, inpoel, coord, geoElem, flux,
483+
visc_flux, velfn, U, P, ndofel, R, viscous );
483484

484485
// compute boundary surface flux integrals
485486
for (const auto& b : m_bc)
486487
tk::bndSurfInt( pref, 1, m_mat_blk, ndof, rdof, std::get<0>(b),
487-
fd, geoFace, geoElem, inpoel, coord, t, m_riemann,
488-
velfn, std::get<1>(b), U, P, ndofel, R, riemannDeriv );
488+
fd, geoFace, geoElem, inpoel, coord, t, m_riemann, visc_flux,
489+
velfn, std::get<1>(b), U, P, ndofel, R, riemannDeriv, viscous );
489490

490491
// compute external (energy) sources
491492
const auto& ic = g_inputdeck.get< tag::ic >();
@@ -1024,6 +1025,17 @@ class CompFlow {
10241025
{
10251026
return {{ ul, Problem::initialize( ncomp, mat_blk, x, y, z, t ) }};
10261027
}
1028+
1029+
static tk::FluxFn::result_type
1030+
visc_flux( ncomp_t ncomp,
1031+
const std::vector< EOS >& mat_blk,
1032+
const std::vector< tk::real >& ugp,
1033+
const std::vector< std::array< tk::real, 3 > > & grad_all )
1034+
{
1035+
std::vector< std::array< tk::real, 3 > > fl( ugp.size(),
1036+
std::array<tk::real, 3 >{{0, 0, 0}});
1037+
return fl;
1038+
}
10271039

10281040
//! \brief Boundary state function providing the left and right state of a
10291041
//! face at symmetry boundaries

src/PDE/Integrate/Basis.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,3 +1052,57 @@ tk::massMatrixTaylorRefEl(std::size_t dof)
10521052

10531053
return Mt;
10541054
}
1055+
1056+
std::vector< std::array< tk::real, 3 > >
1057+
tk::eval_state_gradient ( ncomp_t ncomp,
1058+
const std::size_t ndof,
1059+
const std::size_t ndof_el,
1060+
const std::size_t e,
1061+
const Fields& U,
1062+
const std::array< std::vector<tk::real>, 3 >& dBdx )
1063+
// *****************************************************************************
1064+
// Compute the state variables for the tetrahedron element
1065+
//! \param[in] ncomp Number of scalar components in this PDE system
1066+
//! \param[in] ndof Maximum number of degrees of freedom
1067+
//! \param[in] ndof_el Number of degrees of freedom for the local element
1068+
//! \param[in] e Index for the tetrahedron element
1069+
//! \param[in] U Solution vector at recent time step
1070+
//! \param[in] B Vector of basis functions
1071+
//! \return Vector of state variable for tetrahedron element
1072+
// *****************************************************************************
1073+
{
1074+
// This is commented for now because that when p0/p1 adaptive with limiter
1075+
// applied, the size of basis will be 10. However, ndof_el will be 4 which
1076+
// leads to a size mismatch in limiter function.
1077+
//Assert( B.size() == ndof_el, "Size mismatch" );
1078+
1079+
if (U.empty()) return {};
1080+
1081+
1082+
std::vector< std::array< tk::real, 3 > > state_grad(ncomp,
1083+
std::array< real, 3 >{{0, 0, 0}});
1084+
1085+
1086+
for (std::size_t i=0; i<3; ++i) {
1087+
for (ncomp_t c=0; c<ncomp; ++c)
1088+
{
1089+
auto mark = c*ndof;
1090+
state_grad[c][i] += U( e, mark+1 ) * dBdx[i][1]
1091+
+ U( e, mark+2 ) * dBdx[i][2]
1092+
+ U( e, mark+3 ) * dBdx[i][3];
1093+
1094+
if( ndof_el > 4 )
1095+
{
1096+
state_grad[c][i] += U( e, mark+4 ) * dBdx[i][4]
1097+
+ U( e, mark+5 ) * dBdx[i][5]
1098+
+ U( e, mark+6 ) * dBdx[i][6]
1099+
+ U( e, mark+4 ) * dBdx[i][7]
1100+
+ U( e, mark+5 ) * dBdx[i][8]
1101+
+ U( e, mark+6 ) * dBdx[i][9];
1102+
}
1103+
}
1104+
}
1105+
1106+
return state_grad;
1107+
1108+
}

src/PDE/Integrate/Basis.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ invMassMatTaylorRefEl( std::size_t dof );
133133
std::vector< std::vector< tk::real > >
134134
massMatrixTaylorRefEl(std::size_t dof);
135135

136+
std::vector< std::array< tk::real, 3 > >
137+
eval_state_gradient( ncomp_t ncomp,
138+
const std::size_t ndof,
139+
const std::size_t ndof_el,
140+
const std::size_t e,
141+
const Fields& U,
142+
const std::array< std::vector<tk::real>, 3 >& dBdx );
143+
136144
} // tk::
137145

138146
#endif // Basis_h

src/PDE/Integrate/Boundary.cpp

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ bndSurfInt( const bool pref,
4444
const UnsMesh::Coords& coord,
4545
real t,
4646
const RiemannFluxFn& flux,
47+
const FluxFn& visc_flux,
4748
const VelFn& vel,
4849
const StateFn& state,
4950
const Fields& U,
5051
const Fields& P,
5152
const std::vector< std::size_t >& ndofel,
5253
Fields& R,
5354
std::vector< std::vector< tk::real > >& riemannDeriv,
54-
int intsharp )
55+
bool viscous,
56+
int intsharp)
5557
// *****************************************************************************
5658
//! Compute boundary surface flux integrals for a given boundary type for DG
5759
//! \details This function computes contributions from surface integrals along
@@ -141,6 +143,8 @@ bndSurfInt( const bool pref,
141143

142144
std::array< real, 3 >
143145
fn{{ geoFace(f,1), geoFace(f,2), geoFace(f,3) }};
146+
147+
144148

145149
// Gaussian quadrature
146150
for (std::size_t igp=0; igp<ng; ++igp)
@@ -189,6 +193,65 @@ bndSurfInt( const bool pref,
189193

190194
// Compute the numerical flux
191195
auto fl = flux(mat_blk, fn, var, vel(ncomp, gp[0], gp[1], gp[2], t));
196+
if (viscous){
197+
std::vector< std::array< tk::real, 3 > > grad_all(2*ncomp,
198+
std::array< real, 3 >{{0, 0, 0}});
199+
std::vector<real> fluxl(5, 0);
200+
std::vector<real> fluxr(5, 0);
201+
202+
auto jacInv_l =
203+
tk::inverseJacobian( coordel_l[0], coordel_l[1], coordel_l[2], coordel_l[3] );
204+
auto dBdx_l = tk::eval_dBdx_p1(dof_el, jacInv_l );
205+
206+
if (dof_el > 4){
207+
std::array< std::vector< real >, 3 > coordgp_3;
208+
coordgp_3[0].resize( ng );
209+
coordgp_3[1].resize( ng );
210+
coordgp_3[2].resize( ng );
211+
for(int i=0; i<3; i++)
212+
coordgp_3[i][igp]=ref_gp_l[i];
213+
eval_dBdx_p2( igp, coordgp_3, jacInv_l, dBdx_l );
214+
}
215+
216+
auto state_U_grad_l = eval_state_gradient (ncomp, ndof, dof_el,
217+
el, U, dBdx_l );
218+
auto state_P_grad_l = eval_state_gradient (nprim, ndof, dof_el,
219+
el, P, dBdx_l );
220+
for (ncomp_t c=0; c<ncomp; ++c){
221+
grad_all.push_back(state_U_grad_l[c]);
222+
}
223+
224+
for (ncomp_t c=0; c<ncomp; ++c){
225+
grad_all.push_back(state_P_grad_l[c]);
226+
}
227+
auto fl_vis_l = visc_flux(ncomp, mat_blk, var[0], grad_all);
228+
229+
auto fl_vis_r = visc_flux(ncomp, mat_blk, var[1], grad_all) ;
230+
231+
232+
233+
// Flux functions
234+
for (std::size_t i=0; i<3; ++i)
235+
{
236+
fluxl[1] = fluxl[1] + fl_vis_l[1][i]*fn[i];
237+
fluxl[2] = fluxl[2] + fl_vis_l[2][i]*fn[i];
238+
fluxl[3] = fluxl[3] + fl_vis_l[3][i]*fn[i];
239+
fluxl[4] = fluxl[4] + fl_vis_l[4][i]*fn[i];
240+
fluxr[1] = fluxr[1] + fl_vis_r[1][i]*fn[i];
241+
fluxr[2] = fluxr[2] + fl_vis_r[2][i]*fn[i];
242+
fluxr[3] = fluxr[3] + fl_vis_r[3][i]*fn[i];
243+
fluxr[4] = fluxr[4] + fl_vis_r[4][i]*fn[i];
244+
}
245+
246+
247+
248+
// Numerical flux function
249+
for(std::size_t c=1; c<5; ++c)
250+
fl[c] = fl[c]+0.5 * (fluxl[c] + fluxr[c]);
251+
252+
253+
254+
}
192255

193256
// Code below commented until details about the form of these terms in
194257
// the \alpha_k g_k equations are sorted out.

src/PDE/Integrate/Boundary.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ bndSurfInt( const bool pref,
4242
const UnsMesh::Coords& coord,
4343
real t,
4444
const RiemannFluxFn& flux,
45+
const FluxFn& visc_flux,
4546
const VelFn& vel,
4647
const StateFn& state,
4748
const Fields& U,
4849
const Fields& P,
4950
const std::vector< std::size_t >& ndofel,
5051
Fields& R,
5152
std::vector< std::vector< tk::real > >& riemannDeriv,
52-
int intcompr=0 );
53+
bool viscous,
54+
int intcompr=0);
5355

5456
//! Update the rhs by adding the boundary surface integration term
5557
void

src/PDE/Integrate/Surface.cpp

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,17 @@ surfInt( const bool pref,
4444
const Fields& geoFace,
4545
const Fields& geoElem,
4646
const RiemannFluxFn& flux,
47+
const FluxFn& visc_flux,
4748
const VelFn& vel,
4849
const Fields& U,
4950
const Fields& P,
5051
const std::vector< std::size_t >& ndofel,
5152
const tk::real /*dt*/,
5253
Fields& R,
5354
std::vector< std::vector< tk::real > >& riemannDeriv,
54-
int intsharp )
55+
bool viscous,
56+
int intsharp
57+
)
5558
// *****************************************************************************
5659
// Compute internal surface flux integrals
5760
//! \param[in] pref Indicator for p-adaptive algorithm
@@ -226,6 +229,89 @@ surfInt( const bool pref,
226229

227230
// compute flux
228231
auto fl = flux( mat_blk, fn, state, v );
232+
233+
if (viscous){
234+
std::vector< tk::real> fluxl(5, 0);
235+
std::vector< tk::real> fluxr(5, 0);
236+
//std::array< std::vector<real>, 3 > dBdx_l, dBdx_r;
237+
std::vector< std::array< tk::real, 3 > > grad_all(2*ncomp,
238+
std::array< real, 3 >{{0, 0, 0}});
239+
auto jacInv_l =
240+
tk::inverseJacobian( coordel_l[0], coordel_l[1], coordel_l[2], coordel_l[3] );
241+
auto dBdx_l = tk::eval_dBdx_p1(dof_el, jacInv_l );
242+
auto jacInv_r =
243+
tk::inverseJacobian( coordel_r[0], coordel_r[1], coordel_r[2], coordel_r[3] );
244+
auto dBdx_r = tk::eval_dBdx_p1(dof_er, jacInv_r );
245+
246+
if (dof_el > 4){
247+
std::array< std::vector< real >, 3 > coordgp_3;
248+
coordgp_3[0].resize( ng );
249+
coordgp_3[1].resize( ng );
250+
coordgp_3[2].resize( ng );
251+
for(int i=0; i<3; i++)
252+
coordgp_3[i][igp]=ref_gp_l[i];
253+
eval_dBdx_p2( igp, coordgp_3, jacInv_l, dBdx_l );
254+
}
255+
if (dof_er > 4){
256+
std::array< std::vector< real >, 3 > coordgp_3;
257+
coordgp_3[0].resize( ng );
258+
coordgp_3[1].resize( ng );
259+
coordgp_3[2].resize( ng );
260+
for(int i=0; i<3; i++)
261+
coordgp_3[i][igp]=ref_gp_r[i];
262+
eval_dBdx_p2( igp, coordgp_3, jacInv_r, dBdx_r );
263+
}
264+
265+
auto state_U_grad_l = eval_state_gradient (ncomp, ndof, dof_el,
266+
el, U, dBdx_l );
267+
auto state_P_grad_l = eval_state_gradient (nprim, ndof, dof_el,
268+
el, P, dBdx_l );
269+
for (ncomp_t c=0; c<ncomp; ++c){
270+
grad_all.push_back(state_U_grad_l[c]);
271+
}
272+
273+
for (ncomp_t c=0; c<ncomp; ++c){
274+
grad_all.push_back(state_P_grad_l[c]);
275+
}
276+
auto fl_vis_l = visc_flux(ncomp, mat_blk, state[0], grad_all);
277+
auto state_U_grad_r = eval_state_gradient (ncomp, ndof, dof_er,
278+
er, U, dBdx_r );
279+
auto state_P_grad_r = eval_state_gradient (ncomp, ndof, dof_er,
280+
er, P, dBdx_r );
281+
grad_all.clear();
282+
for (ncomp_t c=0; c<ncomp; ++c){
283+
grad_all.push_back(state_U_grad_r[c]);
284+
}
285+
286+
for (ncomp_t c=0; c<ncomp; ++c){
287+
grad_all.push_back(state_P_grad_r[c]);
288+
}
289+
auto fl_vis_r = visc_flux(ncomp, mat_blk, state[1], grad_all);
290+
291+
292+
293+
// Flux functions
294+
for (std::size_t i=0; i<3; ++i)
295+
{
296+
fluxl[1] = fluxl[1] + fl_vis_l[1][i]*fn[i];
297+
fluxl[2] = fluxl[2] + fl_vis_l[2][i]*fn[i];
298+
fluxl[3] = fluxl[3] + fl_vis_l[3][i]*fn[i];
299+
fluxl[4] = fluxl[4] + fl_vis_l[4][i]*fn[i];
300+
fluxr[1] = fluxr[1] + fl_vis_r[1][i]*fn[i];
301+
fluxr[2] = fluxr[2] + fl_vis_r[2][i]*fn[i];
302+
fluxr[3] = fluxr[3] + fl_vis_r[3][i]*fn[i];
303+
fluxr[4] = fluxr[4] + fl_vis_r[4][i]*fn[i];
304+
}
305+
306+
307+
308+
// Numerical flux function
309+
for(std::size_t c=1; c<5; ++c)
310+
fl[c] = fl[c]+0.5 * (fluxl[c] + fluxr[c]);
311+
312+
313+
314+
}
229315

230316
// Add the surface integration term to the rhs
231317
update_rhs_fa( ncomp, nmat, ndof, ndofel[el], ndofel[er], wt, fn,

src/PDE/Integrate/Surface.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ surfInt( const bool pref,
4242
const Fields& geoFace,
4343
const Fields& geoElem,
4444
const RiemannFluxFn& flux,
45+
const FluxFn& visc_flux,
4546
const VelFn& vel,
4647
const Fields& U,
4748
const Fields& P,
4849
const std::vector< std::size_t >& ndofel,
4950
const tk::real dt,
5051
Fields& R,
5152
std::vector< std::vector< tk::real > >& riemannDeriv,
52-
int intcompr=0 );
53+
bool viscous,
54+
int intcompr=0);
5355

5456
// Update the rhs by adding surface integration term
5557
void

0 commit comments

Comments
 (0)