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

I got this error: " error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘namespace’" In summary, the conversation revolves around a user's attempt to run a tutorial for the computational fluid dynamics software oomph-lib. They initially encounter an error when trying to compile a .cc file and seek help on how to proceed. It is suggested that they check the installation guide and the makefile, and they confirm that they have successfully installed the software. However, when following the tutorial's instructions, they encounter another error and decide to try a manual installation. The conversation ends with the user encountering another error and seeking further guidance.
  • #1
member 428835
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.
 
Technology news on Phys.org
  • #2
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.
 
  • Like
Likes sysprog and member 428835
  • #3
You should try following the "Installation guide" under the "Get it" pull-down.
 
  • Like
Likes sysprog
  • #4
newjerseyrunner said:
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?

phyzguy said:
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 by a moderator:
  • Like
Likes sysprog
  • #5
joshmccraney said:
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?
 
  • Like
Likes member 428835
  • #6
phyzguy said:
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
Did the ./autogen.sh script run without errors? After you ran it, what is in the OOMPH_HOME directory?
 
  • #8
phyzguy said:
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
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.
 
  • Like
Likes sysprog and member 428835
  • #10
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.
 
  • Like
Likes sysprog
  • #11
phyzguy said:
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 by a moderator:
  • #12
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
phyzguy said:
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
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
phyzguy said:
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).

phyzguy said:
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).

phyzguy said:
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
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.
 
  • Like
Likes member 428835
  • #17
phyzguy said:
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:
phyzguy said:
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
So you created a new directory for your own code, right? Print me a listing of what files are in that new directory.
 
  • #19
phyzguy said:
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
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
phyzguy said:
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
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
phyzguy said:
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
phyzguy said:
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
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?
 
  • #26
phyzguy said:
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?
Do you have an email? If so, I can send it to you, as PF isn't letting me upload, and it's too long to paste. I've tried several methods but can't seem to upload it.

The same directory as joe_cool.
 
  • #27
I don't really want to post my E-mail. Can't you upload it to a site like Google drive or github? There are many such sites.
 
  • #28
phyzguy said:
I don't really want to post my E-mail. Can't you upload it to a site like Google drive or github? There are many such sites.
Okay, here it is on github: https://github.com/joshmccraney/oomph-lib-files

PS thanks! Didn't realize this was so easily possible (uploading files for anyone).
 
Last edited by a moderator:
  • #29
joshmccraney said:
Okay, here it is on github: https://github.com/joshmccraney/oomph-lib-files

PS thanks! Didn't realize this was so easily possible (uploading files for anyone).
Sorry, I'm a little stumped. I've never used automake. Apparently the autogen.sh script would generate the correct Makefile from the Makefile.am file. I think you either need to figure out why the autogen.sh script didn't run, or else you might try following the instructions that say, "Writing/linking user code without autotools".
 
  • #30
phyzguy said:
Sorry, I'm a little stumped. I've never used automake. Apparently the autogen.sh script would generate the correct Makefile from the Makefile.am file. I think you either need to figure out why the autogen.sh script didn't run, or else you might try following the instructions that say, "Writing/linking user code without autotools".
I appreciate all of your help! Before I continue, I made a little bit of progress: it occurred to me that I could just edit the demo_driver codes, the example codes. So I uninstalled oomph, then reinstalled it manually. During manual installation, there is a step where I am to go to the home directory and execute
Code:
make check -k
, which, as you commented earlier, generates an executable. Before doing this, I modified the example code, and indeed it performed according to my modifications.

However, when I run the
Code:
make check -k
command, oomph performs this on every example code. I've tried googling what the
Code:
-k
option does, but cannot find anything. Do you know if there is a way I can run this command but have it only effect a particular demo code?
 
  • #31
You can see what the -k option does by just going to the manual. In Linux, the manual for any command is found by typing 'man'. So if you type:

man make

it will tell you the options. What make check does is determined by what's in the Makefile. I suspect it runs all of the various codes, which you don't want to do. So let's say you edited the file called joes_poisson_code.cc. When you type:

make -k

it should make the new executable, which will probably be called joes_poisson_code. You want to run this code and not all of the others. So just type:

./joes_poisson_code

and this should run just that piece of code.
 
  • Like
Likes member 428835
  • #32
phyzguy said:
You can see what the -k option does by just going to the manual. In Linux, the manual for any command is found by typing 'man'. So if you type:

