|
[Sponsors] |
December 18, 2012, 10:04 |
PtrList<PtrList<dimesionedScalar> >
|
#1 |
New Member
M. Sabouri
Join Date: Nov 2011
Posts: 24
Rep Power: 15 |
I want to define binary interaction parameters in a mixture. For example I need to determine the interaction diameter as a matrix-like variable, d_ij.
It seems that a variable of type PtrList<PtrList<dimesionedScalar> > is suitable. But I don't know how to apply a relation like : d_ij[i][j]=(d[i]+d[j])/2 to initialize that. Can anybody help me on this or refer to part of O.F. code for something similar? Thanks. |
|
December 19, 2012, 05:17 |
|
#2 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
Would this do it
Code:
typedef Vector2D<scalar> matrix; typedef Field<matrix> matrixField; matrix zeroMatrix(0,0); matrixField dij(U.size(), zeroMatrix); forAll(dij, celli) { dij[celli].x() = 1.0; dij[celli].y() = 12.0; } |
|
December 19, 2012, 05:19 |
|
#3 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
I just realized, no it wont...
|
|
December 19, 2012, 09:26 |
|
#4 |
New Member
M. Sabouri
Join Date: Nov 2011
Posts: 24
Rep Power: 15 |
Thanks,
I managed it in a different way. I used a PtrList<dimensionedScalar> of size N^2 insted of a N*N matrix. Something like this: PtrList<dimensionedScalar> d(specieName.size()); forAll(specieName, i) { d[i]= .... ; } PtrList<dimensionedScalar> d_ij(specieName.size()*specieName.size()); forAll(specieName, i) { forAll(specieName, j) { label k=i*specieName.size()+j; d_ij[k]=(d[i]+d[j])/2; } } |
|
January 10, 2013, 11:21 |
|
#5 |
Senior Member
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17 |
Hi
You can also use List< List < scalar > > Code:
typedef List< List < scalar > > myMatrix; myMatrix myZeroMatrix(label x, label y) { myMatrix newMyMatrix(x); forAll(newMyMatrix, i) { newMyMatrix[i].setSize(y,0); } return newMyMatrix; } Code:
myMatrix d_ij; d_ij = myZeroMatrix (6,6); Code:
d_ij[0][3] = 6; Hisham |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Fluid travels: Zone 1 --> Zone 2 --> Zone 3. How can I modify diffusivity in each??? | ANT | FLUENT | 1 | August 1, 2012 08:55 |
1.7.x -> buoyantPimpleFoam -> hRhoThermo -> incompressible and icoPoly3ThermoPhysics? | will.logie | OpenFOAM Programming & Development | 1 | February 16, 2011 21:52 |
1.7.x -> buoyantPimpleFoam -> hRhoThermo -> incompressible and icoPoly3ThermoPhysics? | will.logie | OpenFOAM | 0 | December 16, 2010 08:08 |
CAD -> gMsh -> enGrid -> OpenFOAM Problem | AlGates | OpenFOAM | 7 | August 6, 2010 13:46 |
convection......-> conduction......-> convection | madasu | FLUENT | 3 | November 24, 2002 02:15 |