├── Allwmake ├── CMakeLists.txt ├── Eqn ├── rhoEEqn.H ├── rhoEqn.H ├── rhoUEqn.H └── rhoYEqn.H ├── Figs ├── DDT.png ├── ODW.png ├── RDE.png └── Riemann.png ├── Make ├── files └── options ├── README.md ├── calculateR.H ├── centralCourantNo.H ├── createFields.H ├── createFieldsSave.H ├── dfCDSFoam.C ├── directionInterpolate.H ├── example └── oneD_reactiveShockTube │ ├── 0 │ ├── AR.gz │ ├── H2.gz │ ├── O2.gz │ ├── T.gz │ ├── U.gz │ ├── Ydefault.gz │ ├── maxp.gz │ └── p.gz │ ├── 0_orig │ ├── AR.gz │ ├── H2.gz │ ├── O2.gz │ ├── T.gz │ ├── U.gz │ ├── Ydefault.gz │ ├── maxp.gz │ └── p.gz │ ├── 190us-T.jpg │ ├── 190us-YH.jpg │ ├── 190us-u.png │ ├── H2_AR.yaml │ ├── case.foam │ ├── constant │ ├── CanteraTorchProperties │ ├── combustionProperties │ ├── polyMesh │ │ ├── boundary │ │ ├── faces.gz │ │ ├── neighbour.gz │ │ ├── owner.gz │ │ └── points.gz │ ├── thermophysicalProperties │ └── turbulenceProperties │ └── system │ ├── blockMeshDict │ ├── controlDict │ ├── decomposeParDict │ ├── fvSchemes │ ├── fvSolution │ ├── sample │ └── setFieldsDict ├── fluxSchemes ├── AUSMPlus │ ├── AUSMPlus.C │ └── AUSMPlus.H ├── AUSMPlusUp │ ├── AUSMPlusUp.C │ └── AUSMPlusUp.H ├── HLL │ ├── HLL.C │ └── HLL.H ├── HLLC │ ├── HLLC.C │ └── HLLC.H ├── HLLCP │ ├── HLLCP.C │ └── HLLCP.H ├── Kurganov │ ├── Kurganov.C │ └── Kurganov.H ├── Make │ ├── files │ └── options ├── RiemannConvectionScheme │ ├── RiemannConvectionScheme.C │ ├── RiemannConvectionScheme.H │ └── RiemannConvectionSchemes.C ├── Tadmor │ ├── Tadmor.C │ └── Tadmor.H ├── fluxScheme │ ├── fluxScheme.C │ ├── fluxScheme.H │ ├── fluxSchemeTmp.C │ └── newFluxScheme.C └── lnInclude │ ├── AUSMPlus.C │ ├── AUSMPlus.H │ ├── AUSMPlusUp.C │ ├── AUSMPlusUp.H │ ├── HLL.C │ ├── HLL.H │ ├── HLLC.C │ ├── HLLC.H │ ├── HLLCP.C │ ├── HLLCP.H │ ├── Kurganov.C │ ├── Kurganov.H │ ├── RiemannConvectionScheme.C │ ├── RiemannConvectionScheme.H │ ├── RiemannConvectionSchemes.C │ ├── Tadmor.C │ ├── Tadmor.H │ ├── fluxScheme.C │ ├── fluxScheme.H │ ├── fluxSchemeTmp.C │ └── newFluxScheme.C ├── preCal.H ├── setRDeltaT.H ├── setRootCase2.H └── updateFieldsSave.H /Allwmake: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd ${0%/*} || exit 1 # Run from this directory 3 | set -x 4 | 5 | #(wmake libso BCs && wmake) 6 | cd ./fluxSchemes 7 | wclean 8 | wmake 9 | cd .. 10 | wmake 11 | 12 | 13 | # ----------------------------------------------------------------- end-of-file 14 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(dfHighSpeedFoam LANGUAGES CXX) 3 | FIND_PACKAGE(MPI REQUIRED) 4 | 5 | # Check valid thirdParty 6 | if(DEFINED ENV{WM_PROJECT_DIR}) 7 | MESSAGE(STATUS "OpenFOAM: " $ENV{WM_PROJECT_DIR}) 8 | else() 9 | message(FATAL_ERROR "OpenFOAM is not sourced") 10 | endif(DEFINED ENV{WM_PROJECT_DIR}) 11 | 12 | if(DEFINED ENV{CANTERA_ROOT}) 13 | MESSAGE(STATUS "libcantera: " $ENV{CANTERA_ROOT}) 14 | SET(CANTERA_ROOT $ENV{CANTERA_ROOT}) 15 | else() 16 | message(FATAL_ERROR "libcantera directory is not specified") 17 | endif(DEFINED ENV{CANTERA_ROOT}) 18 | 19 | # define variables 20 | SET(OpenFOAM_LIB_DIR $ENV{FOAM_LIBBIN}) 21 | SET(OpenFOAM_SRC $ENV{FOAM_SRC}) 22 | 23 | SET(DF_ROOT $ENV{DF_ROOT}) 24 | SET(DF_SRC $ENV{DF_SRC}) 25 | SET(SRC_ORIG $ENV{SRC_ORIG}) 26 | 27 | # set compilation options 28 | SET(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=bfd -Xlinker --add-needed -Xlinker --no-as-needed") 29 | 30 | SET(CMAKE_C_COMPILER g++) 31 | SET(PATH_LIB_OPENMPI "openmpi-system") # Foundation version 32 | SET(EXE_COMPILE_OPTION "-std=c++14 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 33 | -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor 34 | -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 35 | -DNoRepository -ftemplate-depth-100 36 | -Wno-unused-variable -Wno-unused-but-set-variable -Wno-old-style-cast -DOMPI_SKIP_MPICXX 37 | -pthread -fPIC") 38 | add_definitions("${EXE_COMPILE_OPTION}") 39 | 40 | # add header files 41 | FUNCTION(R_SEARCH search_path return_list) 42 | FILE(GLOB_RECURSE new_list ${search_path}/*.H) 43 | SET(dir_list "") 44 | FOREACH(file_path ${new_list}) 45 | GET_FILENAME_COMPONENT(dir_path ${file_path} PATH) 46 | SET(dir_list ${dir_list} ${dir_path}) 47 | ENDFOREACH() 48 | LIST(REMOVE_DUPLICATES dir_list) 49 | SET(${return_list} ${dir_list} PARENT_SCOPE) 50 | ENDFUNCTION(R_SEARCH) 51 | 52 | R_SEARCH(${DF_SRC}/dfCombustionModels dfcombustion_inc) 53 | R_SEARCH(${DF_SRC}/dfCanteraMixture dfcantera_inc) 54 | R_SEARCH(${DF_SRC}/lagrangian/intermediate dflagrangianinter_inc) 55 | R_SEARCH(${DF_SRC}/lagrangian/spray dflagrangianspray_inc) 56 | R_SEARCH(${DF_SRC}/lagrangian/turbulence dflagrangianturb_inc) 57 | R_SEARCH(${DF_SRC}/dfChemistryModel dfchemistry_inc) 58 | R_SEARCH(${DF_SRC}/thermophysicalModels/thermophysicalProperties dfthermophysicalprop_inc) 59 | R_SEARCH(${DF_SRC}/thermophysicalModels/thermophysicalProperties dfthermophysicalprop_inc) 60 | R_SEARCH(${DF_SRC}/thermophysicalModels/basic dfthermophysicalbasic_inc) 61 | R_SEARCH(${DF_SRC}/thermophysicalModels/SLGThermo dfthermophysicalslg_inc) 62 | R_SEARCH(${DF_SRC}/TurbulenceModels dfturbulence_inc) 63 | R_SEARCH(${DF_SRC}/dynamicMesh dfnewdynamic_inc) 64 | R_SEARCH(${DF_SRC}/dynamicFvMesh dffvdynamic_inc) 65 | 66 | include_directories( 67 | ${OpenFOAM_SRC}/finiteVolume/lnInclude 68 | ${OpenFOAM_SRC}/OSspecific/POSIX/lnInclude 69 | ${OpenFOAM_SRC}/OpenFOAM/lnInclude 70 | $ENV{FOAM_APP}/solvers/compressible/rhoCentralFoam/BCs/lnInclude 71 | ${OpenFOAM_SRC}/finiteVolume/cfdTools 72 | ${OpenFOAM_SRC}/finiteVolume/lnInclude 73 | ${OpenFOAM_SRC}/transportModels/compressible/lnInclude 74 | ${OpenFOAM_SRC}/thermophysicalModels/basic/lnInclude 75 | ${OpenFOAM_SRC}/TurbulenceModels/turbulenceModels/lnInclude 76 | ${OpenFOAM_SRC}/TurbulenceModels/compressible/lnInclude 77 | ${OpenFOAM_SRC}/sampling/lnInclude 78 | ${OpenFOAM_SRC}/dynamicFvMesh/lnInclude 79 | ${OpenFOAM_SRC}/Pstream/mpi 80 | ${OpenFOAM_SRC}/meshTools/lnInclude 81 | ${dfcantera_inc} 82 | ${dfchemistry_inc} 83 | ${dfcombustion_inc} 84 | ${CANTERA_ROOT}/include 85 | ${MPI_INCLUDE_PATH} 86 | ${PROJECT_SOURCE_DIR} 87 | ) 88 | 89 | # add execution 90 | add_executable(${PROJECT_NAME} ${PROJECT_SOURCE_DIR}/dfHighSpeedFoam.C) 91 | 92 | target_link_libraries(${PROJECT_NAME} 93 | $ENV{FOAM_LIBBIN}/libfiniteVolume.so libmeshTools.so libcompressibleTransportModels.so 94 | libturbulenceModels.so libsampling.so libOpenFOAM.so libdynamicFvMesh.so libtopoChangerFvMesh.so 95 | ${CANTERA_ROOT}/lib/libcantera_shared.so.2 96 | ${DF_ROOT}/lib/libdfChemistryModel.so 97 | ${DF_ROOT}/lib/libdfCanteraMixture.so 98 | ${DF_ROOT}/lib/libdfFluidThermophysicalModels.so 99 | ${DF_ROOT}/lib/libdfCombustionModels.so 100 | $ENV{FOAM_LIBBIN}/openmpi-system/libPstream.so 101 | ${MPI_LIBRARIES} 102 | ) 103 | 104 | if(DEFINED ENV{PYTHON_INC_DIR}) 105 | add_definitions(-DUSE_PYTORCH) 106 | # https://pybind11.readthedocs.io/en/stable/advanced/embedding.html 107 | find_package(pybind11) 108 | target_link_libraries(${PROJECT_NAME} pybind11::embed) 109 | endif() 110 | 111 | # install 112 | set(CMAKE_INSTALL_PREFIX ${DF_ROOT}) 113 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 114 | -------------------------------------------------------------------------------- /Eqn/rhoEEqn.H: -------------------------------------------------------------------------------- 1 | /*surfaceScalarField sigmaDotU 2 | ( 3 | "sigmaDotU", 4 | ( 5 | fvc::interpolate(turbulence->muEff())*mesh.magSf()*fvc::snGrad(U) 6 | + (mesh.Sf() & fvc::interpolate(tauMC)) 7 | ) 8 | & (a_pos*U_pos + a_neg*U_neg) 9 | );*/ 10 | 11 | surfaceScalarField sigmaDotU 12 | ( 13 | "sigmaDotU", 14 | ( 15 | fvc::interpolate(turbulence->muEff())*mesh.magSf()*fvc::snGrad(U) 16 | + (mesh.Sf() & fvc::interpolate(tauMC)) 17 | ) 18 | & fluxSchemeFields->Uf() 19 | ); 20 | 21 | if((ddtSchemes == "RK2SSP") || (ddtSchemes == "RK3SSP")) 22 | { 23 | rhoE_rhs = -fvc::div(rhoEPhi)+fvc::div(sigmaDotU); 24 | 25 | rhoE = rkcoe1[nrk]*rhoE_save 26 | + rkcoe2[nrk]*rhoE 27 | + rkcoe3[nrk]*rhoE_rhs*runTime.deltaT(); 28 | } 29 | else 30 | { 31 | solve 32 | ( 33 | fvm::ddt(rhoE) 34 | + fvc::div(rhoEPhi) 35 | - fvc::div(sigmaDotU) 36 | ); 37 | } 38 | 39 | ea = rhoE/rho - 0.5*magSqr(U); 40 | ea.correctBoundaryConditions(); 41 | 42 | ha = ea + p/rho; 43 | chemistry->correctThermo(); // before this, we must update ha = e + p/rho 44 | 45 | rhoE.boundaryFieldRef() == rho.boundaryField()*(ea.boundaryField() + 0.5*magSqr(U.boundaryField())); 46 | 47 | if (!inviscid) 48 | { 49 | if((ddtSchemes == "RK2SSP") || (ddtSchemes == "RK3SSP")) 50 | { 51 | rhoE_rhs = 52 | ( 53 | turbName == "laminar" 54 | ? 55 | ( 56 | fvc::laplacian(turbulence->alphaEff()*thermo.gamma(), ea) 57 | - diffAlphaD 58 | + fvc::div(hDiffCorrFlux) 59 | ) 60 | : 61 | ( 62 | fvc::laplacian(turbulence->alphaEff()*thermo.gamma(), ea) 63 | ) 64 | ); 65 | 66 | 67 | rhoE += rkcoe3[nrk]*rhoE_rhs*runTime.deltaT(); 68 | 69 | ea = rhoE/rho - 0.5*magSqr(U); 70 | ea.correctBoundaryConditions(); 71 | 72 | ha = ea + p/rho; 73 | chemistry->correctThermo(); // before this, we must update ha = e + p/rho 74 | } 75 | else 76 | { 77 | fvScalarMatrix eEqn 78 | ( 79 | fvm::ddt(rho, ea) - fvc::ddt(rho, ea) 80 | == 81 | ( 82 | turbName == "laminar" 83 | ? 84 | ( 85 | // alpha in deepflame is considered to calculate h by default (kappa/Cp), so multiply gamma to correct alpha 86 | fvm::laplacian(turbulence->alphaEff()*thermo.gamma(), ea) 87 | - diffAlphaD 88 | + fvc::div(hDiffCorrFlux) 89 | ) 90 | : 91 | ( 92 | fvm::laplacian(turbulence->alphaEff()*thermo.gamma(), ea) 93 | ) 94 | ) 95 | ); 96 | 97 | eEqn.solve("ea"); 98 | 99 | ha = ea + p/rho; 100 | chemistry->correctThermo(); 101 | rhoE = rho*(ea + 0.5*magSqr(U)); 102 | } 103 | 104 | } 105 | 106 | Info<< "min/max(T) = " 107 | << min(T).value() << ", " << max(T).value() << endl; 108 | 109 | p.ref() = rho()/psi(); 110 | p.correctBoundaryConditions(); 111 | rho.boundaryFieldRef() == psi.boundaryField()*p.boundaryField(); 112 | -------------------------------------------------------------------------------- /Eqn/rhoEqn.H: -------------------------------------------------------------------------------- 1 | if ((ddtSchemes == "RK2SSP") || (ddtSchemes == "RK3SSP")) 2 | { 3 | rho_rhs = -fvc::div(rhoPhi); 4 | 5 | rho = rkcoe1[nrk]*rho_save 6 | + rkcoe2[nrk]*rho 7 | + rkcoe3[nrk]*rho_rhs*runTime.deltaT(); 8 | 9 | Info <<"in rk"<< nrk+1 << " finish calculate rho" << nl << endl; 10 | } 11 | else 12 | { 13 | solve 14 | ( 15 | fvm::ddt(rho) 16 | + fvc::div(rhoPhi) 17 | ); 18 | } 19 | 20 | 21 | -------------------------------------------------------------------------------- /Eqn/rhoUEqn.H: -------------------------------------------------------------------------------- 1 | if ((ddtSchemes == "RK2SSP") || (ddtSchemes == "RK3SSP")) 2 | { 3 | rhoU_rhs = -fvc::div(rhoUPhi); 4 | 5 | rhoU = rkcoe1[nrk]*rhoU_save 6 | + rkcoe2[nrk]*rhoU 7 | + rkcoe3[nrk]*rhoU_rhs*runTime.deltaT(); 8 | 9 | U.ref() = rhoU()/rho(); 10 | U.correctBoundaryConditions(); 11 | rhoU.boundaryFieldRef() == rho.boundaryField()*U.boundaryField(); 12 | 13 | if (!inviscid) 14 | { 15 | rhoU_rhs = fvc::laplacian(turbulence->muEff(),U) + fvc::div(tauMC); 16 | rhoU += rkcoe3[nrk]*rhoU_rhs*runTime.deltaT(); 17 | 18 | U.ref() = rhoU()/rho(); 19 | U.correctBoundaryConditions(); 20 | rhoU.boundaryFieldRef() == rho.boundaryField()*U.boundaryField(); 21 | } 22 | 23 | Info <<"in rk"<muEff(), U) 42 | - fvc::div(tauMC) 43 | ); 44 | rhoU = rho*U; 45 | } 46 | 47 | Info << "\nmin / max mag(U) ; " << gMin(mag(U)()()) << " / " << gMax(mag(U)()()) << nl << endl; 48 | } 49 | 50 | 51 | -------------------------------------------------------------------------------- /Eqn/rhoYEqn.H: -------------------------------------------------------------------------------- 1 | start = std::clock(); 2 | 3 | if (!inviscid) 4 | { 5 | hDiffCorrFlux = Zero; 6 | diffAlphaD = Zero; 7 | sumYDiffError = Zero; 8 | 9 | forAll(Y, i) 10 | { 11 | sumYDiffError += chemistry->rhoD(i)*fvc::grad(Y[i]); 12 | } 13 | } 14 | 15 | tmp> mvConvection 16 | ( 17 | fv::convectionScheme::New 18 | ( 19 | mesh, 20 | fields, 21 | phi, 22 | mesh.divScheme("div(phi,Yi_h)") 23 | ) 24 | ); 25 | 26 | end = std::clock(); 27 | time_monitor_corrDiff += double(end - start) / double(CLOCKS_PER_SEC); 28 | 29 | { 30 | start = std::clock(); 31 | 32 | if((ddtSchemes == "RK2SSP") || (ddtSchemes == "RK3SSP")) 33 | { 34 | if(chemScheme == "direct") 35 | { 36 | chemistry->calculateW(); 37 | } 38 | } 39 | else 40 | { 41 | combustion->correct(); 42 | } 43 | 44 | label flag_mpi_init; 45 | MPI_Initialized(&flag_mpi_init); 46 | if(flag_mpi_init) MPI_Barrier(PstreamGlobals::MPI_COMM_FOAM); 47 | end = std::clock(); 48 | time_monitor_chem += double(end - start) / double(CLOCKS_PER_SEC); 49 | 50 | volScalarField Yt(0.0*Y[0]); 51 | 52 | start = std::clock(); 53 | forAll(Y, i) 54 | { 55 | volScalarField& Yi = Y[i]; 56 | 57 | if (!inviscid) 58 | { 59 | hDiffCorrFlux += chemistry->hai(i)*(chemistry->rhoD(i)*fvc::grad(Yi) - Yi*sumYDiffError); 60 | diffAlphaD += fvc::laplacian(thermo.alpha()*chemistry->hai(i), Yi); 61 | } 62 | 63 | if (i != inertIndex) 64 | { 65 | if((ddtSchemes == "RK2SSP") || (ddtSchemes == "RK3SSP")) 66 | { 67 | rhoYi_rhs = -fvc::div(fluxSchemeFields->interpolate(Y[i], "Yi")*rhoPhi);//fvc::div(phiYi[i]); 68 | 69 | if(chemScheme == "direct") 70 | { 71 | rhoYi_rhs.ref() += chemistry->wrate(i); 72 | Info <<"max reaction rate "<< Yi.name() << " is " << max(chemistry->wrate(i)).value() << endl; 73 | } 74 | 75 | 76 | rhoYi[i] = rkcoe1[nrk]*rhoYi_save[i] 77 | + rkcoe2[nrk]*rhoYi[i] 78 | + rkcoe3[nrk]*rhoYi_rhs*runTime.deltaT(); 79 | } 80 | else 81 | { 82 | // original convection term 83 | // fvScalarMatrix YiEqn 84 | // ( 85 | // fvm::ddt(rho, Yi) 86 | // + mvConvection->fvmDiv(phi, Yi) 87 | // == 88 | // combustion->R(Yi) 89 | // ); 90 | 91 | solve 92 | ( 93 | fvm::ddt(rhoYi[i]) 94 | + fvc::div(fluxSchemeFields->interpolate(Y[i], "Yi")*rhoPhi)//fvc::div(phiYi[i]) 95 | == 96 | chemistry->RR(i) 97 | ); 98 | } 99 | 100 | Yi=rhoYi[i]/rho; 101 | Yi.max(0.0); 102 | 103 | if (!inviscid) 104 | { 105 | const surfaceScalarField phiUc = linearInterpolate(sumYDiffError) & mesh.Sf(); 106 | tmp DEff = chemistry->rhoD(i) + turbulence->mut()/Sct; 107 | 108 | if((ddtSchemes == "RK2SSP") || (ddtSchemes == "RK3SSP")) 109 | { 110 | rhoYi_rhs = 111 | ( 112 | turbName == "laminar" 113 | ? (fvc::laplacian(DEff(), Yi) - fvc::div(phiUc,Yi,"div(phi,Yi_h)")) 114 | : fvc::laplacian(DEff(), Yi) 115 | ); 116 | 117 | rhoYi[i] += rkcoe3[nrk]*rhoYi_rhs*runTime.deltaT(); 118 | 119 | Yi = rhoYi[i]/rho; 120 | Yi.max(0.0); 121 | } 122 | else 123 | { 124 | // original term 125 | // YiEqn -= fvm::laplacian(DEff(), Yi) - mvConvection->fvmDiv(phiUc, Yi); 126 | 127 | fvScalarMatrix YiEqn 128 | ( 129 | fvm::ddt(rho, Yi) - fvc::ddt(rho, Yi) 130 | - 131 | ( 132 | turbName == "laminar" 133 | ? (fvm::laplacian(DEff(), Yi) + mvConvection->fvmDiv(phiUc, Yi)) 134 | : fvm::laplacian(DEff(), Yi) 135 | ) 136 | ); 137 | 138 | YiEqn.relax(); 139 | 140 | YiEqn.solve("Yi"); 141 | 142 | Yi.max(0.0); 143 | } 144 | 145 | } 146 | 147 | // original term 148 | // YiEqn.relax(); 149 | // YiEqn.solve("Yi"); 150 | // Yi.max(0.0); 151 | 152 | if((ddtSchemes == "RK2SSP") || (ddtSchemes == "RK3SSP")) Yi.correctBoundaryConditions(); 153 | rhoYi[i] = rho*Yi; 154 | Yt += Yi; 155 | } 156 | } 157 | 158 | Y[inertIndex] = scalar(1) - Yt; 159 | Y[inertIndex].max(0.0); 160 | rhoYi[inertIndex] = rho*Y[inertIndex]; 161 | 162 | end = std::clock(); 163 | time_monitor_Y += double(end - start) / double(CLOCKS_PER_SEC); 164 | } 165 | -------------------------------------------------------------------------------- /Figs/DDT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/Figs/DDT.png -------------------------------------------------------------------------------- /Figs/ODW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/Figs/ODW.png -------------------------------------------------------------------------------- /Figs/RDE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/Figs/RDE.png -------------------------------------------------------------------------------- /Figs/Riemann.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/Figs/Riemann.png -------------------------------------------------------------------------------- /Make/files: -------------------------------------------------------------------------------- 1 | dfCDSFoam.C 2 | 3 | EXE = $(DF_APPBIN)/dfCDSFoam 4 | -------------------------------------------------------------------------------- /Make/options: -------------------------------------------------------------------------------- 1 | -include $(GENERAL_RULES)/mplibType 2 | 3 | EXE_INC = -std=c++14 \ 4 | -Wno-unused-variable \ 5 | -Wno-unused-but-set-variable \ 6 | -Wno-old-style-cast \ 7 | $(PFLAGS) $(PINC) \ 8 | $(if $(LIBTORCH_ROOT),-DUSE_LIBTORCH,) \ 9 | $(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \ 10 | -I$(CANTERA_ROOT)/include \ 11 | -I$(DF_SRC)/dfCanteraMixture/lnInclude \ 12 | -I$(DF_SRC)/dfChemistryModel/lnInclude \ 13 | -I$(DF_SRC)/dfCombustionModels/lnInclude \ 14 | -I$(FOAM_APP)/solvers/compressible/rhoCentralFoam/BCs/lnInclude \ 15 | -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ 16 | -I$(LIB_SRC)/finiteVolume/cfdTools \ 17 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 18 | -I$(LIB_SRC)/meshTools/lnInclude \ 19 | -I$(LIB_SRC)/Pstream/mpi \ 20 | -I$(LIB_SRC)/sampling/lnInclude \ 21 | -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ 22 | -I$(LIB_SRC)/transportModels/compressible/lnInclude \ 23 | -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ 24 | -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ 25 | -IfluxSchemes/lnInclude \ 26 | $(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include,) \ 27 | $(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include/torch/csrc/api/include,) \ 28 | $(PYTHON_INC_DIR) 29 | 30 | EXE_LIBS = \ 31 | -lfiniteVolume \ 32 | -lcompressibleTransportModels \ 33 | -lturbulenceModels \ 34 | -ldynamicFvMesh \ 35 | -ltopoChangerFvMesh \ 36 | -lmeshTools \ 37 | -L$(DF_LIBBIN) \ 38 | -ldfFluidThermophysicalModels \ 39 | -ldfCompressibleTurbulenceModels \ 40 | -ldfCanteraMixture \ 41 | -ldfChemistryModel \ 42 | -ldfCombustionModels \ 43 | -lfluxSchemes \ 44 | $(CANTERA_ROOT)/lib/libcantera.so \ 45 | $(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libtorch.so,) \ 46 | $(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libc10.so,) \ 47 | $(if $(LIBTORCH_ROOT),-rdynamic,) \ 48 | $(if $(LIBTORCH_ROOT),-lpthread,) \ 49 | $(if $(LIBTORCH_ROOT),$(DF_SRC)/dfChemistryModel/DNNInferencer/build/libDNNInferencer.so,) \ 50 | $(if $(PYTHON_LIB_DIR),$(PYTHON_LIB_DIR),) 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CDSFoam: A detonation solver based on deepflame 2 | 1. The fluxschemes is form [blastFoam](https://github.com/synthetik-technologies/blastfoam) and [detonationFoam](https://github.com/JieSun-pku/detonationFoam) 3 | 2. The HLLC-LM scheme is introduced 4 | 3. The explicit third-order SSP Runge-Kutta method for time integration 5 | 4. The CVODE solver of Cantera for chemical reaction rate evaluation 6 | 5. The dynamic load balancing (DLB) is used for chemical solution 7 | 8 | ## How to install 9 | 1. Install [OpenFOAM-7](https://openfoam.org/version/7/) 10 | 2. Install [deepflame](https://github.com/deepflameCFD/deepflame-dev) 11 | 3. Compile dfCDSFoam:```./Allwmake``` 12 | 13 | ## Derived cases 14 | 1. ***Riemann problem*** 15 | 16 | ![Riemann problem](https://github.com/ChenHuangwei/CDSFoam-deepflame/blob/master/Figs/Riemann.png) 17 | 2. ***Deflagration to detonation transition*** 18 | 19 | ![DDT](https://github.com/ChenHuangwei/CDSFoam-deepflame/blob/master/Figs/DDT.png) 20 | 4. ***Rotating detonation engine*** 21 | 22 | ![RDE](https://github.com/ChenHuangwei/CDSFoam-deepflame/blob/master/Figs/RDE.png) 23 | 6. ***Oblique detonation*** 24 | 25 | ![ODW](https://github.com/ChenHuangwei/CDSFoam-deepflame/blob/master/Figs/ODW.png) 26 | 27 | ## Citation 28 | >**Chen H.W, Zhao M.H, Qiu H, Zhu Y.J. Implementation and verification of an OpenFOAM solver for gas-drople two-phase detonation combustion[J].Physics of Fluids,2024,36(8),-086133.** 29 | -------------------------------------------------------------------------------- /calculateR.H: -------------------------------------------------------------------------------- 1 | start = std::clock(); 2 | 3 | combustion->correct(); 4 | 5 | label flag_mpi_init; 6 | MPI_Initialized(&flag_mpi_init); 7 | if(flag_mpi_init) MPI_Barrier(PstreamGlobals::MPI_COMM_FOAM); 8 | end = std::clock(); 9 | time_monitor_chem += double(end - start) / double(CLOCKS_PER_SEC); 10 | 11 | volScalarField Yt(0.0*Y[0]); 12 | 13 | start = std::clock(); 14 | forAll(Y, i) 15 | { 16 | volScalarField& Yi = Y[i]; 17 | 18 | if (i != inertIndex) 19 | { 20 | rhoYi[i].ref() += chemistry->RR(i)*runTime.deltaT(); 21 | Info <<"max reaction rate "<< Yi.name() << " is " << max(chemistry->RR(i)).value() << endl; 22 | 23 | Yi = rhoYi[i]/rho; 24 | Yi.max(0.0); 25 | 26 | Yi.correctBoundaryConditions(); 27 | rhoYi[i] = rho*Yi; 28 | Yt += Yi; 29 | } 30 | } 31 | 32 | Y[inertIndex] = scalar(1) - Yt; 33 | Y[inertIndex].max(0.0); 34 | rhoYi[inertIndex] = rho*Y[inertIndex]; 35 | 36 | end = std::clock(); 37 | time_monitor_Y += double(end - start) / double(CLOCKS_PER_SEC); 38 | 39 | chemistry->correctThermo(); 40 | Info<< "min/max(T) = " 41 | << min(T).value() << ", " << max(T).value() << endl; 42 | 43 | p.ref() = rho()/psi(); 44 | p.correctBoundaryConditions(); 45 | rho.boundaryFieldRef() == psi.boundaryField()*p.boundaryField(); 46 | 47 | 48 | Info << " finish calculate Reaction" << nl << endl; 49 | 50 | -------------------------------------------------------------------------------- /centralCourantNo.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Global 25 | centralCourantNo 26 | 27 | Description 28 | Calculates the mean and maximum wave speed based Courant Numbers. 29 | 30 | \*---------------------------------------------------------------------------*/ 31 | 32 | surfaceScalarField amaxSf("amaxSf", 33 | mag(fvc::flux(U)) + 34 | mesh.magSf() * fvc::interpolate(c)); 35 | 36 | if (mesh.nInternalFaces()) 37 | { 38 | scalarField sumAmaxSf(fvc::surfaceSum(amaxSf)().primitiveField()); 39 | 40 | CoNum = 0.5*gMax(sumAmaxSf/mesh.V().field())*runTime.deltaTValue(); 41 | 42 | meanCoNum = 43 | 0.5*(gSum(sumAmaxSf)/gSum(mesh.V().field()))*runTime.deltaTValue(); 44 | } 45 | 46 | Info<< "Mean and max Courant Numbers = " 47 | << meanCoNum << " " << CoNum << endl; 48 | 49 | // ************************************************************************* // 50 | -------------------------------------------------------------------------------- /createFields.H: -------------------------------------------------------------------------------- 1 | #include "createRDeltaT.H" 2 | 3 | word ddtSchemes("Euler"); 4 | if (mesh.schemesDict().readIfPresent("timeScheme", ddtSchemes)) 5 | { 6 | if(ddtSchemes == "RK2SSP" || ddtSchemes == "RK3SSP") 7 | { 8 | Info<< "ddtSchemes: " << ddtSchemes << endl; 9 | } 10 | else 11 | { 12 | FatalErrorInFunction 13 | << "This timeScheme is not a valid choice. " 14 | << "Please use RK2SSP or RK3SSP scheme." 15 | << abort(FatalError); 16 | } 17 | } 18 | 19 | word chemScheme("ode"); 20 | mesh.schemesDict().readIfPresent("chemScheme", chemScheme); 21 | 22 | if ((chemScheme == "direct") || (chemScheme == "ode")) 23 | { 24 | Info<< "chemScheme: " << chemScheme << endl; 25 | } 26 | else 27 | { 28 | FatalErrorInFunction 29 | << "chemScheme: " << chemScheme 30 | << " is not a valid choice. " 31 | << "Options are: 'ode' | 'direct'" 32 | << abort(FatalError); 33 | } 34 | 35 | 36 | if((ddtSchemes != "RK2SSP") && (ddtSchemes != "RK3SSP")) 37 | { 38 | if(chemScheme == "direct") 39 | { 40 | FatalErrorInFunction 41 | << "This combination is not a valid choice. " 42 | << "If you want to use direct integrate for chemistry, please use RK2SSP or RK3SSP scheme." 43 | << abort(FatalError); 44 | } 45 | } 46 | 47 | 48 | Info<< "Reading thermophysical properties\n" << endl; 49 | 50 | // psiThermo* pThermo = new hePsiThermo(mesh, word::null); 51 | // psiThermo& thermo = *pThermo; 52 | rhoThermo* pThermo = new heRhoThermo(mesh, word::null); 53 | rhoThermo& thermo = *pThermo; 54 | 55 | //move from creatFieldRefs.H to createFields.H 56 | //p needed to be created before e 57 | volScalarField& p = thermo.p(); 58 | const volScalarField& T = thermo.T(); 59 | const volScalarField& psi = thermo.psi(); 60 | const volScalarField& mu = thermo.mu(); 61 | 62 | dictionary thermoDict 63 | ( 64 | IOdictionary 65 | ( 66 | IOobject 67 | ( 68 | "thermophysicalProperties", 69 | runTime.constant(), 70 | mesh, 71 | IOobject::MUST_READ_IF_MODIFIED, 72 | IOobject::NO_WRITE 73 | ) 74 | ) 75 | ); 76 | 77 | bool inviscid(thermoDict.lookupOrDefault("inviscid",false)); 78 | 79 | Info<< "Reading field U\n" << endl; 80 | volVectorField U 81 | ( 82 | IOobject 83 | ( 84 | "U", 85 | runTime.timeName(), 86 | mesh, 87 | IOobject::MUST_READ, 88 | IOobject::AUTO_WRITE 89 | ), 90 | mesh 91 | ); 92 | 93 | volScalarField rho 94 | ( 95 | IOobject 96 | ( 97 | "rho", 98 | runTime.timeName(), 99 | mesh, 100 | IOobject::NO_READ, 101 | IOobject::AUTO_WRITE 102 | ), 103 | thermo.rho() 104 | ); 105 | 106 | volVectorField rhoU 107 | ( 108 | IOobject 109 | ( 110 | "rhoU", 111 | runTime.timeName(), 112 | mesh, 113 | IOobject::NO_READ, 114 | IOobject::NO_WRITE 115 | ), 116 | rho*U 117 | ); 118 | 119 | surfaceScalarField pos 120 | ( 121 | IOobject 122 | ( 123 | "pos", 124 | runTime.timeName(), 125 | mesh 126 | ), 127 | mesh, 128 | dimensionedScalar(dimless, 1.0) 129 | ); 130 | 131 | surfaceScalarField neg 132 | ( 133 | IOobject 134 | ( 135 | "neg", 136 | runTime.timeName(), 137 | mesh 138 | ), 139 | mesh, 140 | dimensionedScalar(dimless, -1.0) 141 | ); 142 | 143 | //surfaceScalarField phi("phi", fvc::flux(rhoU)); 144 | 145 | surfaceScalarField rhoPhi 146 | ( 147 | IOobject 148 | ( 149 | "rhoPhi", 150 | mesh.time().timeName(), 151 | mesh, 152 | IOobject::NO_READ, 153 | IOobject::NO_WRITE 154 | ), 155 | mesh, 156 | dimensionedScalar("0", dimDensity*dimVelocity*dimArea, 0.0) 157 | ); 158 | 159 | surfaceScalarField phi 160 | ( 161 | IOobject 162 | ( 163 | "phi", 164 | mesh.time().timeName(), 165 | mesh, 166 | IOobject::NO_READ, 167 | IOobject::NO_WRITE 168 | ), 169 | mesh, 170 | dimensionedScalar("0", dimVelocity*dimArea, 0.0) 171 | ); 172 | 173 | surfaceVectorField rhoUPhi 174 | ( 175 | IOobject 176 | ( 177 | "rhoUPhi", 178 | mesh.time().timeName(), 179 | mesh, 180 | IOobject::NO_READ, 181 | IOobject::NO_WRITE 182 | ), 183 | mesh, 184 | dimensionedVector("0", dimDensity*sqr(dimVelocity)*dimArea, Zero) 185 | ); 186 | 187 | surfaceScalarField rhoEPhi 188 | ( 189 | IOobject 190 | ( 191 | "rhoEPhi", 192 | mesh.time().timeName(), 193 | mesh, 194 | IOobject::NO_READ, 195 | IOobject::NO_WRITE 196 | ), 197 | mesh, 198 | dimensionedScalar("0", dimDensity*pow3(dimVelocity)*dimArea, 0.0) 199 | ); 200 | 201 | Info<< "Creating turbulence model\n" << endl; 202 | autoPtr turbulence 203 | ( 204 | compressible::turbulenceModel::New 205 | ( 206 | rho, 207 | U, 208 | phi, 209 | thermo 210 | ) 211 | ); 212 | const word turbName(mesh.objectRegistry::lookupObject("turbulenceProperties").lookup("simulationType")); 213 | 214 | multivariateSurfaceInterpolationScheme::fieldTable fields; 215 | 216 | Info<< "Creating reaction model\n" << endl; 217 | autoPtr> combustion 218 | ( 219 | CombustionModel::New(thermo, turbulence()) 220 | ); 221 | Info<< "end Creating reaction model\n" << endl; 222 | dfChemistryModel* chemistry = combustion->chemistry(); 223 | PtrList& Y = chemistry->Y(); 224 | const word inertSpecie(chemistry->lookup("inertSpecie")); 225 | const label inertIndex(chemistry->species()[inertSpecie]); 226 | chemistry->setEnergyName("ea"); 227 | chemistry->updateEnergy(); 228 | 229 | volScalarField& ea = thermo.he(); 230 | volScalarField ha = ea + p/rho; 231 | 232 | volScalarField rhoE 233 | ( 234 | IOobject 235 | ( 236 | "rhoE", 237 | runTime.timeName(), 238 | mesh, 239 | IOobject::NO_READ, 240 | IOobject::NO_WRITE 241 | ), 242 | rho*(ea + 0.5*magSqr(U)) 243 | ); 244 | 245 | const word combModelName(mesh.objectRegistry::lookupObject("combustionProperties").lookup("combustionModel")); 246 | Info << "Combustion Model Name is confirmed as "<< combModelName << endl; 247 | 248 | 249 | if (combModelName != "flareFGM") 250 | { 251 | chemistry->correctThermo(); 252 | Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; 253 | } 254 | 255 | forAll(Y, i) 256 | { 257 | fields.add(Y[i]); 258 | } 259 | fields.add(thermo.he()); 260 | 261 | const label nspecies(chemistry->species().size()); 262 | PtrList rhoYi(nspecies); 263 | forAll(rhoYi,i) 264 | { 265 | rhoYi.set 266 | ( 267 | i, 268 | new volScalarField 269 | ( 270 | IOobject 271 | ( 272 | "rhoYi" + Y[i].name(), 273 | runTime.timeName(), 274 | mesh, 275 | IOobject::NO_READ, 276 | IOobject::NO_WRITE 277 | ), 278 | rho*Y[i] 279 | ) 280 | ); 281 | } 282 | 283 | const scalar Sct = chemistry->lookupOrDefault("Sct", 1.); 284 | volScalarField diffAlphaD 285 | ( 286 | IOobject 287 | ( 288 | "diffAlphaD", 289 | runTime.timeName(), 290 | mesh, 291 | IOobject::NO_READ, 292 | IOobject::NO_WRITE 293 | ), 294 | mesh, 295 | dimensionedScalar(dimEnergy/dimTime/dimVolume, 0) 296 | ); 297 | volVectorField hDiffCorrFlux 298 | ( 299 | IOobject 300 | ( 301 | "hDiffCorrFlux", 302 | runTime.timeName(), 303 | mesh, 304 | IOobject::NO_READ, 305 | IOobject::NO_WRITE 306 | ), 307 | mesh, 308 | dimensionedVector(dimensionSet(1,0,-3,0,0,0,0), Zero) 309 | ); 310 | volVectorField sumYDiffError 311 | ( 312 | IOobject 313 | ( 314 | "sumYDiffError", 315 | runTime.timeName(), 316 | mesh, 317 | IOobject::NO_READ, 318 | IOobject::NO_WRITE 319 | ), 320 | mesh, 321 | dimensionedVector("sumYDiffError", dimDynamicViscosity/dimLength, Zero) 322 | ); 323 | 324 | volScalarField maxp 325 | ( 326 | IOobject 327 | ( 328 | "maxp", 329 | runTime.timeName(), 330 | mesh, 331 | IOobject::MUST_READ, 332 | IOobject::AUTO_WRITE 333 | ), 334 | mesh 335 | ); 336 | 337 | autoPtr fluxSchemeFields(Foam::fluxScheme::New(mesh)); 338 | -------------------------------------------------------------------------------- /createFieldsSave.H: -------------------------------------------------------------------------------- 1 | volScalarField rho_save("rho_save",thermo.rho()); 2 | 3 | volVectorField rhoU_save("rhoU_save",rho*U); 4 | 5 | volScalarField rhoE_save("rhoE_save",rho*(ea + 0.5*magSqr(U))); 6 | 7 | PtrList rhoYi_save(nspecies); 8 | forAll(rhoYi_save,i) 9 | { 10 | rhoYi_save.set 11 | ( 12 | i, 13 | new volScalarField 14 | ( 15 | IOobject 16 | ( 17 | "rhoYi_save" + Y[i].name(), 18 | runTime.timeName(), 19 | mesh, 20 | IOobject::NO_READ, 21 | IOobject::NO_WRITE 22 | ), 23 | rho*Y[i] 24 | ) 25 | ); 26 | } 27 | 28 | List rkcoe1(3); 29 | List rkcoe2(3); 30 | List rkcoe3(3); 31 | scalar rk=2; 32 | label nrk=0; 33 | 34 | if(ddtSchemes == "RK2SSP") 35 | { 36 | rkcoe1[0]=1.0; rkcoe2[0]=0.0; rkcoe3[0]=1.0; 37 | rkcoe1[1]=0.5; rkcoe2[1]=0.5; rkcoe3[1]=0.5; 38 | rkcoe1[2]=0.0; rkcoe2[2]=0.0; rkcoe3[2]=0.0; 39 | } 40 | else if(ddtSchemes == "RK3SSP") 41 | { 42 | rkcoe1[0]=1.0; rkcoe2[0]=0.0; rkcoe3[0]=1.0; 43 | rkcoe1[1]=0.75; rkcoe2[1]=0.25; rkcoe3[1]=0.25; 44 | rkcoe1[2]=1.0/3.0; rkcoe2[2]=2.0/3.0; rkcoe3[2]=2.0/3.0; 45 | rk=3; 46 | } 47 | -------------------------------------------------------------------------------- /dfCDSFoam.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Application 25 | rhoCentralFoam 26 | 27 | Description 28 | Density-based compressible flow solver based on central-upwind schemes of 29 | Kurganov and Tadmor with support for mesh-motion and topology changes. 30 | 31 | \*---------------------------------------------------------------------------*/ 32 | 33 | #include "dfChemistryModel.H" 34 | #include "CanteraMixture.H" 35 | // #include "hePsiThermo.H" 36 | #include "heRhoThermo.H" 37 | 38 | #ifdef USE_PYTORCH 39 | #include 40 | #include 41 | #include //used to convert 42 | #endif 43 | 44 | #ifdef USE_LIBTORCH 45 | #include 46 | #include "DNNInferencer.H" 47 | #endif 48 | 49 | #include "fvCFD.H" 50 | #include "dynamicFvMesh.H" 51 | // #include "psiThermo.H" 52 | #include "rhoThermo.H" 53 | #include "turbulentFluidThermoModel.H" 54 | #include "fixedRhoFvPatchScalarField.H" 55 | #include "directionInterpolate.H" 56 | #include "localEulerDdtScheme.H" 57 | #include "fvcSmooth.H" 58 | #include "PstreamGlobals.H" 59 | #include "CombustionModel.H" 60 | 61 | #include "fluxScheme.H"// 62 | 63 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 64 | 65 | int main(int argc, char *argv[]) 66 | { 67 | #ifdef USE_PYTORCH 68 | pybind11::scoped_interpreter guard{};//start python interpreter 69 | #endif 70 | #define NO_CONTROL 71 | 72 | #include "postProcess.H" 73 | 74 | // #include "setRootCaseLists.H" 75 | #include "listOptions.H" 76 | #include "setRootCase2.H" 77 | #include "listOutput.H" 78 | #include "createTime.H" 79 | #include "createDynamicFvMesh.H" 80 | #include "createFields.H" 81 | #include "createFieldsSave.H" 82 | #include "createTimeControls.H" 83 | 84 | double time_monitor_flow=0; 85 | double time_monitor_chem=0; 86 | double time_monitor_Y=0; 87 | double time_monitor_AMR=0; 88 | double time_monitor_E=0; 89 | double time_monitor_corrDiff=0; 90 | clock_t start, end; 91 | 92 | turbulence->validate(); 93 | 94 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 95 | 96 | 97 | dimensionedScalar v_zero("v_zero", dimVolume/dimTime, 0.0); 98 | dimensionedScalar refCri("refCri", dimensionSet(1, -4, 0, 0, 0), 0.0); 99 | 100 | // Courant numbers used to adjust the time-step 101 | scalar CoNum = 0.0; 102 | scalar meanCoNum = 0.0; 103 | 104 | Info<< "\nStarting time loop\n" << endl; 105 | 106 | while (runTime.run()) 107 | { 108 | #include "readTimeControls.H" 109 | 110 | //used for AMR 111 | refCri = max(mag(fvc::grad(rho))); 112 | tmp tmagGradrho = mag(fvc::grad(rho)); 113 | volScalarField normalisedGradrho 114 | ( 115 | "normalisedGradrho", 116 | tmagGradrho()/refCri 117 | ); 118 | normalisedGradrho.writeOpt() = IOobject::AUTO_WRITE; 119 | tmagGradrho.clear(); 120 | 121 | if (!LTS) 122 | { 123 | #include "setDeltaT.H" 124 | runTime++; 125 | 126 | // Do any mesh changes 127 | start = std::clock(); 128 | mesh.update(); 129 | end = std::clock(); 130 | time_monitor_AMR += double(end - start) / double(CLOCKS_PER_SEC); 131 | 132 | } 133 | 134 | #include "preCal.H" 135 | 136 | volScalarField rho_rhs("rho_rhs",rho_save/runTime.deltaT()); 137 | volVectorField rhoU_rhs("rhoU_rhs",rhoU_save/runTime.deltaT()); 138 | volScalarField rhoYi_rhs("rhoYi_rhs",rhoYi_save[0]/runTime.deltaT()); 139 | volScalarField rhoE_rhs("rhoE_rhs",rhoE_save/runTime.deltaT()); 140 | 141 | if ((ddtSchemes == "RK2SSP") || (ddtSchemes == "RK3SSP")) 142 | { 143 | for( nrk=0 ; nrkmuEff()); 148 | volTensorField tauMC("tauMC", muEff*dev2(Foam::T(fvc::grad(U)))); 149 | 150 | fluxSchemeFields->update(rho,U,ea,p,c,phi,rhoPhi,rhoUPhi,rhoEPhi); 151 | Info <<"\n in rk"<< nrk+1 << " finish pre-calculation"<< nl << endl; 152 | 153 | if (nrk == 0) 154 | { 155 | #include "centralCourantNo.H" 156 | if (LTS) 157 | { 158 | #include "setRDeltaT.H" 159 | runTime++; 160 | } 161 | 162 | Info<< "Time = " << runTime.timeName() << nl << endl; 163 | 164 | #include "updateFieldsSave.H" 165 | } 166 | 167 | // --- Solve density 168 | #include "Eqn/rhoEqn.H" 169 | 170 | start = std::clock(); 171 | // --- Solve momentum 172 | #include "Eqn/rhoUEqn.H" 173 | end = std::clock(); 174 | time_monitor_flow += double(end - start) / double(CLOCKS_PER_SEC); 175 | 176 | // --- Solve species 177 | #include "Eqn/rhoYEqn.H" 178 | 179 | start = std::clock(); 180 | // --- Solve energy 181 | #include "Eqn/rhoEEqn.H" 182 | end = std::clock(); 183 | time_monitor_E += double(end - start) / double(CLOCKS_PER_SEC); 184 | 185 | if ((nrk == rk-1) && (chemScheme == "ode")) 186 | { 187 | #include "calculateR.H" 188 | } 189 | 190 | } 191 | 192 | } 193 | else 194 | { 195 | 196 | volScalarField muEff("muEff", turbulence->muEff()); 197 | volTensorField tauMC("tauMC", muEff*dev2(Foam::T(fvc::grad(U)))); 198 | 199 | #include "centralCourantNo.H" 200 | 201 | if (LTS) 202 | { 203 | #include "setRDeltaT.H" 204 | runTime++; 205 | } 206 | 207 | Info<< "Time = " << runTime.timeName() << nl << endl; 208 | 209 | fluxSchemeFields->update(rho,U,ea,p,c,phi,rhoPhi,rhoUPhi,rhoEPhi); 210 | 211 | // --- Solve density 212 | #include "Eqn/rhoEqn.H" 213 | 214 | start = std::clock(); 215 | // --- Solve momentum 216 | #include "Eqn/rhoUEqn.H" 217 | end = std::clock(); 218 | time_monitor_flow += double(end - start) / double(CLOCKS_PER_SEC); 219 | 220 | // --- Solve species 221 | #include "Eqn/rhoYEqn.H" 222 | 223 | start = std::clock(); 224 | // --- Solve energy 225 | #include "Eqn/rhoEEqn.H" 226 | end = std::clock(); 227 | time_monitor_E += double(end - start) / double(CLOCKS_PER_SEC); 228 | } 229 | 230 | forAll(maxp, celli) 231 | { 232 | if(maxp[celli] < p[celli]) 233 | maxp[celli] = p[celli]; 234 | } 235 | 236 | turbulence->correct(); 237 | 238 | runTime.write(); 239 | 240 | Info<< "========Time Spent in diffenet parts========"<< endl; 241 | Info<< "MonitorTime_AMR = " << time_monitor_AMR << " s" << endl; 242 | Info<< "MonitorTime_flow = " << time_monitor_flow << " s" << endl; 243 | Info<< "Diffusion Correction Time = " << time_monitor_corrDiff << " s" << endl; 244 | Info<< "MonitorTime_chem = " << time_monitor_chem << " s" << endl; 245 | Info<< "MonitorTime_Y = " << time_monitor_Y << " s" << endl; 246 | Info<< "MonitorTime_E = " << time_monitor_E << " s" << endl; 247 | Info<< "============================================"< 6 | tmp> interpolate 7 | ( 8 | const GeometricField& vf, 9 | const surfaceScalarField& dir, 10 | const word& reconFieldName = word::null 11 | ) 12 | { 13 | tmp> tsf 14 | ( 15 | fvc::interpolate 16 | ( 17 | vf, 18 | dir, 19 | "reconstruct(" 20 | + (reconFieldName != word::null ? reconFieldName : vf.name()) 21 | + ')' 22 | ) 23 | ); 24 | 25 | GeometricField& sf = tsf.ref(); 26 | 27 | sf.rename(vf.name() + '_' + dir.name()); 28 | 29 | return tsf; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0/AR.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0/AR.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0/H2.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0/H2.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0/O2.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0/O2.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0/T.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0/T.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0/U.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0/U.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0/Ydefault.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0/Ydefault.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0/maxp.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0/maxp.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0/p.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0/p.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0_orig/AR.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0_orig/AR.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0_orig/H2.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0_orig/H2.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0_orig/O2.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0_orig/O2.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0_orig/T.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0_orig/T.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0_orig/U.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0_orig/U.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0_orig/Ydefault.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0_orig/Ydefault.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0_orig/maxp.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0_orig/maxp.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/0_orig/p.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/0_orig/p.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/190us-T.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/190us-T.jpg -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/190us-YH.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/190us-YH.jpg -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/190us-u.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/190us-u.png -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/H2_AR.yaml: -------------------------------------------------------------------------------- 1 | generator: ctml2yaml 2 | cantera-version: 2.6.0 3 | date: Wed, 24 May 2023 11:11:32 +0800 4 | input-files: [H2_AR.xml] 5 | 6 | phases: 7 | - name: gas 8 | elements: [H, O, Ar] 9 | species: [H2, O2, H, O, OH, HO2, H2O2, H2O, AR] 10 | thermo: ideal-gas 11 | transport: mixture-averaged 12 | kinetics: gas 13 | reactions: all 14 | state: {T: 300.0 K, P: 1.01325e+05 Pa} 15 | 16 | species: 17 | - name: H2 18 | composition: {H: 2.0} 19 | note: TPIS78 20 | thermo: 21 | model: NASA7 22 | temperature-ranges: [200.0, 1000.0, 3500.0] 23 | data: 24 | - [2.34433112, 7.98052075e-03, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12, 25 | -917.935173, 0.683010238] 26 | - [3.3372792, -4.94024731e-05, 4.99456778e-07, -1.79566394e-10, 2.00255376e-14, 27 | -950.158922, -3.20502331] 28 | transport: 29 | model: gas 30 | geometry: linear 31 | well-depth: 38.0 32 | diameter: 2.92 33 | dipole: 0.0 34 | polarizability: 0.79 35 | rotational-relaxation: 280.0 36 | dispersion-coefficient: 0.0 37 | quadrupole-polarizability: 0.0 38 | - name: O2 39 | composition: {O: 2.0} 40 | note: TPIS89 41 | thermo: 42 | model: NASA7 43 | temperature-ranges: [200.0, 1000.0, 3500.0] 44 | data: 45 | - [3.78245636, -2.99673416e-03, 9.84730201e-06, -9.68129509e-09, 3.24372837e-12, 46 | -1063.94356, 3.65767573] 47 | - [3.28253784, 1.48308754e-03, -7.57966669e-07, 2.09470555e-10, -2.16717794e-14, 48 | -1088.45772, 5.45323129] 49 | transport: 50 | model: gas 51 | geometry: linear 52 | well-depth: 107.4 53 | diameter: 3.458 54 | dipole: 0.0 55 | polarizability: 1.6 56 | rotational-relaxation: 3.8 57 | dispersion-coefficient: 0.0 58 | quadrupole-polarizability: 0.0 59 | - name: H 60 | composition: {H: 1.0} 61 | note: L7/88 62 | thermo: 63 | model: NASA7 64 | temperature-ranges: [200.0, 1000.0, 3500.0] 65 | data: 66 | - [2.5, 7.05332819e-13, -1.99591964e-15, 2.30081632e-18, -9.27732332e-22, 2.54736599e+04, 67 | -0.446682853] 68 | - [2.50000001, -2.30842973e-11, 1.61561948e-14, -4.73515235e-18, 4.98197357e-22, 69 | 2.54736599e+04, -0.446682914] 70 | transport: 71 | model: gas 72 | geometry: atom 73 | well-depth: 145.0 74 | diameter: 2.05 75 | dipole: 0.0 76 | polarizability: 0.0 77 | rotational-relaxation: 0.0 78 | dispersion-coefficient: 0.0 79 | quadrupole-polarizability: 0.0 80 | - name: O 81 | composition: {O: 1.0} 82 | note: L1/90 83 | thermo: 84 | model: NASA7 85 | temperature-ranges: [200.0, 1000.0, 3500.0] 86 | data: 87 | - [3.1682671, -3.27931884e-03, 6.64306396e-06, -6.12806624e-09, 2.11265971e-12, 88 | 2.91222592e+04, 2.05193346] 89 | - [2.56942078, -8.59741137e-05, 4.19484589e-08, -1.00177799e-11, 1.22833691e-15, 90 | 2.92175791e+04, 4.78433864] 91 | transport: 92 | model: gas 93 | geometry: atom 94 | well-depth: 80.0 95 | diameter: 2.75 96 | dipole: 0.0 97 | polarizability: 0.0 98 | rotational-relaxation: 0.0 99 | dispersion-coefficient: 0.0 100 | quadrupole-polarizability: 0.0 101 | - name: OH 102 | composition: {H: 1.0, O: 1.0} 103 | note: S9/01 104 | thermo: 105 | model: NASA7 106 | temperature-ranges: [200.0, 1000.0, 6000.0] 107 | data: 108 | - [4.12530561, -3.22544939e-03, 6.52764691e-06, -5.79853643e-09, 2.06237379e-12, 109 | 3381.53812, -0.69043296] 110 | - [2.86472886, 1.05650448e-03, -2.59082758e-07, 3.05218674e-11, -1.33195876e-15, 111 | 3718.85774, 5.70164073] 112 | transport: 113 | model: gas 114 | geometry: linear 115 | well-depth: 80.0 116 | diameter: 2.75 117 | dipole: 0.0 118 | polarizability: 0.0 119 | rotational-relaxation: 0.0 120 | dispersion-coefficient: 0.0 121 | quadrupole-polarizability: 0.0 122 | - name: HO2 123 | composition: {H: 1.0, O: 2.0} 124 | note: L5/89 125 | thermo: 126 | model: NASA7 127 | temperature-ranges: [200.0, 1000.0, 3500.0] 128 | data: 129 | - [4.30179801, -4.74912051e-03, 2.11582891e-05, -2.42763894e-08, 9.29225124e-12, 130 | 294.80804, 3.71666245] 131 | - [4.0172109, 2.23982013e-03, -6.3365815e-07, 1.1424637e-10, -1.07908535e-14, 132 | 111.856713, 3.78510215] 133 | transport: 134 | model: gas 135 | geometry: nonlinear 136 | well-depth: 107.4 137 | diameter: 3.458 138 | dipole: 0.0 139 | polarizability: 0.0 140 | rotational-relaxation: 1.0 141 | dispersion-coefficient: 0.0 142 | quadrupole-polarizability: 0.0 143 | - name: H2O2 144 | composition: {H: 2.0, O: 2.0} 145 | note: L7/88 146 | thermo: 147 | model: NASA7 148 | temperature-ranges: [200.0, 1000.0, 3500.0] 149 | data: 150 | - [4.27611269, -5.42822417e-04, 1.67335701e-05, -2.15770813e-08, 8.62454363e-12, 151 | -1.77025821e+04, 3.43505074] 152 | - [4.16500285, 4.90831694e-03, -1.90139225e-06, 3.71185986e-10, -2.87908305e-14, 153 | -1.78617877e+04, 2.91615662] 154 | transport: 155 | model: gas 156 | geometry: nonlinear 157 | well-depth: 107.4 158 | diameter: 3.458 159 | dipole: 0.0 160 | polarizability: 0.0 161 | rotational-relaxation: 3.8 162 | dispersion-coefficient: 0.0 163 | quadrupole-polarizability: 0.0 164 | - name: H2O 165 | composition: {H: 2.0, O: 1.0} 166 | note: L8/89 167 | thermo: 168 | model: NASA7 169 | temperature-ranges: [200.0, 1000.0, 3500.0] 170 | data: 171 | - [4.19864056, -2.0364341e-03, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, 172 | -3.02937267e+04, -0.849032208] 173 | - [3.03399249, 2.17691804e-03, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, 174 | -3.00042971e+04, 4.9667701] 175 | transport: 176 | model: gas 177 | geometry: nonlinear 178 | well-depth: 572.4 179 | diameter: 2.605 180 | dipole: 1.844 181 | polarizability: 0.0 182 | rotational-relaxation: 4.0 183 | dispersion-coefficient: 0.0 184 | quadrupole-polarizability: 0.0 185 | - name: AR 186 | composition: {Ar: 1.0} 187 | note: '120186' 188 | thermo: 189 | model: NASA7 190 | temperature-ranges: [200.0, 1000.0, 5000.0] 191 | data: 192 | - [2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.366] 193 | - [2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.366] 194 | transport: 195 | model: gas 196 | geometry: atom 197 | well-depth: 136.5 198 | diameter: 3.33 199 | dipole: 0.0 200 | polarizability: 0.0 201 | rotational-relaxation: 0.0 202 | dispersion-coefficient: 0.0 203 | quadrupole-polarizability: 0.0 204 | 205 | reactions: 206 | - equation: H2 + O2 <=> 2 OH 207 | rate-constant: {A: 1.7e+10, b: 0.0, Ea: 4.778e+04 cal/mol} 208 | - equation: OH + H2 <=> H2O + H 209 | rate-constant: {A: 1.17e+06, b: 1.3, Ea: 3626.0 cal/mol} 210 | - equation: H + O2 <=> OH + O 211 | rate-constant: {A: 5.13e+13, b: -0.816, Ea: 1.6507e+04 cal/mol} 212 | - equation: O + H2 <=> OH + H 213 | rate-constant: {A: 1.8e+07, b: 1.0, Ea: 8826.0 cal/mol} 214 | - equation: H + O2 + M <=> HO2 + M 215 | type: three-body 216 | rate-constant: {A: 2.1e+12, b: -1.0, Ea: 0.0 cal/mol} 217 | efficiencies: {H2: 3.3, H2O: 21.0, O2: 0.0} 218 | - equation: H + O2 + O2 <=> HO2 + O2 219 | rate-constant: {A: 6.7e+13, b: -1.42, Ea: 0.0 cal/mol} 220 | - equation: OH + HO2 <=> H2O + O2 221 | rate-constant: {A: 5.0e+10, b: 0.0, Ea: 1000.0 cal/mol} 222 | - equation: H + HO2 <=> 2 OH 223 | rate-constant: {A: 2.5e+11, b: 0.0, Ea: 1900.0 cal/mol} 224 | - equation: O + HO2 <=> O2 + OH 225 | rate-constant: {A: 4.8e+10, b: 0.0, Ea: 1000.0 cal/mol} 226 | - equation: 2 OH <=> O + H2O 227 | rate-constant: {A: 6.0e+05, b: 1.3, Ea: 0.0 cal/mol} 228 | - equation: H2 + M <=> H + H + M 229 | type: three-body 230 | rate-constant: {A: 2.23e+09, b: 0.5, Ea: 9.26e+04 cal/mol} 231 | efficiencies: {H: 2.0, H2: 3.0, H2O: 6.0} 232 | - equation: O2 + M <=> O + O + M 233 | type: three-body 234 | rate-constant: {A: 1.85e+08, b: 0.5, Ea: 9.556e+04 cal/mol} 235 | - equation: H + OH + M <=> H2O + M 236 | type: three-body 237 | rate-constant: {A: 7.5e+17, b: -2.6, Ea: 0.0 cal/mol} 238 | efficiencies: {H2O: 20.0} 239 | - equation: H + HO2 <=> H2 + O2 240 | rate-constant: {A: 2.5e+10, b: 0.0, Ea: 700.0 cal/mol} 241 | - equation: HO2 + HO2 <=> H2O2 + O2 242 | rate-constant: {A: 2.0e+09, b: 0.0, Ea: 0.0 cal/mol} 243 | - equation: H2O2 + M <=> OH + OH + M 244 | type: three-body 245 | rate-constant: {A: 1.3e+14, b: 0.0, Ea: 4.55e+04 cal/mol} 246 | - equation: H2O2 + H <=> HO2 + H2 247 | rate-constant: {A: 1.6e+09, b: 0.0, Ea: 3800.0 cal/mol} 248 | - equation: H2O2 + OH <=> H2O + HO2 249 | rate-constant: {A: 1.0e+10, b: 0.0, Ea: 1800.0 cal/mol} 250 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/case.foam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/case.foam -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/constant/CanteraTorchProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Version: 7 6 | \\/ M anipulation | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "constant"; 14 | object CanteraTorchProperties; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | chemistry on; 19 | 20 | CanteraMechanismFile "H2_AR.yaml"; 21 | 22 | transportModel "Mix"; 23 | 24 | odeCoeffs 25 | { 26 | "relTol" 1e-6; 27 | "absTol" 1e-10; 28 | } 29 | 30 | inertSpecie "AR"; 31 | 32 | splittingStrategy off; 33 | 34 | TorchSettings 35 | { 36 | torch off; 37 | } 38 | 39 | loadbalancing 40 | { 41 | active true; 42 | log false; 43 | algorithm allAverage;//headTail; 44 | } 45 | 46 | 47 | // ************************************************************************* // 48 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/constant/combustionProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Version: 7 6 | \\/ M anipulation | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "constant"; 14 | object combustionProperties; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | combustionModel laminar; 19 | 20 | // ************************************************************************* // 21 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/constant/polyMesh/boundary: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Version: 7 6 | \\/ M anipulation | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class polyBoundaryMesh; 13 | location "constant/polyMesh"; 14 | object boundary; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | 3 19 | ( 20 | Left 21 | { 22 | type patch; 23 | nFaces 1; 24 | startFace 2399; 25 | } 26 | Right 27 | { 28 | type patch; 29 | nFaces 1; 30 | startFace 2400; 31 | } 32 | empty 33 | { 34 | type empty; 35 | inGroups List 1(empty); 36 | nFaces 9600; 37 | startFace 2401; 38 | } 39 | ) 40 | 41 | // ************************************************************************* // 42 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/constant/polyMesh/faces.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/constant/polyMesh/faces.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/constant/polyMesh/neighbour.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/constant/polyMesh/neighbour.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/constant/polyMesh/owner.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/constant/polyMesh/owner.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/constant/polyMesh/points.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChenHuangwei/CDSFoam-deepflame/43e3d9a7b52c24e613e94ee81a0c811a0f3ac23f/example/oneD_reactiveShockTube/constant/polyMesh/points.gz -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/constant/thermophysicalProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Version: 7 6 | \\/ M anipulation | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "constant"; 14 | object thermophysicalProperties; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | inviscid false; 18 | // ************************************************************************* // 19 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/constant/turbulenceProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Version: 7 6 | \\/ M anipulation | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "constant"; 14 | object turbulenceProperties; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | simulationType laminar; 19 | 20 | 21 | // ************************************************************************* // 22 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/system/blockMeshDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Version: 7 6 | \\/ M anipulation | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object blockMeshDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | convertToMeters 0.1; 18 | 19 | vertices 20 | ( 21 | (0 0 0) 22 | (1.2 0 0) 23 | (1.2 1 0) 24 | (0 1 0) 25 | (0 0 1) 26 | (1.2 0 1) 27 | (1.2 1 1) 28 | (0 1 1) 29 | ); 30 | 31 | blocks 32 | ( 33 | hex (0 1 2 3 4 5 6 7) (2400 1 1) simpleGrading (1 1 1) 34 | ); 35 | 36 | edges 37 | ( 38 | ); 39 | 40 | boundary 41 | ( 42 | Left 43 | { 44 | type patch; 45 | faces 46 | ( 47 | (0 4 7 3) 48 | ); 49 | } 50 | Right 51 | { 52 | type patch; 53 | faces 54 | ( 55 | (1 2 6 5) 56 | ); 57 | } 58 | empty 59 | { 60 | type empty; 61 | faces 62 | ( 63 | (0 1 5 4) 64 | (5 6 7 4) 65 | (3 7 6 2) 66 | (0 3 2 1) 67 | ); 68 | } 69 | ); 70 | 71 | mergePatchPairs 72 | ( 73 | ); 74 | 75 | // ************************************************************************* // 76 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/system/controlDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Version: 7 6 | \\/ M anipulation | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object controlDict; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | application dfHighSpeedFoam; 19 | 20 | startFrom startTime; 21 | 22 | startTime 0; 23 | 24 | stopAt endTime; 25 | 26 | endTime 23e-5; 27 | 28 | deltaT 1e-08; 29 | 30 | writeControl adjustableRunTime; 31 | 32 | writeInterval 1e-5; 33 | 34 | cycleWrite 0; 35 | 36 | writeFormat ascii; 37 | 38 | writePrecision 6; 39 | 40 | writeCompression on; 41 | 42 | timeFormat general; 43 | 44 | timePrecision 6; 45 | 46 | runTimeModifiable true; 47 | 48 | adjustTimeStep yes; 49 | 50 | maxCo 0.1; 51 | 52 | maxDeltaT 1; 53 | 54 | // ************************************************************************* // 55 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/system/decomposeParDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Version: 7 6 | \\/ M anipulation | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object decomposeParDict; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | numberOfSubdomains 8; 19 | 20 | method scotch; 21 | 22 | // ************************************************************************* // 23 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/system/fvSchemes: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Version: 7 6 | \\/ M anipulation | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object fvSchemes; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | fluxScheme HLLCP;//Kurganov; 19 | 20 | ddtSchemes 21 | { 22 | default Euler; 23 | } 24 | 25 | //timeScheme RK3SSP; 26 | gradSchemes 27 | { 28 | default Gauss linear; 29 | } 30 | 31 | divSchemes 32 | { 33 | default none; 34 | div(tauMC) Gauss linear; 35 | div(hDiffCorrFlux) Gauss cubic; 36 | div(phi,Yi_h) Gauss vanLeer; 37 | div(phic,Yi) Gauss vanLeer; 38 | } 39 | 40 | laplacianSchemes 41 | { 42 | default Gauss linear uncorrected; 43 | } 44 | 45 | interpolationSchemes 46 | { 47 | default linear; 48 | reconstruct(rho) Minmod; 49 | reconstruct(U) MinmodV; 50 | reconstruct(T) Minmod; 51 | reconstruct(Yi) Minmod; 52 | reconstruct(c) Minmod; 53 | reconstruct(p) Minmod; 54 | reconstruct(e) Minmod; 55 | } 56 | 57 | snGradSchemes 58 | { 59 | default uncorrected; 60 | } 61 | 62 | 63 | // ************************************************************************* // 64 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/system/fvSolution: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Version: 7 6 | \\/ M anipulation | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object fvSolution; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | solvers 19 | { 20 | U 21 | { 22 | //solver smoothSolver; 23 | //smoother GaussSeidel; 24 | //nSweeps 2; 25 | //tolerance 1e-17; 26 | //relTol 0; 27 | 28 | solver PBiCGStab; 29 | preconditioner DIC; 30 | tolerance 1e-11; 31 | relTol 0; 32 | } 33 | 34 | h 35 | { 36 | $U; 37 | tolerance 1e-11; 38 | relTol 0; 39 | } 40 | 41 | ea 42 | { 43 | $U; 44 | tolerance 1e-11; 45 | relTol 0; 46 | } 47 | 48 | "rho.*" 49 | { 50 | solver diagonal; 51 | } 52 | 53 | "(O2|N2|Yi)" 54 | { 55 | solver PBiCGStab; 56 | preconditioner DILU; 57 | tolerance 1e-11; 58 | relTol 0; 59 | } 60 | 61 | } 62 | 63 | CENTRAL 64 | { 65 | } 66 | 67 | // ************************************************************************* // 68 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/system/sample: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Version: 7 6 | \\/ M anipulation | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object sample; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | type sets; 19 | libs ("libsampling.so"); 20 | 21 | interpolationScheme cellPoint; 22 | 23 | setFormat raw; 24 | 25 | sets 26 | ( 27 | data 28 | { 29 | type lineFace; 30 | axis x; 31 | start (-4.995 0 0); 32 | end (4.995 0 0); 33 | nPoints 1000; 34 | } 35 | ); 36 | 37 | fields (T mag(U) p); 38 | 39 | // ************************************************************************* // 40 | -------------------------------------------------------------------------------- /example/oneD_reactiveShockTube/system/setFieldsDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Version: 7 6 | \\/ M anipulation | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object setFieldsDict; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | defaultFieldValues 19 | ( 20 | volVectorFieldValue U (0 0 0) 21 | volScalarFieldValue T 378.656 22 | volScalarFieldValue p 7173 23 | ); 24 | 25 | regions 26 | ( 27 | boxToCell 28 | { 29 | box (0.06 -0.1 -0.1) (0.12 0.1 0.1); 30 | fieldValues 31 | ( 32 | volVectorFieldValue U (-487.34 0 0) 33 | volScalarFieldValue T 748.472 34 | volScalarFieldValue p 35594 35 | ); 36 | } 37 | ); 38 | 39 | 40 | // ************************************************************************* // 41 | -------------------------------------------------------------------------------- /fluxSchemes/AUSMPlus/AUSMPlus.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2019 Synthetik Applied Technologies 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is derivative work of OpenFOAM. 10 | OpenFOAM is free software: you can redistribute it and/or modify it 11 | under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 | for more details. 18 | You should have received a copy of the GNU General Public License 19 | along with OpenFOAM. If not, see . 20 | \*---------------------------------------------------------------------------*/ 21 | 22 | #include "AUSMPlus.H" 23 | #include "addToRunTimeSelectionTable.H" 24 | 25 | // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // 26 | 27 | namespace Foam 28 | { 29 | namespace fluxSchemes 30 | { 31 | defineTypeNameAndDebug(AUSMPlus, 0); 32 | addToRunTimeSelectionTable(fluxScheme, AUSMPlus, dictionary); 33 | } 34 | } 35 | 36 | 37 | // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 38 | 39 | Foam::fluxSchemes::AUSMPlus::AUSMPlus(const fvMesh& mesh) 40 | : 41 | fluxScheme(mesh) 42 | {} 43 | 44 | 45 | // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // 46 | 47 | Foam::fluxSchemes::AUSMPlus::~AUSMPlus() 48 | {} 49 | 50 | 51 | // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // 52 | 53 | void Foam::fluxSchemes::AUSMPlus::clear() 54 | { 55 | fluxScheme::clear(); 56 | phi_.clear(); 57 | } 58 | 59 | void Foam::fluxSchemes::AUSMPlus::createSavedFields() 60 | { 61 | fluxScheme::createSavedFields(); 62 | if (phi_.valid()) 63 | { 64 | return; 65 | } 66 | phi_ = tmp 67 | ( 68 | new surfaceScalarField 69 | ( 70 | IOobject 71 | ( 72 | "AUSMPlus::phi", 73 | mesh_.time().timeName(), 74 | mesh_ 75 | ), 76 | mesh_, 77 | dimensionedScalar("0", dimVelocity*dimArea, 0.0) 78 | ) 79 | ); 80 | } 81 | 82 | 83 | void Foam::fluxSchemes::AUSMPlus::calculateFluxes 84 | ( 85 | const scalar& rhoOwn, const scalar& rhoNei, 86 | const vector& UOwn, const vector& UNei, 87 | const scalar& eOwn, const scalar& eNei, 88 | const scalar& pOwn, const scalar& pNei, 89 | const scalar& cOwn, const scalar& cNei, 90 | const vector& Sf, 91 | scalar& phi, 92 | scalar& rhoPhi, 93 | vector& rhoUPhi, 94 | scalar& rhoEPhi, 95 | const label facei, const label patchi 96 | ) 97 | { 98 | scalar magSf = mag(Sf); 99 | vector normal = Sf/magSf; 100 | 101 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 102 | scalar HOwn(EOwn + pOwn/rhoOwn); 103 | 104 | scalar ENei = eNei + 0.5*magSqr(UNei); 105 | scalar HNei(ENei + pNei/rhoNei); 106 | 107 | const scalar vMesh(meshPhi(facei, patchi)/magSf); 108 | scalar UvOwn((UOwn & normal) - vMesh); 109 | scalar UvNei((UNei & normal) - vMesh); 110 | 111 | scalar c12(0.5*(cOwn + cNei)); 112 | 113 | // Compute split Mach numbers 114 | scalar MaOwn(UvOwn/c12); 115 | scalar MaNei(UvNei/c12); 116 | scalar magMaOwn(mag(MaOwn)); 117 | scalar magMaNei(mag(MaNei)); 118 | 119 | scalar Ma4Own(max(MaOwn, 0.0)); 120 | scalar P5Own(pos0(MaOwn)); 121 | if (magMaOwn < 1) 122 | { 123 | Ma4Own = 0.25*sqr(MaOwn + 1.0) + beta_*sqr(sqr(MaOwn) - 1.0); 124 | P5Own = 125 | 0.25*sqr(MaOwn + 1.0)*(2.0 - MaOwn) 126 | + alpha_*MaOwn*sqr(sqr(MaOwn) - 1.0); 127 | } 128 | 129 | scalar Ma4Nei(min(MaNei, 0.0)); 130 | scalar P5Nei(neg(MaNei)); 131 | if (magMaNei < 1) 132 | { 133 | Ma4Nei = -0.25*sqr(MaNei - 1.0) - beta_*sqr(sqr(MaNei) - 1.0); 134 | P5Nei = 135 | 0.25*sqr(MaNei - 1.0)*(2.0 + MaNei) 136 | - alpha_*MaNei*sqr(sqr(MaNei) - 1.0); 137 | } 138 | scalar Ma12(Ma4Own + Ma4Nei); 139 | scalar P12(P5Own*pOwn + P5Nei*pNei); 140 | 141 | phi = magSf*c12*Ma12; 142 | 143 | this->save(facei, patchi, phi, phi_); 144 | 145 | scalar p; 146 | if (Ma12 >= 0) 147 | { 148 | this->save(facei, patchi, UOwn, Uf_); 149 | rhoPhi = rhoOwn; 150 | rhoUPhi = rhoOwn*UOwn; 151 | rhoEPhi = rhoOwn*HOwn; 152 | p = pOwn; 153 | } 154 | else 155 | { 156 | this->save(facei, patchi, UNei, Uf_); 157 | rhoPhi = rhoNei; 158 | rhoUPhi = rhoNei*UNei; 159 | rhoEPhi = rhoNei*HNei; 160 | p = pNei; 161 | } 162 | rhoPhi *= phi; 163 | rhoUPhi *= phi; 164 | rhoUPhi += P12*Sf; 165 | rhoEPhi *= phi; 166 | rhoEPhi += vMesh*magSf*p; 167 | } 168 | 169 | 170 | void Foam::fluxSchemes::AUSMPlus::calculateFluxes 171 | ( 172 | const scalarList& alphasOwn, const scalarList& alphasNei, 173 | const scalarList& rhosOwn, const scalarList& rhosNei, 174 | const scalar& rhoOwn, const scalar& rhoNei, 175 | const vector& UOwn, const vector& UNei, 176 | const scalar& eOwn, const scalar& eNei, 177 | const scalar& pOwn, const scalar& pNei, 178 | const scalar& cOwn, const scalar& cNei, 179 | const vector& Sf, 180 | scalar& phi, 181 | scalarList& alphaPhis, 182 | scalarList& alphaRhoPhis, 183 | vector& rhoUPhi, 184 | scalar& rhoEPhi, 185 | const label facei, const label patchi 186 | ) 187 | { 188 | scalar magSf = mag(Sf); 189 | vector normal = Sf/magSf; 190 | 191 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 192 | scalar ENei = eNei + 0.5*magSqr(UNei); 193 | 194 | const scalar vMesh(meshPhi(facei, patchi)/magSf); 195 | scalar UvOwn((UOwn & normal) - vMesh); 196 | scalar UvNei((UNei & normal) - vMesh); 197 | 198 | scalar c12(0.5*(cOwn + cNei)); 199 | 200 | // Compute split Mach numbers 201 | scalar MaOwn(UvOwn/c12); 202 | scalar MaNei(UvNei/c12); 203 | scalar magMaOwn(mag(MaOwn)); 204 | scalar magMaNei(mag(MaNei)); 205 | 206 | scalar Ma4Own(max(MaOwn, 0.0)); 207 | scalar P5Own(pos0(MaOwn)); 208 | if (magMaOwn < 1) 209 | { 210 | Ma4Own = 0.25*sqr(MaOwn + 1.0) + beta_*sqr(sqr(MaOwn) - 1.0); 211 | P5Own = 212 | 0.25*sqr(MaOwn + 1.0)*(2.0 - MaOwn) 213 | + alpha_*MaOwn*sqr(sqr(MaOwn) - 1.0); 214 | } 215 | 216 | scalar Ma4Nei(min(MaNei, 0.0)); 217 | scalar P5Nei(neg(MaNei)); 218 | if (magMaNei < 1) 219 | { 220 | Ma4Nei = -0.25*sqr(MaNei - 1.0) - beta_*sqr(sqr(MaNei) - 1.0); 221 | P5Nei = 222 | 0.25*sqr(MaNei - 1.0)*(2.0 + MaNei) 223 | - alpha_*MaNei*sqr(sqr(MaNei) - 1.0); 224 | } 225 | scalar Ma12(Ma4Own + Ma4Nei); 226 | scalar P12(P5Own*pOwn + P5Nei*pNei); 227 | 228 | phi = magSf*c12*Ma12; 229 | 230 | this->save(facei, patchi, phi, phi_); 231 | 232 | scalar p; 233 | if (Ma12 >= 0) 234 | { 235 | this->save(facei, patchi, UOwn, Uf_); 236 | rhoUPhi = rhoOwn*UOwn; 237 | rhoEPhi = rhoOwn*EOwn + pOwn; 238 | p = pOwn; 239 | forAll(alphasOwn, phasei) 240 | { 241 | alphaPhis[phasei] = alphasOwn[phasei]; 242 | alphaRhoPhis[phasei] = alphasOwn[phasei]*rhosOwn[phasei]; 243 | } 244 | } 245 | else 246 | { 247 | this->save(facei, patchi, UNei, Uf_); 248 | rhoUPhi = rhoNei*UNei; 249 | rhoEPhi = rhoNei*ENei + pNei; 250 | p = pNei; 251 | forAll(alphasNei, phasei) 252 | { 253 | alphaPhis[phasei] = alphasNei[phasei]; 254 | alphaRhoPhis[phasei] = alphasNei[phasei]*rhosNei[phasei]; 255 | } 256 | } 257 | rhoUPhi *= phi; 258 | rhoUPhi += P12*Sf; 259 | rhoEPhi *= phi; 260 | rhoEPhi += vMesh*magSf*p; 261 | 262 | forAll(alphasOwn, phasei) 263 | { 264 | alphaPhis[phasei] *= phi; 265 | alphaRhoPhis[phasei] *= phi; 266 | } 267 | } 268 | 269 | 270 | Foam::scalar Foam::fluxSchemes::AUSMPlus::energyFlux 271 | ( 272 | const scalar& rhoOwn, const scalar& rhoNei, 273 | const vector& UOwn, const vector& UNei, 274 | const scalar& eOwn, const scalar& eNei, 275 | const scalar& pOwn, const scalar& pNei, 276 | const label facei, const label patchi 277 | ) const 278 | { 279 | scalar phi = getValue(facei, patchi, phi_()); 280 | if ( phi >= 0) 281 | { 282 | return 283 | phi*(rhoOwn*(eOwn + 0.5*magSqr(UOwn)) + pOwn) 284 | + meshPhi(facei, patchi)*pOwn; 285 | } 286 | else 287 | { 288 | return 289 | phi*(rhoNei*(eNei + 0.5*magSqr(UNei)) + pNei) 290 | + meshPhi(facei, patchi)*pNei; 291 | } 292 | } 293 | 294 | 295 | Foam::scalar Foam::fluxSchemes::AUSMPlus::interpolate 296 | ( 297 | const scalar& fOwn, const scalar& fNei, 298 | const label facei, const label patchi 299 | ) const 300 | { 301 | 302 | if (getValue(facei, patchi, phi_()) >= 0) 303 | { 304 | return fOwn; 305 | } 306 | else 307 | { 308 | return fNei; 309 | } 310 | } 311 | -------------------------------------------------------------------------------- /fluxSchemes/AUSMPlus/AUSMPlus.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2019 Synthetik Applied Technologies 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is derivative work of OpenFOAM. 10 | OpenFOAM is free software: you can redistribute it and/or modify it 11 | under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 | for more details. 18 | You should have received a copy of the GNU General Public License 19 | along with OpenFOAM. If not, see . 20 | Class 21 | Foam::fluxSchemes::AUSMPlus 22 | Description 23 | Computes flux using AUSM+ scheme 24 | References: 25 | \verbatim 26 | Liou, Meng-Sing (1996). 27 | A Sequel to AUSM: AUSM+. 28 | Journal of Computational Physics, 129, 364-382. 29 | \endverbatim 30 | SourceFiles 31 | AUSMPlus.C 32 | \*---------------------------------------------------------------------------*/ 33 | 34 | #ifndef AUSMPlus_H 35 | #define AUSMPlus_H 36 | 37 | #include "fluxScheme.H" 38 | 39 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 40 | 41 | namespace Foam 42 | { 43 | namespace fluxSchemes 44 | { 45 | 46 | /*---------------------------------------------------------------------------*\ 47 | Class AUSMPlus Declaration 48 | \*---------------------------------------------------------------------------*/ 49 | 50 | class AUSMPlus 51 | : 52 | public fluxScheme 53 | { 54 | // Private Data 55 | 56 | //- Coefficients 57 | scalar alpha_ = 3.0/16.0; 58 | scalar beta_ = 0.125; 59 | 60 | //- Saved flux 61 | tmp phi_; 62 | 63 | 64 | // Private functions 65 | 66 | //- Calcualte fluxes 67 | virtual void calculateFluxes 68 | ( 69 | const scalar& rhoOwn, const scalar& rhoNei, 70 | const vector& UOwn, const vector& UNei, 71 | const scalar& eOwn, const scalar& eNei, 72 | const scalar& pOwn, const scalar& pNei, 73 | const scalar& cOwn, const scalar& cNei, 74 | const vector& Sf, 75 | scalar& phi, 76 | scalar& rhoPhi, 77 | vector& rhoUPhi, 78 | scalar& rhoEPhi, 79 | const label facei, const label patchi = -1 80 | ); 81 | 82 | //- Calcualte fluxes 83 | virtual void calculateFluxes 84 | ( 85 | const scalarList& alphasOwn, const scalarList& alphasNei, 86 | const scalarList& rhosOwn, const scalarList& rhosNei, 87 | const scalar& rhoOwn, const scalar& rhoNei, 88 | const vector& UOwn, const vector& UNei, 89 | const scalar& eOwn, const scalar& eNei, 90 | const scalar& pOwn, const scalar& pNei, 91 | const scalar& cOwn, const scalar& cNei, 92 | const vector& Sf, 93 | scalar& phi, 94 | scalarList& alphaPhis, 95 | scalarList& alphaRhoPhis, 96 | vector& rhoUPhi, 97 | scalar& rhoEPhi, 98 | const label facei, const label patchi = -1 99 | ); 100 | 101 | //- Calculate energy flux for an addition internal energy 102 | virtual scalar energyFlux 103 | ( 104 | const scalar& rhoOwn, const scalar& rhoNei, 105 | const vector& UOwn, const vector& UNei, 106 | const scalar& eOwn, const scalar& eNei, 107 | const scalar& pOwn, const scalar& pNei, 108 | const label facei, const label patchi = -1 109 | ) const; 110 | 111 | //- Interpolate field 112 | virtual scalar interpolate 113 | ( 114 | const scalar& fOwn, const scalar& fNei, 115 | const label facei, const label patchi = -1 116 | ) const; 117 | 118 | 119 | public: 120 | 121 | //- Runtime type information 122 | TypeName("AUSM+"); 123 | 124 | // Costructor 125 | AUSMPlus(const fvMesh& mesh); 126 | 127 | 128 | //- Destructor 129 | virtual ~AUSMPlus(); 130 | 131 | 132 | // Member Functions 133 | 134 | //- Clear savedFields 135 | virtual void clear(); 136 | 137 | //- Allocate saved fields 138 | virtual void createSavedFields(); 139 | }; 140 | 141 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 142 | 143 | } // End namespace Foam 144 | } // End namespace fluxSchemes 145 | 146 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 147 | 148 | #endif 149 | -------------------------------------------------------------------------------- /fluxSchemes/AUSMPlusUp/AUSMPlusUp.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2019 Synthetik Applied Technologies 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is derivative work of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | \*---------------------------------------------------------------------------*/ 25 | 26 | #include "AUSMPlusUp.H" 27 | #include "addToRunTimeSelectionTable.H" 28 | 29 | // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // 30 | 31 | namespace Foam 32 | { 33 | namespace fluxSchemes 34 | { 35 | defineTypeNameAndDebug(AUSMPlusUp, 0); 36 | addToRunTimeSelectionTable(fluxScheme, AUSMPlusUp, dictionary); 37 | } 38 | } 39 | 40 | 41 | // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 42 | 43 | Foam::fluxSchemes::AUSMPlusUp::AUSMPlusUp(const fvMesh& mesh) 44 | : 45 | fluxScheme(mesh) 46 | {} 47 | 48 | 49 | // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // 50 | 51 | Foam::fluxSchemes::AUSMPlusUp::~AUSMPlusUp() 52 | {} 53 | 54 | 55 | // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // 56 | 57 | void Foam::fluxSchemes::AUSMPlusUp::clear() 58 | { 59 | fluxScheme::clear(); 60 | phi_.clear(); 61 | } 62 | 63 | void Foam::fluxSchemes::AUSMPlusUp::createSavedFields() 64 | { 65 | fluxScheme::createSavedFields(); 66 | if (phi_.valid()) 67 | { 68 | return; 69 | } 70 | phi_ = tmp 71 | ( 72 | new surfaceScalarField 73 | ( 74 | IOobject 75 | ( 76 | "AUSMPlusUp::phi", 77 | mesh_.time().timeName(), 78 | mesh_ 79 | ), 80 | mesh_, 81 | dimensionedScalar("0", dimVelocity*dimArea, 0.0) 82 | ) 83 | ); 84 | } 85 | 86 | 87 | void Foam::fluxSchemes::AUSMPlusUp::calculateFluxes 88 | ( 89 | const scalar& rhoOwn, const scalar& rhoNei, 90 | const vector& UOwn, const vector& UNei, 91 | const scalar& eOwn, const scalar& eNei, 92 | const scalar& pOwn, const scalar& pNei, 93 | const scalar& cOwn, const scalar& cNei, 94 | const vector& Sf, 95 | scalar& phi, 96 | scalar& rhoPhi, 97 | vector& rhoUPhi, 98 | scalar& rhoEPhi, 99 | const label facei, const label patchi 100 | ) 101 | { 102 | scalar magSf = mag(Sf); 103 | vector normal = Sf/magSf; 104 | 105 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 106 | scalar HOwn(EOwn + pOwn/rhoOwn); 107 | 108 | scalar ENei = eNei + 0.5*magSqr(UNei); 109 | scalar HNei(ENei + pNei/rhoNei); 110 | 111 | const scalar vMesh(meshPhi(facei, patchi)/magSf); 112 | scalar UvOwn((UOwn & normal) - vMesh); 113 | scalar UvNei((UNei & normal) - vMesh); 114 | 115 | scalar c12(sqrt((sqr(cOwn) + sqr(cNei))/2.0)); 116 | 117 | // Compute split Mach numbers 118 | scalar MaOwn(UvOwn/c12); 119 | scalar MaNei(UvNei/c12); 120 | 121 | scalar MaBarSqr((sqr(UvOwn) + sqr(UvNei))/(2.0*sqr(c12))); 122 | 123 | scalar Ma12 124 | ( 125 | M4(MaOwn, 1) 126 | + M4(MaNei, -1) 127 | - 2.0*Kp_/fa_*max(1.0 - sigma_*MaBarSqr, 0.0)*(pNei - pOwn) 128 | /((rhoOwn + rhoNei)*sqr(c12)) 129 | ); 130 | 131 | scalar P5Own = P5(MaOwn, 1); 132 | scalar P5Nei = P5(MaNei, -1); 133 | 134 | scalar P12 135 | ( 136 | P5Own*pOwn 137 | + P5Nei*pNei 138 | - Ku_*fa_*c12*P5Own*P5Nei 139 | *(rhoOwn + rhoNei)*(UvNei - UvOwn) 140 | ); 141 | 142 | phi = magSf*c12*Ma12; 143 | 144 | this->save(facei, patchi, phi, phi_); 145 | 146 | scalar p; 147 | if (Ma12 >= 0) 148 | { 149 | this->save(facei, patchi, UOwn, Uf_); 150 | rhoPhi = rhoOwn; 151 | rhoUPhi = rhoOwn*UOwn; 152 | rhoEPhi = rhoOwn*HOwn; 153 | p = pOwn; 154 | } 155 | else 156 | { 157 | this->save(facei, patchi, UNei, Uf_); 158 | rhoPhi = rhoNei; 159 | rhoUPhi = rhoNei*UNei; 160 | rhoEPhi = rhoNei*HNei; 161 | p = pNei; 162 | } 163 | rhoPhi *= phi; 164 | rhoUPhi *= phi; 165 | rhoUPhi += P12*Sf; 166 | rhoEPhi *= phi; 167 | rhoEPhi += vMesh*magSf*p; 168 | } 169 | 170 | 171 | void Foam::fluxSchemes::AUSMPlusUp::calculateFluxes 172 | ( 173 | const scalarList& alphasOwn, const scalarList& alphasNei, 174 | const scalarList& rhosOwn, const scalarList& rhosNei, 175 | const scalar& rhoOwn, const scalar& rhoNei, 176 | const vector& UOwn, const vector& UNei, 177 | const scalar& eOwn, const scalar& eNei, 178 | const scalar& pOwn, const scalar& pNei, 179 | const scalar& cOwn, const scalar& cNei, 180 | const vector& Sf, 181 | scalar& phi, 182 | scalarList& alphaPhis, 183 | scalarList& alphaRhoPhis, 184 | vector& rhoUPhi, 185 | scalar& rhoEPhi, 186 | const label facei, const label patchi 187 | ) 188 | { 189 | scalar magSf = mag(Sf); 190 | vector normal = Sf/magSf; 191 | 192 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 193 | scalar ENei = eNei + 0.5*magSqr(UNei); 194 | 195 | const scalar vMesh(meshPhi(facei, patchi)/magSf); 196 | scalar UvOwn((UOwn & normal) - vMesh); 197 | scalar UvNei((UNei & normal) - vMesh); 198 | 199 | scalar c12(sqrt((sqr(cOwn) + sqr(cNei))/2.0)); 200 | 201 | // Compute split Mach numbers 202 | scalar MaOwn(UvOwn/c12); 203 | scalar MaNei(UvNei/c12); 204 | 205 | scalar MaBarSqr((sqr(UvOwn) + sqr(UvNei))/(2.0*sqr(c12))); 206 | 207 | scalar Ma12 208 | ( 209 | M4(MaOwn, 1) 210 | + M4(MaNei, -1) 211 | - 2.0*Kp_/fa_*max(1.0 - sigma_*MaBarSqr, 0.0)*(pNei - pOwn) 212 | /((rhoOwn + rhoNei)*sqr(c12)) 213 | ); 214 | 215 | scalar P5Own = P5(MaOwn, 1); 216 | scalar P5Nei = P5(MaNei, -1); 217 | 218 | scalar P12 219 | ( 220 | P5Own*pOwn 221 | + P5Nei*pNei 222 | - Ku_*fa_*c12*P5Own*P5Nei 223 | *(rhoOwn + rhoNei)*(UvNei - UvOwn) 224 | ); 225 | 226 | phi = magSf*c12*Ma12; 227 | 228 | this->save(facei, patchi, phi, phi_); 229 | 230 | scalar p; 231 | if (Ma12 >= 0) 232 | { 233 | this->save(facei, patchi, UOwn, Uf_); 234 | rhoUPhi = rhoOwn*UOwn; 235 | rhoEPhi = rhoOwn*EOwn + pOwn; 236 | p = pOwn; 237 | forAll(alphasOwn, phasei) 238 | { 239 | alphaPhis[phasei] = alphasOwn[phasei]; 240 | alphaRhoPhis[phasei] = alphasOwn[phasei]*rhosOwn[phasei]; 241 | } 242 | } 243 | else 244 | { 245 | this->save(facei, patchi, UNei, Uf_); 246 | rhoUPhi = rhoNei*UNei; 247 | rhoEPhi = rhoNei*ENei + pNei; 248 | p = pNei; 249 | forAll(alphasNei, phasei) 250 | { 251 | alphaPhis[phasei] = alphasNei[phasei]; 252 | alphaRhoPhis[phasei] = alphasNei[phasei]*rhosNei[phasei]; 253 | } 254 | } 255 | rhoUPhi *= phi; 256 | rhoUPhi += P12*Sf; 257 | rhoEPhi *= phi; 258 | rhoEPhi += vMesh*magSf*p; 259 | 260 | forAll(alphasOwn, phasei) 261 | { 262 | alphaPhis[phasei] *= phi; 263 | alphaRhoPhis[phasei] *= phi; 264 | } 265 | } 266 | 267 | 268 | Foam::scalar Foam::fluxSchemes::AUSMPlusUp::energyFlux 269 | ( 270 | const scalar& rhoOwn, const scalar& rhoNei, 271 | const vector& UOwn, const vector& UNei, 272 | const scalar& eOwn, const scalar& eNei, 273 | const scalar& pOwn, const scalar& pNei, 274 | const label facei, const label patchi 275 | ) const 276 | { 277 | scalar phi = getValue(facei, patchi, phi_()); 278 | if ( phi >= 0) 279 | { 280 | return 281 | phi*(rhoOwn*(eOwn + 0.5*magSqr(UOwn)) + pOwn) 282 | + meshPhi(facei, patchi)*pOwn; 283 | } 284 | else 285 | { 286 | return 287 | phi*(rhoNei*(eNei + 0.5*magSqr(UNei)) + pNei) 288 | + meshPhi(facei, patchi)*pNei; 289 | } 290 | } 291 | 292 | 293 | Foam::scalar Foam::fluxSchemes::AUSMPlusUp::interpolate 294 | ( 295 | const scalar& fOwn, const scalar& fNei, 296 | const label facei, const label patchi 297 | ) const 298 | { 299 | 300 | if (getValue(facei, patchi, phi_()) >= 0) 301 | { 302 | return fOwn; 303 | } 304 | else 305 | { 306 | return fNei; 307 | } 308 | } 309 | -------------------------------------------------------------------------------- /fluxSchemes/AUSMPlusUp/AUSMPlusUp.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2019 Synthetik Applied Technologies 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is derivative work of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Class 25 | Foam::fluxSchemes::AUSMPlusUp 26 | 27 | Description 28 | Computes flux using AUSM+up scheme with low speed correction 29 | 30 | References: 31 | \verbatim 32 | Liou, Meng-Sing (2006). 33 | A sequel to AUSM, Part II: AUSM+-up for all speeds. 34 | Journal of Computational Physics, 214, 137-170. 35 | \endverbatim 36 | 37 | SourceFiles 38 | AUSMPlusUp.C 39 | 40 | \*---------------------------------------------------------------------------*/ 41 | 42 | #ifndef AUSMPlusUp_H 43 | #define AUSMPlusUp_H 44 | 45 | #include "fluxScheme.H" 46 | 47 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 48 | 49 | namespace Foam 50 | { 51 | namespace fluxSchemes 52 | { 53 | 54 | /*---------------------------------------------------------------------------*\ 55 | Class AUSMPlusUp Declaration 56 | \*---------------------------------------------------------------------------*/ 57 | 58 | class AUSMPlusUp 59 | : 60 | public fluxScheme 61 | { 62 | // Private Data 63 | 64 | //- Coefficients 65 | scalar beta_ = 0.125; 66 | scalar Kp_ = 0.25; 67 | scalar Ku_ = 0.75; 68 | scalar sigma_ = 1.0; 69 | scalar fa_ = 1.0; 70 | scalar alpha_ = 3.0/16.0*(5.0*sqr(fa_) - 4.0); 71 | 72 | //- Saved flux 73 | tmp phi_; 74 | 75 | 76 | // Private functions 77 | 78 | //- Calcualte fluxes 79 | virtual void calculateFluxes 80 | ( 81 | const scalar& rhoOwn, const scalar& rhoNei, 82 | const vector& UOwn, const vector& UNei, 83 | const scalar& eOwn, const scalar& eNei, 84 | const scalar& pOwn, const scalar& pNei, 85 | const scalar& cOwn, const scalar& cNei, 86 | const vector& Sf, 87 | scalar& phi, 88 | scalar& rhoPhi, 89 | vector& rhoUPhi, 90 | scalar& rhoEPhi, 91 | const label facei, const label patchi = -1 92 | ); 93 | 94 | //- Calcualte fluxes 95 | virtual void calculateFluxes 96 | ( 97 | const scalarList& alphasOwn, const scalarList& alphasNei, 98 | const scalarList& rhosOwn, const scalarList& rhosNei, 99 | const scalar& rhoOwn, const scalar& rhoNei, 100 | const vector& UOwn, const vector& UNei, 101 | const scalar& eOwn, const scalar& eNei, 102 | const scalar& pOwn, const scalar& pNei, 103 | const scalar& cOwn, const scalar& cNei, 104 | const vector& Sf, 105 | scalar& phi, 106 | scalarList& alphaPhis, 107 | scalarList& alphaRhoPhis, 108 | vector& rhoUPhi, 109 | scalar& rhoEPhi, 110 | const label facei, const label patchi = -1 111 | ); 112 | 113 | //- Calculate energy flux for an addition internal energy 114 | virtual scalar energyFlux 115 | ( 116 | const scalar& rhoOwn, const scalar& rhoNei, 117 | const vector& UOwn, const vector& UNei, 118 | const scalar& eOwn, const scalar& eNei, 119 | const scalar& pOwn, const scalar& pNei, 120 | const label facei, const label patchi = -1 121 | ) const; 122 | 123 | //- Interpolate field 124 | virtual scalar interpolate 125 | ( 126 | const scalar& fOwn, const scalar& fNei, 127 | const label facei, const label patchi = -1 128 | ) const; 129 | 130 | // Mach number polynomials 131 | 132 | //- First order 133 | scalar M1(const scalar& Ma, const label sign) const 134 | { 135 | return 0.5*(Ma + sign*mag(Ma)); 136 | } 137 | 138 | //- Second order 139 | scalar M2(const scalar& Ma, const label sign) const 140 | { 141 | if (mag(Ma) >= 1.0) 142 | { 143 | return M1(Ma, sign); 144 | } 145 | return sign*0.25*sqr(Ma + sign*1.0); 146 | } 147 | 148 | //- Fourth order 149 | scalar M4(const scalar& Ma, const label sign) const 150 | { 151 | if (mag(Ma) >= 1.0) 152 | { 153 | return M1(Ma, sign); 154 | } 155 | return sign*0.25*sqr(Ma + sign) + sign*beta_*sqr(sqr(Ma) - 1.0); 156 | } 157 | 158 | //- Fifth order 159 | scalar P5(const scalar& Ma, const label sign) const 160 | { 161 | if (mag(Ma) >= 1.0) 162 | { 163 | return 0.5*(1.0 + sign*Foam::sign(Ma)); 164 | } 165 | return 166 | 0.25*sqr(Ma + sign)*(2.0 - sign*Ma) 167 | + sign*alpha_*Ma*sqr(sqr(Ma) - 1.0); 168 | } 169 | 170 | 171 | public: 172 | 173 | //- Runtime type information 174 | TypeName("AUSM+up"); 175 | 176 | // Costructor 177 | AUSMPlusUp(const fvMesh& mesh); 178 | 179 | 180 | //- Destructor 181 | virtual ~AUSMPlusUp(); 182 | 183 | 184 | // Member Functions 185 | 186 | //- Clear savedFields 187 | virtual void clear(); 188 | 189 | //- Allocate saved fields 190 | virtual void createSavedFields(); 191 | }; 192 | 193 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 194 | 195 | } // End namespace Foam 196 | } // End namespace fluxSchemes 197 | 198 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 199 | 200 | #endif 201 | -------------------------------------------------------------------------------- /fluxSchemes/HLL/HLL.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2019 Synthetik Applied Technologies 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is derivative work of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | \*---------------------------------------------------------------------------*/ 25 | 26 | #include "HLL.H" 27 | #include "addToRunTimeSelectionTable.H" 28 | 29 | // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // 30 | 31 | namespace Foam 32 | { 33 | namespace fluxSchemes 34 | { 35 | defineTypeNameAndDebug(HLL, 0); 36 | addToRunTimeSelectionTable(fluxScheme, HLL, dictionary); 37 | } 38 | } 39 | 40 | 41 | // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 42 | 43 | Foam::fluxSchemes::HLL::HLL 44 | ( 45 | const fvMesh& mesh 46 | ) 47 | : 48 | fluxScheme(mesh) 49 | {} 50 | 51 | 52 | // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // 53 | 54 | Foam::fluxSchemes::HLL::~HLL() 55 | {} 56 | 57 | 58 | // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 59 | 60 | void Foam::fluxSchemes::HLL::clear() 61 | { 62 | fluxScheme::clear(); 63 | if (SOwn_.valid()) 64 | { 65 | return; 66 | } 67 | 68 | SOwn_.clear(); 69 | SNei_.clear(); 70 | UvOwn_.clear(); 71 | UvNei_.clear(); 72 | } 73 | 74 | void Foam::fluxSchemes::HLL::createSavedFields() 75 | { 76 | fluxScheme::createSavedFields(); 77 | if (SOwn_.valid()) 78 | { 79 | return; 80 | } 81 | 82 | SOwn_ = tmp 83 | ( 84 | new surfaceScalarField 85 | ( 86 | IOobject 87 | ( 88 | "HLL::SOwn", 89 | mesh_.time().timeName(), 90 | mesh_ 91 | ), 92 | mesh_, 93 | dimensionedScalar("0", dimVelocity, 0.0) 94 | ) 95 | ); 96 | SNei_ = tmp 97 | ( 98 | new surfaceScalarField 99 | ( 100 | IOobject 101 | ( 102 | "HLL::SNei", 103 | mesh_.time().timeName(), 104 | mesh_ 105 | ), 106 | mesh_, 107 | dimensionedScalar("0", dimVelocity, 0.0) 108 | ) 109 | ); 110 | UvOwn_ = tmp 111 | ( 112 | new surfaceScalarField 113 | ( 114 | IOobject 115 | ( 116 | "HLL::UvOwn", 117 | mesh_.time().timeName(), 118 | mesh_ 119 | ), 120 | mesh_, 121 | dimensionedScalar("0", dimVelocity, 0.0) 122 | ) 123 | ); 124 | UvNei_ = tmp 125 | ( 126 | new surfaceScalarField 127 | ( 128 | IOobject 129 | ( 130 | "HLL::UvNei", 131 | mesh_.time().timeName(), 132 | mesh_ 133 | ), 134 | mesh_, 135 | dimensionedScalar("0", dimVelocity, 0.0) 136 | ) 137 | ); 138 | } 139 | 140 | 141 | void Foam::fluxSchemes::HLL::calculateFluxes 142 | ( 143 | const scalar& rhoOwn, const scalar& rhoNei, 144 | const vector& UOwn, const vector& UNei, 145 | const scalar& eOwn, const scalar& eNei, 146 | const scalar& pOwn, const scalar& pNei, 147 | const scalar& cOwn, const scalar& cNei, 148 | const vector& Sf, 149 | scalar& phi, 150 | scalar& rhoPhi, 151 | vector& rhoUPhi, 152 | scalar& rhoEPhi, 153 | const label facei, const label patchi 154 | ) 155 | { 156 | scalar magSf = mag(Sf); 157 | vector normal = Sf/magSf; 158 | 159 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 160 | scalar HOwn(EOwn + pOwn/rhoOwn); 161 | 162 | scalar ENei = eNei + 0.5*magSqr(UNei); 163 | scalar HNei(ENei + pNei/rhoNei); 164 | 165 | const scalar vMesh(meshPhi(facei, patchi)/magSf); 166 | scalar UvOwn((UOwn & normal) - vMesh); 167 | scalar UvNei((UNei & normal) - vMesh); 168 | 169 | scalar wOwn(sqrt(rhoOwn)/(sqrt(rhoOwn) + sqrt(rhoNei))); 170 | scalar wNei(1.0 - wOwn); 171 | 172 | scalar cTilde(cOwn*wOwn + cNei*wNei); 173 | scalar UvTilde(UvOwn*wOwn + UvNei*wNei); 174 | 175 | scalar SOwn(min(UvOwn - cOwn, UvTilde - cTilde)); 176 | scalar SNei(max(UvNei + cNei, UvTilde + cTilde)); 177 | 178 | this->save(facei, patchi, SOwn, SOwn_); 179 | this->save(facei, patchi, SNei, SNei_); 180 | this->save(facei, patchi, UvOwn, UvOwn_); 181 | this->save(facei, patchi, UvNei, UvNei_); 182 | 183 | scalar p; 184 | if (SOwn >= 0) 185 | { 186 | phi = this->save(facei, patchi, UOwn, Uf_) & normal; 187 | rhoPhi = rhoOwn*UvOwn; 188 | rhoUPhi = UOwn*rhoOwn*UvOwn + pOwn*normal; 189 | rhoEPhi = UvOwn*rhoOwn*HOwn; 190 | p = pOwn; 191 | } 192 | else if (SOwn < 0 && SNei >= 0) 193 | { 194 | vector rhoUOwn = rhoOwn*UOwn; 195 | vector rhoUNei = rhoNei*UNei; 196 | scalar rhoPhiOwn = rhoOwn*UvOwn; 197 | scalar rhoPhiNei = rhoNei*UvNei; 198 | vector rhoUPhiOwn = rhoUOwn*UvOwn + pOwn*normal; 199 | vector rhoUPhiNei = rhoUNei*UvNei + pNei*normal; 200 | phi = 201 | this->save 202 | ( 203 | facei, 204 | patchi, 205 | (SNei*rhoUNei - SOwn*rhoUOwn + rhoUPhiOwn - rhoUPhiNei) 206 | /(SNei*rhoNei - SOwn*rhoOwn + rhoPhiOwn - rhoPhiNei), 207 | Uf_ 208 | ) & normal; 209 | 210 | rhoPhi = 211 | ( 212 | SNei*rhoOwn*UvOwn - SOwn*rhoNei*UvNei 213 | + SOwn*SNei*(rhoNei - rhoOwn) 214 | )/(SNei - SOwn); 215 | 216 | rhoUPhi = 217 | ( 218 | SNei*rhoUPhiOwn - SOwn*rhoUPhiNei 219 | + SOwn*SNei*(rhoUNei - rhoUOwn) 220 | )/(SNei - SOwn); 221 | 222 | rhoEPhi = 223 | ( 224 | SNei*rhoOwn*HOwn*UvOwn 225 | - SOwn*rhoNei*HNei*UvNei 226 | + SOwn*SNei 227 | *( 228 | rhoNei*ENei 229 | - rhoOwn*EOwn 230 | ) 231 | )/(SNei - SOwn); 232 | p = (SNei*pOwn - SOwn*pNei)/(SNei - SOwn); 233 | } 234 | else 235 | { 236 | phi = this->save(facei, patchi, UNei, Uf_) & normal; 237 | rhoPhi = rhoNei*UvNei; 238 | rhoUPhi = UNei*rhoNei*UvNei + pNei*normal; 239 | rhoEPhi = rhoNei*HNei*UvNei; 240 | p = pNei; 241 | } 242 | phi *= magSf; 243 | rhoPhi *= magSf; 244 | rhoUPhi *= magSf; 245 | rhoEPhi *= magSf; 246 | rhoEPhi += vMesh*magSf*p; 247 | } 248 | 249 | 250 | void Foam::fluxSchemes::HLL::calculateFluxes 251 | ( 252 | const scalarList& alphasOwn, const scalarList& alphasNei, 253 | const scalarList& rhosOwn, const scalarList& rhosNei, 254 | const scalar& rhoOwn, const scalar& rhoNei, 255 | const vector& UOwn, const vector& UNei, 256 | const scalar& eOwn, const scalar& eNei, 257 | const scalar& pOwn, const scalar& pNei, 258 | const scalar& cOwn, const scalar& cNei, 259 | const vector& Sf, 260 | scalar& phi, 261 | scalarList& alphaPhis, 262 | scalarList& alphaRhoPhis, 263 | vector& rhoUPhi, 264 | scalar& rhoEPhi, 265 | const label facei, const label patchi 266 | ) 267 | { 268 | scalar magSf = mag(Sf); 269 | vector normal = Sf/magSf; 270 | 271 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 272 | scalar HOwn(EOwn + pOwn/rhoOwn); 273 | 274 | scalar ENei = eNei + 0.5*magSqr(UNei); 275 | scalar HNei(ENei + pNei/rhoNei); 276 | 277 | const scalar vMesh(meshPhi(facei, patchi)/magSf); 278 | scalar UvOwn((UOwn & normal) - vMesh); 279 | scalar UvNei((UNei & normal) - vMesh); 280 | 281 | scalar wOwn(sqrt(rhoOwn)/(sqrt(rhoOwn) + sqrt(rhoNei))); 282 | scalar wNei(1.0 - wOwn); 283 | 284 | scalar cTilde(cOwn*wOwn + cNei*wNei); 285 | scalar UvTilde(UvOwn*wOwn + UvNei*wNei); 286 | 287 | scalar SOwn(min(UvOwn - cOwn, UvTilde - cTilde)); 288 | scalar SNei(max(UvNei + cNei, UvTilde + cTilde)); 289 | 290 | this->save(facei, patchi, SOwn, SOwn_); 291 | this->save(facei, patchi, SNei, SNei_); 292 | this->save(facei, patchi, UvOwn, UvOwn_); 293 | this->save(facei, patchi, UvNei, UvNei_); 294 | 295 | scalar p; 296 | if (SOwn >= 0) 297 | { 298 | phi = this->save(facei, patchi, UOwn, Uf_) & normal; 299 | rhoUPhi = UOwn*rhoOwn*UvOwn + pOwn*normal; 300 | rhoEPhi = UvOwn*rhoOwn*HOwn; 301 | p = pOwn; 302 | 303 | forAll(alphasOwn, phasei) 304 | { 305 | alphaPhis[phasei] = alphasOwn[phasei]*UvOwn; 306 | alphaRhoPhis[phasei] = alphasOwn[phasei]*rhosOwn[phasei]*UvOwn; 307 | } 308 | } 309 | else if (SOwn < 0 && SNei >= 0) 310 | { 311 | vector rhoUOwn = rhoOwn*UOwn; 312 | vector rhoUNei = rhoNei*UNei; 313 | scalar rhoPhiOwn = rhoOwn*UvOwn; 314 | scalar rhoPhiNei = rhoNei*UvNei; 315 | vector rhoUPhiOwn = rhoUOwn*UvOwn + pOwn*normal; 316 | vector rhoUPhiNei = rhoUNei*UvNei + pNei*normal; 317 | phi = 318 | this->save 319 | ( 320 | facei, 321 | patchi, 322 | (SNei*rhoUNei - SOwn*rhoUOwn + rhoUPhiOwn - rhoUPhiNei) 323 | /(SNei*rhoNei - SOwn*rhoOwn + rhoPhiOwn - rhoPhiNei), 324 | Uf_ 325 | ) & normal; 326 | 327 | rhoUPhi = 328 | ( 329 | SNei*(rhoUOwn*UvOwn + pOwn*normal) 330 | - SOwn*(rhoUNei*UvNei + pNei*normal) 331 | + SOwn*SNei*(rhoUNei - rhoUOwn) 332 | )/(SNei - SOwn); 333 | p = (SNei*pOwn - SOwn*pNei)/(SNei - SOwn); 334 | 335 | rhoEPhi = 336 | ( 337 | SNei*rhoOwn*HOwn*UvOwn 338 | - SOwn*rhoNei*HNei*UvNei 339 | + SOwn*SNei 340 | *( 341 | rhoNei*ENei 342 | - rhoOwn*EOwn 343 | ) 344 | )/(SNei - SOwn); 345 | 346 | forAll(alphasOwn, phasei) 347 | { 348 | alphaPhis[phasei] = 349 | ( 350 | SNei*alphasOwn[phasei]*UvOwn - SOwn*alphasNei[phasei]*UvNei 351 | + SOwn*SNei*(alphasNei[phasei] - alphasOwn[phasei]) 352 | )/(SNei - SOwn); 353 | 354 | scalar alphaRhoOwn = alphasOwn[phasei]*rhosOwn[phasei]; 355 | scalar alphaRhoNei = alphasNei[phasei]*rhosNei[phasei]; 356 | alphaRhoPhis[phasei] = 357 | ( 358 | SNei*alphaRhoOwn*UvOwn - SOwn*alphaRhoNei*UvNei 359 | + SOwn*SNei*(alphaRhoNei - alphaRhoOwn) 360 | )/(SNei - SOwn); 361 | } 362 | } 363 | else 364 | { 365 | phi = this->save(facei, patchi, UNei, Uf_) & normal; 366 | rhoUPhi = UNei*rhoNei*UvNei + pNei*normal; 367 | rhoEPhi = rhoNei*HNei*UvNei; 368 | p = pNei; 369 | 370 | forAll(alphasOwn, phasei) 371 | { 372 | alphaPhis[phasei] = alphasNei[phasei]*UvNei; 373 | alphaRhoPhis[phasei] = alphasNei[phasei]*rhosNei[phasei]*UvNei; 374 | } 375 | } 376 | phi *= magSf; 377 | rhoUPhi *= magSf; 378 | rhoEPhi *= magSf; 379 | rhoEPhi += vMesh*magSf*p; 380 | forAll(alphasOwn, phasei) 381 | { 382 | alphaPhis[phasei] *= magSf; 383 | alphaRhoPhis[phasei] *= magSf; 384 | } 385 | } 386 | 387 | 388 | Foam::scalar Foam::fluxSchemes::HLL::energyFlux 389 | ( 390 | const scalar& rhoOwn, const scalar& rhoNei, 391 | const vector& UOwn, const vector& UNei, 392 | const scalar& eOwn, const scalar& eNei, 393 | const scalar& pOwn, const scalar& pNei, 394 | const label facei, const label patchi 395 | ) const 396 | { 397 | scalar SOwn = getValue(facei, patchi, SOwn_()); 398 | scalar SNei = getValue(facei, patchi, SNei_()); 399 | scalar UvOwn = getValue(facei, patchi, UvOwn_()); 400 | scalar UvNei = getValue(facei, patchi, UvNei_()); 401 | scalar magSf = mag(getValue(facei, patchi, mesh_.Sf())); 402 | 403 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 404 | scalar HOwn = EOwn + pOwn/rhoOwn; 405 | 406 | scalar ENei = eNei + 0.5*magSqr(UNei); 407 | scalar HNei = ENei + pNei/rhoNei; 408 | 409 | scalar phi, p; 410 | if (SOwn >= 0) 411 | { 412 | phi = UvOwn*rhoOwn*HOwn + meshPhi(facei, patchi)*pOwn; 413 | p = pOwn; 414 | } 415 | else if (SOwn < 0 && SNei >= 0) 416 | { 417 | phi = 418 | ( 419 | SNei*rhoOwn*HOwn*UvOwn 420 | - SOwn*rhoNei*HNei*UvNei 421 | + SOwn*SNei 422 | *( 423 | rhoNei*ENei 424 | - rhoOwn*EOwn 425 | ) 426 | )/(SNei - SOwn); 427 | p = (SNei*pOwn - SOwn*pNei)/(SNei - SOwn); 428 | } 429 | else 430 | { 431 | phi = rhoNei*HNei*UvNei + meshPhi(facei, patchi)*pNei; 432 | p = pNei; 433 | } 434 | return phi*magSf + meshPhi(facei, patchi)*p; 435 | } 436 | 437 | 438 | Foam::scalar Foam::fluxSchemes::HLL::interpolate 439 | ( 440 | const scalar& fOwn, const scalar& fNei, 441 | const label facei, const label patchi 442 | ) const 443 | { 444 | scalar SOwn = getValue(facei, patchi, SOwn_()); 445 | scalar SNei = getValue(facei, patchi, SNei_()); 446 | scalar UvOwn = getValue(facei, patchi, UvOwn_()); 447 | scalar UvNei = getValue(facei, patchi, UvNei_()); 448 | 449 | if (SOwn >= 0) 450 | { 451 | return fOwn; 452 | } 453 | else if (SOwn < 0 && SNei >= 0) 454 | { 455 | return 456 | (SNei*fNei - SOwn*fOwn + fOwn*UvOwn + fNei*UvNei)/(SNei - SOwn); 457 | } 458 | else 459 | { 460 | return fNei; 461 | } 462 | } 463 | 464 | // ************************************************************************* // 465 | -------------------------------------------------------------------------------- /fluxSchemes/HLL/HLL.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2019 Synthetik Applied Technologies 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is derivative work of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Class 25 | Foam::fluxSchemes::HLL 26 | 27 | Description 28 | 29 | References: 30 | \verbatim 31 | Toro, E.F., Spruce, M., Speares, W. (1993). 32 | Restoration of the contact surface in the HLL-Riemann solver. 33 | Shock Waves, 4, 25-34. 34 | \endverbatim 35 | 36 | SourceFiles 37 | HLL.C 38 | 39 | \*---------------------------------------------------------------------------*/ 40 | 41 | #ifndef HLL_H 42 | #define HLL_H 43 | 44 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 45 | 46 | #include "fluxScheme.H" 47 | 48 | namespace Foam 49 | { 50 | namespace fluxSchemes 51 | { 52 | 53 | /*---------------------------------------------------------------------------*\ 54 | Class HLL Declaration 55 | \*---------------------------------------------------------------------------*/ 56 | 57 | class HLL 58 | : 59 | public fluxScheme 60 | { 61 | 62 | // Saved variables 63 | 64 | tmp SOwn_; 65 | tmp SNei_; 66 | tmp UvOwn_; 67 | tmp UvNei_; 68 | 69 | 70 | // Private functions 71 | 72 | //- Calcualte fluxes 73 | virtual void calculateFluxes 74 | ( 75 | const scalar& rhoOwn, const scalar& rhoNei, 76 | const vector& UOwn, const vector& UNei, 77 | const scalar& eOwn, const scalar& eNei, 78 | const scalar& pOwn, const scalar& pNei, 79 | const scalar& cOwn, const scalar& cNei, 80 | const vector& Sf, 81 | scalar& phi, 82 | scalar& rhoPhi, 83 | vector& rhoUPhi, 84 | scalar& rhoEPhi, 85 | const label facei, const label patchi = -1 86 | ); 87 | 88 | //- Calcualte fluxes 89 | virtual void calculateFluxes 90 | ( 91 | const scalarList& alphasOwn, const scalarList& alphasNei, 92 | const scalarList& rhosOwn, const scalarList& rhosNei, 93 | const scalar& rhoOwn, const scalar& rhoNei, 94 | const vector& UOwn, const vector& UNei, 95 | const scalar& eOwn, const scalar& eNei, 96 | const scalar& pOwn, const scalar& pNei, 97 | const scalar& cOwn, const scalar& cNei, 98 | const vector& Sf, 99 | scalar& phi, 100 | scalarList& alphaPhis, 101 | scalarList& alphaRhoPhis, 102 | vector& rhoUPhi, 103 | scalar& rhoEPhi, 104 | const label facei, const label patchi = -1 105 | ); 106 | 107 | //- Calculate energy flux for an addition internal energy 108 | virtual scalar energyFlux 109 | ( 110 | const scalar& rhoOwn, const scalar& rhoNei, 111 | const vector& UOwn, const vector& UNei, 112 | const scalar& eOwn, const scalar& eNei, 113 | const scalar& pOwn, const scalar& pNei, 114 | const label facei, const label patchi = -1 115 | ) const; 116 | 117 | //- Interpolate field 118 | virtual scalar interpolate 119 | ( 120 | const scalar& fOwn, const scalar& fNei, 121 | const label facei, const label patchi = -1 122 | ) const; 123 | 124 | 125 | public: 126 | 127 | //- Runtime type information 128 | TypeName("HLL"); 129 | 130 | // Constructor 131 | HLL(const fvMesh& mesh); 132 | 133 | 134 | //- Destructor 135 | virtual ~HLL(); 136 | 137 | 138 | // Member Functions 139 | 140 | //- Clear savedFields 141 | virtual void clear(); 142 | 143 | //- Allocate saved fields 144 | virtual void createSavedFields(); 145 | }; 146 | 147 | 148 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 149 | 150 | } // End namespace fluxSchemes 151 | } // End namespace Foam 152 | 153 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 154 | 155 | #endif 156 | 157 | // ************************************************************************* // 158 | -------------------------------------------------------------------------------- /fluxSchemes/HLLC/HLLC.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2019 Synthetik Applied Technologies 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is derivative work of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | \*---------------------------------------------------------------------------*/ 25 | 26 | #include "HLLC.H" 27 | #include "addToRunTimeSelectionTable.H" 28 | 29 | // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // 30 | 31 | namespace Foam 32 | { 33 | namespace fluxSchemes 34 | { 35 | defineTypeNameAndDebug(HLLC, 0); 36 | addToRunTimeSelectionTable(fluxScheme, HLLC, dictionary); 37 | } 38 | } 39 | 40 | 41 | // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 42 | 43 | Foam::fluxSchemes::HLLC::HLLC 44 | ( 45 | const fvMesh& mesh 46 | ) 47 | : 48 | fluxScheme(mesh) 49 | {} 50 | 51 | 52 | // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // 53 | 54 | Foam::fluxSchemes::HLLC::~HLLC() 55 | {} 56 | 57 | 58 | // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 59 | 60 | 61 | void Foam::fluxSchemes::HLLC::clear() 62 | { 63 | fluxScheme::clear(); 64 | SOwn_.clear(); 65 | SNei_.clear(); 66 | SStar_.clear(); 67 | pStarOwn_.clear(); 68 | pStarNei_.clear(); 69 | UvOwn_.clear(); 70 | UvNei_.clear(); 71 | } 72 | 73 | void Foam::fluxSchemes::HLLC::createSavedFields() 74 | { 75 | fluxScheme::createSavedFields(); 76 | if (SOwn_.valid()) 77 | { 78 | return; 79 | } 80 | SOwn_ = tmp 81 | ( 82 | new surfaceScalarField 83 | ( 84 | IOobject 85 | ( 86 | "HLLC::SOwn", 87 | mesh_.time().timeName(), 88 | mesh_ 89 | ), 90 | mesh_, 91 | dimensionedScalar("0", dimVelocity, 0.0) 92 | ) 93 | ); 94 | SNei_ = tmp 95 | ( 96 | new surfaceScalarField 97 | ( 98 | IOobject 99 | ( 100 | "HLLC::SNei", 101 | mesh_.time().timeName(), 102 | mesh_ 103 | ), 104 | mesh_, 105 | dimensionedScalar("0", dimVelocity, 0.0) 106 | ) 107 | ); 108 | SStar_ = tmp 109 | ( 110 | new surfaceScalarField 111 | ( 112 | IOobject 113 | ( 114 | "HLLC::SStar", 115 | mesh_.time().timeName(), 116 | mesh_ 117 | ), 118 | mesh_, 119 | dimensionedScalar("0", dimVelocity, 0.0) 120 | ) 121 | ); 122 | pStarOwn_ = tmp 123 | ( 124 | new surfaceScalarField 125 | ( 126 | IOobject 127 | ( 128 | "HLLC::pStarOwn", 129 | mesh_.time().timeName(), 130 | mesh_ 131 | ), 132 | mesh_, 133 | dimensionedScalar("0", dimPressure, 0.0) 134 | ) 135 | ); 136 | pStarNei_ = tmp 137 | ( 138 | new surfaceScalarField 139 | ( 140 | IOobject 141 | ( 142 | "HLLC::pStarNei", 143 | mesh_.time().timeName(), 144 | mesh_ 145 | ), 146 | mesh_, 147 | dimensionedScalar("0", dimPressure, 0.0) 148 | ) 149 | ); 150 | UvOwn_ = tmp 151 | ( 152 | new surfaceScalarField 153 | ( 154 | IOobject 155 | ( 156 | "HLLC::UvOwn", 157 | mesh_.time().timeName(), 158 | mesh_ 159 | ), 160 | mesh_, 161 | dimensionedScalar("0", dimVelocity, 0.0) 162 | ) 163 | ); 164 | UvNei_ = tmp 165 | ( 166 | new surfaceScalarField 167 | ( 168 | IOobject 169 | ( 170 | "HLLC::UvNei", 171 | mesh_.time().timeName(), 172 | mesh_ 173 | ), 174 | mesh_, 175 | dimensionedScalar("0", dimVelocity, 0.0) 176 | ) 177 | ); 178 | } 179 | 180 | 181 | void Foam::fluxSchemes::HLLC::calculateFluxes 182 | ( 183 | const scalar& rhoOwn, const scalar& rhoNei, 184 | const vector& UOwn, const vector& UNei, 185 | const scalar& eOwn, const scalar& eNei, 186 | const scalar& pOwn, const scalar& pNei, 187 | const scalar& cOwn, const scalar& cNei, 188 | const vector& Sf, 189 | scalar& phi, 190 | scalar& rhoPhi, 191 | vector& rhoUPhi, 192 | scalar& rhoEPhi, 193 | const label facei, const label patchi 194 | ) 195 | { 196 | scalar magSf = mag(Sf); 197 | vector normal = Sf/magSf; 198 | 199 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 200 | scalar ENei = eNei + 0.5*magSqr(UNei); 201 | 202 | const scalar vMesh(meshPhi(facei, patchi)/magSf); 203 | scalar UvOwn((UOwn & normal) - vMesh); 204 | scalar UvNei((UNei & normal) - vMesh); 205 | 206 | scalar wOwn(sqrt(rhoOwn)/(sqrt(rhoOwn) + sqrt(rhoNei))); 207 | scalar wNei(1.0 - wOwn); 208 | 209 | scalar cTilde(cOwn*wOwn + cNei*wNei); 210 | scalar UvTilde(UvOwn*wOwn + UvNei*wNei); 211 | 212 | scalar SOwn(min(UvOwn - cOwn, UvTilde - cTilde)); 213 | scalar SNei(max(UvNei + cNei, UvTilde + cTilde)); 214 | 215 | scalar SStar 216 | ( 217 | ( 218 | pNei - pOwn 219 | + rhoOwn*UvOwn*(SOwn - UvOwn) 220 | - rhoNei*UvNei*(SNei - UvNei) 221 | ) 222 | /(rhoOwn*(SOwn - UvOwn) - rhoNei*(SNei - UvNei)) 223 | ); 224 | 225 | scalar pStarOwn(pOwn + rhoOwn*(SOwn - UvOwn)*(SStar - UvOwn)); 226 | scalar pStarNei(pNei + rhoNei*(SNei - UvNei)*(SStar - UvNei)); 227 | 228 | this->save(facei, patchi, SOwn, SOwn_); 229 | this->save(facei, patchi, SNei, SNei_); 230 | this->save(facei, patchi, SStar, SStar_); 231 | this->save(facei, patchi, pStarOwn, pStarOwn_); 232 | this->save(facei, patchi, pStarNei, pStarNei_); 233 | this->save(facei, patchi, UvOwn, UvOwn_); 234 | this->save(facei, patchi, UvNei, UvNei_); 235 | 236 | // Owner values 237 | const vector rhoUOwn = rhoOwn*UOwn; 238 | const scalar rhoEOwn = rhoOwn*EOwn; 239 | 240 | const vector rhoUPhiOwn = rhoUOwn*UvOwn + pOwn*normal; 241 | const scalar rhoEPhiOwn = (rhoEOwn + pOwn)*UvOwn; 242 | 243 | // Neighbour values 244 | const vector rhoUNei = rhoNei*UNei; 245 | const scalar rhoENei = rhoNei*ENei; 246 | 247 | const vector rhoUPhiNei = rhoUNei*UvNei + pNei*normal; 248 | const scalar rhoEPhiNei = (rhoENei + pNei)*UvNei; 249 | 250 | scalar p; 251 | if (SOwn > 0) 252 | { 253 | this->save(facei, patchi, UOwn, Uf_); 254 | phi = UvOwn; 255 | rhoPhi = rhoOwn*UvOwn; 256 | p = pOwn; 257 | rhoUPhi = rhoUPhiOwn; 258 | rhoEPhi = rhoEPhiOwn; 259 | } 260 | else if (SStar > 0) 261 | { 262 | const scalar dS = SOwn - SStar; 263 | 264 | this->save 265 | ( 266 | facei, 267 | patchi, 268 | (SOwn*rhoUOwn - rhoUPhiOwn + pStarOwn*normal) 269 | /(rhoOwn*(SOwn - UvOwn)), 270 | Uf_ 271 | ); 272 | phi = SStar; 273 | rhoPhi = phi*rhoOwn*(SOwn - UvOwn)/dS; 274 | p = 0.5*(pStarNei + pStarOwn); 275 | rhoUPhi = 276 | (SStar*(SOwn*rhoUOwn - rhoUPhiOwn) + SOwn*pStarOwn*normal)/dS; 277 | rhoEPhi = SStar*(SOwn*rhoEOwn - rhoEPhiOwn + SOwn*pStarOwn)/dS; 278 | } 279 | else if (SNei > 0) 280 | { 281 | const scalar dS = SNei - SStar; 282 | 283 | this->save 284 | ( 285 | facei, 286 | patchi, 287 | (SNei*rhoUNei - rhoUPhiNei + pStarNei*normal) 288 | /(rhoNei*(SNei - UvNei)), 289 | Uf_ 290 | ); 291 | phi = SStar; 292 | rhoPhi = phi*rhoNei*(SNei - UvNei)/dS; 293 | p = 0.5*(pStarNei + pStarOwn); 294 | rhoUPhi = 295 | (SStar*(SNei*rhoUNei - rhoUPhiNei) + SNei*pStarNei*normal)/dS; 296 | rhoEPhi = SStar*(SNei*rhoENei - rhoEPhiNei + SNei*pStarNei)/dS; 297 | } 298 | else 299 | { 300 | this->save(facei, patchi, UNei, Uf_); 301 | phi = UvNei; 302 | rhoPhi = rhoNei*UvNei; 303 | p = pNei; 304 | rhoUPhi = rhoUPhiNei; 305 | rhoEPhi = rhoEPhiNei; 306 | } 307 | phi *= magSf; 308 | rhoPhi *= magSf; 309 | rhoUPhi *= magSf; 310 | rhoEPhi *= magSf; 311 | rhoEPhi += vMesh*magSf*p; 312 | } 313 | 314 | 315 | void Foam::fluxSchemes::HLLC::calculateFluxes 316 | ( 317 | const scalarList& alphasOwn, const scalarList& alphasNei, 318 | const scalarList& rhosOwn, const scalarList& rhosNei, 319 | const scalar& rhoOwn, const scalar& rhoNei, 320 | const vector& UOwn, const vector& UNei, 321 | const scalar& eOwn, const scalar& eNei, 322 | const scalar& pOwn, const scalar& pNei, 323 | const scalar& cOwn, const scalar& cNei, 324 | const vector& Sf, 325 | scalar& phi, 326 | scalarList& alphaPhis, 327 | scalarList& alphaRhoPhis, 328 | vector& rhoUPhi, 329 | scalar& rhoEPhi, 330 | const label facei, const label patchi 331 | ) 332 | { 333 | scalar magSf = mag(Sf); 334 | vector normal = Sf/magSf; 335 | 336 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 337 | scalar ENei = eNei + 0.5*magSqr(UNei); 338 | 339 | const scalar vMesh(meshPhi(facei, patchi)/magSf); 340 | scalar UvOwn((UOwn & normal) - vMesh); 341 | scalar UvNei((UNei & normal) - vMesh); 342 | 343 | scalar wOwn(sqrt(rhoOwn)/(sqrt(rhoOwn) + sqrt(rhoNei))); 344 | scalar wNei(1.0 - wOwn); 345 | 346 | scalar cTilde(cOwn*wOwn + cNei*wNei); 347 | scalar UvTilde(UvOwn*wOwn + UvNei*wNei); 348 | 349 | scalar SOwn(min(UvOwn - cOwn, UvTilde - cTilde)); 350 | scalar SNei(max(UvNei + cNei, UvTilde + cTilde)); 351 | 352 | scalar SStar 353 | ( 354 | ( 355 | pNei - pOwn 356 | + rhoOwn*UvOwn*(SOwn - UvOwn) 357 | - rhoNei*UvNei*(SNei - UvNei) 358 | ) 359 | /(rhoOwn*(SOwn - UvOwn) - rhoNei*(SNei - UvNei)) 360 | ); 361 | 362 | scalar pStarOwn(pOwn + rhoOwn*(SOwn - UvOwn)*(SStar - UvOwn)); 363 | scalar pStarNei(pNei + rhoNei*(SNei - UvNei)*(SStar - UvNei)); 364 | 365 | this->save(facei, patchi, SOwn, SOwn_); 366 | this->save(facei, patchi, SNei, SNei_); 367 | this->save(facei, patchi, SStar, SStar_); 368 | this->save(facei, patchi, pStarOwn, pStarOwn_); 369 | this->save(facei, patchi, pStarNei, pStarNei_); 370 | this->save(facei, patchi, UvOwn, UvOwn_); 371 | this->save(facei, patchi, UvNei, UvNei_); 372 | 373 | // Owner values 374 | const vector rhoUOwn = rhoOwn*UOwn; 375 | const scalar rhoEOwn = rhoOwn*EOwn; 376 | 377 | const vector rhoUPhiOwn = rhoUOwn*UvOwn + pOwn*normal; 378 | const scalar rhoEPhiOwn = (rhoEOwn + pOwn)*UvOwn; 379 | 380 | // Neighbour values 381 | const vector rhoUNei = rhoNei*UNei; 382 | const scalar rhoENei = rhoNei*ENei; 383 | 384 | const vector rhoUPhiNei = rhoUNei*UvNei + pNei*normal; 385 | const scalar rhoEPhiNei = (rhoENei + pNei)*UvNei; 386 | 387 | scalar p; 388 | if (SOwn > 0) 389 | { 390 | this->save(facei, patchi, UOwn, Uf_); 391 | phi = UvOwn; 392 | rhoUPhi = rhoUPhiOwn; 393 | p = pOwn; 394 | rhoEPhi = rhoEPhiOwn; 395 | 396 | forAll(alphaPhis, phasei) 397 | { 398 | alphaPhis[phasei] = alphasOwn[phasei]*UvOwn; 399 | alphaRhoPhis[phasei] = alphasOwn[phasei]*rhosOwn[phasei]*UvOwn; 400 | } 401 | } 402 | else if (SStar > 0) 403 | { 404 | const scalar dS = SOwn - SStar; 405 | 406 | this->save 407 | ( 408 | facei, 409 | patchi, 410 | (SOwn*rhoUOwn - rhoUPhiOwn + pStarOwn*normal) 411 | /(rhoOwn*(SOwn - UvOwn)), 412 | Uf_ 413 | ); 414 | 415 | scalar f = (SOwn - UvOwn)/dS; 416 | phi = SStar*f; 417 | 418 | rhoUPhi = 419 | (SStar*(SOwn*rhoUOwn - rhoUPhiOwn) + SOwn*pStarOwn*normal)/dS; 420 | p = 0.5*(pStarNei + pStarOwn); 421 | rhoEPhi = SStar*(SOwn*rhoEOwn - rhoEPhiOwn + SOwn*pStarOwn)/dS; 422 | 423 | forAll(alphaPhis, phasei) 424 | { 425 | alphaPhis[phasei] = alphasOwn[phasei]*SStar*f; 426 | alphaRhoPhis[phasei] = alphasOwn[phasei]*rhosOwn[phasei]*SStar*f; 427 | } 428 | } 429 | else if (SNei > 0) 430 | { 431 | const scalar dS = SNei - SStar; 432 | 433 | this->save 434 | ( 435 | facei, 436 | patchi, 437 | (SNei*rhoUNei - rhoUPhiNei + pStarNei*normal) 438 | /(rhoNei*(SNei - UvNei)), 439 | Uf_ 440 | ); 441 | 442 | scalar f = (SNei - UvNei)/dS; 443 | phi = SStar*f; 444 | 445 | rhoUPhi = 446 | (SStar*(SNei*rhoUNei - rhoUPhiNei) + SNei*pStarNei*normal)/dS; 447 | p = 0.5*(pStarNei + pStarOwn); 448 | rhoEPhi = SStar*(SNei*(rhoENei + pStarNei) - rhoEPhiNei)/dS; 449 | 450 | forAll(alphaPhis, phasei) 451 | { 452 | alphaPhis[phasei] = alphasNei[phasei]*SStar*f; 453 | alphaRhoPhis[phasei] = alphasNei[phasei]*rhosNei[phasei]*SStar*f; 454 | } 455 | } 456 | else 457 | { 458 | this->save(facei, patchi, UNei, Uf_); 459 | phi = UvNei; 460 | rhoUPhi = rhoUPhiNei; 461 | p = pNei; 462 | rhoEPhi = rhoEPhiNei; 463 | 464 | forAll(alphaPhis, phasei) 465 | { 466 | alphaPhis[phasei] = alphasNei[phasei]*UvNei; 467 | alphaRhoPhis[phasei] = alphasNei[phasei]*rhosNei[phasei]*UvNei; 468 | } 469 | } 470 | phi *= magSf; 471 | rhoUPhi *= magSf; 472 | rhoEPhi *= magSf; 473 | rhoEPhi += vMesh*magSf*p; 474 | forAll(alphaPhis, phasei) 475 | { 476 | alphaPhis[phasei] *= magSf; 477 | alphaRhoPhis[phasei] *= magSf; 478 | } 479 | } 480 | 481 | 482 | Foam::scalar Foam::fluxSchemes::HLLC::energyFlux 483 | ( 484 | const scalar& rhoOwn, const scalar& rhoNei, 485 | const vector& UOwn, const vector& UNei, 486 | const scalar& eOwn, const scalar& eNei, 487 | const scalar& pOwn, const scalar& pNei, 488 | const label facei, const label patchi 489 | ) const 490 | { 491 | scalar SOwn = getValue(facei, patchi, SOwn_()); 492 | scalar SNei = getValue(facei, patchi, SNei_()); 493 | scalar SStar = getValue(facei, patchi, SStar_()); 494 | scalar pStarOwn = getValue(facei, patchi, pStarOwn_()); 495 | scalar pStarNei = getValue(facei, patchi, pStarNei_()); 496 | scalar UvOwn = getValue(facei, patchi, UvOwn_()); 497 | scalar UvNei = getValue(facei, patchi, UvNei_()); 498 | scalar magSf = mag(getValue(facei, patchi, mesh_.Sf())); 499 | 500 | // Owner values 501 | const scalar rhoEOwn = rhoOwn*(eOwn + 0.5*magSqr(UOwn)); 502 | const scalar rhoEPhiOwn = (rhoEOwn + pOwn)*UvOwn; 503 | 504 | // Neighbour values 505 | const scalar rhoENei = rhoNei*(eNei + 0.5*magSqr(UNei)); 506 | const scalar rhoEPhiNei = (rhoENei + pNei)*UvNei; 507 | 508 | scalar rhoEPhi, p; 509 | if (SOwn > 0) 510 | { 511 | rhoEPhi = rhoEPhiOwn; 512 | p = pOwn; 513 | } 514 | else if (SStar > 0) 515 | { 516 | const scalar dS = SOwn - SStar; 517 | rhoEPhi = SStar*(SOwn*rhoEOwn - rhoEPhiOwn + SOwn*pStarOwn)/dS; 518 | p = 0.5*(pStarNei + pStarOwn); 519 | } 520 | else if (SNei > 0) 521 | { 522 | const scalar dS = SNei - SStar; 523 | rhoEPhi = SStar*(SNei*rhoENei - rhoEPhiNei + SNei*pStarNei)/dS; 524 | p = 0.5*(pStarNei + pStarOwn); 525 | } 526 | else 527 | { 528 | rhoEPhi = rhoEPhiNei; 529 | p = pNei; 530 | } 531 | 532 | return rhoEPhi*magSf + meshPhi(facei, patchi)*p; 533 | } 534 | 535 | 536 | Foam::scalar Foam::fluxSchemes::HLLC::interpolate 537 | ( 538 | const scalar& fOwn, const scalar& fNei, 539 | const label facei, const label patchi 540 | ) const 541 | { 542 | scalar SOwn = getValue(facei, patchi, SOwn_()); 543 | scalar SStar = getValue(facei, patchi, SStar_()); 544 | 545 | if (SOwn > 0 || SStar > 0) 546 | { 547 | return fOwn; 548 | } 549 | else 550 | { 551 | return fNei; 552 | } 553 | } 554 | 555 | // ************************************************************************* // 556 | -------------------------------------------------------------------------------- /fluxSchemes/HLLC/HLLC.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2019 Synthetik Applied Technologies 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is derivative work of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Class 25 | Foam::fluxSchemes::HLLC 26 | 27 | Description 28 | 29 | References: 30 | \verbatim 31 | Toro, E.F., Spruce, M., Speares, W. (1993). 32 | Restoration of the contact surface in the HLL-Riemann solver. 33 | Shock Waves, 4, 25-34. 34 | \endverbatim 35 | 36 | SourceFiles 37 | HLLC.C 38 | 39 | \*---------------------------------------------------------------------------*/ 40 | 41 | #ifndef HLLC_H 42 | #define HLLC_H 43 | 44 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 45 | 46 | #include "fluxScheme.H" 47 | 48 | namespace Foam 49 | { 50 | namespace fluxSchemes 51 | { 52 | 53 | /*---------------------------------------------------------------------------*\ 54 | Class HLLC Declaration 55 | \*---------------------------------------------------------------------------*/ 56 | 57 | class HLLC 58 | : 59 | public fluxScheme 60 | { 61 | 62 | // Saved variables 63 | 64 | tmp SOwn_; 65 | tmp SNei_; 66 | tmp SStar_; 67 | tmp pStarOwn_; 68 | tmp pStarNei_; 69 | tmp UvOwn_; 70 | tmp UvNei_; 71 | 72 | // Private functions 73 | 74 | //- Calcualte fluxes 75 | virtual void calculateFluxes 76 | ( 77 | const scalar& rhoOwn, const scalar& rhoNei, 78 | const vector& UOwn, const vector& UNei, 79 | const scalar& eOwn, const scalar& eNei, 80 | const scalar& pOwn, const scalar& pNei, 81 | const scalar& cOwn, const scalar& cNei, 82 | const vector& Sf, 83 | scalar& phi, 84 | scalar& rhoPhi, 85 | vector& rhoUPhi, 86 | scalar& rhoEPhi, 87 | const label facei, const label patchi = -1 88 | ); 89 | 90 | //- Calcualte fluxes 91 | virtual void calculateFluxes 92 | ( 93 | const scalarList& alphasOwn, const scalarList& alphasNei, 94 | const scalarList& rhosOwn, const scalarList& rhosNei, 95 | const scalar& rhoOwn, const scalar& rhoNei, 96 | const vector& UOwn, const vector& UNei, 97 | const scalar& eOwn, const scalar& eNei, 98 | const scalar& pOwn, const scalar& pNei, 99 | const scalar& cOwn, const scalar& cNei, 100 | const vector& Sf, 101 | scalar& phi, 102 | scalarList& alphaPhis, 103 | scalarList& alphaRhoPhis, 104 | vector& rhoUPhi, 105 | scalar& rhoEPhi, 106 | const label facei, const label patchi = -1 107 | ); 108 | 109 | //- Calculate energy flux for an addition internal energy 110 | virtual scalar energyFlux 111 | ( 112 | const scalar& rhoOwn, const scalar& rhoNei, 113 | const vector& UOwn, const vector& UNei, 114 | const scalar& eOwn, const scalar& eNei, 115 | const scalar& pOwn, const scalar& pNei, 116 | const label facei, const label patchi = -1 117 | ) const; 118 | 119 | //- Interpolate field 120 | virtual scalar interpolate 121 | ( 122 | const scalar& fOwn, const scalar& fNei, 123 | const label facei, const label patchi = -1 124 | ) const; 125 | 126 | 127 | public: 128 | 129 | //- Runtime type information 130 | TypeName("HLLC"); 131 | 132 | // Constructor 133 | HLLC(const fvMesh& mesh); 134 | 135 | 136 | //- Destructor 137 | virtual ~HLLC(); 138 | 139 | 140 | // Member Functions 141 | 142 | //- Clear savedFields 143 | virtual void clear(); 144 | 145 | //- Allocate saved fields 146 | virtual void createSavedFields(); 147 | }; 148 | 149 | 150 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 151 | 152 | } // End namespace fluxSchemes 153 | } // End namespace Foam 154 | 155 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 156 | 157 | #endif 158 | 159 | // ************************************************************************* // 160 | -------------------------------------------------------------------------------- /fluxSchemes/HLLCP/HLLCP.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2019 Synthetik Applied Technologies 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is derivative work of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Class 25 | Foam::fluxSchemes::HLLCP 26 | 27 | Description 28 | 29 | References: 30 | \verbatim 31 | Xie, W., Zheng, R., Lai, J., Li, H. (2018). 32 | An accurate and robust HLLC-type Riemann solver for the compressible 33 | Euler system at various Mach numbers. 34 | Internation Journal of Numberical Methods for Fluids, 89, 430-463. 35 | \endverbatim 36 | 37 | SourceFiles 38 | HLLCP.C 39 | 40 | \*---------------------------------------------------------------------------*/ 41 | 42 | #ifndef HLLCP_H 43 | #define HLLCP_H 44 | 45 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 46 | 47 | #include "fluxScheme.H" 48 | 49 | namespace Foam 50 | { 51 | namespace fluxSchemes 52 | { 53 | 54 | /*---------------------------------------------------------------------------*\ 55 | Class HLLCP Declaration 56 | \*---------------------------------------------------------------------------*/ 57 | 58 | class HLLCP 59 | : 60 | public fluxScheme 61 | { 62 | 63 | // Saved variables 64 | 65 | tmp SOwn_; 66 | tmp SNei_; 67 | tmp SStar_; 68 | tmp pStar_; 69 | tmp phip_; 70 | tmp UTilde_; 71 | tmp UvOwn_; 72 | tmp UvNei_; 73 | 74 | tmp f_; 75 | 76 | // Private functions 77 | 78 | //- Calcualte fluxes 79 | virtual void calculateFluxes 80 | ( 81 | const scalar& rhoOwn, const scalar& rhoNei, 82 | const vector& UOwn, const vector& UNei, 83 | const scalar& eOwn, const scalar& eNei, 84 | const scalar& pOwn, const scalar& pNei, 85 | const scalar& cOwn, const scalar& cNei, 86 | const vector& Sf, 87 | scalar& phi, 88 | scalar& rhoPhi, 89 | vector& rhoUPhi, 90 | scalar& rhoEPhi, 91 | const label facei, const label patchi = -1 92 | ); 93 | 94 | //- Calcualte fluxes 95 | virtual void calculateFluxes 96 | ( 97 | const scalarList& alphasOwn, const scalarList& alphasNei, 98 | const scalarList& rhosOwn, const scalarList& rhosNei, 99 | const scalar& rhoOwn, const scalar& rhoNei, 100 | const vector& UOwn, const vector& UNei, 101 | const scalar& eOwn, const scalar& eNei, 102 | const scalar& pOwn, const scalar& pNei, 103 | const scalar& cOwn, const scalar& cNei, 104 | const vector& Sf, 105 | scalar& phi, 106 | scalarList& alphaPhis, 107 | scalarList& alphaRhoPhis, 108 | vector& rhoUPhi, 109 | scalar& rhoEPhi, 110 | const label facei, const label patchi = -1 111 | ); 112 | 113 | //- Calculate energy flux for an addition internal energy 114 | virtual scalar energyFlux 115 | ( 116 | const scalar& rhoOwn, const scalar& rhoNei, 117 | const vector& UOwn, const vector& UNei, 118 | const scalar& eOwn, const scalar& eNei, 119 | const scalar& pOwn, const scalar& pNei, 120 | const label facei, const label patchi = -1 121 | ) const; 122 | 123 | //- Interpolate field 124 | virtual scalar interpolate 125 | ( 126 | const scalar& fOwn, const scalar& fNei, 127 | const label facei, const label patchi = -1 128 | ) const; 129 | 130 | //- Update fields before calculating fluxes 131 | virtual void preUpdate(const volScalarField& p); 132 | 133 | //- Correct fluxes 134 | virtual void postUpdate(); 135 | 136 | 137 | public: 138 | 139 | //- Runtime type information 140 | TypeName("HLLCP"); 141 | 142 | // Constructor 143 | HLLCP(const fvMesh& mesh); 144 | 145 | 146 | //- Destructor 147 | virtual ~HLLCP(); 148 | 149 | 150 | // Member Functions 151 | 152 | //- Clear savedFields 153 | virtual void clear(); 154 | 155 | //- Allocate saved fields 156 | virtual void createSavedFields(); 157 | }; 158 | 159 | 160 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 161 | 162 | } // End namespace fluxSchemes 163 | } // End namespace Foam 164 | 165 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 166 | 167 | #endif 168 | 169 | // ************************************************************************* // 170 | -------------------------------------------------------------------------------- /fluxSchemes/Kurganov/Kurganov.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | 2019-10-21 Jeff Heylmun: Moved from rhoCentralFoam to runtime selectable 9 | method. 10 | -------------------------------------------------------------------------------License 11 | This file is part of OpenFOAM. 12 | 13 | OpenFOAM is free software: you can redistribute it and/or modify it 14 | under the terms of the GNU General Public License as published by 15 | the Free Software Foundation, either version 3 of the License, or 16 | (at your option) any later version. 17 | 18 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 19 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21 | for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with OpenFOAM. If not, see . 25 | 26 | \*---------------------------------------------------------------------------*/ 27 | 28 | #include "Kurganov.H" 29 | #include "addToRunTimeSelectionTable.H" 30 | 31 | // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // 32 | 33 | namespace Foam 34 | { 35 | namespace fluxSchemes 36 | { 37 | defineTypeNameAndDebug(Kurganov, 0); 38 | addToRunTimeSelectionTable(fluxScheme, Kurganov, dictionary); 39 | } 40 | } 41 | 42 | 43 | // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 44 | 45 | Foam::fluxSchemes::Kurganov::Kurganov 46 | ( 47 | const fvMesh& mesh 48 | ) 49 | : 50 | fluxScheme(mesh) 51 | {} 52 | 53 | 54 | // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // 55 | 56 | Foam::fluxSchemes::Kurganov::~Kurganov() 57 | {} 58 | 59 | 60 | // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 61 | 62 | void Foam::fluxSchemes::Kurganov::clear() 63 | { 64 | fluxScheme::clear(); 65 | aPhivOwn_.clear(); 66 | aPhivNei_.clear(); 67 | aOwn_.clear(); 68 | aNei_.clear(); 69 | aSf_.clear(); 70 | } 71 | 72 | 73 | void Foam::fluxSchemes::Kurganov::createSavedFields() 74 | { 75 | fluxScheme::createSavedFields(); 76 | if (aPhivOwn_.valid()) 77 | { 78 | return; 79 | } 80 | 81 | aPhivOwn_ = tmp 82 | ( 83 | new surfaceScalarField 84 | ( 85 | IOobject 86 | ( 87 | "Kurganov::aPhivOwn", 88 | mesh_.time().timeName(), 89 | mesh_ 90 | ), 91 | mesh_, 92 | dimensionedScalar("0", dimVelocity*dimArea, 0.0) 93 | ) 94 | ); 95 | aPhivNei_ = tmp 96 | ( 97 | new surfaceScalarField 98 | ( 99 | IOobject 100 | ( 101 | "Kurganov::aPhivNei", 102 | mesh_.time().timeName(), 103 | mesh_ 104 | ), 105 | mesh_, 106 | dimensionedScalar("0", dimVelocity*dimArea, 0.0) 107 | ) 108 | ); 109 | 110 | aOwn_ = tmp 111 | ( 112 | new surfaceScalarField 113 | ( 114 | IOobject 115 | ( 116 | "Kurganov::aOwn", 117 | mesh_.time().timeName(), 118 | mesh_ 119 | ), 120 | mesh_, 121 | dimensionedScalar("0", dimless, 0.0) 122 | ) 123 | ); 124 | aNei_ = tmp 125 | ( 126 | new surfaceScalarField 127 | ( 128 | IOobject 129 | ( 130 | "Kurganov::aNei", 131 | mesh_.time().timeName(), 132 | mesh_ 133 | ), 134 | mesh_, 135 | dimensionedScalar("0", dimless, 0.0) 136 | ) 137 | ); 138 | aSf_ = tmp 139 | ( 140 | new surfaceScalarField 141 | ( 142 | IOobject 143 | ( 144 | "Kurganov::aSf", 145 | mesh_.time().timeName(), 146 | mesh_ 147 | ), 148 | mesh_, 149 | dimensionedScalar("0", dimVelocity*dimArea, 0.0) 150 | ) 151 | ); 152 | } 153 | 154 | 155 | void Foam::fluxSchemes::Kurganov::calculateFluxes 156 | ( 157 | const scalar& rhoOwn, const scalar& rhoNei, 158 | const vector& UOwn, const vector& UNei, 159 | const scalar& eOwn, const scalar& eNei, 160 | const scalar& pOwn, const scalar& pNei, 161 | const scalar& cOwn, const scalar& cNei, 162 | const vector& Sf, 163 | scalar& phi, 164 | scalar& rhoPhi, 165 | vector& rhoUPhi, 166 | scalar& rhoEPhi, 167 | const label facei, const label patchi 168 | ) 169 | { 170 | scalar magSf = mag(Sf); 171 | 172 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 173 | scalar ENei = eNei + 0.5*magSqr(UNei); 174 | 175 | scalar phivOwn(UOwn & Sf); 176 | scalar phivNei(UNei & Sf); 177 | 178 | scalar cSfOwn(cOwn*magSf); 179 | scalar cSfNei(cNei*magSf); 180 | 181 | const scalar vMesh(meshPhi(facei, patchi));// 182 | phivOwn -= vMesh; 183 | phivNei -= vMesh; 184 | 185 | scalar ap 186 | ( 187 | max(max(phivOwn + cSfOwn, phivNei + cSfNei), 0.0) 188 | ); 189 | scalar am 190 | ( 191 | min(min(phivOwn - cSfOwn, phivNei - cSfNei), 0.0) 192 | ); 193 | 194 | scalar aOwn(ap/(ap - am)); 195 | scalar aSf(am*aOwn); 196 | scalar aNei(1.0 - aOwn); 197 | 198 | phivOwn *= aOwn; 199 | phivNei *= aNei; 200 | 201 | scalar aphivOwn(phivOwn - aSf); 202 | scalar aphivNei(phivNei + aSf); 203 | 204 | this->save(facei, patchi, aphivOwn, aPhivOwn_); 205 | this->save(facei, patchi, aphivNei, aPhivNei_); 206 | this->save(facei, patchi, aOwn, aOwn_); 207 | this->save(facei, patchi, aNei, aNei_); 208 | this->save(facei, patchi, aSf, aSf_); 209 | 210 | this->save(facei, patchi, aOwn*UOwn + aNei*UNei, Uf_); 211 | phi = aphivOwn + aphivNei; 212 | rhoPhi = aphivOwn*rhoOwn + aphivNei*rhoNei; 213 | 214 | rhoUPhi = 215 | ( 216 | (aphivOwn*rhoOwn*UOwn + aphivNei*rhoNei*UNei) 217 | + (aOwn*pOwn + aNei*pNei)*Sf 218 | ); 219 | 220 | rhoEPhi = 221 | ( 222 | aphivOwn*(rhoOwn*EOwn + pOwn) 223 | + aphivNei*(rhoNei*ENei + pNei) 224 | + aSf*pOwn - aSf*pNei 225 | + vMesh*(aOwn*pOwn + aNei*pNei) 226 | ); 227 | } 228 | 229 | 230 | void Foam::fluxSchemes::Kurganov::calculateFluxes 231 | ( 232 | const scalarList& alphasOwn, const scalarList& alphasNei, 233 | const scalarList& rhosOwn, const scalarList& rhosNei, 234 | const scalar& rhoOwn, const scalar& rhoNei, 235 | const vector& UOwn, const vector& UNei, 236 | const scalar& eOwn, const scalar& eNei, 237 | const scalar& pOwn, const scalar& pNei, 238 | const scalar& cOwn, const scalar& cNei, 239 | const vector& Sf, 240 | scalar& phi, 241 | scalarList& alphaPhis, 242 | scalarList& alphaRhoPhis, 243 | vector& rhoUPhi, 244 | scalar& rhoEPhi, 245 | const label facei, const label patchi 246 | ) 247 | { 248 | scalar magSf = mag(Sf); 249 | 250 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 251 | scalar ENei = eNei + 0.5*magSqr(UNei); 252 | 253 | scalar phivOwn(UOwn & Sf); 254 | scalar phivNei(UNei & Sf); 255 | 256 | scalar cSfOwn(cOwn*magSf); 257 | scalar cSfNei(cNei*magSf); 258 | 259 | const scalar vMesh(meshPhi(facei, patchi)); 260 | phivOwn -= vMesh; 261 | phivNei -= vMesh; 262 | 263 | scalar ap 264 | ( 265 | max(max(phivOwn + cSfOwn, phivNei + cSfNei), 0.0) 266 | ); 267 | scalar am 268 | ( 269 | min(min(phivOwn - cSfOwn, phivNei - cSfNei), 0.0) 270 | ); 271 | 272 | scalar aOwn(ap/(ap - am)); 273 | scalar aSf(am*aOwn); 274 | scalar aNei(1.0 - aOwn); 275 | 276 | phivOwn *= aOwn; 277 | phivNei *= aNei; 278 | 279 | scalar aphivOwn(phivOwn - aSf); 280 | scalar aphivNei(phivNei + aSf); 281 | 282 | this->save(facei, patchi, aphivOwn, aPhivOwn_); 283 | this->save(facei, patchi, aphivNei, aPhivNei_); 284 | this->save(facei, patchi, aOwn, aOwn_); 285 | this->save(facei, patchi, aNei, aNei_); 286 | this->save(facei, patchi, aSf, aSf_); 287 | 288 | this->save(facei, patchi, aOwn*UOwn + aNei*UNei, Uf_); 289 | 290 | phi = aphivOwn + aphivNei; 291 | 292 | forAll(alphasOwn, phasei) 293 | { 294 | alphaPhis[phasei] = 295 | aphivOwn*alphasOwn[phasei] + aphivNei*alphasNei[phasei]; 296 | alphaRhoPhis[phasei] = 297 | aphivOwn*alphasOwn[phasei]*rhosOwn[phasei] 298 | + aphivNei*alphasNei[phasei]*rhosNei[phasei]; 299 | } 300 | 301 | rhoUPhi = 302 | ( 303 | (aphivOwn*rhoOwn*UOwn + aphivNei*rhoNei*UNei) 304 | + (aOwn*pOwn + aNei*pNei)*Sf 305 | ); 306 | 307 | rhoEPhi = 308 | ( 309 | aphivOwn*(rhoOwn*EOwn + pOwn) 310 | + aphivNei*(rhoNei*ENei + pNei) 311 | + aSf*pOwn - aSf*pNei 312 | + vMesh*(aOwn*pOwn + aNei*pNei) 313 | ); 314 | } 315 | 316 | 317 | Foam::scalar Foam::fluxSchemes::Kurganov::energyFlux 318 | ( 319 | const scalar& rhoOwn, const scalar& rhoNei, 320 | const vector& UOwn, const vector& UNei, 321 | const scalar& eOwn, const scalar& eNei, 322 | const scalar& pOwn, const scalar& pNei, 323 | const label facei, const label patchi 324 | ) const 325 | { 326 | scalar aphivOwn = getValue(facei, patchi, aPhivOwn_()); 327 | scalar aphivNei = getValue(facei, patchi, aPhivNei_()); 328 | scalar aOwn = getValue(facei, patchi, aOwn_()); 329 | scalar aNei = getValue(facei, patchi, aNei_()); 330 | scalar aSf = getValue(facei, patchi, aSf_()); 331 | 332 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 333 | scalar ENei = eNei + 0.5*magSqr(UNei); 334 | 335 | 336 | return 337 | ( 338 | aphivOwn*(rhoOwn*EOwn + pOwn) 339 | + aphivNei*(rhoNei*ENei + pNei) 340 | + aSf*pOwn - aSf*pNei 341 | + meshPhi(facei, patchi)*(aOwn*pOwn + aNei*pNei) 342 | ); 343 | } 344 | 345 | 346 | Foam::scalar Foam::fluxSchemes::Kurganov::interpolate 347 | ( 348 | const scalar& fOwn, const scalar& fNei, 349 | const label facei, const label patchi 350 | ) const 351 | { 352 | scalar aOwn = getValue(facei, patchi, aOwn_()); 353 | scalar aNei = getValue(facei, patchi, aNei_()); 354 | 355 | return aOwn*fOwn + aNei*fNei; 356 | } 357 | 358 | // ************************************************************************* // 359 | -------------------------------------------------------------------------------- /fluxSchemes/Kurganov/Kurganov.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | 2019-10-21 Jeff Heylmun: Moved from rhoCentralFoam to runtime selectable 9 | method. 10 | -------------------------------------------------------------------------------License 11 | This file is part of OpenFOAM. 12 | 13 | OpenFOAM is free software: you can redistribute it and/or modify it 14 | under the terms of the GNU General Public License as published by 15 | the Free Software Foundation, either version 3 of the License, or 16 | (at your option) any later version. 17 | 18 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 19 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21 | for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with OpenFOAM. If not, see . 25 | 26 | Class 27 | Foam::fluxSchemes::Kurganov 28 | 29 | Description 30 | 31 | SourceFiles 32 | Kurganov.C 33 | 34 | \*---------------------------------------------------------------------------*/ 35 | 36 | #ifndef Kurganov_H 37 | #define Kurganov_H 38 | 39 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 40 | 41 | #include "fluxScheme.H" 42 | 43 | namespace Foam 44 | { 45 | namespace fluxSchemes 46 | { 47 | 48 | /*---------------------------------------------------------------------------*\ 49 | Class Kurganov Declaration 50 | \*---------------------------------------------------------------------------*/ 51 | 52 | class Kurganov 53 | : 54 | public fluxScheme 55 | { 56 | 57 | // Saved variables 58 | 59 | tmp aPhivOwn_; 60 | tmp aPhivNei_; 61 | tmp aOwn_; 62 | tmp aNei_; 63 | tmp aSf_; 64 | 65 | 66 | // Private functions 67 | 68 | //- Calcualte fluxes 69 | virtual void calculateFluxes 70 | ( 71 | const scalar& rhoOwn, const scalar& rhoNei, 72 | const vector& UOwn, const vector& UNei, 73 | const scalar& eOwn, const scalar& eNei, 74 | const scalar& pOwn, const scalar& pNei, 75 | const scalar& cOwn, const scalar& cNei, 76 | const vector& Sf, 77 | scalar& phi, 78 | scalar& rhoPhi, 79 | vector& rhoUPhi, 80 | scalar& rhoEPhi, 81 | const label facei, const label patchi = -1 82 | ); 83 | 84 | //- Calcualte fluxes 85 | virtual void calculateFluxes 86 | ( 87 | const scalarList& alphasOwn, const scalarList& alphasNei, 88 | const scalarList& rhosOwn, const scalarList& rhosNei, 89 | const scalar& rhoOwn, const scalar& rhoNei, 90 | const vector& UOwn, const vector& UNei, 91 | const scalar& eOwn, const scalar& eNei, 92 | const scalar& pOwn, const scalar& pNei, 93 | const scalar& cOwn, const scalar& cNei, 94 | const vector& Sf, 95 | scalar& phi, 96 | scalarList& alphaPhis, 97 | scalarList& alphaRhoPhis, 98 | vector& rhoUPhi, 99 | scalar& rhoEPhi, 100 | const label facei, const label patchi = -1 101 | ); 102 | 103 | //- Calculate energy flux for an addition internal energy 104 | virtual scalar energyFlux 105 | ( 106 | const scalar& rhoOwn, const scalar& rhoNei, 107 | const vector& UOwn, const vector& UNei, 108 | const scalar& eOwn, const scalar& eNei, 109 | const scalar& pOwn, const scalar& pNei, 110 | const label facei, const label patchi = -1 111 | ) const; 112 | 113 | //- Interpolate field 114 | virtual scalar interpolate 115 | ( 116 | const scalar& fOwn, const scalar& fNei, 117 | const label facei, const label patchi = -1 118 | ) const; 119 | 120 | 121 | public: 122 | 123 | //- Runtime type information 124 | TypeName("Kurganov"); 125 | 126 | // Constructor 127 | Kurganov(const fvMesh& mesh); 128 | 129 | 130 | //- Destructor 131 | virtual ~Kurganov(); 132 | 133 | 134 | // Member Functions 135 | 136 | //- Clear savedFields 137 | virtual void clear(); 138 | 139 | //- Allocate saved fields 140 | virtual void createSavedFields(); 141 | }; 142 | 143 | 144 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 145 | 146 | } // End namespace fluxSchemes 147 | } // End namespace Foam 148 | 149 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 150 | 151 | #endif 152 | 153 | // ************************************************************************* // 154 | -------------------------------------------------------------------------------- /fluxSchemes/Make/files: -------------------------------------------------------------------------------- 1 | fluxScheme/fluxScheme.C 2 | fluxScheme/newFluxScheme.C 3 | 4 | HLLC/HLLC.C 5 | HLLCP/HLLCP.C 6 | HLL/HLL.C 7 | Kurganov/Kurganov.C 8 | Tadmor/Tadmor.C 9 | AUSMPlus/AUSMPlus.C 10 | AUSMPlusUp/AUSMPlusUp.C 11 | 12 | 13 | LIB = $(DF_LIBBIN)/libfluxSchemes 14 | -------------------------------------------------------------------------------- /fluxSchemes/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 3 | -I$(LIB_SRC)/meshTools/lnInclude 4 | 5 | LIB_LIBS = 6 | -------------------------------------------------------------------------------- /fluxSchemes/RiemannConvectionScheme/RiemannConvectionScheme.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | \*---------------------------------------------------------------------------*/ 25 | 26 | #include "RiemannConvectionScheme.H" 27 | #include "fvcSurfaceIntegrate.H" 28 | #include "fvMatrices.H" 29 | #include "fvc.H" 30 | 31 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 32 | 33 | namespace Foam 34 | { 35 | 36 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 37 | 38 | namespace fv 39 | { 40 | 41 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 42 | 43 | 44 | template 45 | tmp> 46 | RiemannConvectionScheme::interpolate 47 | ( 48 | const surfaceScalarField& faceFlux, 49 | const GeometricField& vf 50 | ) const 51 | { 52 | return fluxScheme_.interpolate(vf, vf.name()); 53 | } 54 | 55 | 56 | template 57 | tmp> 58 | RiemannConvectionScheme::flux 59 | ( 60 | const surfaceScalarField& faceFlux, 61 | const GeometricField& vf 62 | ) const 63 | { 64 | return faceFlux*interpolate(faceFlux, vf); 65 | } 66 | 67 | 68 | template 69 | tmp> 70 | RiemannConvectionScheme::fvmDiv 71 | ( 72 | const surfaceScalarField& faceFlux, 73 | const GeometricField& vf 74 | ) const 75 | { 76 | 77 | tmp> tfvm 78 | ( 79 | new fvMatrix 80 | ( 81 | vf, 82 | faceFlux.dimensions()*vf.dimensions() 83 | ) 84 | ); 85 | fvMatrix& fvm = tfvm.ref(); 86 | 87 | fvm += fvc::surfaceIntegrate(flux(faceFlux, vf)); 88 | 89 | return tfvm; 90 | } 91 | 92 | 93 | template 94 | tmp> 95 | RiemannConvectionScheme::fvcDiv 96 | ( 97 | const surfaceScalarField& faceFlux, 98 | const GeometricField& vf 99 | ) const 100 | { 101 | tmp> tConvection 102 | ( 103 | fvc::surfaceIntegrate(flux(faceFlux, vf)) 104 | ); 105 | 106 | tConvection.ref().rename 107 | ( 108 | "convection(" + faceFlux.name() + ',' + vf.name() + ')' 109 | ); 110 | 111 | return tConvection; 112 | } 113 | 114 | 115 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 116 | 117 | } // End namespace fv 118 | 119 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 120 | 121 | } // End namespace Foam 122 | 123 | // ************************************************************************* // 124 | -------------------------------------------------------------------------------- /fluxSchemes/RiemannConvectionScheme/RiemannConvectionScheme.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Class 25 | Foam::fv::RiemannConvectionScheme 26 | 27 | Description 28 | Comvection scheme that uses explicit fluxes for both fvc and fvm based 29 | convection terms. The fluxes are calculated using the saved Riemann solver 30 | fields in with interpolation from upwinding and downwinding directions 31 | 32 | SourceFiles 33 | RiemannConvectionScheme.C 34 | 35 | \*---------------------------------------------------------------------------*/ 36 | 37 | #ifndef RiemannConvectionScheme_H 38 | #define RiemannConvectionScheme_H 39 | 40 | #include "convectionScheme.H" 41 | #include "fluxScheme.H" 42 | 43 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 44 | 45 | namespace Foam 46 | { 47 | 48 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 49 | 50 | namespace fv 51 | { 52 | 53 | /*---------------------------------------------------------------------------*\ 54 | Class RiemannConvectionScheme Declaration 55 | \*---------------------------------------------------------------------------*/ 56 | 57 | template 58 | class RiemannConvectionScheme 59 | : 60 | public fv::convectionScheme 61 | { 62 | // Private Data 63 | 64 | //- Reference to flux scheme 65 | const fluxScheme& fluxScheme_; 66 | 67 | 68 | public: 69 | 70 | //- Runtime type information 71 | TypeName("Riemann"); 72 | 73 | 74 | // Constructors 75 | 76 | //- Construct from flux and interpolation scheme 77 | RiemannConvectionScheme 78 | ( 79 | const fvMesh& mesh, 80 | const surfaceScalarField& faceFlux, 81 | const tmp>& scheme 82 | ) 83 | : 84 | convectionScheme(mesh, faceFlux), 85 | fluxScheme_(mesh.lookupObject("fluxScheme")) 86 | {} 87 | 88 | //- Construct from flux and Istream 89 | RiemannConvectionScheme 90 | ( 91 | const fvMesh& mesh, 92 | const surfaceScalarField& faceFlux, 93 | Istream& is 94 | ) 95 | : 96 | convectionScheme(mesh, faceFlux), 97 | fluxScheme_(mesh.lookupObject("fluxScheme")) 98 | {} 99 | 100 | //- Disallow default bitwise copy construction 101 | RiemannConvectionScheme(const RiemannConvectionScheme&) = delete; 102 | 103 | 104 | // Member Functions 105 | 106 | tmp> interpolate 107 | ( 108 | const surfaceScalarField&, 109 | const GeometricField& 110 | ) const; 111 | 112 | tmp> flux 113 | ( 114 | const surfaceScalarField&, 115 | const GeometricField& 116 | ) const; 117 | 118 | tmp> fvmDiv 119 | ( 120 | const surfaceScalarField&, 121 | const GeometricField& 122 | ) const; 123 | 124 | tmp> fvcDiv 125 | ( 126 | const surfaceScalarField&, 127 | const GeometricField& 128 | ) const; 129 | 130 | 131 | // Member Operators 132 | 133 | //- Disallow default bitwise assignment 134 | void operator=(const RiemannConvectionScheme&) = delete; 135 | }; 136 | 137 | 138 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 139 | 140 | } // End namespace fv 141 | 142 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 143 | 144 | } // End namespace Foam 145 | 146 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 147 | 148 | #ifdef NoRepository 149 | #include "RiemannConvectionScheme.C" 150 | #endif 151 | 152 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 153 | 154 | #endif 155 | 156 | // ************************************************************************* // 157 | -------------------------------------------------------------------------------- /fluxSchemes/RiemannConvectionScheme/RiemannConvectionSchemes.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | \*---------------------------------------------------------------------------*/ 25 | 26 | #include "RiemannConvectionScheme.H" 27 | #include "fvMesh.H" 28 | 29 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 30 | 31 | makeFvConvectionScheme(RiemannConvectionScheme) 32 | 33 | // ************************************************************************* // 34 | -------------------------------------------------------------------------------- /fluxSchemes/Tadmor/Tadmor.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | 2019-10-21 Jeff Heylmun: Moved from rhoCentralFoam to runtime selectable 9 | method. 10 | -------------------------------------------------------------------------------License 11 | This file is part of OpenFOAM. 12 | 13 | OpenFOAM is free software: you can redistribute it and/or modify it 14 | under the terms of the GNU General Public License as published by 15 | the Free Software Foundation, either version 3 of the License, or 16 | (at your option) any later version. 17 | 18 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 19 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21 | for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with OpenFOAM. If not, see . 25 | 26 | \*---------------------------------------------------------------------------*/ 27 | 28 | #include "Tadmor.H" 29 | #include "addToRunTimeSelectionTable.H" 30 | 31 | // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // 32 | 33 | namespace Foam 34 | { 35 | namespace fluxSchemes 36 | { 37 | defineTypeNameAndDebug(Tadmor, 0); 38 | addToRunTimeSelectionTable(fluxScheme, Tadmor, dictionary); 39 | } 40 | } 41 | 42 | 43 | // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 44 | 45 | Foam::fluxSchemes::Tadmor::Tadmor 46 | ( 47 | const fvMesh& mesh 48 | ) 49 | : 50 | fluxScheme(mesh) 51 | {} 52 | 53 | 54 | // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // 55 | 56 | Foam::fluxSchemes::Tadmor::~Tadmor() 57 | {} 58 | 59 | 60 | // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 61 | 62 | void Foam::fluxSchemes::Tadmor::clear() 63 | { 64 | fluxScheme::clear(); 65 | aPhivOwn_.clear(); 66 | aPhivNei_.clear(); 67 | aSf_.clear(); 68 | } 69 | 70 | 71 | void Foam::fluxSchemes::Tadmor::createSavedFields() 72 | { 73 | fluxScheme::createSavedFields(); 74 | if (aPhivOwn_.valid()) 75 | { 76 | return; 77 | } 78 | 79 | aPhivOwn_ = tmp 80 | ( 81 | new surfaceScalarField 82 | ( 83 | IOobject 84 | ( 85 | "Tadmor::aPhivOwn", 86 | mesh_.time().timeName(), 87 | mesh_ 88 | ), 89 | mesh_, 90 | dimensionedScalar("0", dimVelocity*dimArea, 0.0) 91 | ) 92 | ); 93 | aPhivNei_ = tmp 94 | ( 95 | new surfaceScalarField 96 | ( 97 | IOobject 98 | ( 99 | "Tadmor::aPhivNei", 100 | mesh_.time().timeName(), 101 | mesh_ 102 | ), 103 | mesh_, 104 | dimensionedScalar("0", dimVelocity*dimArea, 0.0) 105 | ) 106 | ); 107 | aSf_ = tmp 108 | ( 109 | new surfaceScalarField 110 | ( 111 | IOobject 112 | ( 113 | "Kurganov::aSf", 114 | mesh_.time().timeName(), 115 | mesh_ 116 | ), 117 | mesh_, 118 | dimensionedScalar("0", dimVelocity*dimArea, 0.0) 119 | ) 120 | ); 121 | } 122 | 123 | 124 | void Foam::fluxSchemes::Tadmor::calculateFluxes 125 | ( 126 | const scalar& rhoOwn, const scalar& rhoNei, 127 | const vector& UOwn, const vector& UNei, 128 | const scalar& eOwn, const scalar& eNei, 129 | const scalar& pOwn, const scalar& pNei, 130 | const scalar& cOwn, const scalar& cNei, 131 | const vector& Sf, 132 | scalar& phi, 133 | scalar& rhoPhi, 134 | vector& rhoUPhi, 135 | scalar& rhoEPhi, 136 | const label facei, const label patchi 137 | ) 138 | { 139 | scalar magSf = mag(Sf); 140 | 141 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 142 | scalar ENei = eNei + 0.5*magSqr(UNei); 143 | 144 | scalar phivOwn(UOwn & Sf); 145 | scalar phivNei(UNei & Sf); 146 | 147 | scalar cSfOwn(cOwn*magSf); 148 | scalar cSfNei(cNei*magSf); 149 | 150 | const scalar vMesh(meshPhi(facei, patchi)); 151 | phivOwn -= vMesh; 152 | phivNei -= vMesh; 153 | 154 | scalar ap(max(max(phivOwn + cSfOwn, phivNei + cSfNei), 0.0)); 155 | scalar am(min(min(phivOwn - cSfOwn, phivNei - cSfNei), 0.0)); 156 | 157 | scalar amaxSf(max(mag(am), mag(ap))); 158 | scalar aSf(-0.5*amaxSf); 159 | 160 | phivOwn *= 0.5; 161 | phivNei *= 0.5; 162 | 163 | scalar aphivOwn(phivOwn - aSf); 164 | scalar aphivNei(phivNei + aSf); 165 | 166 | this->save(facei, patchi, aphivOwn, aPhivOwn_); 167 | this->save(facei, patchi, aphivNei, aPhivNei_); 168 | this->save(facei, patchi, aSf, aSf_); 169 | 170 | this->save(facei, patchi, 0.5*(UOwn + UNei), Uf_); 171 | phi = aphivOwn + aphivNei; 172 | rhoPhi = aphivOwn*rhoOwn + aphivNei*rhoNei; 173 | 174 | rhoUPhi = 175 | ( 176 | (aphivOwn*rhoOwn*UOwn + aphivNei*rhoNei*UNei) 177 | + 0.5*(pOwn + pNei)*Sf 178 | ); 179 | 180 | rhoEPhi = 181 | ( 182 | aphivOwn*(rhoOwn*EOwn + pOwn) 183 | + aphivNei*(rhoNei*ENei + pNei) 184 | + aSf*pOwn - aSf*pNei 185 | + vMesh*0.5*(pOwn + pNei) 186 | ); 187 | } 188 | 189 | 190 | void Foam::fluxSchemes::Tadmor::calculateFluxes 191 | ( 192 | const scalarList& alphasOwn, const scalarList& alphasNei, 193 | const scalarList& rhosOwn, const scalarList& rhosNei, 194 | const scalar& rhoOwn, const scalar& rhoNei, 195 | const vector& UOwn, const vector& UNei, 196 | const scalar& eOwn, const scalar& eNei, 197 | const scalar& pOwn, const scalar& pNei, 198 | const scalar& cOwn, const scalar& cNei, 199 | const vector& Sf, 200 | scalar& phi, 201 | scalarList& alphaPhis, 202 | scalarList& alphaRhoPhis, 203 | vector& rhoUPhi, 204 | scalar& rhoEPhi, 205 | const label facei, const label patchi 206 | ) 207 | { 208 | scalar magSf = mag(Sf); 209 | 210 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 211 | scalar ENei = eNei + 0.5*magSqr(UNei); 212 | 213 | scalar phivOwn(UOwn & Sf); 214 | scalar phivNei(UNei & Sf); 215 | 216 | scalar cSfOwn(cOwn*magSf); 217 | scalar cSfNei(cNei*magSf); 218 | 219 | const scalar vMesh(meshPhi(facei, patchi)); 220 | phivOwn -= vMesh; 221 | phivNei -= vMesh; 222 | 223 | scalar aOwn(max(max(phivOwn + cSfOwn, phivNei + cSfNei), 0.0)); 224 | scalar aNei(min(min(phivOwn - cSfOwn, phivNei - cSfNei), 0.0)); 225 | 226 | scalar amaxSf(max(mag(aNei), mag(aOwn))); 227 | scalar aSf(-0.5*amaxSf); 228 | 229 | phivOwn *= 0.5; 230 | phivNei *= 0.5; 231 | 232 | scalar aphivOwn(phivOwn - aSf); 233 | scalar aphivNei(phivNei + aSf); 234 | 235 | this->save(facei, patchi, aphivOwn, aPhivOwn_); 236 | this->save(facei, patchi, aphivNei, aPhivNei_); 237 | this->save(facei, patchi, aSf, aSf_); 238 | 239 | this->save(facei, patchi, 0.5*(UOwn + UNei), Uf_); 240 | 241 | phi = aphivOwn + aphivNei; 242 | 243 | forAll(alphasOwn, phasei) 244 | { 245 | alphaPhis[phasei] = 246 | aphivOwn*alphasOwn[phasei] + aphivNei*alphasNei[phasei]; 247 | alphaRhoPhis[phasei] = 248 | aphivOwn*alphasOwn[phasei]*rhosOwn[phasei] 249 | + aphivNei*alphasNei[phasei]*rhosNei[phasei]; 250 | } 251 | 252 | rhoUPhi = 253 | ( 254 | (aphivOwn*rhoOwn*UOwn + aphivNei*rhoNei*UNei) 255 | + 0.5*(pOwn + pNei)*Sf 256 | ); 257 | 258 | rhoEPhi = 259 | ( 260 | aphivOwn*(rhoOwn*EOwn + pOwn) 261 | + aphivNei*(rhoNei*ENei + pNei) 262 | + aSf*pOwn - aSf*pNei 263 | + vMesh*0.5*(pOwn + pNei) 264 | ); 265 | } 266 | 267 | 268 | Foam::scalar Foam::fluxSchemes::Tadmor::energyFlux 269 | ( 270 | const scalar& rhoOwn, const scalar& rhoNei, 271 | const vector& UOwn, const vector& UNei, 272 | const scalar& eOwn, const scalar& eNei, 273 | const scalar& pOwn, const scalar& pNei, 274 | const label facei, const label patchi 275 | ) const 276 | { 277 | scalar aphivOwn = getValue(facei, patchi, aPhivOwn_()); 278 | scalar aphivNei = getValue(facei, patchi, aPhivNei_()); 279 | scalar aSf = getValue(facei, patchi, aSf_()); 280 | 281 | scalar EOwn = eOwn + 0.5*magSqr(UOwn); 282 | scalar ENei = eNei + 0.5*magSqr(UNei); 283 | 284 | return 285 | ( 286 | aphivOwn*(rhoOwn*EOwn + pOwn) 287 | + aphivNei*(rhoNei*ENei + pNei) 288 | + aSf*pOwn - aSf*pNei 289 | + meshPhi(facei, patchi)*0.5*(pOwn + pNei) 290 | ); 291 | } 292 | 293 | 294 | Foam::scalar Foam::fluxSchemes::Tadmor::interpolate 295 | ( 296 | const scalar& fOwn, const scalar& fNei, 297 | const label facei, const label patchi 298 | ) const 299 | { 300 | return 0.5*(fOwn + fNei); 301 | } 302 | 303 | // ************************************************************************* // 304 | -------------------------------------------------------------------------------- /fluxSchemes/Tadmor/Tadmor.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | 2019-10-21 Jeff Heylmun: Moved from rhoCentralFoam to runtime selectable 9 | method. 10 | ------------------------------------------------------------------------------- 11 | License 12 | This file is part of OpenFOAM. 13 | 14 | OpenFOAM is free software: you can redistribute it and/or modify it 15 | under the terms of the GNU General Public License as published by 16 | the Free Software Foundation, either version 3 of the License, or 17 | (at your option) any later version. 18 | 19 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 20 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 22 | for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with OpenFOAM. If not, see . 26 | 27 | Class 28 | Foam::fluxSchemes::Tadmor 29 | 30 | Description 31 | 32 | SourceFiles 33 | Tadmor.C 34 | 35 | \*---------------------------------------------------------------------------*/ 36 | 37 | #ifndef Tadmor_H 38 | #define Tadmor_H 39 | 40 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 41 | 42 | #include "fluxScheme.H" 43 | 44 | namespace Foam 45 | { 46 | namespace fluxSchemes 47 | { 48 | 49 | /*---------------------------------------------------------------------------*\ 50 | Class Tadmor Declaration 51 | \*---------------------------------------------------------------------------*/ 52 | 53 | class Tadmor 54 | : 55 | public fluxScheme 56 | { 57 | 58 | // Saved variables 59 | 60 | tmp aPhivOwn_; 61 | tmp aPhivNei_; 62 | tmp aSf_; 63 | 64 | 65 | // Private functions 66 | 67 | //- Calcualte fluxes 68 | virtual void calculateFluxes 69 | ( 70 | const scalar& rhoOwn, const scalar& rhoNei, 71 | const vector& UOwn, const vector& UNei, 72 | const scalar& eOwn, const scalar& eNei, 73 | const scalar& pOwn, const scalar& pNei, 74 | const scalar& cOwn, const scalar& cNei, 75 | const vector& Sf, 76 | scalar& phi, 77 | scalar& rhoPhi, 78 | vector& rhoUPhi, 79 | scalar& rhoEPhi, 80 | const label facei, const label patchi = -1 81 | ); 82 | 83 | //- Calcualte fluxes 84 | virtual void calculateFluxes 85 | ( 86 | const scalarList& alphasOwn, const scalarList& alphasNei, 87 | const scalarList& rhosOwn, const scalarList& rhosNei, 88 | const scalar& rhoOwn, const scalar& rhoNei, 89 | const vector& UOwn, const vector& UNei, 90 | const scalar& eOwn, const scalar& eNei, 91 | const scalar& pOwn, const scalar& pNei, 92 | const scalar& cOwn, const scalar& cNei, 93 | const vector& Sf, 94 | scalar& phi, 95 | scalarList& alphaPhis, 96 | scalarList& alphaRhoPhis, 97 | vector& rhoUPhi, 98 | scalar& rhoEPhi, 99 | const label facei, const label patchi = -1 100 | ); 101 | 102 | //- Calculate energy flux for an addition internal energy 103 | virtual scalar energyFlux 104 | ( 105 | const scalar& rhoOwn, const scalar& rhoNei, 106 | const vector& UOwn, const vector& UNei, 107 | const scalar& eOwn, const scalar& eNei, 108 | const scalar& pOwn, const scalar& pNei, 109 | const label facei, const label patchi = -1 110 | ) const; 111 | 112 | //- Interpolate field 113 | virtual scalar interpolate 114 | ( 115 | const scalar& fOwn, const scalar& fNei, 116 | const label facei, const label patchi = -1 117 | ) const; 118 | 119 | 120 | public: 121 | 122 | //- Runtime type information 123 | TypeName("Tadmor"); 124 | 125 | // Constructor 126 | Tadmor(const fvMesh& mesh); 127 | 128 | 129 | //- Destructor 130 | virtual ~Tadmor(); 131 | 132 | 133 | // Member Functions 134 | 135 | //- Clear savedFields 136 | virtual void clear(); 137 | 138 | //- Allocate saved fields 139 | virtual void createSavedFields(); 140 | }; 141 | 142 | 143 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 144 | 145 | } // End namespace fluxSchemes 146 | } // End namespace Foam 147 | 148 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 149 | 150 | #endif 151 | 152 | // ************************************************************************* // 153 | -------------------------------------------------------------------------------- /fluxSchemes/fluxScheme/fluxScheme.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2019 Synthetik Applied Technologies 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is derivative work of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Class 25 | Foam::fluxScheme 26 | 27 | Description 28 | Base class for flux schemes to interpolate fields and loop over faces 29 | and boundaries 30 | 31 | SourceFiles 32 | fluxScheme.C 33 | newFluxScheme.C 34 | 35 | \*---------------------------------------------------------------------------*/ 36 | 37 | #ifndef fluxScheme_H 38 | #define fluxScheme_H 39 | 40 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 41 | 42 | #include "volFields.H" 43 | #include "surfaceFields.H" 44 | #include "regIOobject.H" 45 | #include "dictionary.H" 46 | #include "runTimeSelectionTables.H" 47 | #include "fvc.H" 48 | 49 | namespace Foam 50 | { 51 | 52 | /*---------------------------------------------------------------------------*\ 53 | Class fluxScheme Declaration 54 | \*---------------------------------------------------------------------------*/ 55 | 56 | class fluxScheme 57 | : 58 | public regIOobject 59 | { 60 | protected: 61 | 62 | //- Const reference to mesh 63 | const fvMesh& mesh_; 64 | 65 | //- Owner and neighbour surface fields 66 | tmp own_; 67 | tmp nei_; 68 | 69 | //- Saved interpolated U field 70 | tmp Uf_; 71 | 72 | //- Saved interpolated rho fields 73 | tmp rhoOwn_; 74 | tmp rhoNei_; 75 | 76 | 77 | // Protected Functions 78 | 79 | //- Calcualte fluxes 80 | virtual void calculateFluxes 81 | ( 82 | const scalar& rhoOwn, const scalar& rhoNei, 83 | const vector& UOwn, const vector& UNei, 84 | const scalar& eOwn, const scalar& eNei, 85 | const scalar& pOwn, const scalar& pNei, 86 | const scalar& cOwn, const scalar& cNei, 87 | const vector& Sf, 88 | scalar& phi, 89 | scalar& rhoPhi, 90 | vector& rhoUPhi, 91 | scalar& rhoEPhi, 92 | const label facei, const label patchi = -1 93 | ) = 0; 94 | 95 | //- Update 96 | virtual void calculateFluxes 97 | ( 98 | const scalarList& alphasOwn, const scalarList& alphasNei, 99 | const scalarList& rhosOwn, const scalarList& rhosNei, 100 | const scalar& rhoOwn, const scalar& rhoNei, 101 | const vector& UOwn, const vector& UNei, 102 | const scalar& eOwn, const scalar& eNei, 103 | const scalar& pOwn, const scalar& pNei, 104 | const scalar& cOwn, const scalar& cNei, 105 | const vector& Sf, 106 | scalar& phi, 107 | scalarList& alphaPhis, 108 | scalarList& alphaRhosPhis, 109 | vector& rhoUPhi, 110 | scalar& rhoEPhi, 111 | const label facei, const label patchi = -1 112 | ) = 0; 113 | 114 | //- Calculate energy flux for an addition internal energy 115 | virtual scalar energyFlux 116 | ( 117 | const scalar& rhoOwn, const scalar& rhoNei, 118 | const vector& UOwn, const vector& UNei, 119 | const scalar& eOwn, const scalar& eNei, 120 | const scalar& pOwn, const scalar& pNei, 121 | const label facei, const label patchi = -1 122 | ) const = 0; 123 | 124 | //- Interpolate field 125 | virtual scalar interpolate 126 | ( 127 | const scalar& fOwn, const scalar& fNei, 128 | const label facei, const label patchi = -1 129 | ) const = 0; 130 | 131 | //- Update fields before calculating fluxes 132 | virtual void preUpdate(const volScalarField& p) 133 | {} 134 | 135 | //- Correct fluxes 136 | virtual void postUpdate() 137 | {} 138 | 139 | //- Return velocity w.r.t. face 140 | scalar meshPhi(const label facei, const label patchi) const 141 | { 142 | if (!mesh_.moving()) 143 | { 144 | return 0.0; 145 | } 146 | if (patchi != -1) 147 | { 148 | return mesh_.phi().boundaryField()[patchi][facei]; 149 | } 150 | else 151 | { 152 | return mesh_.phi()[facei]; 153 | } 154 | } 155 | 156 | 157 | //- Set Uf at facei 158 | template 159 | Type save 160 | ( 161 | const label facei, 162 | const label patchi, 163 | const Type& x, 164 | tmp>& xf 165 | ) 166 | { 167 | if (xf.valid()) 168 | { 169 | if (patchi != -1) 170 | { 171 | xf.ref().boundaryFieldRef()[patchi][facei] = x; 172 | } 173 | else 174 | { 175 | xf.ref()[facei] = x; 176 | } 177 | } 178 | return x; 179 | } 180 | 181 | //- Set Uf at facei 182 | template 183 | Type getValue 184 | ( 185 | const label facei, 186 | const label patchi, 187 | const GeometricField& xf 188 | ) const 189 | { 190 | if (patchi != -1) 191 | { 192 | return xf.boundaryField()[patchi][facei]; 193 | } 194 | else 195 | { 196 | return xf[facei]; 197 | } 198 | } 199 | 200 | inline word scheme(const word& name) const 201 | { 202 | word schemeName = "reconstruct(" + name + ")"; 203 | if 204 | ( 205 | !mesh_.schemesDict().subDict("interpolationSchemes").found(schemeName) 206 | ) 207 | { 208 | WarningInFunction 209 | << "Riemann schemes are used, but no limiter is " << nl 210 | << "specified for " << name << "." << nl 211 | << "This may result in unstable solutions." << endl; 212 | } 213 | return schemeName; 214 | } 215 | 216 | 217 | public: 218 | 219 | //- Runtime type information 220 | TypeName("fluxScheme"); 221 | 222 | 223 | // Declare runtime construction 224 | 225 | declareRunTimeSelectionTable 226 | ( 227 | autoPtr, 228 | fluxScheme, 229 | dictionary, 230 | (const fvMesh& mesh), 231 | (mesh) 232 | ); 233 | 234 | // Constructor 235 | fluxScheme(const fvMesh& mesh); 236 | 237 | 238 | //- Destructor 239 | virtual ~fluxScheme(); 240 | 241 | 242 | // Selectors 243 | 244 | static autoPtr New(const fvMesh& e); 245 | 246 | 247 | // Member Functions 248 | 249 | //- Clear savedFields 250 | virtual void clear(); 251 | 252 | //- Allocate saved fields 253 | virtual void createSavedFields(); 254 | 255 | //- Flux for three scalar fields 256 | template 257 | tmp> interpolate 258 | ( 259 | const GeometricField& f, 260 | const word& fName 261 | ) const; 262 | 263 | //- Update 264 | void update 265 | ( 266 | const volScalarField& rho, 267 | const volVectorField& U, 268 | const volScalarField& e, 269 | const volScalarField& p, 270 | const volScalarField& c, 271 | surfaceScalarField& phi, 272 | surfaceScalarField& rhoPhi, 273 | surfaceVectorField& rhoUPhi, 274 | surfaceScalarField& rhoEPhi 275 | ); 276 | 277 | //- Update 278 | void update 279 | ( 280 | const PtrList& alphas, 281 | const UPtrList& rhos, 282 | const volVectorField& U, 283 | const volScalarField& e, 284 | const volScalarField& p, 285 | const volScalarField& c, 286 | surfaceScalarField& phi, 287 | PtrList& alphaPhis, 288 | PtrList& alphaRhoPhis, 289 | surfaceScalarField& rhoPhi, 290 | surfaceVectorField& rhoUPhi, 291 | surfaceScalarField& rhoEPhi 292 | ); 293 | 294 | //- Update 295 | void update 296 | ( 297 | const volScalarField& alpha, 298 | const volScalarField& rho1, 299 | const volScalarField& rho2, 300 | const volVectorField& U, 301 | const volScalarField& e, 302 | const volScalarField& p, 303 | const volScalarField& c, 304 | surfaceScalarField& phi, 305 | surfaceScalarField& alphaPhi, 306 | surfaceScalarField& alphaRhoPhi1, 307 | surfaceScalarField& alphaRhoPhi2, 308 | surfaceScalarField& alphaRhoPhi, 309 | surfaceVectorField& rhoUPhi, 310 | surfaceScalarField& rhoEPhi 311 | ); 312 | 313 | //- Calculate energy flux for an addition internal energy 314 | tmp energyFlux 315 | ( 316 | const volScalarField& rho, 317 | const volVectorField& U, 318 | const volScalarField& e, 319 | const volScalarField& p 320 | ) const; 321 | 322 | //- Return interpolated U field 323 | tmp Uf() const; 324 | 325 | //- Dummy write for regIOobject 326 | bool writeData(Ostream& os) const; 327 | }; 328 | 329 | 330 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 331 | 332 | } // End namespace Foam 333 | 334 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 335 | 336 | #ifdef NoRepository 337 | #include "fluxSchemeTmp.C" 338 | #endif 339 | 340 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 341 | 342 | #endif 343 | 344 | // ************************************************************************* // 345 | -------------------------------------------------------------------------------- /fluxSchemes/fluxScheme/fluxSchemeTmp.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2019 Synthetik Applied Technologies 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is derivative work of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | \*---------------------------------------------------------------------------*/ 25 | 26 | #include "fluxScheme.H" 27 | 28 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 29 | 30 | namespace Foam 31 | { 32 | 33 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 34 | 35 | template 36 | tmp> fluxScheme::interpolate 37 | ( 38 | const GeometricField& f, 39 | const word& name 40 | ) const 41 | { 42 | typedef GeometricField fieldType; 43 | label nCmpts = pTraits::nComponents; 44 | 45 | fieldType fOwn(fvc::interpolate(f, own_(), scheme(name))); 46 | fieldType fNei(fvc::interpolate(f, nei_(), scheme(name))); 47 | 48 | tmp tmpf 49 | ( 50 | new fieldType 51 | ( 52 | IOobject 53 | ( 54 | f.name() + "f", 55 | mesh_.time().timeName(), 56 | mesh_, 57 | IOobject::NO_READ, 58 | IOobject::NO_WRITE, 59 | false 60 | ), 61 | mesh_, 62 | dimensioned("0", f.dimensions(), pTraits::zero) 63 | ) 64 | ); 65 | fieldType& ff = tmpf.ref(); 66 | 67 | forAll(fOwn, facei) 68 | { 69 | for (label i = 0; i < nCmpts; i++) 70 | { 71 | setComponent(ff[facei], i) = interpolate 72 | ( 73 | component(fOwn[facei], i), 74 | component(fNei[facei], i), 75 | facei 76 | ); 77 | } 78 | } 79 | 80 | forAll(f.boundaryField(), patchi) 81 | { 82 | forAll(f.boundaryField()[patchi], facei) 83 | { 84 | for (label i = 0; i < nCmpts; i++) 85 | { 86 | setComponent(ff.boundaryFieldRef()[patchi][facei], i) = 87 | interpolate 88 | ( 89 | component(fOwn.boundaryField()[patchi][facei], i), 90 | component(fNei.boundaryField()[patchi][facei], i), 91 | facei, patchi 92 | ); 93 | } 94 | } 95 | } 96 | return tmpf; 97 | } 98 | 99 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 100 | 101 | } // End namespace Foam 102 | 103 | // ************************************************************************* // 104 | -------------------------------------------------------------------------------- /fluxSchemes/fluxScheme/newFluxScheme.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2019 Synthetik Applied Technologies 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is derivative work of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | \*---------------------------------------------------------------------------*/ 25 | 26 | #include "fluxScheme.H" 27 | 28 | // * * * * * * * * * * * * * * * * Selector * * * * * * * * * * * * * * * * // 29 | 30 | Foam::autoPtr Foam::fluxScheme::New 31 | ( 32 | const fvMesh& mesh 33 | ) 34 | { 35 | word fluxSchemeType(mesh.schemesDict().lookup("fluxScheme")); 36 | 37 | Info<< "Selecting fluxScheme: " << fluxSchemeType << endl; 38 | 39 | dictionaryConstructorTable::iterator cstrIter = 40 | dictionaryConstructorTablePtr_->find(fluxSchemeType); 41 | 42 | if (cstrIter == dictionaryConstructorTablePtr_->end()) 43 | { 44 | FatalErrorInFunction 45 | << "Unknown fluxScheme type " 46 | << fluxSchemeType << endl << endl 47 | << "Valid fluxScheme types are : " << endl 48 | << dictionaryConstructorTablePtr_->sortedToc() 49 | << exit(FatalError); 50 | } 51 | 52 | return cstrIter()(mesh); 53 | } 54 | 55 | 56 | // ************************************************************************* // 57 | -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/AUSMPlus.C: -------------------------------------------------------------------------------- 1 | ../AUSMPlus/AUSMPlus.C -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/AUSMPlus.H: -------------------------------------------------------------------------------- 1 | ../AUSMPlus/AUSMPlus.H -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/AUSMPlusUp.C: -------------------------------------------------------------------------------- 1 | ../AUSMPlusUp/AUSMPlusUp.C -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/AUSMPlusUp.H: -------------------------------------------------------------------------------- 1 | ../AUSMPlusUp/AUSMPlusUp.H -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/HLL.C: -------------------------------------------------------------------------------- 1 | ../HLL/HLL.C -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/HLL.H: -------------------------------------------------------------------------------- 1 | ../HLL/HLL.H -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/HLLC.C: -------------------------------------------------------------------------------- 1 | ../HLLC/HLLC.C -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/HLLC.H: -------------------------------------------------------------------------------- 1 | ../HLLC/HLLC.H -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/HLLCP.C: -------------------------------------------------------------------------------- 1 | ../HLLCP/HLLCP.C -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/HLLCP.H: -------------------------------------------------------------------------------- 1 | ../HLLCP/HLLCP.H -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/Kurganov.C: -------------------------------------------------------------------------------- 1 | ../Kurganov/Kurganov.C -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/Kurganov.H: -------------------------------------------------------------------------------- 1 | ../Kurganov/Kurganov.H -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/RiemannConvectionScheme.C: -------------------------------------------------------------------------------- 1 | ../RiemannConvectionScheme/RiemannConvectionScheme.C -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/RiemannConvectionScheme.H: -------------------------------------------------------------------------------- 1 | ../RiemannConvectionScheme/RiemannConvectionScheme.H -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/RiemannConvectionSchemes.C: -------------------------------------------------------------------------------- 1 | ../RiemannConvectionScheme/RiemannConvectionSchemes.C -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/Tadmor.C: -------------------------------------------------------------------------------- 1 | ../Tadmor/Tadmor.C -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/Tadmor.H: -------------------------------------------------------------------------------- 1 | ../Tadmor/Tadmor.H -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/fluxScheme.C: -------------------------------------------------------------------------------- 1 | ../fluxScheme/fluxScheme.C -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/fluxScheme.H: -------------------------------------------------------------------------------- 1 | ../fluxScheme/fluxScheme.H -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/fluxSchemeTmp.C: -------------------------------------------------------------------------------- 1 | ../fluxScheme/fluxSchemeTmp.C -------------------------------------------------------------------------------- /fluxSchemes/lnInclude/newFluxScheme.C: -------------------------------------------------------------------------------- 1 | ../fluxScheme/newFluxScheme.C -------------------------------------------------------------------------------- /preCal.H: -------------------------------------------------------------------------------- 1 | // --- Directed interpolation of primitive fields onto faces 2 | 3 | volScalarField rPsi("rPsi", 1.0/psi); 4 | surfaceScalarField rPsi_pos(interpolate(rPsi, pos, T.name())); 5 | surfaceScalarField rPsi_neg(interpolate(rPsi, neg, T.name())); 6 | 7 | volScalarField c("c", sqrt(thermo.Cp()/thermo.Cv()*rPsi)); 8 | -------------------------------------------------------------------------------- /setRDeltaT.H: -------------------------------------------------------------------------------- 1 | //same with rhoCentralFoam 2 | { 3 | volScalarField& rDeltaT = trDeltaT.ref(); 4 | 5 | scalar rDeltaTSmoothingCoeff 6 | ( 7 | runTime.controlDict().lookupOrDefault 8 | ( 9 | "rDeltaTSmoothingCoeff", 10 | 0.02 11 | ) 12 | ); 13 | 14 | // Set the reciprocal time-step from the local Courant number 15 | rDeltaT.ref() = max 16 | ( 17 | 1/dimensionedScalar(dimTime, maxDeltaT), 18 | fvc::surfaceSum(amaxSf)()() 19 | /((2*maxCo)*mesh.V()) 20 | ); 21 | 22 | // Update tho boundary values of the reciprocal time-step 23 | rDeltaT.correctBoundaryConditions(); 24 | 25 | fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff); 26 | 27 | Info<< "Flow time scale min/max = " 28 | << gMin(1/rDeltaT.primitiveField()) 29 | << ", " << gMax(1/rDeltaT.primitiveField()) << endl; 30 | } 31 | -------------------------------------------------------------------------------- /setRootCase2.H: -------------------------------------------------------------------------------- 1 | Foam::argList args(argc,argv,true,true,/*initialise=*/false); 2 | if (!args.checkRootCase()) 3 | { 4 | Foam::FatalError.exit(); 5 | } -------------------------------------------------------------------------------- /updateFieldsSave.H: -------------------------------------------------------------------------------- 1 | rho_save = rho; 2 | 3 | rhoU_save = rho*U; 4 | 5 | rhoE_save = rho*(ea + 0.5*magSqr(U)); 6 | 7 | forAll(rhoYi_save,i) 8 | { 9 | rhoYi_save[i] = rho*Y[i]; 10 | } 11 | 12 | Info <<"finish update saved fields"<< endl; --------------------------------------------------------------------------------