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

how to use setFields in multiregionsolver

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By karlvirgil

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 1, 2012, 05:37
Default how to use setFields in multiregionsolver
  #1
Member
 
jack
Join Date: Jul 2011
Posts: 52
Rep Power: 15
lg88 is on a distinguished road
Hello everyone
I am simulating a FSI problem with multiregionsolver.In my case,there are only two regions, solid and fluid.Now I want to use the function setFields to set a quantity ,for example initial volume fraction, in fluid region.
I tried to put the setFieldsDict file in system/fluid floder,then run
Code:
setFields -region solid
or
Code:
setFields
And it failed.

The following is the details of the file setFieldsDict in my case:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

defaultFieldValues
(
volScalarFieldValue sigma 2
);

regions
(
boxToCell
{
box (-1.1 -1.1 0) (-1.0 1.1 5);
fieldValues
(
volScalarFieldValue sigma 0.01
);
}

boxToCell
{
box (1.0 -1.1 0) (1.1 1.1 5);
fieldValues
(
volScalarFieldValue sigma 0.01
);
}
);

// ************************************************** **** //

So where should I put the setFieldsDict and how to modified it?

regards!

lg88
lg88 is offline   Reply With Quote

Old   August 2, 2012, 08:42
Default
  #2
New Member
 
JOMAA Ghassan
Join Date: Jan 2012
Location: Paris
Posts: 8
Rep Power: 14
ghas is on a distinguished road
Hi Jack,

To do that, follow the following steps:

1- cd $WM_PROJECT_DIR/applications/utilities/preProcessing
2- cp -r setFields $WM_PROJECT_USER_DIR/applications/utilities/preProcessing
3- Rename the directory and the source file name, clean all the dependancies and
> mv setFields mysetFields
> cd mysetFields
> mv setFields.C mysetFields.C
> wclean

5- Add the region option to mysetFields.C file by

# include "addRegionOption.H"

6- Replace the line

# include "createMesh.H"

by:

# include "createNamedPolyMesh.H"

7- Open Make/files and modify it as follows:
mysetFields.C
EXE = $(FOAM_USER_APPBIN)/mysetFields

8- Compile the utility by wmake

9- Now your utility is ready to be ued:

> mysetFields -region solid



Best regards

Ghassan
ghas is offline   Reply With Quote

Old   August 2, 2012, 10:44
Default
  #3
Member
 
jack
Join Date: Jul 2011
Posts: 52
Rep Power: 15
lg88 is on a distinguished road
Hi Ghassan

I have done as you said and it works correctly.Thank you very much!
By the way,do you know how to convert the result data of different regions to tecplot360?
I use the following command,but the converted data can not work in tecplot.
Code:
foamToTecplot360 -region fluid
foamToTecplot360 -region solid
regards!

lg88

Last edited by lg88; August 2, 2012 at 11:08.
lg88 is offline   Reply With Quote

Old   August 2, 2012, 12:44
Default
  #4
New Member
 
JOMAA Ghassan
Join Date: Jan 2012
Location: Paris
Posts: 8
Rep Power: 14
ghas is on a distinguished road
Hi jack,

The foamTotecplot supports the multi-region option and I think that there is another proplem in your run. what's the error message ?

Best regards,

Ghassan

Last edited by ghas; August 2, 2012 at 13:00.
ghas is offline   Reply With Quote

Old   August 2, 2012, 20:39
Default
  #5
Member
 
jack
Join Date: Jul 2011
Posts: 52
Rep Power: 15
lg88 is on a distinguished road
Hi Ghassan
I have found my problem and it can run now.Thank you all the same!

regards!

jack
lg88 is offline   Reply With Quote

Old   November 26, 2012, 14:38
Default setFields multiregion fix for 2.1.x
  #6
New Member
 
karlvirgil's Avatar
 
