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

using boxes to partition constant-regions for computing

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 31, 2015, 04:27
Default using boxes to partition constant-regions for computing
  #1
Member
 
Karelke Yu
Join Date: Dec 2014
Posts: 66
Rep Power: 4
cfdopenfoam is on a distinguished road
dear foamers,

i will be very sorry if the title misleads you. well, i am trying to partition my computational domain (not mesh or grid) into several "subregions", and each "subregion" has two constant factors for some computation. different "subregions" will have different constant factors. i hope you know that this is not for parallel computing and i do not mean to decompose any fields or mesh. what i want to do is to impose specific constants to corresponding "subregions" and i consider this as some pre-processing. the very simple psudo-code may be as follows:
Code:
// this file locates in constant/ and named by subregionProperties
constantFactors1 4 // lets say, 4 subregions
(
    subregionName0    0.1;
    subregionName1    0.2;
    subregionName2    0.1;
    subregionName3    0.3;
);

constantFactors2 4 // lets say, 4 subregions
(
    subregionName0    0.3;
    subregionName1    0.1;
    subregionName2    0.2;
    subregionName3    0.5;
)
during simulation, I want to use these factors:
Code:
// during runTime
    if(current cell in subregionName0) then use factors(0.1 0.3);
// or if(current cell in box0) then use factors(0.1 0.3);
    ...
I do not want every cell to have 2 fields to store the factors but cells in subregions to share the corresponding factors. I guess firstly I may need use box to define the "subregions" locations and the following ??? how should i make the implementation???
i hope i have clarified my intention. thanks for your attention.
cfdopenfoam is offline   Reply With Quote

Old   October 31, 2015, 10:41
Default
  #2
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,748
Blog Entries: 39
Rep Power: 103
wyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of light
Quick answer: http://www.cfd-online.com/Forums/ope...tml#post512233 - post #10
wyldckat is offline   Reply With Quote

Old   November 1, 2015, 07:52
Default
  #3
Member
 
Karelke Yu
Join Date: Dec 2014
Posts: 66
Rep Power: 4
cfdopenfoam is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
thanks for your help. i have been struggling on this problem these days and i learned how to basically use topoSet and setSet, probably as some pre-processing. but my intention is to do something with the sets (or maybe zones) during runtime. (BTW, why we have mesh.cellZone() but not mesh.cellSet() )
also, i draft the pesudo-code in mySolver.C:
Code:
// the following code to be added in mySolver.C
List<dimensionedScalar> p1(subregionPropertiesDict.lookup("constantFactors1"));
forAll(p1, i)
{
    const word regionName = p1[i].name();
    forAll(cellsInRegionName, cellI)
    {
        U[cellI] = U[cellI] * p1[i].value();
    };
};
i am sorry that i am new to openfoam coding and please help me correct my mistakes. thanks in advance.
/karelke
cfdopenfoam is offline   Reply With Quote

Old   November 1, 2015, 16:55
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,748
Blog Entries: 39
Rep Power: 103
wyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of light
Hi Karelke,

Sorry, I should have emphasized this line from the post I mentioned:
Quote:
Originally Posted by wyldckat View Post
There you will find that setFields is used in a similar way to topoSet. You can use setFields for assigning a value to a field based on bounding boxes.
The 3rd tutorial on the OpenFOAM User Guide explains how to use setFields: http://cfd.direct/openfoam/user-guid...#x7-530002.3.3 - subsection "2.3.3 Setting initial field"

Quote:
Originally Posted by cfdopenfoam View Post
BTW, why we have mesh.cellZone() but not mesh.cellSet()
"cellSet" is what I like to call a shopping list. It has a list of cells index/identification numbers and only that.
"cellZone" is an actual zone in the mesh, that can be created from a "cellSet". A "cellZone" can have its own mesh characteristics, such as identification of what's inside and orientation and stuff like that (sorry, I can't remember all of the details right now).

