Running a C++ code from oomph-lib (a CFD software)

  • C/++/#
  • Thread starter joshmccraney
  • Start date
  • #1
1,799
75

Main Question or Discussion Point

Hi PF!

I recently installed the computational fluid dynamics software oomph-lib, which is similar to OpenFOAM. After installing, I'm trying to run a tutorial provided with the program, described here. I think all I need to do it run the .cc file here, so I type into the terminal

>> gcc elastic_two_layer_interface.cc

and I receive the output "No such file or directory #include "generic.h"". Can you tell if this is all I need to execute, or is there something more I should be doing? Any help is greatly appreciated.
 

Answers and Replies

  • #2
1,512
616
No, that's not how you compile that. Most programs that come like that have what's called a "makefile" which generates the commandline that you need. The reason that you are getting include errors is because your build path is not set up, that is something you put in the commanline. You will also almost certainly get Linker errors too since you can include library headers all you want but that's not the same as actually linking the library itself. dig through the makefile and try to figure out what it's doing.
 
  • #3
phyzguy
Science Advisor
4,354
1,334
You should try following the "Installation guide" under the "Get it" pull-down.
 
  • #4
1,799
75
No, that's not how you compile that. Most programs that come like that have what's called a "makefile" which generates the commandline that you need. The reason that you are getting include errors is because your build path is not set up, that is something you put in the commanline. You will also almost certainly get Linker errors too since you can include library headers all you want but that's not the same as actually linking the library itself. dig through the makefile and try to figure out what it's doing.
You're right! The directory layout is

OOMPH/oomph-lib-1.0.1306 >> demo_drivers >> navier_stokes >> two_layer_interface

where the first directory OOMPH/oomph-lib-1.0.1306 contains a script titled " configure ". I ran this via

>>./configure

and it added the script Makefile in the final directory two_layer_interface (this directory previously did not have this script). So now I have all the scripts shown here, though my Makefile is different than theirs (I'm a noob, so can't see what the differences imply).

What should I do now?

You should try following the "Installation guide" under the "Get it" pull-down.
I did this, which is how I installed the program. I read the page, but I don't see how it helps me run one of the demo codes provided with the software.
 
Last edited:
  • #5
phyzguy
Science Advisor
4,354
1,334
I did this, which is how I installed the program. I read the page, but I don't see how it helps me run one of the demo codes provided with the software.
Did you install it with the "./autogen.sh" script, or did you do a manual install?
 
  • #6
1,799
75
Did you install it with the "./autogen.sh" script, or did you do a manual install?
I installed via "./autogen.sh".

I edited post 4, which likely changes your recommendation for next steps.
 
  • #7
phyzguy
Science Advisor
4,354
1,334
Did the ./autogen.sh script run without errors? After you ran it, what is in the OOMPH_HOME directory?
 
  • #8
1,799
75
Did the ./autogen.sh script run without errors? After you ran it, what is in the OOMPH_HOME directory?
Yes, it ran without errors. It contains:
aclocal.m4 compile config.log demo_drivers install-sh missing src
AUTHORS config config.status depcomp libtool NEWS stamp-h1
autogen.sh config.guess config.sub doc ltmain.sh non_interactive_autogen.sh user_drivers
autom4te.cache config.h configure external_distributions Makefile oomph-lib-config.h user_src
bin config.h.in configure.ac external_src Makefile.am README validate.sh
ChangeLog config.h.in~ COPYING INSTALL Makefile.in self_test
 
  • #9
phyzguy
Science Advisor
4,354
1,334
According to the installation instructions, it should create a 'build' directory, which I don't see in your list. Maybe it didn't really run. I would suggest you try following the step-by-step "Manual instalation" instructions. Then you can see if anything goes wrong along the way. After that, you can see ifit runs by folliwng their instruction, "Check if we can make and run the user codes". Also, you should try reading the README and INSTALL files.
 
  • #10
phyzguy
Science Advisor
4,354
1,334
I tried downloading it and running the ./autogen.sh, and there were significant errors. Try running

grep error config.log

This will list the errors that occurred during the autogen. Is it really free of errors? Mine wasn't.
 
  • #11
