CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to access the members of a "volScalarField"? (http://www.cfd-online.com/Forums/openfoam-programming-development/108928-how-access-members-volscalarfield.html)

u396852 November 5, 2012 06:19

How to access the members of a "volScalarField"?
 
I have to compare the individual values of a volScalarField. It gives error saying that operator (>) is not defined for volScalarField varible. How do I access the each member of the volScalarField varialbe. Also, there is function which calculates shearStress() and stores in volScalarField. How to access the each member of that function?

kmooney November 5, 2012 16:59

Quote:

Originally Posted by u396852 (Post 390306)
I have to compare the individual values of a volScalarField. It gives error saying that operator (>) is not defined for volScalarField varible. How do I access the each member of the volScalarField varialbe. Also, there is function which calculates shearStress() and stores in volScalarField. How to access the each member of that function?

You can access the entries of a volScalarField as such:
Code:

volScalarField myVSF;

scalarField intVSF = myVSF.internalField();

forAll(intVSF, cellI)
{
    intVSF[cellI] = whatYourAfter;
}

Note: A volScalarField has both internal and patch boundary values to access.

u396852 November 9, 2012 00:38

thank a lot kmooney for your reply it indeed works. thanks for the help.

u396852 November 27, 2012 06:35

access the values of volScalarField
 
Kmooney now with your suggestion i am able to define the intVSF but when i try to access the values of intVSF using the following code it gives errors. i am copying the error message at the end could you help understanding it

Code:

volScalarField shearstress = old_visc*strainRate(); /* old_visc is VSF and strainRate() is function which returns shear rate which is also VSF */

volScalarField shearrate = strainRate();

scalarField intVSF = shearstress.internalField();
scalarField intVSF1 = shearrate.internalField();

if ( current_time.value() < 0.0001)
return old_visc;

else
{
forAll(intVSF1, celll)
{
if (intVSF1[celll] < scalar(0.001))
return old_visc;

else

if (intVSF1[celll] > scalar(10000))
return old_visc;

else {
if (intVSF[celll] > scalar(temp)) /* temp is calculated in the code */

return nu0_ /nu0_ is defined in the code
else
return old_visc;
}
}



ERROR:

[compute-0-25.local:16834] *** An error occurred in MPI_Recv
[compute-0-25.local:16834] *** on communicator MPI_COMM_WORLD
[compute-0-25.local:16834] *** MPI_ERR_TRUNCATE: message truncated
[compute-0-25.local:16834] *** MPI_ERRORS_ARE_FATAL (goodbye)
[compute-0-3.local:01034] *** An error occurred in MPI_Recv
[compute-0-3.local:01034] *** on communicator MPI_COMM_WORLD
[compute-0-3.local:01034] *** MPI_ERR_TRUNCATE: message truncated
[compute-0-3.local:01034] *** MPI_ERRORS_ARE_FATAL (goodbye)
[compute-0-37.local:09710] *** An error occurred in MPI_Recv
[compute-0-37.local:09710] *** on communicator MPI_COMM_WORLD
[compute-0-37.local:09710] *** MPI_ERR_TRUNCATE: message truncated
[compute-0-37.local:09710] *** MPI_ERRORS_ARE_FATAL (goodbye)
[compute-0-23.local:00497] *** An error occurred in MPI_Recv
[compute-0-23.local:00497] *** on communicator MPI_COMM_WORLD
[compute-0-23.local:00497] *** MPI_ERR_TRUNCATE: message truncated
[compute-0-23.local:00497] *** MPI_ERRORS_ARE_FATAL (goodbye)
[compute-0-38.local:14813] [0,0,0] ORTE_ERROR_LOG: Timeout in file base/pls_base_orted_cmds.c at line 275
[compute-0-38.local:14813] [0,0,0] ORTE_ERROR_LOG: Timeout in file pls_rsh_module.c at line 1166
[compute-0-38.local:14813] [0,0,0] ORTE_ERROR_LOG: Timeout in file errmgr_hnp.c at line 90
mpirun noticed that job rank 0 with PID 14908 on node compute-0-38 exited on signal 15 (Terminated).
[compute-0-38.local:14813] [0,0,0] ORTE_ERROR_LOG: Timeout in file base/pls_base_orted_cmds.c at line 188
[compute-0-38.local:14813] [0,0,0] ORTE_ERROR_LOG: Timeout in file pls_rsh_module.c at line 1198
--------------------------------------------------------------------------
mpirun was unable to cleanly terminate the daemons for this job. Returned value Timeout instead of ORTE_SUCCESS.
--------------------------------------------------------------------------
0/: Permission denied.

size 0 is not equal to the given value of 11037
file: /home/u396852/OpenFOAM/u396852-1.5/paintCases/Ellisrun-0.001fix-time-step/processor0/2e-05/visco_old from line 18 to line 63.
From function Field<Type>::Field(const word& keyword, const dictionary& dict, const label s)
in file /share/apps/devel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/Field.C at line 224.
FOAM exiting


All times are GMT -4. The time now is 21:56.