|
[Sponsors] |
How to implement a alphaContactAngle boundary condition |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 2, 2018, 02:11 |
How to implement a alphaContactAngle boundary condition
|
#1 |
Senior Member
Abe
Join Date: May 2016
Posts: 119
Rep Power: 9 |
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); #}; }; } |
|
February 6, 2018, 20:43 |
|
#2 |
Senior Member
Abe
Join Date: May 2016
Posts: 119
Rep Power: 9 |
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 thanks |
|
February 20, 2018, 16:44 |
what libs are needed for constantAlphaContactAngle?
|
#3 |
Senior Member
Abe
Join Date: May 2016
Posts: 119
Rep Power: 9 |
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) |
|
July 3, 2018, 05:32 |
|
#4 | |
Member
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9 |
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"); Quote:
|
||
July 3, 2018, 06:04 |
|
#5 |
Senior Member
Abe
Join Date: May 2016
Posts: 119
Rep Power: 9 |
Haha, thanks- that was a pretty stupid mistake...
|
|
July 3, 2018, 06:48 |
|
#6 |
Member
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9 |
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 |
|
December 2, 2019, 06:00 |
|
#7 | |
New Member
Arman N
Join Date: Mar 2019
Posts: 13
Rep Power: 7 |
Quote:
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; } 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 Code:
value uniform 0; Please help me if you have any idea where I am mistaken and how to deal with this. Thanks, Arman |
||
|
|
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 |