|
[Sponsors] |
Taking the absolute value of a volVectorField or a volTensorField |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 16, 2005, 06:24 |
Hi,
I wish to compute the abs
|
#1 |
Member
Marco Kupiainen
Join Date: Mar 2009
Posts: 31
Rep Power: 17 |
Hi,
I wish to compute the absolute value of a volVectorField gp componentwise. I have tried to loop over all cells: forAll(centres, celli) { if ( gp[celli].x() < 0.0 ) { gp[celli].x() = -gp[celli].x(); } if ( gp[celli].y() < 0.0 ) { gp[celli].y() = -gp[celli].y(); } if ( gp[celli].z() < 0.0 ) { gp[celli].z() = -gp[celli].z(); } } but when I take min(gp) it shows negative values. How does this work? What should I do instead? best regards |
|
September 16, 2005, 08:22 |
Should be:
volVectorField g
|
#2 |
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33 |
Should be:
volVectorField gpCmptMag = cmptMag(gp); but it is not instantiated because it's not really appropriate for geometric fields. How about: vectorField gpCmptMag = cmptMag(gp.internalField()); This gives you the internal part of the field. Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk |
|
March 19, 2019, 09:56 |
abs not working for me
|
#3 | |
New Member
Join Date: Apr 2018
Posts: 17
Rep Power: 8 |
Quote:
I did "volVectorField U1CmptMag = Foam::cmptMag(U1);" thank you |
||
July 25, 2019, 14:00 |
|
#4 | |
New Member
Reza
Join Date: Jun 2012
Posts: 27
Rep Power: 14 |
Quote:
Hi Dela, I am not sure if you have solved your problem or not but just in case: cmptMag is not overloaded for volVectorField as the error message informs. So to overcome this problem you can do as follows: First, define a new volVEctorField in the createFields.H like this: volVectorField cmptMagU = U; Then in the C-file you can add the following loop: forAll ( U, index ) { cmptMagU [ index ] = cmptMag ( U [ index ] ); } This should work but I advise you to be cautious about the boundary cells. I would advise to use this on internalField() and take care of the boundary separately. BR |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to get the Diagonal elements of volTensorField | su_junwei | OpenFOAM Running, Solving & CFD | 0 | December 1, 2008 11:29 |
VolVectorField of complex numbers | quba | OpenFOAM | 0 | December 17, 2007 09:06 |
VolTensorField Gamma in laplacian | haibinli | OpenFOAM Running, Solving & CFD | 0 | May 17, 2007 02:45 |
To get the magnitude of volVectorField | susana | OpenFOAM Pre-Processing | 5 | November 16, 2006 07:53 |
VolTensorField | evgenii | OpenFOAM Pre-Processing | 1 | February 22, 2006 06:50 |