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

Compile boundary condition as a new dynamic library

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 23, 2010, 14:06
Default Compile boundary condition as a new dynamic library
  #1
New Member
 
Mohan
Join Date: Jan 2010
Posts: 4
Rep Power: 16
mohanphy is on a distinguished road
Dear All,

I am trying to Compile boundary condition as a new dynamic library. I following this tutorials: http://openfoamwiki.net/index.php/Tu....28OF-1.4.1.29

I have done the following steps :

openfoam@Mohan:~/OpenFOAM/openfoam-1.6/src/finiteVolume/fields/fvPatchFields/derived$ svn checkout http://openfoam-extend.svn.sourcefor...bolicVelocity/
A parabolicVelocity/parabolicVelocityFvPatchVectorField.C
A parabolicVelocity/parabolicVelocityFvPatchVectorField.H
U parabolicVelocity
Checked out revision 1738.

I have downloaded it :

openfoam@Mohan:~/OpenFOAM/openfoam-1.6/src/finiteVolume/fields/fvPatchFields/derived$ cd parabolicVelocity/


openfoam@Mohan:~/OpenFOAM/openfoam-1.6/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity$ ls
parabolicVelocityFvPatchVectorField.C parabolicVelocityFvPatchVectorField.H

openfoam@Mohan:~/OpenFOAM/openfoam-1.6/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity$ mkdir Make

openfoam@Mohan:~/OpenFOAM/openfoam-1.6/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity$ ls
Make parabolicVelocityFvPatchVectorField.H
parabolicVelocityFvPatchVectorField.C

openfoam@Mohan:~/OpenFOAM/openfoam-1.6/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity$ cd Make/

openfoam@Mohan:~/OpenFOAM/openfoam-1.6/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity/Make$ vim files

openfoam@Mohan:~/OpenFOAM/openfoam-1.6/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity/Make$ vim options

wmake will show the following message :

openfoam@Mohan:~/OpenFOAM/openfoam-1.6/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity/Make$ wmake libso

wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file parabolicVelocityFvPatchVectorField.C
SOURCE=parabolicVelocityFvPatchVectorField.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/openfoam/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/openfoam/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude -I/home/openfoam/OpenFOAM/OpenFOAM-1.6/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/parabolicVelocityFvPatchVectorField.o
'/home/openfoam/OpenFOAM/openfoam-1.6/lib/linuxGccDPOpt/libmyBCs.so' is up to date.
openfoam@Mohan:~/OpenFOAM/openfoam-1.6/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity$ ls
lnInclude parabolicVelocityFvPatchVectorField.C parabolicVelocityFvPatchVectorField.H
Make parabolicVelocityFvPatchVectorField.dep

It has successfully creates "libmyBCs.so" in /home/openfoam/OpenFOAM/openfoam-1.6/lib/linuxGccDPOpt/libmyBCs.so

The tutorials saying that I need to add the following line in system/controlDict file: libs ("libmyBCs.so");

The problem is I don't know where is the system/controlDict file (absolute path). some one please explain me to find system/controlDict file.

Thanks & Rg
Mohan L
mohanphy is offline   Reply With Quote

Old   March 22, 2013, 10:42
Default
  #2
Senior Member
 
starter
Join Date: Sep 2012
Posts: 125
Rep Power: 16
sihaqqi is on a distinguished road
Mohan

I am after this parabolic velocity patch .C and .H. I use openFoam 2.1. the link you have given does not have these files. Can you please post these. The need is very urgent because first I have to understand them as a beginner in OpenFoam and then I shall have to convert in 1/7th power law.

I shall be grateful

regards
sihaqqi is offline   Reply With Quote

Old   March 24, 2013, 15:01
Default
  #3
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings sihaqqi,

They are available here: https://github.com/ogoe/OpenFOAM-1.6...bolicVelocity/

Direct links:
Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   March 24, 2013, 19:26
Default
  #4
Senior Member
 
starter
Join Date: Sep 2012
Posts: 125
Rep Power: 16
sihaqqi is on a distinguished road
Dear Bruno

Many thanks for this.
Thanks & Regards

Sihaqqi
sihaqqi is offline   Reply With Quote

Old   March 25, 2013, 03:26
Default
  #5
Senior Member
 
starter
Join Date: Sep 2012
Posts: 125
Rep Power: 16
sihaqqi is on a distinguished road
Bruno

Can you please advise where I can get Make files and options from for this thing

Regards
sihaqqi is offline   Reply With Quote

