|
[Sponsors] |
![]() |
![]() |
#1 |
Member
Juho Peltola
Join Date: Mar 2009
Location: Finland
Posts: 89
Rep Power: 17 ![]() |
I'm having trouble with a for loop over the velocity field. Could anyone point out where the problem might be? I've tried a quite a few variations but I've ran out of ideas.
I've included the relevant part of the code ant the error message below. ================================================== ========== dimensionedScalar ULimit("ULimit",U.dimensions(),50); forAll (U, celli) { if (mag(U[celli]) > ULimit) { } } ================================================== ========= About line "if (mag(U[celli]) > ULimit)": ================================================== ========== error: no match for 'operator>' in 'Foam::mag [with Form = Foam::Vector<double>, Cmpt = double, int nCmpt = 3](((const Foam::VectorSpace<foam::vector<double>, double, 3>&)((const Foam::VectorSpace<foam::vector<double>, double, 3>*)(&((Foam::Vector<double>*)((Foam::volVectorFie ld*)Ua)->Foam::GeometricField< foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::<anonymous>.Foam::DimensionedField <foam::vector<double>, Foam::volMesh>::<anonymous>.Foam::Field<foam::vect or<double> >::<anonymous>.Foam::List<foam::vector<double> >::<anonymous>.Foam::UList<t>::operator[] [with T = Foam::Vector<double>](celli))->Foam::Vector<double>::<anonymous>)))) > ULimit' ================================================== ========= |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Member
Juho Peltola
Join Date: Mar 2009
Location: Finland
Posts: 89
Rep Power: 17 ![]() |
Hi again.
I actually managed to do what I wanted to do without any for loops - which is probably the right way - but for the future I would like to know how a forAll loop, such as described in the first post, could be made to work. Juho |
|
![]() |
![]() |
![]() |
![]() |
#3 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 ![]() |
U[celli] returns a vector
mag(U[cellI]) returns a scalar you have defined ULimit as a dimensionedScalar A dimensionedScalar is not a scalar and the > operation is not defined for comparing these two types. To make it work you can do one of the following: 1. define ULimit as a scalar 2. Write the if statement like this: if (mag(U[celli] > ULimit.value()) |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 ![]() |
Missed a bracket, should be:
if (mag(U[ccelli]) > ULimit.value()) |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Senior Member
Francois Beaubert
Join Date: Mar 2009
Location: Lille, France
Posts: 147
Rep Power: 17 ![]() |
I'm also having trouble with a forAll loop over a volVectorField.
Sorry for the dummy question but I'm not able to find the mistake on the simple snippet code below which doesn't work for ccCyl.boundaryField()[patchI] but do work for ccCyl[patchI] I've got the following error message error: no matching function for call to ‘Foam::fvPatchField<Foam::Vector<double> >::component(<unre solved overloaded function type>)’ --------------------The snippet -------------------------------------------------------------------------------------- volVectorField cc = mesh.C(); //The vector field cc will now be transformed into cylindrical coordinates volVectorField ccCyl ( IOobject ( "ccCyl", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, vector(0,0,0) ); ccCyl.internalField() = ccs.localVector(cc.internalField()); forAll (ccCyl.boundaryField(), patchI) { ccCyl.boundaryField()[patchI] = ccs.localVector(cc.boundaryField()[patchI]); if (ccCyl.boundaryField()[patchI].component(vector::y) < 0.0) { Info << "ccCyl.boundaryField = " << ccCyl.boundaryField()[patchI].component(vector::Y); } } -------------------------End of the snippet --------------------------------------------------------------------------------------- Any idea? Thank you for your kind help Francois |
|
![]() |
![]() |
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tensor mathematics forAll macro combination tensors with vectors | olesen | OpenFOAM Running, Solving & CFD | 4 | February 25, 2009 05:03 |
Vector devide by vector | bhuve | OpenFOAM Running, Solving & CFD | 2 | June 2, 2008 07:14 |
which is a better way to loop in fortran? | zonexo | Main CFD Forum | 7 | June 23, 2006 04:47 |
Why doesnbt the macro forall work for the volVectorField variable | siwen | OpenFOAM Running, Solving & CFD | 2 | February 24, 2006 15:27 |
loop(p,I->p) how this loop works? | Sinan | FLUENT | 0 | January 18, 2005 18:04 |