As for the code you're trying to use... I believe that by using setFields to define the values for a specific field, for example one named "Zoning", you can then load the "Zoning" field file the same way that "U" and "p" are loaded in the solver's "createFields.H". Then you can use something like this:
Code:
// the following code to be added in mySolver.C
List<dimensionedScalar> p1(subregionPropertiesDict.lookup("constantFactors1"));
forAll(p1, i)
{
    const word regionName = p1[i].name();
    forAll(U, cellI)
    {
        if(p1[i].value() == Zoning[cellI])
        {
             U[cellI] = U[cellI] * p1[i].value();
        }
    };
};
Uh... not sure if this is what you really want to do, but the idea I want to give you is that the field "Zoning" is the one that will have the values that identify your region.

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   November 1, 2015, 23:21
Default
  #5
Member
 
Karelke Yu
Join Date: Dec 2014
Posts: 66
Rep Power: 4
cfdopenfoam is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
"cellSet" is what I like to call a shopping list. It has a list of cells index/identification numbers and only that.
"cellZone" is an actual zone in the mesh, that can be created from a "cellSet". A "cellZone" can have its own mesh characteristics, such as identification of what's inside and orientation and stuff like that (sorry, I can't remember all of the details right now).
thank you for so much type-in. i must apologize for making my problem difficult to understand. well, in fact i could do this as the method you offered. namely create a new volScalarField constantFactor and set this field with setFields. thus i could use it without particularly coding in mySolver.C because every cell possesses this field constantFactor. however, these occupy unnecessary memory and i wonder if i could let cells in certain sets or zones or subregions share a single scalar value during runTime but not only the initial time (as setFields do). and thus i think i need some particulary coding in mySolver.C and i am now struggling on how to do it.
maybe this intention could not be easy (or even possible) to implement. but that is what this thread posted to ask. hope that clarified.
thanks again for your attention.
cfdopenfoam is offline   Reply With Quote

Old   November 2, 2015, 04:48
Default
  #6
Senior Member
 
Join Date: Oct 2013
Posts: 371
Rep Power: 7
chriss85 is on a distinguished road
You might be able to do that if you compute some field values manually, e.g. not in a differential equation. However, in normal cases I would suggest using a field with the factors assigned as its values. Then you can directly use the field in an equation. The memory requirement is usually not the limiting factor in OpenFOAM.
chriss85 is offline   Reply With Quote

Old   November 2, 2015, 05:15
Default
  #7
Member
 
Karelke Yu
Join Date: Dec 2014
Posts: 66
Rep Power: 4
cfdopenfoam is on a distinguished road
Quote:
Originally Posted by chriss85 View Post
You might be able to do that if you compute some field values manually, e.g. not in a differential equation. However, in normal cases I would suggest using a field with the factors assigned as its values. Then you can directly use the field in an equation. The memory requirement is usually not the limiting factor in OpenFOAM.
greetings to chriss85.

yeah. what i need do is actually some simple manually-computing and it's not in a differential equation. and now i find it might indeed not be a easy task without creating a field. but i wonder if there are (or should be) classes such as cellSetScalarField or cellZoneScalarField for convenience.
at last i think the problem will be solved as what you and Bruno have suggested.
BTW, in terms of the dictionary
Code:
// this file locates in constant/ and named by subregionProperties
constantFactors1 4 // lets say, 4 subregions. is this a list?
(
    subregionName0    0.1;  // delimited by a ";"??
    subregionName1    0.2;
    subregionName2    0.1;
    subregionName3    0.3;
);
how should i read the dict and load the value?
thanks for your attention and valuable suggestion.
cfdopenfoam 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
Chemical properties that are used in Fluent kimej FLUENT 4 August 19, 2011 11:29
Constant Volume Combustion with reactingFoam Alish1984 OpenFOAM Running, Solving & CFD 2 May 8, 2011 08:51
How to install CGNS under windows xp? lzgwhy Main CFD Forum 1 January 11, 2011 19:44
CGNS lib and Fortran compiler manaliac Main CFD Forum 2 November 29, 2010 07:25
Really big problems when creating own materials da Jop FLUENT 0 June 28, 2007 11:15


All times are GMT -4. The time now is 16:59.