New BoundaryCondition: how to modify a single component of a field?
hello,
I need to make for a simulation a new type of boundary condition. This is my first attempt of programming with openFoam and I'm able to realize a time varying boundary condition starting from oscillatingFixedValueFvPatchField file. As in oscillatingBC the field varies with time and it is great for a single component field, such as the pressure p. But if I want to vary only a single component of a velocity field for example, I didn't understand how I can do that. I Understood that the field class belongs from List class, and so I tried with a for cycle and edit one by one all the elements of the list (field), but if I try to reach the x() y() or z() method of the single element I get an error because only the vector class have these method.. so how I can reach this method and vary single component of element of the field list? best regards and sorry for my bad english Lucio |
Hi Lucio
All BCs in OF are templated, which means they work for scalars, vectors and tensors in the same fashion. If you elaborate more on your problem, maybe you'll receive better answers! The cyclic BC will apply the same calculation to all elements of your variable (e.g. a Vector). If you need to make a BC that works only for one component of a vector, you may consider using codedFixedValue, groovyBC or change the patch from inside the solver. Regards, Hisham |
thank you very much for the reply! However I reach up a solution with this function in my new BC timeVaryingVelocityComponent :)
Code:
template<class Type> In this code I modified only the single component (indicated by the int value component_) and I leave untouched the other.. and finally the function searchMax that give the index of the field that points to biggest value between the single component field: Code:
critiques & suggestions are always welcome :) Best regards, Lucio |
Hello!
I don't know why, but for parallel application this construct works fine: Code:
but this other gives me always Fatal error from first iteration! Code:
can anybody give me some explanation? Regard, Lucio |
Standard C++ notes:
1- Make sure that the "currentScale(...)" you invoke returns a scalar 2- Try the parallelized "forAll(...,...)" instead of the classic "for(i=0;...;i++)" |
All times are GMT -4. The time now is 17:30. |