CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   bug in cylindricalCS class or fatal setup error?!! (https://www.cfd-online.com/Forums/openfoam-programming-development/70252-bug-cylindricalcs-class-fatal-setup-error.html)

Enzu Zheng August 30, 2017 19:38

About the bug in cylindricalCS (compiled in OpenFOAM 4.0)
 
Quote:

Originally Posted by sitajeje (Post 658813)
Dear Foamers,

I compared the GeometricField.H of OF4.1 and OF2.1, and found that the type of internalField() used in this utility is changed:
OpenFOAM4.1
typedef DimensionedField<Type, GeoMesh> Internal;
....
inline const Internal& internalField() const;

OpenFOAM2.1
typedef Field<Type> InternalField;
....
inline const InternalField& internalField() const;

This made the error that I posted in the last thread. I wonder how should I amend this code so that it can be used for OF4.0? I appreciate greatly for any suggestions and hints!

Thank you very much in advance!

Best regards,
sitajeje

Hi, sitajeje,

I changed it to

forAll (ccCyl.internalField(), i)
{
ccCyl.ref()[i]=cyl.localVector(cc.internalField()[i]);
}

Now it can compile successfully, but any better way to modify it? Thanks.

Best regards,
Enzu

sitajeje August 31, 2017 08:44

convertToCylindrical for OF4.0
 
1 Attachment(s)
Hello Enzu

please find my adaption to OF4.0 in the attachment.

sitajeje

Enzu Zheng August 31, 2017 20:03

Thanks, Sitajeje. This helps.

Enzu

tom.opt September 29, 2017 05:44

has anyone found a fix for this code to work in OF5 ?

I get this error when i wmake
convertToCylindrical.C: In function ‘int main(int, char**)’:
convertToCylindrical.C:118:21: error: ‘class Foam::IOobject’ has no member named ‘headerOk’
if (Uheader.headerOk())
^
/opt/openfoam5/wmake/rules/General/transform:25: recipe for target 'Make/linux64GccDPInt32Opt/convertToCylindrical.o' failed
make: *** [Make/linux64GccDPInt32Opt/convertToCylindrical.o] Error 1

Chris123 November 23, 2017 09:12

I got the same error message. Any idea how to fix it?
Best regards,
Mark

tom.opt November 23, 2017 11:56

Quote:

Originally Posted by Chris123 (Post 672611)
I got the same error message. Any idea how to fix it?
Best regards,
Mark

Hi Mark,
The way I worked around it was to use paraview for postProcessing, and I just used formulas In the calculator to convert the values that I needed from XYZ to cylindrical.

I think the script was written for an older version of openfoam and doesn't work with newer versions

Chris123 November 24, 2017 01:48

Thank you Tom. This is also a solution but I would prefere the script solution due to automatize the process.
So no one who updated the script to newer versions of OF?

Elliptic CFD December 15, 2017 21:03

Changing from Cartesian to cylindrical coordinates using a different origin
 
This is a quick comment for anyone who is trying to use the OpenFOAM library to change from a Cartesian coordinate system to a cylindrical coordinate system with a different origin. The conversion will not work using the code posted in this forum as the library assumes that the origin is still at [0 0 0].

A quick fix will be to translate the Cartesian coordinate system using the origin of the new cylindrical coordinates then doing the coordinate system conversion. For instance

// Creating cylindrical coordinates
cylindricalCS ccs
(
"ccs",
point(5.0, 0.0, 1.58), // centre point of ccs
vector(0, -1, 0), // axis of ccs
vector(0, 0, -1), // base axis for cylindrical angle
false
);

// The cartersian coordinates used by the simulation
volVectorField cco = mesh.C();

dimensionedVector origin("origin", dimLength, vector(5.0, 0.0, 1.58));

volVectorField cc = cco - origin;

polarCoord.primitiveFieldRef() = ccs.localVector(cc.internalField());

forAll(polarCoord.boundaryField(), patchI)
{
polarCoord.boundaryFieldRef()[patchI] = ccs.localVector(cc.boundaryField()[patchI]);
}

polarCoord.write();

This should work

Quote:

Originally Posted by eagle (Post 395529)
Hi all !

Im trying to use this utilitie for a body not aligned with the origin of the mesh. Its because Im simulating a bent pipe and the center of bend is the center of origin and not the rotation axis of the pipe.

The Problem is if Im changing the cylindricalCs like

cylindricalCS cyl(

"cylindricalCS",
-> point(0.169, 0, 0),//origin of cs
vector(0, 0, 1), //rotation axis
vector(0, 1, 0), //start of angle
false); //keyword false: Use radians since cos and sin work with radians

The class/or tool doesn't use the point Im giving it. Im relatively new to foam so Im not
sure if the problem is somewhere around here:

ccCyl.internalField() = cyl.localVector(cc.internalField());
forAll (ccCyl.boundaryField(), patchI)
{
ccCyl.boundaryField()[patchI] = cyl.localVector(cc.boundaryField()[patchI]);
}

I checked Theta and its not in accordance to the center of the cylindrical Coordinatesystem.

I know I could just change the origin of the mesh. But as I'm also simulating a pipe helix and need the cylindrical coordinates somewhere in the helix I do need the answer to this anyway.

I could really use some help here ;)

best regards

-----------------------------------------------------

Edit:

by searching for a solution I considered using:

globalToLocal (const vector &, bool translate) const

instead of:

localVector (const vector &global) const


see here:

http://foam.sourceforge.net/docs/cpp/a00294.html

So Im in the opinion during transformation with localVector the translation of the origin is getting lost.
I could imagine using globalToLocal is solving the problem but I cant use it or dont know how because its
a protected function ?


Chris123 January 8, 2018 08:42

Hi Ehimen, thank you for your help.
honestly I do not understand which file I have to modify according to your enries, is it the cylindricalCS.C file? Than I do not know where?

Sorry for my unknowledge.

gu1 August 9, 2018 14:00

Quote:

Originally Posted by tom.opt (Post 666070)
has anyone found a fix for this code to work in OF5 ?

I get this error when i wmake
convertToCylindrical.C: In function ‘int main(int, char**)’:
convertToCylindrical.C:118:21: error: ‘class Foam::IOobject’ has no member named ‘headerOk’
if (Uheader.headerOk())
^
/opt/openfoam5/wmake/rules/General/transform:25: recipe for target 'Make/linux64GccDPInt32Opt/convertToCylindrical.o' failed
make: *** [Make/linux64GccDPInt32Opt/convertToCylindrical.o] Error 1

Just switch the Uheader.headerOk() to Uheader.good()

Chris123 October 24, 2018 05:24

Sorry for my late reply. Thank you gu1, now it works.
But now I got Ucyl and Ualpha both with x,y, z option.
Even if I take a look into the "convertTocylindric" file it is not quite clear to me what I see. (e.g. if I select Ucyl (x) looks quite different from Ucyl (y).
Can you please explain me what I got if I choose Ualpha/Ucyl (x,y,z)?
Thank you

Chris123 October 24, 2018 05:51

I would like to add, Ualpha (y,z) is zero.
My aim is to export U radial data, but I need an allocation to theta and range.


All times are GMT -4. The time now is 20:57.