CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to use genericFvPatchField (https://www.cfd-online.com/Forums/openfoam-solving/58638-how-use-genericfvpatchfield.html)

maddhi August 17, 2008 10:59

Hello again! My next questi
 
Hello again!

My next question while learning about BC implementation...:

It seems that the genericFvPatchField (derived from calculatedFvPatchField) somehow interprets it's arguments into field names. Does this mean that for example in the dictionary file I could have a patch like follows?

boundaryField{
//...
mypatch{
type generic;
value "p-rho*sqr(U)/2";
}...

Probably I'm getting this completely wrong, so can I find any explanations in existing documentation how the genericFvPatchField or calculatedFvPatchField are supposed to be used?

Thanks
Maddhi

eugene August 18, 2008 05:55

Seems to me that generic is ju
 
Seems to me that generic is just a renaming of the old default boundary type. In which case, you cant really use it for anything.

maddhi August 18, 2008 07:23

Hello Eugene! You are right
 
Hello Eugene!

You are right, comparing the directories under finiteVolume/fields/fvPatchFields/basic/ shows that apparently "default" has been "replaced" by generic.

I want to implement a class that performs calculations on the dependent variables and applies the result as boundary condition on certain patches.

To give an example, I calculate the flux F_A=sum(c*<u,n>) of a concentration c across patch A, and on patch B the boundary condition should be c=k*F_A for some constant k.

This is just an example, the actual BCs are more involved, but if you could give some hints how to achieve the example above, I will probably know how to continue.

a) Which base class is best used to implement a BC like c=k*F_A where F_A depends on U and c?
b) How would I get access to the fields U and c in my implementation? Does the fvPatchField have a reference to a registry where I can find the required fields?
c) What steps are required to make my new fvPatchField available for use like

patch B{
type myNewBC;
constant_k 3.14;
}

more specifically how does OpenFOAM know for example that a fixedValueFvPatchField is requested if "type fixedValue" is given in the dictionary?

Thanks
Maddhi

eugene August 18, 2008 10:01

a) Probably something like sur
 
a) Probably something like surfaceNormalFixedValue

b) Yes, you do a database lookup: mesh().lookupObject<volvectorfield>("U") for instance. (the mesh has access to the database)

c) Depends on where you compiled it, but you can generally add the new library containing the BC using the "libs" keyword in the controlDict. Check documentation for details.

d) The class declaration has a macro called TypeName that adds the specified name to a run time type information table.

Your best bet to learn more about this stuff is to learn to read the code. There are examples of everything you need here: src/finiteVolume/fvPatchFields/


All times are GMT -4. The time now is 11:13.