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/)
-   -   Preprocessing code wmake (https://www.cfd-online.com/Forums/openfoam-programming-development/255667-preprocessing-code-wmake.html)

gmax April 23, 2024 04:26

Preprocessing code wmake
 
Hi everyone, I'm trying to debug buoyantFoam for mesh switching (when the solution is mapped to another mesh it crashes). What I would like to do is observe what is placed inside the file when it is compiled.


Usually if I want to do this with g++ I can give a command like:
Code:

g++ -E code.C -o preproces.file

and get a pre process file. I'm not sure you can do this with wmake. Does anyone know if it can be done or if there is an alternative way to understand the code?
thanks for the replies.

olesen April 23, 2024 11:21

Not the most convenient, since you have a number of include directories and defines to worry about but you could try doing the following:


Code:

cd your/directory

wmake > stderr


The stderr file will contain the full command-line used to compile. Will "only" need to edit this to add the '-E' option and replace the output name with your prepro.file .


This worked OK for me, but even a simple file quickly expands to 150k lines!

gmax April 23, 2024 11:57

Perfect, thank you so much!, I hadn't thought of that.


I think it worked correctly, I generated a 190k file but having some keywords I hope to get by. It's the only way I could think of to understand what and how it is called within the code, maybe you could recommend some other method?


However I only used the first line to fill in the one where the buoyantFoam.o object was created

olesen April 26, 2024 11:53

Quote:

Originally Posted by gmax (Post 868150)
Perfect, thank you so much!, I hadn't thought of that.


I think it worked correctly, I generated a 190k file but having some keywords I hope to get by. It's the only way I could think of to understand what and how it is called within the code, maybe you could recommend some other method?


However I only used the first line to fill in the one where the buoyantFoam.o object was created


This benefit of C++ is that you can write code to solve complex problems that you'd mostly not otherwise be able so solve. The downside is that you may not actually understand the code since it becomes so complex. Seems to be normal enough.
For what it's worth, expanding code with the pre-processor will not get you very far. You'd also need to trace and understand which inheritances happen where, and which virtual methods are being called etc. Definitely non-trivial.

gmax April 29, 2024 03:34

Quote:

Originally Posted by olesen (Post 868355)
This benefit of C++ is that you can write code to solve complex problems that you'd mostly not otherwise be able so solve. The downside is that you may not actually understand the code since it becomes so complex. Seems to be normal enough.
For what it's worth, expanding code with the pre-processor will not get you very far. You'd also need to trace and understand which inheritances happen where, and which virtual methods are being called etc. Definitely non-trivial.

thank you very much, yes in the end I didn't get very far with the preprocessing.

The only way I see is to study the code, I'll read it during the night, thank you very much.


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