CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Marangoni bc (

zakifoam November 6, 2007 11:59

Hi all, I am trying to spec
Hi all,

I am trying to specify Marangoni boundary condition on the top boundary of a cavity. At first, I am trying to 'enforce' this b.c in the main code I am using (boussinesqBouyantFoam). Later, I will try to learn how to incorporate it in a new b.c library (i.e the elegant way).

The b.c is:

du/dy = (dSigma/dT)*(dT/dx)/mu
dw/dy = (dSigma/dT)*(dT/dz)/mu

where (dSigma/dT) is temperature gradient of surface tension, assumed to be constant.

The implementation is as follows:

volVectorField gradT = fvc::grad(T);

volScalarField dTdx = gradT.component(0);
volScalarField dTdy = gradT.component(1);
volScalarField dTdz = gradT.component(2);

label patchI1 = mesh.boundaryMesh().findPatchID("top");

volScalarField u = U.component(0);
volScalarField v = U.component(1);
volScalarField w = U.component(2);

fixedGradientFvPatchScalarField& bufferu = refCast<fixedgradientfvpatchscalarfield>(u.boundar yField()[patchI1]);
fixedGradientFvPatchScalarField& bufferv = refCast<fixedgradientfvpatchscalarfield>(v.boundar yField()[patchI1]);
fixedGradientFvPatchScalarField& bufferw = refCast<fixedgradientfvpatchscalarfield>(w.boundar yField()[patchI1]);

scalarField graduyTop = bufferu.snGrad();
scalarField gradwyTop = bufferw.snGrad();

fvPatchScalarField& dTdxTop = dTdx.boundaryField()[patchI1];
fvPatchScalarField& dTdzTop = dTdz.boundaryField()[patchI1];

forAll (graduyTop, faceI1)
graduyTop[faceI1] = dsigmadT.value()*dTdxTop[faceI1]/mu.value();

forAll (gradwyTop, faceI1)
gradwyTop[faceI1] = dsigmadT.value()*dTdzTop[faceI1]/mu.value();


There was no error message upon compiling. For the simulation, I used fixedGradient b.c for velocity at top surface, i.e:

in 0/U:

type fixedGradient;
gradient uniform (0 0 0);

When running the simulation, I got this error message:

--> FOAM FATAL ERROR : Attempt to cast type calculated to type fixedGradient

From function refCast<to>(From&)
in file /home/zaki/OpenFOAM/OpenFOAM-1.3/src/OpenFOAM/lnInclude/typeInfo.H at line 103.

FOAM aborting

marangoniFoam [0x4142cb]

Could anyone explain and help me with this problem?



tehache November 8, 2007 05:14

Hi Zaid, I have not really
Hi Zaid,

I have not really lookked at your error - but I have implemented (and tested) a Marangoni boundary condition.
Have a look at it, maybe it serves you.


Thomas marangoniFvPatchVectorField.H marangoniFvPatchVectorField.C

zakifoam January 22, 2008 13:46

Hi Thomas, Thanks for the b
Hi Thomas,

Thanks for the b.c code you provided. Sorry for not replying for long time since I've been busy with other things. Now I want to concentrate back on marangoni b.c.

I tried to compile the marangoni b.c but I got the following error:

/home/zaki/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude/fvPatchField.H:132 : instantiated from 'Foam::fvPatchField<type>::adddictionaryConstructo rToTable<fvpatchfieldtype>:: adddictionaryConstructorToTable(const Foam::word&) [with fvPatchFieldType = Foam::marangoniFvPatchVectorField, Type = Foam::Vector<double>]'
marangoniFvPatchVectorField.C:228: instantiated from here
/home/zaki/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude/fvPatchField.H:132 : error: cannot allocate an object of abstract type 'Foam::marangoniFvPatchVectorField'
marangoniFvPatchVectorField.H:51: note: since type 'Foam::marangoniFvPatchVectorField' has pure virtual functions
make: *** [Make/linux64GccDPOpt/marangoniFvPatchVectorField.o] Error 1

Could you explain what might happen?



tehache February 25, 2008 07:35

Hi Zaki, I think that versi
Hi Zaki,

I think that version I posted worked for OpenFoam-1.3.
I have a version adapted to version 1.4.1, which you are apparently using, but I have to say I right now do not remember if I tested that. I have set up an installation for 1.4.1 some time ago, compiled it, but am actually still using the 1.4 version. So, here, at your own risk, the 1.4.1 version.
Please note, that in 1.4.1 also the directory structure in fvPatchFields changed, if I remember correctly.

Good luck...

Thomas marangoniFvPatchVectorField.H marangoniFvPatchVectorField.C

zakifoam February 25, 2008 11:51

Hi Thomas, Thanks a lot! ht
Hi Thomas,

Thanks a lot! The compilation was successfully done. Now I'm trying to run a test case.


mike_jaworski January 19, 2009 17:10

Hi Thomas and Zaki, Is it
Hi Thomas and Zaki,
Is it possible for one of you to upload an example solver and case file using this boundary file?

Mike J.

mike_jaworski January 21, 2009 19:16

Hello FOAMers, I am havi
Hello FOAMers,
I am having difficulty getting the marangoni BC to operate correctly and I am hoping for a hint about what I am doing wrong.

First, I am integrating this BC into a solver which uses the conjugateHeatFoam as a template and so have two mesh regions coupled by the energy equation (the fluid portion is replaced with the mhdFoam solver).

Second, I have compiled the BC with the help of the instructions here. It compiles and apparently links correctly.

Third, I have a case file and the <case>/0/U file includes the BC as follows:

type marangoni;
marangonicoeff 0.147e-3;
Now, when I run the case like this, I get a message that reads:

marangoniFvPatchVectorField::snGrad(): object gradT not found!
and no flow. So, looking at the source code which Thomas above supplied, I find the following line:

if(!db().foundObject<vectorfield>("gradT")) {
Info << " marangoniFvPatchVectorField::snGrad(): object gradT not found!" << endl;
I think to myself: ah, it expects me to create a volVectorField called gradT somewhere in the solver to calculate this material.

I dutifully add the line:

volVectorField gradT = fvc::grad(T);
underneath the reading in of the temperature field in the solver code.

The solver compiles without a hitch.

However, when I run the solver, I get the following error message:

Reading field p

Reading field T

Creating field grad(T)

request for volScalarField T from objectRegistry solid failed
available objects of type volScalarField are


From function objectRegistry::lookupObject<type>(const word&) const
in file /home/mjaworsk/OpenFOAM/OpenFOAM-1.5-dev/src/OpenFOAM/lnInclude/objectRegistryTe mplates.C at line 142.

FOAM aborting


Can anyone help me with this error?

Thank you,
Mike J.

kati January 22, 2009 08:20

Hi Mike, The BC is looking
Hi Mike,

The BC is looking for gradT in database, so you should create it like you do for fields that are written and read from time dumps, i.e. something with IOobject.


mike_jaworski January 23, 2009 03:48

Hi Kati, This did, indeed
Hi Kati,
This did, indeed, solve my problem. Thank you.
Mike J.

Hanna April 20, 2009 10:56

I'm new to OpenFOAM and C++ language.
I have a diffucult using the "MarangoniFvPatchVectorField".

Now, I am bringing this BC in solver (icoheatMaFOAM).
However, I couldn't compile the solver and getting following error message.

…/lnInclude/marangoniFvPatchVectorField.H:107: error: cannot allocate an object of abstract type ‘Foam::marangoniFvPatchVectorField’

…/lnInclude/marangoniFvPatchVectorField.H:58: note: because the following virtual functions are pure within ‘Foam::marangoniFvPatchVectorField’:
…/lnInclude/transformFvPatchField.H:109: note: Foam::tmp<Foam::fvPatchField<Type> > Foam::transformFvPatchField<Type>::clone(const Foam::DimensionedField<Type, Foam::volMesh>&) const [with Type = Foam::Vector<double>]
…/lnInclude/marangoniFvPatchVectorField.H: In member function ‘virtual Foam::tmp<Foam::fvPatchField<Foam::Vector<double> > > Foam::marangoniFvPatchVectorField::clone(const Foam::vectorField&) const’:
…/lnInclude/marangoniFvPatchVectorField.H:123: error: cannot allocate an object of abstract type ‘Foam::marangoniFvPatchVectorField’
…/lnInclude/marangoniFvPatchVectorField.H:58: note: since type ‘Foam::marangoniFvPatchVectorField’ has pure virtual functions

Could anyone help me with this error.
Thank you.


isabel March 31, 2010 13:15

Hello everybody,

I have succesfully compiled the boundary condition which Thomas tehache supplied.
In the solver, I have created the gradT as an IOobject:

volVectorField gradT

In the boundary conditions I wrote this:

type marangoni;
marangonicoeff 0.05;

The code compiles and runs ok. But when I execute the command foamDataToFluent (I am using Fluent as a posprocessor) I have the following warning:

Time = 0
Converting field pd
Converting field T
marangoniFvPatchVectorField::snGrad(): object gradT not found!
marangoniFvPatchVectorField::snGrad(): object gradT not found!
Converting field gradT

gradT is defined but the solver do not find it. And in the postprocessor I can see that gradT is not zero and is calculated oK.

Other problem is that the solver is not aplying this condition, i.e. although I set the marangonicoeff = 1000000, I have no difference between marangonicoeff = 0.05 or marangonicoeff = 0

Does anybody know which is the problem. May be the boundary conditions of temperature or velocity?

tehache April 1, 2010 08:25

I have to leave now (urgent holidays...:)) ... but promise to post next week the version I am currently using with OpenFoam 1.6.x, where the value field is beeing written, and which needed changes to work with 1.6.x.


tehache April 9, 2010 03:28

I updated the boundary condition a little (its now writing also its value, was missing before..), and its working for me now with 1.6.x.
As the testcase was too large to upload here, please find it (and the B.C.) at the links given below.
Under the link named MarangoniTest I add a small testcase. Gravity is set to 0, Marangoni-Number is small in order to obtain a stationary and axisymmetric solution (although calculation is 3D), which I have compared to results from our own 2D-Code Crysmas, and with Fluent, results are (within some percent, did not check grid dependence..) the same.
Therefore, I personally trust it, but dont give any guarantee :)