Old   March 25, 2013, 16:57
Default
  #6
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by sihaqqi View Post
Can you please advise where I can get Make files and options from for this thing
It's explained in the first link on this thread: http://openfoamwiki.net/index.php/Tu....28OF-1.4.1.29
__________________
wyldckat is offline   Reply With Quote

Old   July 25, 2013, 07:22
Default
  #7
Member
 
nadine moussa
Join Date: Mar 2012
Posts: 30
Rep Power: 14
nadine is on a distinguished road
Hello,

I don't know if I am really unlucky, but none of the links refering to parapolicVelocity are working!!!

Can someone help me and post a valid link so I can add this condition and compile it?

Thanks a lot,
Nadine
nadine is offline   Reply With Quote

Old   July 25, 2013, 10:48
Default
  #8
Member
 
nadine moussa
Join Date: Mar 2012
Posts: 30
Rep Power: 14
nadine is on a distinguished road
Re-Hello,

Finally i found source files using this link:

https://github.com/Unofficial-Extend...eld.H.svn-base

I saved both the .C and .H in a file outside openfoam and followed the instructions givin in wiki to add my library and linked it dynamically by adding libs ("libmyBCs.so"); in my controlDict.

Than I ran the simulation but I got an error message, indicating that there is no such a boundary condition and giving me choices between the classical boundaries found in openfoam!!!

what did I do wrong and how can I fix it!
Help!

Waiting for your answers, even if it s summer time

Nadine,
nadine is offline   Reply With Quote

Old   July 25, 2013, 12:17
Default
  #9
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Quote:
Originally Posted by nadine View Post
Re-Hello,

Finally i found source files using this link:

https://github.com/Unofficial-Extend...eld.H.svn-base

I saved both the .C and .H in a file outside openfoam and followed the instructions givin in wiki to add my library and linked it dynamically by adding libs ("libmyBCs.so"); in my controlDict.

Than I ran the simulation but I got an error message, indicating that there is no such a boundary condition and giving me choices between the classical boundaries found in openfoam!!!

what did I do wrong and how can I fix it!
Help!

Waiting for your answers, even if it s summer time

Nadine,
Can you, please, post your case files?
alexeym is offline   Reply With Quote

Old   August 18, 2013, 13:21
Default
  #10
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

@Nadine: I don't know if you've fixed the problem you reported about, but here is summary and updated building instructions, based on 1.6-ext and http://openfoamwiki.net/index.php/Tu....28OF-1.4.1.29 - edit: and yes it should work for almost any version of OpenFOAM!

Run these commands:
Code:
mkdir -p $FOAM_RUN
cd $FOAM_RUN/..
mkdir parabolicVelocity
cd parabolicVelocity

wget "http://sourceforge.net/p/openfoam-extend/OpenFOAM-1.6-ext/ci/master/tree/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity/parabolicVelocityFvPatchVectorField.C?format=raw" -O parabolicVelocityFvPatchVectorField.C
wget "http://sourceforge.net/p/openfoam-extend/OpenFOAM-1.6-ext/ci/master/tree/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity/parabolicVelocityFvPatchVectorField.H?format=raw" -O parabolicVelocityFvPatchVectorField.H

mkdir Make
echo 'parabolicVelocityFvPatchVectorField.C'  > Make/files
echo 'LIB = $(FOAM_USER_LIBBIN)/libmyBCs'  >> Make/files

echo 'EXE_INC =  -I$(LIB_SRC)/finiteVolume/lnInclude'  > Make/options
echo 'EXE_LIBS = '  >> Make/options

wmake libso
The I used the tutorial "incompressible/simpleFoam/pitzDaily" as basis and edited the files:
  • "system/controlDict" - Added the line:
    Code:
    libs ("libmyBCs.so");
  • "0/U" - changed the BC "inlet" to this:
    Code:
        inlet
        {
            type            parabolicVelocity;
            n               (1 0 0);
            y               (0 1 0);
            maxValue        1;
            value           (0 0 0); // Dummy for paraFoam, which will NOT show a correct profile at time 0.
        }
Then to run the case, I simply run:
Code:
blockMesh
simpleFoam
Best regards,
Bruno
mgg, hiuluom, k.farnagh and 1 others like this.
__________________

Last edited by wyldckat; January 2, 2014 at 19:18. Reason: see
wyldckat is offline   Reply With Quote

Old   January 2, 2014, 11:29
Default
  #11
Member
 
Tony
Join Date: Nov 2013
Posts: 35
Rep Power: 13
wzx1989221 is on a distinguished road
Dear Bruno,

I find your post very useful. Just want to know if it is possible to do the parabolic inlet in that way using OF 2.1? Or is it only applicable in OF 1.6-ext version?

Looking forward to your reply. Thank you very much.