1,799
75
According to the installation instructions, it should create a 'build' directory, which I don't see in your list. Maybe it didn't really run. I would suggest you try following the step-by-step "Manual instalation" instructions. Then you can see if anything goes wrong along the way. After that, you can see ifit runs by folliwng their instruction, "Check if we can make and run the user codes". Also, you should try reading the README and INSTALL files.
I did the manual approach and it seems everything is going well. No errors, and the cases seem to be running fine. Still waiting on the final command, but no errors (I think it's validating all demo codes), so I'll like your previous comment in case anyone in the future follows this thread.

Assuming everything is running (which I believe it is, but again, waiting for the validation), to run my own problem I would follow steps here. But notice step 3 says to rerun "./autogen.sh"; should I do this? Would it even work considering it failed in the initial setup?
 
Last edited:
  • #12
phyzguy
Science Advisor
4,354
1,334
It looks like all the autogen.sh is doing in this case is creating a new Makefile. You should be able to copy the Makefile from the directory with the test cases, edit it to point at your new problem, and then run make. At least, this is what I think.
 
  • #13
1,799
75
It looks like all the autogen.sh is doing in this case is creating a new Makefile. You should be able to copy the Makefile from the directory with the test cases, edit it to point at your new problem, and then run make. At least, this is what I think.
Before attempting to try and make my own (because I have failed) I'm going to just run a demo code (crawl before you walk sort of idea). Following the manual installation, second to last box requires executing " make ", which I do, and without errors, I then execute " ./joes_poisson_code" again, without errors. After these two commands .dat files are generated, along with a few others. After everything is generated, if I execute " make " again, I receive an error, but if I delete all the directories/files created from these two commands, I can re-execute both commands error free. For this case there were only 4 initial files: Makefile, Makefile.am, Makefile.in, and joes_poisson_code.cc.

With this in mind I went into the demo codes and found one I wanted to run, but of course it failed on the " make " command (since the manual installation ran everything). So now I'm trying to decide what to delete to allow the " make " command to run without errors, so I delete all files/directories so that my file contains only those listed here. Then when I execute " make " I receive the error

make: Nothing to be done for 'all'.

I'm so lost. Do you have any ideas?
 
  • #14
phyzguy
Science Advisor
4,354
1,334
I'm surprised it gives you an error if you re-run "make". What is the error? Did you try running "make clean" before re-running "make"? This might help. I think what you want to do next is to follow the instructions under, "How to write your own code and link it against oomph-lib's library/libraries". This involves creating a new directory and copying over the joes_poisson_code.cc file, which is the source code, and then editing it to do what you want. Do you understand what you are doing here? The joes_poisson_code.cc file contains the source code you are going to run, and which you can edit. Try editing this and putting in a printf statement, for example, that says printf("Here I go - running the code!"). When you run "make", it generates the joes_poisson_code executable, which is binary code that you can't read, but is what the computer runs. You run it by typing ./joes_poisson_code. Maybe you know all of this.
 
  • #15
1,799
75
I'm surprised it gives you an error if you re-run "make". What is the error? Did you try running "make clean" before re-running "make"? This might help.
The error was " make: Nothing to be done for 'all'. " I don't have access to that machine until Monday (though I may be able to get to it in about 10 hours, so I'll try doing this before leaving town).

I think what you want to do next is to follow the instructions under, "How to write your own code and link it against oomph-lib's library/libraries". This involves creating a new directory and copying over the joes_poisson_code.cc file, which is the source code, and then editing it to do what you want. Do you understand what you are doing here?
I tried this also but did not post it. In that case, I get a different error, though I'll have to see what it is again. I'll write (hopefully tomorrow) and state the error. All I recall is this particular error was not the same. But, the command " make " did not work in this approach either. I do think I understand what is happening (at least I followed all the steps you cite and read the documentation).

The joes_poisson_code.cc file contains the source code you are going to run, and which you can edit. Try editing this and putting in a printf statement, for example, that says printf("Here I go - running the code!"). When you run "make", it generates the joes_poisson_code executable, which is binary code that you can't read, but is what the computer runs. You run it by typing ./joes_poisson_code. Maybe you know all of this.
Does it matter where I output the print statement (probably not)? I noticed the " make " command generated an executable code, but only through the first execution (not from creating a new directory and copying over the joes_poisson_code.cc file).
 
  • #16
phyzguy
Science Advisor
4,354
1,334
The "Nothing to be done" message is not an error. It is just telling you that the executable has already been built and there is no need to build it again. You only need to re-run "make" when you change something in the source code.
 
  • #17
1,799
75
The "Nothing to be done" message is not an error. It is just telling you that the executable has already been built and there is no need to build it again. You only need to re-run "make" when you change something in the source code.
Sweet, so it looks like I can run the example codes: you're right about the make command! Thanks so much.

