With a little more work, Parameters can hold any type including std  
containers. What you need to do is create a template specialization for  
that print method so that the compiler knows how to print your specific  
type. After that you've done that, the code you posted earlier should work.  
You can stick much more complicated data structures into Parameters too -  
such as containers of containers...

Cody

On Apr 14, 2011 8:51pm, 蔡园武 <[email protected]> wrote:
> Thanks, John,

> but I don't think it's just the print error, because if I comment the

> std::cout sentence, the error message is the same. It seems that  
> Parameters

> only can hold basic values like int or Real, not the compound type like

> vector.

> If it is so, I must transfer the vector to other functions as an actual

> parameter besides equation_systems and system_name.



> 2011/4/15 John Peterson [email protected]>



> > 2011/4/13 蔡园武 [email protected]>:

> > > I have faced some problems in my code, and need your help.

> > >

> > > 1. I see that the user can pass parameters into equation_systems, so  
> they

> > > can be retrieved in other functions. But when I want to pass a vector  
> or

> > > matrix, it won't work:

> > >

> > > std::vector & EDA =

> > > equation_systems.parameters.set > ("ElemDensity");

> > > const unsigned int NElem = mesh.n_elem();

> > > EDA.resize(NElem);

> > > for (unsigned int i = 0; i
> > > EDA[i] = 1.0;

> > > std::cout
> > > }

> > >

> > > Where am I wrong? How can I achieve my purpose?

> >

> > Are you seeing a compiler error or runtime error? On my system,

> > attempting to put std::vectors into a Parameters object gives a

> > compile error:

> >

> > in void libMesh::Parameters::Parameter::print(std::ostream&)

> > parameters.h:280: error: no match for 'operator
> >

> > Since you can't print a vector this way. This seems like an

> > unnecessary limitation on the Parameters class, we could possibly fix

> > it by specializing Parameter::print(ostream&) for vector but I

> > don't have the time to or any desire mess with that at the moment.

> >

> > --

> > John

> >







> --

> Cai Yuanwu 蔡园武

> Dept. of Engineering Mechanics,

> Dalian University of Technology,

> Dalian 116024, China

> ------------------------------------------------------------------------------

> Benefiting from Server Virtualization: Beyond Initial Workload

> Consolidation -- Increasing the use of server virtualization is a top

> priority.Virtualization can reduce costs, simplify management, and improve

> application availability and disaster protection. Learn more about  
> boosting

> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev

> _______________________________________________

> Libmesh-users mailing list

> [email protected]

> https://lists.sourceforge.net/lists/listinfo/libmesh-users

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to