CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

How to implement a alphaContactAngle boundary condition

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 2, 2018, 02:11
Default How to implement a alphaContactAngle boundary condition
  #1
KTG
Senior Member
 
Abe
Join Date: May 2016
Posts: 119
Rep Power: 9
KTG is on a distinguished road
Hi all,

I am trying to implement a dynamic contact angle boundary condition that is a little more complex than the dynamicAlphaContactAngle condition that ships with openfoam. I would like to use a code stream or coded fixed value, but am not sure how to return the value of theta. I am working off Joel Guerrero's tutorial and the dynamicAlphaContactAngle source code, but am pretty lost. If I could get it working for just theta = tanh(uwall), I could figure out the rest. Below is my best attempt, which does not work. If anyone can set me down the right path with this, please let me know (maybe I should be using codedFixedValue?).

Thanks

Code:
    leftWall
{
    type            alphaContactAngle;
    value           #codeStream;
        {
            codeInclude
            #{
                #include "fvCFD.H"
            #};

            codeOptions
            #{
                -I$(LIB_SRC)/finiteVolume/lnInclude \
                -I$(LIB_SRC)/meshTools/lnInclude
            #};

            //libs needed to visualize BC in paraview
            codeLibs
            #{
            -lmeshTools \
            -lfiniteVolume
            #};

            code
            #{
                const IOdictionary& d = static_cast<const IOdictionary&>
        (
                    dict.parent().parent()
                );
                const fvMesh& mesh = refCast<const fvMesh>(d.db());
                const label id = mesh.boundary().findPatchID("leftWall");
                const fvPatch& patch = mesh.boundary()[id];

     const vectorField nf(patch().nf());
 
     // Calculated the component of the velocity parallel to the wall
     vectorField Uwall(Up.patchInternalField() - Up);
     Uwall -= (nf & Uwall)*nf;
 
     // Find the direction of the interface parallel to the wall
     vectorField nWall(nHat - (nf & nHat)*nf);
 
     // Normalise nWall
     nWall /= (mag(nWall) + SMALL);
 
     // Calculate Uwall resolved normal to the interface parallel to
     // the interface
     scalarField uwall(nWall & Uwall);
 
  return 2 + tanh(uwall);


            #};
        };

}
KTG is offline   Reply With Quote

Old   February 6, 2018, 20:43
Default
  #2
KTG
Senior Member
 
Abe
Join Date: May 2016
Posts: 119
Rep Power: 9
KTG is on a distinguished road
Maybe someone can help with this much less ambitious code. All I am trying to do here is assign a constant angle of 90, just to see if I can get #codestream to work at all:

Code:
    leftWall
{
    type            constantAlphaContactAngle;
    theta0           #codeStream
        {
            codeInclude
            #{
                #include "fvCFD.H"
            #};

            codeOptions
            #{
                -I$(LIB_SRC)/finiteVolume/lnInclude \
                -I$(LIB_SRC)/meshTools/lnInclude
            #};

            //libs needed to visualize BC in paraview
            codeLibs
            #{
            -lmeshTools \
            -lfiniteVolume
            #};

            code
            #{
                const IOdictionary& d = static_cast<const IOdictionary&>
        (
                    dict.parent().parent()
                );
                const fvMesh& mesh = refCast<const fvMesh>(d.db());
                const label id = mesh.boundary().findPatchID("leftWall");
                const fvPatch& patch = mesh.boundary()[id];

                
                scalarField theta0(patch.size(), scalar(0) );

                forAll(theta0, i)
                    {
                    const scalar y = patch.Cf()[i][1];
                    theta0[i] = scalar( 90.0 );
                    }
                    
                theta0.writeEntry("", os);



            #};
        };
        limit          gradient;
        value          uniform 0;

}

but I still get the error:
Code:
--> FOAM FATAL IO ERROR: 
wrong token type - expected Scalar, found on line 0 the word 'uniform'

file: /home/abe/Desktop/damBreak/damBreak/0/alpha.water.boundaryField.leftWall.theta0 at line 0.

    From function Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::doubleScalar&)
    in file lnInclude/Scalar.C at line 107.