I have run the testcase using a slightly modified buoyantBoussinesqSimpleFoam:

add this to createFields to store temperature gradients:

Info<< "Generating/reading field gradT\n" << endl;
volVectorField gradT

and add this in the solver code:

-> gradT=fvc::grad(T);

specify the B.C. in U as follows:
type marangoni;
marangonicoeff -9.9e-06;

the marangonicoeff to specifiy is the usual marangonicoefficient (d sigma/dT) divided by DYNAMIC viscosity!


isabel April 19, 2010 03:19

Thank you very much, tehache. Now my problem works Ok.

magarajan84 February 15, 2012 06:15

marangoni stress
hey everyone,
i am trying to simulate selective laser sintering process with marangoni stress function wrt time as a boundary condition can u suggest me where i can apply this condition. i am using fluent as my solver and if udf is required can somebody help me with that..

thank you.

Sherlock_1812 June 13, 2013 06:31

returning gradient at the boundary
Hi everyone,

I have gone through the marangoniFvPatchVectorField.C file and I have difficulty in understanding parts of the code as I'm not very good at C++ and am new to OpenFOAM

what do the following lines of the code mean?

tmp<vectorField > marangoniFvPatchVectorField::snGrad() const
    //Info << "entering  marangoniFvPatchVectorField::snGrad()" << endl;
    vectorField nHat = this->patch().nf();
    vectorField pif = this->patchInternalField();
    vectorField result;
    if(!db().foundObject<vectorField>("gradT")) {
    Info << " marangoniFvPatchVectorField::snGrad(): object gradT not found!" << endl;
    Foam::error theError(" marangoniFvPatchVectorField::evaluate(): object gradT not found!");
    return transform(I - sqr(nHat),pif);
    else {
    fvPatchField<vector> gradT =this->patch().lookupPatchField<volVectorField, vector>("gradT");
    vectorField  gradT_internal = gradT.patchInternalField();
    vectorField gradTplane= transform(I - sqr(nHat),gradT_internal);
    vectorField pifplane= transform(I - sqr(nHat),pif);
    return (result-pif)*this->patch().deltaCoeffs();
    //Info << "leaving  marangoniFvPatchVectorField::snGrad()" << endl;   
    return result;

What does transform do? Does it help us in returning a gradient along the boundary?

Thanks in advance.


tehache June 14, 2013 06:40

Hi sherlock (and others),

As I am getting a lot of private messages regarding the Marangoni B.C.:
I posted this thing 4 years ago just as an example of how I tried to solve the problem, not as something I would consider a good programming example.
It worked for me, and some others, in OpenFoam 1.6, since then, I have not touched it, and actually dont really remember what I did and why.

Perhaps I should not have posted it.

As far as I remember, the transform you are asking for gives the projection of the patch internal vector field onto the patch plane, I think you can figure that out looking at the implementation of the base class, transformFvPatchVectorField.

God luck!

Sherlock_1812 June 15, 2013 00:37

Many thanks
Hi Thomas,

Thank you. I shall have a look at the base class to try and understand this better.

Sherlock_1812 August 30, 2013 07:04

Hello all,

I have a 2 questions.
Firstly, I have a doubt in the volVectorField definition of gradT. Why is it READ_IF_PRESENT? I'm not able to view the test case attached and so i'm not able to have a look into the 0/gradT file.

Second, if the internal and boundary fields are at constant temperature initially, won't gradT have the same value at all points?

Kindly excuse me if the questions are too naive. I have just started with OpenFOAM.

All times are GMT -4. The time now is 02:46.