volScalarField to volVectorField
Dear Foamers,
I have three volScalarField namely: avgUx, avgUy, and avgUz as follows in the code: Code:
volScalarField avgUx Code:
scalarField spanavgUMeanX Thanks, Syavash |
Well, I have tried to construct a volVectorField from aforementioned volScalarField using the following block:
Code:
volVectorField Uvec Code:
In file included from postSpanwiseAverage.C:82:0: Any kind of help is highly appreciated Syavash |
Anyone willing to help??!
Thanks. |
|
You can access the individual carthesian coordinates of a volume vector field directly. I think it is something like U[cellI].x or something similar. Just try it out. Then you formulate a ForAll loop and overwrite them. The access of individual memeber of your volume scalar field is even more simple, just avgUx[cellI] is the value of cellI member of avgUx.
Regards, Daniel |
|
@ Lilla
I tried something like this: Code:
volVectorField Uvec Code:
FOAM FATAL ERROR: @Henning86: Thanks for your reply. I know the difference between sclalarfield, volScalarField, and volVectorField but I am not really an OF programmer! Could you be more specific regarding my case?!! What syntax should I use? A simple example is highly appreciated. |
This function only allows only to get the compoenents in each direction.
attempted to assign to a const reference to constant object of type Hadn't seen this: The function you are looking for is: http://foam.sourceforge.net/docs/cpp/a00911.html void replace (const direction, const GeometricField< cmptType, PatchField, GeoMesh > &) void replace (const direction, const dimensioned< cmptType > &) |
Quote:
Thank you for any help. :) |
The component function is not meant to set the internalfield. Try:
Code:
Uvec.internalField().replace(vector::X,avgUx.internalField()); |
Quote:
And if I understood correctly, OpenFOAM cannot store surfaceVectorFields in the time folders? It has to be a mesh-element value of voLVectorField |
Can't convert volScalar Field to volScalarField
Hi all,
I am trying to edit twoPhaseEulerFoam solver by introducing another force in the momentum equation.Below is the UEqns.H file that I am editing.The bold part is what I am introducing in the code. However the third bolded line where I introduce volVectorField it gives me an error saying "error: conversion from ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ to non-scalar type ‘Foam::volVectorField {aka Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>}’ requested volVectorField FV = (KA,KA,KA); " How do I introduce the scalar in the volScalarField into volVectorField? Your help in this matter is greatly appreciated. Thanks and Regards, Code:
Info<< "Constructing momentum equations" << endl; |
Hi,
what you are trying to do is not possible. The easiest way is to do it somehow like that: Code:
volVectorField yourField Code:
volVectorField FV = (KA,KA,KA); Code:
volVectorField yourField = U; // copy of the field |
Hi shanvach,
In OF, the fvVectorMatrix is a special object, which describes a linear equation system consisting of a scalar matrix, an unknown vector field and a source term. You cannot just multiply the terms by something. The structure of that operation is that each of those terms (fvm:... etc) does a specific operation to add or assign values to the matrix coefficients or the source term. So, you have to include your mutiplier to each of those component by respecting what kind of field term is asked for. For a scalar field multiplied to the temporal derivative, you somewhat have already have the syntax in the upper part of your code: Code:
fvm::ddt(alpha1, U1) For the source term, the code is: Code:
fvm::Sp(fvc::div(phi1), U1) The tricky part is: Code:
fvm::div(phi1, U1) Just be aware: this is a little work to do and you have to spend some time understanding the structure of fvm objects. Regards, Daniel |
Quote:
maybe I missed the point when one was starting to talk about fvMatrix class, but shanvach was actually asking for the bold lines in his code? |
Dear Tobi,
You are correct. I should read the question more carefully. But the code further below will not work, I think. This popped up immediately when I read it. Regards, Daniel |
Hi,
you are right too. I stopped reading the code after I reached the bolded lines; its a matter of available time I have. However, your answer is of benefit too based on the missing matrix definition. :) |
All times are GMT -4. The time now is 13:37. |