CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Help-How to reach the goal in my BC,what's the error? (https://www.cfd-online.com/Forums/openfoam-programming-development/69130-help-how-reach-goal-my-bc-whats-error.html)

zhajingjing October 13, 2009 02:15

Help-How to reach the goal in my BC,what's the error?
 
:confused:
I have to write a new boundary condition derived from the " mixed "type. The goal is to set the velocity at the boundary as follow:
  1. The horizontal velocity gets the value from a function of time or the coordinate XYZ .
  2. The vertical velocity must be made to equal to the value on the cells next to the boundary.How can I reach the goal correctly.
About the first goal:
The following sentences must have some error that I could not found out:

Code:

const labelList patchCells = this->patch().faceCells();
            scalar UMaker(0);
            UMaker=cos(omega_*db().time().value());
            forAll(patchCells,i)
            {
              this->refValue()[i]= vector(UMaker,0.0,0.0);
              this->refGrad()[i] = vector(0.0,0.0,0.0);
              this->valueFraction()[i] = 0.0;
            }

I just set the horizontal velocity to be UMaker, and set the vertical velocity to be zero.Even simple like this ,I still get the following message after "wmake libso" and running a wave tank case.

gradientInternalCoeffs cannot be called for a genericFvPatchField (actual type waveMakerVelocity)
on patch inlet of field U in file "/home/jingjing/OpenFOAM/jingjing-1.5/run/othercases/surfacewaveBC/waveBC2/linearWave/0/U"
You are probably trying to solve for a field with a generic boundary condition.

From function genericFvPatchField<Type>::gradientInternalCoeffs( ) const
in file fields/fvPatchFields/basic/generic/genericFvPatchField.C at line 692.

FOAM exiting

why???

about the second goal:
Can I fetch the vertical velocity on the cells next to the patch like this:

Code:

const tmp< Field<vector> >& refUy=this->patchInternalField();
forAll(patchCells,i)
{
      Uy=refUy()[patchCells[i]].y();
...

then I can change "this->refValue()[i]= vector(UMaker,0.0,0.0); " to "this->refValue()[i]= vector(UMaker,Uy,0.0); "?
If it's not correct.What's the correct expression for the second goal?

Any help will be appreciated!!!



gschaider October 13, 2009 07:01

Quote:

Originally Posted by zhajingjing (Post 232385)
:confused:

gradientInternalCoeffs cannot be called for a genericFvPatchField (actual type waveMakerVelocity)
on patch inlet of field U in file "/home/jingjing/OpenFOAM/jingjing-1.5/run/othercases/surfacewaveBC/waveBC2/linearWave/0/U"
You are probably trying to solve for a field with a generic boundary condition.

From function genericFvPatchField<Type>::gradientInternalCoeffs( ) const
in file fields/fvPatchFields/basic/generic/genericFvPatchField.C at line 692.

FOAM exiting

why???

This means that your solver doesn't know the boundary condition. Either you must link it to your solver or load the binary as a plugin (libs in controlDict). If you do that, check that the TypeName-macro is set to the name you're specify in the boundaryField

BTW: another possibility would be to prototype the boundary condition in groovyBC. internalField() would get you the internal values of a field

zhajingjing October 13, 2009 09:21

There may be other reasons
 
Hi gschaider,

I have examined it carefully.About the link problem: after " wmake libso" , my BC became a lib like any other standard BCs in FOAM. In this situation,if the BC has no error, it will be known by the solver. I have implemented other non-standard BC well in this way.So it may be not the link problem but the error from my BC code.
BWT, in my version (1.5), the method "load the binary as a plugin (libs in controlDict)" doesn't work .I don't know why
The typeName in the case file 0/U is as the same as that in my BC code.
So I still don't know why the solver cann't know my BC.-----where is the error in my BC?

maybe for the second goal ,I can use " Uy=internalField()[patchCells[i]].y(); "But that is not the key point.

Thanks for any help!

zhajingjing October 14, 2009 03:59

this is my BC code
 
2 Attachment(s)
Hello everyone,

the following is my BC and a waveTank case,if you are interested in my problem,you can have a look and try .Thank you

jingjing

zhajingjing October 14, 2009 14:31

a foolish mistake!
 
I'm so sorry that I make a foolish mistake-----I forgot to add the BC lib to the solver's makefile and recompile the solver. I used a non-standard BC successfully long time ago,so I forgot the correct way of linking a new BC to a solver.
I apologize for wasting your time.


All times are GMT -4. The time now is 00:07.