CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Making changes to the files under /opt/openfoam directory (https://www.cfd-online.com/Forums/openfoam-programming-development/121669-making-changes-files-under-opt-openfoam-directory.html)

Mojtaba.a August 2, 2013 11:01

Making changes to the files under /opt/openfoam directory
 
Hi dear Foamers,

I am trying to modify some utilities and make some small changes in them, but I do not want to make new utilities, because changes are so small.

For example I am trying to write out "Total cell numbers" while I am running "checkMesh" utility.
I don't want to make a new "checkMesh2" utility to do this. Just want to make the small change in the source file and compiling "checkMesh" utility again.

My openFOAM is installed in /opt directory.
is it possible to do this?

Best regards,
Mojtaba

nimasam August 2, 2013 13:01

as opt is writing protected for user , you should be root,
i guess using sudo wmake will solve your problem, or you may want to compile it as usual, then put your binary file where present checkMesh binary file is placed

Mojtaba.a August 2, 2013 15:01

Quote:

Originally Posted by nimasam (Post 443531)
as opt is writing protected for user , you should be root,
i guess using sudo wmake will solve your problem, or you may want to compile it as usual, then put your binary file where present checkMesh binary file is placed

Thank you dear Nima,
Well actually sudo wmake doesn't help, I don't know why yet. I was thinking about deleting compiled binaries of checkMesh (or maybe wclean it) and then compile my new utility with the same name (checkMesh) in FOAM_USER_APPBIN.
Your second idea is interesting.

I will report back the results.

best

luckycfd August 2, 2013 15:11

salam
 
Greetings Mojtaba,
following instruction:
Code:

1. cp -r $FOAM_UTILITIES/mesh/manipulation/checkMesh $FOAM_RUN/checkMesh2
2. cd $FOAM_RUN/checkMesh2
3. making your changes in the relevant source file
4.  Change your Make/files to:
                printMeshStats.C
                checkTopology.C
                checkGeometry.C
                checkMesh.C

                EXE = $(FOAM_USER_APPBIN)/checkMesh2
5. Compile:
                  wclean
                  rm –r Make/linux*
                  wmake

Best regards,
Hassan:)

Mojtaba.a August 2, 2013 15:21

Quote:

Originally Posted by luckycfd (Post 443548)
Greetings Mojtaba,
following instruction:
Code:

1. cp -r $FOAM_UTILITIES/mesh/manipulation/checkMesh $FOAM_RUN/checkMesh2
2. cd $FOAM_RUN/checkMesh2
3. making your changes in the relevant source file
4.  Change your Make/files to:
                printMeshStats.C
                checkTopology.C
                checkGeometry.C
                checkMesh.C

                EXE = $(FOAM_USER_APPBIN)/checkMesh2
5. Compile:
                  wclean
                  rm –r Make/linux*
                  wmake

Best regards,
Hassan:)

Thank you dear Hassan :),

Well this procedure doesn't actually replace the utility "checkMesh". I think it simply makes a new utility named "checkMesh2".

I prefer to have the old checkMesh utility with some new changes, without compiling a whole new utility named "checkMesh2".

best,
Mojtaba

Mojtaba.a August 2, 2013 15:48

Problem is solved,

Thank you Nima and Hassan for your suggestions. :)
Well actually solution was quite easy as Nimasam said.
Here is the step by step procedure:

1- Copy your desired utility into
$WM_PROJECT_USER_DIR/applications/utilities

2- modify the code and make your desired modifications.

3- Do not change *.C file name and do not change the name in /Make/files

4- run wmake

5- sudo rm /opt/openfoam---/platforms/linux64GccDPOpt/bin/utility

i.e: sudo rm /opt/openfoam---/platforms/linux64GccDPOpt/bin/checkMesh

Note: --- is your Of version

6- sudo cp $WM_PROJECT_USER_DIR/applications/utilities/utility /opt/openfoam---/platforms/linux64GccDPOpt/bin/

i.e:

sudo cp $WM_PROJECT_USER_DIR/applications/utilities/checkMesh /opt/openfoam---/platforms/linux64GccDPOpt/bin/


And you are done ;)

Best Wishes,
Mojtaba

Mojtaba.a September 27, 2013 15:46

Hi, I want to make some little modifications to my previous post.
Here is the updated procedure:

1- Copy your desired utility into
$WM_PROJECT_USER_DIR/applications/utilities

2- modify the code and make your desired modifications.

***3- Do not change *.C file name and do not change the name in /Make/files

but instead change FOAM_APPBIN into FOAM_USER_APPBIN

4- run wmake

5- sudo rm /opt/openfoam<version>/platforms/linux64GccDPOpt/bin/utility

i.e: sudo rm /opt/openfoam221/platforms/linux64GccDPOpt/bin/checkMesh

***6- sudo cp $WM_PROJECT_USER_DIR/platforms/linux64GccDPOpt/bin/utility /opt/openfoam<version>/platforms/linux64GccDPOpt/bin/

i.e:

***sudo cp $WM_PROJECT_USER_DIR/platforms/linux64GccDPOpt/bin/checkMesh /opt/openfoam221/platforms/linux64GccDPOpt/bin/

I hope it helps a bit.
Best.


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