Dear all 

I am using dealii to solve a multi component system has its own fe, 
dofHandler, and solution vector. I am using a matrix free implementation 
for the entire program. 

I am using the Postprocessor class to derive quantities that depend on all 
of the components. 

The Postprocessor works fine in serial implementation. However, when trying 
to run using MPI the output is producing wrong results. 

I created a procedure to generate a joint solution vector and a joint 
handler following tutorial 32. However, this tutorial uses Trillinos 
vectors and I am using dealii’s own distributed vector and I am suspecting 
that this might be problem. 

Hence, my question is how to properly generate a joint solution vector 
while using dealii's distributed::vector class.


I have attached a text file that contains the procedure that was used to 
generate a the joint vector and I would appreciate if anyone would point 
out the mistakes that I made


Thank you 
​

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/c4beae48-c449-4b03-85df-1406bebc11dbn%40googlegroups.com.
        std::vector<vectorType> copy_solution_vectors;
        for (unsigned int i = 0; i < solution_set.size(); ++i)
        {
                vectorType copy_vector;
                LinearAlgebra::distributed::Vector<double> 
tmp(*solution_set[i]);
                copy_vector.reinit(dof_handler_set[i]->locally_owned_dofs(), 
*locally_relevant_dofs_set[i],triangulation.get_communicator());
                copy_vector.copy_locally_owned_data_from(tmp);
                constraints_set[i]->distribute(copy_vector);
                copy_vector.update_ghost_values();
                copy_solution_vectors.push_back(copy_vector);
        }

        // -----------------------------------
        // generate the combined dof handler
        // -----------------------------------
        const FESystem<dim> joint_fe(*fe_set[0],1,
                                                                 *fe_set[1],1,
                                                                 *fe_set[2],1,
                                                                 *fe_set[3],1);
        DoFHandler<dim> joint_dof_handler(triangulation);
        joint_dof_handler.distribute_dofs(joint_fe);
        Assert(joint_dof_handler.n_dofs() == total_degrees_of_freedom, 
ExcInternalError());
        // -----------------------------------
        // generate the combined solution vector
        // -----------------------------------
        vectorType joint_solution;
        joint_solution.reinit(joint_dof_handler.locally_owned_dofs(), 
triangulation.get_communicator());
        {
            std::vector<types::global_dof_index> 
local_joint_dof_indices(joint_fe.n_dofs_per_cell());
            std::vector<types::global_dof_index> 
local_temperature_dof_indices(fe_temperature->n_dofs_per_cell());
            std::vector<types::global_dof_index> 
local_displcamenet_dof_indices(fe_displacement->n_dofs_per_cell());
            std::vector<types::global_dof_index> 
local_concentration_dof_indices(fe_concentration->n_dofs_per_cell());
            std::vector<types::global_dof_index> 
local_eta_dof_indices(fe_eta->n_dofs_per_cell());

            typename DoFHandler<dim>::active_cell_iterator
                joint_cell         = joint_dof_handler.begin_active(),
                        joint_endc         = joint_dof_handler.end(),
                        temperature_cell   = 
dof_handler_temperature->begin_active(),
                displacement_cell  = dof_handler_displacement->begin_active(),
                        concentration_cell = 
dof_handler_concentration->begin_active(),
                        eta_cell           = dof_handler_eta->begin_active();
            for (; joint_cell != joint_endc;
                 ++joint_cell, ++temperature_cell, ++displacement_cell, 
++concentration_cell, ++eta_cell)
                if (joint_cell->is_locally_owned())
                {
                        joint_cell->get_dof_indices(local_joint_dof_indices);
                        
temperature_cell->get_dof_indices(local_temperature_dof_indices);
                        
displacement_cell->get_dof_indices(local_displcamenet_dof_indices);
                        
concentration_cell->get_dof_indices(local_concentration_dof_indices);
                        eta_cell->get_dof_indices(local_eta_dof_indices);

                        for (unsigned int i = 0; i < 
joint_fe.n_dofs_per_cell(); ++i)
                                if 
(joint_fe.system_to_base_index(i).first.first == 0)
                                {
                            Assert(joint_fe.system_to_base_index(i).first.first 
== 0, ExcInternalError());
                            Assert(joint_fe.system_to_base_index(i).second < 
local_temperature_dof_indices.size(),ExcInternalError());
                            joint_solution(local_joint_dof_indices[i]) =
                                        
copy_solution_vectors[0](local_temperature_dof_indices[joint_fe.system_to_base_index(i).second]);
                                }
                                else 
if(joint_fe.system_to_base_index(i).first.first == 1)
                                {
                                        
Assert(joint_fe.system_to_base_index(i).first.first == 1, ExcInternalError());
                            Assert(joint_fe.system_to_base_index(i).second < 
local_displcamenet_dof_indices.size(),ExcInternalError());
                            joint_solution(local_joint_dof_indices[i]) =
                                        
copy_solution_vectors[1](local_displcamenet_dof_indices[joint_fe.system_to_base_index(i).second]);
                                }
                                else 
if(joint_fe.system_to_base_index(i).first.first == 2)
                                {
                                        
Assert(joint_fe.system_to_base_index(i).first.first == 2, ExcInternalError());
                            Assert(joint_fe.system_to_base_index(i).second < 
local_concentration_dof_indices.size(),ExcInternalError());
                            joint_solution(local_joint_dof_indices[i]) =
                                        
copy_solution_vectors[2](local_concentration_dof_indices[joint_fe.system_to_base_index(i).second]);
                                }
                                else
                                {
                                        
Assert(joint_fe.system_to_base_index(i).first.first == 3, ExcInternalError());
                                        
Assert(joint_fe.system_to_base_index(i).second < 
local_eta_dof_indices.size(),ExcInternalError());
                                        
joint_solution(local_joint_dof_indices[i]) =
                                                        
copy_solution_vectors[3](local_eta_dof_indices[joint_fe.system_to_base_index(i).second]);
                                }
                }
        }
        joint_solution.compress(VectorOperation::insert);

        
        IndexSet locally_relevant_joint_dofs(joint_dof_handler.n_dofs());
        DoFTools::extract_locally_relevant_dofs(joint_dof_handler, 
locally_relevant_joint_dofs);

        vectorType locally_relevant_joint_solution;
        
locally_relevant_joint_solution.reinit(joint_dof_handler.locally_owned_dofs(),locally_relevant_joint_dofs,
 triangulation.get_communicator());
        
locally_relevant_joint_solution.copy_locally_owned_data_from(joint_solution);
        locally_relevant_joint_solution.update_ghost_values();
        
    Postprocessor postprocessor(analysis_data);
    DataOut<dim> data_out;
    data_out.attach_dof_handler(joint_dof_handler);
    data_out.add_data_vector(locally_relevant_joint_solution, postprocessor);
    data_out.build_patches();

Reply via email to