User-coded BC for uniformFixedValue
uniformFixedValue
allows options such as table
, tableFile
, csvFile
or polynomial
. Is there any supported way for accessing and manipulating these values from a user-coded BC like codedFixedValue
?
Thank you.
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Link issues together to show that they're related. Learn more.
Activity
- Mark OLESEN assigned to @mark
assigned to @mark
- Maintainer
Hi @carpemonf,
This sounds familiar - not sure if you or someone else ask this on cfd-online, or if there was an answer.
Are you trying to inherit a uniformFixedValue with your codedFixedValue? Or trying to access/manipulate the entries from a different boundary condition entirely?
You should note is that the name "uniformFixedValue" is misleading in the meantime. The values described can be non-uniform, time-varying. Also they use a PatchFunction1, which means they can also include coordinate transformations or separate scaling for each direction. If we want to get a single value, we will need an additional method name.
- Author
Thanks @mark. Sorry, if there was a similar question on cfd-online I missed it.
I actually want to define a BC as a Function1 of time and update the values from the code entry in
codedFixedValue
. All for the same patch and field. Is this possible without creating a new BC? - Maintainer
Sounds like you want to use a CodedFunction1 for the entry?
- Author
I think that the problem when using CodedFunction1 for the entry is that then I can't set-up time-dependent values from a table and use them in the code.
I'm adding below an example of the BC that if supported would do what I'm looking for:
test { name test0; type codedFixedValue; + refValue tableFile; + refValueCoeffs + { + file "$FOAM_CASE/file"; + } codeInclude #{ // includes #}; code #{ vectorField& v = *this + // do stuff for updating v using time-dependent refValue `this->refValue()` operator==(v); #}; value $internalField; }
Thanks again.
- Maintainer
@carpemonf - Ok I follow what you are trying. Will try something on develop. Are you using 1912 or later?
- Author
That's great, @mark. Thanks. I'm using v2006.
Edited by Carlos Peña-Monferrer - Maintainer
Hi @carpemonf - have a basic concept (mostly working), but won't get finished tonight. It would be helpful if you had a small tutorial type of use case that I could add into the tutorials and for testing.
Thanks!
- Author
Sure. I can prepare an extension of an existing tutorial with similar features for testing.
- Please register or sign in to reply
- Maintainer
Currently looks like this:
inlet { name swirl; type codedFixedValue; refValue sine; refValueCoeffs { amplitude 1.0; frequency 1.0; scale 2.0; level 2.0; } codeInclude #{ #include "Function1.H" #}; code #{ static autoPtr<Function1<scalar>> generator; const dictionary& dict = this->dictionaryContent::dict(); if (!generator) { // Info<< "Construct from dictionary" << nl; generator = Function1<scalar>::New("refValue", dict); } // Info<< "value: " << generator->value(100) << nl; const vector axis(1, 0, 0); vectorField v(2.0*this->patch().Cf() ^ axis); v.replace(vector::X, 1.0); operator==(v); #}; value $internalField; }
Using a method-local static seems to be the best way to create and maintain the Function1 since we can't have a data member declaration mechanism (no templated means of defining the types and the copy constructors etc).
- Author
Awesome @mark.
I have created a
pipeCyclicSinParabolic
frompipeCyclic
where including your code the inlet would be something like the following.PD: I have fixed the value for
pipeRadius
as I'm not sure that$pipeRadius
would work here. Please correct me if I'm wrong or if there's any other way to pass that variable.inlet { name sinParabolic; type codedFixedValue; refValue sine; refValueCoeffs { amplitude 1.0; frequency 1.0; scale 2.0; level 2.0; } codeInclude #{ #include "Function1.H" #}; code #{ // Uncomment for testing on non-windows systems [fragile] // IOobject::scopeSeparator = '_'; scalar pipeRadius = 0.5; vectorField& v = *this; static autoPtr<Function1<scalar>> generator; const dictionary& dict = this->dictionaryContent::dict(); if (!generator) { // Info<< "Construct from dictionary" << nl; generator = Function1<scalar>::New("refValue", dict); } const scalar t = this->db().time().value(); // scalar Ux = 1.0; scalar Ux = generator->value(t); forAll(v, faceI) { scalar r = mag(this->patch().Cf()[faceI]); v[faceI] = vector(2*Ux*(1 - sqr(r)/sqr(pipeRadius)), 0.0, 0.0); } operator==(v); #}; value $internalField; }
- Maintainer
Hi @carpemonf - this is probably still a bit too fragile (with the hard-coded radius) and anyone not involved in this current discussion would think "what is the point?".
I think we need something closer to your original problem - providing various bits of external data via tables etc, but using a modified version of them in the coded bit. Otherwise we would probably just use a coded PatchFunction1 or an expression PatchFunction1 for the whole thing.
- Author
Hi @mark,
I wanted to be practical there for testing. While I totally agree with you, because of confidentiality I would need to think of a different case than the one I'm dealing with, and that still shows the need or benefit of this approach. I can give it a try using some open-source dataset.
Best.
- Author
@mark What about adding some random noise taking the time-dependent velocity reference from a table? I think this is not currently possible without creating a new BC or wrapper. For instance, something like
turbulentInlet
but usingx_ref
from the table.x_p = (1 - \alpha) x_p^{n - 1} + \alpha (x_{ref} + c s R |x_{ref}|)
- Maintainer
Hi @carpemonf
I had most of the code done and I thought I could squeeze this in for the release, but hit a few regressions with it, which makes me too concerned to put it in just yet (and still manage my stress levels). I hope you understand.
BTW: for a contrived example, I put together a coded PatchFunction1 that recombined two other Function1s, which are both defined within the dictionary scope.
- Author
@mark I totally understand. Many thanks for the update, much appreciated.
- Mark OLESEN mentioned in issue #2107 (closed)
mentioned in issue #2107 (closed)
- Mark OLESEN mentioned in commit b59ae32d
mentioned in commit b59ae32d
- Maintainer
Closing out - should be working with the changes that went into 2106.
- Mark OLESEN closed
closed