I'm having trouble with a for
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' ================================================== ========= |
Hi again.
I actually manage
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 |
U returns a vector
mag(U) ret
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()) |
Missed a bracket, should be:
Missed a bracket, should be:
if (mag(U[ccelli]) > ULimit.value()) |
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 |
All times are GMT -4. The time now is 10:07. |