Conditional Operation on a Geometric Field
This may be a relatively simple question. I am simplifying the actual problem, for clarity.
Say variable X is of type volScalarField, and takes values between 0 and 1.0. I want to define a dependent variable Y (type volScalarField) whose definition depends on the local value of X. Something like
Y = exp(-X);
Y = 2*X;
I tried to do this literally, and it said something like
error: no match for 'operator>' in 'Foam::operator*(const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::scalar&) [...]
Because this operation has to be done cell by cell, you need to use something like:
forAll (X, celli)
Y[celli] = exp(-X[celli]);}
Y[celli] = 2*X[celli];}
If the field has dimensions, then you're going to have to make sure you deal with them properly, but other than that I think that's how it goes down.
|All times are GMT -4. The time now is 08:05.|