CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Specifying nonuniform boundary condition

Register Blogs Community New Posts Updated Threads Search

Like Tree40Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 5, 2011, 15:28
Default
  #41
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 16
bigbang is on a distinguished road
Hi. I don't know if it's because I'm using openFoam 2.0.0, but I get this error after trying to run the code

Code:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#0  Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam200/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::sigSegv::sigHandler(int) in "/opt/openfoam200/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2   in "/lib/libc.so.6"
#3  std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) in "/usr/lib/libstdc++.so.6"
#4  
 in "/home/alexander/OpenFOAM/alexander-2.0.0/platforms/linux64GccDPOpt/bin/inletBC"
#5  __libc_start_main in "/lib/libc.so.6"
#6  
 in "/home/alexander/OpenFOAM/alexander-2.0.0/platforms/linux64GccDPOpt/bin/inletBC"
Segmentation fault
Any ideas? Basically when I don't put a patch name, the program says I'm missing an argument. When I do put a patch name it returns the error quoted above. Help. Thanks.
bigbang is offline   Reply With Quote

Old   August 8, 2011, 06:32
Default
  #42
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by bigbang View Post
Hi. I don't know if it's because I'm using openFoam 2.0.0, but I get this error after trying to run the code

Code:
#2   in "/lib/libc.so.6"
#3  std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) in "/usr/lib/libstdc++.so.6"
Any ideas? Basically when I don't put a patch name, the program says I'm missing an argument. When I do put a patch name it returns the error quoted above. Help. Thanks.
Not 100% sure but usually if the code SegFaults at this basic_string the problem is that you're mixing binaries (library and exe) produced by two different g++-versions. But your milage may vary
gschaider is offline   Reply With Quote

Old   August 8, 2011, 08:33
Default
  #43
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 16
bigbang is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Not 100% sure but usually if the code SegFaults at this basic_string the problem is that you're mixing binaries (library and exe) produced by two different g++-versions. But your milage may vary
Thanks for the reply gschaider. I don't think I understand where to go from here. Can you take a look at my code and wmake output.

Code:

Code:
#include "fvCFD.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{

argList::validArgs.append("patchName");

#   include "setRootCase.H"

word patchName(args.args()[3]);

#   include "createTime.H"
#   include "createMesh.H"
#   include "createFields.H"
#   include "initContinuityErrs.H"

Info<< "This utility initializes gamma values for boundary patches based on" <<endl;
Info<< "a geometric limit. Default is set to: z>=0 ==>gamma=0, z<o ==>gamma=1." <<endl;
Info<< "These settings are presently only changeable by modifying the source code." <<endl;
Info<< "Source code to be found in: OF/user/applications." <<endl;
Info<< "Change code (.C file) according your needs and in that directory run wmake." <<endl;
Info<< "\nStarting time loop\n" << endl;

// Get index of patch 
label inletPatchID = mesh.boundaryMesh().findPatchID(patchName); 

// Get reference to boundary value 
const fvPatchVectorField& centre = mesh.C().boundaryField()[inletPatchID];

//Uncomment the line for your case: U for velocity cases, gamma for gamma cases
fvPatchVectorField& Inlet = U.boundaryField()[inletPatchID]; 
//fvPatchScalarField& targetPatch = gamma.boundaryField()[inletPatchID];

// loop over all hub faces 
forAll(Inlet, faceI) 
{ 
// get coordinate for face centre 
const vector& c = centre[faceI]; 

// c[0] is X coordinate, c[1] is Y coordinate, c[2] is Z coordinate
// Apply boundary condition based in one coordinate (X, Y, or Z). 

if (c[2] < 0.3)
//if true: below watersurface
{
//targetPatch[faceI] =  scalar (1);
Inlet[faceI] = vector (1, 0, 0); 
}
//if false: at or above watersurface
else
{
//targetPatch[faceI] = scalar (0);
Inlet[faceI] = vector (10 ,0 ,0);
}

}

// Force the write 
//gamma.write(); 
U.write();

Info<< "\n ExecutionTime = " 
<< runTime.elapsedCpuTime() 
<< " s\n" << endl; 

Info<< "End" << endl; 

return(0); 
}
wmake output:

