bool RichardsMultiphaseProblem::updateSolution(NumericVector<Number>& vec_solution, NumericVector<Number>& ghosted_solution) { bool updatedSolution = false; // this gets set to true if we needed to enforce the bound at any node unsigned int sys_num = getNonlinearSystem().number(); // For parallel procs i believe that i have to use local_nodes_begin, rather than just nodes_begin // _mesh comes from SystemBase (_mesh = getNonlinearSystem().subproblem().mesh(), and subproblem is this object) MeshBase::node_iterator nit = _mesh.getMesh().local_nodes_begin(); const MeshBase::node_iterator nend = _mesh.getMesh().local_nodes_end(); for ( ; nit != nend; ++nit) { const Node & node = *(*nit); // dofs[0] is the dof number of the bounded variable at this node // dofs[1] is the dof number of the lower variable at this node std::vector<unsigned int> dofs(2); dofs[0] = node.dof_number(sys_num, _bounded_var_num, 0); dofs[1] = node.dof_number(sys_num, _lower_var_num, 0); // soln[0] is the value of the bounded variable at this node // soln[1] is the value of the lower variable at this node std::vector<Number> soln(2); vec_solution.get(dofs, soln); // do the bounding if (soln[0] < soln[1]) { /* dof_id_type nd = node.id(); Moose::out << "nd = " << nd << " dof_bounded = " << dofs[0] << " dof_lower = " << dofs[1] << "\n"; Moose::out << " bounded_value = " << soln[0] << " lower_value = " << soln[1] << "\n"; */ vec_solution.set(dofs[0], soln[1]); // set the bounded variable equal to the lower value updatedSolution = true; } } // The above vec_solution.set calls potentially added "set" commands to a queue // The following actions the queue (doing MPI commands if necessary), so // vec_solution will actually be modified by this following command vec_solution.close(); // if any proc updated the solution, all procs will know about it _communicator.max(updatedSolution); if (updatedSolution) { ghosted_solution = vec_solution; ghosted_solution.close(); } return updatedSolution; }