|
[Sponsors] |
February 17, 2009, 14:03 |
Hello forum:
I'm working wi
|
#1 |
New Member
Alex Schenkman
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17 |
Hello forum:
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 But receiving? 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, Thanks in advance for any hint! |
|
February 18, 2009, 13:50 |
Hi Alex!
Just an idea: for
|
#2 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Hi Alex!
Just an idea: for "pulling" another solution I'd write a boundary-condition (timeVaryingMappedFixedValueFvPatchField might be similar to what you're trying to achieve) OR 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) Bernhard
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
|
February 18, 2009, 15:22 |
Thanks for you answer, Bernhar
|
#3 |
New Member
Alex Schenkman
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17 |
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? Thanks again! PS: I find it very hard to navigate through ALL these C++ code. |
|
February 19, 2009, 08:11 |
Hi Alex!
timeVaryingMappedF
|
#4 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Hi Alex!
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
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
|
February 19, 2009, 18:09 |
Bernhard:
Without your help
|
#5 |
New Member
Alex Schenkman
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17 |
Bernhard:
Without your help I wouldn't get anywhere, 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. Any clues? |
|
March 3, 2009, 11:46 |
Bernhard:
In a previous pos
|
#6 | |
New Member
Alex Schenkman
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17 |
Bernhard:
In a previous post you suggest the following: Quote:
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! |
||
March 3, 2009, 14:03 |
Hi Alex!
@2: Don't tell any
|
#7 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Hi Alex!
@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) Bernhard
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
|
March 27, 2009, 17:30 |
[Solved]
|
#8 |
New Member
Alex Schenkman
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17 |
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. Code:
fvPatchField<T> *aField = const_cast<fvPatchField<T>*>(&fld.boundaryField()[index]); forAll(*aField, valueIndex) { assignFieldValue( (*aField)[valueIndex], aDouble ); } Thanks for your help, and I hope this helps someone else. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Modify the htc using UDF on NT | frederic | FLUENT | 1 | February 24, 2020 00:26 |
HELP NEEDED HOW TO MAP VALUES FROM PATCH OF ONE MESH TO PATCH OF ANOTHER MESH | mkraposhin | OpenFOAM Running, Solving & CFD | 3 | September 4, 2011 10:42 |
Patch names amp forces functionObject | david | OpenFOAM Bugs | 3 | April 26, 2011 22:59 |
How To Modify the eqution | yinyajun436 | OpenFOAM Running, Solving & CFD | 1 | March 31, 2008 18:01 |
How to modify a value by a UDF? | jwt | FLUENT | 3 | May 23, 2003 13:01 |