Re: [Libmesh-users] Norm of a NumericVector for specific variable...

 Re: [Libmesh-users] Norm of a NumericVector for specific variable... From: Derek Gaston - 2008-11-05 23:29:25 ```On Nov 5, 2008, at 4:09 PM, Roy Stogner wrote: > In fact, I think we'll want to hand this norm off to NumericVector in > the end too, providing it with a cloned NumericVector whose > coefficients are set to the proper weights given in the SystemNorm, so > it just has to call the linear algebra package to pointwise multiply > and then take a norm. This makes sense to me. >> So... now my question is... is there a way to get a list of all of >> the DofIndices for a variable on a processor? Or am I going to >> have to loop over each element calling dof_map->dof_indices() and >> passing in the variable to build up this list? > > I don't see any way, no. Maybe Ben knows of something I'm forgetting. Hopefully. > But at least you won't have to loop over *every* element - you just > need to know which local DoFs belong to your variable. Right... just loop over local elements. Well... I guess I'll start writing something... Derek ```

 [Libmesh-users] Norm of a NumericVector for specific variable... From: Derek Gaston - 2008-11-05 22:09:41 ```Anyone have a good piece of code for computing a norm of just the piece of a NumericVector that corresponds to a specific variable number? My problem is that I have multiple variables in my system... but I need to get the norm of the residual for each one individually. Should we maybe extend the l2_norm(), l1_norm(), linfty_norm() functions to take an option variable number? Derek ```
 Re: [Libmesh-users] Norm of a NumericVector for specific variable... From: Roy Stogner - 2008-11-05 22:18:09 ``` On Wed, 5 Nov 2008, Derek Gaston wrote: > Anyone have a good piece of code for computing a norm of just the > piece of a NumericVector that corresponds to a specific variable > number? My problem is that I have multiple > variables in my system... but I need to get the norm of the residual > for each one individually. > > Should we maybe extend the l2_norm(), l1_norm(), linfty_norm() > functions to take an option variable number? Does the NumericVector class even have enough information to know which variable a coefficient belongs to? I'd hope it doesn't; I like modular code. I think what you want to modify is the SystemNorm class. Currently it assumes that you either want a weighted combination of Sobolev norms of different variables or a discrete norm of the entire vector. Extending it (and the classes that use it) to provide weighted discrete norms of particular combinations of variables within a vector should be straightforward. --- Roy ```
 Re: [Libmesh-users] Norm of a NumericVector for specific variable... From: Derek Gaston - 2008-11-05 22:57:07 ```Hmmm... I didn't even know that SystemNorm existed. After poking around to where it was used... it looks like a method already exists for what I want: System::calculate_norm(NumericVector& v, unsigned int var = 0, FEMNormType norm_type = L2) But like you say, that function assumes that if you want a discrete norm of the vector... that you want it of the entire vector. In fact... ultimately... NumericVector::norm_type() gets called. So... it looks like the function that should get modified is: System::calculate_norm(NumericVector& v, const SystemNorm &norm) Which is what the above one calls (which calls NumericVector::norm_type() ). So... now my question is... is there a way to get a list of all of the DofIndices for a variable on a processor? Or am I going to have to loop over each element calling dof_map->dof_indices() and passing in the variable to build up this list? Derek On Nov 5, 2008, at 3:17 PM, Roy Stogner wrote: > > > On Wed, 5 Nov 2008, Derek Gaston wrote: > >> Anyone have a good piece of code for computing a norm of just the >> piece of a NumericVector that corresponds to a specific variable >> number? My problem is that I have multiple >> variables in my system... but I need to get the norm of the residual >> for each one individually. >> >> Should we maybe extend the l2_norm(), l1_norm(), linfty_norm() >> functions to take an option variable number? > > Does the NumericVector class even have enough information to know > which variable a coefficient belongs to? I'd hope it doesn't; I like > modular code. > > I think what you want to modify is the SystemNorm class. Currently it > assumes that you either want a weighted combination of Sobolev norms > of different variables or a discrete norm of the entire vector. > Extending it (and the classes that use it) to provide weighted > discrete norms of particular combinations of variables within a vector > should be straightforward. > --- > Roy ```
 Re: [Libmesh-users] Norm of a NumericVector for specific variable... From: Roy Stogner - 2008-11-05 23:09:20 ```On Wed, 5 Nov 2008, Derek Gaston wrote: > Hmmm... I didn't even know that SystemNorm existed. After poking around to > where it was used... it looks like a method already exists for what I want: > > System::calculate_norm(NumericVector& v, unsigned int var = 0, > FEMNormType norm_type = L2) Right. System has its hands on the DofMap, so it can do exactly what you want without any change in the classes' interdependence. > But like you say, that function assumes that if you want a discrete norm of > the vector... that you want it of the entire vector. In fact... > ultimately... NumericVector::norm_type() gets called. Hey, what did you want me to do, reinvent the wheel? ;-) In fact, I think we'll want to hand this norm off to NumericVector in the end too, providing it with a cloned NumericVector whose coefficients are set to the proper weights given in the SystemNorm, so it just has to call the linear algebra package to pointwise multiply and then take a norm. > So... now my question is... is there a way to get a list of all of the > DofIndices for a variable on a processor? Or am I going to have to loop over > each element calling dof_map->dof_indices() and passing in the variable to > build up this list? I don't see any way, no. Maybe Ben knows of something I'm forgetting. But at least you won't have to loop over *every* element - you just need to know which local DoFs belong to your variable. --- Roy ```
 Re: [Libmesh-users] Norm of a NumericVector for specific variable... From: Derek Gaston - 2008-11-05 23:29:25 ```On Nov 5, 2008, at 4:09 PM, Roy Stogner wrote: > In fact, I think we'll want to hand this norm off to NumericVector in > the end too, providing it with a cloned NumericVector whose > coefficients are set to the proper weights given in the SystemNorm, so > it just has to call the linear algebra package to pointwise multiply > and then take a norm. This makes sense to me. >> So... now my question is... is there a way to get a list of all of >> the DofIndices for a variable on a processor? Or am I going to >> have to loop over each element calling dof_map->dof_indices() and >> passing in the variable to build up this list? > > I don't see any way, no. Maybe Ben knows of something I'm forgetting. Hopefully. > But at least you won't have to loop over *every* element - you just > need to know which local DoFs belong to your variable. Right... just loop over local elements. Well... I guess I'll start writing something... Derek ```