FOAM exiting
If anyone has any ideas, please put me out of my misery.

thanks
KTG is offline   Reply With Quote

Old   February 20, 2018, 16:44
Default what libs are needed for constantAlphaContactAngle?
  #3
KTG
Senior Member
 
Abe
Join Date: May 2016
Posts: 119
Rep Power: 9
KTG is on a distinguished road
This is so frustrating, because it should be really simple. The only reason I can come up with for why it is not working is that I am not including the right codeInclude, codeOptions, or codeLibs? I am just trying to get the simplest thing to work using codestream, in this case just setting the contact angle to 20.



Code:
    lowerWall
    {
        type           constantAlphaContactAngle;
        theta0         #codeStream
        {
            codeInclude
            #{
                #include "fvCFD.H"
            #};

            codeOptions
            #{
                -I$(LIB_SRC)/finiteVolume/lnInclude \
                -I$(LIB_SRC)/meshTools/lnInclude
            #};

            //libs needed to visualize BC in paraview
            codeLibs
            #{
            -lmeshTools \
            -lfiniteVolume
            #};

            code
            #{
                const IOdictionary& d = static_cast<const IOdictionary&>
        (
                    dict.parent().parent()
                );
                const fvMesh& mesh = refCast<const fvMesh>(d.db());
                const label id = mesh.boundary().findPatchID("velocity-inlet-5");
                const fvPatch& patch = mesh.boundary()[id];

                scalarField theta0(patch.size(), scalar(0) );


                forAll(theta0, i)
                {
theta0[i] = 20;
                }

                theta0.writeEntry("", os);
            #};
        };
        limit          gradient;
        value          uniform 0;
    }

The error code:

Code:
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigSegv::sigHandler(int) at ??:?
#2  ? in "/lib64/libc.so.6"
#3  codeStream_f156995d3e4bf224419ce97808a42d8596a1ef93 at 0/alpha.water.boundaryField.lowerWall.#codeStream:73
#4  Foam::functionEntries::codeStream::execute(Foam::dictionary const&, Foam::primitiveEntry&, Foam::Istream&) at ??:?
#5  Foam::functionEntry::execute(Foam::word const&, Foam::dictionary const&, Foam::primitiveEntry&, Foam::Istream&) at ??:?
#6  Foam::primitiveEntry::expandFunction(Foam::word const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#7  Foam::primitiveEntry::append(Foam::token const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#8  Foam::primitiveEntry::read(Foam::dictionary const&, Foam::Istream&) at ??:?
#9  Foam::primitiveEntry::readEntry(Foam::dictionary const&, Foam::Istream&) at ??:?
#10  Foam::primitiveEntry::primitiveEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#11  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#12  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#13  Foam::dictionary::dictionary(Foam::fileName const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#14  Foam::dictionaryEntry::dictionaryEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#15  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#16  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#17  Foam::dictionary::dictionary(Foam::fileName const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#18  Foam::dictionaryEntry::dictionaryEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#19  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#20  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#21  Foam::operator>>(Foam::Istream&, Foam::dictionary&) at ??:?
#22  Foam::localIOdictionary::localIOdictionary(Foam::IOobject const&, Foam::Istream&) at ??:?
#23  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::readFields() at ??:?
#24  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&, bool) at ??:?
#25  ? at ??:?
#26  ? at ??:?
#27  ? at ??:?
#28  __libc_start_main in "/lib64/libc.so.6"
#29  ? at ??:?
Segmentation fault (core dumped)
Help...
KTG is offline   Reply With Quote

Old   July 3, 2018, 05:32
Default
  #4
Member
 
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9
rarnaunot is on a distinguished road
Hi!

I'm also a Junior in codeStream code but I have also started with the same example as you did. This example worked for me but I had to copy and paste the code litterally without any change!

The error here it is in const label id = mesh.boundary().findPatchID("velocity-inlet-5");

It should point to the same path used before, in your case "loweWall":

Code:
mesh.boundary().findPatchID("lowerWall");
Hope it works

