Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "AlbPUMI_NodeData.hpp"
00008
00009 Teuchos::RCP<Albany::AbstractNodeFieldContainer>
00010 AlbPUMI::buildPUMINodeField(const std::string& name, const std::vector<int>& dim, const bool output){
00011
00012 switch(dim.size()){
00013
00014 case 1:
00015 return Teuchos::rcp(new NodeData<double, 1>(name, dim, output));
00016 break;
00017
00018 case 2:
00019 return Teuchos::rcp(new NodeData<double, 2>(name, dim, output));
00020 break;
00021
00022 case 3:
00023 return Teuchos::rcp(new NodeData<double, 3>(name, dim, output));
00024 break;
00025
00026 default:
00027 TEUCHOS_TEST_FOR_EXCEPT_MSG(true, "Error: unexpected argument for dimension");
00028 }
00029 }
00030
00031
00032 template<typename DataType, unsigned ArrayDim, class traits>
00033 AlbPUMI::NodeData<DataType, ArrayDim, traits>::NodeData(const std::string& name_,
00034 const std::vector<int>& dim, const bool output_) :
00035 name(name_),
00036 output(output_),
00037 dims(dim),
00038 nfield_dofs(1),
00039 beginning_index(0)
00040 {
00041
00042 for(std::size_t i = 1; i < dims.size(); i++)
00043
00044 nfield_dofs *= dims[i];
00045
00046 }
00047
00048 template<typename DataType, unsigned ArrayDim, class traits>
00049 void
00050 AlbPUMI::NodeData<DataType, ArrayDim, traits>::resize(const Teuchos::RCP<const Epetra_Map>& local_node_map_){
00051
00052 local_node_map = local_node_map_;
00053 std::size_t total_size = local_node_map->NumMyElements() * nfield_dofs;
00054 buffer.resize(total_size);
00055
00056 beginning_index = 0;
00057
00058 }
00059
00060 template<typename DataType, unsigned ArrayDim, class traits>
00061 Albany::MDArray
00062 AlbPUMI::NodeData<DataType, ArrayDim, traits>::getMDA(const std::vector<apf::Node>& buck){
00063
00064 unsigned numNodes = buck.size();
00065
00066 field_type the_array = traits_type::buildArray(&buffer[beginning_index], numNodes, dims);
00067
00068 beginning_index += numNodes * nfield_dofs;
00069
00070 return the_array;
00071
00072 }
00073
00074 template<typename DataType, unsigned ArrayDim, class traits>
00075 void
00076 AlbPUMI::NodeData<DataType, ArrayDim, traits>::saveField(const Teuchos::RCP<const Epetra_Vector>& overlap_node_vec,
00077 int offset, int blocksize){
00078
00079 const Epetra_BlockMap& overlap_node_map = overlap_node_vec->Map();
00080 if(blocksize < 0)
00081 blocksize = overlap_node_map.ElementSize();
00082
00083
00084 for(std::size_t i = 0; i < local_node_map->NumMyElements(); i++) {
00085
00086 int node_gid = local_node_map->GID(i);
00087 int local_node = overlap_node_map.LID(node_gid);
00088 if(local_node < 0) continue;
00089 int block_start = local_node * blocksize;
00090
00091 for(std::size_t j = 0; j < nfield_dofs; j++)
00092
00093 buffer[i * nfield_dofs + j] = (*overlap_node_vec)[block_start + offset + j];
00094
00095 }
00096 }