implementBoundaryCondition
implementBoundaryCondition
• To add a new boundary condition, start by finding one that does almost what you want. Copy
that to your user directories under the same directory structure as the original installation.
• Modify the entry for the inlet boundary condition in 0/U to:
type parabolicVelocity;
n (1 0 0);
y (0 1 0);
maxValue 1;
value uniform (0 0 0); // Dummy for paraFoam
The contents of this entry must be in accordance with the constructor in the
parabolicVelocityFvPatchVectorField class. n is the direction of the flow, y is the
coordinate direction of the profile, and maxvalue is the centerline velocity.
i.e. the library must be added for each case that will use it, but no re-compilation is needed
for any solver. libmyFiniteVolume.so is found using the LD_LIBRARY_PATH environ-
ment variable, and if you followed the instructions on how to set up OpenFOAM and compile
the boundary condition this should work automatically.
• You can now run the case using the original simpleFoam solver. Note that we never re-
compiled the original simpleFoam solver, and if you do ldd `which simpleFoam` your
new library will NOT show up since it is linked at run-time (using dlopen).
• There are some public constructors and member functions that are defined in detail in the
.C-file.
• We used the third constructor when we tested the boundary condition, i.e. we read the
member data from a dictionary.
• The actual implementation of the boundary condition can be found in the updateCoeffs()
member function:
• Find out more about all the variables by including the following in the end of the updateCoeffs
member function:
Info <<
"c" << c << endl;
Info <<
"ctr" << ctr << endl;
Info <<
"y_" << y_ << endl;
Info <<
"bb.max()" << bb.max() << endl;
Info <<
"bb.min()" << bb.min() << endl;
Info <<
"(c - ctr)" << c - ctr << endl;
Info <<
"((c - ctr) & y_)" << ((c - ctr) & y_) << endl;
Info <<
"((bb.max() - bb.min()) & y_)" <<
((bb.max() - bb.min()) & y_) << endl;
Info << "coord" << coord << endl;