diff --git a/unit_tests/kernels/UnitTestKernelUtils.C b/unit_tests/kernels/UnitTestKernelUtils.C index 74eba0b04..0d88be632 100644 --- a/unit_tests/kernels/UnitTestKernelUtils.C +++ b/unit_tests/kernels/UnitTestKernelUtils.C @@ -170,6 +170,44 @@ struct TrigFieldFunction std::sin(a * pi * z))/(1.0 - gamintnot); } + void dwalldistdx(const double* coords, double* qField) const + { + const double x = coords[0]; + const double y = coords[1]; + const double z = coords[2]; + + const double a_pi = a * pi; + const double cosx = std::cos(a_pi * x); + const double sinx = std::sin(a_pi * x); + const double cosy = std::cos(a_pi * y); + const double siny = std::sin(a_pi * y); + const double cosz = std::cos(a_pi * z); + const double sinz = std::sin(a_pi * z); + + qField[0] = -dwalldistdxnot * a_pi * sinx * siny * cosz; + qField[1] = dwalldistdxnot * a_pi * cosx * cosy * cosz; + qField[2] = -dwalldistdxnot * a_pi * cosx * siny * sinz; + } + + void dnDotVdx(const double* coords, double* qField) const + { + const double x = coords[0]; + const double y = coords[1]; + const double z = coords[2]; + + const double a_pi = a * pi; + const double cosx = std::cos(a_pi * x); + const double sinx = std::sin(a_pi * x); + const double cosy = std::cos(a_pi * y); + const double siny = std::sin(a_pi * y); + const double cosz = std::cos(a_pi * z); + const double sinz = std::sin(a_pi * z); + + qField[0] = -dnDotVdxnot * a_pi * sinx * siny * cosz; + qField[1] = dnDotVdxnot * a_pi * cosx * cosy * cosz; + qField[2] = -dnDotVdxnot * a_pi * cosx * siny * sinz; + } + void tdr(const double* coords, double* qField) const { double x = coords[0]; @@ -305,6 +343,12 @@ private: /// Factor for gamint field static constexpr double gamintnot{0.02}; + /// Factor for dwalldistdx field + static constexpr double dwalldistdxnot{1.0}; + + /// Factor for dnDotVdx field + static constexpr double dnDotVdxnot{1.0}; + /// Factor for tdr field static constexpr double tdrnot{1.0}; @@ -360,6 +404,10 @@ init_trigonometric_field( funcPtr = &TrigFieldFunction::sdr; else if (fieldName == "gamma_transition") // added: transition funcPtr = &TrigFieldFunction::gamint; + else if (fieldName == "dwalldistdx") // added: transition + funcPtr = &TrigFieldFunction::dwalldistdx; + else if (fieldName == "dnDotVdx") // added: transition + funcPtr = &TrigFieldFunction::dnDotVdx; else if (fieldName == "total_dissipation_rate") funcPtr = &TrigFieldFunction::tdr; else if (fieldName == "dwdx") @@ -524,6 +572,24 @@ gamint_test_function( // added: transition init_trigonometric_field(bulk, coordinates, gamint); } +void +dwalldistdx_test_function( + const stk::mesh::BulkData& bulk, + const sierra::nalu::VectorFieldType& coordinates, + sierra::nalu::VectorFieldType& dwalldistdx) +{ + init_trigonometric_field(bulk, coordinates, dwalldistdx); +} + +void +dnDotVdx_test_function( + const stk::mesh::BulkData& bulk, + const sierra::nalu::VectorFieldType& coordinates, + sierra::nalu::VectorFieldType& dnDotVdx) +{ + init_trigonometric_field(bulk, coordinates, dnDotVdx); +} + void tdr_test_function( const stk::mesh::BulkData& bulk, diff --git a/unit_tests/kernels/UnitTestKernelUtils.h b/unit_tests/kernels/UnitTestKernelUtils.h index 350f9445b..7fedec783 100644 --- a/unit_tests/kernels/UnitTestKernelUtils.h +++ b/unit_tests/kernels/UnitTestKernelUtils.h @@ -88,6 +88,16 @@ void gamint_test_function( //added const sierra::nalu::VectorFieldType& coordinates, sierra::nalu::ScalarFieldType& gamint); +void dwalldistdx_test_function( + const stk::mesh::BulkData& bulk, + const sierra::nalu::VectorFieldType& coordinates, + sierra::nalu::VectorFieldType& dwalldistdx); + +void dnDotVdx_test_function( + const stk::mesh::BulkData& bulk, + const sierra::nalu::VectorFieldType& coordinates, + sierra::nalu::VectorFieldType& dnDotVdx); + void tdr_test_function( const stk::mesh::BulkData& bulk, const sierra::nalu::VectorFieldType& coordinates, @@ -850,6 +860,80 @@ class SSTKernelHex8Mesh : public LowMachKernelHex8Mesh sierra::nalu::ScalarFieldType* pecletFactor_{nullptr}; }; +/** Test Fixture for the BLT Gamma Kernels + * + */ +class BLTGammaM2015KernelHex8Mesh : public LowMachKernelHex8Mesh +{ +public: + BLTGammaM2015KernelHex8Mesh() + : LowMachKernelHex8Mesh(), + tke_(&meta_->declare_field( + stk::topology::NODE_RANK, "turbulent_ke")), + sdr_(&meta_->declare_field( + stk::topology::NODE_RANK, "specific_dissipation_rate")), + visc_( + &meta_->declare_field(stk::topology::NODE_RANK, "viscosity")), + tvisc_(&meta_->declare_field( + stk::topology::NODE_RANK, "turbulent_viscosity")), + gamint_(&meta_->declare_field( + stk::topology::NODE_RANK, "gamma_transition")), //added + minDistance_(&meta_->declare_field( + stk::topology::NODE_RANK, "minimum_distance_to_wall")), + dudx_(&meta_->declare_field(stk::topology::NODE_RANK, "dudx")), + dwalldistdx_(&meta_->declare_field(stk::topology::NODE_RANK, "dwalldistdx")), + dnDotVdx_(&meta_->declare_field(stk::topology::NODE_RANK, "dnDotVdx")) + { + stk::mesh::put_field_on_mesh(*tke_, meta_->universal_part(), nullptr); + stk::mesh::put_field_on_mesh(*sdr_, meta_->universal_part(), nullptr); + stk::mesh::put_field_on_mesh(*visc_, meta_->universal_part(), nullptr); + stk::mesh::put_field_on_mesh(*tvisc_, meta_->universal_part(), nullptr); + stk::mesh::put_field_on_mesh(*gamint_, meta_->universal_part(), nullptr); //added + stk::mesh::put_field_on_mesh( + *minDistance_, meta_->universal_part(), nullptr); + stk::mesh::put_field_on_mesh( + *dudx_, meta_->universal_part(), spatialDim_ * spatialDim_, nullptr); + stk::io::set_field_output_type( + *dudx_, stk::io::FieldOutputType::FULL_TENSOR_36); + stk::mesh::put_field_on_mesh( + *dwalldistdx_, meta_->universal_part(), spatialDim_, nullptr); + stk::io::set_field_output_type(*dwalldistdx_, stk::io::FieldOutputType::VECTOR_3D); + stk::mesh::put_field_on_mesh( + *dnDotVdx_, meta_->universal_part(), spatialDim_, nullptr); + stk::io::set_field_output_type(*dnDotVdx_, stk::io::FieldOutputType::VECTOR_3D); + } + virtual ~BLTGammaM2015KernelHex8Mesh() {} + + virtual void fill_mesh_and_init_fields( + const bool doPerturb = false, const bool generateSidesets = false) override + { + LowMachKernelHex8Mesh::fill_mesh_and_init_fields( + doPerturb, generateSidesets); + stk::mesh::field_fill(0.2, *visc_); + stk::mesh::field_fill(0.3, *tvisc_); + unit_test_kernel_utils::density_test_function( + *bulk_, *coordinates_, *density_); + unit_test_kernel_utils::tke_test_function(*bulk_, *coordinates_, *tke_); + unit_test_kernel_utils::sdr_test_function(*bulk_, *coordinates_, *sdr_); + unit_test_kernel_utils::gamint_test_function(*bulk_, *coordinates_, *gamint_); // added + unit_test_kernel_utils::minimum_distance_to_wall_test_function( + *bulk_, *coordinates_, *minDistance_); + unit_test_kernel_utils::dudx_test_function(*bulk_, *coordinates_, *dudx_); + stk::mesh::field_fill(0.0, *dwalldistdx_); + stk::mesh::field_fill(0.0, *dnDotVdx_); + } + + sierra::nalu::ScalarFieldType* tke_{nullptr}; + sierra::nalu::ScalarFieldType* sdr_{nullptr}; + sierra::nalu::ScalarFieldType* visc_{nullptr}; + sierra::nalu::ScalarFieldType* tvisc_{nullptr}; + sierra::nalu::ScalarFieldType* gamint_{nullptr}; + sierra::nalu::ScalarFieldType* minDistance_{nullptr}; + sierra::nalu::TensorFieldType* dudx_{nullptr}; + sierra::nalu::VectorFieldType* dwalldistdx_{nullptr}; + sierra::nalu::VectorFieldType* dnDotVdx_{nullptr}; +}; + /** Test Fixture for the KE Kernels * */ diff --git a/unit_tests/node_kernels/CMakeLists.txt b/unit_tests/node_kernels/CMakeLists.txt index fc7537960..41f9f5f77 100644 --- a/unit_tests/node_kernels/CMakeLists.txt +++ b/unit_tests/node_kernels/CMakeLists.txt @@ -19,4 +19,5 @@ target_sources(${utest_ex_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/UnitTestKONodeKernel.C ${CMAKE_CURRENT_SOURCE_DIR}/UnitTestKsgsNodeKernel.C ${CMAKE_CURRENT_SOURCE_DIR}/UnitTestWallDistNode.C + ${CMAKE_CURRENT_SOURCE_DIR}/UnitTestBLTGammaM2015NodeKernel.C ) diff --git a/unit_tests/node_kernels/UnitTestBLTGammaM2015NodeKernel.C b/unit_tests/node_kernels/UnitTestBLTGammaM2015NodeKernel.C new file mode 100644 index 000000000..cb4d5fa96 --- /dev/null +++ b/unit_tests/node_kernels/UnitTestBLTGammaM2015NodeKernel.C @@ -0,0 +1,150 @@ +// Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS), National Renewable Energy Laboratory, University of Texas Austin, +// Northwest Research Associates. Under the terms of Contract DE-NA0003525 +// with NTESS, the U.S. Government retains certain rights in this software. +// +// This software is released under the BSD 3-clause license. See LICENSE file +// for more details. +// + +#include "kernels/UnitTestKernelUtils.h" +#include "UnitTestUtils.h" +#include "UnitTestHelperObjects.h" + +#include "node_kernels/BLTGammaM2015NodeKernel.h" + +namespace { +namespace hex8_golds { +namespace blt_gamma { +static constexpr double rhs[8] = { + 0, + 0, + 0, + 0.12823826807242, + 0, + 0, + -0.043287170452808, + 0.43035793150449, +}; + +static constexpr double lhs[8][8] = { + { + 1.5336779974765e-19, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + }, + { + 0, + 4.6113433001562e-05, + 0, + 0, + 0, + 0, + 0, + 0, + }, + { + 0, + 0, + 6.4413186123242e-11, + 0, + 0, + 0, + 0, + 0, + }, + { + 0, + 0, + 0, + 0.13131235277404, + 0, + 0, + 0, + 0, + }, + { + 0, + 0, + 0, + 0, + 7.8452858117332e-05, + 0, + 0, + 0, + }, + { + 0, + 0, + 0, + 0, + 0, + 0.001645541661088, + 0, + 0, + }, + { + 0, + 0, + 0, + 0, + 0, + 0, + 0.12774384574574, + 0, + }, + { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.7648927575084, + }, +}; +} // namespace blt_gamma + +} // namespace hex8_golds +} // namespace + +TEST_F(BLTGammaM2015KernelHex8Mesh, NGP_blt_gamma_node) +{ + // Only execute for 1 processor runs + if (bulk_->parallel_size() > 1) + return; + + fill_mesh_and_init_fields(); + + // Setup solution options + solnOpts_.meshMotion_ = false; + solnOpts_.externalMeshDeformation_ = false; + solnOpts_.initialize_turbulence_constants(); + + unit_test_utils::NodeHelperObjects helperObjs( + bulk_, stk::topology::HEX_8, 1, partVec_[0]); + + helperObjs.nodeAlg->add_kernel(*meta_); + + helperObjs.execute(); + + Kokkos::deep_copy( + helperObjs.linsys->hostNumSumIntoCalls_, + helperObjs.linsys->numSumIntoCalls_); + EXPECT_EQ(helperObjs.linsys->lhs_.extent(0), 8u); + EXPECT_EQ(helperObjs.linsys->lhs_.extent(1), 8u); + EXPECT_EQ(helperObjs.linsys->rhs_.extent(0), 8u); + EXPECT_EQ(helperObjs.linsys->hostNumSumIntoCalls_(0), 8u); + + namespace hex8_golds = hex8_golds::blt_gamma; + unit_test_kernel_utils::expect_all_near( + helperObjs.linsys->rhs_, hex8_golds::rhs, 1.0e-12); + unit_test_kernel_utils::expect_all_near<8>( + helperObjs.linsys->lhs_, hex8_golds::lhs, 1.0e-12); +}