|
[Sponsors] |
Plotting Surface tension force with interfoam |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 11, 2015, 19:18 |
Plotting Surface tension force with interfoam
|
#1 |
Member
Mahmoud Aboukhedr
Join Date: Feb 2014
Location: London
Posts: 40
Rep Power: 12 |
ear Foamrs,
I was looking in all the threads for a clear way to plot the surface tension forces, but I could not find any. So i tried to change the way interfoam (2.2.0) calculate the forces in interFoam, So I changed the interface.C file and added this line surfaceScalarField f = fvc::interpolate(interface.sigmaK())*fvc::snGrad(a lpha1); Then I changed the Uequ.H File to be fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(rhoPhi, U) + turbulence->divDevRhoReff(rho, U) ); UEqn.relax(); if (pimple.momentumPredictor()) { solve ( UEqn == fvc::reconstruct ( ( f - ghf*fvc::snGrad(rho) - fvc::snGrad(p_rgh) ) * mesh.magSf() ) ); } by doing so, no the solver calculate the surface tension force separately, then added to the momentum equation, I tried it and it compiles and works fine... Now I need to plot for the (f) and the interface curvature (K) in the processioning. So I added these lines to the create field file; volVectorField f ( IOobject ( "f", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedVector("f",dimMass/(dimLength*dimLength*dimTime*dimTime), vector(0,0,0)) ); volScalarField K ( IOobject ( "K", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimless/dimTime ); It compile fine .... but the problem that ;; when i plot for f or K ... the field is empty .. So anyone can help ??? I can c f and K in each time step while am postpossessing .. but zero values .. Any help will do .. thanks Mahmoud |
|
September 12, 2015, 13:46 |
|
#2 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
For OpenFOAM-2.2;
First declare f as surfaceScalarField in createField.H Code:
surfaceScalarField f ( IOobject ( "f", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) ); Code:
f = fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1); Because it is surfaceField, it cannot loaded automatically in paraFoam. There is a small trick to load it as mentioned HERE For OpenFOAM-2.3 and above, there are few changes in the transportModels library which give a new function to calculate the surface tension force directly. Therefore instead of Code:
fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) Code:
mixture.surfaceTensionForce() Hassan |
|
September 12, 2015, 20:28 |
Plotting Surface tension force with interfoam
|
#3 |
Member
Mahmoud Aboukhedr
Join Date: Feb 2014
Location: London
Posts: 40
Rep Power: 12 |
Dear Hassen,
Thanks for your reply, that works fine for me. I will just re-post the steps for future reference so Foamers can use it. So to plot surface scale field one can add the line in red to the end of the interFoam.C file as following Code:
f = fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1); runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; Code:
fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(rhoPhi, U) + turbulence->divDevRhoReff(rho, U) ); UEqn.relax(); if (pimple.momentumPredictor()) { solve ( UEqn == fvc::reconstruct ( ( f - ghf*fvc::snGrad(rho) - fvc::snGrad(p_rgh) ) * mesh.magSf() ) ); } Code:
// Construct interface from alpha1 distribution interfaceProperties interface(alpha1, U, twoPhaseProperties); surfaceScalarField f ( IOobject ( "f", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) ); 1-Run foamToVTK -surfaceFields 2-Run paraFoam. 3-Load the surface fields base file "VTK/surfaceFields/surfaceFields_..vtk", so you can see them with the respective time snapshot. 4-Then apply the "Glyphs" filter to this file and you should see the respective points in glyph form. Still ... am looking for plotting the Vol vector field !! So any one can help in doing so?? Mahmoud |
|
September 13, 2015, 07:02 |
|
#4 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
If f will be used in UEqn, it should be calculated just before Pressure-velocity PIMPLE corrector loop.
To calculate f as volVectorField, define a new field in createFields as follows; Code:
volVectorField fV ( IOobject ( "fV", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), fvc::reconstruct(f* mesh.magSf()) ); Code:
fV = fvc::reconstruct(f* mesh.magSf()); in createFields Code:
volVectorField fV ( IOobject ( "fV", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), fvc::reconstruct((fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1))* mesh.magSf()) ); Code:
fV = fvc::reconstruct((fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1))* mesh.magSf()); Best wishes, Hassan |
|
December 1, 2016, 08:42 |
|
#5 |
Member
Camille Bilger
Join Date: Jul 2013
Posts: 43
Rep Power: 13 |
Hi,
This all worked wonderfully, thank you. I am trying to do a similar exercise with a different volVectorField nHat_ (interface unit normal) from interfaceProperties.C: Code:
volVectorField nHat_ = gradGamma/(mag(gradGamma) + deltaN_); forAll(nHat_.boundaryField(), patchi) { nHat_.boundaryField()[patchi] = nHatfv.boundaryField()[patchi]; } K_ = -fvc::div(nHatf_) + (nHat_ & fvc::grad(nHatfv) & nHat_); and define it in the constructor as: Code:
nHat_ ( IOobject ( "nHat", gamma_.time().timeName(), gamma_.mesh() ), gamma_.mesh(), dimensionedVector("nHat", dimless, vector::zero) ), Code:
interface.correct(); Code:
volVectorField nHat = interface.nHat(); if(runTime.write()) { nHat.write(); } Code:
interfaceProperties interface(gamma, U, twoPhaseProperties); volVectorField nHat ( IOobject ( "nHatf", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), interface.nHat() ); But nHat does not seem to be passed to the solver correctly. Values are being printed inside interfaceProperties.C But from the solver I get an empty internalField uniform(0 0 0) and at boundaries: calculated (0 0 0) Any tips? It's strange that this procedure works for the volScalarField K but not for this volVectorField. |
|
December 1, 2016, 09:37 |
Regarding nHat in post processing
|
#6 |
Member
Mahmoud Aboukhedr
Join Date: Feb 2014
Location: London
Posts: 40
Rep Power: 12 |
Hello Camille,
Am not 100% sure I got what you want to do, though I can see the problem. For me the first part of the problem is using nHat for postprocessing like using K in postprocessing as we did before, If am not wrong. For starter you can try adding those 4 lines to the main solver just to get nHat for post-processing; In the main interFoam.C add Code:
const volVectorField gradGamma = fvc::grad(gamma); const dimensionedScalar deltaN("deltaN", dimensionSet(0,-1,0,0,0,0,0), 1E-16); nHatF = (gradGamma/(mag(gradGamma)+deltaN)); Code:
volVectorField nHatF ( IOobject ( "nHatF", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); nHat.write(); When you run the case, I will suppose it will stop and ask for nHatF file in the 0 folders >> So just before running, make a copy of the U file and rename it nHatF ... and run This should work fine just for getting nHat for post processing. Let me know if it worked because it may not If you want to use nhat for different calculation in the interfaceprop. I think you need to clarify a bit what exactly you want to do.. Also we still have the code master (hk318i) to check If he can help Mahmoud,, |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ICEM] Problems with coedge curves and surfaces | tommymoose | ANSYS Meshing & Geometry | 6 | December 1, 2020 12:12 |
[Gmsh] Problem with Gmsh | nishant_hull | OpenFOAM Meshing & Mesh Conversion | 23 | August 5, 2015 03:09 |
Surface Tension Test Cases | sega | OpenFOAM Running, Solving & CFD | 2 | March 8, 2011 13:19 |
surface tension force | Ray | Main CFD Forum | 0 | October 17, 2001 16:42 |
gravitational force for free surface flow | Jongtae Kim | Main CFD Forum | 1 | July 2, 2000 12:57 |