Join Date: Jul 2009
Location: Wrentham, MA
Posts: 9
Rep Power: 17
karlvirgil is on a distinguished road
For OpenFOAM-2.1.x the setFields can be made multiregional if the following changes are made to setFields.C

Quote:
$ )git diff setFields.C

diff --git a/applications/utilities/preProcessing/setFields/setFields.C b/applications/utilities/preProcessing/setFields/setFields.C
index 0930468..d9a53ee 100644
--- a/applications/utilities/preProcessing/setFields/setFields.C
+++ b/applications/utilities/preProcessing/setFields/setFields.C
@@ -331,9 +331,10 @@ public:

int main(int argc, char *argv[])
{
+# include "addRegionOption.H"
# include "setRootCase.H"
# include "createTime.H"
-# include "createMesh.H"
+# include "createNamedMesh.H"

Ivooo likes this.
karlvirgil is offline   Reply With Quote

Old   January 14, 2013, 15:51
Default
  #7
Member
 
Jamal
Join Date: May 2012
Location: Freiburg
Posts: 54
Rep Power: 13
aujamal20 is an unknown quantity at this point
Dear
I am using OF 2.1.0 and I am trying to modify setFields utility to work on multiRegion and I have followed the same steps which are given but I am facing error

Quote:
SOURCE=mysetFields.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/OpenFOAM/OpenFOAM-2.1.0/src/finiteVolume/lnInclude -I/opt/OpenFOAM/OpenFOAM-2.1.0/src/meshTools/lnInclude -IlnInclude -I. -I/opt/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude -I/opt/OpenFOAM/OpenFOAM-2.1.0/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/mysetFields.o
In file included from mysetFields.C:37:0:
/opt/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/addRegionOption.H:6:5: error: expected constructor, destructor, or type conversion before '(' token
mysetFields.C: In function 'int main(int, char**)':
mysetFields.C:343:6: error: 'Get' was not declared in this scope
mysetFields.C:343:10: error: expected ';' before 'times'
mysetFields.C:369:62: error: no matching function for call to 'setCellField::iNew::iNew(Foam:olyMesh&, Foam::labelList)'
mysetFields.C:369:62: note: candidates are:
mysetFields.C:133:9: note: setCellField::iNew::iNew(const Foam::fvMesh&, const labelList&)
mysetFields.C:133:9: note: no known conversion for argument 1 from 'Foam:olyMesh' to 'const Foam::fvMesh&'
mysetFields.C:126:11: note: setCellField::iNew::iNew(const setCellField::iNew&)
mysetFields.C:126:11: note: candidate expects 1 argument, 2 provided
mysetFields.C:404:63: error: no matching function for call to 'setCellField::iNew::iNew(Foam:olyMesh&, Foam::List<int>)'
mysetFields.C:404:63: note: candidates are:
mysetFields.C:133:9: note: setCellField::iNew::iNew(const Foam::fvMesh&, const labelList&)
mysetFields.C:133:9: note: no known conversion for argument 1 from 'Foam:olyMesh' to 'const Foam::fvMesh&'
mysetFields.C:126:11: note: setCellField::iNew::iNew(const setCellField::iNew&)
mysetFields.C:126:11: note: candidate expects 1 argument, 2 provided
mysetFields.C:425:63: error: no matching function for call to 'setFaceField::iNew::iNew(Foam:olyMesh&, Foam::List<int>)'
mysetFields.C:425:63: note: candidates are:
mysetFields.C:295:9: note: setFaceField::iNew::iNew(const Foam::fvMesh&, const labelList&)
mysetFields.C:295:9: note: no known conversion for argument 1 from 'Foam:olyMesh' to 'const Foam::fvMesh&'
mysetFields.C:288:11: note: setFaceField::iNew::iNew(const setFaceField::iNew&)
mysetFields.C:288:11: note: candidate expects 1 argument, 2 provided
make: *** [Make/linux64GccDPOpt/mysetFields.o] Error 1
Help me out to fix this error.

Regards,
Jamal
aujamal20 is offline   Reply With Quote

Old   January 14, 2013, 16:21
Default
  #8
New Member
 
JOMAA Ghassan
Join Date: Jan 2012
Location: Paris
Posts: 8
Rep Power: 14
ghas is on a distinguished road
Quote:
Originally Posted by aujamal20 View Post
Dear
I am using OF 2.1.0 and I am trying to modify setFields utility to work on multiRegion and I have followed the same steps which are given but I am facing error



Help me out to fix this error.

Regards,
Jamal
Hi Jamal,

I think that you uncommented "// Get times list" by the ommision of "//" . You can find the modified code of setFields in the attached file.

Best Regards,
Ghassan
Attached Files
File Type: c mysetFields.C (11.3 KB, 129 views)
ghas is offline   Reply With Quote

Old   January 15, 2013, 06:01
Default
  #9
Member
 
Jamal
Join Date: May 2012
Location: Freiburg
Posts: 54
Rep Power: 13
aujamal20 is an unknown quantity at this point
Dear ghas

So nice of you, it helped me to solve the problem...

Thanks
aujamal20 is offline   Reply With Quote

Old   June 18, 2018, 11:23
Default
  #10
Member
 
Ben 017
Join Date: Nov 2017
Posts: 70
Rep Power: 9
Ben UWIHANGANYE is on a distinguished road
Quote:
Originally Posted by ghas View Post
Hi Jack,

To do that, follow the following steps:

1- cd $WM_PROJECT_DIR/applications/utilities/preProcessing
2- cp -r setFields $WM_PROJECT_USER_DIR/applications/utilities/preProcessing
3- Rename the directory and the source file name, clean all the dependancies and
> mv setFields mysetFields
> cd mysetFields
> mv setFields.C mysetFields.C
> wclean

5- Add the region option to mysetFields.C file by

# include "addRegionOption.H"

6- Replace the line

# include "createMesh.H"

by:

# include "createNamedPolyMesh.H"

7- Open Make/files and modify it as follows:
mysetFields.C
EXE = $(FOAM_USER_APPBIN)/mysetFields

8- Compile the utility by wmake

9- Now your utility is ready to be ued:

> mysetFields -region solid



Best regards

Ghassan

I was trying the same procedure but failed, the following is the error msg i got. May you help please.



/opt/openfoam4/applications/utilities/preProcessing/mysetFields
mkdir: cannot create directory ‘/opt/openfoam4/platforms/linux64GccDPInt32Opt/applications’: Permission denied
/bin/sh: 1: cannot create /opt/openfoam4/platforms/linux64GccDPInt32Opt/applications/utilities/preProcessing/mysetFields/options: Directory nonexistent
make: *** No rule to make target '/opt/openfoam4/platforms/linux64GccDPInt32Opt/applications/utilities/preProcessing/mysetFields/options'. Stop.
/bin/sh: 1: cannot create /opt/openfoam4/platforms/linux64GccDPInt32Opt/applications/utilities/preProcessing/mysetFields/options: Directory nonexistent
make: *** No rule to make target '/opt/openfoam4/platforms/linux64GccDPInt32Opt/applications/utilities/preProcessing/mysetFields/options', needed by 'all'. Stop.
wmake error: file '/opt/openfoam4/platforms/linux64GccDPInt32Opt/applications/utilities/preProcessing/mysetFields/sourceFiles' could not be created in /opt/openfoam4/applications/utilities/preProcessing/mysetFields




Regard!
Ben UWIHANGANYE is offline   Reply With Quote

Old   June 18, 2018, 11:44
Default
  #11
New Member
 
JOMAA Ghassan
Join Date: Jan 2012
Location: Paris
Posts: 8
Rep Power: 14
ghas is on a distinguished road
You need to modify the location of the binary executable file mysetFields(or run wmake as a super user). To do so, you can just repalce the last line of Make/files:



EXE = $(FOAM_APPBIN)/mysetFields



by



EXE = $(FOAM_USER_APPBIN)/mysetFields




regards
ghas is offline   Reply With Quote

Old   June 18, 2018, 11:50
Default
  #12
Member
 
Ben 017
Join Date: Nov 2017
Posts: 70
Rep Power: 9
Ben UWIHANGANYE is on a distinguished road
Thank you for quick feedback.




That one i did as it has been instructed :

May be that of running it as super user is what i didn't. How is it done(run as super user.)?






Regard!
Ben UWIHANGANYE is offline   Reply With Quote

Old   June 18, 2018, 11:56
Default
  #13
New Member
 
JOMAA Ghassan
Join Date: Jan 2012
Location: Paris
Posts: 8
Rep Power: 14
ghas is on a distinguished road
> sudo su
> enter your password
> source /opt/openfoam4/etc/bashrc
> cd /opt/openfoam4/applications/utilities/preProcessing/mysetFields
> wmake


Regards
ghas is offline   Reply With Quote

Old   June 18, 2018, 16:34
Default
  #14
Member
 
Ben 017
Join Date: Nov 2017
Posts: 70
Rep Power: 9
Ben UWIHANGANYE is on a distinguished road
Quote:
Originally Posted by lg88 View Post
Hello everyone
I am simulating a FSI problem with multiregionsolver.In my case,there are only two regions, solid and fluid.Now I want to use the function setFields to set a quantity ,for example initial volume fraction, in fluid region.
I tried to put the setFieldsDict file in system/fluid floder,then run
Code:
setFields -region solid
or
Code:
setFields
And it failed.

The following is the details of the file setFieldsDict in my case:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

defaultFieldValues
(
volScalarFieldValue sigma 2
);

regions
(
boxToCell
{
box (-1.1 -1.1 0) (-1.0 1.1 5);
fieldValues
(
volScalarFieldValue sigma 0.01
);
}

boxToCell
{
box (1.0 -1.1 0) (1.1 1.1 5);
fieldValues
(
volScalarFieldValue sigma 0.01
);
}
);

// ************************************************** **** //

So where should I put the setFieldsDict and how to modified it?

regards!

lg88
Hello,

Did you succeed with this case, may you share the setup and results you got?

is it possible to replace the boxTocell with a cylinder?


Thank you!
Ben UWIHANGANYE is offline   Reply With Quote

Old   June 22, 2018, 06:15
Default immersed cylinder
  #15
Member
 
Ben 017
Join Date: Nov 2017
Posts: 70
Rep Power: 9
Ben UWIHANGANYE is on a distinguished road
Hello Foamers,

I would like to ask how the modified setFieldsDict is used in FSI simulation.

Indeed, I want to simulate flow over a cylinder(stationary and oscillating). I have used toposetDict to map that cylinder in fluid Cartesian domain.

Let: eta=1 solid region, eta=0 fluid region.
Then i have a c++ code that gives me a value of eta each time step. The eta's value alternate from 0 to 1 and from 1 to 0. C++ code prints eta values in .dat format.

I am asking if it is possible to use setFieldsDict to move (oscillating motion) that cylinder as eta changes.

what should be my code looking like?

I will be happy to hear from you!

Regard!
Ben UWIHANGANYE is offline   Reply With Quote

Old   July 11, 2018, 13:30
Default
  #16
Member
 
Vivek
Join Date: Mar 2018
Location: India
Posts: 54
Rep Power: 8
vivek05 is on a distinguished road
Hi
i am facing problem in setFields usage. simulating spray using interFoam solver .when i run setFields command it doesnt make any changes in 0/alpha.water folder. i am using boxTocell (0 0.1 -1) (0.06 0.1 1) these dimension are my fuel inlet coordinates.
vivek05 is offline   Reply With Quote

Old   April 13, 2022, 10:01
Default setFields i OF ESI 2112
  #17
New Member
 
Marco Rosatti
Join Date: Mar 2019
Location: Argentina
Posts: 4
Rep Power: 7
Brodenson is on a distinguished road
Quote:
Originally Posted by ghas View Post
Hi Jack,

To do that, follow the following steps:

1- cd $WM_PROJECT_DIR/applications/utilities/preProcessing
2- cp -r setFields $WM_PROJECT_USER_DIR/applications/utilities/preProcessing
3- Rename the directory and the source file name, clean all the dependancies and
> mv setFields mysetFields
> cd mysetFields
> mv setFields.C mysetFields.C
> wclean

5- Add the region option to mysetFields.C file by

# include "addRegionOption.H"

6- Replace the line

# include "createMesh.H"

by:

# include "createNamedPolyMesh.H"

7- Open Make/files and modify it as follows:
mysetFields.C
EXE = $(FOAM_USER_APPBIN)/mysetFields

8- Compile the utility by wmake

9- Now your utility is ready to be ued:

> mysetFields -region solid



Best regards

Ghassan
I tried to use this in OF ESI 2112 and it didn't work but I discovered that using only setFields -region <your region name> works fine!

Greetings!
Brodenson is offline   Reply With Quote

Old   June 12, 2022, 14:39
Default
  #18
Member
 
Michael Jensen
Join Date: May 2022
Posts: 36
Rep Power: 4
mikethe1wheelnut is on a distinguished road
Quote:
Originally Posted by ghas View Post
Hi Jack,

To do that, follow the following steps:

1- cd $WM_PROJECT_DIR/applications/utilities/preProcessing
2- cp -r setFields $WM_PROJECT_USER_DIR/applications/utilities/preProcessing
3- Rename the directory and the source file name, clean all the dependancies and
> mv setFields mysetFields
> cd mysetFields
> mv setFields.C mysetFields.C
> wclean

5- Add the region option to mysetFields.C file by

# include "addRegionOption.H"

6- Replace the line

# include "createMesh.H"

by:

# include "createNamedPolyMesh.H"

7- Open Make/files and modify it as follows:
mysetFields.C
EXE = $(FOAM_USER_APPBIN)/mysetFields

8- Compile the utility by wmake

9- Now your utility is ready to be ued:

> mysetFields -region solid



Best regards

Ghassan

Code:
eriadar@eriadar-Latitude-E7440:/opt/openfoam9/applications/utilities/preProcessing$ mv setFields mysetFields
mv: cannot move 'setFields' to 'mysetFields': Permission denied
..is this command supposed to be executed with sudo? ..or it it supposed to be done in the -destination- directory?


Edit: based on ghas's comment [10:56], I conclude I'm supposed to do this with sudo.


Edit 2: my file doesn't have this line: "# include "createMesh.H"" -the closest I come is " #include "createNamedMesh.H"", half-way down the file.


Edit 3: I've been reading the forum rules, and concluded that this is in the wrong place. I'm "hijacking" the thread. ..So somehow I have to come up with a new original title for a new thread..


Last edited by mikethe1wheelnut; June 12, 2022 at 20:03. Reason: ..self-explanatory..
mikethe1wheelnut is offline   Reply With Quote

Old   June 12, 2022, 19:57
Default Instructions not completely clear, or other problems..
  #19
Member
 
Michael Jensen
Join Date: May 2022
Posts: 36
Rep Power: 4
mikethe1wheelnut is on a distinguished road
Quote:
Originally Posted by ghas View Post
Hi Jack,

To do that, follow the following steps:

1- cd $WM_PROJECT_DIR/applications/utilities/preProcessing
2- cp -r setFields $WM_PROJECT_USER_DIR/applications/utilities/preProcessing
3- Rename the directory and the source file name, clean all the dependancies and
> mv setFields mysetFields
> cd mysetFields
> mv setFields.C mysetFields.C
> wclean

5- Add the region option to mysetFields.C file by

# include "addRegionOption.H"

6- Replace the line

# include "createMesh.H"

by:

# include "createNamedPolyMesh.H"

7- Open Make/files and modify it as follows:
mysetFields.C
EXE = $(FOAM_USER_APPBIN)/mysetFields

8- Compile the utility by wmake

9- Now your utility is ready to be ued:

> mysetFields -region solid



Best regards

Ghassan

I have got, in principle, to the stage of compiling with wmake. I get the following errors:


Code:
eriadar@eriadar-Latitude-E7440:/opt/openfoam9/applications/utilities/preProcessing/mysetFields$ wmake
mkdir: cannot create directory ‘/opt/openfoam9/platforms/linux64GccDPInt32Opt/applications’: Permission denied
/bin/sh: 1: cannot create /opt/openfoam9/platforms/linux64GccDPInt32Opt/applications/utilities/preProcessing/mysetFields/files: Directory nonexistent
make: *** [/opt/openfoam9/wmake/makefiles/files:59: /opt/openfoam9/platforms/linux64GccDPInt32Opt/applications/utilities/preProcessing/mysetFields/files] Error 2
wmake error: file '/opt/openfoam9/platforms/linux64GccDPInt32Opt/applications/utilities/preProcessing/mysetFields/files' could not be created in /opt/openfoam9/applications/utilities/preProcessing/mysetFields
eriadar@eriadar-Latitude-E7440:/opt/openfoam9/applications/utilities/preProcessing/mysetFields$ sudo wmake
[sudo] password for eriadar: 
sudo: wmake: command not found
eriadar@eriadar-Latitude-E7440:/opt/openfoam9/applications/utilities/preProcessing/mysetFields$ ls /usr/bin/make
/usr/bin/make
eriadar@eriadar-Latitude-E7440:/opt/openfoam9/applications/utilities/preProcessing/mysetFields$ /usr/bin/make --version
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
eriadar@eriadar-Latitude-E7440:/opt/openfoam9/applications/utilities/preProcessing/mysetFields$
Perhaps somebody can spot what is wrong?


In the instructions, I've made the assumption that:


Code:
> mv setFields mysetFields
      > cd mysetFields
      > mv setFields.C mysetFields.C
      > wclean
    
    5- Add the region option to mysetFields.C file by 
    
    #   include "addRegionOption.H"
    
    6- Replace the line 
    
     # include "createMesh.H"
    
    by:
    
    #   include "createNamedPolyMesh.H"
    
    7- Open Make/files and modify it as follows:
    mysetFields.C
    EXE = $(FOAM_USER_APPBIN)/mysetFields
should all be done in the directory:


Code:
$WM_PROJECT_DIR/applications/utilities/preProcessing
I'm not at all sure about that though. My next experiment will be un-doing (if possible -not totally clear on what wclean does) what I've done, and re-doing it in:


Code:
$WM_PROJECT_USER_DIR/applications/utilities/preProcessing
Edit: I've been reading the forum rules, and concluded that this is in the wrong place. I'm "hijacking" the thread. ..So somehow I have to come up with a new original title for a new thread..


Edit: Please see my most recent "progress" here: Compilation problems adapting setFields for multiregionsolver

Last edited by mikethe1wheelnut; June 13, 2022 at 03:29. Reason: added link to new thread with the problems I'm having.
mikethe1wheelnut is offline   Reply With Quote

Reply

Tags
setfields


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
setFields not working dsanza OpenFOAM 4 October 18, 2018 10:43
Problems with the execution of the setFields utility. foamer OpenFOAM Pre-Processing 5 June 3, 2013 13:24
setFields tool does not assign water volume for given mesh. paka OpenFOAM 2 June 7, 2012 10:17
OF 1.6-ext setFields does not keep patch values Arnoldinho OpenFOAM Bugs 3 May 9, 2012 04:58
question on setFields fijinx OpenFOAM Running, Solving & CFD 1 February 15, 2010 16:07


All times are GMT -4. The time now is 09:40.