CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   new curvature model with interFoam (https://www.cfd-online.com/Forums/openfoam-programming-development/70296-new-curvature-model-interfoam.html)

DaChris November 19, 2009 12:13

new curvature model with interFoam
 
Hi,

I want to test a new curvature model by using InterFoam. When I try to compile the following code I get an error, but I don't know how to fix it. I hope, someone can help me. :)

Code:

//Cell gradient of gamma
    volVectorField gradGamma = fvc::grad(gamma);
    // Interpolated face-gradient of gamma
   
    surfaceScalarField phiGradGamma = fvc::interpolate(gradGamma)& mesh.Sf();
   
    //curvature 
    surfaceScalarField kappa =    ((1) / mag(gradGamma))
                    * (((gradGamma)/(mag(gradGamma)))
                    * fvc::grad(mag(gradGamma))
      //line.29=>              - fvc::div(phiGradGamma));

And this is the first error:
Quote:

curvature.H:29: error: conversion from ‘Foam::tmp<Foam::GeometricField<Foam::Tensor<doubl e>, Foam::fvPatchField, Foam::volMesh> >’ to non-scalar type ‘Foam::surfaceScalarField’ requested

kathrin_kissling November 20, 2009 10:01

Dear Chris,

the error you get tells you your problem quite clearly. You just need to check carefully.
You want to calculate a surfaceScalarField for the curvature. Obviosly there is a volTensorField somewhere inside your calculation. Because it is not possible to initialize a surfaceScalarField by a volTensorField you get an error.
Go carefully through your expression and you will find

//curvature
surfaceScalarField kappa = ((1) / mag(gradGamma))
* (((gradGamma)/(mag(gradGamma)))
* fvc::grad(mag(gradGamma))
//line.29=> - fvc::div(phiGradGamma));(1)/mag(gradGamma) gives you a volScalarField (remember you want to have a surfaceScalarField, at least you seam to initialize it that way)

you multiply it by the volVectorField (gradGamma)/mag(gradGamma)
now you have a volVectorField

now you perform another multiplication and I'm not sure what you inted to do. you multiply it by another volVectorField. The * operator gives you the outer product of two vectors and produces a tensor. Now we have your volTensorField. In addition you now want to subtract the divergence of a scalar? What is that?

In summary:

1. you are not allowed to mix fields defined on the faces and on the volumes.

2. you should go over your mathematics, I think theres a bug inside your implementation or inside the equation you are trying to implement. If you need help on that, we would need the equation

Hope this helps
Best

Kathrin

DaChris November 21, 2009 10:42

Dear Kathrin,

thank you for the hints. I think my implementation is blemished. I'll go through my implementation and try to correct it. If this doesn't work, I would post the equation.


Best

Chris

DaChris December 2, 2009 06:26

Hi,

I did it and compiled the solver, but a new problem appears.

Here is the equation: \kappa=\frac{1}{|\nabla\gamma|}\ast\left[\frac{\nabla\gamma}{|\nabla\gamma|}\circ\nabla|\nabla\gamma|-\nabla\circ\nabla\gamma\right]


Code:

volVectorField gradGamma = fvc::grad(gamma);

volScalarField kappa =    ((1) / mag(gradGamma))
                    *((((gradGamma)/(mag(gradGamma))) 
                    & fvc::grad(mag(gradGamma)))
                    - (fvc::div(gradGamma)
                    ));

Further the undefined keyword is caused by (fvc::div(gradGamma)).
Quote:

keyword div(grad(gamma)) is undefined in dictionary "~/case/yTestCase2/system/fvSchemes::divSchemes"

file: ~/case/yTestCase2/system/fvSchemes::divSchemes from line 33 to line 40.

From function dictionary::lookupEntry(const word& keyword) const
in file db/dictionary/dictionary.C at line 213.

FOAM exiting
When I define the keyword in fvSchemes, I get an EOF error for Gauss upwind e.g and when I try Gauss linear, I get a floating Point exception.

Quote:

#0 Foam::error::printStack(Foam::Ostream&) in "/home/caelinux/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#1 Foam::sigFpe::sigFpeHandler(int) in "/home/caelinux/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#2 ?? in "/lib/libc.so.6"
#3 Foam::divide(Foam::Field<double>&, double const&, Foam::UList<double> const&) in "/home/caelinux/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#4 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator/<Foam::fvPatchField, Foam::volMesh>(Foam::dimensioned<double> const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) in "/home/caelinux/OpenFOAM/caelinux-1.5/applications/bin/linux64GccDPOpt/myFoam"
#5 main in "/home/caelinux/OpenFOAM/caelinux-1.5/applications/bin/linux64GccDPOpt/myFoam"
#6 __libc_start_main in "/lib/libc.so.6"
#7 Foam::regIOobject::readIfModified() in "/home/caelinux/OpenFOAM/caelinux-1.5/applications/bin/linux64GccDPOpt/myFoam"
Floating point exception

kathrin_kissling December 2, 2009 06:47

Hi Chris,

what you yre trying to do is applying a laplacian. So you should do something like

fvc::laplacian(gamma)

instead of

fvc::div(gradGamma)

be very carefull with the mathematics!

of course, then you need to specify a laplacian scheme.

You can also go


fvc::laplacian(gamma, nameOfYourDesiredScheme)

then the scheme is hardcoded and cannot be changed from fvSchemes.

Check on src/finiteVolume/finiteVolume/fvc/fvcLaplacian.H/.C

for details.

Hope this helps

Kathrin

DaChris December 2, 2009 07:41

Hi kathrin,

I tried fvc::laplacian(gamma) with Gauss linear corrected, running the case and I get a floating point exception.

Quote:

#0 Foam::error::printStack(Foam::Ostream&) in "/home/caelinux/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#1 Foam::sigFpe::sigFpeHandler(int) in "/home/caelinux/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#2 ?? in "/lib/libc.so.6"
#3 Foam::divide(Foam::Field<double>&, double const&, Foam::UList<double> const&) in "/home/caelinux/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#4 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator/<Foam::fvPatchField, Foam::volMesh>(Foam::dimensioned<double> const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) in "/home/caelinux/OpenFOAM/caelinux-1.5/applications/bin/linux64GccDPOpt/cstFoam"
#5 main in "/home/caelinux/OpenFOAM/caelinux-1.5/applications/bin/linux64GccDPOpt/myFoam"
#6 __libc_start_main in "/lib/libc.so.6"
#7 Foam::regIOobject::readIfModified() in "/home/caelinux/OpenFOAM/caelinux-1.5/applications/bin/linux64GccDPOpt/myFoam"
Floating point exception
Unfortunately, my OpenFoam skills are too low to interpret this error.

kathrin_kissling December 2, 2009 08:57

Could you do me a favour?

Get rid of the laplacian term for a second, and check whether the problem really is in that one.

If this is not the point.

Maybe your dividing by zero somewhere.
Try

1/(mag(gradGamma)+SMALL)
where SMALL is a small number rescueing you from dividing by zero, which will definitly give you a floating point exeption.

Best

Kathrin

DaChris December 2, 2009 12:37

Hi Kathrin,

I tried +SMALL, but it seems there are more divisions by zero. I think this division makes problems:

gradGamma/mag(gradGamma)

When I look into interfaceProperties, I find this:
surfaceVectorField nHatfv = gradGammaf/(mag(gradGammaf) + deltaN_)

I'm not sure, but I think that this missing deltaN_ causes the floating point exceptions.

deltaN_ ( "deltaN" 1e-8/pow(average(gamma.mesh().V()), 1.0/3.0) )


Edit:
I fixed the floating point exception. The problem was a couple of division by zero. ;) Thank you very much Kathrin for the hint. But now, there is a dimension problem. :)

Best

Chris

duongquaphim October 22, 2010 08:45

Hi Chris,

I am doing Taylor bubble simulation with OF. I also have some problems with curvature since it is very important in my flow.

Do you get a better result with your model of calculating curvature? Can you share some of your tests?

Regards,

Duong

Andrea_85 March 2, 2011 09:18

Hi,

I also try to define the curvature of the interface for my simulation using interFoam. Has anyone found a good way to get it?? because with the classical definition in interfaceProperties.C i get strange results.

Thanks
andrea

idefix May 31, 2013 09:53

Hi,

I am a little confused of how the interface in a cell is modeled in the interFoam-solver. I´ve got difficulties to imagine one step.

If I am right, the following steps are repeated:
- alpha1 is calculated
- interface unit normal vector is calculated (PhD Rusche eq(4.17))
- the curvature is calculated with this normal vector.

I can´t really understand how I get the interface from the curvature.

Can somebody help me please?

Thanks a lot
Idefix

vigneshTG July 10, 2014 10:24

Hi all !!

I am also trying to model the surface tension force with a new formulation :F_{\sigma}=\sigma* \nabla^{2}\alpha* \hat{n}

I have modified some of the lines (in bold letters) in PEqn.H file in interfoam solver directory to model the force.
Code:

volScalarField lapalpha(fvc::laplacian(alpha1));
surfaceScalarField phig
    (
        (

                fvc::interpolate(lapalpha)*interface.sigma()*interface.nHatf()
          - ghf*fvc::snGrad(rho)
        )*rAUf*mesh.magSf()
    );

I was able to compile the solver but, when i run a test case, i get floating point exception (core dumped) error. Can someone help me with this ?
Also, I want to know whether i have coded correctly ?

I am new to Openfoam !!

Thanks and Regards
Vignesh TG

Martin_K_lalelu February 6, 2015 04:36

Hi Vignesh,

curvature calculation seems to be crucial in interfoam/CSF, did you make any progress with this approach?


best regards

Martin



vigneshTG February 6, 2015 05:04

Hi Martin,

I implemented the above formulation but it doesn't work properly. I suggest you to give a try to the code interfoamssf posted in this thread !! There is also a paper by the same person regarding its formulation.

also this thread how is parasitic currents now ?

Martin_K_lalelu February 6, 2015 07:19

Thanks a lot for your answer, I will have a look!

Z.Q. Niu July 31, 2017 07:57

Dear Martin,
Have you got any new idea about the curvature model for interFoam ?


All times are GMT -4. The time now is 04:23.