[deal.II] affine representation

2017-12-18 Thread Jean Ragusa
Hi,

I am solving a linear system (say linear heat conduction) with many 
different materials (blockID) whose material properties are uncertain. 

My goal is to use a RB approach to build the ROM. However, while building 
the snapshots, for every new sample, I need to reassemble the system 
matrix. This operation can become quite costly when repeated many times.

It would be better to exploit the affine representation of my problem. To 
make this simple, I am only describing the 2-material case. Suppose I have 
a block ID for each material. The global stiffness matrix  is K = k1 K1 + 
k2 K2,
where k1,k2 are the conductivities of materials 1/2 and K1 is the stiffness 
matrix built with a *unit* conductivity in regions where material 1 is 
present and a similar definition for K2. The size of each matrix is n 
(total ndofs). But their number of nonzero entries (nnz) depends on how 
many cells are in each material region. If you extrapolate this to 1000 
materials, it is clear that I do not want to allocate the memory for 1000  
Ki matrices based on the total ndofs in the system. I would like to create 
each Ki matrix with just enough memory for each material region. 

So, is there a way to do this in deal?

Thanks
--jean

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[deal.II] L2 norm of distribution solution

2019-03-01 Thread Jean Ragusa
Hi,

I have a solution vector with locally owned and locally relevant dofs. I 
want to compute its L2-norm. Using the l2_norm() on it caused a Trilinos 
error (I was going to compute the squared of the L2 norm, then do an MPI 
Allreduce on the resulting values).

So, I decided to code it "by hand" as follows: 

double norm_squared = 0.;
const unsigned int start_ = (dist_solution.local_range().first), end_ = 
(dist_solution.local_range().second);

for (unsigned int i = start_; i < end_; ++i)
   norm_squared += std::pow(dist_solution(i),2);

double norm_global =0.;
MPI_Allreduce(_squared, _global, 1, MPI_DOUBLE, MPI_SUM, 
mpi_communicator);
norm_global = std::sqrt(norm_global);


Even though this works, I was wondering if there is a better way to do 
this? 

Cheers,
--jean


-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] L2 norm of distribution solution

2019-03-03 Thread Jean Ragusa
Thanks Wolfgang.I am just replying to add a couple of details that were not 
100% obvious to me. Maybe someone else will benefit from this when the 
search the post archive...

As Wolfgang stated, copying the vector that contains ghosted values 
(relevant dofs) into a completely distributed vector allows you to use 
l2_norm() on it.What I didn't realize is that the l2_norm() on a 
distributed vector calls the MPI_Allreduce behind the scene and thus no 
additional action is needed when writing your own code.


On Saturday, March 2, 2019 at 10:28:03 AM UTC-6, Wolfgang Bangerth wrote:
>
> On 3/1/19 8:54 PM, Jean Ragusa wrote: 
> > 
> > I have a solution vector with locally owned and locally relevant dofs. I 
> want 
> > to compute its L2-norm. Using the l2_norm() on it caused a Trilinos 
> error (I 
> > was going to compute the squared of the L2 norm, then do an MPI 
> Allreduce on 
> > the resulting values). 
> > 
> > So, I decided to code it "by hand" as follows: 
> > 
> > double norm_squared = 0.; 
> > const unsigned int start_ = (dist_solution.local_range().first), end_ = 
> > (dist_solution.local_range().second); 
> > 
> > for (unsigned int i = start_; i < end_; ++i) 
> > norm_squared += std::pow(dist_solution(i),2); 
> > 
> > double norm_global =0.; 
> > MPI_Allreduce(_squared, _global, 1, MPI_DOUBLE, MPI_SUM, 
> > mpi_communicator); 
> > norm_global = std::sqrt(norm_global); 
> > 
> > 
> > Even though this works, I was wondering if there is a better way to do 
> this? 
>
> Yes! Create a completely distributed vector, copy your ghosted vector into 
> it, 
> and then compute the l2 norm of that completely distributed vector. That's 
> going to cost a bit of communication, but I suspect you're not doing it 
> often 
> enough to actually feel the difference :-) 
>
> Cheers 
>   W. 
>
> -- 
>  
> Wolfgang Bangerth  email: bang...@colostate.edu 
>  
> www: http://www.math.colostate.edu/~bangerth/ 
>
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.