## Re: [Libmesh-users] Multiplying dphi[i][qp] by an arbitrary vector

 Re: [Libmesh-users] Multiplying dphi[i][qp] by an arbitrary vector From: John Peterson - 2008-12-04 19:32:19 ```On Thu, Dec 4, 2008 at 12:39 PM, bkraczek wrote: > I'm new to libmesh, and I am not a great C++ programmer, so the answer to > this may seem obvious. I am working from example 3 to implement a poisson > solver with a RHS that includes the dot product of the weighting function > with a vector that I set. > > So, working from line 351 of ex3.C, > > Fe(i) += JxW[qp]*fxy*phi[i][qp]; > > I want to change this to > > Fe(i) += JxW[qp]*dphi[i][qp]* gradGat ; > > where gradGat is the vector I desire to take the inner product with. How do > I properly construct gradGat so I can get the desired dot product? You can construct a Gradient object like this: Gradient gradGat(xvalue, yvalue, zvalue); See: include/numerics/vector_value.h, Gradient is nothing but a typedef for VectorValue, so you can use any of the VectorValue constructors which are available. Also, you may want to put parentheses, like so: JxW[qp]*(dphi[i][qp]* gradGat) ; to guarantee order of operation, but it should work either way. -- John ```

 [Libmesh-users] Multiplying dphi[i][qp] by an arbitrary vector From: bkraczek - 2008-12-04 18:39:58 ```I'm new to libmesh, and I am not a great C++ programmer, so the answer to this may seem obvious. I am working from example 3 to implement a poisson solver with a RHS that includes the dot product of the weighting function with a vector that I set. So, working from line 351 of ex3.C, Fe(i) += JxW[qp]*fxy*phi[i][qp]; I want to change this to Fe(i) += JxW[qp]*dphi[i][qp]* gradGat ; where gradGat is the vector I desire to take the inner product with. How do I properly construct gradGat so I can get the desired dot product? Thanks, Brent ```
 Re: [Libmesh-users] Multiplying dphi[i][qp] by an arbitrary vector From: John Peterson - 2008-12-04 19:32:19 ```On Thu, Dec 4, 2008 at 12:39 PM, bkraczek wrote: > I'm new to libmesh, and I am not a great C++ programmer, so the answer to > this may seem obvious. I am working from example 3 to implement a poisson > solver with a RHS that includes the dot product of the weighting function > with a vector that I set. > > So, working from line 351 of ex3.C, > > Fe(i) += JxW[qp]*fxy*phi[i][qp]; > > I want to change this to > > Fe(i) += JxW[qp]*dphi[i][qp]* gradGat ; > > where gradGat is the vector I desire to take the inner product with. How do > I properly construct gradGat so I can get the desired dot product? You can construct a Gradient object like this: Gradient gradGat(xvalue, yvalue, zvalue); See: include/numerics/vector_value.h, Gradient is nothing but a typedef for VectorValue, so you can use any of the VectorValue constructors which are available. Also, you may want to put parentheses, like so: JxW[qp]*(dphi[i][qp]* gradGat) ; to guarantee order of operation, but it should work either way. -- John ```
 Re: [Libmesh-users] Multiplying dphi[i][qp] by an arbitrary vector From: Derek Gaston - 2008-12-08 17:01:21 ```Also... more generally you can construct a TypeVector object and fill it up with data... these will correctly dot with any of the FE vectors. Derek On Dec 4, 2008, at 12:32 PM, John Peterson wrote: > On Thu, Dec 4, 2008 at 12:39 PM, bkraczek > wrote: >> I'm new to libmesh, and I am not a great C++ programmer, so the >> answer to >> this may seem obvious. I am working from example 3 to implement a >> poisson >> solver with a RHS that includes the dot product of the weighting >> function >> with a vector that I set. >> >> So, working from line 351 of ex3.C, >> >> Fe(i) += JxW[qp]*fxy*phi[i][qp]; >> >> I want to change this to >> >> Fe(i) += JxW[qp]*dphi[i][qp]* gradGat ; >> >> where gradGat is the vector I desire to take the inner product >> with. How do >> I properly construct gradGat so I can get the desired dot product? > > You can construct a Gradient object like this: > > Gradient gradGat(xvalue, yvalue, zvalue); > > See: include/numerics/vector_value.h, Gradient is nothing but a > typedef for VectorValue, so you can use any of the VectorValue > constructors which are available. Also, you may want to put > parentheses, like so: > > JxW[qp]*(dphi[i][qp]* gradGat) ; > > to guarantee order of operation, but it should work either way. > > -- > John > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Libmesh-users mailing list > Libmesh-users@... > https://lists.sourceforge.net/lists/listinfo/libmesh-users ```