CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

How to use inputValueMapper

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Laurence Wallian

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 25, 2023, 08:35
Default How to use inputValueMapper
  #1
Senior Member
 
Join Date: Dec 2021
Posts: 209
Rep Power: 5
Alczem is on a distinguished road
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)
                );
            };                                                                   
        }
    }
So my hope was that the hot wall would be between 283.15 and 293.15 Kelvins depending on how cold the other wall gets.


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
Alczem is offline   Reply With Quote

Old   January 25, 2023, 09:01
Default
  #2
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,076
Rep Power: 26
Yann will become famous soon enough
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)
                );
            };                                                                   
        }
    }
Yann
Yann is offline   Reply With Quote

Old   January 25, 2023, 10:07
Default
  #3
Senior Member
 
Join Date: Dec 2021
Posts: 209
Rep Power: 5
Alczem is on a distinguished road
Quote:
Originally Posted by Yann View Post
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)
                );
            };                                                                   
        }
    }
Yann



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;
    }
    
}
Can anyone point me in the right direction? Thanks


EDIT: Woops, missed the end bracket...
Alczem is offline   Reply With Quote

Old   February 16, 2023, 11:18
Default perhaps you should modify some openfoam src files and recompile
  #4
New Member
 
Laurence Wallian
Join Date: Mar 2009
Posts: 19
Rep Power: 17
Laurence Wallian is on a distinguished road
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
Laurence Wallian is offline   Reply With Quote

Old   February 20, 2023, 03:25
Default
  #5
Senior Member
 
Join Date: Dec 2021
Posts: 209
Rep Power: 5
Alczem is on a distinguished road
Hey!


Thanks for the help, I will give it a go as soon as I have some time and report back
Alczem is offline   Reply With Quote

Old   February 21, 2023, 03:34
Default
  #6
New Member
 
Laurence Wallian
Join Date: Mar 2009
Posts: 19
Rep Power: 17
Laurence Wallian is on a distinguished road
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 !
Alczem likes this.
Laurence Wallian is offline   Reply With Quote

Old   April 19, 2023, 03:40
Default
  #7
Senior Member
 
Join Date: Dec 2021
Posts: 209
Rep Power: 5
Alczem is on a distinguished road
Quote:
Originally Posted by Laurence Wallian View Post
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 !



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:
  1. add the following lines in /usr/local/OpenFOAM-v2212/src/meshTools/PatchFunction1/makePatchFunction1s.C and compile

    Code:
        addUniformValueFieldFunction1s(inputValueMapper, scalar);
        addUniformValueFieldFunction1s(inputValueMapper, vector);
        addUniformValueFieldFunction1s(inputValueMapper, sphericalTensor);
        addUniformValueFieldFunction1s(inputValueMapper, symmTensor);
        addUniformValueFieldFunction1s(inputValueMapper, tensor);
  2. Add the functionObject needed in your controlDict (in my case avg_temp_cold to compute an average temperature)
  3. Use the following syntax to map the functionObject result to the boundary condition:
    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       avg_temp_cold;
    
                    // The result used for x         
                    functionObjectResult average(cold_wall,T);
                             
                    defaultValue         300.15;
    
                     
                }
                value                                                              
                    {                                                                  
                        type            table;                                         
                        values
                        (
                            (273.15  313.15)
                            (303.15  283.15)
                        );
                    };
            }
    
            value               uniform 303.15;
        }
Notice the functionObjectResult: you may have to try a few times to get it right.


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;
    }
Alczem is offline   Reply With Quote

Old   April 19, 2023, 05:31
Default
  #8
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,689
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by Alczem View Post
add the following lines in /usr/local/OpenFOAM-v2212/src/meshTools/PatchFunction1/makePatchFunction1s.C and compile

  1. Code:
        addUniformValueFieldFunction1s(inputValueMapper, scalar);
        addUniformValueFieldFunction1s(inputValueMapper, vector);
        addUniformValueFieldFunction1s(inputValueMapper, sphericalTensor);
        addUniformValueFieldFunction1s(inputValueMapper, symmTensor);
        addUniformValueFieldFunction1s(inputValueMapper, tensor);
...
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).

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.
olesen is offline   Reply With Quote

Old   April 19, 2023, 07:46
Default
  #9
Senior Member
 
Join Date: Dec 2021
Posts: 209
Rep Power: 5
Alczem is on a distinguished road
Quote:
Originally Posted by olesen View Post
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.

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!
Alczem is offline   Reply With Quote

Old   April 20, 2023, 03:58
Default
  #10
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,689
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
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:
  • tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/system/scalarTransport
  • applications/test/Function1/case1/constant/function1Properties
olesen is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:46.