In this blog, quick reference notes about OpenFOAM are posted in a form of a summary to address a specific topic per post.
codedFixedValue Boundary Condition
Posted April 11, 2012 at 17:57 by Hisham
Tags boundary, codedfixedvalue, openfoam
This is an example of using codedFixedValue boundary condition to input expressions that are time and position dependent.
Code:
PatchName { type codedFixedValue; value uniform (0 0 0); //$internalField; redirectType BC_Given_Name; code #{ fixedValueFvPatchVectorField myPatch (*this); forAll(myPatch, celli) { myPatch[celli] = (this->db().time().value()/*TIME*/ * this->patch().Cf()[celli]/*centers of patch faces (for x-value use this->patch().Cf()[celli][0])*/ ); } operator==(myPatch); #}; }
Total Comments 1
Comments
-
Dear Hisham,
thank you for your little template. I would ask you something. If I need to use inside the code block a constant from a file how can I proceed? I tried different ways, but any of these have had good results.
Do you have any idea to perform this?
Thank you in advance,
Vincenzo
PS:
Here an example:
#include "<fileIncludingVariables>"
boundaryField
{
PatchName
{
type codedFixedValue;
value uniform (0 0 0); //$internalField;
redirectType BC_Given_Name;
code
#{
fixedValueFvPatchVectorField myPatch (*this);
forAll(myPatch, celli)
{
myPatch[celli] = $amplitude*(this->db().time().value()/*TIME*/ * this->patch().Cf()[celli]/*centers of patch faces (for x-value use this->patch().Cf()[celli][0])*/ );
}
operator==(myPatch);
#};
}
.
.
.
.
.
}Posted July 5, 2017 at 08:11 by vsammartano