|
[Sponsors] |
January 25, 2023, 08:35 |
How to use inputValueMapper
|
#1 |
Senior Member
Join Date: Dec 2021
Posts: 209
Rep Power: 5 |
Hey everyone!
I am trying to set up a simulation with a cold wall and a hot wall in a square cavity. The hot wall temperature would be regulated by the cold wall temperature (where a negative flux is applied). For that, I saw that OpenFoam v2112 had inputValueMapper to create dependent boundary conditions : https://www.linkedin.com/pulse/new-f...bias-holzmann/ My hot wall boundary condition looks like this: Code:
hot_wall { type uniformFixedValue; value { type inputValueMapper; mode function; function { // Here we retrieve data from another FO (its the x-value) type functionObjectValue; // The name of the FO functionObject averageSurfaceTemperature; // The result used for x functionObjectResult average(cold_wall,T); defaultValue 200; }; value { type table; values ( (273.15 293.15) (283.15 283.15) ); }; } } But I get this error: Code:
--> FOAM FATAL IO ERROR: (openfoam-2112 patch=220610) Missing or invalid PatchFunction1 entry: uniformValue file: 0/T.boundaryField.hot_wall at line 50 to 80. From static Foam::autoPtr<Foam::PatchFunction1<Type> > Foam::PatchFunction1<Type>::New(const Foam::polyPatch&, const Foam::word&, const Foam::entry*, const Foam::dictionary&, bool, bool) [with Type = double] in file /builddir/build/BUILD/OpenFOAM-v2112/src/meshTools/lnInclude/PatchFunction1New.C at line 124. FOAM exiting I haven't found any resource about this inputValuemapper that looks quite powerful, other than the link I shared. Can anyone help me on this, or provide some information? Thanks for the help! Cheers |
|
January 25, 2023, 09:01 |
|
#2 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,085
Rep Power: 26 |
Hello,
I did not have the occasion to use inputValueMapper yet, but the error is related to the uniformFixedValue BC. Try this: Code:
hot_wall { type uniformFixedValue; uniformValue { type inputValueMapper; mode function; function { // Here we retrieve data from another FO (its the x-value) type functionObjectValue; // The name of the FO functionObject averageSurfaceTemperature; // The result used for x functionObjectResult average(cold_wall,T); defaultValue 200; }; value { type table; values ( (273.15 293.15) (283.15 283.15) ); }; } } |
|
January 25, 2023, 10:07 |
|
#3 | |
Senior Member
Join Date: Dec 2021
Posts: 209
Rep Power: 5 |
Quote:
Hey! Thanks for the help, I tried your modified version but it fails with the following error: Code:
--> FOAM FATAL IO ERROR: (openfoam-2206) Unknown PatchFunction1 type inputValueMapper for uniformValue Valid PatchFunction1 types : 18 ( coded constant cosine csvFile expression functionObjectValue mappedFile one polynomial sample sampled scale sine square table tableFile uniformValue zero ) file: 0/T.boundaryField.hot_wall at line 31 to 60. From static Foam::autoPtr<Foam::PatchFunction1<Type> > Foam::PatchFunction1<Type>::New(const Foam::polyPatch&, const Foam::word&, const Foam::entry*, const Foam::dictionary&, bool, bool) [with Type = double] in file /home/mol/openfoam/OpenFOAM-com/src/meshTools/lnInclude/PatchFunction1New.C at line 152. FOAM exiting Here it is with the modification suggested by Yann: Code:
boundaryField { adiabatic { type zeroGradient; } hot_wall { type uniformFixedValue; uniformValue { type inputValueMapper; mode function; function { // Here we retrieve data from another FO (its the x-value) type functionObjectValue; // The name of the FO functionObject averageSurfaceTemperature; // The result used for x functionObjectResult average(cold_wall,T); defaultValue 200; }; value { type table; values ( (273.15 293.15) (283.15 283.15) ); }; } } cold_wall { type externalWallHeatFluxTemperature; mode power; Q -0.5; //qr qr; //qrRelaxation 0.1; //relaxation 0.1; //emissivity 0.88; kappaMethod fluidThermo; value $internalField; } "(.*front|.*back)" { type empty; } } EDIT: Woops, missed the end bracket... |
||
February 16, 2023, 11:18 |
perhaps you should modify some openfoam src files and recompile
|
#4 |
New Member
Laurence Wallian
Join Date: Mar 2009
Posts: 19
Rep Power: 17 |
hello,
I've tried this operation : add the following lines in /usr/local/OpenFOAM-v2212/src/meshTools/PatchFunction1/makePatchFunction1s.C addUniformValueFieldFunction1s(inputValueMapper, scalar); addUniformValueFieldFunction1s(inputValueMapper, vector); addUniformValueFieldFunction1s(inputValueMapper, sphericalTensor); addUniformValueFieldFunction1s(inputValueMapper, symmTensor); addUniformValueFieldFunction1s(inputValueMapper, tensor); and then ./Allwmake -s -l it seems to work. I hope it will help you best regards |
|
February 20, 2023, 03:25 |
|
#5 |
Senior Member
Join Date: Dec 2021
Posts: 209
Rep Power: 5 |
Hey!
Thanks for the help, I will give it a go as soon as I have some time and report back |
|
February 21, 2023, 03:34 |
|
#6 |
New Member
Laurence Wallian
Join Date: Mar 2009
Posts: 19
Rep Power: 17 |
hello,
I've tried a similar case, but in fact, it doesn't work : the value taken into account for T_hot only depends of default value, not of average(cold_wall,T)... and when I comment the line "default value 200;", I have the following bug : Function object averageSurfaceTemperature results not found. Valid objects with results include: 0() sorry ! I haven't found any solution yet ! |
|
April 19, 2023, 03:40 |
|
#7 | |
Senior Member
Join Date: Dec 2021
Posts: 209
Rep Power: 5 |
Quote:
Hey again Laurence, It has been a while but I finally had some time to test things out these past few days. Your solution indeed works! I think you were missing the function in your controlDict. The functionObject entry looks for a similarly named function in the controlDict. So I assume that's probably why you could not make it work. So to sum up:
Many thanks Laurence! I definitely think this is one of the most versatile features of OpenFOAM for preprocessing, can't wait to play with it do you think the modifications you made to the source file should be reported to the development team? I feel like this change should be included in the default installation (so that it could be used with the precompiled windows version for instance). Cheers! EDIT: I quickly tested other boundary conditions such as externalWallHeatFluxTemperature in power mode. It worked even with the standard OpenFoam version so the issue lies only with the uniformFixedValue condition. My apologies, I was not really exhaustive during my tests. The externalWallHeatFluxTemperature example: Code:
hot_wall { type externalWallHeatFluxTemperature; mode power; Q { type inputValueMapper; mode function; function { // Here we retrieve data from another FO (its the x-value) type functionObjectValue; // The name of the FO functionObject avg_temp_cold; // The result used for x functionObjectResult average(cold_wall,T); defaultValue 300.15; } value { type table; values ( (297.15 10) (298.15 0) ); }; } kappaMethod fluidThermo; value $internalField; } |
||
April 19, 2023, 05:31 |
|
#8 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,694
Rep Power: 40 |
Quote:
This is an interesting point. Probably worth raising an issue. However, I think that it might need a PatchFunction1 version of the inputValueMapper. The input value mapper itself is not spatially distributed (hence a uniform value), but since it acts as to remap values it should probably be redirecting the input function values which could be non-uniform. |
||
April 19, 2023, 07:46 |
|
#9 | |
Senior Member
Join Date: Dec 2021
Posts: 209
Rep Power: 5 |
Quote:
My actual understanding of the programming logic of OpenFOAM is way too limited to have a relevant opinion on this sadly I will gladly take your word for it though! |
||
April 20, 2023, 03:58 |
|
#10 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,694
Rep Power: 40 |
I also thought you might be able to use an expression PatchFunction1 here as well. In the meantime the expressions also provide a hook to define and use scalar/vector functions. You could have the lookup of the functionObject as one function, the table remapping as a second function and connect them together with an expression.
There are unfortunately not that many meaningful examples of the syntax (perhaps you could donate one to the tutorial suite?), but take a look at the following locations:
|
|
Thread Tools | Search this Thread |
Display Modes | |
|
|