CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

PtrList<PtrList<dimesionedScalar> >

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   December 18, 2012, 09:04
Default PtrList<PtrList<dimesionedScalar> >
  #1
New Member
 
M. Sabouri
Join Date: Nov 2011
Posts: 16
Rep Power: 4
Moslem is on a distinguished road
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.
Moslem is offline   Reply With Quote

Old   December 19, 2012, 04:17
Default
  #2
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 692
Rep Power: 18
niklas will become famous soon enough
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;
    }
niklas is offline   Reply With Quote

Old   December 19, 2012, 04:19
Default
  #3
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 692
Rep Power: 18
niklas will become famous soon enough
I just realized, no it wont...
niklas is offline   Reply With Quote

Old   December 19, 2012, 08:26
Default
  #4
New Member
 
M. Sabouri
Join Date: Nov 2011
Posts: 16
Rep Power: 4
Moslem is on a distinguished road
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;
}
}
Moslem is offline   Reply With Quote

Old   January 10, 2013, 10:21
Default
  #5
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
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;

}
To initiate your matrix
Code:
myMatrix d_ij;
d_ij = myZeroMatrix (6,6);
to modify elements:
Code:
d_ij[0][3] = 6;
Best regards
Hisham
Hisham is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 07:55
1.7.x -> buoyantPimpleFoam -> hRhoThermo -> incompressible and icoPoly3ThermoPhysics? will.logie OpenFOAM Programming & Development 1 February 16, 2011 20:52
1.7.x -> buoyantPimpleFoam -> hRhoThermo -> incompressible and icoPoly3ThermoPhysics? will.logie OpenFOAM 0 December 16, 2010 07:08
CAD -> gMsh -> enGrid -> OpenFOAM Problem AlGates OpenFOAM 7 August 6, 2010 12:46
convection......-> conduction......-> convection madasu FLUENT 3 November 24, 2002 01:15


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