Hi -

> If I have 4 unknowns at each grid point, what is the best way to
> store this data ?

This sounds like a good use for a tuple to me.

E.g. instead of


 var u1 : [Domain] real;
 var u2 : [Domain] real;
 var u3 : [Domain] real;
 var u4 : [Domain] real;


you can use

 var u : [Domain] 4*real;

where now instead of writing

 u2[x]

you'd write

 u[x][2]

for example.

Representing it as a record is also reasonable
but that has more to do with how you wish to structure
the code. Of course you could use a tuple in a record,
or 4 different fields. I would generally advise against
making a 4-element array as a field in that record -
a tuple is a better fit.

If it made sense to include the 4 unknowns in "Domain",
you could also add another dimension to Domain.

Or, you could declare an array of arrays:

 var u : [Domain] [1..4] real

and use it just like the tuple.

Of all these, I'd recommend storing tuples:

 var u : [Domain] 4*real;

Cheers,

-michael

On 10/6/16, 4:15 AM, "Praveen C" <[email protected]> wrote:

>Hello
>
>
>I am thinking of a finite different type application. So I will have
>loops like
>
>
>forall (i,j) in Domain
>{
>// use all 4 components of solution at (i-3,j), (i-2,j), (i-1,j), (i,j),
>(i+1,j)
>// and do some computation
>}
>
>
>and similarly a loop where I access solution values along j-axis.
>
>
>Best
>praveen
>
>
>On Thu, Oct 6, 2016 at 8:41 AM, Praveen C
><[email protected]> wrote:
>
>Dear all
>
>
>If I have 4 unknowns at each grid point, what is the best way to store
>this data ?
>
>
>I could do
>
>
>var u1 : [Domain] real;
>var u2 : [Domain] real;
>
>var u3 : [Domain] real;
>
>var u4 : [Domain] real;
>
>
>
>But this is not very nice for coding.
>
>
>I could use a record
>
>
>record Solution
>{
>var u : [1..4] real;
>}
>
>
>var sol : [Domain] Solution;
>
>
>Is there a reason to choose one over the other in terms of performance.
>
>
>Thanks
>praveen
>
>
>
>
>
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to