|
[Sponsors] |
September 28, 2011, 09:53 |
Adding side force to forceCoeffs.C
|
#1 |
Member
Daniel
Join Date: Apr 2010
Location: Manchester
Posts: 30
Rep Power: 16 |
I have edited forceCoeffs.C to include side forces by basically copying the dragDig, dragForce etc entries and adding an additional line with sfDir and sideForce. When I have recompiled forceCoeffs and added a sfDir option to my controlDict it gives no output for lift, drag nor side force.
An example of how I have edited the forceCoeffs.C: Code:
scalar liftForce = totForce & liftDir_; scalar dragForce = totForce & dragDir_; scalar sideForce = totForce & sfDir_; scalar pitchMoment = totMoment & pitchAxis_; scalar Cl = liftForce/(Aref_*pDyn); scalar Cd = dragForce/(Aref_*pDyn); scalar Cy = sideForce/(Aref_*pDyn); scalar Cm = pitchMoment/(Aref_*lRef_*pDyn); Any help is appreciated, Daniel. |
|
September 28, 2011, 11:24 |
|
#2 |
Member
Daniel
Join Date: Apr 2010
Location: Manchester
Posts: 30
Rep Power: 16 |
I made a typo in the .C file which I have corrected and now it works. Sorry about that.
For anyone interested, the new forceCoeffs.C is below and all you have to do is add a sfDir specification in the functions subdict of the controlDict file. Code:
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. \*---------------------------------------------------------------------------*/ #include "forceCoeffs.H" #include "dictionary.H" #include "Time.H" #include "Pstream.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeNameAndDebug(Foam::forceCoeffs, 0); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::forceCoeffs::forceCoeffs ( const word& name, const objectRegistry& obr, const dictionary& dict, const bool loadFromFiles ) : forces(name, obr, dict, loadFromFiles), liftDir_(vector::zero), dragDir_(vector::zero), sfDir_(vector::zero), pitchAxis_(vector::zero), magUInf_(0.0), lRef_(0.0), Aref_(0.0) { read(dict); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::forceCoeffs::~forceCoeffs() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::forceCoeffs::read(const dictionary& dict) { if (active_) { forces::read(dict); // Directions for lift and drag forces, and pitch moment dict.lookup("liftDir") >> liftDir_; dict.lookup("dragDir") >> dragDir_; dict.lookup("sfDir") >> sfDir_; dict.lookup("pitchAxis") >> pitchAxis_; // Free stream velocity magnitude dict.lookup("magUInf") >> magUInf_; // Reference length and area scales dict.lookup("lRef") >> lRef_; dict.lookup("Aref") >> Aref_; } } void Foam::forceCoeffs::writeFileHeader() { if (forcesFilePtr_.valid()) { forcesFilePtr_() << "# Time" << tab << "Cd" << tab << "Cl" << tab << "Cy" << tab << "Cm" << endl; } } void Foam::forceCoeffs::execute() { // Do nothing - only valid on write } void Foam::forceCoeffs::end() { // Do nothing - only valid on write } void Foam::forceCoeffs::write() { if (active_) { // Create the forces file if not already created makeFile(); forcesMoments fm = forces::calcForcesMoment(); scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_; vector totForce = fm.first().first() + fm.first().second(); vector totMoment = fm.second().first() + fm.second().second(); scalar liftForce = totForce & liftDir_; scalar dragForce = totForce & dragDir_; scalar sideForce = totForce & sfDir_; scalar pitchMoment = totMoment & pitchAxis_; scalar Cl = liftForce/(Aref_*pDyn); scalar Cd = dragForce/(Aref_*pDyn); scalar Cy = sideForce/(Aref_*pDyn); scalar Cm = pitchMoment/(Aref_*lRef_*pDyn); if (Pstream::master()) { forcesFilePtr_() << obr_.time().value() << tab << Cd << tab << Cl << tab << Cy << tab << Cm << endl; if (log_) { Info<< "forceCoeffs output:" << nl << " Cd = " << Cd << nl << " Cl = " << Cl << nl << " Cy = " << Cy << nl << " Cm = " << Cm << nl << endl; } } } } // ************************************************************************* // |
|
October 29, 2012, 03:12 |
|
#3 |
Member
Join Date: Apr 2012
Location: France
Posts: 72
Rep Power: 14 |
Hi all,
I'm interested by the new forceCoeffs.C file. I try to test it but it don't works. I updated the forceCoeffs.C, then I added sfDir line in the forceCoeffs file. Finally, I recompile OpenFOAM. What is wrong with the method? Thanks for your explanation |
|
October 30, 2012, 04:21 |
|
#4 |
Member
Join Date: Apr 2012
Location: France
Posts: 72
Rep Power: 14 |
No suggestion ?
|
|
November 4, 2012, 06:49 |
|
#5 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Rider,
Attached is the adapted code based on drrbradford's modifications. The main difference is only how the modifications were made:
Code:
wmake libso
Best regards, Bruno
__________________
|
|
November 5, 2012, 04:48 |
|
#6 |
Member
Join Date: Apr 2012
Location: France
Posts: 72
Rep Power: 14 |
Thank you for this work and your time.
When I used "wmake" or "sudo bash ./Allmake" in the directory "functionObjects", I had this error message "wmake : command not found" What is the problem ? Thanks all. |
|
November 5, 2012, 04:54 |
|
#7 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Rider,
Unpack the package in a user folder of yours, not in OpenFOAM's source code folder! And use: Code:
wmake libso To get a better understanding of what I'm talking/writing about, perhaps you should study a bit this tutorial: http://openfoamwiki.net/index.php/Ho...ure_to_icoFoam Best regards, Bruno
__________________
|
|
November 5, 2012, 06:19 |
|
#8 |
Member
Join Date: Apr 2012
Location: France
Posts: 72
Rep Power: 14 |
Hi Bruno,
I had misunderstood the structure of the modification ... It works. I will test it now Thanks a lot ! |
|
September 30, 2013, 07:22 |
Error in compiling utility
|
#9 | |
Senior Member
Himanshu Sharma
Join Date: Jul 2012
Posts: 101
Rep Power: 14 |
Quote:
First off all thanks for the utility, But i am not able to build it properly on my system i am following quoted steps you have provided but its giving me some error. given below. Code:
wmakeLnInclude: linking include files to ./lnInclude Making dependency list for source file forceDirCoeffs/forceDirCoeffs.C could not open file writer.H for source file forceDirCoeffs/forceDirCoeffs.C Making dependency list for source file forceDirCoeffs/forceDirCoeffsFunctionObject.C could not open file writer.H for source file forceDirCoeffs/forceDirCoeffsFunctionObject.C SOURCE=forceDirCoeffs/forceDirCoeffs.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam221/src/finiteVolume/lnInclude -I/opt/openfoam221/src/meshTools/lnInclude -I/opt/openfoam221/src/sampling/lnInclude -I/opt/openfoam221/src/transportModels -I/opt/openfoam221/src/turbulenceModels -I/opt/openfoam221/src/turbulenceModels/LES/LESdeltas/lnInclude -I/opt/openfoam221/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam221/src/postProcessing/functionObjects/forces/lnInclude -IlnInclude -I. -I/opt/openfoam221/src/OpenFOAM/lnInclude -I/opt/openfoam221/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/forceDirCoeffs.o In file included from forceDirCoeffs/forceDirCoeffs.H:40:0, from forceDirCoeffs/forceDirCoeffs.C:26: /opt/openfoam221/src/postProcessing/functionObjects/forces/lnInclude/forces.H:115:20: fatal error: writer.H: No such file or directory compilation terminated. make: *** [Make/linux64GccDPOpt/forceDirCoeffs.o] Error 1 Code:
Making dependency list for source file forceDirCoeffs/forceDirCoeffs.C Making dependency list for source file forceDirCoeffs/forceDirCoeffsFunctionObject.C SOURCE=forceDirCoeffs/forceDirCoeffs.C ; icpc -std=c++0x -Dlinux64 -DWM_DP -wd327,654,819,1125,1476,1505,1572 -O2 -no-prec-div -DNoRepository -I/opt/app/OpenFOAM/OpenFOAM-2.2.1/src/finiteVolume/lnInclude -I/opt/app/OpenFOAM/OpenFOAM-2.2.1/src/meshTools/lnInclude -I/opt/app/OpenFOAM/OpenFOAM-2.2.1/src/sampling/lnInclude -I/opt/app/OpenFOAM/OpenFOAM-2.2.1/src/transportModels -I/opt/app/OpenFOAM/OpenFOAM-2.2.1/src/turbulenceModels -I/opt/app/OpenFOAM/OpenFOAM-2.2.1/src/turbulenceModels/LES/LESdeltas/lnInclude -I/opt/app/OpenFOAM/OpenFOAM-2.2.1/src/thermophysicalModels/basic/lnInclude -I/opt/app/OpenFOAM/OpenFOAM-2.2.1/src/postProcessing/functionObjects/forces/lnInclude -IlnInclude -I. -I/opt/app/OpenFOAM/OpenFOAM-2.2.1/src/OpenFOAM/lnInclude -I/opt/app/OpenFOAM/OpenFOAM-2.2.1/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64IccDPOpt/forceDirCoeffs.o forceDirCoeffs/forceDirCoeffs.C(33): error: name followed by "::" must be a class or namespace name defineTypeNameAndDebug(Foam::forceDirCoeffs, 0); ^ forceDirCoeffs/forceDirCoeffs.C(33): error: name followed by "::" must be a class or namespace name defineTypeNameAndDebug(Foam::forceDirCoeffs, 0); ^ forceDirCoeffs/forceDirCoeffs.C(33): error #303: explicit type is missing ("int" assumed) defineTypeNameAndDebug(Foam::forceDirCoeffs, 0); ^ forceDirCoeffs/forceDirCoeffs.C(33): error: expected a ";" defineTypeNameAndDebug(Foam::forceDirCoeffs, 0); ^ forceDirCoeffs/forceDirCoeffs.C(33): error: name followed by "::" must be a class or namespace name defineTypeNameAndDebug(Foam::forceDirCoeffs, 0); ^ forceDirCoeffs/forceDirCoeffs.C(33): error: name followed by "::" must be a class or namespace name defineTypeNameAndDebug(Foam::forceDirCoeffs, 0); ^ forceDirCoeffs/forceDirCoeffs.C(91): error: identifier "forcesFilePtr_" is undefined if (forcesFilePtr_.valid()) ^ forceDirCoeffs/forceDirCoeffs.C(116): error: identifier "makeFile" is undefined makeFile(); ^ forceDirCoeffs/forceDirCoeffs.C(118): error: identifier "forcesMoments" is undefined forcesMoments fm = forces::calcForcesMoment(); ^ forceDirCoeffs/forceDirCoeffs.C(137): error: identifier "forcesFilePtr_" is undefined forcesFilePtr_() ^ compilation aborted for forceDirCoeffs/forceDirCoeffs.C (code 2) make: *** [Make/linux64IccDPOpt/forceDirCoeffs.o] Error 2 Thank you Regards Himanshu Sharma |
||
October 1, 2013, 07:32 |
|
#10 | ||
New Member
ThienMa
Join Date: Sep 2013
Posts: 8
Rep Power: 13 |
Hi himanshu28
I Know this error, in the terminal you go to this folder and type follow me: Quote:
and now you type: Quote:
Thien Last edited by luuhoangthien; October 2, 2013 at 14:54. |
|||
October 2, 2013, 04:46 |
Thanks
|
#11 | |
Senior Member
Himanshu Sharma
Join Date: Jul 2012
Posts: 101
Rep Power: 14 |
Quote:
Regards Himanshu |
||
January 13, 2014, 11:58 |
|
#12 |
Member
Join Date: Apr 2012
Location: France
Posts: 72
Rep Power: 14 |
Hi Bruno,
I try to add the modification to the OF V222, but i don't succeed. I always have this error : "unknown function type force DirCoeffs". When I add the modification like the previous OF version, I don't have error message, but the modification seems to not be affect. Thank you in advance ! |
|
January 13, 2014, 17:33 |
|
#13 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Rider,
I won't have much time to look deeper into this before the weekend. But one question: did you also try in OpenFOAM 2.2.1? Either way, OpenFOAM 2.2 has been evolving on the function objects topic quite a bit, adding new features to them for 2.2.1, 2.2.2 and 2.2.x, so things have continued to change. So it really depends on what was the starting point you've used to make the code modifications. Best regards, Bruno
__________________
|
|
January 14, 2014, 04:46 |
|
#14 |
Member
Join Date: Apr 2012
Location: France
Posts: 72
Rep Power: 14 |
Hi Bruno,
Thanks for your quick reply. Yes, I have tried with the OF V221. The problem is the same. I used your methode with the forceDirCoeff file. Best regards. |
|
January 26, 2014, 13:28 |
|
#15 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Rider,
OK, things did change considerably in OpenFOAM 2.2. It has got binning and all! This time I've gone through the somewhat correct steps in sharing modified code, which is provided here: https://github.com/wyldckat/forceDirCoeffs The instructions are provided there and make sure you replace all references to "21x" to "22x", when following the installation steps. Let me know if you have any problems following the steps or any problems using the modified library. Best regards, Bruno
__________________
|
|
February 6, 2014, 00:09 |
|
#16 |
New Member
Join Date: Jul 2010
Posts: 4
Rep Power: 16 |
Good day Bruno,
I have followed your most recent directions in the github site. I am running simpleFoam and it seems that the program is not picking up my forceDirCoeffs directory I have compiled. In my controlDict file I have placed #include "forceDirCoeffs" into the functions. Below is found in my simpleFoam.log file. I think there must be a problem with the functionObject.C file in the OpenFOAM222 directory but do not know how to resolve it. Any help here would be much appreciated. Thanks, Geoff [6] --> FOAM FATAL ERROR: |
|
February 6, 2014, 17:57 |
|
#17 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings Geoff,
Quote:
The idea is that you should add the following line to the "controlDict" file: Code:
libs (libforceDirCoeffs.so); If you have this: Code:
libs ( libforces.so ); Code:
libs ( libforces.so libforceDirCoeffs.so ); Bruno
__________________
|
||
February 8, 2014, 17:45 |
|
#18 |
New Member
Join Date: Jul 2010
Posts: 4
Rep Power: 16 |
Thanks again for the help. I am running OpenFOAM 2.2.2. I did have to do one additional thing to the files I cloned from your github. Before the wmake command, I had to add lforces to the Make/options file, as seen below.
EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/turbulenceModels \ -I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/postProcessing/functionObjects/forces/lnInclude LIB_LIBS = \ -lincompressibleTransportModels \ -lincompressibleRASModels \ -lincompressibleLESModels \ -lfluidThermophysicalModels \ -lspecie \ -lcompressibleRASModels \ -lcompressibleLESModels \ -lfiniteVolume \ -lmeshTools \ -lforces \ -lfileFormats Works great now, I actually added a few terms, to give coefficients in all three directions in global coordinates as well as all three directions of local coordinates to the body being analysed. |
|
February 16, 2014, 13:43 |
|
#19 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Geoff,
I've updated the repository, regarding the README file and the linking to "libforces" as you indicated. Do feel free to clone the repository and publish your modifications to it! Best regards, Bruno
__________________
|
|
March 27, 2014, 10:13 |
|
#20 |
New Member
Join Date: Jul 2010
Posts: 4
Rep Power: 16 |
Let me finish my masters project first, then I will be more than happy to tidy up and post the updates. Just three more weeks!
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Force can not converge | colopolo | CFX | 13 | October 4, 2011 23:03 |
How to measure side force and yawing moment | firda | FLUENT | 0 | November 3, 2010 03:33 |
[blockMesh] BlockMeshmergePatchPairs | hjasak | OpenFOAM Meshing & Mesh Conversion | 11 | August 15, 2008 08:36 |
CFX Solver Memory Error | mike | CFX | 1 | March 19, 2008 08:22 |
[Commercial meshers] Converting meshes that includes interfaces | ham | OpenFOAM Meshing & Mesh Conversion | 29 | January 8, 2007 09:58 |