From: wolf Date: Mon, 21 Oct 2002 14:17:31 +0000 (+0000) Subject: Use Table objects instead of vectors of vectors. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1cf51f0fbed0f154b1385f74dce9121385a95103;p=dealii-svn.git Use Table objects instead of vectors of vectors. git-svn-id: https://svn.dealii.org/trunk@6692 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/data_out_base.h b/deal.II/base/include/base/data_out_base.h index 48c88b0755..aab724c0ec 100644 --- a/deal.II/base/include/base/data_out_base.h +++ b/deal.II/base/include/base/data_out_base.h @@ -18,6 +18,7 @@ #include #include #include + #include #include @@ -1529,15 +1530,16 @@ class DataOutBase * thus moved into this separate * function. * - * Note that because of the close - * similarity of the two formats, + * Note that because of the + * similarity of the formats, * this function is also used by - * the Vtk output function. + * the Vtk and Tecplot output + * functions. */ template static void write_gmv_reorder_data_vectors (const std::vector > &patches, - std::vector > &data_vectors); + Table<2,double> &data_vectors); }; diff --git a/deal.II/base/source/data_out_base.cc b/deal.II/base/source/data_out_base.cc index 34bd75ee8e..8a192e48bb 100644 --- a/deal.II/base/source/data_out_base.cc +++ b/deal.II/base/source/data_out_base.cc @@ -2086,11 +2086,10 @@ void DataOutBase::write_gmv (const std::vector > &patches, // separate thread and when wanting // to write out the data, we wait // for that thread to finish - std::vector > data_vectors (n_data_sets, - std::vector (n_nodes)); + Table<2,double> data_vectors (n_data_sets, n_nodes); Threads::ThreadManager thread_manager; void (*fun_ptr) (const std::vector > &, - std::vector > &) + Table<2,double> &) = &DataOutBase::template write_gmv_reorder_data_vectors; Threads::spawn (thread_manager, Threads::encapsulate (fun_ptr) @@ -2443,229 +2442,229 @@ void DataOutBase::write_tecplot (const std::vector > &patche }; }; - - // in Tecplot FEBLOCK format the vertex - // coordinates and the data have an - // order that is a bit unpleasant - // (first all x coordinates, then - // all y coordinate, ...; first all - // data of variable 1, then - // variable 2, etc), so we have to - // copy the data vectors a bit around - // - // note that we copy vectors when - // looping over the patches since we - // have to write them one variable - // at a time and don't want to use - // more than one loop - // - // this copying of data vectors can - // be done while we already output - // the vertices, so do this on a - // separate thread and when wanting - // to write out the data, we wait - // for that thread to finish - std::vector > data_vectors (n_data_sets, - std::vector (n_nodes)); - Threads::ThreadManager thread_manager; - void (*fun_ptr) (const std::vector > &, - std::vector > &) - = &DataOutBase::template write_gmv_reorder_data_vectors; - Threads::spawn (thread_manager, - Threads::encapsulate (fun_ptr) - .collect_args(patches, data_vectors)); + // in Tecplot FEBLOCK format the vertex + // coordinates and the data have an + // order that is a bit unpleasant + // (first all x coordinates, then + // all y coordinate, ...; first all + // data of variable 1, then + // variable 2, etc), so we have to + // copy the data vectors a bit around + // + // note that we copy vectors when + // looping over the patches since we + // have to write them one variable + // at a time and don't want to use + // more than one loop + // + // this copying of data vectors can + // be done while we already output + // the vertices, so do this on a + // separate thread and when wanting + // to write out the data, we wait + // for that thread to finish + + Table<2,double> data_vectors (n_data_sets, n_nodes); - /////////////////////////////// - // first make up a list of used - // vertices along with their - // coordinates + Threads::ThreadManager thread_manager; + void (*fun_ptr) (const std::vector > &, + Table<2,double> &) + = &DataOutBase::template write_gmv_reorder_data_vectors; + Threads::spawn (thread_manager, + Threads::encapsulate (fun_ptr) + .collect_args(patches, data_vectors)); + + /////////////////////////////// + // first make up a list of used + // vertices along with their + // coordinates - for (unsigned int d=1; d<=spacedim; ++d) - { + for (unsigned int d=1; d<=spacedim; ++d) + { - for (typename std::vector >::const_iterator patch=patches.begin(); - patch!=patches.end(); ++patch) - { - const unsigned int n_subdivisions = patch->n_subdivisions; + for (typename std::vector >::const_iterator patch=patches.begin(); + patch!=patches.end(); ++patch) + { + const unsigned int n_subdivisions = patch->n_subdivisions; - switch (dim) - { - case 1: - { - for (unsigned int i=0; ivertices[1](0) * i / n_subdivisions) + - (patch->vertices[0](0) * (n_subdivisions-i) / n_subdivisions)) - << '\n'; - break; - }; + switch (dim) + { + case 1: + { + for (unsigned int i=0; ivertices[1](0) * i / n_subdivisions) + + (patch->vertices[0](0) * (n_subdivisions-i) / n_subdivisions)) + << '\n'; + break; + }; - case 2: - { - for (unsigned int i=0; ivertices[1](d-1) * x_frac) + - (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) + - ((patch->vertices[2](d-1) * x_frac) + - (patch->vertices[3](d-1) * (1-x_frac))) * y_frac) - << '\n'; - }; - break; - }; + // compute coordinates for + // this patch point + + out << (((patch->vertices[1](d-1) * x_frac) + + (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) + + ((patch->vertices[2](d-1) * x_frac) + + (patch->vertices[3](d-1) * (1-x_frac))) * y_frac) + << '\n'; + }; + break; + }; - case 3: - { - for (unsigned int i=0; ivertices[1](d-1) * x_frac) + - (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) + - ((patch->vertices[2](d-1) * x_frac) + - (patch->vertices[3](d-1) * (1-x_frac))) * y_frac) * (1-z_frac) + - (((patch->vertices[5](d-1) * x_frac) + - (patch->vertices[4](d-1) * (1-x_frac))) * (1-y_frac) + - ((patch->vertices[6](d-1) * x_frac) + - (patch->vertices[7](d-1) * (1-x_frac))) * y_frac) * z_frac) - << '\n'; - }; - break; - }; + out << ((((patch->vertices[1](d-1) * x_frac) + + (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) + + ((patch->vertices[2](d-1) * x_frac) + + (patch->vertices[3](d-1) * (1-x_frac))) * y_frac) * (1-z_frac) + + (((patch->vertices[5](d-1) * x_frac) + + (patch->vertices[4](d-1) * (1-x_frac))) * (1-y_frac) + + ((patch->vertices[6](d-1) * x_frac) + + (patch->vertices[7](d-1) * (1-x_frac))) * y_frac) * z_frac) + << '\n'; + }; + break; + }; - default: - Assert (false, ExcNotImplemented()); - }; - }; - out << std::endl; - }; + default: + Assert (false, ExcNotImplemented()); + }; + }; + out << std::endl; + }; - /////////////////////////////////////// - // data output. - // - // now write the data vectors to - // @p{out} first make sure that all - // data is in place - thread_manager.wait (); + /////////////////////////////////////// + // data output. + // + // now write the data vectors to + // @p{out} first make sure that all + // data is in place + thread_manager.wait (); - // then write data. - for (unsigned int data_set=0; data_set(out, "\n")); - out << std::endl; - }; + copy(data_vectors[data_set].begin(), + data_vectors[data_set].end(), + std::ostream_iterator(out, "\n")); + out << std::endl; + }; - ///////////////////////////////// - // now for the cells. note that - // vertices are counted from 1 onwards + ///////////////////////////////// + // now for the cells. note that + // vertices are counted from 1 onwards - unsigned int first_vertex_of_patch = 0; + unsigned int first_vertex_of_patch = 0; - for (typename std::vector >::const_iterator patch=patches.begin(); - patch!=patches.end(); ++patch) - { - const unsigned int n_subdivisions = patch->n_subdivisions; + for (typename std::vector >::const_iterator patch=patches.begin(); + patch!=patches.end(); ++patch) + { + const unsigned int n_subdivisions = patch->n_subdivisions; - // write out the cells making - // up this patch - switch (dim) - { - case 1: - { - break; - }; - case 2: - { - for (unsigned int i=0; i > // to write out the data, we wait // for that thread to finish - std::vector > data_vectors (n_data_sets, - std::vector (n_nodes)); + Table<2,double> data_vectors (n_data_sets, n_nodes); + Threads::ThreadManager thread_manager; void (*fun_ptr) (const std::vector > &, - std::vector > &) + Table<2,dim> &) = &DataOutBase::template write_gmv_reorder_data_vectors; Threads::spawn (thread_manager, Threads::encapsulate (fun_ptr) @@ -3217,11 +3216,11 @@ void DataOutBase::write_vtk (const std::vector > &patches, // separate thread and when wanting // to write out the data, we wait // for that thread to finish - std::vector > data_vectors (n_data_sets, - std::vector (n_nodes)); + Table<2,double> data_vectors (n_data_sets, n_nodes); + Threads::ThreadManager thread_manager; void (*fun_ptr) (const std::vector > &, - std::vector > &) + Table<2,double> &) = &DataOutBase::template write_gmv_reorder_data_vectors; Threads::spawn (thread_manager, Threads::encapsulate (fun_ptr) @@ -3456,7 +3455,7 @@ void DataOutBase::write_vtk (const std::vector > &patches, template void DataOutBase::write_gmv_reorder_data_vectors (const std::vector > &patches, - std::vector > &data_vectors) + Table<2,double> &data_vectors) { // unlike in the main function, we // don't have here the data_names @@ -3467,7 +3466,7 @@ DataOutBase::write_gmv_reorder_data_vectors (const std::vector #include +#include +#include template @@ -167,23 +168,18 @@ void PolynomialSpace::compute( } // Store data in a single - // vector. Access is by + // object. Access is by // v[d][n][o] // d: coordinate direction // n: number of 1d polynomial // o: order of derivative - std::vector > > - v(dim, - std::vector > (n_1d, - std::vector (v_size, 0.))); - - for (unsigned int d=0; d >& v_d=v[d]; - Assert(v_d.size()==n_1d, ExcInternalError()); - for (unsigned int i=0; i > v(dim, n_1d); + for (unsigned int d=0; d::compute( { for (unsigned int d=0;d1) ? v[1][iy][(d==1) ? 1 : 0] : 1.) - * ((dim>2) ? v[2][iz][(d==2) ? 1 : 0] : 1.); + * ((dim>1) ? v[1][iy][(d==1) ? 1 : 0] : 1.) + * ((dim>2) ? v[2][iz][(d==2) ? 1 : 0] : 1.); ++k; } } diff --git a/deal.II/base/source/table_handler.cc b/deal.II/base/source/table_handler.cc index 4009e03d17..934431d84f 100644 --- a/deal.II/base/source/table_handler.cc +++ b/deal.II/base/source/table_handler.cc @@ -13,6 +13,7 @@ #include +#include #ifdef HAVE_STD_STRINGSTREAM # include @@ -123,8 +124,8 @@ void TableHandler::add_column_to_supercolumn (const std::string &key, if (!supercolumns.count(superkey)) { - std::pair > new_column(superkey, - std::vector()); + std::pair > + new_column(superkey, std::vector()); supercolumns.insert(new_column); // replace key in column_order // by superkey @@ -225,8 +226,7 @@ void TableHandler::write_text(std::ostream &out) const // first compute the widths of each // entry of the table, in order to // have a nicer alignement - std::vector > - entry_widths (nrows, std::vector(n_cols)); + Table<2,unsigned int> entry_widths (nrows, n_cols); for (unsigned int i=0; i #include +#include +#include + @@ -50,9 +52,12 @@ TensorProductPolynomials::compute_grad(const unsigned int i, const Point &p) const { const unsigned int n_pols=polynomials.size(); - - std::vector > v(dim, std::vector (2)); + // compute values and + // uni-directional derivatives at + // the given point in each + // co-ordinate direction + std::vector > v(dim, std::vector (2)); for (unsigned int d=0; d::compute( v_size=3; } - std::vector > > v( - dim, std::vector > (n_pols, std::vector (v_size))); - - for (unsigned int d=0; d > &v_d=v[d]; - Assert(v_d.size()==n_pols, ExcInternalError()); - for (unsigned int i=0; i > v(dim, n_pols); + for (unsigned int d=0; d