Quote:
Originally Posted by KTG View Post
This is so frustrating, because it should be really simple. The only reason I can come up with for why it is not working is that I am not including the right codeInclude, codeOptions, or codeLibs? I am just trying to get the simplest thing to work using codestream, in this case just setting the contact angle to 20.



Code:
    lowerWall
    {
        type           constantAlphaContactAngle;
        theta0         #codeStream
        {
            codeInclude
            #{
                #include "fvCFD.H"
            #};

            codeOptions
            #{
                -I$(LIB_SRC)/finiteVolume/lnInclude \
                -I$(LIB_SRC)/meshTools/lnInclude
            #};

            //libs needed to visualize BC in paraview
            codeLibs
            #{
            -lmeshTools \
            -lfiniteVolume
            #};

            code
            #{
                const IOdictionary& d = static_cast<const IOdictionary&>
        (
                    dict.parent().parent()
                );
                const fvMesh& mesh = refCast<const fvMesh>(d.db());
                const label id = mesh.boundary().findPatchID("velocity-inlet-5");
                const fvPatch& patch = mesh.boundary()[id];

                scalarField theta0(patch.size(), scalar(0) );


                forAll(theta0, i)
                {
theta0[i] = 20;
                }

                theta0.writeEntry("", os);
            #};
        };
        limit          gradient;
        value          uniform 0;
    }

The error code:

Code:
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigSegv::sigHandler(int) at ??:?
#2  ? in "/lib64/libc.so.6"
#3  codeStream_f156995d3e4bf224419ce97808a42d8596a1ef93 at 0/alpha.water.boundaryField.lowerWall.#codeStream:73
#4  Foam::functionEntries::codeStream::execute(Foam::dictionary const&, Foam::primitiveEntry&, Foam::Istream&) at ??:?
#5  Foam::functionEntry::execute(Foam::word const&, Foam::dictionary const&, Foam::primitiveEntry&, Foam::Istream&) at ??:?
#6  Foam::primitiveEntry::expandFunction(Foam::word const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#7  Foam::primitiveEntry::append(Foam::token const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#8  Foam::primitiveEntry::read(Foam::dictionary const&, Foam::Istream&) at ??:?
#9  Foam::primitiveEntry::readEntry(Foam::dictionary const&, Foam::Istream&) at ??:?
#10  Foam::primitiveEntry::primitiveEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#11  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#12  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#13  Foam::dictionary::dictionary(Foam::fileName const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#14  Foam::dictionaryEntry::dictionaryEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#15  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#16  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#17  Foam::dictionary::dictionary(Foam::fileName const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#18  Foam::dictionaryEntry::dictionaryEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#19  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#20  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#21  Foam::operator>>(Foam::Istream&, Foam::dictionary&) at ??:?
#22  Foam::localIOdictionary::localIOdictionary(Foam::IOobject const&, Foam::Istream&) at ??:?
#23  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::readFields() at ??:?
#24  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&, bool) at ??:?
#25  ? at ??:?
#26  ? at ??:?
#27  ? at ??:?
#28  __libc_start_main in "/lib64/libc.so.6"
#29  ? at ??:?
Segmentation fault (core dumped)
Help...
rarnaunot is offline   Reply With Quote

Old   July 3, 2018, 06:04
Default
  #5
KTG
Senior Member
 
Abe
Join Date: May 2016
Posts: 119
Rep Power: 9
KTG is on a distinguished road
Haha, thanks- that was a pretty stupid mistake...
KTG is offline   Reply With Quote

Old   July 3, 2018, 06:48
Default
  #6
Member
 
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9
rarnaunot is on a distinguished road
In this post How to create the internalField with #codeStream they use a different way to define the new scalar internal Field. They define the Field as:
scalarField newField(mesh.nCells(), 0);

and you as:
scalarField theta0(patch.size(), scalar(0) );

I don't know if this could be also an error or they are the same function.....

Bye
rarnaunot is offline   Reply With Quote

Old   December 2, 2019, 06:00
Default
  #7
New Member
 