Best regards,
Tony
wzx1989221 is offline   Reply With Quote

Old   January 2, 2014, 19:22
Default
  #12
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings Tony,

Quote:
Originally Posted by wzx1989221 View Post
I find your post very useful. Just want to know if it is possible to do the parabolic inlet in that way using OF 2.1? Or is it only applicable in OF 1.6-ext version?
Good question! I've updated post #10 to add a note about that.

I forgot to mention back then, but it's sort-of implied that these instructions are for any OpenFOAM version, but rely on the source code of OpenFOAM-1.6-ext. Actually, now it's foam-extend 3.0, but this boundary condition is pretty much the same .

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   January 2, 2014, 20:02
Default
  #13
Member
 
Tony
Join Date: Nov 2013
Posts: 35
Rep Power: 13
wzx1989221 is on a distinguished road
Dear Bruno,

Thank you very much for the reply. Actually I have checked out that it works well with OF 2.1.

One thing is that I tried to use it for 3D pipe flow, but the profile turned out to be varying in only one direction like in channel. Any suggestions on making it work for pipe?

Best regards,
Tony
wzx1989221 is offline   Reply With Quote

Old   January 2, 2014, 20:40
Default
  #14
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Tony,

Mmm... what you are looking for is a paraboloid: http://en.wikipedia.org/wiki/Paraboloid
But this boundary condition from 1.6-ext is only "parabolic"

The idea is that you need to modify the source code of the method "updateCoeffs()". Essentially, you need to modify these two lines of code:
Code:
 // Calculate local 1-D coordinate for the parabolic profile
scalarField coord = 2*((c - ctr) & y_)/((bb.max() - bb.min()) & y_);

vectorField::operator=(n_*maxValue_*(1.0 - sqr(coord)));
Right now I don't have much time to look into this. But let me know if you don't manage to solve this by yourself. And if you are able to, do share the solution!

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   January 3, 2014, 09:34
Default
  #15
Member
 
Tony
Join Date: Nov 2013
Posts: 35
Rep Power: 13
wzx1989221 is on a distinguished road
Hi Bruno,

Many thanks for the tips. I will look into that to see if I can resolve it. I will share the solution if I make it.

Regards,
Tony
vipin1431 likes this.
wzx1989221 is offline   Reply With Quote

Old   August 6, 2015, 07:20
Default
  #16
New Member
 
vipin
Join Date: Jun 2015
Posts: 14
Rep Power: 11
vipin1431 is on a distinguished road
Quote:
Originally Posted by wzx1989221 View Post
Hi Bruno,

Many thanks for the tips. I will look into that to see if I can resolve it. I will share the solution if I make it.

Regards,
Tony
hi tony,
I followed the above instruction to get parabolic inlet velocity and also i got same profile like i.e. variation along one direction only did you get it corrected....if yes, please help me to correct it.


regard
vipin
vipin1431 is offline   Reply With Quote

Old   August 23, 2016, 09:46
Default
  #17
Member
 
Rudolf Hellmuth
Join Date: Sep 2012
Location: Dundee, Scotland
Posts: 40
Rep Power: 14
rudolf.hellmuth is on a distinguished road
Paraboloid velocity profile on a circular patch:

Code:
    inlet
    {
        type            codedFixedValue;
        value           uniform (0 0 0);
        redirectType    Poiseuille;   
        code
        #{
            const fvPatch& boundaryPatch = patch(); 
            const vectorField& Cf = boundaryPatch.Cf(); 
            vectorField& U = *this;
        
            //gfunc calculates the function on decomposed patches for parallel runs.
            scalar patchArea = gSum(boundaryPatch.magSf());
            //Info << "Patch area: " << patchArea << endl;
            
            vector ctr = gSum(boundaryPatch.magSf()*Cf)/patchArea;
            //Info << "Patch center: " << ctr << endl;
            
            scalar R = sqrt(patchArea/constant::mathematical::pi);
            //Info << "Patch radius: " << R << endl;
            
            vector n = gSum(boundaryPatch.magSf()*boundaryPatch.nf())/patchArea;
            //Info << "Patch mean normal: " << normal << endl;
            
            scalar Umean = 1.0;
            
            forAll(Cf, i)
            {
                U[i] = -n*2.0*Umean*(1.0 - sqr(mag(Cf[i] - ctr)/R));
            }
            // operator==(vector(1.0, 0.0, 0.0));
        #};
    }
This codedFixedValue BC is working for me. You can use this code to compile a PoiseuilleBC.so if you want.

I hope it can help you,
Rudolf
rudolf.hellmuth is offline   Reply With Quote

Old   November 18, 2016, 08:40
Default Paraboloid velocity profile on a square channel ?
  #18
