[overture] Re: where structure explanation

  • From: Bill Henshaw <wdhenshaw@xxxxxxxxx>
  • To: overture@xxxxxxxxxxxxx
  • Date: Thu, 3 May 2018 15:30:04 -0400

HI Hub,
  The where statement sets an internal mask inside A++ that is used in
subsequent array statements.
In your case you should probably pass the mask into the function.

You can instead just write loops and use an "if" statement. This is
probably easiest.

...Bill

On Thu, May 3, 2018 at 10:28 AM, HH <hubpoub@xxxxxxxxx> wrote:

Hi there,

I  am quite confused with the "where" structure. I mean I can use it when
doing simple things such as adding values from two different variables into
another just other the discretization points. But when it comes to more
complicated things I am facing issues and I am not sure how to handle them
and where to find the right documentation.

Let's have an example. If I want to replace the sin * cos function
starting at line 28 of the interpolation example in the primer (section
3.3) by a function of my own  (myFunction) using a variable N defined over
cg to give something like :

u[grid](I1,I2,I3)=myFunction(N[grid](I1,I2,I3))

What should be the header of myFunction ? I succeed in compiling with

realArray myFunction(realArray ) but I am not sure that it will work (how
then the index I1,I2,I3 are passed ? and what about the
CompositeGrid::ISdiscretizationPoint I am using along with "where" ?)

Thanx for any hints

Hub





Other related posts: