CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Pre-Processing (
-   -   is there a command to restate after setFields? (

immortality April 30, 2013 11:58

is there a command to restate after setFields?
I have changed the mesh after setFields command and it now gives an error
.so I like to know if is there a command or way to delete non uniform initial values and set it again after such changes?

mgdenno April 30, 2013 12:56

I am not aware of a utility to reset the fields, however you can just open the text files in the 0 directory and delete the internal fields data so that the file only contains the boundary conditions. In general, I think the approach is to create a copy of the field files before running to setFields to avoid having to do it manually.

Lieven April 30, 2013 16:14

Indeed, as Matthew suggests, make a habit of doing

cp -r 0 0.orig
before modifying the fields in the 0-folder. This will save you a lot of time ;-).
Putting the files back is then simply done as

cp 0.orig/* 0/


immortality June 21, 2013 13:59

but it would be nice that a tool be provided like in Swak4Foam for this purpose(if there is not any now!)

colinB June 25, 2013 04:57

actually the method suggested by Lieven is very simple
so there is no need for a separate tool,

however if you have recognized the need for a tool you can exploit the
great advantage of OpenFoam:
You can do everything yourself.
Along with the advantage comes a disadvantage:
You have to do everything yourself.

Still a simple search and replace function like

(use google on that one in combination with keywords like
command and terminal or type: sed --help to get further advice on
how to use it)

in a bash script should do the work.

Deriving a separate c++ code or anything else from that problem
is breaking butterflies on a wheel in my opinion.

I hope I could contribute

akidess June 25, 2013 06:29

I think is what you are looking for.

immortality June 30, 2013 06:14

what does mean fieldfile?what should I replace it in the command?

===== [options] <fieldfile> error: Too few arguments (1 needed, 0 given)
ehsan@Ehsan-com:~/Desktop/two_parted$ clearInternalFields -help
clearInternalFields: command not found
ehsan@Ehsan-com:~/Desktop/two_parted$ -help
===== [options] <fieldfile>

Takes a field-file and makes the whole internal field uniform. Either taking
the value from a patch or using a user-specified value

--version              show program's version number and exit
--help, -h              show this help message and exit
--patch=PATCH          The name of the patch that should provide the value
--value=VALUE          The value that should be used for the internal field
--test                  Does not write the file but only prints it to the
--source-key=SRCKEY    The key that should be read from the source patch:

Options common to all PyFoam-applications

--psyco-accelerated    Accelerate the script using the psyco-library
                        (EXPERIMENTAL and requires a separatly installed
--profile-python        Profile the python-script (not the OpenFOAM-program) -
                        mostly of use for developers
--profile-cpython      Profile the python-script (not the OpenFOAM-program)
                        using the better cProfile library - mostly of use for
--profile-hotshot      Profile the python-script using the hotshot-library
                        (not the OpenFOAM-program) - mostly of use for
                        developers - EXPERIMENTAL
--traceback-on-error    Prints a traceback when an error is encountered (for
--interactive-debugger  In case of an exception start the interactive debugger
                        PDB. Also implies --traceback-on-error
                        Print the dictionary with the generated application
                        data after running
                        Write a pickled version of the application data to a
                        file. If the filename given is 'stdout' then the
                        pickled data is written to stdout. The usual standard
                        output is then captured and added to the application
                        data as an entry 'stdout' (same for 'stderr'). Be
                        careful with these option for commands that generate a
                        lot of output

immortality June 30, 2013 06:20

according to the error I set a patch(right) and a value(p as a field) but nothing done.

ehsan@Ehsan-com:~/Desktop/two_parted$ p
Error in /usr/local/bin/ : Either a patch or a value must be specified
ehsan@Ehsan-com:~/Desktop/two_parted$ right
Error in /usr/local/bin/ : Either a patch or a value must be specified

wyldckat June 30, 2013 06:55

Greetings to all!

@Ehsan: I have not tried this, but the help text seems very clear to me!
  • Need to modify the internal field by using the value that is currently already defined on the patch "right"? Then use:
    Code: p --patch=right
  • Need to modify the internal field with the specified value? Then use:
    Code: p --value=0.0

Best regards,

immortality June 30, 2013 10:10

the files are compressed.have to decompressed them at first?

ehsan@Ehsan-com:~/Desktop/two_parted$ p --value=0.0
Error in /usr/local/bin/ : Problem with file p : [Errno 2] No such file or directory: '/home/ehsan/Desktop/two_parted/p.gz'

wyldckat June 30, 2013 17:43

According to the error message, you should run like this:
Code: 0/p --value=0.0

immortality June 30, 2013 17:47

I think so.
then should repeat it for all fields one after another.:)

All times are GMT -4. The time now is 21:41.