Help compiling code (newbie)
Hi everyone,
Im currently doing my dissertation at University of Bath, UK on cyclocopter rotors and found the following blog post: http://lordvon64.blogspot.co.uk/2014...87540156025031 The model he has made closely follows the experimental data from other cyclocopters and I would love to be able to run/edit his code, listed on github here: https://github.com/lordvon/OpenFOAM_...ster/cycloRamp Now, bear with me at this point, I am totally new to OpenFOAM, and I dont know how to run this code. I have installed OpenFOAM correctly (done a few of the tutorials to confirm) and downloaded the repository from Github. What is the next step? In the files on Github he has the 'compiling new OpenFOAM source' file, which lists how to compile. All the steps until the last line seem to have been done in the downloaded repository, if I am correct? The files in /Make have been made. The last line details adding the line to controlDict, does this mean I go into controlDict in the system files and add the line? then run the file remake? If anyone could give me an idiots guide to doing this I would be very much appreciated, starting from the begining. The author of the blog is helpful but being in different time zones the reply's are quite delayed. Thanks, Tom |
Hi Tom,
It looks like you're pretty close. If you have already compiled that library you should be pretty close. The last step is to add a line to the controlDict of whatever case you're running this on but there is a typo in his instructions. There should be a semicolon closing the parentheses ; like this: libs ( "libCycloRamp.so" ); Do you already have an example case that will engage the functionality of this new library? Cheer! Kyle Quote:
|
Ah OK, I think I get hwo it works now.
I was thinking of the code uplaoded to Github as the code to run on its own. But its actually just the library which other code uses to run. So I need to find out the example that will use this library, then add the line you said to the controlDict file of that example, then run that example as normal? It doesnt mention anythign about that in his blog post does it? The only sentance that soudns like it points to the right example is 'I used the pimpleDyMFoam solver in PISO mode (no SIMPLE iterations)'. Does that mean anything? Thanks for your help Tom |
Without an example case you're going to have to effectively reverse engineer the case configuration. Also, it looks like the mesh he's using its awfully complicated in terms of multiple embedded rotational sliding boundary interfaces.
After having a quick look at his code its going to be really difficult to put a case together from scratch, even with a ton of OpenFOAM experience. I think your best bet is to get in touch with the original developer and ask for an example case. Cheers, Kyle |
Hi Kyle,
Thanks for the info. Ive contacted the author and he is going to post a case file to this thread, which should help me get the simulation up and running. Thanks for the help, im sure I may have a couple more questions lol, using OpenFOAM is on a whole different level to what im used to Tom |
1 Attachment(s)
You will not have to reverse-engineer anything!!! I am the author of the post mentioned above. Here I have attached the case and mesh files for the cyclorotor simulation. Here is how I use it:
-I view the mesh by 'gmsh main.geo' inside the mesh folder. I change whatever I need in mesh/inputs.geo. -run './parallel runname' in the main directory (where case and mesh reside) -That's it! That is after of course you have compiled the custom solidBodyMotionFunctions that were referenced above, and installed gmsh. Also, you might have to chmod +x a few files to make them executable. Please let me know of any questions! |
I think my problem is with compiling the solver at the moment. when I run the make command I get the following :
wmakeLnInclude: linking include files to ./lnInclude Making dependency list for source file cycloRamp.C SOURCE=cycloRamp.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam230/src/dynamicFvMesh/lnInclude -I/opt/openfoam230/src/dynamicFvMesh/solidBodyMotionFvMesh/lnInclude -IlnInclude -I. -I/opt/openfoam230/src/OpenFOAM/lnInclude -I/opt/openfoam230/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/cycloRamp.o In file included from cycloRamp.H:38:0, from cycloRamp.C:26: /opt/openfoam230/src/dynamicFvMesh/lnInclude/solidBodyMotionFunction.H: In static member function ‘static Foam::autoPtr<Foam::solidBodyMotionFunction> Foam::solidBodyMotionFunction::adddictionaryConstr uctorToTable<solidBodyMotionFunctionType>::New(con st Foam::dictionary&, const Foam::Time&) [with solidBodyMotionFunctionType = Foam::solidBodyMotionFunctions::cycloRamp]’: /opt/openfoam230/src/dynamicFvMesh/lnInclude/solidBodyMotionFunction.H:90:9: instantiated from ‘Foam::solidBodyMotionFunction::adddictionaryConst ructorToTable<solidBodyMotionFunctionType>::adddic tionaryConstructorToTable(const Foam::word&) [with solidBodyMotionFunctionType = Foam::solidBodyMotionFunctions::cycloRamp]’ cycloRamp.C:46:1: instantiated from here /opt/openfoam230/src/dynamicFvMesh/lnInclude/solidBodyMotionFunction.H:90:9: error: cannot allocate an object of abstract type ‘Foam::solidBodyMotionFunctions::cycloRamp’ cycloRamp.H:53:7: note: because the following virtual functions are pure within ‘Foam::solidBodyMotionFunctions::cycloRamp’: /opt/openfoam230/src/dynamicFvMesh/lnInclude/solidBodyMotionFunction.H:110:50: note: virtual Foam::autoPtr<Foam::solidBodyMotionFunction> Foam::solidBodyMotionFunction::clone() const /opt/openfoam230/src/dynamicFvMesh/lnInclude/solidBodyMotionFunction.H:90:9: warning: control reaches end of non-void function [-Wreturn-type] make: *** [Make/linux64GccDPOpt/cycloRamp.o] Error 1 It looks like its throwing up a few errors, do you have any idea what it means? |
Hi Thomas,
I made sure it worked before I uploaded it to Github, though the instructions could be better, which I have updated based on feedback from this thread. Please delete the cycloRamp library files and redownload them and try again. This time, only doing these few things: -type 'sudo' and then login -Go inside the main directory of the downloaded files (where Make, cycloRamp.C,cycloRamp.h,etc. reside) -Make the freshly downloaded file executable by 'chmod +x remake' -Run './remake' If you do not get errors, great! Compiling always seems to be the biggest obstacle in running custom OpenFOAM stuff. You then can run a simulation with './parallel yourRunName' in the main directory of the case files I uploaded to this thread. Even if you get errors then, they will be very easy to debug. Since you and I have spent a bit of time on this, I am determined to get it working for you :) Which version of OpenFOAM are you using? |
Iv followed the instructions but still get a couple of error messages,a lthough it is far fewer than before.
I get: linux64GccDPOpt/options:7: *** commands commence before first target. Stop. wmake error: file 'Make/linux64GccDPOpt/objectFiles' could not be created in /home/tom/OpenFOAM/tom-2.3.0/applications/solvers/cycloRamp cp: cannot stat `/home/tom/OpenFOAM/root-2.3.0/platforms/linux64GccDPOpt/lib/libCycloRamp.so': No such file or directory In your 'compiling new OpenFOAM source' file you have the text to put in the options file as different to the file you uploaded. Ive tried both and get the same error though. It feels like its so close. Im using OpenFOAM 2.3.0 :) |
Oops, I guess they are different but they both should work. After a little Google searching, it might be the format of the text in the Make/options file. I updated the file on Github, and all I did was remove the tabs. Try and see if anything is different.
I wish I could test it, but it works as is on my computer unfortunately. |
Im getting further and further each time I go through. At the moment its making the /Make/linux64GccDPOpt files and a /lnInclude folder with links to the .C and .H files.
However there is still an error: cycloRamp.C:46:1: instantiated from here /opt/openfoam230/src/dynamicFvMesh/lnInclude/solidBodyMotionFunction.H:90:9: error: cannot allocate an object of abstract type ‘Foam::solidBodyMotionFunctions::cycloRamp’ cycloRamp.H:53:7: note: because the following virtual functions are pure within ‘Foam::solidBodyMotionFunctions::cycloRamp’: /opt/openfoam230/src/dynamicFvMesh/lnInclude/solidBodyMotionFunction.H:110:50: note: virtual Foam::autoPtr<Foam::solidBodyMotionFunction> Foam::solidBodyMotionFunction::clone() const /opt/openfoam230/src/dynamicFvMesh/lnInclude/solidBodyMotionFunction.H:90:9: warning: control reaches end of non-void function [-Wreturn-type] make: *** [Make/linux64GccDPOpt/cycloRamp.o] Error 1 cp: cannot stat `/home/tom/OpenFOAM/root-2.3.0/platforms/linux64GccDPOpt/lib/libCycloRamp.so': No such file or directory Looks like its on line 46 of cycloRamp.C, running this bit of code: namespace Foam { namespace solidBodyMotionFunctions { defineTypeNameAndDebug(cycloRamp, 0); addToRunTimeSelectionTable ( solidBodyMotionFunction, cycloRamp, dictionary ); } } Any ideas? Tom |
Could be the version. Ill try out 230, as I used 222. Or, you could try out 222. I will try to let you know tomorrow.
|
Hi,
Success on the compiling front, I installed 222 and it compiled perfectly. Now just got to figure out how to run the other code. When the code runs I get a warning that it could not load libCycloBucket.so. Is there another library called this? The github code only has cycloRamp.so. I also get one for libRampedAxisRotationMotion.so, this is on Github so I will compile it and that error should go away Tom |
1 Attachment(s)
Great!
libCycloBucket and libRampedAxisRotationMotion were other custom codes of mine I made for different pitching schedule and ramping up the rotor speed for (supposedly) faster transient simulation, respectively. They are utilized in 'system/controlDict' and 'constant/dynamicMeshDict'. In dynamicMeshDict you specify rotation speed and for my custom code the cyclorotor parameters. It is an error on my part that those case files use cycloBucket instead of cycloRamp in the dynamicMeshDict. So, I have attached the case files that work the same way as the earlier one, except that it has the correct dynamicMeshDict (no need to recompile, etc.). But you should compile rampedAxisRotationMotion if its no problem, otherwise you will need to change the dynamicMeshDict to not use it, and instead use the standard OpenFOAM mesh rotation function, which does a hard start. The mesh in the new attached case files is different. If you prefer the old mesh, simply copy over your old 'mesh' to replace the one in the new attachment. (I also changed the cyclorotor.zip posted earlier to avoid confusion) Just as a side note, in libCycloRamp the pitching motion is sinusoidal with respect to azimuthal position (of the blade w.r.t. rotor center). In libCycloBucket the pitching schedule looks more like a clipped sine wave. So if you are interested in implementing this or other more interesting pitching schedules as a function of azimuthal position, let me know and I can upload it. Pretty much any arbitrary sufficiently-smooth pitching schedule is possible with the method described in "Design, Development, and Flight Test of a Small-Scale Cyclogyro UAV Utilizing a Novel Cam-Based Passive Blade Pitching Mechanism" by Zachary Adams, et al. I do not know where to get the PDF for free for everyone, but since you are a University undergrad you should be able to access it for free somehow. |
Excellent, closer than ever.
I make it through the set up; till the run case question its all fine with no errors. However when I run the case I get the followign error: Selecting dynamicFvMesh multiSolidBodyMotionFvMesh Selecting solid-body motion function rampedAxisRotationMotion [0] [0] [0] --> FOAM FATAL IO ERROR: [0] keyword CofG is undefined in dictionary "/home/tom/OpenFOAM/OpenFOAM-2.2.2/cyclorotor/runname/processor0/../constant/dynamicMeshDict.multiSolidBodyMotionFvMeshCoeffs.r otorVolume.rampedAxisRotationMotionCoeffs" [0] [0] file: /home/tom/OpenFOAM/OpenFOAM-2.2.2/cyclorotor/runname/processor0/../constant/dynamicMeshDict.multiSolidBodyMotionFvMeshCoeffs.r otorVolume.rampedAxisRotationMotionCoeffs from line 26 to line 26. [0] [0] From function dictionary::lookupEntry(const word&, bool, bool) const [0] in file db/dictionary/dictionary.C at line 402. [0] FOAM parallel run exiting [0] rampedAxisRotationMotion compiled correctly with no errors but it looks like this is an error in that library Tom |
Alright I think we are out of the woods. These are just typos (i had different versions of rampedAxisRotationMotion). I uploaded the corrected cases once again to the links above. The only thing that is different is 'constant/dynamicMeshDict'.
|
Almost there,
I get the error when I run the case: [0] file: /home/tom/Desktop/cyclorotor/2/processor0/0/p at line 0. [0] [0] From function regIOobject::readStream() [0] in file db/regIOobject/regIOobjectRead.C at line 73. [0] FOAM parallel run exiting [0] There is the folder '0' in the /runname folder, with the p file in, but not within the individual processor folders. It says this for all 4 processors (0, 1, 2, 3) The newly updated zip files also have 1 error in the mesh but I copied over the old mesh and its working perfectly so no worries there. Thanks for all the help. I really appreciate it Tom |
I think an error is occurring earlier. Please put all output into a text file and upload it.
|
When I run ./parallel I get the following:
Code:
root@tom-770Z5E-780Z5E:~/Desktop/cyclorotor# ./parallel 1 |
and after I run case:
Code:
/*---------------------------------------------------------------------------*\ |
Ah, i realised fixBoundary is in the /case folder, going to chmod all the files in that folder and see if that fixes it
|
After applying executable permissions to all files im pretty sure it all runs fine until the run case part.
After I run the case this is the terminal: Code:
/*---------------------------------------------------------------------------*\ |
And:
Code:
[2] in "/home/tom/OpenFOAM/OpenFOAM-2.2.2/platforms/linux64GccDPOpt/bin/pimpleDyMFoam" |
Well, if you get errors in setting it up, there is no use running it.
Are you also new to Linux? If not, the errors should be pretty clear. You need to run 'chmod +x fixBoundary'. 'setup' is a script that uses other scripts. Those other scripts should be executable. |
Show all outputs when you run './setup casename'
|
I just downloaded my cylclorotor.zip file, 'chmod +x setup parallel case/enclosed case/fixBoundary case/bashMultiply', './parallel test', answered 'y' to run the simulation and it worked. So I am not sure what errors you are getting.
Are you sure the two custom libraries, rampedAxisRotationMotion and cycloRamp compiled successfully? You mentioned you are using the old mesh... try the new mesh. I got some warnings running the new mesh, but no errors. It will still work fine. |
I figured that out right after posting haha. Ive done exactly what youve said and im getting a error:
mpirun noticed that process rank 2 with PID 8280 on node tom-770Z5E-780Z5E exited on signal 8 (Floating point exception). Would I be right in thinking this means somewhere in the code there is a divide by zero or some other mathematical error? |
Is there any way you could paste your terminal output when you run ./parallel. And I can compare the correct output to mine.
It may help me figure out the exact point it goes wrong |
1 Attachment(s)
You should post your output from running './parallel test', where 'test' is the name of the new folder that is created that contains the files pertinent to your simulation. Please do not forget to specify it.
I don't know how it would help, but attached is my output to running './parallel test' (I quit the simulation with CTRL+C at the end, it did not abort by error). Note that in the beginning Gmsh complains of error, but its just GUI stuff. The mesh is still made. |
1 Attachment(s)
Hi,
Ive compared logs and before running the case it seems like the mesh is slightly different. Im not sure why as I havn't done anything to it. If you look at the section 'Checking patch topology for multiply connected surfaces...' the points are slightly different in number, not much, but slightly off. After running the case the transformation of the cycloRamp functions: (solidBodyMotionFunctions::cycloRamp::transformati on(): Time = 0.2 transformation: ((-0.164971 0.212763 0) (0.280207 (0 0 0.95994)))) are all fine and the same, but the rampedAxisRotationMotion transformation above is different: Mine: solidBodyMotionFunctions::rampedAxisRotationMotion ::transformation(): Time = 0.2 transformation: ((0 0 0) (0.999864 (0 0 0.0164673))) Yours: solidBodyMotionFunctions::rampedAxisRotationMotion ::transformation(): Time = 0.2 transformation: ((0 0 0) (0.586916 (0 0 0.809648))) Could be where the number is so close to zero that it starts throwing up errors. All I can think of is that the rampedAxisRotationMotion you have on github is a slightly older version of the one you are running. Could that be the case? If so, I think this could be the final piece in the puzzle Tom |
Can you go into your newly named folder and run 'moveDynamicMesh'?
This will move the mesh, but will not solve for anything. Thus, you can see if there is a mismatch of the predicted motions of the blade volumes and the main rotor volume. You can view the locations of the meshes at the latest timestep with 'paraFoam' |
Hmmm, I checked the github source and the units on the two custom codes seem to be consistent. But we'll see your result.
|
Actually they are not consistent. I think you solved it. I made a change to the github files for rampedAxisRotationMotion.C. All I did was delete the degToRad() conversions.
Please redownload and recompile rampedAxisRotationMotion. I bet it will work this time. |
1 Attachment(s)
I get the error:
--> FOAM FATAL ERROR: Unable to find initial target face From function void Foam::AMIInterpolation<SourcePatch, TargetPatch>::calcAddressing(const SourcePatch&, const TargetPatch&, label, label) in file lnInclude/AMIInterpolation.C at line 725. FOAM aborting Full log in attached |
Can you please look at my last posts? You brought attention to an inconsistency in rampedAxisRotationMotion that I fixed.
|
HUZZAH!!!!! Its currently solving, i make that a productive evening. Ill let you know if I run into any problems, but at the moment its all flowing nicely. Once the code finishes is it just a case of typing 'paraFoam' to do the post processing stuff?
Thank you so much for all this, its very much appreciated |
Out of interest, how long does the code take to run on your PC?
|
Awesome!
Yes, once you want to view the results, 'paraFoam' will bring up a GUI, in which you can view the p and U fields, surface distributions, etc. It is pretty straightforward to use and there are a lot of good tutorials out there. Keep in my mind you need to specify the frequency of writing out the results to be viewed. This is controlled in controlDict. The simulation does not take long at all; should be about a few hours. BUT, the run time is highly variable according to the size of the mesh and the maximum Courant number. I think a high Courant number is set in the case files (30?), and the Courant number used in my validation runs was 2 (more accurate, smaller time step, higher overall run time). So in the beginning of the simulation, you may want to use the high Courant number, and when the force results settle, you can change it to a lower Courant number. You can simply change this in controlDict while the case is still running. On my computer (i7-2700 processor) it ran in a few hours, I think. I ran these back in November last year, so I don't remember exactly, but I know it never took more than a day. Oh, and since this simulation is run in parallel, you should run 'reconstructPar -latestTime' before you view the latest time step in paraFoam. Also, inside the 'parallel' script you should see that I specified it to run on 4 cores. If you want to use a different number, you should change this. To view forces, 'chmod +x f' and run the file named f. If you changed the mesh or operating parameters, you should change them accordingly in the variables at the top of the 'f' script. |
This is absolutely incredible. Thank so much.
Couple of things, in paraFoam, it only seems to give me two steps, 0 is 0s and 1 is 10s. there doesnt seem to be any inbetween. I can use the 10s mark to be my steady state forces, which is perfect, jsut wondering if I can get inbetween states, for animations etc. Also, If I were to edit the mesh to make it more like my system, from what I can see: Change chord length is /mesh/blades/0_inputs.geo, Change bladeShord Change max and min pitch is maxPitch, minPitch in /rotor rotor radius to smaller is rotorRadius in /rotor blade count down to 4 is bladeCount in /rotor. Then check mesh etc and run again? Then to change the rotational speed where would I go? Or would changing these things in the mesh then mean I would need to change a load of files in the /case directory, like the dynamiMeshDict |
If you look in processor0, processor1, etc. you will see the time steps available that were written (the frequency of writing is in controlDict). If you want all of these timesteps, do 'reconstructPar' and it will reconstruct from the decomposed processor0,etc. parts and thus make it available to paraView (it used to be able to read decomposed timesteps directly, but now it does not for some reason; you have to reconstruct them first).
Any changes you make in the mesh and geometry can be immediately viewed by opening main.geo in Gmsh. All those parameters are easily changeable in the corresponding 0_inputs.geo files. But changing the number of blades requires a little more editing. Since you want less blades, you will have to manually comment out the parts in main.geo that specify bladeVolume4 and bladeVolume5, since they will no longer exist (For every blade there is a corresponding blade volume). In the case files, you will have to edit dynamicMeshDict. In it, you can see that variables for each blade volume is specified. The custom function needs to know the initial location of the blade, its radial distance from the center of the rotor, and the initial and final rotation speeds in order to calculate each blade volume's center of pitching. Comment out bladeVolumes 4 and 5, then change phi_ to 0,90,180,270 for bladeVolumes 0,1,2, and 3, respectively. ALL other variables have to be the same for EVERY blade volume. And: radialVelocityf = OMEGAF, radialVelocity0 = OMEGA0, t0 = T0, tf = TF, CofG = COFR. When you change the radius in the geometry/mesh, you also have to change it here for all blade volumes. Here is also where you change the rotational speeds. Finally, the parameter changes have to be taken into account into the 'f' file. Change the rotation speed accordingly. Note that the power figure will not be correctly computed during the ramp-up phase, as the rotation speed is actually less than what is input during this period. |
All times are GMT -4. The time now is 15:20. |