diff --git a/Allwmake b/Allwmake index 923b8ec4..017ba567 100755 --- a/Allwmake +++ b/Allwmake @@ -12,6 +12,8 @@ wmake src/dfChemistryModel wmake src/TurbulenceModels/compressible wmake src/regionModels/surfaceFilmModels src/lagrangian/Allwmake $targetType $* +wmake src/dynamicMesh +wmake src/dynamicFvMesh wmake applications/solvers/df0DFoam wmake applications/solvers/dfLowMachFoam diff --git a/applications/solvers/dfHighSpeedFoam/dfHighSpeedFoam.C b/applications/solvers/dfHighSpeedFoam/dfHighSpeedFoam.C index 042d1a6a..3088e778 100644 --- a/applications/solvers/dfHighSpeedFoam/dfHighSpeedFoam.C +++ b/applications/solvers/dfHighSpeedFoam/dfHighSpeedFoam.C @@ -60,6 +60,7 @@ int main(int argc, char *argv[]) double time_monitor_flow; double time_monitor_chem; double time_monitor_Y; + double time_monitor_AMR; clock_t start, end; turbulence->validate(); @@ -69,6 +70,7 @@ int main(int argc, char *argv[]) #include "readFluxScheme.H" dimensionedScalar v_zero("v_zero", dimVolume/dimTime, 0.0); + dimensionedScalar refCri("refCri", dimensionSet(1, -4, 0, 0, 0), 0.0); // Courant numbers used to adjust the time-step scalar CoNum = 0.0; @@ -80,13 +82,28 @@ int main(int argc, char *argv[]) { #include "readTimeControls.H" + //used for AMR + refCri = max(mag(fvc::grad(rho))); + tmp tmagGradrho = mag(fvc::grad(rho)); + volScalarField normalisedGradrho + ( + "normalisedGradrho", + tmagGradrho()/refCri + ); + normalisedGradrho.writeOpt() = IOobject::AUTO_WRITE; + tmagGradrho.clear(); + if (!LTS) { #include "setDeltaT.H" runTime++; // Do any mesh changes + start = std::clock(); mesh.update(); + end = std::clock(); + time_monitor_AMR += double(end - start) / double(CLOCKS_PER_SEC); + } // --- Directed interpolation of primitive fields onto faces @@ -225,6 +242,7 @@ int main(int argc, char *argv[]) Info<< "MonitorTime_chem = " << time_monitor_chem << " s" << nl << endl; Info<< "MonitorTime_Y = " << time_monitor_Y << " s" << nl << endl; Info<< "MonitorTime_flow = " << time_monitor_flow << " s" << nl << endl; + Info<< "MonitorTime_AMR = " << time_monitor_AMR << " s" << nl << endl; Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/H2.gz b/examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/H2.gz similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/H2.gz rename to examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/H2.gz diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/N2.gz b/examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/N2.gz similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/N2.gz rename to examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/N2.gz diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/O2.gz b/examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/O2.gz similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/O2.gz rename to examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/O2.gz diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/T.gz b/examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/T.gz similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/T.gz rename to examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/T.gz diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/U.gz b/examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/U.gz similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/U.gz rename to examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/U.gz diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/Ydefault.gz b/examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/Ydefault.gz similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/Ydefault.gz rename to examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/Ydefault.gz diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/p.gz b/examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/p.gz similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/0_orig/p.gz rename to examples/dfHighSpeedFoam/oneD_detonationH2/0_orig/p.gz diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/Allclean b/examples/dfHighSpeedFoam/oneD_detonationH2/Allclean similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/Allclean rename to examples/dfHighSpeedFoam/oneD_detonationH2/Allclean diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/Allrun b/examples/dfHighSpeedFoam/oneD_detonationH2/Allrun similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/Allrun rename to examples/dfHighSpeedFoam/oneD_detonationH2/Allrun diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/H2_Li.xml b/examples/dfHighSpeedFoam/oneD_detonationH2/H2_Li.xml similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/H2_Li.xml rename to examples/dfHighSpeedFoam/oneD_detonationH2/H2_Li.xml diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/constant/CanteraTorchProperties b/examples/dfHighSpeedFoam/oneD_detonationH2/constant/CanteraTorchProperties similarity index 91% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/constant/CanteraTorchProperties rename to examples/dfHighSpeedFoam/oneD_detonationH2/constant/CanteraTorchProperties index 3436a18a..640b9e14 100755 --- a/examples/dfHighSpeedFoam/det_1D_H2_01mm/constant/CanteraTorchProperties +++ b/examples/dfHighSpeedFoam/oneD_detonationH2/constant/CanteraTorchProperties @@ -21,8 +21,8 @@ CanteraMechanismFile "H2_Li.xml"; transportModel "UnityLewis"; loadbalancing { - active false; - //log true; + active true; + log true; } odeCoeffs {} @@ -32,9 +32,4 @@ zeroDReactor { //cvorcp "UV"; } -loadbalancing -{ - active true; - //log true; -} // ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_detonationH2/constant/dynamicMeshDict b/examples/dfHighSpeedFoam/oneD_detonationH2/constant/dynamicMeshDict new file mode 100644 index 00000000..b6057554 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_detonationH2/constant/dynamicMeshDict @@ -0,0 +1,68 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object dynamicMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dynamicFvMesh dfDynamicRefineFvMesh; + +multiCritRefinementControls +{ + enableMultiCritRefinementControl false; +} + +dfDynamicRefineFvMeshCoeffs +{ + // How often to refine + refineInterval 1; + + // Field to be refinement on + field normalisedGradrho; + + // Refine field in between lower..upper + lowerRefineLevel 0.2; + upperRefineLevel 1; + + // If value < unrefineLevel unrefine + unrefineLevel 0.2; + + // Have slower than 2:1 refinement + nBufferLayers 3; + + // Refine cells only up to maxRefinement levels + maxRefinement 3; + + // Stop refinement if maxCells reached + maxCells 1000000; + + // Flux field and corresponding velocity field. Fluxes on changed + // faces get recalculated by interpolating the velocity. Use 'none' + // on surfaceScalarFields that do not need to be reinterpolated. + correctFluxes + ( + (phi none) + //(nHatf none) + //(rhoPhi none) + //(alphaPhi0.water none) + //(ghf none) + (neg none) + (pos none) + ); + + // Write the refinement level as a volScalarField + dumpLevel true; +} + + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/constant/thermophysicalProperties b/examples/dfHighSpeedFoam/oneD_detonationH2/constant/thermophysicalProperties similarity index 97% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/constant/thermophysicalProperties rename to examples/dfHighSpeedFoam/oneD_detonationH2/constant/thermophysicalProperties index e983a193..873b8e16 100755 --- a/examples/dfHighSpeedFoam/det_1D_H2_01mm/constant/thermophysicalProperties +++ b/examples/dfHighSpeedFoam/oneD_detonationH2/constant/thermophysicalProperties @@ -14,5 +14,5 @@ FoamFile object thermophysicalProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -inviscid true; +inviscid false; // ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/constant/turbulenceProperties b/examples/dfHighSpeedFoam/oneD_detonationH2/constant/turbulenceProperties similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/constant/turbulenceProperties rename to examples/dfHighSpeedFoam/oneD_detonationH2/constant/turbulenceProperties diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/system/blockMeshDict b/examples/dfHighSpeedFoam/oneD_detonationH2/system/blockMeshDict similarity index 95% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/system/blockMeshDict rename to examples/dfHighSpeedFoam/oneD_detonationH2/system/blockMeshDict index 1a73e764..921bd986 100755 --- a/examples/dfHighSpeedFoam/det_1D_H2_01mm/system/blockMeshDict +++ b/examples/dfHighSpeedFoam/oneD_detonationH2/system/blockMeshDict @@ -30,7 +30,7 @@ vertices blocks ( - hex (0 1 2 3 4 5 6 7) (5000 1 1) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) (625 1 1) simpleGrading (1 1 1) ); edges diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/system/controlDict b/examples/dfHighSpeedFoam/oneD_detonationH2/system/controlDict similarity index 86% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/system/controlDict rename to examples/dfHighSpeedFoam/oneD_detonationH2/system/controlDict index 57ed5645..515e99b6 100755 --- a/examples/dfHighSpeedFoam/det_1D_H2_01mm/system/controlDict +++ b/examples/dfHighSpeedFoam/oneD_detonationH2/system/controlDict @@ -14,7 +14,9 @@ FoamFile object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -libs ("libfieldFunctionObjects.so"); +libs ( + "libdfDynamicFvMesh.so" + ); application dfHighSpeedFoam; @@ -24,7 +26,7 @@ startTime 0; stopAt endTime; -endTime 2.4e-4; +endTime 2.2e-4; deltaT 1e-09; @@ -48,7 +50,7 @@ runTimeModifiable true; adjustTimeStep yes; -maxCo 0.02; +maxCo 0.1; maxDeltaT 1; @@ -57,8 +59,8 @@ functions minMax { type fieldMinMax; - libs ("libfieldFunctionObjects.so"); - writeControl timeStep; //writeTime; + libs ("libdfFieldFunctionObjects.so"); + writeControl writeTime; //timeStep; fields (p); } } diff --git a/examples/dfHighSpeedFoam/oneD_detonationH2/system/decomposeParDict b/examples/dfHighSpeedFoam/oneD_detonationH2/system/decomposeParDict new file mode 100755 index 00000000..e6fbae05 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_detonationH2/system/decomposeParDict @@ -0,0 +1,32 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +method scotch; + +constraints +{ + dfRefinementHistory + { + //- Decompose cells such that all cell originating from single cell + // end up on same processor + type dfRefinementHistory; + } +} + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/system/fvSchemes b/examples/dfHighSpeedFoam/oneD_detonationH2/system/fvSchemes similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/system/fvSchemes rename to examples/dfHighSpeedFoam/oneD_detonationH2/system/fvSchemes diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/system/fvSolution b/examples/dfHighSpeedFoam/oneD_detonationH2/system/fvSolution similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/system/fvSolution rename to examples/dfHighSpeedFoam/oneD_detonationH2/system/fvSolution diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/system/sample b/examples/dfHighSpeedFoam/oneD_detonationH2/system/sample similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/system/sample rename to examples/dfHighSpeedFoam/oneD_detonationH2/system/sample diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/system/setFieldsDict b/examples/dfHighSpeedFoam/oneD_detonationH2/system/setFieldsDict similarity index 100% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/system/setFieldsDict rename to examples/dfHighSpeedFoam/oneD_detonationH2/system/setFieldsDict diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/AR b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/AR new file mode 100755 index 00000000..4a7914aa --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/AR @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object AR; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.8861; + + +boundaryField +{ + Left + { + type zeroGradient; + } + + Right + { + type zeroGradient; + } + + empty + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/H2 b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/H2 new file mode 100755 index 00000000..6c9c8e4c --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/H2 @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object H2; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.01266; + + +boundaryField +{ + Left + { + type zeroGradient; + } + + Right + { + type zeroGradient; + } + + empty + { + type empty; + } +} + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/O2 b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/O2 new file mode 100755 index 00000000..4d6f7000 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/O2 @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object O2; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.101266; + + +boundaryField +{ + Left + { + type zeroGradient; + } + + Right + { + type zeroGradient; + } + + empty + { + type empty; + } +} + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/T b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/T new file mode 100755 index 00000000..eecff994 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/T @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0.913683; +//internalField uniform 300; + +boundaryField +{ + Left + { + type zeroGradient; + } + + Right + { + type inletOutlet; + inletValue uniform 748.472; + value uniform 748.472; + } + + empty + { + type empty; + } +} + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/U b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/U new file mode 100755 index 00000000..4d76526e --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/U @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + Left + { + type fixedValue; + value uniform (0 0 0); + } + + Right + { + type inletOutlet; + inletValue uniform (-487.34 0 0); + value uniform (-487.34 0 0); + } + + empty + { + type empty; + } +} + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/Ydefault b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/Ydefault new file mode 100755 index 00000000..7e583b1e --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/Ydefault @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object Ydefault; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.0; + +boundaryField +{ + Left + { + type zeroGradient; + } + + Right + { + type zeroGradient; + } + + empty + { + type empty; + } +} + + + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/p b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/p new file mode 100755 index 00000000..2b26b604 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/0_orig/p @@ -0,0 +1,40 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 35594; + +boundaryField +{ + Left + { + type zeroGradient; + } + + Right + { + type fixedValue; + value uniform 35594; + } + + empty + { + type empty; + } +} + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/Allclean b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/Allclean new file mode 100755 index 00000000..e40b9408 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/Allclean @@ -0,0 +1,13 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +echo "Cleaning log.*" +rm log.* +echo "Cleaning processor*" +rm -r processor* +echo "Cleaning polyMesh/" +rm -r constant/polyMesh +echo "Cleaning postProcessing/" +rm -r postProcessing +echo "Cleaning 0/" +rm -r 0 \ No newline at end of file diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/Allrun b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/Allrun new file mode 100755 index 00000000..f9647173 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/Allrun @@ -0,0 +1,13 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +application=dfHighSpeedFoam + +cp -r 0_orig/ 0/ +runApplication blockMesh +runApplication setFields +runApplication decomposePar +runApplication mpirun -np 5 $application -parallel diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/H2_AR.xml b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/H2_AR.xml new file mode 100755 index 00000000..4945c984 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/H2_AR.xml @@ -0,0 +1,531 @@ + + + + + + + H O Ar + H2 O2 H O OH HO2 H2O2 H2O AR + + + 300.0 + 101325.0 + + + + + + + + + + + + H:2 + TPIS78 + + + + 2.344331120E+00, 7.980520750E-03, -1.947815100E-05, 2.015720940E-08, + -7.376117610E-12, -9.179351730E+02, 6.830102380E-01 + + + + 3.337279200E+00, -4.940247310E-05, 4.994567780E-07, -1.795663940E-10, + 2.002553760E-14, -9.501589220E+02, -3.205023310E+00 + + + + linear + 38.000 + 2.920 + 0.000 + 0.790 + 280.000 + 0.000 + 0.000 + + + + + + O:2 + TPIS89 + + + + 3.782456360E+00, -2.996734160E-03, 9.847302010E-06, -9.681295090E-09, + 3.243728370E-12, -1.063943560E+03, 3.657675730E+00 + + + + 3.282537840E+00, 1.483087540E-03, -7.579666690E-07, 2.094705550E-10, + -2.167177940E-14, -1.088457720E+03, 5.453231290E+00 + + + + linear + 107.400 + 3.458 + 0.000 + 1.600 + 3.800 + 0.000 + 0.000 + + + + + + H:1 + L7/88 + + + + 2.500000000E+00, 7.053328190E-13, -1.995919640E-15, 2.300816320E-18, + -9.277323320E-22, 2.547365990E+04, -4.466828530E-01 + + + + 2.500000010E+00, -2.308429730E-11, 1.615619480E-14, -4.735152350E-18, + 4.981973570E-22, 2.547365990E+04, -4.466829140E-01 + + + + atom + 145.000 + 2.050 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + + + + + + O:1 + L1/90 + + + + 3.168267100E+00, -3.279318840E-03, 6.643063960E-06, -6.128066240E-09, + 2.112659710E-12, 2.912225920E+04, 2.051933460E+00 + + + + 2.569420780E+00, -8.597411370E-05, 4.194845890E-08, -1.001777990E-11, + 1.228336910E-15, 2.921757910E+04, 4.784338640E+00 + + + + atom + 80.000 + 2.750 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + + + + + + H:1 O:1 + S9/01 + + + + 4.125305610E+00, -3.225449390E-03, 6.527646910E-06, -5.798536430E-09, + 2.062373790E-12, 3.381538120E+03, -6.904329600E-01 + + + + 2.864728860E+00, 1.056504480E-03, -2.590827580E-07, 3.052186740E-11, + -1.331958760E-15, 3.718857740E+03, 5.701640730E+00 + + + + linear + 80.000 + 2.750 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + + + + + + H:1 O:2 + L5/89 + + + + 4.301798010E+00, -4.749120510E-03, 2.115828910E-05, -2.427638940E-08, + 9.292251240E-12, 2.948080400E+02, 3.716662450E+00 + + + + 4.017210900E+00, 2.239820130E-03, -6.336581500E-07, 1.142463700E-10, + -1.079085350E-14, 1.118567130E+02, 3.785102150E+00 + + + + nonlinear + 107.400 + 3.458 + 0.000 + 0.000 + 1.000 + 0.000 + 0.000 + + + + + + H:2 O:2 + L7/88 + + + + 4.276112690E+00, -5.428224170E-04, 1.673357010E-05, -2.157708130E-08, + 8.624543630E-12, -1.770258210E+04, 3.435050740E+00 + + + + 4.165002850E+00, 4.908316940E-03, -1.901392250E-06, 3.711859860E-10, + -2.879083050E-14, -1.786178770E+04, 2.916156620E+00 + + + + nonlinear + 107.400 + 3.458 + 0.000 + 0.000 + 3.800 + 0.000 + 0.000 + + + + + + H:2 O:1 + L8/89 + + + + 4.198640560E+00, -2.036434100E-03, 6.520402110E-06, -5.487970620E-09, + 1.771978170E-12, -3.029372670E+04, -8.490322080E-01 + + + + 3.033992490E+00, 2.176918040E-03, -1.640725180E-07, -9.704198700E-11, + 1.682009920E-14, -3.000429710E+04, 4.966770100E+00 + + + + nonlinear + 572.400 + 2.605 + 1.844 + 0.000 + 4.000 + 0.000 + 0.000 + + + + + + Ar:1 + 120186 + + + + 2.500000000E+00, 0.000000000E+00, 0.000000000E+00, 0.000000000E+00, + 0.000000000E+00, -7.453750000E+02, 4.366000000E+00 + + + + 2.500000000E+00, 0.000000000E+00, 0.000000000E+00, 0.000000000E+00, + 0.000000000E+00, -7.453750000E+02, 4.366000000E+00 + + + + atom + 136.500 + 3.330 + 0.000 + 0.000 + 0.000 + 0.000 + 0.000 + + + + + + + + H2 + O2 [=] 2 OH + + + 1.700000E+10 + 0.0 + 47780.000000 + + + H2:1.0 O2:1 + OH:2.0 + + + + + OH + H2 [=] H2O + H + + + 1.170000E+06 + 1.3 + 3626.000000 + + + OH:1.0 H2:1 + H2O:1.0 H:1 + + + + + H + O2 [=] OH + O + + + 5.130000E+13 + -0.816 + 16507.000000 + + + H:1.0 O2:1 + OH:1.0 O:1 + + + + + O + H2 [=] OH + H + + + 1.800000E+07 + 1.0 + 8826.000000 + + + O:1.0 H2:1 + OH:1.0 H:1 + + + + + H + O2 + M [=] HO2 + M + + + 2.100000E+12 + -1.0 + 0.000000 + + H2:3.3 H2O:21.0 O2:0.0 + + H:1.0 O2:1 + HO2:1.0 + + + + + H + O2 + O2 [=] HO2 + O2 + + + 6.700000E+13 + -1.42 + 0.000000 + + + H:1.0 O2:2 + HO2:1.0 O2:1 + + + + + OH + HO2 [=] H2O + O2 + + + 5.000000E+10 + 0.0 + 1000.000000 + + + OH:1.0 HO2:1 + H2O:1.0 O2:1 + + + + + H + HO2 [=] 2 OH + + + 2.500000E+11 + 0.0 + 1900.000000 + + + H:1.0 HO2:1 + OH:2.0 + + + + + O + HO2 [=] O2 + OH + + + 4.800000E+10 + 0.0 + 1000.000000 + + + O:1.0 HO2:1 + O2:1.0 OH:1 + + + + + 2 OH [=] O + H2O + + + 6.000000E+05 + 1.3 + 0.000000 + + + OH:2.0 + O:1.0 H2O:1 + + + + + H2 + M [=] H + H + M + + + 2.230000E+09 + 0.5 + 92600.000000 + + H:2.0 H2:3.0 H2O:6.0 + + H2:1.0 + H:2.0 + + + + + O2 + M [=] O + O + M + + + 1.850000E+08 + 0.5 + 95560.000000 + + + O2:1.0 + O:2.0 + + + + + H + OH + M [=] H2O + M + + + 7.500000E+17 + -2.6 + 0.000000 + + H2O:20.0 + + H:1.0 OH:1 + H2O:1.0 + + + + + H + HO2 [=] H2 + O2 + + + 2.500000E+10 + 0.0 + 700.000000 + + + H:1.0 HO2:1 + H2:1.0 O2:1 + + + + + HO2 + HO2 [=] H2O2 + O2 + + + 2.000000E+09 + 0.0 + 0.000000 + + + HO2:2.0 + H2O2:1.0 O2:1 + + + + + H2O2 + M [=] OH + OH + M + + + 1.300000E+14 + 0.0 + 45500.000000 + + + H2O2:1.0 + OH:2.0 + + + + + H2O2 + H [=] HO2 + H2 + + + 1.600000E+09 + 0.0 + 3800.000000 + + + H2O2:1.0 H:1 + HO2:1.0 H2:1 + + + + + H2O2 + OH [=] H2O + HO2 + + + 1.000000E+10 + 0.0 + 1800.000000 + + + H2O2:1.0 OH:1 + H2O:1.0 HO2:1 + + + diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/constant/CanteraTorchProperties b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/constant/CanteraTorchProperties new file mode 100755 index 00000000..4640968d --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/constant/CanteraTorchProperties @@ -0,0 +1,35 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object chemistryProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +chemistry on; +CanteraMechanismFile "H2_AR.xml"; +transportModel "UnityLewis"; +loadbalancing +{ + active true; + log true; +} +odeCoeffs +{} +inertSpecie "AR"; + +zeroDReactor +{ + //cvorcp "UV"; +} +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/constant/thermophysicalProperties b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/constant/thermophysicalProperties new file mode 100755 index 00000000..873b8e16 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/constant/thermophysicalProperties @@ -0,0 +1,18 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +inviscid false; +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/constant/turbulenceProperties b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/constant/turbulenceProperties new file mode 100755 index 00000000..ab70e94d --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/constant/turbulenceProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/blockMeshDict b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/blockMeshDict new file mode 100755 index 00000000..c4112e99 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/blockMeshDict @@ -0,0 +1,75 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 0.1; + +vertices +( + (0 0 0) + (1.2 0 0) + (1.2 1 0) + (0 1 0) + (0 0 1) + (1.2 0 1) + (1.2 1 1) + (0 1 1) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (2400 1 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + Left + { + type patch; + faces + ( + (0 4 7 3) + ); + } + Right + { + type patch; + faces + ( + (1 2 6 5) + ); + } + empty + { + type empty; + faces + ( + (0 1 5 4) + (5 6 7 4) + (3 7 6 2) + (0 3 2 1) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/controlDict b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/controlDict new file mode 100755 index 00000000..7567b959 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/controlDict @@ -0,0 +1,59 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application dfHighSpeedFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 23e-5; + +deltaT 1e-08; + +writeControl adjustableRunTime; + +writeInterval 5e-6; + +cycleWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression on; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +adjustTimeStep yes; + +maxCo 0.1; + +maxDeltaT 1; + +functions +{ + #includeFunc mag(U) +} + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/det_1D_H2_01mm/system/decomposeParDict b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/decomposeParDict similarity index 96% rename from examples/dfHighSpeedFoam/det_1D_H2_01mm/system/decomposeParDict rename to examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/decomposeParDict index 470777a2..dc84190c 100755 --- a/examples/dfHighSpeedFoam/det_1D_H2_01mm/system/decomposeParDict +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/decomposeParDict @@ -15,7 +15,7 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -numberOfSubdomains 4; +numberOfSubdomains 5; method scotch; diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/fvSchemes b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/fvSchemes new file mode 100755 index 00000000..b8df2960 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/fvSchemes @@ -0,0 +1,58 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +fluxScheme Kurganov; + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + div(tauMC) Gauss linear; + div(hDiffCorrFlux) Gauss cubic; + div(phi,Yi_h) Gauss vanLeer; +} + +laplacianSchemes +{ + default Gauss linear uncorrected; +} + +interpolationSchemes +{ + default linear; + reconstruct(rho) Minmod; + reconstruct(U) MinmodV; + reconstruct(T) Minmod; + reconstruct(Yi) Minmod; +} + +snGradSchemes +{ + default uncorrected; +} + + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/fvSolution b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/fvSolution new file mode 100755 index 00000000..17c77b5d --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/fvSolution @@ -0,0 +1,67 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + U + { + //solver smoothSolver; + //smoother GaussSeidel; + //nSweeps 2; + //tolerance 1e-17; + //relTol 0; + + solver PBiCGStab; + preconditioner DIC; + tolerance 1e-11; + relTol 0; + } + + h + { + $U; + tolerance 1e-11; + relTol 0; + } + + e + { + $U; + tolerance 1e-11; + relTol 0; + } + + "rho.*" + { + solver diagonal; + } + + "(O2|N2|Yi)" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-11; + relTol 0; + } + +} + +CENTRAL +{ +} + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/sample b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/sample new file mode 100755 index 00000000..f5ac29bb --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/sample @@ -0,0 +1,39 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object sample; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +type sets; +libs ("libsampling.so"); + +interpolationScheme cellPoint; + +setFormat raw; + +sets +( + data + { + type lineFace; + axis x; + start (-4.995 0 0); + end (4.995 0 0); + nPoints 1000; + } +); + +fields (T mag(U) p); + +// ************************************************************************* // diff --git a/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/setFieldsDict b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/setFieldsDict new file mode 100755 index 00000000..4f686528 --- /dev/null +++ b/examples/dfHighSpeedFoam/oneD_reactiveShockTube/system/setFieldsDict @@ -0,0 +1,40 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 7 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volVectorFieldValue U (0 0 0) + volScalarFieldValue T 378.656 + volScalarFieldValue p 7173 +); + +regions +( + boxToCell + { + box (0.06 -0.1 -0.1) (0.12 0.1 0.1); + fieldValues + ( + volVectorFieldValue U (-487.34 0 0) + volScalarFieldValue T 748.472 + volScalarFieldValue p 35594 + ); + } +); + + +// ************************************************************************* // diff --git a/src/dynamicFvMesh/Make/files b/src/dynamicFvMesh/Make/files new file mode 100644 index 00000000..7b6a909f --- /dev/null +++ b/src/dynamicFvMesh/Make/files @@ -0,0 +1,6 @@ +dfDynamicRefineFvMesh/multiCritRefinement.C +dfDynamicRefineFvMesh/dfDynamicRefineFvMesh.C + +dfRefinementHistoryConstraint/dfRefinementHistoryConstraint.C + +LIB = $(FOAM_USER_LIBBIN)/libdfDynamicFvMesh diff --git a/src/dynamicFvMesh/Make/options b/src/dynamicFvMesh/Make/options new file mode 100644 index 00000000..e4f8715a --- /dev/null +++ b/src/dynamicFvMesh/Make/options @@ -0,0 +1,21 @@ +EXE_INC = -std=c++14\ + -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(DF_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude + +LIB_LIBS = \ + -ltriSurface \ + -lmeshTools \ + -ldynamicMesh \ + -ldynamicFvMesh \ + -lfiniteVolume \ + -lextrudeModel \ + -ldecompositionMethods \ + $(FOAM_USER_LIBBIN)/libnewdynamicMesh.so\ + -L$(FOAM_LIBBIN)/dummy \ + -lmetisDecomp -lptscotchDecomp -lscotchDecomp + diff --git a/src/dynamicFvMesh/dfDynamicRefineFvMesh/dfDynamicRefineFvMesh.C b/src/dynamicFvMesh/dfDynamicRefineFvMesh/dfDynamicRefineFvMesh.C new file mode 100644 index 00000000..586d4821 --- /dev/null +++ b/src/dynamicFvMesh/dfDynamicRefineFvMesh/dfDynamicRefineFvMesh.C @@ -0,0 +1,1852 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "dfDynamicRefineFvMesh.H" +#include "addToRunTimeSelectionTable.H" +#include "surfaceInterpolate.H" +#include "volFields.H" +#include "polyTopoChange.H" +#include "surfaceFields.H" +#include "syncTools.H" +#include "pointFields.H" +#include "sigFpe.H" +#include "cellSet.H" +#include "wedgePolyPatch.H" +#include "emptyPolyPatch.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(dfDynamicRefineFvMesh, 0); + addToRunTimeSelectionTable(dynamicFvMesh, dfDynamicRefineFvMesh, IOobject); + + + // Helper class for accessing max cell level of faces accross processor patches + template + class combineMaxOp + { + public: + void operator()(Type& x, const Type& y) const + { + x = max(x, y); + } + }; +} + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +Foam::label Foam::dfDynamicRefineFvMesh::count +( + const PackedBoolList& l, + const unsigned int val +) +{ + label n = 0; + forAll(l, i) + { + if (l.get(i) == val) + { + n++; + } + + // debug also serves to get-around Clang compiler trying to optimsie + // out this forAll loop under O3 optimisation + if (debug) + { + Info<< "n=" << n << endl; + } + } + + return n; +} + + +void Foam::dfDynamicRefineFvMesh::calculateProtectedCells +( + PackedBoolList& unrefineableCell +) const +{ + if (protectedCell_.empty()) + { + unrefineableCell.clear(); + return; + } + + const labelList& cellLevel = meshCutter_->cellLevel(); + + unrefineableCell = protectedCell_; + + // Get neighbouring cell level + labelList neiLevel(nFaces()-nInternalFaces()); + + for (label facei = nInternalFaces(); facei < nFaces(); facei++) + { + neiLevel[facei-nInternalFaces()] = cellLevel[faceOwner()[facei]]; + } + syncTools::swapBoundaryFaceList(*this, neiLevel); + + + while (true) + { + // Pick up faces on border of protected cells + boolList seedFace(nFaces(), false); + + forAll(faceNeighbour(), facei) + { + label own = faceOwner()[facei]; + bool ownProtected = unrefineableCell.get(own); + label nei = faceNeighbour()[facei]; + bool neiProtected = unrefineableCell.get(nei); + + if (ownProtected && (cellLevel[nei] > cellLevel[own])) + { + seedFace[facei] = true; + } + else if (neiProtected && (cellLevel[own] > cellLevel[nei])) + { + seedFace[facei] = true; + } + } + for (label facei = nInternalFaces(); facei < nFaces(); facei++) + { + label own = faceOwner()[facei]; + bool ownProtected = unrefineableCell.get(own); + if + ( + ownProtected + && (neiLevel[facei-nInternalFaces()] > cellLevel[own]) + ) + { + seedFace[facei] = true; + } + } + + syncTools::syncFaceList(*this, seedFace, orEqOp()); + + + // Extend unrefineableCell + bool hasExtended = false; + + for (label facei = 0; facei < nInternalFaces(); facei++) + { + if (seedFace[facei]) + { + label own = faceOwner()[facei]; + if (unrefineableCell.get(own) == 0) + { + unrefineableCell.set(own, 1); + hasExtended = true; + } + + label nei = faceNeighbour()[facei]; + if (unrefineableCell.get(nei) == 0) + { + unrefineableCell.set(nei, 1); + hasExtended = true; + } + } + } + for (label facei = nInternalFaces(); facei < nFaces(); facei++) + { + if (seedFace[facei]) + { + label own = faceOwner()[facei]; + if (unrefineableCell.get(own) == 0) + { + unrefineableCell.set(own, 1); + hasExtended = true; + } + } + } + + if (!returnReduce(hasExtended, orOp())) + { + break; + } + } +} + + +void Foam::dfDynamicRefineFvMesh::readDict() +{ + dictionary refineDict + ( + IOdictionary + ( + IOobject + ( + "dynamicMeshDict", + time().constant(), + *this, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE, + false + ) + ).subDict(typeName + "Coeffs") + ); + + List> fluxVelocities = List> + ( + refineDict.lookup("correctFluxes") + ); + // Rework into hashtable. + correctFluxes_.resize(fluxVelocities.size()); + forAll(fluxVelocities, i) + { + correctFluxes_.insert(fluxVelocities[i][0], fluxVelocities[i][1]); + }; + + if (refineDict.found("mapSurfaceFields")) + { + List surfFlds = List + ( + refineDict.lookup("mapSurfaceFields") + ); + // Rework into hashtable. + correctFluxes_.resize(surfFlds.size()); + forAll(surfFlds, i) + { + mapSurfaceFields_.insert(surfFlds[i], surfFlds[i]); + }; + } + + dumpLevel_ = Switch(refineDict.lookup("dumpLevel")); +} + + +// Refines cells, maps fields and recalculates (an approximate) flux +Foam::autoPtr +Foam::dfDynamicRefineFvMesh::refine +( + const labelList& cellsToRefine +) +{ + // Mesh changing engine. + polyTopoChange meshMod(*this); + + // Play refinement commands into mesh changer. + meshCutter_->setRefinement(cellsToRefine, meshMod); + + // Create mesh (with inflation), return map from old to new mesh. + //autoPtr map = meshMod.changeMesh(*this, true); + autoPtr map = meshMod.changeMesh(*this, false); + + Info<< "Refined from " + << returnReduce(map().nOldCells(), sumOp