Skip to content

Commit

Permalink
Use consistent formatting in all for loops.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwpeterson committed Mar 10, 2014
1 parent 0a6a97f commit 1750657
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 39 deletions.
24 changes: 12 additions & 12 deletions src/mesh/exodusII_io.C
Original file line number Diff line number Diff line change
Expand Up @@ -555,20 +555,20 @@ void ExodusII_IO::write_element_data (const EquationSystems & es)
// of the values in soln
std::vector<Real> complex_soln(3*num_values);

for(unsigned i(0); i < num_vars; ++i)
for (unsigned i=0; i<num_vars; ++i)
{

for(unsigned int j(0); j < num_elems; ++j)
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + j] = value.real();
}
for(unsigned int j(0); j < num_elems; ++j)
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + num_elems +j] = value.imag();
}
for(unsigned int j(0); j < num_elems; ++j)
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + 2*num_elems + j] = std::abs(value);
Expand Down Expand Up @@ -640,7 +640,7 @@ void ExodusII_IO::write_nodal_data (const std::string& fname,
std::vector<Real> imag_parts(num_nodes);
std::vector<Real> magnitudes(num_nodes);

for(unsigned int i(0); i < num_nodes; ++i)
for (unsigned int i=0; i<num_nodes; ++i)
{
real_parts[i] = soln[i*num_vars + c].real();
imag_parts[i] = soln[i*num_vars + c].imag();
Expand All @@ -653,7 +653,7 @@ void ExodusII_IO::write_nodal_data (const std::string& fname,
std::vector<Number> cur_soln(num_nodes);

// Copy out this variable's solution
for(dof_id_type i=0; i<num_nodes; i++)
for (dof_id_type i=0; i<num_nodes; i++)
cur_soln[i] = soln[i*num_vars + c];
exio_helper->write_nodal_values(variable_name_position+1,cur_soln,_timestep);
#endif
Expand Down Expand Up @@ -712,20 +712,20 @@ void ExodusII_IO::write_global_data (const std::vector<Number>& soln,
// of the values in soln
std::vector<Real> complex_soln(3*num_values);

for(unsigned i(0); i < num_vars; ++i)
for (unsigned i=0; i<num_vars; ++i)
{

for(unsigned int j(0); j < num_elems; ++j)
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + j] = value.real();
}
for(unsigned int j(0); j < num_elems; ++j)
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + num_elems +j] = value.imag();
}
for(unsigned int j(0); j < num_elems; ++j)
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + 2*num_elems + j] = std::abs(value);
Expand Down Expand Up @@ -839,7 +839,7 @@ void ExodusII_IO::write_nodal_data_discontinuous (const std::string& fname,
std::vector<Real> imag_parts(num_nodes);
std::vector<Real> magnitudes(num_nodes);

for(int i(0); i < num_nodes; ++i)
for (int i=0; i<num_nodes; ++i)
{
real_parts[i] = soln[i*num_vars + c].real();
imag_parts[i] = soln[i*num_vars + c].imag();
Expand All @@ -852,7 +852,7 @@ void ExodusII_IO::write_nodal_data_discontinuous (const std::string& fname,
// Copy out this variable's solution
std::vector<Number> cur_soln(num_nodes);

for(int i=0; i<num_nodes; i++)
for (int i=0; i<num_nodes; i++)
cur_soln[i] = soln[i*num_vars + c];

exio_helper->write_nodal_values(c+1,cur_soln,_timestep);
Expand Down
14 changes: 8 additions & 6 deletions src/mesh/exodusII_io_helper.C
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,9 @@ void ExodusII_IO_Helper::create(std::string filename)
// call create there.
if ((this->processor_id() == 0) || (!_run_only_on_proc0))
{
int comp_ws(0), io_ws(0);
int
comp_ws = 0,
io_ws = 0;

if(_single_precision)
{
Expand Down Expand Up @@ -1153,7 +1155,7 @@ void ExodusII_IO_Helper::write_nodal_coordinates(const MeshBase & mesh, bool use
if(_single_precision)
{
std::vector<float> x_single(num_nodes), y_single(num_nodes), z_single(num_nodes);
for(int i(0); i < num_nodes; ++i)
for (int i=0; i<num_nodes; ++i)
{
x_single[i] = static_cast<float>(x[i]);
y_single[i] = static_cast<float>(y[i]);
Expand Down Expand Up @@ -1647,7 +1649,7 @@ void ExodusII_IO_Helper::write_element_values(const MeshBase & mesh, const std::
if(_single_precision)
{
std::vector<float> cast_data(num_elems_this_block);
for(unsigned int l=0; l < num_elems_this_block; ++l)
for (unsigned int l=0; l<num_elems_this_block; ++l)
{
cast_data[l] = static_cast<float>(data[l]);
}
Expand Down Expand Up @@ -1686,7 +1688,7 @@ void ExodusII_IO_Helper::write_nodal_values(int var_id, const std::vector<Real>
{
unsigned int num_values = values.size();
std::vector<float> cast_values(num_values);
for(unsigned int i(0); i < num_values; ++i)
for (unsigned int i=0; i<num_values; ++i)
{
cast_values[i] = static_cast<float>(values[i]);
}
Expand Down Expand Up @@ -1753,7 +1755,7 @@ void ExodusII_IO_Helper::write_global_values(const std::vector<Real> & values, i
unsigned int num_values = values.size();
std::vector<float> cast_values(num_values);

for(unsigned int i(0); i < num_values; ++i)
for (unsigned int i=0; i<num_values; ++i)
cast_values[i] = static_cast<float>(values[i]);

ex_err = exII::ex_put_glob_vars(ex_id, timestep, num_global_vars, &cast_values[0]);
Expand Down Expand Up @@ -1790,7 +1792,7 @@ std::vector<std::string> ExodusII_IO_Helper::get_complex_names(const std::vector

// This will loop over all names and create new "complex" names
// (i.e. names that start with r_, i_ or a_
for(; names_it != names_end; ++names_it)
for (; names_it != names_end; ++names_it)
{
std::cout << "VARIABLE: " << *names_it << std::endl;
std::stringstream name_real, name_imag, name_abs;
Expand Down
11 changes: 5 additions & 6 deletions src/mesh/nemesis_io.C
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ void Nemesis_IO::read (const std::string& base_filename)
nemhelper->read_nodeset(nodeset);

// Add nodes from the node_list to the BoundaryInfo object
for(unsigned int node=0; node<nemhelper->node_list.size(); node++)
for (unsigned int node=0; node<nemhelper->node_list.size(); node++)
{
// Don't run past the end of our node map!
if (to_uint(nemhelper->node_list[node]-1) >= nemhelper->node_num_map.size())
Expand Down Expand Up @@ -1358,20 +1358,19 @@ void Nemesis_IO::write_global_data (const std::vector<Number>& soln,
// of the values in soln
std::vector<Real> complex_soln(3*num_values);

for(unsigned i(0); i < num_vars; ++i)
for (unsigned i=0; i<num_vars; ++i)
{

for(unsigned int j(0); j < num_elems; ++j)
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + j] = value.real();
}
for(unsigned int j(0); j < num_elems; ++j)
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + num_elems +j] = value.imag();
}
for(unsigned int j(0); j < num_elems; ++j)
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + 2*num_elems + j] = std::abs(value);
Expand Down
32 changes: 17 additions & 15 deletions src/mesh/nemesis_io_helper.C
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,9 @@ void Nemesis_IO_Helper::create(std::string filename)
{
// Fall back on double precision when necessary since ExodusII
// doesn't seem to support long double
int comp_ws(0), io_ws(0);
int
comp_ws = 0,
io_ws = 0;

if(_single_precision)
{
Expand Down Expand Up @@ -1771,9 +1773,9 @@ void Nemesis_IO_Helper::build_element_and_node_maps(const MeshBase& pmesh)
this->libmesh_node_num_to_exodus.clear();

// Set the map for nodes
for(std::set<int>::iterator it = this->nodes_attached_to_local_elems.begin();
it != this->nodes_attached_to_local_elems.end();
++it)
for (std::set<int>::iterator it = this->nodes_attached_to_local_elems.begin();
it != this->nodes_attached_to_local_elems.end();
++it)
{
// I.e. given exodus_node_id,
// exodus_node_num_to_libmesh[ exodus_node_id ] returns the libmesh ID for that node.
Expand All @@ -1796,9 +1798,9 @@ void Nemesis_IO_Helper::build_element_and_node_maps(const MeshBase& pmesh)
this->libmesh_elem_num_to_exodus.clear();

// Now loop over each subdomain and get a unique numbering for the elements
for(std::map<subdomain_id_type, std::vector<unsigned int> >::iterator it = this->subdomain_map.begin();
it != this->subdomain_map.end();
++it)
for (std::map<subdomain_id_type, std::vector<unsigned int> >::iterator it = this->subdomain_map.begin();
it != this->subdomain_map.end();
++it)
{
block_ids.push_back((*it).first);

Expand Down Expand Up @@ -2054,9 +2056,9 @@ void Nemesis_IO_Helper::write_nodesets(const MeshBase & mesh)
// See what we got
if (verbose)
{
for(std::map<boundary_id_type, std::vector<int> >::iterator it = local_node_boundary_id_lists.begin();
it != local_node_boundary_id_lists.end();
++it)
for (std::map<boundary_id_type, std::vector<int> >::iterator it = local_node_boundary_id_lists.begin();
it != local_node_boundary_id_lists.end();
++it)
{
libMesh::out << "[" << this->processor_id() << "] ID: " << (*it).first << ", ";

Expand Down Expand Up @@ -2184,7 +2186,7 @@ void Nemesis_IO_Helper::write_sidesets(const MeshBase & mesh)
// Loop over all the elements in the family tree, store their converted IDs
// and side IDs to the map's vectors. TODO: Somehow reserve enough space for these
// push_back's...
for(unsigned int j=0; j<family.size(); ++j)
for (unsigned int j=0; j<family.size(); ++j)
{
const ExodusII_IO_Helper::Conversion conv = em.assign_conversion(mesh.elem(family[j]->id())->type());

Expand Down Expand Up @@ -2313,7 +2315,7 @@ void Nemesis_IO_Helper::write_nodal_coordinates(const MeshBase & mesh, bool /*us
if(_single_precision)
{
std::vector<float> x_single(local_num_nodes), y_single(local_num_nodes), z_single(local_num_nodes);
for(unsigned int i(0); i < local_num_nodes; ++i)
for (unsigned int i=0; i<local_num_nodes; ++i)
{
x_single[i] = static_cast<float>(x[i]);
y_single[i] = static_cast<float>(y[i]);
Expand Down Expand Up @@ -2428,7 +2430,7 @@ void Nemesis_IO_Helper::write_nodal_solution
std::vector<Real> imag_parts(num_nodes);
std::vector<Real> magnitudes(num_nodes);

for(int i(0); i < num_nodes; ++i)
for (int i=0; i<num_nodes; ++i)
{
Number value = values[this->exodus_node_num_to_libmesh[i]*num_vars + c];
real_parts[i] = value.real();
Expand All @@ -2441,8 +2443,8 @@ void Nemesis_IO_Helper::write_nodal_solution
#else
std::vector<Number> cur_soln(num_nodes);

//Copy out this variable's solution
for(int i=0; i<num_nodes; i++)
// Copy out this variable's solution
for (int i=0; i<num_nodes; i++)
cur_soln[i] = values[this->exodus_node_num_to_libmesh[i]*num_vars + c];

write_nodal_values(c+1,cur_soln,timestep);
Expand Down

0 comments on commit 1750657

Please sign in to comment.