Regarding our previous post about making my own code, after copying the driver codes joes_poisson_code.cc and the three Makefile{.am .in} and Makefile scripts I follow your advice:
I'm surprised it gives you an error if you re-run "make". What is the error? Did you try running "make clean" before re-running "make"?
The error I receive is
Makefile:324: .deps/joes_poisson_code.Po: No such file or directory
make: *** No rule to make target '.deps/joes_poisson_code.Po'. Stop.

And looking at Makefile:324 reads: include ./$(DEPDIR)/joes_poisson_code.Po

Any idea how to proceed? Do I need to completely redo the manual installation here since they wanted me to run autogen.sh?
 
  • #18
phyzguy
Science Advisor
4,354
1,334
So you created a new directory for your own code, right? Print me a listing of what files are in that new directory.
 
  • #19
1,799
75
So you created a new directory for your own code, right? Print me a listing of what files are in that new directory.
Yes, I created a new directory "josephine_cool". The four files I copied within are
joes_poisson_code.cc Makefile Makefile.am Makefile.in
 
  • #20
phyzguy
Science Advisor
4,354
1,334
Since you can't run the autogen.sh (for whatever reason), you need to make sure the Makefile is pointing at the right files. Try looking at the Makefile files in the joe_cool directory and editing the Makefile in your new directory so it points at the right files.
 
  • #21
1,799
75
Since you can't run the autogen.sh (for whatever reason), you need to make sure the Makefile is pointing at the right files. Try looking at the Makefile files in the joe_cool directory and editing the Makefile in your new directory so it points at the right files.
Okay, so I copied everything that once read "joe_cool" to now "josephine_cool" and when I run make and make clean I receive the error:
Makefile:324: .deps/joes_poisson_code.Po: No such file or directory
make: *** No rule to make target '.deps/joes_poisson_code.Po'. Stop.

what is the .Po extension? I've no clue. But, when I do the same thing in the joe_cool folder it runs fine.
 
  • #22
phyzguy
Science Advisor
4,354
1,334
I don't know either. How does it run in the joe_cool directory? In the joe_cool directory, where is the *.Po file and how does it find it?
 
  • #23
1,799
75
I don't know either. How does it run in the joe_cool directory? In the joe_cool directory, where is the *.Po file and how does it find it?
I noticed in one of the Makefile scripts something about configuration, so I reconfigured everything via the manual installation instructions. Then I had an error on line 327 (progress). So I went back to the top of the directory and ran make. It's taking it's sweet time, so we'll see what happens here. I'll keep you posted either way.
 
  • #24
1,799
75
I don't know either. How does it run in the joe_cool directory? In the joe_cool directory, where is the *.Po file and how does it find it?
Okay, so I'm not sure where the .Po file is, but that seems not to be the issue now. after recompiling and running make the terminal outputs:

g++ -DHAVE_CONFIG_H -I. -I../.. -DOOMPH_HAS_STACKTRACE -DOOMPH_HAS_UNISTDH -DOOMPH_HAS_FPUCONTROLH -DOOMPH_HAS_MALLOCH -DOOMPH_HAS_TRIANGLE_LIB -DOOMPH_HAS_TETGEN_LIB -DUSING_OOMPH_SUPERLU -DUSING_OOMPH_SUPERLU_DIST -I/build/include -DgFortran -g -O2 -MT joes_poisson_code.o -MD -MP -MF .deps/joes_poisson_code.Tpo -c -o joes_poisson_code.o joes_poisson_code.cc
joes_poisson_code.cc:34:10: fatal error: generic.h: No such file or directory
#include "generic.h"
^~~~~~~~~~~
compilation terminated.
Makefile:327: recipe for target 'joes_poisson_code.o' failed
make: *** [joes_poisson_code.o] Error 1

so it seems the code is trying to make joes_poisson_code.o but is unable to. Any ideas?
 
  • #25
phyzguy
Science Advisor
4,354
1,334
It's not finding the file generic.h. There's probably a link in the Makefile that needs to be edited. How long is the Makefile. Can you pasted it in here? Or if it's too long, can you post it somewhere?

Also, where did you create the josephine_cool directory? Is it in the same directory as joe_cool?
 

Related Threads for: Running a C++ code from oomph-lib (a CFD software)

Replies
1
Views
188
  • Last Post
Replies
4
Views
1K
  • Last Post
Replies
0
Views
2K
  • Last Post
Replies
4
Views
2K
Replies
6
Views
2K
Replies
12
Views
1K
Replies
2
Views
1K
Replies
2
Views
545
Top