Arman N
Join Date: Mar 2019
Posts: 13
Rep Power: 7
Arman_N is on a distinguished road
Quote:
Originally Posted by KTG View Post
Maybe someone can help with this much less ambitious code. All I am trying to do here is assign a constant angle of 90, just to see if I can get #codestream to work at all:

Code:
    leftWall
{
    type            constantAlphaContactAngle;
    theta0           #codeStream
        {
            codeInclude
            #{
                #include "fvCFD.H"
            #};

            codeOptions
            #{
                -I$(LIB_SRC)/finiteVolume/lnInclude \
                -I$(LIB_SRC)/meshTools/lnInclude
            #};

            //libs needed to visualize BC in paraview
            codeLibs
            #{
            -lmeshTools \
            -lfiniteVolume
            #};

            code
            #{
                const IOdictionary& d = static_cast<const IOdictionary&>
        (
                    dict.parent().parent()
                );
                const fvMesh& mesh = refCast<const fvMesh>(d.db());
                const label id = mesh.boundary().findPatchID("leftWall");
                const fvPatch& patch = mesh.boundary()[id];

                
                scalarField theta0(patch.size(), scalar(0) );

                forAll(theta0, i)
                    {
                    const scalar y = patch.Cf()[i][1];
                    theta0[i] = scalar( 90.0 );
                    }
                    
                theta0.writeEntry("", os);



            #};
        };
        limit          gradient;
        value          uniform 0;

}

but I still get the error:
Code:
--> FOAM FATAL IO ERROR: 
wrong token type - expected Scalar, found on line 0 the word 'uniform'

file: /home/abe/Desktop/damBreak/damBreak/0/alpha.water.boundaryField.leftWall.theta0 at line 0.

    From function Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::doubleScalar&)
    in file lnInclude/Scalar.C at line 107.

FOAM exiting
If anyone has any ideas, please put me out of my misery.

thanks


Hi,

I have faced the very same problem with #codestream. I was wondering if you were able to overcome it. My code is as follows (it is almost exactly the same as yours):

Code:
    lowerWall
    {
        type		constantAlphaContactAngle;
        theta0		#codeStream
	{
		codeInclude
		#{
			#include "fvCFD.H"
		#};

		codeOptions
		#{
			-I$(LIB_SRC)/finiteVolume/lnInclude \
			-I$(LIB_SRC)/meshTools/lnInclude
		#};

		// libs needed to visualize BC in paraview
		codeLibs
		#{
			-lmeshTools \
			-lfiniteVolume
		#};

		code
		#{
			const IOdictionary& d = static_cast<const IOdictionary&>
			(
				dict.parent().parent()
			);

			const fvMesh& mesh = refCast<const fvMesh>(d.db());

			const label id = mesh.boundary().findPatchID("lowerWall");

			const fvPatch& patch = mesh.boundary()[id];
			
			scalarField theta0(patch.size(), scalar(0));

			forAll(theta0, i)
			{
				theta0[i] = scalar(20);
			}

			theta0.writeEntry("", os);
		#};
	};
	limit		gradient;
	value		uniform 0;
    }
but I get this error:
Code:
--> FOAM FATAL IO ERROR: 
wrong token type - expected Scalar, found on line 0: word 'uniform'

file: /home/arman/OpenFOAM/run/dynamicAlpha/0/alpha.water.boundaryField.lowerWall.theta0 at line 0.

    From function Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::doubleScalar&)
    in file lnInclude/Scalar.C at line 147.

FOAM exiting
I don't get it. It seems that it might have a problem with the line:
Code:
value		uniform 0;
but that's just OpenFOAM default format.

Please help me if you have any idea where I am mistaken and how to deal with this.

Thanks,
Arman
Arman_N is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Out File does not show Imbalance in % Mmaragann CFX 5 January 20, 2017 10:20
Wrong flow in ratating domain problem Sanyo CFX 17 August 15, 2015 06:20
Divergence after implement nonreflecting boundary condition fireflies Main CFD Forum 0 October 23, 2014 10:16
How to implement heat flux boundary condition as function of time baran_foam OpenFOAM Running, Solving & CFD 3 September 15, 2014 00:28
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 17:44


All times are GMT -4. The time now is 22:39.