man make

it will tell you the options. What make check does is determined by what's in the Makefile. I suspect it runs all of the various codes, which you don't want to do. So let's say you edited the file called joes_poisson_code.cc. When you type:

make -k

it should make the new executable, which will probably be called joes_poisson_code. You want to run this code and not all of the others. So just type:

./joes_poisson_code

and this should run just that piece of code.
Thanks for this! I appreciate it!

So I still haven't made my new user code, but I'm easily able to change the demo code and re-run it. The trick was to delete the executable, run " make check " in the directory with the .cc file, and then everything runs well.

Thanks so much for your help on this! I'll write if I have more questions, but you've helped so much!

I should add that you are correct: make check runs all the codes in the directory, but since there are only two, and one take about 5 seconds to run, it's not an issue. However, running make gives me errors, so I have to run make check.
 
Last edited by a moderator:
  • #33
joshmccraney said:
Thanks for this! I appreciate it!

So I still haven't made my new user code, but I'm easily able to change the demo code and re-run it. The trick was to delete the executable, run " make check " in the directory with the .cc file, and then everything runs well.

Thanks so much for your help on this! I'll write if I have more questions, but you've helped so much!

I should add that you are correct: make check runs all the codes in the directory, but since there are only two, and one take about 5 seconds to run, it's not an issue. However, running make gives me errors, so I have to run make check.
Glad I could help. Keep at it!
 
  • #34
joshmccraney said:
Thanks for this! I appreciate it!

So I still haven't made my new user code, but I'm easily able to change the demo code and re-run it. The trick was to delete the executable, run " make check " in the directory with the .cc file, and then everything runs well.

Thanks so much for your help on this! I'll write if I have more questions, but you've helped so much!

I should add that you are correct: make check runs all the codes in the directory, but since there are only two, and one take about 5 seconds to run, it's not an issue. However, running make gives me errors, so I have to run make check.
Hello @joshmccraney !
I'm trying to install oomph-lib too but I'm facing the same issue with

fatal error: generic.h: No such file or directory

I attempted to resolve this by providing the -L directory to the generic.h file in the Makefile.am but to no avail.

What do you mean by "deleting the executable"?

By the way, when I tried running make check -k after installation in the top-level directory oomph-lib all tests failed because they could not locate the generic.h file.

I've installed oomph-lib in my system via Docker Ubuntu following this link (I could not install it properly either on Mac OS Monterey and faced the same generic.h error). Thank you so much!
 
  • #35
I'm sorry, this was 3 years ago and I can't recall. I ended up using OpenFOAM for simulations. Best of luck
 

1. What is oomph-lib and how is it related to C++?

Oomph-lib is an open-source C++ library that provides a framework for solving partial differential equations (PDEs) using the finite element method. It is written in C++ and can be used as a standalone library or integrated into other C++ codes.

2. How do I run a C++ code from oomph-lib?

To run a C++ code from oomph-lib, you will first need to download and install the oomph-lib library on your computer. Then, you can use a C++ compiler to compile your code and link it with the oomph-lib libraries. Finally, you can run the executable file generated by the compiler to execute your code.

3. Can I use oomph-lib for CFD simulations?

Yes, oomph-lib is specifically designed for solving PDEs, including those encountered in computational fluid dynamics (CFD). It provides a wide range of finite element formulations and adaptive mesh refinement techniques that are suitable for CFD simulations.

4. Are there any limitations to running a C++ code from oomph-lib?

As with any software, there may be limitations to running a C++ code from oomph-lib. Some potential limitations include the need for a good understanding of C++ programming and the finite element method, as well as the time and computational resources required for running simulations.

5. Are there any resources available for learning how to run a C++ code from oomph-lib?

Yes, there are many resources available for learning how to run a C++ code from oomph-lib. These include online tutorials, user guides, and forums where you can ask questions and get help from experienced users. You can also refer to the oomph-lib documentation for detailed instructions on how to get started with using the library.

Similar threads

  • Programming and Computer Science
Replies
1
Views
986
  • Programming and Computer Science
Replies
21
Views
2K
  • Programming and Computer Science
Replies
2
Views
283
  • Programming and Computer Science
Replies
2
Views
731
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
1
Views
936
  • Programming and Computer Science
Replies
14
Views
1K
  • Programming and Computer Science
Replies
0
Views
487
Back
Top