Hello forum: I'm working wi
I'm working with functionObejcts to interface OpenFOAM with another application.
Each time step, I need to send and receive information from the other app.
Sending is solved by extending PatchAverageFunctionObject, found here: simpleFunctionObjects
For example, for icoFoam, how could I modify the pressure or the velocity field, for a given patch, between time steps?
I have debugged icoFoam but I get lost in the code, http://www.cfd-online.com/OpenFOAM_D...lipart/sad.gif
Thanks in advance for any hint!
Hi Alex! Just an idea: for
Just an idea: for "pulling" another solution I'd write a boundary-condition (timeVaryingMappedFixedValueFvPatchField might be similar to what you're trying to achieve)
the functionObject directly writes the values to the patch (I assume that after sending the external program calculates and then can send back a solution)
Thanks for you answer, Bernhar
Thanks for you answer, Bernhard!
Do you have any links to any code using timeVaryingMappedFixedValueFvPatchField?
So I can try to understand what it is, and how it is used?
From the name I can see that it is some kind of mapping between a patch, that varies in time...
From my functionObject, how can I modify a patch? Or where can I find some code to look at that does it?
PS: I find it very hard to navigate through ALL these C++ code.
Hi Alex! timeVaryingMappedF
timeVaryingMappedFixedValueFvPatchField is found in $FOAM_SRC/finiteVolue/fields/fvPatchFields/derived (quoting from memory). Or you can look it up in the Doxygen.
A quick and dirty-approach to writing the patch field in the function-object would be the reverse of what you're already doing: just put the "fld.boundaryField()[index]" (that is an example from the simpleFunctionObjects onto the left side of an = and voila you're writting to the patch.
Bernhard: Without your help
Without your help I wouldn't get anywhere, http://www.cfd-online.com/OpenFOAM_D...part/happy.gif
I think that the following line, placed after the average is calculated in the for-loop, within patchAverageFunctionObject::average(), will achieve what I want:
fld.boundaryField()[index] *= anExternalScalar / vals[patchI].component(0);
where vals[patchI].component(0) should give me the x-component of the newly computed average.
But it doesn't work !?!
The compiler complains when [T = double], as patchAverageFunctionObject::average() is a templated function.
I don't get why, becasue even scalarField defines the component() method.
Bernhard: In a previous pos
In a previous post you suggest the following:
If I don't missunderstand it, fld is constant and thus cannot be modified.
1) Is it possible to write to fld anyway?
2) Or, how could I get a writtable reference to U?
All examples I've found on the forum modify U and p from within the solver (the main function), and we are trying to avoid modifying the solvers.
Thanks in advance!
Hi Alex! @2: Don't tell any
@2: Don't tell anyone, that I said this: google for const_cast. But beware: this operator allows you to violate the encapsulation mechanisms and therefor using it is similar to running with an open knife
@1: what I would suggest is writing a boundary-condition and provide it with an interface to change the boundary values. In the functionObject dynamicCast the general patch field to that type (maybe use a isA to guard that cast) to your type and use your methods to set the value (Look thorough the doxygen for isA and dynamicCast and grep the sources for example usages)
I just wanted to post the solution to my question.
I extended pathAverageFunctionObject, and reused much of the code in the average() method.
Here follows the code I added within average() to write on the boundary defined in the controlDict.
Thanks for your help, and I hope this helps someone else.
|All times are GMT -4. The time now is 11:09.|