CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

About extracting the normals to faces on a patch

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Hannes_Kiel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 14, 2014, 10:32
Default About extracting the normals to faces on a patch
  #1
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
Dear All,

I am studying the flow around an airfoil. The point is that I am interested in saving a file containing the normal vectors to the faces on the patch "airfoil". Do you know how I can get this?

Thanks a lot,
Samuele
samiam1000 is offline   Reply With Quote

Old   March 14, 2014, 14:07
Default
  #2
Member
 
Hannes
Join Date: Apr 2009
Location: Schleswig, Germany
Posts: 38
Rep Power: 17
Hannes_Kiel is on a distinguished road
You could modify writeCellCentres to write Sf() instead of magSf().
__________________
FluidEngineeringSolutions
Hannes_Kiel is offline   Reply With Quote

Old   March 17, 2014, 11:44
Default
  #3
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
Dear Hannes,

thanks for writing.

Actually, I was thinking to compute cell normals run-time and not as post-processing.

I opened the elbow tutorial and I modified the controlDict as follows:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.2                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
libs
(
    "libOpenFOAM.so"
);

application     icoFoam;

startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         10;

deltaT          0.05;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

functions
{
    #include "computeNormals"
}

// ************************************************************************* //
where the computNormals is:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.2                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/

computeNormals
{
	functionObjectLibs ("libutilityFunctionObjects.so"); 
	type coded; 
	redirectType computeNormals; 
	outputControl outputTime; 
	code 
	#{
		polyPatch velocity-inlet-5;
		const vectorField::subField normals = patch.faceAreas(); 
	#};
}
Nevertheless, it does not work and I get the following error:
Code:
lab@labPC:~/OpenFOAM/OpenFOAM-2.2.2/tutorials/incompressible/icoFoam/elbow$ icoFoam 
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.2                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : 2.2.2-9739c53ec43f
Exec   : icoFoam
Date   : Mar 17 2014
Time   : 16:44:05
Host   : "labPC"
PID    : 9593
Case   : /home/lab/OpenFOAM/OpenFOAM-2.2.2/tutorials/incompressible/icoFoam/elbow
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading transportProperties

Reading field p

Reading field U

Reading/calculating face flux field phi


Starting time loop

Using dynamicCode for functionObject computeNormals at line 13 in "/home/lab/OpenFOAM/OpenFOAM-2.2.2/tutorials/incompressible/icoFoam/elbow/system/controlDict.functions.computeNormals"
Creating new library in "dynamicCode/computeNormals/platforms/linux64GccDPOpt/lib/libcomputeNormals_f9d5dbd87ebb60fe8eb22f95db6cc5f67e8f26a7.so"
Invoking "wmake -s libso /home/lab/OpenFOAM/OpenFOAM-2.2.2/tutorials/incompressible/icoFoam/elbow/dynamicCode/computeNormals"
wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file functionObjectTemplate.C
Making dependency list for source file FilterFunctionObjectTemplate.C
/home/lab/OpenFOAM/OpenFOAM-2.2.2/tutorials/incompressible/icoFoam/elbow/system/controlDict.functions.computeNormals: In member function ‘virtual void Foam::computeNormalsFunctionObject::write()’:
/home/lab/OpenFOAM/OpenFOAM-2.2.2/tutorials/incompressible/icoFoam/elbow/system/controlDict.functions.computeNormals:19:19: error: expected initializer before ‘-’ token
/home/lab/OpenFOAM/OpenFOAM-2.2.2/tutorials/incompressible/icoFoam/elbow/system/controlDict.functions.computeNormals:20:41: error: ‘patch’ was not declared in this scope
/home/lab/OpenFOAM/OpenFOAM-2.2.2/tutorials/incompressible/icoFoam/elbow/system/controlDict.functions.computeNormals:20:31: warning: unused variable ‘normals’ [-Wunused-variable]
make: *** [Make/linux64GccDPOpt/functionObjectTemplate.o] Error 1


