CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (http://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   is there a command to restate after setFields? (http://www.cfd-online.com/Forums/openfoam-pre-processing/117017-there-command-restate-after-setfields.html)

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
Code:

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
Code:

cp 0.orig/* 0/
Cheers,

L

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

sed
(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
regards

akidess June 25, 2013 06:29

I think pyFoamClearInternalField.py is what you are looking for.

immortality June 30, 2013 06:14

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

=====
  pyFoamClearInternalField.py [options] <fieldfile>

pyFoamClearInternalField.py: 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$  pyFoamClearInternalField.py -help
Usage
=====
  pyFoamClearInternalField.py [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

Options
=======
--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
                        screen
--source-key=SRCKEY    The key that should be read from the source patch:
                        value

Default
-------
Options common to all PyFoam-applications

--psyco-accelerated    Accelerate the script using the psyco-library
                        (EXPERIMENTAL and requires a separatly installed
                        psyco)
--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
                        developers
--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
                        debugging)
--interactive-debugger  In case of an exception start the interactive debugger
                        PDB. Also implies --traceback-on-error
--dump-application-data
                        Print the dictionary with the generated application
                        data after running
--pickle-application-data=PICKLEAPPLICATIONDATA
                        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.
Code:

ehsan@Ehsan-com:~/Desktop/two_parted$ pyFoamClearInternalField.py p
Error in /usr/local/bin/pyFoamClearInternalField.py : Either a patch or a value must be specified
ehsan@Ehsan-com:~/Desktop/two_parted$ pyFoamClearInternalField.py right
Error in /usr/local/bin/pyFoamClearInternalField.py : 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:

    pyFoamClearInternalField.py p --patch=right
  • Need to modify the internal field with the specified value? Then use:
    Code:

    pyFoamClearInternalField.py p --value=0.0

Best regards,
Bruno

immortality June 30, 2013 10:10

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

ehsan@Ehsan-com:~/Desktop/two_parted$ pyFoamClearInternalField.py p --value=0.0
Error in /usr/local/bin/pyFoamClearInternalField.py : 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:

pyFoamClearInternalField.py 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.