Hi Paul,

I am wondering what is the right way to output a PetscVector in parallel 
mode. I copied a nonlinear system's solution into a PetscVector and 
wrote it into a file. I was using operator = for the assignment. While 
the PetscVector seemed correct in the memory, the output was wrong. The 
error was that the output contained only part of the vector that was 
distributed on one processor. My code is as follows:

     NonlinearImplicitSystem system;

     //Assign the vector v:
     Parallel::Communicator c;
     PetscVector<Real> v(c);
     v.init(*(system.solution));
     system.solution->close();
     v= *(system.solution); //assign v
     v.close();

     //Verify v:
     system.solution->l2_norm();         v.l2_norm();

     //Output the vector v:
     system.solution->print_global();
     v.print_global();
     v.localize_to_one( std::vector v2);
     cout << v2; //output the std:vector v2 on process id=0 only

The norms of system.solution and v were identical. So both of them 
seemed correct during the run time.

Their output differed: system.solution->print_global() returned a right 
result, but v.print_global() resulted in some correct values + a series 
of 0s.  When outputting v by v.localize_to_one(v2) and then outputting 
the std::vector v2, I got all 0s.

Did I miss any function calls in above?

Thanks,
Dafang


On 01/15/2014 09:21 PM, Paul T. Bauman wrote:
> I believe operator= will do the right thing. In particular, when you 
> call close() after setting the values, any communication that needs to 
> be done will get done. Be sure to run with METHOD=dbg or METHOD=devel 
> to trip any asserts that you might hit when you're debugging.
>
> Best,
>
> Paul
>
>
> On Wed, Jan 15, 2014 at 5:10 PM, Dafang Wang <[email protected] 
> <mailto:[email protected]>> wrote:
>
>     Hi Folks,
>
>     I have a nonlinear system and I want to set its current_local_solution
>     from a known vector, as follows:
>
>     NonlinearImplicitSystem system;
>     NumericVector v;
>     Set system.current_local_solution to be v;
>
>     How can I do this when the program is to be run in parallel? There are
>     ghost-node issues so I could not do the setting by standard c++
>     assignments. Does Libmesh provide a special function for this
>     operation?
>
>     Any comments will be well appreciated.
>
>     Thanks,
>     Dafang
>
>     --
>     Dafang Wang, Ph.D
>     Postdoctoral Fellow
>     Institute of Computational Medicine
>     Department of Biomedical Engineering
>     Johns Hopkins University
>     Hackerman Hall Room 218
>     Baltimore, MD, 21218
>
>     
> ------------------------------------------------------------------------------
>     CenturyLink Cloud: The Leader in Enterprise Cloud Services.
>     Learn Why More Businesses Are Choosing CenturyLink Cloud For
>     Critical Workloads, Development Environments & Everything In Between.
>     Get a Quote or Start a Free Trial Today.
>     
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
>     _______________________________________________
>     Libmesh-users mailing list
>     [email protected]
>     <mailto:[email protected]>
>     https://lists.sourceforge.net/lists/listinfo/libmesh-users
>
>

-- 
Dafang Wang, Ph.D
Postdoctoral Fellow
Institute of Computational Medicine
Department of Biomedical Engineering
Johns Hopkins University
Hackerman Hall Room 218
Baltimore, MD, 21218
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to