--> FOAM FATAL IO ERROR: 
Failed wmake "dynamicCode/computeNormals/platforms/linux64GccDPOpt/lib/libcomputeNormals_f9d5dbd87ebb60fe8eb22f95db6cc5f67e8f26a7.so"


file: /home/lab/OpenFOAM/OpenFOAM-2.2.2/tutorials/incompressible/icoFoam/elbow/system/controlDict.functions.computeNormals from line 13 to line 18.

    From function codedBase::createLibrary(..)
    in file db/dynamicLibrary/codedBase/codedBase.C at line 202.

FOAM exiting

lab@labPC:~/OpenFOAM/OpenFOAM-2.2.2/tutorials/incompressible/icoFoam/elbow$
Any idea?

Thanks a lot,
Samuele
samiam1000 is offline   Reply With Quote

Old   March 17, 2014, 13:58
Default
  #4
Member
 
Hannes
Join Date: Apr 2009
Location: Schleswig, Germany
Posts: 38
Rep Power: 17
Hannes_Kiel is on a distinguished road
Hi Samuele,

first of all the compiler does not like your patch name. If you need to have it in the code, you might want to try something like velocityInlet5 instead.

Regarding the coded function object this is just a wild guess as I haven't used it:
code
#{
// get normals

const surfaceVectorField& normals = mesh().Sf();
// Write
normals.write();
#}

possibly: normals.boundaryField().write()

Good Luck
Hannes
amuzeshi likes this.
__________________
FluidEngineeringSolutions
Hannes_Kiel is offline   Reply With Quote

Old   March 19, 2014, 09:15
Default
  #5
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
Dear Hannes,

thanks a lot.

What you suggested works pretty well and I have a file names "S" in the constant/polyMesh dir. That's very nice.
Nevertheless, I am not completely satisfied, yet. I would need 2 improvements:

1. computing the normals on a patch only;
2. rescale the normals in order to have magnitude 1;

Could you help in doing this?

Thanks a lot,
Samuele

PS: attached a case. If you run blockMesh and icoFoam (it's the cavity case), you can get what I wrote above.
Attached Files
File Type: gz cavity.tar.gz (2.2 KB, 30 views)
samiam1000 is offline   Reply With Quote

Old   August 9, 2018, 07:53
Default Progress??
  #6
New Member
 
Héctor Lodoso
Join Date: Oct 2015
Location: Spain
Posts: 15
Rep Power: 11
Héctor Lodoso is on a distinguished road
Hi Samuele,


Did you make any progress in this regard? I am dealing with the same issue...


Many thanks!
Héctor



Quote:
Originally Posted by samiam1000 View Post
Dear Hannes,

thanks a lot.

What you suggested works pretty well and I have a file names "S" in the constant/polyMesh dir. That's very nice.
Nevertheless, I am not completely satisfied, yet. I would need 2 improvements:

1. computing the normals on a patch only;
2. rescale the normals in order to have magnitude 1;

Could you help in doing this?


Thanks a lot,
Samuele

PS: attached a case. If you run blockMesh and icoFoam (it's the cavity case), you can get what I wrote above.
__________________
Best regards!
Héctor Lodoso
Héctor Lodoso is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
y+ and u+ values with low-Re RANS turbulence models: utility + testcase florian_krause OpenFOAM 114 August 23, 2023 06:37
[snappyHexMesh] Add Mesh Layers doesnt work on the whole surface Kryo OpenFOAM Meshing & Mesh Conversion 13 February 17, 2022 08:34
[Other] Mesh Importing Problem cuteapathy ANSYS Meshing & Geometry 2 June 24, 2017 06:29
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 10:38
Possible Bug in pimpleFoam (or createPatch) (or fluent3DMeshToFoam) cfdonline2mohsen OpenFOAM 3 October 21, 2013 10:28


All times are GMT -4. The time now is 14:00.