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<Number> & EDA = > equation_systems.parameters.set<std::vector<Number> > ("ElemDensity"); > const unsigned int NElem = mesh.n_elem(); > EDA.resize(NElem); > for (unsigned int i = 0; i < NElem; i++) { > EDA[i] = 1.0; > std::cout << EDA[i] << std::endl; > } > > 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<T>::print(std::ostream&) parameters.h:280: error: no match for 'operator<<' in 'os <<(...)' 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<T>::print(ostream&) for vector<T> but I don't have the time to or any desire mess with that at the moment. -- John ------------------------------------------------------------------------------ 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
