# PtrList<PtrList<dimesionedScalar> >

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

 December 18, 2012, 10:04 PtrList > #1 New Member   M. Sabouri Join Date: Nov 2011 Posts: 24 Rep Power: 7 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 > 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: 22 Would this do it Code: ``` typedef Vector2D matrix; typedef Field 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: 22 I just realized, no it wont...

 December 19, 2012, 09:26 #4 New Member   M. Sabouri Join Date: Nov 2011 Posts: 24 Rep Power: 7 Thanks, I managed it in a different way. I used a PtrList of size N^2 insted of a N*N matrix. Something like this: PtrList d(specieName.size()); forAll(specieName, i) { d[i]= .... ; } PtrList 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: 253 Blog Entries: 10 Rep Power: 10 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

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post ANT FLUENT 1 August 1, 2012 07:55 will.logie OpenFOAM Programming & Development 1 February 16, 2011 21:52 will.logie OpenFOAM 0 December 16, 2010 08:08 AlGates OpenFOAM 7 August 6, 2010 12:46 madasu FLUENT 3 November 24, 2002 02:15

All times are GMT -4. The time now is 20:54.