Code:
Making dependency list for source file inletBC.C
SOURCE=inletBC.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam200/src/finiteVolume/lnInclude -I/opt/openfoam200/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam200/src/OpenFOAM/lnInclude -I/opt/openfoam200/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/inletBC.o
/opt/openfoam200/src/finiteVolume/lnInclude/initContinuityErrs.H: In function ‘int main(int, char**)’:
/opt/openfoam200/src/finiteVolume/lnInclude/initContinuityErrs.H:37: warning: unused variable ‘cumulativeContErr’
g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam200/src/finiteVolume/lnInclude -I/opt/openfoam200/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam200/src/OpenFOAM/lnInclude -I/opt/openfoam200/src/OSspecific/POSIX/lnInclude   -fPIC -Xlinker --add-needed Make/linux64GccDPOpt/inletBC.o -L/opt/openfoam200/platforms/linux64GccDPOpt/lib \
	     -lfiniteVolume -lmeshTools -lOpenFOAM -ldl   -lm -o /home/alexander/OpenFOAM/alexander-2.0.0/platforms/linux64GccDPOpt/bin/inletBC
bigbang is offline   Reply With Quote

Old   August 8, 2011, 10:44
Default
  #44
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by bigbang View Post
Thanks for the reply gschaider. I don't think I understand where to go from here. Can you take a look at my code and wmake output.
If my theory is correct then NO utilitiy you compiled yourself should work. The reason would be that the compiler that was used for compiling OF used another library for the strings (probably because it was another version of the compiler) than the compiler you're using now. Check this by compiling another 3rd party utility. Or by copying the sources of a utility that comes with OF, modifying the Make/files (so that you don't overwrite the original binary), compiling and runnig that.

If I'm wrong then I can't help you. If I'm right you'll either have to recompile OF or find out which compiler was actually used for your distro

Good luck
gschaider is offline   Reply With Quote