Senior Member
 
vidyadhar
Join Date: Jul 2016
Posts: 138
Rep Power: 10
vidyadhar is on a distinguished road
Quote:
Originally Posted by rudolf.hellmuth View Post
Paraboloid velocity profile on a circular patch:

Code:
    inlet
    {
        type            codedFixedValue;
        value           uniform (0 0 0);
        redirectType    Poiseuille;   
        code
        #{
            const fvPatch& boundaryPatch = patch(); 
            const vectorField& Cf = boundaryPatch.Cf(); 
            vectorField& U = *this;
        
            //gfunc calculates the function on decomposed patches for parallel runs.
            scalar patchArea = gSum(boundaryPatch.magSf());
            //Info << "Patch area: " << patchArea << endl;
            
            vector ctr = gSum(boundaryPatch.magSf()*Cf)/patchArea;
            //Info << "Patch center: " << ctr << endl;
            
            scalar R = sqrt(patchArea/constant::mathematical::pi);
            //Info << "Patch radius: " << R << endl;
            
            vector n = gSum(boundaryPatch.magSf()*boundaryPatch.nf())/patchArea;
            //Info << "Patch mean normal: " << normal << endl;
            
            scalar Umean = 1.0;
            
            forAll(Cf, i)
            {
                U[i] = -n*2.0*Umean*(1.0 - sqr(mag(Cf[i] - ctr)/R));
            }
            // operator==(vector(1.0, 0.0, 0.0));
        #};
    }
This codedFixedValue BC is working for me. You can use this code to compile a PoiseuilleBC.so if you want.

I hope it can help you,
Rudolf

Hello Rudolf,

I have seen your post on paraboloid profile for a circular patch.

I would like to implement paraboloid profile for a square patch, since, in my case, I have to give fully developed profile at the inlet to a square channel.

Can you help me in implementing the same.

Thanks & Regards,
vidyadhar
vidyadhar is offline   Reply With Quote

Old   November 18, 2016, 09:51
Default
  #19
Member
 
Rudolf Hellmuth
Join Date: Sep 2012
Location: Dundee, Scotland
Posts: 40
Rep Power: 14
rudolf.hellmuth is on a distinguished road
Quote:
Originally Posted by vidyadhar View Post
Hello Rudolf,
I would like to implement paraboloid profile for a square patch, since, in my case, I have to give fully developed profile at the inlet to a square channel.
I can easily help you to make this "paraboloid" if your rectangular patch is on a plane orthogonal to the Cartesian coordinates. If it is diagonal to the Cartesian coordinates, then you'd have to either give the patch orientation as input, or you'd have to figure out a way of obtaining the patch orientation with the patch data.

Try this:
Code:
// patch area
    scalar A = gSum(patch().magSf());
    
    // patch normal vector is the weighted mean of patch face normal
    // vectors
    vector np = gSum(patch().magSf()*patch().nf())/A;
    
    // patch centre is the weighted mean of patch face centres
    vector O = gSum(patch().magSf()*patch().Cf())/A;
   
    // local position of cell centres (referenced on the patch centre)
    scalarField pos = mag(patch().Cf() - O);
    
    // patch lengths on x and y directions
    scalar X = 1.0;
    scalar Y = 1.4;
        
    fixedValueFvPatchVectorField::operator==
    (
      -np*vmean*2.0 *(1.0 - sqr(pos.x()/X))*(1.0 - sqr(pos.y()/Y))
    );
I haven't tested that, it's just an idea. There are two parabolas, one on the x direction and the other on the y direction. I hope this code can help you.

Good luck!
Rudolf
rudolf.hellmuth is offline   Reply With Quote

Old   November 18, 2016, 10:07
Default
  #20
Senior Member
 
vidyadhar
Join Date: Jul 2016
Posts: 138
Rep Power: 10
vidyadhar is on a distinguished road
Hello Rudolf,

Thank you for the immediate help.

I will test the code and get back to you with the outcomes.

Thanks & Regards,
vidyadhar
vidyadhar 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
compile errors of boundary condition "expDirectionMixed" liying02ts OpenFOAM Bugs 2 February 1, 2010 21:11
how to set up a wall boundary condition according to calculated wall shear stress? gameoverli OpenFOAM Pre-Processing 1 May 21, 2009 09:28
How to define a dynamic Boundary Condition? abrahamgx CFX 2 March 10, 2009 00:03
How to define a dynamic Boundary Condition? (New) abrahamgx CFX 2 March 9, 2009 08:43
Dynamic Temperature Boundary Condition Kshitij FLUENT 0 October 12, 2005 14:40


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