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

explicitSetValue

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 1 Post By samiam1000
  • 2 Post By kwardle

Reply
 
LinkBack Thread Tools Display Modes
Old   March 20, 2012, 11:41
Default explicitSetValue
  #1
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
Dear all,

reading this tutorial, I have found these lines:
Code:
The example shows an explicit volumetric source for a scalar equation, given by a ...ExplicitSource entry. Similarly a constraint can also be applied that sets values in given cells, given by a ...ExplicitSetValue entry. Specialised sources are also available, e.g. actuationDiskSource for wind turbing siting calculations.
It seems that it is possible to set the value of a variable in certain cells, by using the explicitSetValue function.

The point is that I can not understand which is the file that I have to edit.

Could anyone help?

Thanks a lot,

Samuele
mm.abdollahzadeh likes this.
samiam1000 is offline   Reply With Quote

Old   March 20, 2012, 23:38
Default
  #2
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 195
Rep Power: 10
kwardle is on a distinguished road
Take a look at constant/sourcesProperties. This is where you set the sources. The easiest way is to use a cellSet as is done in the simpleFoam/turbineSiting tutorial. The cellSets are defined in system/topoSetDict by running topoSet--which will need to be run in parallel after your decomposePar if you are planning to run your solver in parallel.

For an explicit scalar source named s1 on a field T for example, you would have the following in your sourcesProperties:

Code:
s1
{
    type            scalarExplicitSource;
    active          true;
    timeStart       0;
    duration        10000;
    selectionMode   cellSet;
    cellSet         s1;

    scalarExplicitSourceCoeffs
    {
        volumeMode      absolute; //specific
        injectionRate
        {
            T              <some scalar value>;
        }
    }
}
Hope that helps.
samiam1000 and pyt like this.
kwardle is offline   Reply With Quote

Old   March 21, 2012, 03:42
Default
  #3
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
Dear kwardle,

yeah, this helps a lot, thank you very much.

