Difference between revisions of "HowTo Adding a new boundary condition"

From OpenFOAMWiki
(Initial document layout)
 
m
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
== A simple example: parabolic velocity inlet ==
+
First look at [[contrib_groovyBC|groovyBC]].  If this isn't suitable, follow these steps below.
Stuff to add here
+
  
== Compiling the source code==
+
# Choose a boundary condition that is close to the one you want - we'll call it <tt>originalFvPatchField</tt>.
Stuff to add here
+
# Copy the directory contents to anywhere (say <tt>run/myCode</tt>).
 +
# Rename all the copied files to a new name (say <tt>customFvPatchField</tt>). <bash>for i in `ls`; do mv $i `echo $i|sed s/originalFvPatchField/customFvPatchField/g`;done</bash>
 +
# Search & replace all text in all the new files old name for new name (<tt>originalFvPatchField</tt> replaced with <tt>customFvPatchField</tt>) <bash> for i in `ls`; do sed -i s/originalFvPatchField/customFvPatchField/g $i;done</bash>
 +
# Modify the code to suit your needs.
 +
# Create the directory structure: <tt>myCode/Make</tt>, and create <tt>files</tt> and <tt>options</tt> in it.
 +
# Put the relevant info into <tt>files</tt>:
 +
## Search for <tt>originalFvPatchField</tt> in <tt>finiteVolume/Make/files</tt>.
 +
## Copy the relevant entry (entries) into your <tt>myCode/Make/files</tt>
 +
## Rename the entries as necessary - rename it with your <tt>customFvPatchField</tt> naming (if there's an <tt>s</tt> on the end, keep it there).
 +
## Tell it what the new library name will be.  Use $(FOAM_USER_LIBBIN) instead of $(FOAM_LIBBIN), and add <tt>lib</tt> to the front of the new name.  It should look something like: <tt>LIB = $(FOAM_USER_LIBBIN)/libcustomPatchField</tt>
 +
# The <tt>options</tt> file should have <tt>EXE_INC</tt> (for any includes such as <tt>-I$(LIB_SRC)/finiteVolume/lnInclude</tt> for finiteVolume) and <tt>LIB_LIBS</tt> (for included libraries, such as <tt>-lfiniteVolume</tt> for finiteVolume). Look at other <tt>LIB_LIBS</tt> for examples.
 +
# <tt>$wmake libso</tt>
 +
# Add whatever new dictionary entries are needed to your initial conditions files, such as <tt>0/U</tt> and <tt>0/P</tt> files.
 +
# Add <tt>libs ( "libcustomFvPatchField.so" "libOpenFOAM.so" )</tt> to <tt>controlDict</tt>
 +
# It should run now.
  
== Adding the new BC to libfoamUser ==
+
With reference to [http://www.cfd-online.com/Forums/openfoam/72434-custom-boundary-condition-openfoam.html].
Stuff to add here
+
See also [http://www.tfd.chalmers.se/~hani/kurser/OS_CFD/implementBoundaryCondition.pdf].
 +
[[User:Marupio|Marupio]] 17:00, 26 February 2010 (UTC)
  
== Adding the new BC to FoamX ==
+
[[Category:Tutorials]]
Stuff to add here
+
 
+
== Testing with a simple case ==
+
Stuff to add here
+
 
+
== Gotchas and solutions ==
+
Stuff to add here
+

Latest revision as of 16:54, 16 January 2014

First look at groovyBC. If this isn't suitable, follow these steps below.

  1. Choose a boundary condition that is close to the one you want - we'll call it originalFvPatchField.
  2. Copy the directory contents to anywhere (say run/myCode).
  3. Rename all the copied files to a new name (say customFvPatchField).
    for i in `ls`; do mv $i `echo $i|sed s/originalFvPatchField/customFvPatchField/g`;done
  4. Search & replace all text in all the new files old name for new name (originalFvPatchField replaced with customFvPatchField)
     for i in `ls`; do sed -i s/originalFvPatchField/customFvPatchField/g $i;done
  5. Modify the code to suit your needs.
  6. Create the directory structure: myCode/Make, and create files and options in it.
  7. Put the relevant info into files:
    1. Search for originalFvPatchField in finiteVolume/Make/files.
    2. Copy the relevant entry (entries) into your myCode/Make/files
    3. Rename the entries as necessary - rename it with your customFvPatchField naming (if there's an s on the end, keep it there).
    4. Tell it what the new library name will be. Use $(FOAM_USER_LIBBIN) instead of $(FOAM_LIBBIN), and add lib to the front of the new name. It should look something like: LIB = $(FOAM_USER_LIBBIN)/libcustomPatchField
  8. The options file should have EXE_INC (for any includes such as -I$(LIB_SRC)/finiteVolume/lnInclude for finiteVolume) and LIB_LIBS (for included libraries, such as -lfiniteVolume for finiteVolume). Look at other LIB_LIBS for examples.
  9. $wmake libso
  10. Add whatever new dictionary entries are needed to your initial conditions files, such as 0/U and 0/P files.
  11. Add libs ( "libcustomFvPatchField.so" "libOpenFOAM.so" ) to controlDict
  12. It should run now.

With reference to [1]. See also [2]. Marupio 17:00, 26 February 2010 (UTC)