Dear All,

I have found below in the mail-list in 2007 , while I am also trying to
find a way of how to initialize PETScWrappers::MPI::BlockSparseMatrix.

================================================

> 1 - A vector of size n_blocks, which contains vectors of size
> n_mpi_procs, which contain the local number of dofs on the mpi
> processes for a given block/component.  This would allow one to do
> something like block_local_dofs[i] (where i is a block/component
> number), and get a vector of local dof numbers to give
> mpi_sparse_matrix.reinit().
>
> 2 - A vector of size n_mpi_procs, which contains vectors of size
> n_blocks, which contain the local number of dofs of each block on
> that particular process.  This would allow one to do something like
> local_block_dofs[i] (where i is an mpi_process number), and get a
> vector containing the local number of dofs for each block on that
> process.  This is my understanding of what the the mpi block vectors
> need for reinit(block_size, comm, local_sizes).

Here is something for your second suggestion, completely untested. Try to put
this into dof_tools.h and dof_tools.cc and see if it does what you need (I
haven't even checked whether it compiles yet, so take a close look at whether
you can identify what it does and whether it does things correctly):
--------------------------------------
template <class DH>
void
DoFTools::count_dofs_per_subdomain_and_component (const DH
&dof_handler,
                                                  
std::vector<std::vector<unsigned int> > &result)
{
  std::vector<unsigned int> subdomain_association (dof_handler.n_dofs());
  get_subdomain_association (subdomain_association);

  const unsigned int n_subdomains = *std::max_element
(subdomain_association.begin(),
                                                       
subdomain_association.end());

  const unsigned int n_components = ::n_components(dof_handler);

                                   // check sizes of arguments
  Assert (result.size() == n_subdomains,
          ExcDimensionMismatch (result.size(), n_subdomains));
  for (unsigned int i=0; i<n_subdomains; ++i)
    Assert (results[i].size() == n_components,
            ExcDimensionMismatch (results[i].size(), n_components));

                                   // initialize output arguments to zero
  for (unsigned int i=0; i<n_subdomains; ++i)
    std::fill (result[i].begin(), result[i].end(), 0);

  std::vector<bool> dofs_for_component (dof_handler.n_dofs());
  for (unsigned int component=0; component<n_components; ++component)
    {
      std::vector<bool> component_mask (n_components, false);
      component_mask[component] = true;

      extract_dofs (dof_handler, dofs_for_component, component_mask);

      for (unsigned int i=0; i<dof_handler.n_dofs(); ++i)
        ++result[subdomain_association[i]][component];
    }
}
-------------------------------------
The code talks in terms of components and subdomains, not blocks and
n_mpi_procs, but I suppose that these are related for you.

If this works for you, let me know and I will put this in slightly polished
and documented form into the library!

Best
 Wolfgang

-------------------------------------------------------------------------
Wolfgang Bangerth                email:            bangerth at math.tamu.edu
                                 www: http://www.math.tamu.edu/~bangerth/

=================================================================


Could you make me clearer of how to use and initialize that matrix. Now.
document does not have this one.

Sungho


_______________________________________________

Reply via email to