From 044488b623342a1e14e27b6a2dcd69800d1f9f5e Mon Sep 17 00:00:00 2001 From: MengnanLi91 <118846840+MengnanLi91@users.noreply.github.com> Date: Tue, 1 Aug 2023 10:34:56 -0600 Subject: [PATCH 1/2] Fix face interpolation in FV with central difference, use _normal[0] #25076 --- .../SideAdvectiveFluxIntegral.C | 34 +++++++++++-------- .../side_advection_flux_integral_fv_out.csv | 4 +-- .../side_advection_flux_integral_fv.i | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/framework/src/postprocessors/SideAdvectiveFluxIntegral.C b/framework/src/postprocessors/SideAdvectiveFluxIntegral.C index 39cff2250f72..89abd76ccede 100644 --- a/framework/src/postprocessors/SideAdvectiveFluxIntegral.C +++ b/framework/src/postprocessors/SideAdvectiveFluxIntegral.C @@ -84,24 +84,30 @@ SideAdvectiveFluxIntegralTempl::computeFaceInfoIntegral(const FaceInfo * const auto state = determineState(); - const auto adv_quant_face = raw_value((*_adv_quant)( - Moose::FaceArg({fi, Moose::FV::LimiterType::Upwind, true, false, nullptr}), state)); - // Get face value for velocity - const auto vel_x = raw_value( - (_vel_x)(Moose::FaceArg({fi, Moose::FV::LimiterType::Upwind, true, false, nullptr}), state)); + const auto vel_x = raw_value(( + _vel_x)(Moose::FaceArg({fi, Moose::FV::LimiterType::CentralDifference, true, false, nullptr}), + state)); const auto vel_y = - _vel_y - ? raw_value((*_vel_y)( - Moose::FaceArg({fi, Moose::FV::LimiterType::Upwind, true, false, nullptr}), state)) - : 0; + _vel_y ? raw_value((*_vel_y)( + Moose::FaceArg( + {fi, Moose::FV::LimiterType::CentralDifference, true, false, nullptr}), + state)) + : 0; const auto vel_z = - _vel_z - ? raw_value((*_vel_z)( - Moose::FaceArg({fi, Moose::FV::LimiterType::Upwind, true, false, nullptr}), state)) - : 0; + _vel_z ? raw_value((*_vel_z)( + Moose::FaceArg( + {fi, Moose::FV::LimiterType::CentralDifference, true, false, nullptr}), + state)) + : 0; + + const bool elem_is_upwind = RealVectorValue(vel_x, vel_y, vel_z) * _normals[0] >= 0; + const auto adv_quant_face = raw_value((*_adv_quant)( + Moose::FaceArg( + {fi, Moose::FV::LimiterType::CentralDifference, elem_is_upwind, false, nullptr}), + state)); - return fi->normal() * adv_quant_face * RealVectorValue(vel_x, vel_y, vel_z); + return _normals[0] * adv_quant_face * RealVectorValue(vel_x, vel_y, vel_z); } template diff --git a/test/tests/postprocessors/side_advection_flux_integral/gold/side_advection_flux_integral_fv_out.csv b/test/tests/postprocessors/side_advection_flux_integral/gold/side_advection_flux_integral_fv_out.csv index 41e81f805c34..75cf33faeeba 100644 --- a/test/tests/postprocessors/side_advection_flux_integral/gold/side_advection_flux_integral_fv_out.csv +++ b/test/tests/postprocessors/side_advection_flux_integral/gold/side_advection_flux_integral_fv_out.csv @@ -1,4 +1,4 @@ time,flux_left_exact,flux_right 0,0,0 -0.01,0.029690344730663,0.00022003434004834 -0.02,0.058801645425301,0.00084521638158382 +0.01,-0.016310130018774,0.00011738468226592 +0.02,-0.033656421815896,0.00045782390748827 diff --git a/test/tests/postprocessors/side_advection_flux_integral/side_advection_flux_integral_fv.i b/test/tests/postprocessors/side_advection_flux_integral/side_advection_flux_integral_fv.i index c1b2ebb50d06..c6215a04c8cb 100644 --- a/test/tests/postprocessors/side_advection_flux_integral/side_advection_flux_integral_fv.i +++ b/test/tests/postprocessors/side_advection_flux_integral/side_advection_flux_integral_fv.i @@ -104,5 +104,5 @@ [] [Outputs] - csv = true + csv = true [] From a8cf298665d95bef774cf2ed9b4fee0f044111e2 Mon Sep 17 00:00:00 2001 From: MengnanLi91 <118846840+MengnanLi91@users.noreply.github.com> Date: Tue, 1 Aug 2023 16:44:56 -0600 Subject: [PATCH 2/2] Address review: use fi->normal() instead of _normal[0],remove raw_value --- .../SideAdvectiveFluxIntegral.C | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/framework/src/postprocessors/SideAdvectiveFluxIntegral.C b/framework/src/postprocessors/SideAdvectiveFluxIntegral.C index 89abd76ccede..2696b716008e 100644 --- a/framework/src/postprocessors/SideAdvectiveFluxIntegral.C +++ b/framework/src/postprocessors/SideAdvectiveFluxIntegral.C @@ -77,37 +77,38 @@ template Real SideAdvectiveFluxIntegralTempl::computeFaceInfoIntegral(const FaceInfo * const fi) { - using MetaPhysicL::raw_value; - mooseAssert(fi, "We should have a face info in " + name()); mooseAssert(_adv_quant, "We should have an advected quantity in " + name()); const auto state = determineState(); // Get face value for velocity - const auto vel_x = raw_value(( - _vel_x)(Moose::FaceArg({fi, Moose::FV::LimiterType::CentralDifference, true, false, nullptr}), - state)); + const auto vel_x = + (_vel_x)(Moose::FaceArg( + {fi, Moose::FV::LimiterType::CentralDifference, true, false, nullptr}), + state); const auto vel_y = - _vel_y ? raw_value((*_vel_y)( - Moose::FaceArg( - {fi, Moose::FV::LimiterType::CentralDifference, true, false, nullptr}), - state)) - : 0; + _vel_y + ? ((*_vel_y)(Moose::FaceArg( + {fi, Moose::FV::LimiterType::CentralDifference, true, false, nullptr}), + state)) + : 0; const auto vel_z = - _vel_z ? raw_value((*_vel_z)( - Moose::FaceArg( - {fi, Moose::FV::LimiterType::CentralDifference, true, false, nullptr}), - state)) - : 0; - - const bool elem_is_upwind = RealVectorValue(vel_x, vel_y, vel_z) * _normals[0] >= 0; - const auto adv_quant_face = raw_value((*_adv_quant)( + _vel_z + ? ((*_vel_z)(Moose::FaceArg( + {fi, Moose::FV::LimiterType::CentralDifference, true, false, nullptr}), + state)) + : 0; + + auto fi_normal = _current_elem == fi->elemPtr() ? fi->normal() : Point(-fi->normal()); + const bool elem_is_upwind = RealVectorValue(vel_x, vel_y, vel_z) * fi_normal >= 0; + + const auto adv_quant_face = (*_adv_quant)( Moose::FaceArg( {fi, Moose::FV::LimiterType::CentralDifference, elem_is_upwind, false, nullptr}), - state)); + state); - return _normals[0] * adv_quant_face * RealVectorValue(vel_x, vel_y, vel_z); + return fi_normal * adv_quant_face * RealVectorValue(vel_x, vel_y, vel_z); } template