|
[Sponsors] |
Macro existing for calculating a cell surface? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 10, 2010, 16:50 |
Macro existing for calculating a cell surface?
|
#1 |
New Member
Join Date: Jun 2010
Posts: 14
Rep Power: 16 |
Hi everyone!
I'm a starter at openFOAM and I'd like to calculate the circulation around a 2D vortex (the simulation is done and I already have the coordinates of the point of maximum vorticity (<=> vortex center)). To do so, I need to integrate the surface of cells in order to get a disc surrounding the vortex, and then sum up the product of each cell surface by the vorticity to get the final circulation: "gamma(circulation)=sum(wi(vorticity at cell i) x Ai(surface of cell i))" Is there a macro already existing allowing you to calculate the surface of each cell? I didn't find anything on the forum concerning that. I would like to avoid doing something like that: CellSurface(i)=[y(i+1)-y(i)].[x(i+1)-x(i)] Thanks in advance for you're help! Maxime |
|
June 11, 2010, 04:32 |
|
#2 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
http://foam.sourceforge.net/doc/Doxy...1_1fvMesh.html the Sf() and magSf() methods can be used to get the surface vector and the magnitude of the surface vector for the mesh faces, respectively. the inherited cells() method http://foam.sourceforge.net/doc/Doxy...h-members.html allows you to find the faces corresponding to each cell. |
||
June 14, 2010, 12:49 |
|
#3 |
New Member
Join Date: Jun 2010
Posts: 14
Rep Power: 16 |
Hi!
Here's the code for the calculation of the circulation, I'm really having a hard time finding out why it doesn't work: // * * * * * * * * * * * * * * * * * *Circulation calculation (beginning)* * * * * * * * * * * * * * * * * * * * * * * * // scalar circulation = 0.0; scalar r = 0.0; //scalar cell_area = 0.0; const surfaceScalarField& magSf = mesh.magSf(); forAll(magVorticity, cellI) { //cell_area = (mesh.C()[cellI+1].component(0)-mesh.C()[cellI].component(0)).(mesh.C()[cellI+1].component(1)-mesh.C()[cellI].component(1)); // Surface of one cell if (distance < r[cellI]) // If the radius stays inferior to r_c... { // circulation = circulation + magVorticity[cellI].cell_area[cellI]; // ...calculation of the circulation circulation = circulation + magVorticity[cellI].magSf[cellI]; } } // * * * * * * * * * * * * * * * * * *Circulation calculation (end)* * * * * * * * * * * * * * * * * * * * * * * * // The message given in the terminal is as follows (after I did wmake): make: Warning: File `linux64GccDPOpt/options' has modification time 6e+02 s in the future make: warning: Clock skew detected. Your build may be incomplete. make: Warning: File `Make/linux64GccDPOpt/dontIncludeDeps' has modification time 6e+02 s in the future Making dependency list for source file MaxVorCirc.C make: warning: Clock skew detected. Your build may be incomplete. make: Warning: File `MaxVorCirc.dep' has modification time 6e+02 s in the future SOURCE=MaxVorCirc.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/usr/local/OpenFOAM/OpenFOAM-1.6/src/postProcessing/postCalc -I/usr/local/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude -IlnInclude -I. -I/usr/local/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude -I/usr/local/OpenFOAM/OpenFOAM-1.6/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/MaxVorCirc.o MaxVorCirc.C: In function ‘void Foam::calc(const Foam::argList&, const Foam::Time&, const Foam::fvMesh&)’: MaxVorCirc.C:86: error: invalid types ‘Foam::scalar[Foam::label]’ for array subscript MaxVorCirc.C:93: error: request for member ‘magSf’ in ‘magVorticity.Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::<anonymous>.Foam:imensionedField <double, Foam::volMesh>::<anonymous>.Foam::Field<double>::< anonymous>.Foam::List<double>::<anonymous>.Foam::U List<T>:perator[] [with T = double](cellI)’, which is of non-class type ‘double’ MaxVorCirc.C:80: warning: unused variable ‘magSf’ make: *** [Make/linux64GccDPOpt/MaxVorCirc.o] Error 1 Any help given would be very appreciated. Thanking you in advance, Maxime |
|
June 14, 2010, 16:49 |
|
#4 |
New Member
Join Date: Jun 2010
Posts: 14
Rep Power: 16 |
Just to make it a little bit more clear (updated version also):
I have to calculate the circulation in a vortex. My code is as follows: Code:
#include "calc.H" #include "fvc.H" void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) { volScalarField magVorticity // Imports the results of the vortex vorticity ( IOobject ( "magVorticity", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); scalar circulation = 0.0; scalar r = 0.0; const volScalarField& magSf = mesh.magSf(); forAll(magVorticity, cellI) { if (distance < r[cellI]) // If the radius (distance) stays lower than the critical radius (r)... { circulation += magSf.magVorticity[cellI]; // ...calculation of the circulation. } } } Code:
SOURCE=MaxVorCirc.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/usr/local/OpenFOAM/OpenFOAM-1.6/src/postProcessing/postCalc -I/usr/local/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude -IlnInclude -I. -I/usr/local/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude -I/usr/local/OpenFOAM/OpenFOAM-1.6/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/MaxVorCirc.o MaxVorCirc.C: In function ‘void Foam::calc(const Foam::argList&, const Foam::Time&, const Foam::fvMesh&)’: MaxVorCirc.C:89: error: invalid types ‘Foam::scalar[Foam::label]’ for array subscript MaxVorCirc.C:94: error: ‘magSf’ was not declared in this scope make: *** [Make/linux64GccDPOpt/MaxVorCirc.o] Error 1 Thank you in advance! Maxime |
|
June 15, 2010, 03:23 |
|
#5 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Please re-read my previous post. You are, for example, trying to use a surfaceScalarField (which is defined for mesh faces) for cells, and lots of other dubious things.
|
|
June 17, 2010, 19:04 |
|
#6 |
New Member
Join Date: Jun 2010
Posts: 14
Rep Power: 16 |
Hello,
I'd like to know how I can access/choose the area (of only one of the 6 faces) of a internal cubical finite volume (not near a patch). I know I have to use the magSf command, but I don't know which face area (or which direction) of the finite volume it gives me. Thank you. Maxime |
|
July 13, 2010, 08:37 |
|
#7 |
New Member
Join Date: Jun 2010
Posts: 1
Rep Power: 0 |
Hey maximeg,
Have you solved your problem in order to calculate the circulation? In my simulation (flow around around a car) I need to calculate the circulation as well, but here for rectangular "boxes" around the car. Can you help me out with some advice? Thanks in advance, \AlterSchwede |
|
July 13, 2010, 14:30 |
|
#8 | |
New Member
Join Date: Jun 2010
Posts: 14
Rep Power: 16 |
Quote:
No, unfortunately I didn't find what I was looking for. I calculated the surface manually instead (not hard but not general). I don't think you'll be able to do that though (in my case, all the cells have the same size). If you find anything please let me know. Maxime |
||
Tags |
cell |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Gmsh] boundaries with gmshToFoam | ouafa | OpenFOAM Meshing & Mesh Conversion | 7 | May 21, 2010 13:43 |
Cell ID macro ?!?!?!?!?! | bohis | FLUENT | 1 | November 14, 2008 09:26 |
UDF macro for surface tension coefficient | Frederik | FLUENT | 2 | May 30, 2005 11:54 |
Macro for velocity on the face of the cell | Dragos | FLUENT | 0 | April 7, 2005 12:12 |
cell to cell relation | CMB | Siemens | 1 | December 4, 2003 05:05 |