Old   August 8, 2011, 10:56
Default
  #45
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 16
bigbang is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Check this by compiling another 3rd party utility. Or by copying the sources of a utility that comes with OF, modifying the Make/files (so that you don't overwrite the original binary), compiling and runnig that.
I copied the icoFoam source and added a scalar transport model for Temperature following an online tutorial and it ran perfectly. I will pursue a new direction thanks.
bigbang is offline   Reply With Quote

Old   August 8, 2011, 11:39
Default
  #46
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by bigbang View Post
I copied the icoFoam source and added a scalar transport model for Temperature following an online tutorial and it ran perfectly. I will pursue a new direction thanks.
Aaaa. It was so obvious:

word patchName(args.args()[3]);

that is pre 1.5-convention. Use 0 instead of 3.
gschaider is offline   Reply With Quote

Old   August 8, 2011, 12:38
Default
  #47
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 16
bigbang is on a distinguished road
Ahh. Thank you. I fixed this since I am running OF 2.0.0. It worked, but then I get the same error further into the code...

Code:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading field U

This utility initializes gamma values for boundary patches based on
a geometric limit. Default is set to: z>=0 ==>gamma=0, z<o ==>gamma=1.
These settings are presently only changeable by modifying the source code.
Source code to be found in: OF/user/applications.
Change code (.C file) according your needs and in that directory run wmake.

Starting time loop

#0  Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam200/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::sigSegv::sigHandler(int) in "/opt/openfoam200/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2   in "/lib/libc.so.6"
#3  
 in "/home/alexander/OpenFOAM/alexander-2.0.0/platforms/linux64GccDPOpt/bin/inletBC"
#4  __libc_start_main in "/lib/libc.so.6"
#5  
 in "/home/alexander/OpenFOAM/alexander-2.0.0/platforms/linux64GccDPOpt/bin/inletBC"
Segmentation fault
alexander@alexander-G50VT:~/OpenFOAM/alexander-2.0.0/run/testCase$
Is there another convention in there that may not be up to standard for OF 2.0.0?
bigbang is offline   Reply With Quote

Old   August 8, 2011, 15:08
Default
  #48
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by bigbang View Post
Ahh. Thank you. I fixed this since I am running OF 2.0.0. It worked, but then I get the same error further into the code...

Code:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading field U

This utility initializes gamma values for boundary patches based on
a geometric limit. Default is set to: z>=0 ==>gamma=0, z<o ==>gamma=1.
These settings are presently only changeable by modifying the source code.
Source code to be found in: OF/user/applications.
Change code (.C file) according your needs and in that directory run wmake.

Starting time loop

#0  Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam200/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::sigSegv::sigHandler(int) in "/opt/openfoam200/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2   in "/lib/libc.so.6"
#3  
 in "/home/alexander/OpenFOAM/alexander-2.0.0/platforms/linux64GccDPOpt/bin/inletBC"
#4  __libc_start_main in "/lib/libc.so.6"
#5  
 in "/home/alexander/OpenFOAM/alexander-2.0.0/platforms/linux64GccDPOpt/bin/inletBC"
Segmentation fault
alexander@alexander-G50VT:~/OpenFOAM/alexander-2.0.0/run/testCase$
Is there another convention in there that may not be up to standard for OF 2.0.0?
No idea. SegFault is usually accessing an element that is not in a list. Do yourself a favour and compile yourself a Debug-version of OF if you want to go into developing. The Debug-version checks for such array out of bounds errors and aborts with meaningful error messages (but this comes at the expense of performance).

If that is too much action for you sprinkle the code with "Info << "-statements and see how far it gets (my personal guess is that you specified a nno-existing patch, because the code never checks whether the patch is really there)
gschaider is offline   Reply With Quote

Old   August 8, 2011, 15:26
Default
  #49
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 16
bigbang is on a distinguished road
Thank you for the Info<< sprinkler idea. I did it and realized that my loop wasn't accepting the parameters in forAll(). Looking further into the problem I noticed that the patchID was -1 for all patches meaning it wasn't retrieving the patch correctly. I just fed the program the value 4 for my inlet and it works fine now.

Thanks again!
bigbang is offline   Reply With Quote

Old   November 5, 2012, 06:56
Default
  #50
New Member
 
Qiong
Join Date: Oct 2012
Posts: 3
Rep Power: 14
Taylor is on a distinguished road
Quote:
Originally Posted by markc View Post
Lets try WITH attachment this time
setBoundarygamma.zip

hi Markc
I am a new hand in OpenFoam, in my case I want to set the blasius profile at inlet, but I have no ideal about these. I try to use your file in my case, but it doesnŽt work, because the youdidnŽt set the type name of the new boundary, if I use setboundarygamma in 0file, It couldnŽt be recognize.
please forgive me if my question is stupid.
Thanks in advance.


now I know it, thank you very much. I mix the solver and the new boundary condition. thank you very much.


Taylor

Last edited by Taylor; November 6, 2012 at 08:49.
Taylor is offline   Reply With Quote

Old   November 5, 2012, 07:01
Default
  #51
New Member
 
Qiong
Join Date: Oct 2012
Posts: 3
Rep Power: 14
Taylor is on a distinguished road
hi,

I am sorry if I disturb you. do you solve the blasuis boundary condition in OpenFoam?
now I am crazy for this problem.

Taylor

Quote:
Originally Posted by ami View Post
Hi Chen Jun

I am interested in considering nonuniform boundary conditions in my computations (e.g., a laminar Blasius boundary layer inflow condition along the free stream flow condition). Please can you specify the file name you described and how to use it?

thanks
Taylor is offline   Reply With Quote

Old   November 6, 2012, 08:47
Default
  #52
New Member
 
Qiong
Join Date: Oct 2012
Posts: 3
Rep Power: 14
Taylor is on a distinguished road
Quote:
Originally Posted by hani View Post
This thread actually belongs in preprocessing. Anyway, Chen actually describes the basics of how to set your boundary conditions. It is however a bit difficult to understand for a beginner. Let me, as a slightly more than beginner try to help you in a more detailed way (there might be other solutions also):

It is unlikely that there is such a boundary condition already implemented and distributed in OpenFoam. You will have to implement it yourself. This goes at least for less common bc's.

A suggestion on how to implement the steady bc (reads 0 and overwrites 0):

Step 1:
Copy the source directory of the particular solver that you want to use to your personal applications directory. For instance:
mkdir ~/OpenFOAM/hani-1.2/applications (if you don't have it)
cp -r OpenFOAM/OpenFOAM-1.2/applications/solvers/incompressible/simpleFoam ~/OpenFOAM/hani-1.2/applications/

Step 2:
Rename your copied directory to something that makes sence, for instance:
mv ~/OpenFOAM/hani-1.2/applications/simpleFoam ~/OpenFOAM/hani-1.2/applications/blasiusBC
Rename the .C-file in your blasiusBC directory to blasiusBC.C
Edit blasiusBC.C: Insert correct descriptions for Application and Description in the header of the file, for clarity. Remove everything in the main function except the include statements in the beginning. You may later on check which ones you actually need by commenting them and try to compile. The compiler error messages will guide you.

Step 3:
Implement your bc's using the directives that Chen gave you. This should be located after the include statements in the main function.
Write out the variables you have changed at the end of the main function:
// Force the write
U.write();
k.write();
epsilon.write();
phi.write();

Info<< "\n ExecutionTime = "
<< runTime.elapsedCpuTime()
<< " s\n" << endl;

Info<< "End" << endl;

return(0);

Step 4:
Edit blasiusBC/Make/files to make sure that the filenames blasiusBC is used instead of the name of the original application.

Step 5:
Compile.
Move to your blasiusBC directory and type
wmake

Step 6:
type:
rehash
to make the executable available.

Step 7:
Set your bc's by typing:
blasiusBC <root> <case>
which will change the files in your <root>/<case>/0 directory to include the bc's you defined in blasiusBC.

Step 8:
Run your case using the solver you need for the application. It will read the 0 directory and get the correct bc's.

Good luck!
Håkan.

thank you very much, I use it and works fine, really thank you
Taylor is offline   Reply With Quote

Old   September 13, 2013, 13:20
Default
  #53
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Dear everybody,

In this forum you explain how to implement a non-uniform value as boundary condition. For instance, U=whatever.
I need to implement a non uniform temperature gradient as boundary condition. How can I do it?

Regards
isabel is offline   Reply With Quote

Old   September 16, 2013, 16:20
Default
  #54
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by isabel View Post
Dear everybody,

In this forum you explain how to implement a non-uniform value as boundary condition. For instance, U=whatever.
I need to implement a non uniform temperature gradient as boundary condition. How can I do it?

Regards
From me you're going to hear "groovyBC". Others will tell you "coded". Second is with C++-programming, first without
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   September 19, 2013, 06:45
Default
  #55
Member
 
Zacarias Carral
Join Date: Sep 2012
Posts: 35
Rep Power: 14
zcarral is on a distinguished road
Dear Bernard,

I agree that "groovyBC" is an option but perhaps there is a way to program a non uniform temperature gradient. Does anybody know how to program it?
zcarral is offline   Reply With Quote

Old   February 12, 2014, 07:04
Default
  #56
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Dear everybody,

I am using groovyBC to set the boundary condition gradT=2*x
I have written this code:

top
{
type groovyBC;
gradientExpression "gradT";
fractionExpression "0";
variables "gradT=2*mesh.C().component(vector::X);";
timelines ( );
}


And I have the following error:

--> FOAM FATAL ERROR:
Parser Error at "1.3-6" :"field mesh not existing or of wrong type"
"2*mesh.C().component(vector::X)"
" ^^^^ "

From function parsingValue
in file lnInclude/CommonValueExpressionDriverI.H at line 802.

FOAM exiting

How can I call x coordinate using groovyBC?
isabel is offline   Reply With Quote

Old   February 13, 2014, 08:08
Default
  #57
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Problem solved. This is the correct code:

top
{
type groovyBC;
gradientExpression "gradT";
fractionExpression "0";
variables "gradT=2*pos().x;";
timelines ( );
}
isabel is offline   Reply With Quote

Old   October 21, 2014, 14:28
Default Boundary on the variable boundaryField
  #58
New Member
 
---
Join Date: Jan 2013
Posts: 17
Rep Power: 13
gironidegirona is on a distinguished road
Hi you all,

I think that your proposal solution for a variable boundary condition (I understand in time) is to modify the solver.

I would like to have a variable boundary condition depending on the position on the boundary itself. My approach is to modify the (for example) U values list and on the boundary set the value of each element on a list. The thing to know is if this is possible, and if it is how I do that? which is the element order?
example:

Inlet
{
list of values on each boundary element
}


Thanks in advance
gironidegirona is offline   Reply With Quote

Old   October 21, 2014, 15:37
Default
  #59
Senior Member
 
Yuehan
Join Date: Nov 2012
Posts: 142
Rep Power: 14
wc34071209 is on a distinguished road
i dont think doing this way is a wise idea, it is doable though.
wc34071209 is offline   Reply With Quote

Old   October 22, 2014, 15:52
Default
  #60
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by gironidegirona View Post
Hi you all,

I think that your proposal solution for a variable boundary condition (I understand in time) is to modify the solver.

I would like to have a variable boundary condition depending on the position on the boundary itself. My approach is to modify the (for example) U values list and on the boundary set the value of each element on a list. The thing to know is if this is possible, and if it is how I do that? which is the element order?
example:

Inlet
{
list of values on each boundary element
}


Thanks in advance
No. Boundary condition should never go into the solver. Only Fortran-Programmers do such a thing.

Possible solutions are the coded-BoundaryCondition that comes with OpenFOAM (there you've got to program in C++) or the groovyBC that comes with swak4Foam (a bit easier to use I like to think)
ngj likes this.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider 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
Specifying nonuniform initial condition msyaml OpenFOAM Running, Solving & CFD 65 April 25, 2016 05:23
Nonuniform initial condition using cellSetDict rinao OpenFOAM Running, Solving & CFD 6 January 9, 2013 01:42
Nonuniform boundary syntax juho OpenFOAM Running, Solving & CFD 1 December 11, 2008 17:13
Set nonuniform boundary values nikwin OpenFOAM Running, Solving & CFD 1 November 30, 2008 08:12
Nonuniform gradient boundary condition ankgupta8um OpenFOAM Running, Solving & CFD 1 March 14, 2006 02:34


All times are GMT -4. The time now is 18:15.