Just a question (I'll google it, but maybe you already know the answer): can I use `explicitSetValue' with buoyantSimpleFoam/buoyantPisoFoam solver, too?

Thanks again,

Samuele
samiam1000 is offline   Reply With Quote

Old   March 21, 2012, 04:18
Default
  #4
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
Pardon the spam, but I need more help. Let me try to explain what I think I should do:

1. I prepare my case folder
2. I add the constant/sourcesProperties file
3. I give the command topoSet --which (I can not und this point very well. I have a volume patch in my constant/polyMesh/cellZones file.. Isn't it possible to insert in the constant/sourcesProperties the name of that patch instead of running topoSet? I can not und how to use it)
4. I run my simulation.

Is that correct?

If so, I am going to work ok point 3.

Also, in order to embed this functionality in the buoyantSimplFoam folder is it enough to add this line
Quote:
sources.constrain(UEqn());
in the UEqn.H file, according to this page?


Thanks a lot for your help,

Samuele

Last edited by samiam1000; March 21, 2012 at 05:33. Reason: I added a new question
samiam1000 is offline   Reply With Quote

Old   March 21, 2012, 10:03
Default
  #5
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 195
Rep Power: 10
kwardle is on a distinguished road
First, no, buoyantSimpleFoam is not currently set up to use sources as you can see in UEqn.H. You are correct in that you need to add the line you mentioned, but you also need to add the source term in the actual equation as:

Code:
    tmp<fvVectorMatrix> UEqn
    (
        fvm::div(phi, U)
      + turbulence->divDevRhoReff(U)
      == sources(U)
    );
For example, compare simpleFoam/UEqn.H with the one in buoyantSimpleFoam/UEqn.H and you will see the lines you need to add. But that is NOT everything. There are two additional things to add elsewhere:

1. Add the header to the main solver source file (buoyantSimpleFoam.C) as:

Code:
#include "IObasicSourceList.H"
2. Add the line:
Code:
 IObasicSourceList sources(mesh);
to the end of createFields.H

Again take a look at the files in simpleFoam as an example. Be sure to recompile your solver and you should be good (unless I have missed something). If there are errors, they are usually helpful it you start at the time and actually take a look at why it is complaining. This will help you add what is missing.
Regards,
Kent
kwardle is offline   Reply With Quote

Old   March 21, 2012, 10:09
Default
  #6
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
Hi Kent and thanks for answering.

I did what you suggested, but I get an error. Here you can find a new post with my problem (I started a new thread since it is a different problem).

If you can have a look, that would be great.
Thanks a lot,

Samuele

PS: now I am trying to run a case using the simpleFoam solver in order to be able to use the explicitSetValue feature. I want to fix the value of a variable (the temperature!) in each cell of a certain patch. That sounds challenging, doesn't it?
samiam1000 is offline   Reply With Quote

Old   March 21, 2012, 10:15
Default
  #7
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 195
Rep Power: 10
kwardle is on a distinguished road
Sorry, I didn't answer item #3 in your post. If you want to apply a uniform source everywhere in your domain (not sure what you mean by 'volume patch') then just create a cellSet as a box bigger than your volume with the following in topoSetDict:

Code:
actions
(
    {
        name    bigBox;
        type    cellSet;
        action  new;
     
        source boxToCell;
        sourceInfo
        {
        box (-1 -1 -1) (1 1 1);  //box corner limits
        }
    }
);
kwardle is offline   Reply With Quote

Old   March 21, 2012, 10:22
Default
  #8
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
Sorry: maybe I didn't explain very well what I meant. I don't want to fix the temperature in each cell of my domain, but I want to fix it in each cell that is in a subdomain in the patch called air_infinite.

If you look at my constant/polyMesh/cellZones, you will find:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.0.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       regIOobject;
    location    "constant/polyMesh";
    object      cellZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

3
(
air_infinite
{
    type cellZone;
cellLabels      List<label> 
1218
(
0
.
.
.
1217
)
;
}

air_internal
{
    type cellZone;
cellLabels      List<label> 
97372
(
1218
.
.
.
98589
)
;
}

air_external
{
    type cellZone;
cellLabels      List<label> 
9492
(
98590
.
.
.
108081
)
;
}
)

// ************************************************************************* //
and what I want to do is to write in the constant/sourcesProperties the name of the patch (i.e. air_internal). Is it possible?
samiam1000 is offline   Reply With Quote

Old   March 21, 2012, 10:29
Default
  #9
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 195
Rep Power: 10
kwardle is on a distinguished road
OK, I misunderstood and thought you were trying to set a source not constrain the value to a set value. Even so, I think the setup is all the same you would just use scalarExplicitSetValue instead in your sourcesProperties as:

Code:
s1
{
    type            scalarExplicitSetValue;
    active          true;
    timeStart       0;
    duration        10000;
    selectionMode   cellSet;
    cellSet         bigBox;

    scalarExplicitSetValueCoeffs
    {
        injectionRate
        {
            T              <some scalar value>;
        }
    }
}
As for you question about setting the source on a cellZone. How did you create the cellZone in the first place? You would have had to create a cellSet first and the run setsToZones to create the zone (perhaps there is another way but this is the one I know) or you have converted the mesh from some other format in which case, I think it still makes the set first. Presumably you already have a cellSet named air_internal as well. Take a look in constant/polyMesh/sets/ to see.
kwardle is offline   Reply With Quote

Old   March 21, 2012, 10:41
Default
  #10
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
Quote:
Originally Posted by kwardle View Post
OK, I misunderstood and thought you were trying to set a source not constrain the value to a set value. Even so, I think the setup is all the same you would just use scalarExplicitSetValue instead in your sourcesProperties as:

Code:
s1
{
    type            scalarExplicitSetValue;
    active          true;
    timeStart       0;
    duration        10000;
    selectionMode   cellSet;
    cellSet         bigBox;

    scalarExplicitSetValueCoeffs
    {
        injectionRate
        {
            T              <some scalar value>;
        }
    }
}
Yeah, thanks a lot. That's great.

Quote:

As for you question about setting the source on a cellZone. How did you create the cellZone in the first place? You would have had to create a cellSet first and the run setsToZones to create the zone (perhaps there is another way but this is the one I know) or you have converted the mesh from some other format in which case, I think it still makes the set first. Presumably you already have a cellSet named air_internal as well. Take a look in constant/polyMesh/sets/ to see.
This is a more challenging question. Well, I convert the mesh from the fluent format and that's why I have those patches in the cellZone file.

Also, I don't have any constant/polyMesh.. How can I create it?
Sorry, but I can not understand your suggestion.
Could you explain the steps?

Thanks again,

Samuele
samiam1000 is offline   Reply With Quote

Old   March 21, 2012, 11:04
Default
  #11
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 195
Rep Power: 10
kwardle is on a distinguished road
Two thoughts.
1. Not sure which converter you used, but fluentMeshToFoam has an option -writeSets which will write your regions as sets. It also has one -writeZones which will just write the zones only. So, you could make a new case and reconvert your mesh with -writeSets and copy those over to the old case..
2. Alternatively, it would be pretty simple to manually create the cellSet file from the cellZone file. The format of the cellSet file would just be:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.1.x                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       cellSet;
    location    "constant/polyMesh/sets";
    object      air_internal;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


97372
(
1218
.
.
.
98589
)

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
That seems easy enough. Just copy and paste the list of cell numbers in you zone and create the file as constant/polyMesh/sets/air_internal.
kwardle is offline   Reply With Quote

Old   March 21, 2012, 12:28
Default
  #12
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
Thanks a lot. I am going to try with this.

Just a question: should I "activate" the sourceProperties file?

I mean, once I save it in the constant folder, how can I `tell' the solver to read it?
Is it automatic?

Thanks again,

Samuele
samiam1000 is offline   Reply With Quote

Old   March 21, 2012, 12:43
Default
  #13
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 195
Rep Power: 10
kwardle is on a distinguished road
If the solver is set up for sources it will look for the file and probably complain if it is not there. If the file sourcesProperties is there and the specific source is set to "active true;" then it should work.
kwardle is offline   Reply With Quote

Old   March 22, 2012, 04:16
Default
  #14
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
I thought about fixing the velocity instead of pressure.
But it doesn't work.

Last edited by samiam1000; March 22, 2012 at 04:39.
samiam1000 is offline   Reply With Quote

Old   March 22, 2012, 04:35
Default
  #15
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
That's great.

Everything works, now!

Thanks for the support,

Samuele.

PS: now I have to add this feature into the buoyantSimpleFoam problem. If you want to help me, look at this. Samuele

Last edited by samiam1000; March 22, 2012 at 05:36.
samiam1000 is offline   Reply With Quote

Old   March 26, 2012, 06:16
Default Could you have a look at the link?
  #16
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
Dear Kent,

could you help me in solving the same problem with buoyanPimpleFoam.

If you want, you can read this thread.

Thanks a lot,

Samuele.
samiam1000 is offline   Reply With Quote

Old   April 17, 2012, 05:13
Default
  #17
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
Dear Kent,

I would like to embed the explicitSetValue feature (read here) in the chtMultiRegionFoam (see here).

Could you kindly help, please?

Thanks a lot,

Samuele
samiam1000 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ExplicitSetValue samiam1000 OpenFOAM 0 March 8, 2012 09:28


All times are GMT -4. The time now is 11:38.