void copy_vector_to_mesh( fei::Vector & vec, const DofMapper & dof, stk_classic::mesh::BulkData & mesh_bulk_data ) { vec.scatterToOverlap(); std::vector<int> shared_and_owned_indices; vec.getVectorSpace()->getIndices_SharedAndOwned(shared_and_owned_indices); size_t num_values = shared_and_owned_indices.size(); if(num_values == 0) { return; } std::vector<double> values(num_values); vec.copyOut(num_values,&shared_and_owned_indices[0],&values[0]); stk_classic::mesh::EntityRank ent_type; stk_classic::mesh::EntityId ent_id; const stk_classic::mesh::FieldBase * field; int offset_into_field; for(size_t i = 0; i < num_values; ++i) { dof.get_dof( shared_and_owned_indices[i], ent_type, ent_id, field, offset_into_field ); stk_classic::mesh::Entity & entity = *mesh_bulk_data.get_entity(ent_type, ent_id); void * data = stk_classic::mesh::field_data(*field,entity); if(!(field->type_is<double>()) || data == NULL) { std::ostringstream oss; oss << "stk_classic::linsys::copy_vector_to_mesh ERROR, bad data type, or "; oss << " field (" << field->name() << ") not found on entity with type " << entity.entity_rank(); oss << " and ID " << entity.identifier(); std::string str = oss.str(); throw std::runtime_error(str.c_str()); } double * double_data = reinterpret_cast<double *>(data); double_data[offset_into_field] = values[i]; } }