Download data/tutorials/potentialFoam/cylinder/system/functions from introvoyz042/OpenFOAM-dev: direct link, hf CLI and curl.
- Browser
- Download file 3.09 kB
-
https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/tutorials/potentialFoam/cylinder/system/functions
- Command line
-
hf download hf://datasets/introvoyz042/OpenFOAM-dev/data/tutorials/potentialFoam/cylinder/system/functions
-
curl -L -o functions https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/tutorials/potentialFoam/cylinder/system/functions
3.09 kB
| /*--------------------------------*- C++ -*----------------------------------*\ | |
| ========= | | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | |
| \\ / O peration | Website: https://openfoam.org | |
| \\ / A nd | Version: dev | |
| \\/ M anipulation | | |
| \*---------------------------------------------------------------------------*/ | |
| FoamFile | |
| { | |
| format ascii; | |
| class dictionary; | |
| location "system"; | |
| object functions; | |
| } | |
| // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | |
| error | |
| { | |
| type coded; | |
| // Load the library containing the 'coded' functionObject | |
| libs ("libutilityFunctionObjects.so"); | |
| codeInclude | |
| #{ | |
| #include "volFields.H" | |
| #}; | |
| codeEnd | |
| #{ | |
| // Lookup U | |
| Info<< "Looking up field U\n" << endl; | |
| const volVectorField& U = mesh().lookupObject<volVectorField>("U"); | |
| Info<< "Reading inlet velocity uInfX\n" << endl; | |
| scalar ULeft = 0.0; | |
| label leftI = mesh().boundary().findIndex("left"); | |
| const fvPatchVectorField& fvp = U.boundaryField()[leftI]; | |
| if (fvp.size()) | |
| { | |
| ULeft = fvp[0].x(); | |
| } | |
| reduce(ULeft, maxOp()); | |
| dimensionedScalar uInfX | |
| ( | |
| "uInfx", | |
| dimensionSet(0, 1, -1, 0, 0), | |
| ULeft | |
| ); | |
| Info << "U at inlet = " << uInfX.value() << " m/s" << endl; | |
| scalar magCylinder = 0.0; | |
| label cylI = mesh().boundary().findIndex("cylinder"); | |
| const fvPatchVectorField& cylFvp = mesh().C().boundaryField()[cylI]; | |
| if (cylFvp.size()) | |
| { | |
| magCylinder = mag(cylFvp[0]); | |
| } | |
| reduce(magCylinder, maxOp()); | |
| dimensionedScalar radius | |
| ( | |
| "radius", | |
| dimensionSet(0, 1, 0, 0, 0), | |
| magCylinder | |
| ); | |
| Info << "Cylinder radius = " << radius.value() << " m" << endl; | |
| volVectorField UA | |
| ( | |
| IOobject | |
| ( | |
| "UA", | |
| mesh().time().name(), | |
| U.mesh(), | |
| IOobject::NO_READ, | |
| IOobject::AUTO_WRITE | |
| ), | |
| U | |
| ); | |
| Info<< "\nEvaluating analytical solution" << endl; | |
| const volVectorField& centres = UA.mesh().C(); | |
| volScalarField magCentres(mag(centres)); | |
| volScalarField theta(acos((centres & vector(1,0,0))/magCentres)); | |
| volVectorField cs2theta | |
| ( | |
| cos(2*theta)*vector(1,0,0) | |
| + sin(2*theta)*vector(0,1,0) | |
| ); | |
| UA = uInfX*(dimensionedVector(vector(1,0,0)) | |
| - pow((radius/magCentres),2)*cs2theta); | |
| // Force writing of UA (since time has not changed) | |
| UA.write(); | |
| volScalarField error("error", mag(U-UA)/mag(UA)); | |
| Info<<"Writing relative error in U to " << error.objectPath() | |
| << endl; | |
| error.write(); | |
| #}; | |
| } | |
| // ************************************************************************* // | |